Loading cmds/pm/src/com/android/commands/pm/Pm.java +1 −1 Original line number Diff line number Diff line Loading @@ -981,7 +981,7 @@ public final class Pm { } else if (userId < 0) { info = mUm.createUser(name, flags); } else { info = mUm.createProfileForUser(name, flags, userId); info = mUm.createProfileForUser(name, flags, userId, null); } if (info != null) { Loading core/java/android/os/IUserManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ interface IUserManager { int getCredentialOwnerProfile(int userHandle); UserInfo createUser(in String name, int flags); UserInfo createProfileForUser(in String name, int flags, int userHandle); UserInfo createProfileForUser(in String name, int flags, int userHandle, in String[] disallowedPackages); UserInfo createRestrictedProfile(String name, int parentUserHandle); void setUserEnabled(int userHandle); boolean removeUser(int userHandle); Loading core/java/android/os/UserManager.java +23 −4 Original line number Diff line number Diff line Loading @@ -1340,15 +1340,34 @@ public class UserManager { * * @param name the user's name * @param flags flags that identify the type of user and other properties. * @see UserInfo * @param userHandle new user will be a profile of this use. * @param userHandle new user will be a profile of this user. * * @return the UserInfo object for the created user, or null if the user could not be created. * @return the {@link UserInfo} object for the created user, or null if the user * could not be created. * @hide */ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle) { return createProfileForUser(name, flags, userHandle, null); } /** * Version of {@link #createProfileForUser(String, int, int)} that allows you to specify * any packages that should not be installed in the new profile by default, these packages can * still be installed later by the user if needed. * * @param name the user's name * @param flags flags that identify the type of user and other properties. * @param userHandle new user will be a profile of this user. * @param disallowedPackages packages that will not be installed in the profile being created. * * @return the {@link UserInfo} object for the created user, or null if the user * could not be created. * @hide */ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle, String[] disallowedPackages) { try { return mService.createProfileForUser(name, flags, userHandle); return mService.createProfileForUser(name, flags, userHandle, disallowedPackages); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } Loading services/core/java/com/android/server/pm/PackageManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -20679,9 +20679,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); } /** Called by UserManagerService */ void createNewUser(int userId) { void createNewUser(int userId, String[] disallowedPackages) { synchronized (mInstallLock) { mSettings.createNewUserLI(this, mInstaller, userId); mSettings.createNewUserLI(this, mInstaller, userId, disallowedPackages); } synchronized (mPackages) { scheduleWritePackageRestrictionsLocked(userId); services/core/java/com/android/server/pm/Settings.java +4 −2 Original line number Diff line number Diff line Loading @@ -3949,7 +3949,7 @@ final class Settings { } void createNewUserLI(@NonNull PackageManagerService service, @NonNull Installer installer, int userHandle) { int userHandle, String[] disallowedPackages) { String[] volumeUuids; String[] names; int[] appIds; Loading @@ -3970,8 +3970,10 @@ final class Settings { if (ps.pkg == null || ps.pkg.applicationInfo == null) { continue; } final boolean shouldInstall = ps.isSystem() && !ArrayUtils.contains(disallowedPackages, ps.name); // Only system apps are initially installed. ps.setInstalled(ps.isSystem(), userHandle); ps.setInstalled(shouldInstall, userHandle); // Need to create a data directory for all apps under this user. Accumulate all // required args and call the installer after mPackages lock has been released volumeUuids[i] = ps.volumeUuid; Loading Loading
cmds/pm/src/com/android/commands/pm/Pm.java +1 −1 Original line number Diff line number Diff line Loading @@ -981,7 +981,7 @@ public final class Pm { } else if (userId < 0) { info = mUm.createUser(name, flags); } else { info = mUm.createProfileForUser(name, flags, userId); info = mUm.createProfileForUser(name, flags, userId, null); } if (info != null) { Loading
core/java/android/os/IUserManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -36,7 +36,8 @@ interface IUserManager { int getCredentialOwnerProfile(int userHandle); UserInfo createUser(in String name, int flags); UserInfo createProfileForUser(in String name, int flags, int userHandle); UserInfo createProfileForUser(in String name, int flags, int userHandle, in String[] disallowedPackages); UserInfo createRestrictedProfile(String name, int parentUserHandle); void setUserEnabled(int userHandle); boolean removeUser(int userHandle); Loading
core/java/android/os/UserManager.java +23 −4 Original line number Diff line number Diff line Loading @@ -1340,15 +1340,34 @@ public class UserManager { * * @param name the user's name * @param flags flags that identify the type of user and other properties. * @see UserInfo * @param userHandle new user will be a profile of this use. * @param userHandle new user will be a profile of this user. * * @return the UserInfo object for the created user, or null if the user could not be created. * @return the {@link UserInfo} object for the created user, or null if the user * could not be created. * @hide */ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle) { return createProfileForUser(name, flags, userHandle, null); } /** * Version of {@link #createProfileForUser(String, int, int)} that allows you to specify * any packages that should not be installed in the new profile by default, these packages can * still be installed later by the user if needed. * * @param name the user's name * @param flags flags that identify the type of user and other properties. * @param userHandle new user will be a profile of this user. * @param disallowedPackages packages that will not be installed in the profile being created. * * @return the {@link UserInfo} object for the created user, or null if the user * could not be created. * @hide */ public UserInfo createProfileForUser(String name, int flags, @UserIdInt int userHandle, String[] disallowedPackages) { try { return mService.createProfileForUser(name, flags, userHandle); return mService.createProfileForUser(name, flags, userHandle, disallowedPackages); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } Loading
services/core/java/com/android/server/pm/PackageManagerService.java +2 −2 Original line number Diff line number Diff line Loading @@ -20679,9 +20679,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); } /** Called by UserManagerService */ void createNewUser(int userId) { void createNewUser(int userId, String[] disallowedPackages) { synchronized (mInstallLock) { mSettings.createNewUserLI(this, mInstaller, userId); mSettings.createNewUserLI(this, mInstaller, userId, disallowedPackages); } synchronized (mPackages) { scheduleWritePackageRestrictionsLocked(userId);
services/core/java/com/android/server/pm/Settings.java +4 −2 Original line number Diff line number Diff line Loading @@ -3949,7 +3949,7 @@ final class Settings { } void createNewUserLI(@NonNull PackageManagerService service, @NonNull Installer installer, int userHandle) { int userHandle, String[] disallowedPackages) { String[] volumeUuids; String[] names; int[] appIds; Loading @@ -3970,8 +3970,10 @@ final class Settings { if (ps.pkg == null || ps.pkg.applicationInfo == null) { continue; } final boolean shouldInstall = ps.isSystem() && !ArrayUtils.contains(disallowedPackages, ps.name); // Only system apps are initially installed. ps.setInstalled(ps.isSystem(), userHandle); ps.setInstalled(shouldInstall, userHandle); // Need to create a data directory for all apps under this user. Accumulate all // required args and call the installer after mPackages lock has been released volumeUuids[i] = ps.volumeUuid; Loading