Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba039066 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Allow some packages to be excluded during during work profile creation."

parents 4ac6a8e8 7cb54a34
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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) {
+2 −1
Original line number Diff line number Diff line
@@ -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);
+23 −4
Original line number Diff line number Diff line
@@ -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();
        }
+2 −2
Original line number Diff line number Diff line
@@ -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);
+4 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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