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

Commit 171b6d8e authored by Pavel Grafov's avatar Pavel Grafov
Browse files

Extract ActiveAdmin and DevicePolicyData from DPMS.

And some minor changes:

* Don't check uid of admin returned by PackageManager since
it would only happen as a result of a horrible bug and looks
defensive.

* Don't check CrossUserPermission and feature flag in findAdmin
since it is only invoked from already trusted low level context
and not exposed via binder.

* Some redundant null checks.

* Inclusive language.

* Removed non-standard indentation in dupm() methods, replaced
  by newlines. Also added some missing spaces.

Test: presubmit
Bug: 162317175
Change-Id: Ib30787d5205235f33e350e0e66b390940b723bca
parent f577e3ed
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -139,6 +139,11 @@ public class UserRestrictionsUtils {
            UserManager.DISALLOW_CONFIG_PRIVATE_DNS
    });

    public static final Set<String> DEPRECATED_USER_RESTRICTIONS = Sets.newArraySet(
            UserManager.DISALLOW_ADD_MANAGED_PROFILE,
            UserManager.DISALLOW_REMOVE_MANAGED_PROFILE
    );

    /**
     * Set of user restriction which we don't want to persist.
     */
+1116 −0

File added.

Preview size limit exceeded, changes collapsed.

+566 −0

File added.

Preview size limit exceeded, changes collapsed.

+18 −1595

File changed.

Preview size limit exceeded, changes collapsed.

+6 −8
Original line number Diff line number Diff line
@@ -1604,7 +1604,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        dpm.setApplicationRestrictionsManagingPackage(admin1, RESTRICTIONS_DELEGATE);

        // DPMS correctly stores and retrieves the delegates
        DevicePolicyManagerService.DevicePolicyData policy = dpms.mUserData.get(userHandle);
        DevicePolicyData policy = dpms.mUserData.get(userHandle);
        assertEquals(2, policy.mDelegationMap.size());
        MoreAsserts.assertContentsInAnyOrder(policy.mDelegationMap.get(CERT_DELEGATE),
            DELEGATION_CERT_INSTALL);
@@ -1846,11 +1846,11 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        reset(getServices().userManagerInternal);
    }

    private DevicePolicyManagerService.ActiveAdmin getDeviceOwner() {
    private ActiveAdmin getDeviceOwner() {
        ComponentName component = dpms.mOwners.getDeviceOwnerComponent();
        DevicePolicyManagerService.DevicePolicyData policy =
        DevicePolicyData policy =
                dpms.getUserData(dpms.mOwners.getDeviceOwnerUserId());
        for (DevicePolicyManagerService.ActiveAdmin admin : policy.mAdminList) {
        for (ActiveAdmin admin : policy.mAdminList) {
            if (component.equals(admin.info.getComponent())) {
                return admin;
            }
@@ -3745,8 +3745,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        setUserSetupCompleteForUser(false, userId);

        // GIVEN userComplete is true in DPM
        DevicePolicyManagerService.DevicePolicyData userData =
                new DevicePolicyManagerService.DevicePolicyData(userId);
        DevicePolicyData userData = new DevicePolicyData(userId);
        userData.mUserSetupComplete = true;
        dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);

@@ -3770,8 +3769,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
        setUserSetupCompleteForUser(false, userId);

        // GIVEN userComplete is true in DPM
        DevicePolicyManagerService.DevicePolicyData userData =
                new DevicePolicyManagerService.DevicePolicyData(userId);
        DevicePolicyData userData = new DevicePolicyData(userId);
        userData.mUserSetupComplete = true;
        dpms.mUserData.put(UserHandle.USER_SYSTEM, userData);