Loading core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ interface IUserManager { Bitmap getUserIcon(int userHandle); List<UserInfo> getUsers(boolean excludeDying); List<UserInfo> getProfiles(int userHandle, boolean enabledOnly); UserInfo getProfileParent(int userHandle); UserInfo getUserInfo(int userHandle); boolean isRestricted(); void setGuestEnabled(boolean enable); Loading core/java/android/os/UserManager.java +20 −3 Original line number Diff line number Diff line Loading @@ -269,7 +269,8 @@ public class UserManager { } /** * Returns the user handle for the user that this application is running for. * Returns the user handle for the user that the calling process is running on. * * @return the user handle of the user making this call. * @hide */ Loading Loading @@ -585,7 +586,8 @@ public class UserManager { } /** * Returns a list of UserHandles for profiles associated with this user, including this user. * Returns a list of UserHandles for profiles associated with the user that the calling process * is running on, including the user itself. * * @return A non-empty list of UserHandles associated with the calling user. */ Loading @@ -605,6 +607,21 @@ public class UserManager { return profiles; } /** * Returns the parent of the profile which this method is called from * or null if called from a user that is not a profile. * * @hide */ public UserInfo getProfileParent(int userHandle) { try { return mService.getProfileParent(userHandle); } catch (RemoteException re) { Log.w(TAG, "Could not get profile parent", re); return null; } } /** * If the target user is a managed profile of the calling user or the caller * is itself a managed profile, then this returns a badged copy of the given Loading Loading @@ -632,7 +649,7 @@ public class UserManager { private int getBadgeResIdForUser(int userHandle) { // Return the framework-provided badge. List<UserInfo> userProfiles = getProfiles(UserHandle.myUserId()); List<UserInfo> userProfiles = getProfiles(getUserHandle()); for (UserInfo user : userProfiles) { if (user.id == userHandle && user.isManagedProfile()) { Loading services/core/java/com/android/server/pm/UserManagerService.java +24 −21 Original line number Diff line number Diff line Loading @@ -288,6 +288,20 @@ public class UserManagerService extends IUserManager.Stub { return users; } @Override public UserInfo getProfileParent(int userHandle) { checkManageUsersPermission("get the profile parent"); synchronized (mPackagesLock) { UserInfo profile = getUserInfoLocked(userHandle); int parentUserId = profile.profileGroupId; if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) { return null; } else { return getUserInfoLocked(parentUserId); } } } private boolean isProfileOf(UserInfo user, UserInfo profile) { return user.id == profile.id || (user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID Loading Loading @@ -1015,17 +1029,6 @@ public class UserManagerService extends IUserManager.Stub { } } private int getNextProfileGroupIdLocked() { int maxGroupId = UserInfo.NO_PROFILE_GROUP_ID; for (int i = 0; i < mUsers.size(); i++) { UserInfo ui = mUsers.valueAt(i); if (maxGroupId < ui.profileGroupId) { maxGroupId = ui.profileGroupId; } } return maxGroupId + 1; } @Override public UserInfo createProfileForUser(String name, int flags, int userId) { checkManageUsersPermission("Only the system can create users"); Loading @@ -1042,16 +1045,16 @@ public class UserManagerService extends IUserManager.Stub { return createUserInternal(name, flags, UserHandle.USER_NULL); } private UserInfo createUserInternal(String name, int flags, int profileId) { private UserInfo createUserInternal(String name, int flags, int parentId) { final long ident = Binder.clearCallingIdentity(); UserInfo userInfo = null; try { synchronized (mInstallLock) { synchronized (mPackagesLock) { UserInfo profile = null; if (profileId != UserHandle.USER_NULL) { profile = getUserInfoLocked(profileId); if (profile == null) return null; UserInfo parent = null; if (parentId != UserHandle.USER_NULL) { parent = getUserInfoLocked(parentId); if (parent == null) return null; } if (isUserLimitReachedLocked()) return null; int userId = getNextAvailableIdLocked(); Loading @@ -1064,12 +1067,12 @@ public class UserManagerService extends IUserManager.Stub { Environment.getUserSystemDirectory(userInfo.id).mkdirs(); mUsers.put(userId, userInfo); writeUserListLocked(); if (profile != null) { if (profile.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) { profile.profileGroupId = getNextProfileGroupIdLocked(); writeUserLocked(profile); if (parent != null) { if (parent.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) { parent.profileGroupId = parent.id; writeUserLocked(parent); } userInfo.profileGroupId = profile.profileGroupId; userInfo.profileGroupId = parent.profileGroupId; } writeUserLocked(userInfo); mPm.createNewUserLILPw(userId, userPath); Loading Loading
core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ interface IUserManager { Bitmap getUserIcon(int userHandle); List<UserInfo> getUsers(boolean excludeDying); List<UserInfo> getProfiles(int userHandle, boolean enabledOnly); UserInfo getProfileParent(int userHandle); UserInfo getUserInfo(int userHandle); boolean isRestricted(); void setGuestEnabled(boolean enable); Loading
core/java/android/os/UserManager.java +20 −3 Original line number Diff line number Diff line Loading @@ -269,7 +269,8 @@ public class UserManager { } /** * Returns the user handle for the user that this application is running for. * Returns the user handle for the user that the calling process is running on. * * @return the user handle of the user making this call. * @hide */ Loading Loading @@ -585,7 +586,8 @@ public class UserManager { } /** * Returns a list of UserHandles for profiles associated with this user, including this user. * Returns a list of UserHandles for profiles associated with the user that the calling process * is running on, including the user itself. * * @return A non-empty list of UserHandles associated with the calling user. */ Loading @@ -605,6 +607,21 @@ public class UserManager { return profiles; } /** * Returns the parent of the profile which this method is called from * or null if called from a user that is not a profile. * * @hide */ public UserInfo getProfileParent(int userHandle) { try { return mService.getProfileParent(userHandle); } catch (RemoteException re) { Log.w(TAG, "Could not get profile parent", re); return null; } } /** * If the target user is a managed profile of the calling user or the caller * is itself a managed profile, then this returns a badged copy of the given Loading Loading @@ -632,7 +649,7 @@ public class UserManager { private int getBadgeResIdForUser(int userHandle) { // Return the framework-provided badge. List<UserInfo> userProfiles = getProfiles(UserHandle.myUserId()); List<UserInfo> userProfiles = getProfiles(getUserHandle()); for (UserInfo user : userProfiles) { if (user.id == userHandle && user.isManagedProfile()) { Loading
services/core/java/com/android/server/pm/UserManagerService.java +24 −21 Original line number Diff line number Diff line Loading @@ -288,6 +288,20 @@ public class UserManagerService extends IUserManager.Stub { return users; } @Override public UserInfo getProfileParent(int userHandle) { checkManageUsersPermission("get the profile parent"); synchronized (mPackagesLock) { UserInfo profile = getUserInfoLocked(userHandle); int parentUserId = profile.profileGroupId; if (parentUserId == UserInfo.NO_PROFILE_GROUP_ID) { return null; } else { return getUserInfoLocked(parentUserId); } } } private boolean isProfileOf(UserInfo user, UserInfo profile) { return user.id == profile.id || (user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID Loading Loading @@ -1015,17 +1029,6 @@ public class UserManagerService extends IUserManager.Stub { } } private int getNextProfileGroupIdLocked() { int maxGroupId = UserInfo.NO_PROFILE_GROUP_ID; for (int i = 0; i < mUsers.size(); i++) { UserInfo ui = mUsers.valueAt(i); if (maxGroupId < ui.profileGroupId) { maxGroupId = ui.profileGroupId; } } return maxGroupId + 1; } @Override public UserInfo createProfileForUser(String name, int flags, int userId) { checkManageUsersPermission("Only the system can create users"); Loading @@ -1042,16 +1045,16 @@ public class UserManagerService extends IUserManager.Stub { return createUserInternal(name, flags, UserHandle.USER_NULL); } private UserInfo createUserInternal(String name, int flags, int profileId) { private UserInfo createUserInternal(String name, int flags, int parentId) { final long ident = Binder.clearCallingIdentity(); UserInfo userInfo = null; try { synchronized (mInstallLock) { synchronized (mPackagesLock) { UserInfo profile = null; if (profileId != UserHandle.USER_NULL) { profile = getUserInfoLocked(profileId); if (profile == null) return null; UserInfo parent = null; if (parentId != UserHandle.USER_NULL) { parent = getUserInfoLocked(parentId); if (parent == null) return null; } if (isUserLimitReachedLocked()) return null; int userId = getNextAvailableIdLocked(); Loading @@ -1064,12 +1067,12 @@ public class UserManagerService extends IUserManager.Stub { Environment.getUserSystemDirectory(userInfo.id).mkdirs(); mUsers.put(userId, userInfo); writeUserListLocked(); if (profile != null) { if (profile.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) { profile.profileGroupId = getNextProfileGroupIdLocked(); writeUserLocked(profile); if (parent != null) { if (parent.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) { parent.profileGroupId = parent.id; writeUserLocked(parent); } userInfo.profileGroupId = profile.profileGroupId; userInfo.profileGroupId = parent.profileGroupId; } writeUserLocked(userInfo); mPm.createNewUserLILPw(userId, userPath); Loading