Use public method in RestrictedLockUtils#isCurrentUserOrProfile

No need for new system API

Test: Built
Bug: 116798569
Change-Id: Iec6b29f8e47037854b36556a03e1f044dcaa5136
This commit is contained in:
Philip P. Moltmann
2018-10-09 15:49:54 -07:00
parent 421f1a152c
commit 54ff6b0138
3 changed files with 1 additions and 9 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -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 {