Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e8cd562 authored by Rahul Sabnis's avatar Rahul Sabnis Committed by Automerger Merge Worker
Browse files

Fixes a bug in the BluetoothDevice#getIdentityAddress API where it am: 448c2830

parents 70b63e45 448c2830
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -3881,7 +3881,7 @@ public class AdapterService extends Service {
        if (deviceProp != null && deviceProp.isConsolidated()) {
            return deviceProp.getIdentityAddress();
        } else {
            return address;
            return null;
        }
    }

+8 −5
Original line number Diff line number Diff line
@@ -853,19 +853,22 @@ public class AdapterServiceTest {

    @Test
    public void testAddressConsolidation() {
        // Create device properties
        // Verify that we return null when the device property for this address does not exist
        Assert.assertNull(mAdapterService.getIdentityAddress(TEST_BT_ADDR_1));

        // Create device property
        RemoteDevices remoteDevices = mAdapterService.getRemoteDevices();
        remoteDevices.addDeviceProperties(Utils.getBytesFromAddress((TEST_BT_ADDR_1)));
        String identityAddress = mAdapterService.getIdentityAddress(TEST_BT_ADDR_1);
        Assert.assertEquals(identityAddress, TEST_BT_ADDR_1);

        // Verify that we return null when the identity address is not known
        Assert.assertNull(mAdapterService.getIdentityAddress(TEST_BT_ADDR_1));

        // Trigger address consolidate callback
        remoteDevices.addressConsolidateCallback(Utils.getBytesFromAddress(TEST_BT_ADDR_1),
                Utils.getBytesFromAddress(TEST_BT_ADDR_2));

        // Verify we can get correct identity address
        identityAddress = mAdapterService.getIdentityAddress(TEST_BT_ADDR_1);
        Assert.assertEquals(identityAddress, TEST_BT_ADDR_2);
        Assert.assertEquals(TEST_BT_ADDR_2, mAdapterService.getIdentityAddress(TEST_BT_ADDR_1));
    }

    private static byte[] getMetricsSalt(HashMap<String, HashMap<String, String>> adapterConfig) {
+2 −1
Original line number Diff line number Diff line
@@ -1477,7 +1477,8 @@ public final class BluetoothDevice implements Parcelable, Attributable {
     * Returns the identity address of this BluetoothDevice.
     * <p> For example, "00:11:22:AA:BB:CC".
     *
     * @return Bluetooth identity address as a string
     * @return this device's identity address as a string or {@code null} if the identity
     *         address is either not known or is unable to be retrieved
     * @hide
     */
    @SystemApi