Loading android/app/src/com/android/bluetooth/Utils.java +4 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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()) Loading android/app/src/com/android/bluetooth/btservice/ProfileService.java +4 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading framework/java/android/bluetooth/BluetoothUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.bluetooth; import android.os.UserHandle; import java.time.Duration; /** Loading @@ -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); } Loading
android/app/src/com/android/bluetooth/Utils.java +4 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading Loading @@ -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()) Loading
android/app/src/com/android/bluetooth/btservice/ProfileService.java +4 −3 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; } Loading
framework/java/android/bluetooth/BluetoothUtils.java +7 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.bluetooth; import android.os.UserHandle; import java.time.Duration; /** Loading @@ -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); }