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

Commit 26e845bd authored by Leonid Baraz's avatar Leonid Baraz
Browse files

Add missing lock to areAllUsersAffiliatedWithDeviceLocked

Added missing guards and @Guarded annotation by `getLockObject()`

Bug: 323495252
Change-Id: I49e835025940ee69138ee9782ef13e66fd7ee785
Test: Run CTS-Verifier "Check new user disclaimer" test and see a notification and a dialog are shown.
Flag: EXEMPT bugfix
parent 0bbf1dde
Loading
Loading
Loading
Loading
+19 −11
Original line number Diff line number Diff line
@@ -4152,9 +4152,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    }
    private void checkAllUsersAreAffiliatedWithDevice() {
        synchronized (getLockObject()) {
            Preconditions.checkCallAuthorization(areAllUsersAffiliatedWithDeviceLocked(),
                    "operation not allowed when device has unaffiliated users");
        }
    }
    @Override
    public boolean isAdminActive(ComponentName adminReceiver, int userHandle) {
@@ -18213,6 +18215,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        return false;
    }
    @GuardedBy("getLockObject()")
    private boolean areAllUsersAffiliatedWithDeviceLocked() {
        return mInjector.binderWithCleanCallingIdentity(() -> {
            final List<UserInfo> userInfos = mUserManager.getAliveUsers();
@@ -18310,10 +18313,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        final CallerIdentity caller = getCallerIdentity(admin, packageName);
        if (isPermissionCheckFlagEnabled()) {
            synchronized (getLockObject()) {
                Preconditions.checkCallAuthorization(isOrganizationOwnedDeviceWithManagedProfile()
                        || areAllUsersAffiliatedWithDeviceLocked());
                enforcePermission(MANAGE_DEVICE_POLICY_SECURITY_LOGGING, caller.getPackageName(),
                        UserHandle.USER_ALL);
            }
        } else {
            if (admin != null) {
                Preconditions.checkCallAuthorization(
@@ -18325,9 +18330,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                        isCallerDelegate(caller, DELEGATION_SECURITY_LOGGING));
            }
            synchronized (getLockObject()) {
                Preconditions.checkCallAuthorization(isOrganizationOwnedDeviceWithManagedProfile()
                        || areAllUsersAffiliatedWithDeviceLocked());
            }
        }
        DevicePolicyEventLogger
                .createEvent(DevicePolicyEnums.RETRIEVE_PRE_REBOOT_SECURITY_LOGS)
@@ -24541,6 +24548,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        });
    }
    @GuardedBy("getLockObject()")
    private void migrateUserControlDisabledPackagesLocked() {
        Binder.withCleanCallingIdentity(() -> {
            List<UserInfo> users = mUserManager.getUsers();