Loading cmds/pm/src/com/android/commands/pm/Pm.java +5 −5 Original line number Diff line number Diff line Loading @@ -1033,18 +1033,18 @@ public final class Pm { public void runCreateUser() { String name; int relatedUserId = -1; int userId = -1; int flags = 0; String opt; while ((opt = nextOption()) != null) { if ("--relatedTo".equals(opt)) { if ("--profileOf".equals(opt)) { String optionData = nextOptionData(); if (optionData == null || !isNumber(optionData)) { System.err.println("Error: no USER_ID specified"); showUsage(); return; } else { relatedUserId = Integer.parseInt(optionData); userId = Integer.parseInt(optionData); } } else if ("--managed".equals(opt)) { flags |= UserInfo.FLAG_MANAGED_PROFILE; Loading @@ -1062,14 +1062,14 @@ public final class Pm { name = arg; try { UserInfo info = null; if (relatedUserId < 0) { if (userId < 0) { info = mUm.createUser(name, flags); } else { if (Process.myUid() != 0) { System.err.println("Error: not running as root."); return; } info = mUm.createRelatedUser(name, flags, relatedUserId); info = mUm.createProfileForUser(name, flags, userId); } if (info != null) { System.out.println("Success: created user id " + info.id); Loading core/java/android/app/ActivityManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -605,11 +605,11 @@ public class ActivityManager { public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002; /** * Provides a list that also contains recent tasks for user * and related users. * Provides a list that contains recent tasks for all * profiles of a user. * @hide */ public static final int RECENT_INCLUDE_RELATED = 0x0004; public static final int RECENT_INCLUDE_PROFILES = 0x0004; /** * Return a list of the tasks that the user has recently launched, with Loading core/java/android/content/pm/UserInfo.java +6 −6 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class UserInfo implements Parcelable { public static final int FLAG_MANAGED_PROFILE = 0x00000020; public static final int NO_RELATED_GROUP_ID = -1; public static final int NO_PROFILE_GROUP_ID = -1; public int id; public int serialNumber; Loading @@ -80,7 +80,7 @@ public class UserInfo implements Parcelable { public int flags; public long creationTime; public long lastLoggedInTime; public int relatedGroupId; public int profileGroupId; /** User is only partially created. */ public boolean partial; Loading @@ -94,7 +94,7 @@ public class UserInfo implements Parcelable { this.name = name; this.flags = flags; this.iconPath = iconPath; this.relatedGroupId = NO_RELATED_GROUP_ID; this.profileGroupId = NO_PROFILE_GROUP_ID; } public boolean isPrimary() { Loading Loading @@ -137,7 +137,7 @@ public class UserInfo implements Parcelable { creationTime = orig.creationTime; lastLoggedInTime = orig.lastLoggedInTime; partial = orig.partial; relatedGroupId = orig.relatedGroupId; profileGroupId = orig.profileGroupId; } public UserHandle getUserHandle() { Loading @@ -162,7 +162,7 @@ public class UserInfo implements Parcelable { dest.writeLong(creationTime); dest.writeLong(lastLoggedInTime); dest.writeInt(partial ? 1 : 0); dest.writeInt(relatedGroupId); dest.writeInt(profileGroupId); } public static final Parcelable.Creator<UserInfo> CREATOR Loading @@ -184,6 +184,6 @@ public class UserInfo implements Parcelable { creationTime = source.readLong(); lastLoggedInTime = source.readLong(); partial = source.readInt() != 0; relatedGroupId = source.readInt(); profileGroupId = source.readInt(); } } core/java/android/os/IUserManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ import android.graphics.Bitmap; */ interface IUserManager { UserInfo createUser(in String name, int flags); UserInfo createRelatedUser(in String name, int flags, int relatedUserId); UserInfo createProfileForUser(in String name, int flags, int userHandle); boolean removeUser(int userHandle); void setUserName(int userHandle, String name); void setUserIcon(int userHandle, in Bitmap icon); Bitmap getUserIcon(int userHandle); List<UserInfo> getUsers(boolean excludeDying); List<UserInfo> getRelatedUsers(int userHandle); List<UserInfo> getProfiles(int userHandle); UserInfo getUserInfo(int userHandle); boolean isRestricted(); void setGuestEnabled(boolean enable); Loading core/java/android/os/UserManager.java +29 −9 Original line number Diff line number Diff line Loading @@ -410,20 +410,29 @@ public class UserManager { } /** * Creates a user with the specified name and options. * Renamed, just present to avoid multi project commit. * TODO delete. * @hide */ public UserInfo createRelatedUser(String name, int flags, int relatedUserId) { return createProfileForUser(name, flags, relatedUserId); } /** * Creates a user with the specified name and options as a profile of another user. * 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. * @see UserInfo * @param relatedUserId new user will be related to this user id. * @param userHandle new user will be a profile of this use. * * @return the UserInfo object for the created user, or null if the user could not be created. * @hide */ public UserInfo createRelatedUser(String name, int flags, int relatedUserId) { public UserInfo createProfileForUser(String name, int flags, int userHandle) { try { return mService.createRelatedUser(name, flags, relatedUserId); return mService.createProfileForUser(name, flags, userHandle); } catch (RemoteException re) { Log.w(TAG, "Could not create a user", re); return null; Loading Loading @@ -454,15 +463,26 @@ public class UserManager { } /** * Returns information for all users related to userId * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle users related to this user id will be returned. * @return the list of related users. * Renaming, left to avoid multi project commit. * TODO Delete. * @hide */ public List<UserInfo> getRelatedUsers(int userHandle) { return getProfiles(userHandle); } /** * Returns list of the profiles of userHandle including * userHandle itself. * * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle profiles of this user will be returned. * @return the list of profiles. * @hide */ public List<UserInfo> getProfiles(int userHandle) { try { return mService.getRelatedUsers(userHandle); return mService.getProfiles(userHandle); } catch (RemoteException re) { Log.w(TAG, "Could not get user list", re); return null; Loading Loading
cmds/pm/src/com/android/commands/pm/Pm.java +5 −5 Original line number Diff line number Diff line Loading @@ -1033,18 +1033,18 @@ public final class Pm { public void runCreateUser() { String name; int relatedUserId = -1; int userId = -1; int flags = 0; String opt; while ((opt = nextOption()) != null) { if ("--relatedTo".equals(opt)) { if ("--profileOf".equals(opt)) { String optionData = nextOptionData(); if (optionData == null || !isNumber(optionData)) { System.err.println("Error: no USER_ID specified"); showUsage(); return; } else { relatedUserId = Integer.parseInt(optionData); userId = Integer.parseInt(optionData); } } else if ("--managed".equals(opt)) { flags |= UserInfo.FLAG_MANAGED_PROFILE; Loading @@ -1062,14 +1062,14 @@ public final class Pm { name = arg; try { UserInfo info = null; if (relatedUserId < 0) { if (userId < 0) { info = mUm.createUser(name, flags); } else { if (Process.myUid() != 0) { System.err.println("Error: not running as root."); return; } info = mUm.createRelatedUser(name, flags, relatedUserId); info = mUm.createProfileForUser(name, flags, userId); } if (info != null) { System.out.println("Success: created user id " + info.id); Loading
core/java/android/app/ActivityManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -605,11 +605,11 @@ public class ActivityManager { public static final int RECENT_IGNORE_UNAVAILABLE = 0x0002; /** * Provides a list that also contains recent tasks for user * and related users. * Provides a list that contains recent tasks for all * profiles of a user. * @hide */ public static final int RECENT_INCLUDE_RELATED = 0x0004; public static final int RECENT_INCLUDE_PROFILES = 0x0004; /** * Return a list of the tasks that the user has recently launched, with Loading
core/java/android/content/pm/UserInfo.java +6 −6 Original line number Diff line number Diff line Loading @@ -71,7 +71,7 @@ public class UserInfo implements Parcelable { public static final int FLAG_MANAGED_PROFILE = 0x00000020; public static final int NO_RELATED_GROUP_ID = -1; public static final int NO_PROFILE_GROUP_ID = -1; public int id; public int serialNumber; Loading @@ -80,7 +80,7 @@ public class UserInfo implements Parcelable { public int flags; public long creationTime; public long lastLoggedInTime; public int relatedGroupId; public int profileGroupId; /** User is only partially created. */ public boolean partial; Loading @@ -94,7 +94,7 @@ public class UserInfo implements Parcelable { this.name = name; this.flags = flags; this.iconPath = iconPath; this.relatedGroupId = NO_RELATED_GROUP_ID; this.profileGroupId = NO_PROFILE_GROUP_ID; } public boolean isPrimary() { Loading Loading @@ -137,7 +137,7 @@ public class UserInfo implements Parcelable { creationTime = orig.creationTime; lastLoggedInTime = orig.lastLoggedInTime; partial = orig.partial; relatedGroupId = orig.relatedGroupId; profileGroupId = orig.profileGroupId; } public UserHandle getUserHandle() { Loading @@ -162,7 +162,7 @@ public class UserInfo implements Parcelable { dest.writeLong(creationTime); dest.writeLong(lastLoggedInTime); dest.writeInt(partial ? 1 : 0); dest.writeInt(relatedGroupId); dest.writeInt(profileGroupId); } public static final Parcelable.Creator<UserInfo> CREATOR Loading @@ -184,6 +184,6 @@ public class UserInfo implements Parcelable { creationTime = source.readLong(); lastLoggedInTime = source.readLong(); partial = source.readInt() != 0; relatedGroupId = source.readInt(); profileGroupId = source.readInt(); } }
core/java/android/os/IUserManager.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -28,13 +28,13 @@ import android.graphics.Bitmap; */ interface IUserManager { UserInfo createUser(in String name, int flags); UserInfo createRelatedUser(in String name, int flags, int relatedUserId); UserInfo createProfileForUser(in String name, int flags, int userHandle); boolean removeUser(int userHandle); void setUserName(int userHandle, String name); void setUserIcon(int userHandle, in Bitmap icon); Bitmap getUserIcon(int userHandle); List<UserInfo> getUsers(boolean excludeDying); List<UserInfo> getRelatedUsers(int userHandle); List<UserInfo> getProfiles(int userHandle); UserInfo getUserInfo(int userHandle); boolean isRestricted(); void setGuestEnabled(boolean enable); Loading
core/java/android/os/UserManager.java +29 −9 Original line number Diff line number Diff line Loading @@ -410,20 +410,29 @@ public class UserManager { } /** * Creates a user with the specified name and options. * Renamed, just present to avoid multi project commit. * TODO delete. * @hide */ public UserInfo createRelatedUser(String name, int flags, int relatedUserId) { return createProfileForUser(name, flags, relatedUserId); } /** * Creates a user with the specified name and options as a profile of another user. * 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. * @see UserInfo * @param relatedUserId new user will be related to this user id. * @param userHandle new user will be a profile of this use. * * @return the UserInfo object for the created user, or null if the user could not be created. * @hide */ public UserInfo createRelatedUser(String name, int flags, int relatedUserId) { public UserInfo createProfileForUser(String name, int flags, int userHandle) { try { return mService.createRelatedUser(name, flags, relatedUserId); return mService.createProfileForUser(name, flags, userHandle); } catch (RemoteException re) { Log.w(TAG, "Could not create a user", re); return null; Loading Loading @@ -454,15 +463,26 @@ public class UserManager { } /** * Returns information for all users related to userId * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle users related to this user id will be returned. * @return the list of related users. * Renaming, left to avoid multi project commit. * TODO Delete. * @hide */ public List<UserInfo> getRelatedUsers(int userHandle) { return getProfiles(userHandle); } /** * Returns list of the profiles of userHandle including * userHandle itself. * * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * @param userHandle profiles of this user will be returned. * @return the list of profiles. * @hide */ public List<UserInfo> getProfiles(int userHandle) { try { return mService.getRelatedUsers(userHandle); return mService.getProfiles(userHandle); } catch (RemoteException re) { Log.w(TAG, "Could not get user list", re); return null; Loading