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

Commit a795fa44 authored by Ilyas Sung's avatar Ilyas Sung
Browse files

Move position of System user pre-condition check in CreateAndManageUser method

Bug: 289515470
Test: btest CreateAndManageUserTest
Change-Id: I8a55253c70f33dc8cb11d8635fc745e13547bdb5
parent 7b05e435
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -12303,9 +12303,6 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
        }
        final CallerIdentity caller = getCallerIdentity(admin);
        final CallerIdentity caller = getCallerIdentity(admin);
        // Only allow the system user to use this method
        Preconditions.checkCallAuthorization(caller.getUserHandle().isSystem(),
                "createAndManageUser was called from non-system user");
        Preconditions.checkCallAuthorization(isDefaultDeviceOwner(caller));
        Preconditions.checkCallAuthorization(isDefaultDeviceOwner(caller));
        checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_CREATE_AND_MANAGE_USER);
        checkCanExecuteOrThrowUnsafe(DevicePolicyManager.OPERATION_CREATE_AND_MANAGE_USER);
@@ -12316,6 +12313,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    "createAndManageUser was called while in headless single user mode");
                    "createAndManageUser was called while in headless single user mode");
        }
        }
        // Only allow the system user to use this method
        Preconditions.checkCallAuthorization(caller.getUserHandle().isSystem(),
                "createAndManageUser was called from non-system user");
        final boolean ephemeral = (flags & DevicePolicyManager.MAKE_USER_EPHEMERAL) != 0;
        final boolean ephemeral = (flags & DevicePolicyManager.MAKE_USER_EPHEMERAL) != 0;
        final boolean demo = (flags & DevicePolicyManager.MAKE_USER_DEMO) != 0
        final boolean demo = (flags & DevicePolicyManager.MAKE_USER_DEMO) != 0
                && UserManager.isDeviceInDemoMode(mContext);
                && UserManager.isDeviceInDemoMode(mContext);