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

Commit bbab0b18 authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioDeviceInventory: protect from null BT identity address

It is possible that the address returned by BluetoothDevice.getIdentityAddress()
is null in which case AudioDeviceInventory.onUpdateLeAudioGroupAddresses() must prevent
from setting @NonNull DeviceInfo fields mDeviceIdentityAddress and mPeerIdentityDeviceAddress
to null.

Bug: 334973381
Test: repro steps in bug.
Change-Id: Ib3b4693df4abf22774803c9aac60f532cd9f6a72
parent 611af796
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -983,9 +983,9 @@ public class AudioDeviceInventory {
                    }
                    if (di.mPeerDeviceAddress.equals("")) {
                        for (Pair<String, String> addr : addresses) {
                            if (!addr.first.equals(di.mDeviceAddress)) {
                                di.mPeerDeviceAddress = addr.first;
                                di.mPeerIdentityDeviceAddress = addr.second;
                            if (!di.mDeviceAddress.equals(addr.first)) {
                                di.mPeerDeviceAddress = TextUtils.emptyIfNull(addr.first);
                                di.mPeerIdentityDeviceAddress = TextUtils.emptyIfNull(addr.second);
                                break;
                            }
                        }
@@ -996,8 +996,8 @@ public class AudioDeviceInventory {
                    }
                    if (di.mDeviceIdentityAddress.equals("")) {
                        for (Pair<String, String> addr : addresses) {
                            if (addr.first.equals(di.mDeviceAddress)) {
                                di.mDeviceIdentityAddress = addr.second;
                            if (di.mDeviceAddress.equals(addr.first)) {
                                di.mDeviceIdentityAddress = TextUtils.emptyIfNull(addr.second);
                                break;
                            }
                        }
+6 −0
Original line number Diff line number Diff line
@@ -1116,6 +1116,12 @@ public class BtHelper {
        return mLeAudio.getGroupId(device);
    }

    /**
     * Returns all addresses and identity addresses for LE Audio devices a group.
     * @param groupId The ID of the group from which to get addresses.
     * @return A List of Pair(String main_address, String identity_address). Note that the
     * addresses returned by BluetoothDevice can be null.
     */
    /*package*/ List<Pair<String, String>> getLeAudioGroupAddresses(int groupId) {
        List<Pair<String, String>> addresses = new ArrayList<>();
        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();