Use public method in RestrictedLockUtils#isCurrentUserOrProfile
No need for new system API Test: Built Bug: 116798569 Change-Id: Iec6b29f8e47037854b36556a03e1f044dcaa5136
This commit is contained in:
@@ -4137,7 +4137,6 @@ package android.os {
|
||||
|
||||
public class UserManager {
|
||||
method public void clearSeedAccountData();
|
||||
method public int[] getProfileIds(int, boolean);
|
||||
method public java.lang.String getSeedAccountName();
|
||||
method public android.os.PersistableBundle getSeedAccountOptions();
|
||||
method public java.lang.String getSeedAccountType();
|
||||
|
||||
@@ -2363,7 +2363,6 @@ public class UserManager {
|
||||
*/
|
||||
@RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS,
|
||||
Manifest.permission.CREATE_USERS}, conditional = true)
|
||||
@SystemApi
|
||||
public @NonNull int[] getProfileIds(@UserIdInt int userId, boolean enabledOnly) {
|
||||
try {
|
||||
return mService.getProfileIds(userId, enabledOnly);
|
||||
|
||||
@@ -91,13 +91,7 @@ public class RestrictedLockUtils {
|
||||
|
||||
public static boolean isCurrentUserOrProfile(Context context, int userId) {
|
||||
UserManager um = context.getSystemService(UserManager.class);
|
||||
int[] userIds = um.getProfileIds(UserHandle.myUserId(), true);
|
||||
for (int i = 0; i < userIds.length; i++) {
|
||||
if (userIds[i] == userId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return um.getUserProfiles().contains(UserHandle.of(userId));
|
||||
}
|
||||
|
||||
public static class EnforcedAdmin {
|
||||
|
||||
Reference in New Issue
Block a user