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

Commit 228ee4cb authored by Kyunglyul Hyun's avatar Kyunglyul Hyun Committed by Automerger Merge Worker
Browse files

Merge "Fix potential NPE in SapService" into main am: 425ff7b0 am: 6e1a023b

parents 81575447 6e1a023b
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -907,12 +907,14 @@ public class SapService extends ProfileService implements AdapterService.Bluetoo

        @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)
        private SapService getService(AttributionSource source) {
            if (!Utils.checkServiceAvailable(mService, TAG)
                    || !Utils.checkCallerIsSystemOrActiveOrManagedUser(mService, TAG)
                    || !Utils.checkConnectPermissionForDataDelivery(mService, source, TAG)) {
            SapService sapService = mService;

            if (!Utils.checkServiceAvailable(sapService, TAG)
                    || !Utils.checkCallerIsSystemOrActiveOrManagedUser(sapService, TAG)
                    || !Utils.checkConnectPermissionForDataDelivery(sapService, source, TAG)) {
                return null;
            }
            return mService;
            return sapService;
        }

        SapBinder(SapService service) {
+6 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.os.Looper;

import androidx.test.filters.MediumTest;
import androidx.test.platform.app.InstrumentationRegistry;
@@ -60,6 +61,11 @@ public class SapServiceTest {
    public void setUp() throws Exception {
        mTargetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        TestUtils.setAdapterService(mAdapterService);

        if (Looper.myLooper() == null) {
            Looper.prepare();
        }

        mService = new SapService(mTargetContext);
        mService.start();
        mService.setAvailable(true);