Loading core/java/android/os/UserManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public class UserManager { /** * Returns the user name of the user making this call. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @return the user name */ public String getUserName() { Loading @@ -69,6 +70,7 @@ public class UserManager { /** * Returns the UserInfo object describing a specific user. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle the user handle of the user whose information is being requested. * @return the UserInfo object for a specific user. * @hide Loading @@ -84,6 +86,7 @@ public class UserManager { /** * Creates a user with the specified name and options. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * * @param name the user's name * @param flags flags that identify the type of user and other properties. Loading @@ -103,6 +106,7 @@ public class UserManager { /** * Returns information for all users on this device. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @return the list of users that were created. * @hide */ Loading @@ -117,6 +121,7 @@ public class UserManager { /** * Removes a user and all associated data. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle the integer handle of the user, where 0 is the primary user. * @hide */ Loading @@ -131,6 +136,7 @@ public class UserManager { /** * Updates the user's name. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * * @param userHandle the user's integer handle * @param name the new name for the user Loading Loading @@ -162,6 +168,7 @@ public class UserManager { /** * Enable or disable the use of a guest account. If disabled, the existing guest account * will be wiped. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param enable whether to enable a guest account. * @hide */ Loading @@ -175,6 +182,7 @@ public class UserManager { /** * Checks if a guest user is enabled for this device. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @return whether a guest user is enabled * @hide */ Loading @@ -189,6 +197,7 @@ public class UserManager { /** * Wipes all the data for a user, but doesn't remove the user. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle * @hide */ Loading core/res/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -790,7 +790,7 @@ third party applications. --> <permission android:name="android.permission.MANAGE_USERS" android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="signature" android:protectionLevel="signature|system" android:label="@string/permlab_manageUsers" android:description="@string/permdesc_manageUsers" /> Loading services/java/com/android/server/pm/UserManagerService.java +21 −12 Original line number Diff line number Diff line Loading @@ -137,11 +137,17 @@ public class UserManagerService extends IUserManager.Stub { public UserInfo getUserInfo(int userId) { checkManageUsersPermission("query user"); synchronized (mUsers) { UserInfo info = mUsers.get(userId); return info; return getUserInfoLocked(userId); } } /* * Should be locked on mUsers before calling this. */ private UserInfo getUserInfoLocked(int userId) { return mUsers.get(userId); } public boolean exists(int userId) { synchronized (mUsers) { return ArrayUtils.contains(mUserIds, userId); Loading Loading @@ -212,8 +218,9 @@ public class UserManagerService extends IUserManager.Stub { } /** * Enforces that only the system UID or root's UID can call a method exposed * via Binder. * Enforces that only the system UID or root's UID or apps that have the * {@link android.Manifest.permission.MANAGE_USERS MANAGE_USERS} * permission can make certain calls to the UserManager. * * @param message used as message if SecurityException is thrown * @throws SecurityException if the caller is not system or root Loading Loading @@ -534,7 +541,7 @@ public class UserManagerService extends IUserManager.Stub { public int getUserSerialNumber(int userHandle) { synchronized (mUsers) { if (!exists(userHandle)) return -1; return getUserInfo(userHandle).serialNumber; return getUserInfoLocked(userHandle).serialNumber; } } Loading @@ -542,7 +549,7 @@ public class UserManagerService extends IUserManager.Stub { public int getUserHandle(int userSerialNumber) { synchronized (mUsers) { for (int userId : mUserIds) { if (getUserInfo(userId).serialNumber == userSerialNumber) return userId; if (getUserInfoLocked(userId).serialNumber == userSerialNumber) return userId; } // Not found return -1; Loading Loading @@ -617,6 +624,7 @@ public class UserManagerService extends IUserManager.Stub { * @return */ private int getNextAvailableId() { synchronized (mUsers) { int i = 0; while (i < Integer.MAX_VALUE) { if (mUsers.indexOfKey(i) < 0) { Loading @@ -626,6 +634,7 @@ public class UserManagerService extends IUserManager.Stub { } return i; } } private boolean createPackageFolders(int id, File userPath) { // mInstaller may not be available for unit-tests. Loading services/tests/servicestests/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.MANAGE_USERS" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <application> <uses-library android:name="android.test.runner" /> Loading Loading
core/java/android/os/UserManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public class UserManager { /** * Returns the user name of the user making this call. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @return the user name */ public String getUserName() { Loading @@ -69,6 +70,7 @@ public class UserManager { /** * Returns the UserInfo object describing a specific user. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle the user handle of the user whose information is being requested. * @return the UserInfo object for a specific user. * @hide Loading @@ -84,6 +86,7 @@ public class UserManager { /** * Creates a user with the specified name and options. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * * @param name the user's name * @param flags flags that identify the type of user and other properties. Loading @@ -103,6 +106,7 @@ public class UserManager { /** * Returns information for all users on this device. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @return the list of users that were created. * @hide */ Loading @@ -117,6 +121,7 @@ public class UserManager { /** * Removes a user and all associated data. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle the integer handle of the user, where 0 is the primary user. * @hide */ Loading @@ -131,6 +136,7 @@ public class UserManager { /** * Updates the user's name. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * * @param userHandle the user's integer handle * @param name the new name for the user Loading Loading @@ -162,6 +168,7 @@ public class UserManager { /** * Enable or disable the use of a guest account. If disabled, the existing guest account * will be wiped. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param enable whether to enable a guest account. * @hide */ Loading @@ -175,6 +182,7 @@ public class UserManager { /** * Checks if a guest user is enabled for this device. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @return whether a guest user is enabled * @hide */ Loading @@ -189,6 +197,7 @@ public class UserManager { /** * Wipes all the data for a user, but doesn't remove the user. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle * @hide */ Loading
core/res/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -790,7 +790,7 @@ third party applications. --> <permission android:name="android.permission.MANAGE_USERS" android:permissionGroup="android.permission-group.SYSTEM_TOOLS" android:protectionLevel="signature" android:protectionLevel="signature|system" android:label="@string/permlab_manageUsers" android:description="@string/permdesc_manageUsers" /> Loading
services/java/com/android/server/pm/UserManagerService.java +21 −12 Original line number Diff line number Diff line Loading @@ -137,11 +137,17 @@ public class UserManagerService extends IUserManager.Stub { public UserInfo getUserInfo(int userId) { checkManageUsersPermission("query user"); synchronized (mUsers) { UserInfo info = mUsers.get(userId); return info; return getUserInfoLocked(userId); } } /* * Should be locked on mUsers before calling this. */ private UserInfo getUserInfoLocked(int userId) { return mUsers.get(userId); } public boolean exists(int userId) { synchronized (mUsers) { return ArrayUtils.contains(mUserIds, userId); Loading Loading @@ -212,8 +218,9 @@ public class UserManagerService extends IUserManager.Stub { } /** * Enforces that only the system UID or root's UID can call a method exposed * via Binder. * Enforces that only the system UID or root's UID or apps that have the * {@link android.Manifest.permission.MANAGE_USERS MANAGE_USERS} * permission can make certain calls to the UserManager. * * @param message used as message if SecurityException is thrown * @throws SecurityException if the caller is not system or root Loading Loading @@ -534,7 +541,7 @@ public class UserManagerService extends IUserManager.Stub { public int getUserSerialNumber(int userHandle) { synchronized (mUsers) { if (!exists(userHandle)) return -1; return getUserInfo(userHandle).serialNumber; return getUserInfoLocked(userHandle).serialNumber; } } Loading @@ -542,7 +549,7 @@ public class UserManagerService extends IUserManager.Stub { public int getUserHandle(int userSerialNumber) { synchronized (mUsers) { for (int userId : mUserIds) { if (getUserInfo(userId).serialNumber == userSerialNumber) return userId; if (getUserInfoLocked(userId).serialNumber == userSerialNumber) return userId; } // Not found return -1; Loading Loading @@ -617,6 +624,7 @@ public class UserManagerService extends IUserManager.Stub { * @return */ private int getNextAvailableId() { synchronized (mUsers) { int i = 0; while (i < Integer.MAX_VALUE) { if (mUsers.indexOfKey(i) < 0) { Loading @@ -626,6 +634,7 @@ public class UserManagerService extends IUserManager.Stub { } return i; } } private boolean createPackageFolders(int id, File userPath) { // mInstaller may not be available for unit-tests. Loading
services/tests/servicestests/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.MANAGE_USERS" /> <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS" /> <application> <uses-library android:name="android.test.runner" /> Loading