Loading android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +37 −21 Original line number Diff line number Diff line Loading @@ -674,24 +674,39 @@ class AdapterProperties { Flags.identityAddressNullIfUnknown() ? Utils.getBrEdrAddress(device, mService) : mService.getIdentityAddress(address); debugLog("cleanupPrevBondRecordsFor: " + device); int deviceType = mRemoteDevices.getDeviceProperties(device).getDeviceType(); debugLog("cleanupPrevBondRecordsFor: " + device + ", device type: " + deviceType); if (identityAddress == null) { return; } if (Flags.cleanupLeOnlyDeviceType() && deviceType != BluetoothDevice.DEVICE_TYPE_LE) { return; } for (BluetoothDevice existingDevice : mBondedDevices) { String existingAddress = existingDevice.getAddress(); String existingIdentityAddress = Flags.identityAddressNullIfUnknown() ? Utils.getBrEdrAddress(existingDevice, mService) : mService.getIdentityAddress(existingAddress); if (!identityAddress.equals(existingIdentityAddress) || address.equals( existingAddress)) { continue; int existingDeviceType = mRemoteDevices.getDeviceProperties(existingDevice).getDeviceType(); boolean removeExisting = false; if (identityAddress.equals(existingIdentityAddress) && !address.equals(existingAddress)) { if (Flags.cleanupLeOnlyDeviceType()) { // Existing device record should be removed only if the device type is LE-only removeExisting = (existingDeviceType == BluetoothDevice.DEVICE_TYPE_LE); } else { removeExisting = true; } } // Found an existing device with same identity address but different pseudo address if (removeExisting) { // Found an existing LE-only device with the same identity address but different // pseudo address if (mService.getNative().removeBond(Utils.getBytesFromAddress(existingAddress))) { mBondedDevices.remove(existingDevice); infoLog( Loading @@ -710,6 +725,7 @@ class AdapterProperties { break; } } } int getDiscoverableTimeout() { return mDiscoverableTimeout; Loading android/app/src/com/android/bluetooth/btservice/RemoteDevices.java +1 −0 Original line number Diff line number Diff line Loading @@ -485,6 +485,7 @@ public class RemoteDevices { /** * @param deviceType the mDeviceType to set */ @VisibleForTesting void setDeviceType(int deviceType) { synchronized (mObject) { this.mDeviceType = deviceType; Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterPropertiesTest.java +7 −2 Original line number Diff line number Diff line Loading @@ -101,8 +101,13 @@ public class AdapterPropertiesTest { @Test public void testCleanupPrevBondRecordsFor() { mRemoteDevices.reset(); mRemoteDevices.addDeviceProperties(TEST_BT_ADDR_BYTES); mRemoteDevices.addDeviceProperties(TEST_BT_ADDR_BYTES_2); mRemoteDevices .addDeviceProperties(TEST_BT_ADDR_BYTES) .setDeviceType(BluetoothDevice.DEVICE_TYPE_LE); mRemoteDevices .addDeviceProperties(TEST_BT_ADDR_BYTES_2) .setDeviceType(BluetoothDevice.DEVICE_TYPE_LE); BluetoothDevice device1, device2; device1 = mRemoteDevices.getDevice(TEST_BT_ADDR_BYTES); device2 = mRemoteDevices.getDevice(TEST_BT_ADDR_BYTES_2); Loading Loading
android/app/src/com/android/bluetooth/btservice/AdapterProperties.java +37 −21 Original line number Diff line number Diff line Loading @@ -674,24 +674,39 @@ class AdapterProperties { Flags.identityAddressNullIfUnknown() ? Utils.getBrEdrAddress(device, mService) : mService.getIdentityAddress(address); debugLog("cleanupPrevBondRecordsFor: " + device); int deviceType = mRemoteDevices.getDeviceProperties(device).getDeviceType(); debugLog("cleanupPrevBondRecordsFor: " + device + ", device type: " + deviceType); if (identityAddress == null) { return; } if (Flags.cleanupLeOnlyDeviceType() && deviceType != BluetoothDevice.DEVICE_TYPE_LE) { return; } for (BluetoothDevice existingDevice : mBondedDevices) { String existingAddress = existingDevice.getAddress(); String existingIdentityAddress = Flags.identityAddressNullIfUnknown() ? Utils.getBrEdrAddress(existingDevice, mService) : mService.getIdentityAddress(existingAddress); if (!identityAddress.equals(existingIdentityAddress) || address.equals( existingAddress)) { continue; int existingDeviceType = mRemoteDevices.getDeviceProperties(existingDevice).getDeviceType(); boolean removeExisting = false; if (identityAddress.equals(existingIdentityAddress) && !address.equals(existingAddress)) { if (Flags.cleanupLeOnlyDeviceType()) { // Existing device record should be removed only if the device type is LE-only removeExisting = (existingDeviceType == BluetoothDevice.DEVICE_TYPE_LE); } else { removeExisting = true; } } // Found an existing device with same identity address but different pseudo address if (removeExisting) { // Found an existing LE-only device with the same identity address but different // pseudo address if (mService.getNative().removeBond(Utils.getBytesFromAddress(existingAddress))) { mBondedDevices.remove(existingDevice); infoLog( Loading @@ -710,6 +725,7 @@ class AdapterProperties { break; } } } int getDiscoverableTimeout() { return mDiscoverableTimeout; Loading
android/app/src/com/android/bluetooth/btservice/RemoteDevices.java +1 −0 Original line number Diff line number Diff line Loading @@ -485,6 +485,7 @@ public class RemoteDevices { /** * @param deviceType the mDeviceType to set */ @VisibleForTesting void setDeviceType(int deviceType) { synchronized (mObject) { this.mDeviceType = deviceType; Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterPropertiesTest.java +7 −2 Original line number Diff line number Diff line Loading @@ -101,8 +101,13 @@ public class AdapterPropertiesTest { @Test public void testCleanupPrevBondRecordsFor() { mRemoteDevices.reset(); mRemoteDevices.addDeviceProperties(TEST_BT_ADDR_BYTES); mRemoteDevices.addDeviceProperties(TEST_BT_ADDR_BYTES_2); mRemoteDevices .addDeviceProperties(TEST_BT_ADDR_BYTES) .setDeviceType(BluetoothDevice.DEVICE_TYPE_LE); mRemoteDevices .addDeviceProperties(TEST_BT_ADDR_BYTES_2) .setDeviceType(BluetoothDevice.DEVICE_TYPE_LE); BluetoothDevice device1, device2; device1 = mRemoteDevices.getDevice(TEST_BT_ADDR_BYTES); device2 = mRemoteDevices.getDevice(TEST_BT_ADDR_BYTES_2); Loading