Loading android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -350,7 +350,8 @@ static void discovery_state_changed_callback(bt_discovery_state_t state) { checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__); } static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t cod) { static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t cod, bool min_16_digits) { jbyteArray addr, devname; if (!checkCallbackThread()) { ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); Loading @@ -370,7 +371,8 @@ static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint callbackEnv->SetByteArrayRegion(devname, 0, sizeof(bt_bdname_t), (jbyte*)bdname); callbackEnv->CallVoidMethod(sJniCallbacksObj, method_pinRequestCallback, addr, devname, cod); callbackEnv->CallVoidMethod(sJniCallbacksObj, method_pinRequestCallback, addr, devname, cod, min_16_digits); checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__); callbackEnv->DeleteLocalRef(addr); Loading Loading @@ -619,7 +621,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { "([B[I[[B)V"); method_deviceFoundCallback = env->GetMethodID(jniCallbackClass, "deviceFoundCallback", "([B)V"); method_pinRequestCallback = env->GetMethodID(jniCallbackClass, "pinRequestCallback", "([B[BI)V"); "([B[BIZ)V"); method_sspRequestCallback = env->GetMethodID(jniCallbackClass, "sspRequestCallback", "([B[BIII)V"); Loading android/app/src/com/android/bluetooth/btservice/AdapterService.java +4 −1 Original line number Diff line number Diff line Loading @@ -1671,7 +1671,10 @@ public class AdapterService extends Service { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDING) { // Only allow setting a pin in bonding state, or bonded state in case of security upgrade. if (deviceProp == null || (deviceProp.getBondState() != BluetoothDevice.BOND_BONDING && deviceProp.getBondState() != BluetoothDevice.BOND_BONDED)) { return false; } Loading android/app/src/com/android/bluetooth/btservice/BondStateMachine.java +13 −5 Original line number Diff line number Diff line Loading @@ -235,10 +235,16 @@ final class BondStateMachine extends StateMachine { BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN); break; } if (msg.arg2 == 1) { // Minimum 16 digit pin required here sendDisplayPinIntent(devProp.getAddress(), 0, BluetoothDevice.PAIRING_VARIANT_PIN_16_DIGITS); } else { // In PIN_REQUEST, there is no passkey to display.So do not send the // EXTRA_PAIRING_KEY type in the intent( 0 in SendDisplayPinIntent() ) sendDisplayPinIntent(devProp.getAddress(), 0, BluetoothDevice.PAIRING_VARIANT_PIN); } break; default: Loading Loading @@ -402,8 +408,9 @@ final class BondStateMachine extends StateMachine { sendMessage(msg); } void pinRequestCallback(byte[] address, byte[] name, int cod) { void pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits) { //TODO(BT): Get wakelock and update name and cod BluetoothDevice bdDevice = mRemoteDevices.getDevice(address); if (bdDevice == null) { mRemoteDevices.addDeviceProperties(address); Loading @@ -413,6 +420,7 @@ final class BondStateMachine extends StateMachine { Message msg = obtainMessage(PIN_REQUEST); msg.obj = bdDevice; msg.arg2 = min16Digits ? 1 : 0; // Use arg2 to pass the min16Digit boolean sendMessage(msg); } Loading android/app/src/com/android/bluetooth/btservice/JniCallbacks.java +2 −2 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ final class JniCallbacks { mRemoteDevices.deviceFoundCallback(address); } void pinRequestCallback(byte[] address, byte[] name, int cod) { mBondStateMachine.pinRequestCallback(address, name, cod); void pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits) { mBondStateMachine.pinRequestCallback(address, name, cod, min16Digits); } void bondStateChangeCallback(int status, byte[] address, int newState) { Loading android/app/src/com/android/bluetooth/sap/SapService.java +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ public class SapService extends ProfileService { // TODO: Consider reusing the mServerSocket - it is indented to be reused // for multiple connections. mServerSocket = mAdapter.listenUsingRfcommOn( BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP, true); BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP, true, true); if (mSdpHandle >= 0) { SdpManager.getDefaultManager().removeSdpRecord(mSdpHandle); if (VERBOSE) Log.d(TAG, "Removing SDP record"); Loading Loading
android/app/jni/com_android_bluetooth_btservice_AdapterService.cpp +6 −4 Original line number Diff line number Diff line Loading @@ -350,7 +350,8 @@ static void discovery_state_changed_callback(bt_discovery_state_t state) { checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__); } static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t cod) { static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint32_t cod, bool min_16_digits) { jbyteArray addr, devname; if (!checkCallbackThread()) { ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); Loading @@ -370,7 +371,8 @@ static void pin_request_callback(bt_bdaddr_t *bd_addr, bt_bdname_t *bdname, uint callbackEnv->SetByteArrayRegion(devname, 0, sizeof(bt_bdname_t), (jbyte*)bdname); callbackEnv->CallVoidMethod(sJniCallbacksObj, method_pinRequestCallback, addr, devname, cod); callbackEnv->CallVoidMethod(sJniCallbacksObj, method_pinRequestCallback, addr, devname, cod, min_16_digits); checkAndClearExceptionFromCallback(callbackEnv, __FUNCTION__); callbackEnv->DeleteLocalRef(addr); Loading Loading @@ -619,7 +621,7 @@ static void classInitNative(JNIEnv* env, jclass clazz) { "([B[I[[B)V"); method_deviceFoundCallback = env->GetMethodID(jniCallbackClass, "deviceFoundCallback", "([B)V"); method_pinRequestCallback = env->GetMethodID(jniCallbackClass, "pinRequestCallback", "([B[BI)V"); "([B[BIZ)V"); method_sspRequestCallback = env->GetMethodID(jniCallbackClass, "sspRequestCallback", "([B[BIII)V"); Loading
android/app/src/com/android/bluetooth/btservice/AdapterService.java +4 −1 Original line number Diff line number Diff line Loading @@ -1671,7 +1671,10 @@ public class AdapterService extends Service { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device); if (deviceProp == null || deviceProp.getBondState() != BluetoothDevice.BOND_BONDING) { // Only allow setting a pin in bonding state, or bonded state in case of security upgrade. if (deviceProp == null || (deviceProp.getBondState() != BluetoothDevice.BOND_BONDING && deviceProp.getBondState() != BluetoothDevice.BOND_BONDED)) { return false; } Loading
android/app/src/com/android/bluetooth/btservice/BondStateMachine.java +13 −5 Original line number Diff line number Diff line Loading @@ -235,10 +235,16 @@ final class BondStateMachine extends StateMachine { BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN); break; } if (msg.arg2 == 1) { // Minimum 16 digit pin required here sendDisplayPinIntent(devProp.getAddress(), 0, BluetoothDevice.PAIRING_VARIANT_PIN_16_DIGITS); } else { // In PIN_REQUEST, there is no passkey to display.So do not send the // EXTRA_PAIRING_KEY type in the intent( 0 in SendDisplayPinIntent() ) sendDisplayPinIntent(devProp.getAddress(), 0, BluetoothDevice.PAIRING_VARIANT_PIN); } break; default: Loading Loading @@ -402,8 +408,9 @@ final class BondStateMachine extends StateMachine { sendMessage(msg); } void pinRequestCallback(byte[] address, byte[] name, int cod) { void pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits) { //TODO(BT): Get wakelock and update name and cod BluetoothDevice bdDevice = mRemoteDevices.getDevice(address); if (bdDevice == null) { mRemoteDevices.addDeviceProperties(address); Loading @@ -413,6 +420,7 @@ final class BondStateMachine extends StateMachine { Message msg = obtainMessage(PIN_REQUEST); msg.obj = bdDevice; msg.arg2 = min16Digits ? 1 : 0; // Use arg2 to pass the min16Digit boolean sendMessage(msg); } Loading
android/app/src/com/android/bluetooth/btservice/JniCallbacks.java +2 −2 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ final class JniCallbacks { mRemoteDevices.deviceFoundCallback(address); } void pinRequestCallback(byte[] address, byte[] name, int cod) { mBondStateMachine.pinRequestCallback(address, name, cod); void pinRequestCallback(byte[] address, byte[] name, int cod, boolean min16Digits) { mBondStateMachine.pinRequestCallback(address, name, cod, min16Digits); } void bondStateChangeCallback(int status, byte[] address, int newState) { Loading
android/app/src/com/android/bluetooth/sap/SapService.java +1 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ public class SapService extends ProfileService { // TODO: Consider reusing the mServerSocket - it is indented to be reused // for multiple connections. mServerSocket = mAdapter.listenUsingRfcommOn( BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP, true); BluetoothAdapter.SOCKET_CHANNEL_AUTO_STATIC_NO_SDP, true, true); if (mSdpHandle >= 0) { SdpManager.getDefaultManager().removeSdpRecord(mSdpHandle); if (VERBOSE) Log.d(TAG, "Removing SDP record"); Loading