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

Commit d62b22d8 authored by Ajay Panicker's avatar Ajay Panicker Committed by android-build-merger
Browse files

Merge "Prevent Null Pointer Exception caused by empty remote device properties" am: 82e2aed6

am: 939f2094

Change-Id: I1acad92fea490fd2c81b092f505d4f26c2574e18
parents f0355742 939f2094
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -262,7 +262,8 @@ final class RemoteDevices {
        Intent intent = new Intent(BluetoothDevice.ACTION_UUID);
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(BluetoothDevice.EXTRA_UUID, prop == null ? null : prop.mUuids);
        mAdapterService.initProfilePriorities(device, prop.mUuids);
        mAdapterService.initProfilePriorities(device, prop == null ? null : prop.mUuids);

        mAdapterService.sendBroadcast(intent, AdapterService.BLUETOOTH_ADMIN_PERM);

        //Remove the outstanding UUID request
+44 −0
Original line number Diff line number Diff line
package com.android.bluetooth.btservice;

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothClass;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.ParcelUuid;
import android.util.Log;
import com.android.bluetooth.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.lang.Thread;

import android.test.AndroidTestCase;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;

public class RemoteDevicesTest extends AndroidTestCase {
    public void testSendUuidIntent() {
        if (Looper.myLooper() == null) Looper.prepare();

        AdapterService mockService = mock(AdapterService.class);
        RemoteDevices devices = new RemoteDevices(mockService);
        BluetoothDevice device =
                BluetoothAdapter.getDefaultAdapter().getRemoteDevice("00:11:22:33:44:55");
        devices.updateUuids(device);

        Looper.myLooper().quitSafely();
        Looper.loop();

        verify(mockService).initProfilePriorities(device, null);
        verify(mockService).sendBroadcast(any(), anyString());
        verifyNoMoreInteractions(mockService);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public class BluetoothMapContentObserverTest extends AndroidTestCase {
    }

    public void testInitMsgList() {
        Looper.prepare();
        if (Looper.myLooper() == null) Looper.prepare();

        Context mockContext = mock(Context.class);
        MockContentResolver mockResolver = new MockContentResolver(mockContext);