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

Commit 8ce16aad authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Automerger Merge Worker
Browse files

Merge changes from topic "fixSettingsCrash" into udc-dev am: 25ffa223

parents 5263ffa5 25ffa223
Loading
Loading
Loading
Loading
+32 −0
Original line number Original line Diff line number Diff line
@@ -684,6 +684,38 @@ final class DevicePolicyEngine {
        }
        }
    }
    }


    <V> void transferPolicies(EnforcingAdmin oldAdmin, EnforcingAdmin newAdmin) {
        Set<PolicyKey> globalPolicies = new HashSet<>(mGlobalPolicies.keySet());
        for (PolicyKey policy : globalPolicies) {
            PolicyState<?> policyState = mGlobalPolicies.get(policy);
            if (policyState.getPoliciesSetByAdmins().containsKey(oldAdmin)) {
                PolicyDefinition<V> policyDefinition =
                        (PolicyDefinition<V>) policyState.getPolicyDefinition();
                PolicyValue<V> policyValue =
                        (PolicyValue<V>) policyState.getPoliciesSetByAdmins().get(oldAdmin);
                setGlobalPolicy(policyDefinition, newAdmin, policyValue);
            }
        }

        for (int i = 0; i < mLocalPolicies.size(); i++) {
            int userId = mLocalPolicies.keyAt(i);
            Set<PolicyKey> localPolicies = new HashSet<>(
                    mLocalPolicies.get(userId).keySet());
            for (PolicyKey policy : localPolicies) {
                PolicyState<?> policyState = mLocalPolicies.get(userId).get(policy);
                if (policyState.getPoliciesSetByAdmins().containsKey(oldAdmin)) {
                    PolicyDefinition<V> policyDefinition =
                            (PolicyDefinition<V>) policyState.getPolicyDefinition();
                    PolicyValue<V> policyValue =
                            (PolicyValue<V>) policyState.getPoliciesSetByAdmins().get(oldAdmin);
                    setLocalPolicy(policyDefinition, newAdmin, policyValue, userId);
                }
            }
        }

        removePoliciesForAdmin(oldAdmin);
    }

    private Set<UserRestrictionPolicyKey> getUserRestrictionPolicyKeysForAdminLocked(
    private Set<UserRestrictionPolicyKey> getUserRestrictionPolicyKeysForAdminLocked(
            Map<PolicyKey, PolicyState<?>> policies,
            Map<PolicyKey, PolicyState<?>> policies,
            EnforcingAdmin admin) {
            EnforcingAdmin admin) {
+84 −44

File changed.

Preview size limit exceeded, changes collapsed.

+13 −0
Original line number Original line Diff line number Diff line
@@ -1512,6 +1512,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
     * Validates that when the device owner is removed, the reset password token is cleared
     * Validates that when the device owner is removed, the reset password token is cleared
     */
     */
    @Test
    @Test
    @Ignore("b/277916462")
    public void testClearDeviceOwner_clearResetPasswordToken() throws Exception {
    public void testClearDeviceOwner_clearResetPasswordToken() throws Exception {
        mContext.callerPermissions.add(android.Manifest.permission.MANAGE_DEVICE_ADMINS);
        mContext.callerPermissions.add(android.Manifest.permission.MANAGE_DEVICE_ADMINS);
        mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
        mContext.callerPermissions.add(permission.MANAGE_PROFILE_AND_DEVICE_OWNERS);
@@ -2602,6 +2603,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetApplicationHiddenWithDO() throws Exception {
    public void testSetApplicationHiddenWithDO() throws Exception {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setupDeviceOwner();
        setupDeviceOwner();
@@ -2627,6 +2629,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetApplicationHiddenWithPOOfOrganizationOwnedDevice() throws Exception {
    public void testSetApplicationHiddenWithPOOfOrganizationOwnedDevice() throws Exception {
        final int MANAGED_PROFILE_USER_ID = CALLER_USER_HANDLE;
        final int MANAGED_PROFILE_USER_ID = CALLER_USER_HANDLE;
        final int MANAGED_PROFILE_ADMIN_UID =
        final int MANAGED_PROFILE_ADMIN_UID =
@@ -4373,6 +4376,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetAutoTimeZoneEnabledModifiesSetting() throws Exception {
    public void testSetAutoTimeZoneEnabledModifiesSetting() throws Exception {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setupDeviceOwner();
        setupDeviceOwner();
@@ -4384,6 +4388,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetAutoTimeZoneEnabledWithPOOnUser0() throws Exception {
    public void testSetAutoTimeZoneEnabledWithPOOnUser0() throws Exception {
        mContext.binder.callingUid = DpmMockContext.SYSTEM_UID;
        mContext.binder.callingUid = DpmMockContext.SYSTEM_UID;
        setupProfileOwnerOnUser0();
        setupProfileOwnerOnUser0();
@@ -4395,6 +4400,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetAutoTimeZoneEnabledFailWithPONotOnUser0() throws Exception {
    public void testSetAutoTimeZoneEnabledFailWithPONotOnUser0() throws Exception {
        setupProfileOwner();
        setupProfileOwner();
        assertExpectException(SecurityException.class, null,
        assertExpectException(SecurityException.class, null,
@@ -4404,6 +4410,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetAutoTimeZoneEnabledWithPOOfOrganizationOwnedDevice() throws Exception {
    public void testSetAutoTimeZoneEnabledWithPOOfOrganizationOwnedDevice() throws Exception {
        setupProfileOwner();
        setupProfileOwner();
        configureProfileOwnerOfOrgOwnedDevice(admin1, CALLER_USER_HANDLE);
        configureProfileOwnerOfOrgOwnedDevice(admin1, CALLER_USER_HANDLE);
@@ -5377,6 +5384,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testResetPasswordWithToken() throws Exception {
    public void testResetPasswordWithToken() throws Exception {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setupDeviceOwner();
        setupDeviceOwner();
@@ -5411,6 +5419,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void resetPasswordWithToken_NumericPin() throws Exception {
    public void resetPasswordWithToken_NumericPin() throws Exception {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setupDeviceOwner();
        setupDeviceOwner();
@@ -5431,6 +5440,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void resetPasswordWithToken_EmptyPassword() throws Exception {
    public void resetPasswordWithToken_EmptyPassword() throws Exception {
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        mContext.binder.callingUid = DpmMockContext.CALLER_SYSTEM_USER_UID;
        setupDeviceOwner();
        setupDeviceOwner();
@@ -7251,6 +7261,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testCanProfileOwnerResetPasswordWhenLocked() throws Exception {
    public void testCanProfileOwnerResetPasswordWhenLocked() throws Exception {
        setDeviceEncryptionPerUser();
        setDeviceEncryptionPerUser();
        setupProfileOwner();
        setupProfileOwner();
@@ -7314,6 +7325,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetAccountTypesWithManagementDisabledOnManagedProfile() throws Exception {
    public void testSetAccountTypesWithManagementDisabledOnManagedProfile() throws Exception {
        setupProfileOwner();
        setupProfileOwner();


@@ -7333,6 +7345,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
    }
    }


    @Test
    @Test
    @Ignore("b/277916462")
    public void testSetAccountTypesWithManagementDisabledOnOrgOwnedManagedProfile()
    public void testSetAccountTypesWithManagementDisabledOnOrgOwnedManagedProfile()
            throws Exception {
            throws Exception {
        mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS);
        mContext.callerPermissions.add(permission.INTERACT_ACROSS_USERS);