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

Commit 4e654189 authored by Chienyuan Huang's avatar Chienyuan Huang Committed by Android (Google) Code Review
Browse files

Merge "Address consoildation: check dual map first when get device" into tm-qpr-dev

parents b7e7be21 e8e44206
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) {