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

Commit 3b428b8e authored by Kholoud Mohamed's avatar Kholoud Mohamed
Browse files

Fix bug in getCameraDisabled for a specified admin

Bug: 297983169
Test: btest a.d.c.CameraTest#getCameraDisabled_*
Change-Id: Id6695fd589e172ff98029bccf1174b9ca4e34d6c
parent fa76627b
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -623,6 +623,27 @@ final class DevicePolicyEngine {
        }
    }

    /**
     * Retrieves the global policy set by the admin for the provided {@code policyDefinition} and
     * if one was set, otherwise returns {@code null}.
     */
    @Nullable
    <V> V getGlobalPolicySetByAdmin(
            @NonNull PolicyDefinition<V> policyDefinition,
            @NonNull EnforcingAdmin enforcingAdmin) {
        Objects.requireNonNull(policyDefinition);
        Objects.requireNonNull(enforcingAdmin);

        synchronized (mLock) {
            if (!hasGlobalPolicyLocked(policyDefinition)) {
                return null;
            }
            PolicyValue<V> value = getGlobalPolicyStateLocked(policyDefinition)
                    .getPoliciesSetByAdmins().get(enforcingAdmin);
            return value == null ? null : value.getValue();
        }
    }

    /**
     * Retrieves the values set for the provided {@code policyDefinition} by each admin.
     */
+9 −3
Original line number Diff line number Diff line
@@ -9125,9 +9125,15 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                        UserManager.DISALLOW_CAMERA);
        if (who != null) {
            EnforcingAdmin admin = getEnforcingAdminForCaller(who, callerPackageName);
            return Boolean.TRUE.equals(
                    mDevicePolicyEngine.getLocalPolicySetByAdmin(
                            policy, admin, affectedUserId));
            Boolean value = null;
            if (isDeviceOwner(caller)) {
                value = mDevicePolicyEngine.getGlobalPolicySetByAdmin(policy, admin);
            } else {
                value = mDevicePolicyEngine.getLocalPolicySetByAdmin(
                        policy, admin, affectedUserId);
            }
            return Boolean.TRUE.equals(value);
        } else {
            return Boolean.TRUE.equals(
                    mDevicePolicyEngine.getResolvedPolicy(policy, affectedUserId));