Loading services/core/java/com/android/server/pm/LauncherAppsService.java +15 −20 Original line number Diff line number Diff line Loading @@ -379,9 +379,10 @@ public class LauncherAppsService extends SystemService { public List<UserHandle> getUserProfiles() { int[] userIds; if (!canAccessHiddenProfile(getCallingUid(), getCallingPid())) { userIds = mUm.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); userIds = mUserManagerInternal.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); } else { userIds = mUm.getEnabledProfileIds(getCallingUserId()); userIds = mUserManagerInternal.getProfileIds(getCallingUserId(), true); } final List<UserHandle> result = new ArrayList<>(userIds.length); for (int userId : userIds) { Loading @@ -398,9 +399,10 @@ public class LauncherAppsService extends SystemService { int[] userIds; if (!canAccessHiddenProfile(callingUid, Binder.getCallingPid())) { userIds = mUm.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); userIds = mUserManagerInternal.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); } else { userIds = mUm.getEnabledProfileIds(getCallingUserId()); userIds = mUserManagerInternal.getProfileIds(getCallingUserId(), true); } final long token = Binder.clearCallingIdentity(); Loading Loading @@ -503,17 +505,12 @@ public class LauncherAppsService extends SystemService { return true; } long ident = injectClearCallingIdentity(); try { final UserInfo callingUserInfo = mUm.getUserInfo(callingUserId); final UserInfo callingUserInfo = mUserManagerInternal.getUserInfo(callingUserId); if (callingUserInfo != null && callingUserInfo.isProfile()) { Slog.w(TAG, message + " for another profile " + targetUserId + " from " + callingUserId + " not allowed"); return false; } } finally { injectRestoreCallingIdentity(ident); } if (isHiddenProfile(UserHandle.of(targetUserId)) && !canAccessHiddenProfile(callingUid, callingPid)) { Loading @@ -529,9 +526,9 @@ public class LauncherAppsService extends SystemService { return false; } long identity = injectClearCallingIdentity(); try { UserProperties properties = mUm.getUserProperties(targetUser); UserProperties properties = mUserManagerInternal .getUserProperties(targetUser.getIdentifier()); if (properties == null) { return false; } Loading @@ -540,8 +537,6 @@ public class LauncherAppsService extends SystemService { == UserProperties.PROFILE_API_VISIBILITY_HIDDEN; } catch (IllegalArgumentException e) { return false; } finally { injectRestoreCallingIdentity(identity); } } Loading Loading @@ -686,7 +681,7 @@ public class LauncherAppsService extends SystemService { final int callingUid = injectBinderCallingUid(); final long ident = injectClearCallingIdentity(); try { if (mUm.getUserInfo(user.getIdentifier()).isManagedProfile()) { if (mUserManagerInternal.getUserInfo(user.getIdentifier()).isManagedProfile()) { // Managed profile should not show hidden apps return launcherActivities; } Loading Loading @@ -1713,7 +1708,7 @@ public class LauncherAppsService extends SystemService { } final long identity = Binder.clearCallingIdentity(); try { String userType = mUm.getUserInfo(user.getIdentifier()).userType; String userType = mUserManagerInternal.getUserInfo(user.getIdentifier()).userType; Set<String> preInstalledPackages = mUm.getPreInstallableSystemPackages(userType); if (preInstalledPackages == null) { return new ArrayList<>(); Loading services/core/java/com/android/server/pm/UserManagerInternal.java +15 −0 Original line number Diff line number Diff line Loading @@ -367,6 +367,21 @@ public abstract class UserManagerInternal { */ public abstract @NonNull int[] getProfileIds(@UserIdInt int userId, boolean enabledOnly); /** * Returns a list of the users that are associated with the specified user, including the user * itself. This includes the user, its profiles, its parent, and its parent's other profiles, * as applicable. * * <p>Note that this includes only profile types that are not hidden. * * @param userId id of the user to return profiles for * @param enabledOnly whether return only {@link UserInfo#isEnabled() enabled} profiles * @return A non-empty array of ids of profiles associated with the specified user if the user * exists. Otherwise, an empty array. */ public abstract @NonNull int[] getProfileIdsExcludingHidden(@UserIdInt int userId, boolean enabledOnly); /** * Checks if the {@code callingUserId} and {@code targetUserId} are same or in same group * and that the {@code callingUserId} is not a profile and {@code targetUserId} is enabled. Loading services/core/java/com/android/server/pm/UserManagerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -8048,6 +8048,14 @@ public class UserManagerService extends IUserManager.Stub { } } @Override public int[] getProfileIdsExcludingHidden(@UserIdInt int userId, boolean enabledOnly) { synchronized (mUsersLock) { return getProfileIdsLU(userId, null /* userType */, enabledOnly, /* excludeHidden */ true).toArray(); } } @Override public @Nullable LauncherUserInfo getLauncherUserInfo(@UserIdInt int userId) { UserInfo userInfo; Loading Loading
services/core/java/com/android/server/pm/LauncherAppsService.java +15 −20 Original line number Diff line number Diff line Loading @@ -379,9 +379,10 @@ public class LauncherAppsService extends SystemService { public List<UserHandle> getUserProfiles() { int[] userIds; if (!canAccessHiddenProfile(getCallingUid(), getCallingPid())) { userIds = mUm.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); userIds = mUserManagerInternal.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); } else { userIds = mUm.getEnabledProfileIds(getCallingUserId()); userIds = mUserManagerInternal.getProfileIds(getCallingUserId(), true); } final List<UserHandle> result = new ArrayList<>(userIds.length); for (int userId : userIds) { Loading @@ -398,9 +399,10 @@ public class LauncherAppsService extends SystemService { int[] userIds; if (!canAccessHiddenProfile(callingUid, Binder.getCallingPid())) { userIds = mUm.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); userIds = mUserManagerInternal.getProfileIdsExcludingHidden(getCallingUserId(), /* enabled= */ true); } else { userIds = mUm.getEnabledProfileIds(getCallingUserId()); userIds = mUserManagerInternal.getProfileIds(getCallingUserId(), true); } final long token = Binder.clearCallingIdentity(); Loading Loading @@ -503,17 +505,12 @@ public class LauncherAppsService extends SystemService { return true; } long ident = injectClearCallingIdentity(); try { final UserInfo callingUserInfo = mUm.getUserInfo(callingUserId); final UserInfo callingUserInfo = mUserManagerInternal.getUserInfo(callingUserId); if (callingUserInfo != null && callingUserInfo.isProfile()) { Slog.w(TAG, message + " for another profile " + targetUserId + " from " + callingUserId + " not allowed"); return false; } } finally { injectRestoreCallingIdentity(ident); } if (isHiddenProfile(UserHandle.of(targetUserId)) && !canAccessHiddenProfile(callingUid, callingPid)) { Loading @@ -529,9 +526,9 @@ public class LauncherAppsService extends SystemService { return false; } long identity = injectClearCallingIdentity(); try { UserProperties properties = mUm.getUserProperties(targetUser); UserProperties properties = mUserManagerInternal .getUserProperties(targetUser.getIdentifier()); if (properties == null) { return false; } Loading @@ -540,8 +537,6 @@ public class LauncherAppsService extends SystemService { == UserProperties.PROFILE_API_VISIBILITY_HIDDEN; } catch (IllegalArgumentException e) { return false; } finally { injectRestoreCallingIdentity(identity); } } Loading Loading @@ -686,7 +681,7 @@ public class LauncherAppsService extends SystemService { final int callingUid = injectBinderCallingUid(); final long ident = injectClearCallingIdentity(); try { if (mUm.getUserInfo(user.getIdentifier()).isManagedProfile()) { if (mUserManagerInternal.getUserInfo(user.getIdentifier()).isManagedProfile()) { // Managed profile should not show hidden apps return launcherActivities; } Loading Loading @@ -1713,7 +1708,7 @@ public class LauncherAppsService extends SystemService { } final long identity = Binder.clearCallingIdentity(); try { String userType = mUm.getUserInfo(user.getIdentifier()).userType; String userType = mUserManagerInternal.getUserInfo(user.getIdentifier()).userType; Set<String> preInstalledPackages = mUm.getPreInstallableSystemPackages(userType); if (preInstalledPackages == null) { return new ArrayList<>(); Loading
services/core/java/com/android/server/pm/UserManagerInternal.java +15 −0 Original line number Diff line number Diff line Loading @@ -367,6 +367,21 @@ public abstract class UserManagerInternal { */ public abstract @NonNull int[] getProfileIds(@UserIdInt int userId, boolean enabledOnly); /** * Returns a list of the users that are associated with the specified user, including the user * itself. This includes the user, its profiles, its parent, and its parent's other profiles, * as applicable. * * <p>Note that this includes only profile types that are not hidden. * * @param userId id of the user to return profiles for * @param enabledOnly whether return only {@link UserInfo#isEnabled() enabled} profiles * @return A non-empty array of ids of profiles associated with the specified user if the user * exists. Otherwise, an empty array. */ public abstract @NonNull int[] getProfileIdsExcludingHidden(@UserIdInt int userId, boolean enabledOnly); /** * Checks if the {@code callingUserId} and {@code targetUserId} are same or in same group * and that the {@code callingUserId} is not a profile and {@code targetUserId} is enabled. Loading
services/core/java/com/android/server/pm/UserManagerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -8048,6 +8048,14 @@ public class UserManagerService extends IUserManager.Stub { } } @Override public int[] getProfileIdsExcludingHidden(@UserIdInt int userId, boolean enabledOnly) { synchronized (mUsersLock) { return getProfileIdsLU(userId, null /* userType */, enabledOnly, /* excludeHidden */ true).toArray(); } } @Override public @Nullable LauncherUserInfo getLauncherUserInfo(@UserIdInt int userId) { UserInfo userInfo; Loading