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

Commit d8a67a64 authored by Evan Chen's avatar Evan Chen
Browse files

Fix NullPointerException when fetching uuid from BluetoothDevice

Test: cts
Bug: 322040773

Change-Id: I0f79501461298697632692920a0587928ad4c167
parent 9b26927b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -368,8 +368,10 @@ public class CompanionDeviceManagerService extends SystemService {

        if (blueToothDevices != null) {
            for (BluetoothDevice bluetoothDevice : blueToothDevices) {
                final List<ParcelUuid> deviceUuids = bluetoothDevice.getUuids() == null
                        ? Collections.emptyList() : Arrays.asList(bluetoothDevice.getUuids());
                final ParcelUuid[] bluetoothDeviceUuids = bluetoothDevice.getUuids();

                final List<ParcelUuid> deviceUuids = ArrayUtils.isEmpty(bluetoothDeviceUuids)
                        ? Collections.emptyList() : Arrays.asList(bluetoothDeviceUuids);

                for (AssociationInfo ai:
                        mAssociationStore.getAssociationsByAddress(bluetoothDevice.getAddress())) {
+5 −2
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.util.Slog;
import android.util.SparseArray;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.ArrayUtils;
import com.android.server.companion.AssociationStore;
import com.android.server.companion.ObservableUuid;
import com.android.server.companion.ObservableUuidStore;
@@ -172,8 +173,10 @@ public class BluetoothCompanionDeviceConnectionListener
                mAssociationStore.getAssociationsByAddress(device.getAddress());
        final List<ObservableUuid> observableUuids =
                mObservableUuidStore.getObservableUuidsForUser(userId);
        final List<ParcelUuid> deviceUuids = device.getUuids() == null
                ? Collections.emptyList() : Arrays.asList(device.getUuids());
        final ParcelUuid[] bluetoothDeviceUuids = device.getUuids();

        final List<ParcelUuid> deviceUuids = ArrayUtils.isEmpty(bluetoothDeviceUuids)
                ? Collections.emptyList() : Arrays.asList(bluetoothDeviceUuids);

        if (DEBUG) {
            Log.d(TAG, "onDevice_ConnectivityChanged() " + btDeviceToString(device)