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

Commit 024f979d authored by Lenka Trochtova's avatar Lenka Trochtova
Browse files

Allow ephemeral users on the split-system-user systems only.

BUG: 27143201

Change-Id: I37f3ca7366648dbf07df39a7a972857e0ff78a9a
parent 44da2940
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -1833,6 +1833,11 @@ public class UserManagerService extends IUserManager.Stub {
                        return null;
                    }
                }
                if (!UserManager.isSplitSystemUser() && (flags & UserInfo.FLAG_EPHEMERAL) != 0) {
                    Log.e(LOG_TAG,
                            "Ephemeral users are supported on split-system-user systems only.");
                    return null;
                }
                // In split system user mode, we assign the first human user the primary flag.
                // And if there is no device owner, we also assign the admin flag to primary user.
                if (UserManager.isSplitSystemUser()
+10 −0
Original line number Diff line number Diff line
@@ -4968,6 +4968,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            return;
        }
        Preconditions.checkNotNull(who, "ComponentName is null");
        // Allow setting this policy to true only if there is a split system user.
        if (forceEphemeralUsers && !mInjector.userManagerIsSplitSystemUser()) {
            throw new IllegalArgumentException(
                    "Cannot force ephemeral users on systems without split system user.");
        }
        boolean removeAllUsers = false;
        synchronized (this) {
            final ActiveAdmin deviceOwner =
@@ -6818,6 +6823,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        if (!mInjector.binderGetCallingUserHandle().isSystem()) {
            throw new SecurityException("createAndManageUser was called from non-system user");
        }
        if (!mInjector.userManagerIsSplitSystemUser()
                && (flags & DevicePolicyManager.MAKE_USER_EPHEMERAL) != 0) {
            throw new IllegalArgumentException(
                    "Ephemeral users are only supported on systems with a split system user.");
        }
        // Create user.
        UserHandle user = null;
        synchronized (this) {