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

Commit e8e44206 authored by Chienyuan Huang's avatar Chienyuan Huang
Browse files

Address consoildation: check dual map first when get device

Bug: 262679188
Test: manual
Change-Id: I6a0a301c7040dd33f62bf5293b2ef5dc923cd28e
Merged-In: I6a0a301c7040dd33f62bf5293b2ef5dc923cd28e
parent 05334db8
Loading
Loading
Loading
Loading
+15 −16
Original line number Diff line number Diff line
@@ -247,30 +247,29 @@ final class RemoteDevices {

    DeviceProperties getDeviceProperties(BluetoothDevice device) {
        synchronized (mDevices) {
            DeviceProperties prop = mDevices.get(device.getAddress());
            if (prop == null) {
                String mainAddress = mDualDevicesMap.get(device.getAddress());
                if (mainAddress != null && mDevices.get(mainAddress) != null) {
                    prop = mDevices.get(mainAddress);
            String address = mDualDevicesMap.get(device.getAddress());
            // If the device is not in the dual map, use its original address
            if (address == null || mDevices.get(address) == null) {
                address = device.getAddress();
            }
            }
            return prop;
            return mDevices.get(address);
        }
    }

    BluetoothDevice getDevice(byte[] address) {
        String addressString = Utils.getAddressStringFromByte(address);
        DeviceProperties prop = mDevices.get(addressString);
        if (prop == null) {
            String mainAddress = mDualDevicesMap.get(addressString);
            if (mainAddress != null && mDevices.get(mainAddress) != null) {
                prop = mDevices.get(mainAddress);
        String deviceAddress = mDualDevicesMap.get(addressString);
        // If the device is not in the dual map, use its original address
        if (deviceAddress == null || mDevices.get(deviceAddress) == null) {
            deviceAddress = addressString;
        }

        DeviceProperties prop = mDevices.get(deviceAddress);
        if (prop != null) {
            return prop.getDevice();
        }
        return null;
    }
        return prop.getDevice();
    }

    @VisibleForTesting
    DeviceProperties addDeviceProperties(byte[] address) {