diff options
author | Jessica Hummel <jhummel@google.com> | 2014-05-09 09:33:27 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-09 09:33:28 +0000 |
commit | a8c5f577d0dfa23fb955faed4966e65dd8323bc6 (patch) | |
tree | 0f406fecf8c8325b0e15fcefd7dabf6360e5397f /services | |
parent | 242c14bee570dfae4995df5cf175328e6f4155c7 (diff) | |
parent | be81c800ae6216e30b6008b4c73172b36531c405 (diff) | |
download | frameworks_base-a8c5f577d0dfa23fb955faed4966e65dd8323bc6.zip frameworks_base-a8c5f577d0dfa23fb955faed4966e65dd8323bc6.tar.gz frameworks_base-a8c5f577d0dfa23fb955faed4966e65dd8323bc6.tar.bz2 |
Merge "Add api for getting the parent of a profile."
Diffstat (limited to 'services')
-rw-r--r-- | services/core/java/com/android/server/pm/UserManagerService.java | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index 60c6313..60212bf 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -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 @@ -1022,17 +1036,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"); @@ -1049,16 +1052,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(); @@ -1071,12 +1074,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); |