summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Pawlowski <jpawlowski@google.com>2016-07-28 05:19:11 -0700
committerJakub Pawlowski <jpawlowski@google.com>2016-11-10 12:23:45 -0800
commite3b6e8187e63374e225d21b1992f6c8224a3f408 (patch)
tree1bd42ec408adcdf9a0bbd016b9b6318ac8115471
parent119ceb8282e8b6acc67efbc012506238d637101d (diff)
downloadandroid_packages_apps_Bluetooth-e3b6e8187e63374e225d21b1992f6c8224a3f408.tar.gz
android_packages_apps_Bluetooth-e3b6e8187e63374e225d21b1992f6c8224a3f408.tar.bz2
android_packages_apps_Bluetooth-e3b6e8187e63374e225d21b1992f6c8224a3f408.zip
Add LE Secure Connection data parsing (2/4)
Bug: 30460956 Change-Id: Ie5c3ad96e7a834c9dc0a6791cf2cd24ecaeb927e (cherry picked from commit 1d768333363310f093b6249a5f9c70ad1545c136)
-rwxr-xr-xjni/com_android_bluetooth_btservice_AdapterService.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/jni/com_android_bluetooth_btservice_AdapterService.cpp b/jni/com_android_bluetooth_btservice_AdapterService.cpp
index a8d11bbab..bba1ba461 100755
--- a/jni/com_android_bluetooth_btservice_AdapterService.cpp
+++ b/jni/com_android_bluetooth_btservice_AdapterService.cpp
@@ -32,6 +32,8 @@
namespace android {
#define OOB_TK_SIZE 16
+#define OOB_LE_SC_C_SIZE 16
+#define OOB_LE_SC_R_SIZE 16
#define ADDITIONAL_NREFS 50
static jmethodID method_stateChangeCallback;
@@ -837,18 +839,51 @@ static jboolean createBondOutOfBandNative(JNIEnv* env, jobject obj, jbyteArray a
}
jbyte* smTKBytes = NULL;
+ jbyte* leScCBytes = NULL;
+ jbyte* leScRBytes = NULL;
+ jbyteArray leScC = NULL;
+ jbyteArray leScR = NULL;
+
jbyteArray smTK = callByteArrayGetter(env, oobData, "android/bluetooth/OobData", "getSecurityManagerTk");
if (smTK != NULL) {
smTKBytes = env->GetByteArrayElements(smTK, NULL);
int len = env->GetArrayLength(smTK);
if (len != OOB_TK_SIZE) {
- ALOGI("%s: wrong length of smTK, should be empty or %d bytes.", __FUNCTION__, OOB_TK_SIZE);
+ ALOGI("%s: wrong length of smTK, should be empty or %d bytes.", __func__, OOB_TK_SIZE);
jniThrowIOException(env, EINVAL);
goto done;
}
memcpy(oob_data.sm_tk, smTKBytes, len);
}
+ leScC = callByteArrayGetter(env, oobData, "android/bluetooth/OobData",
+ "getLeSecureConnectionsConfirmation");
+ if (leScC != NULL) {
+ leScCBytes = env->GetByteArrayElements(leScC, NULL);
+ int len = env->GetArrayLength(leScC);
+ if (len != OOB_LE_SC_C_SIZE) {
+ ALOGI("%s: wrong length of LE SC Confirmation, should be empty or %d bytes.",
+ __func__, OOB_LE_SC_C_SIZE);
+ jniThrowIOException(env, EINVAL);
+ goto done;
+ }
+ memcpy(oob_data.le_sc_c, leScCBytes, len);
+ }
+
+ leScR = callByteArrayGetter(env, oobData, "android/bluetooth/OobData",
+ "getLeSecureConnectionsRandom");
+ if (leScR != NULL) {
+ leScRBytes = env->GetByteArrayElements(leScR, NULL);
+ int len = env->GetArrayLength(leScR);
+ if (len != OOB_LE_SC_R_SIZE) {
+ ALOGI("%s: wrong length of LE SC Random, should be empty or %d bytes.",
+ __func__, OOB_LE_SC_R_SIZE);
+ jniThrowIOException(env, EINVAL);
+ goto done;
+ }
+ memcpy(oob_data.le_sc_r, leScRBytes, len);
+ }
+
if (sBluetoothInterface->create_bond_out_of_band((bt_bdaddr_t *)addr, transport, &oob_data)
== BT_STATUS_SUCCESS)
result = JNI_TRUE;
@@ -859,6 +894,12 @@ done:
if (smTK != NULL)
env->ReleaseByteArrayElements(smTK, smTKBytes, 0);
+ if (leScC != NULL)
+ env->ReleaseByteArrayElements(leScC, leScCBytes, 0);
+
+ if (leScR != NULL)
+ env->ReleaseByteArrayElements(leScR, leScRBytes, 0);
+
return result;
}