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

Commit 4458ad7f authored by Kholoud Mohamed's avatar Kholoud Mohamed
Browse files

Fix bug in createAndManageUser on non hsum devices

The recent changes for blocking createAndManageUser accidentally blocked it even on non-hsum devices if the DPC had specified the single_user mode in its manifest.

Bug: 336547982
Test: atest com.android.cts.devicepolicy.DeviceOwnerTest
Change-Id: I937c68eb1a6eef6cc26e18d7f17f651e4dac072e
parent 81f6b5c6
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -12413,7 +12413,8 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        if (Flags.headlessDeviceOwnerSingleUserEnabled()) {
            // Block this method if the device is in headless main user mode
            Preconditions.checkCallAuthorization(
                    getHeadlessDeviceOwnerModeForDeviceOwner()
                    !mInjector.userManagerIsHeadlessSystemUserMode()
                            || getHeadlessDeviceOwnerModeForDeviceOwner()
                            != HEADLESS_DEVICE_OWNER_MODE_SINGLE_USER,
                    "createAndManageUser was called while in headless single user mode");
        }
@@ -23472,11 +23473,13 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    }
    private boolean hasAdminPolicy(int adminPolicy, String callerPackageName) {
        synchronized (getLockObject()) {
            CallerIdentity caller = getCallerIdentity(callerPackageName);
            ActiveAdmin deviceAdmin = getActiveAdminWithPolicyForUidLocked(
                    null, adminPolicy, caller.getUid());
            return deviceAdmin != null;
        }
    }
    /**
     * Return whether the calling process has been granted permission to apply a device policy on