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

Commit 397999f0 authored by Amith Yamasani's avatar Amith Yamasani Committed by Android (Google) Code Review
Browse files

Merge "Save per-user camera policy in different system properties"

parents 85b88003 50956980
Loading
Loading
Loading
Loading
+7 −5
Original line number Original line Diff line number Diff line
@@ -1580,15 +1580,16 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
    void syncDeviceCapabilitiesLocked(DevicePolicyData policy) {
    void syncDeviceCapabilitiesLocked(DevicePolicyData policy) {
        // Ensure the status of the camera is synced down to the system. Interested native services
        // Ensure the status of the camera is synced down to the system. Interested native services
        // should monitor this value and act accordingly.
        // should monitor this value and act accordingly.
        boolean systemState = SystemProperties.getBoolean(SYSTEM_PROP_DISABLE_CAMERA, false);
        String cameraPropertyForUser = SYSTEM_PROP_DISABLE_CAMERA_PREFIX + policy.mUserHandle;
        boolean systemState = SystemProperties.getBoolean(cameraPropertyForUser, false);
        boolean cameraDisabled = getCameraDisabled(null, policy.mUserHandle);
        boolean cameraDisabled = getCameraDisabled(null, policy.mUserHandle);
        if (cameraDisabled != systemState) {
        if (cameraDisabled != systemState) {
            long token = Binder.clearCallingIdentity();
            long token = Binder.clearCallingIdentity();
            try {
            try {
                String value = cameraDisabled ? "1" : "0";
                String value = cameraDisabled ? "1" : "0";
                if (DBG) Slog.v(LOG_TAG, "Change in camera state ["
                if (DBG) Slog.v(LOG_TAG, "Change in camera state ["
                        + SYSTEM_PROP_DISABLE_CAMERA + "] = " + value);
                        + cameraPropertyForUser + "] = " + value);
                SystemProperties.set(SYSTEM_PROP_DISABLE_CAMERA, value);
                SystemProperties.set(cameraPropertyForUser, value);
            } finally {
            } finally {
                Binder.restoreCallingIdentity(token);
                Binder.restoreCallingIdentity(token);
            }
            }
@@ -3669,9 +3670,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {


    /**
    /**
     * The system property used to share the state of the camera. The native camera service
     * The system property used to share the state of the camera. The native camera service
     * is expected to read this property and act accordingly.
     * is expected to read this property and act accordingly. The userId should be appended
     * to this key.
     */
     */
    public static final String SYSTEM_PROP_DISABLE_CAMERA = "sys.secpolicy.camera.disabled";
    public static final String SYSTEM_PROP_DISABLE_CAMERA_PREFIX = "sys.secpolicy.camera.off_";


    /**
    /**
     * Disables all device cameras according to the specified admin.
     * Disables all device cameras according to the specified admin.