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

Commit 2dced6a9 authored by Chienyuan Huang's avatar Chienyuan Huang Committed by Gerrit Code Review
Browse files

Merge "Address consoildation: check dual map first when get device"

parents b2b47630 7612950d
Loading
Loading
Loading
Loading
+15 −16
Original line number Original line Diff line number Diff line
@@ -251,30 +251,29 @@ final class RemoteDevices {


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


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

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


    @VisibleForTesting
    @VisibleForTesting
    DeviceProperties addDeviceProperties(byte[] address) {
    DeviceProperties addDeviceProperties(byte[] address) {