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

Commit f1d1f79c authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add a Bluetooth UserNull to serve a placeholder" am: 0bfe843b

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1965086

Change-Id: I10390017959a8c94120bd41f4d6f19429514210b
parents c422a7c0 0bfe843b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.Manifest.permission.BLUETOOTH_ADVERTISE;
import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.BLUETOOTH_SCAN;
import static android.Manifest.permission.RENOUNCE_PERMISSIONS;
import static android.bluetooth.BluetoothUtils.USER_HANDLE_NULL;
import static android.content.PermissionChecker.PERMISSION_HARD_DENIED;
import static android.content.PermissionChecker.PID_UNKNOWN;
import static android.content.pm.PackageManager.GET_PERMISSIONS;
@@ -316,12 +317,12 @@ public final class Utils {
        }
    }

    static int sSystemUiUid = UserHandle.USER_NULL;
    static int sSystemUiUid = USER_HANDLE_NULL.getIdentifier();
    public static void setSystemUiUid(int uid) {
        Utils.sSystemUiUid = uid;
    }

    static int sForegroundUserId = UserHandle.USER_NULL;
    static int sForegroundUserId = USER_HANDLE_NULL.getIdentifier();
    public static void setForegroundUserId(int uid) {
        Utils.sForegroundUserId = uid;
    }
@@ -633,7 +634,7 @@ public final class Utils {
        try {
            UserManager um = context.getSystemService(UserManager.class);
            UserHandle uh = um.getProfileParent(callingUser);
            int parentUser = (uh != null) ? uh.getIdentifier() : UserHandle.USER_NULL;
            int parentUser = (uh != null) ? uh.getIdentifier() : USER_HANDLE_NULL.getIdentifier();

            // Always allow SystemUI/System access.
            return (sForegroundUserId == callingUser.getIdentifier())
+4 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothUtils;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -282,9 +283,9 @@ public abstract class ProfileService extends Service {
            @Override
            public void onReceive(Context context, Intent intent) {
                final String action = intent.getAction();
                final int userId =
                        intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL);
                if (userId == UserHandle.USER_NULL) {
                final int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE,
                        BluetoothUtils.USER_HANDLE_NULL.getIdentifier());
                if (userId == BluetoothUtils.USER_HANDLE_NULL.getIdentifier()) {
                    Log.e(mName, "userChangeReceiver received an invalid EXTRA_USER_HANDLE");
                    return;
                }
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.bluetooth;

import android.os.UserHandle;

import java.time.Duration;

/**
@@ -38,4 +40,9 @@ public final class BluetoothUtils {
    static Duration getSyncTimeout() {
        return SYNC_CALLS_TIMEOUT;
    }

    /**
     * Match with UserHandl.NULL but accessible inside bluetooth package
     */
    public static final UserHandle USER_HANDLE_NULL = UserHandle.of(-10000);
}