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

Commit cddd231a authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Fix user id issue in AdapterServiceTest

Tag: #feature
Bug: 228385580
Test: Manual
Ignore-AOSP-First: Resolving merge conflict
Change-Id: I94808792a3cca044f2cc4991d1894c87f59e44ec
parent 9d166591
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -321,6 +321,11 @@ public final class Utils {
    }

    static int sForegroundUserId = USER_HANDLE_NULL.getIdentifier();

    public static int getForegroundUserId() {
        return Utils.sForegroundUserId;
    }

    public static void setForegroundUserId(int userId) {
        Utils.sForegroundUserId = userId;
    }
+1 −3
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import android.bluetooth.UidTraffic;
import android.companion.CompanionDeviceManager;
import android.content.AttributionSource;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
@@ -3715,8 +3714,7 @@ public class AdapterService extends Service {
        @Override
        public void setForegroundUserId(int userId, AttributionSource attributionSource) {
            AdapterService service = getService();
            if (service == null || !callerIsSystemOrActiveUser(TAG, "setForegroundUserId")
                    || !Utils.checkConnectPermissionForDataDelivery(
            if (service == null || !Utils.checkConnectPermissionForDataDelivery(
                    service, Utils.getCallingAttributionSource(mService),
                    "AdapterService setForegroundUserId")) {
                return;
+5 −0
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ public class AdapterServiceTest {
    private PackageManager mMockPackageManager;
    private MockContentResolver mMockContentResolver;
    private HashMap<String, HashMap<String, String>> mAdapterConfig;
    private int mForegroundUserId;

    private void configureEnabledProfiles() {
        Log.e("AdapterServiceTest", "configureEnabledProfiles");
@@ -319,6 +320,10 @@ public class AdapterServiceTest {
    @After
    public void tearDown() {
        Log.e("AdapterServiceTest", "tearDown()");

        // Restores the foregroundUserId to the ID prior to the test setup
        Utils.setForegroundUserId(mForegroundUserId);

        mServiceBinder.unregisterCallback(mIBluetoothCallback, mAttributionSource);
        mAdapterService.cleanup();
    }