Loading core/java/android/os/UserManager.java +10 −31 Original line number Diff line number Diff line Loading @@ -839,7 +839,8 @@ public class UserManager { } /** * Creates a user with the specified name and options. * Creates a user with the specified name and options. For non-admin users, default user * restrictions are going to be applied. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * * @param name the user's name Loading @@ -850,12 +851,18 @@ public class UserManager { * @hide */ public UserInfo createUser(String name, int flags) { UserInfo user = null; try { return mService.createUser(name, flags); user = mService.createUser(name, flags); if (user != null && !user.isAdmin()) { Bundle userRestrictions = mService.getUserRestrictions(user.id); addDefaultUserRestrictions(userRestrictions); mService.setUserRestrictions(userRestrictions, user.id); } } catch (RemoteException re) { Log.w(TAG, "Could not create a user", re); return null; } return user; } /** Loading @@ -881,34 +888,6 @@ public class UserManager { return guest; } /** * Creates a secondary user with the specified name and options and configures it with default * restrictions. * 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 * * @return the UserInfo object for the created user, or null if the user could not be created. * @hide */ public UserInfo createSecondaryUser(String name, int flags) { try { UserInfo user = mService.createUser(name, flags); if (user == null) { return null; } Bundle userRestrictions = mService.getUserRestrictions(user.id); addDefaultUserRestrictions(userRestrictions); mService.setUserRestrictions(userRestrictions, user.id); return user; } catch (RemoteException re) { Log.w(TAG, "Could not create a user", re); return null; } } private static void addDefaultUserRestrictions(Bundle restrictions) { restrictions.putBoolean(DISALLOW_OUTGOING_CALLS, true); restrictions.putBoolean(DISALLOW_SMS, true); Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +1 −1 Original line number Diff line number Diff line Loading @@ -621,7 +621,7 @@ public class UserSwitcherController { if (ActivityManager.isUserAMonkey()) { return; } UserInfo user = mUserManager.createSecondaryUser( UserInfo user = mUserManager.createUser( mContext.getString(R.string.user_new_user_name), 0 /* flags */); if (user == null) { // Couldn't create user, most likely because there are too many, but we haven't Loading Loading
core/java/android/os/UserManager.java +10 −31 Original line number Diff line number Diff line Loading @@ -839,7 +839,8 @@ public class UserManager { } /** * Creates a user with the specified name and options. * Creates a user with the specified name and options. For non-admin users, default user * restrictions are going to be applied. * Requires {@link android.Manifest.permission#MANAGE_USERS} permission. * * @param name the user's name Loading @@ -850,12 +851,18 @@ public class UserManager { * @hide */ public UserInfo createUser(String name, int flags) { UserInfo user = null; try { return mService.createUser(name, flags); user = mService.createUser(name, flags); if (user != null && !user.isAdmin()) { Bundle userRestrictions = mService.getUserRestrictions(user.id); addDefaultUserRestrictions(userRestrictions); mService.setUserRestrictions(userRestrictions, user.id); } } catch (RemoteException re) { Log.w(TAG, "Could not create a user", re); return null; } return user; } /** Loading @@ -881,34 +888,6 @@ public class UserManager { return guest; } /** * Creates a secondary user with the specified name and options and configures it with default * restrictions. * 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 * * @return the UserInfo object for the created user, or null if the user could not be created. * @hide */ public UserInfo createSecondaryUser(String name, int flags) { try { UserInfo user = mService.createUser(name, flags); if (user == null) { return null; } Bundle userRestrictions = mService.getUserRestrictions(user.id); addDefaultUserRestrictions(userRestrictions); mService.setUserRestrictions(userRestrictions, user.id); return user; } catch (RemoteException re) { Log.w(TAG, "Could not create a user", re); return null; } } private static void addDefaultUserRestrictions(Bundle restrictions) { restrictions.putBoolean(DISALLOW_OUTGOING_CALLS, true); restrictions.putBoolean(DISALLOW_SMS, true); Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +1 −1 Original line number Diff line number Diff line Loading @@ -621,7 +621,7 @@ public class UserSwitcherController { if (ActivityManager.isUserAMonkey()) { return; } UserInfo user = mUserManager.createSecondaryUser( UserInfo user = mUserManager.createUser( mContext.getString(R.string.user_new_user_name), 0 /* flags */); if (user == null) { // Couldn't create user, most likely because there are too many, but we haven't Loading