summaryrefslogtreecommitdiff
path: root/service/java/com
diff options
context:
space:
mode:
author Richard MacGregor <rmacgregor@google.com> 2024-11-07 23:04:27 +0000
committer Richard MacGregor <rmacgregor@google.com> 2024-11-07 23:04:27 +0000
commit24e95993efce47d1aac97dd05ab5a97700e5b027 (patch)
treea906d09c0959479e2746555fbbed2dadd84f7dfb /service/java/com
parent0e09a99ea8a4886d89bf89a3fa3a9d9a19d9123e (diff)
Move USER_NULL to UserHandleCompat
Change-Id: I1532a775026710d4123ae6f8ea53bfeb30615ab4 RelNote: N/A Bug: 376728836 Flag: EXEMPT refactor Test: build
Diffstat (limited to 'service/java/com')
-rw-r--r--service/java/com/android/permission/compat/UserHandleCompat.java7
-rw-r--r--service/java/com/android/safetycenter/UserProfileGroup.java14
2 files changed, 14 insertions, 7 deletions
diff --git a/service/java/com/android/permission/compat/UserHandleCompat.java b/service/java/com/android/permission/compat/UserHandleCompat.java
index 1901aa997..1b3ebb8d6 100644
--- a/service/java/com/android/permission/compat/UserHandleCompat.java
+++ b/service/java/com/android/permission/compat/UserHandleCompat.java
@@ -29,6 +29,13 @@ public final class UserHandleCompat {
public static final int USER_ALL = UserHandle.ALL.getIdentifier();
/**
+ * A user ID to indicate an undefined user of the device.
+ *
+ * @see UserHandle#USER_NULL
+ */
+ public static final @UserIdInt int USER_NULL = -10000;
+
+ /**
* A user ID to indicate the "system" user of the device.
*/
public static final int USER_SYSTEM = UserHandle.SYSTEM.getIdentifier();
diff --git a/service/java/com/android/safetycenter/UserProfileGroup.java b/service/java/com/android/safetycenter/UserProfileGroup.java
index 3202c3776..a78113b04 100644
--- a/service/java/com/android/safetycenter/UserProfileGroup.java
+++ b/service/java/com/android/safetycenter/UserProfileGroup.java
@@ -30,6 +30,7 @@ import android.util.Log;
import androidx.annotation.Nullable;
+import com.android.permission.compat.UserHandleCompat;
import com.android.permission.util.UserUtils;
import java.lang.annotation.Retention;
@@ -49,8 +50,6 @@ import java.util.Objects;
public final class UserProfileGroup {
private static final String TAG = "UserProfileGroup";
- // UserHandle#USER_NULL is a @TestApi so it cannot be accessed from the mainline module.
- public static final @UserIdInt int USER_NULL = -10000;
@UserIdInt private final int mProfileParentUserId;
private final int[] mManagedProfilesUserIds;
@@ -147,7 +146,7 @@ public final class UserProfileGroup {
int managedProfilesUserIdsLen = 0;
int managedRunningProfilesUserIdsLen = 0;
- int privateProfileUserId = USER_NULL;
+ int privateProfileUserId = UserHandleCompat.USER_NULL;
boolean privateProfileRunning = false;
for (int i = 0; i < userProfiles.size(); i++) {
@@ -228,7 +227,7 @@ public final class UserProfileGroup {
/* destPos= */ 1,
mManagedProfilesUserIds.length);
- if (mPrivateProfileUserId != USER_NULL) {
+ if (mPrivateProfileUserId != UserHandleCompat.USER_NULL) {
allProfileIds[allProfileIds.length - 1] = mPrivateProfileUserId;
}
@@ -269,7 +268,7 @@ public final class UserProfileGroup {
case PROFILE_TYPE_MANAGED:
return mManagedProfilesUserIds;
case PROFILE_TYPE_PRIVATE:
- return mPrivateProfileUserId != USER_NULL
+ return mPrivateProfileUserId != UserHandleCompat.USER_NULL
? new int[]{mPrivateProfileUserId} : new int[]{};
default:
Log.w(TAG, "profiles requested for unexpected profile type " + profileType);
@@ -308,7 +307,7 @@ public final class UserProfileGroup {
private int getNumProfiles() {
return 1
+ mManagedProfilesUserIds.length
- + (mPrivateProfileUserId == USER_NULL ? 0 : 1);
+ + (mPrivateProfileUserId == UserHandleCompat.USER_NULL ? 0 : 1);
}
/**
@@ -361,7 +360,8 @@ public final class UserProfileGroup {
}
}
- return USER_NULL != mPrivateProfileUserId && userId == mPrivateProfileUserId;
+ return UserHandleCompat.USER_NULL != mPrivateProfileUserId
+ && userId == mPrivateProfileUserId;
}
@Override