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

Commit 2447edd8 authored by Ben Komalo's avatar Ben Komalo
Browse files

New device policy to disable camera.

This introduces a new policy that a DeviceAdmin can use to disable _all_
cameras on the device. A separate CL will be made on the media side to
watch this policy bit and act accordingly.

Bug: 4185303
Change-Id: I700cfc4a8317bb74087ccae39346d74467fc58b2
parent d3ee2fa1
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -3577,6 +3577,7 @@ package android.app.admin {
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int USES_ENCRYPTED_STORAGE = 7; // 0x7
    field public static final int USES_POLICY_DISABLE_CAMERA = 8; // 0x8
    field public static final int USES_POLICY_EXPIRE_PASSWORD = 6; // 0x6
    field public static final int USES_POLICY_FORCE_LOCK = 3; // 0x3
    field public static final int USES_POLICY_LIMIT_PASSWORD = 0; // 0x0
@@ -3610,6 +3611,7 @@ package android.app.admin {
  public class DevicePolicyManager {
    method public java.util.List<android.content.ComponentName> getActiveAdmins();
    method public boolean getCameraDisabled(android.content.ComponentName);
    method public int getCurrentFailedPasswordAttempts();
    method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
    method public long getMaximumTimeToLock(android.content.ComponentName);
@@ -3633,6 +3635,7 @@ package android.app.admin {
    method public void lockNow();
    method public void removeActiveAdmin(android.content.ComponentName);
    method public boolean resetPassword(java.lang.String, int);
    method public void setCameraDisabled(android.content.ComponentName, boolean);
    method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
    method public void setMaximumTimeToLock(android.content.ComponentName, long);
    method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
+13 −1
Original line number Diff line number Diff line
@@ -130,6 +130,14 @@ public final class DeviceAdminInfo implements Parcelable {
     */
    public static final int USES_ENCRYPTED_STORAGE = 7;

    /**
     * A type of policy that this device admin can use: disables use of all device cameras.
     *
     * <p>To control this policy, the device admin must have a "disable-camera"
     * tag in the "uses-policies" section of its meta-data.
     */
    public static final int USES_POLICY_DISABLE_CAMERA = 8;

    /** @hide */
    public static class PolicyInfo {
        public final int ident;
@@ -174,6 +182,9 @@ public final class DeviceAdminInfo implements Parcelable {
        sPoliciesDisplayOrder.add(new PolicyInfo(USES_ENCRYPTED_STORAGE, "encrypted-storage",
                com.android.internal.R.string.policylab_encryptedStorage,
                com.android.internal.R.string.policydesc_encryptedStorage));
        sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_DISABLE_CAMERA, "disable-camera",
                com.android.internal.R.string.policylab_disableCamera,
                com.android.internal.R.string.policydesc_disableCamera));

        for (int i=0; i<sPoliciesDisplayOrder.size(); i++) {
            PolicyInfo pi = sPoliciesDisplayOrder.get(i);
@@ -365,7 +376,8 @@ public final class DeviceAdminInfo implements Parcelable {
     * {@link #USES_POLICY_LIMIT_PASSWORD}, {@link #USES_POLICY_WATCH_LOGIN},
     * {@link #USES_POLICY_RESET_PASSWORD}, {@link #USES_POLICY_FORCE_LOCK},
     * {@link #USES_POLICY_WIPE_DATA},
     * {@link #USES_POLICY_EXPIRE_PASSWORD}, {@link #USES_ENCRYPTED_STORAGE}.
     * {@link #USES_POLICY_EXPIRE_PASSWORD}, {@link #USES_ENCRYPTED_STORAGE},
     * {@link #USES_POLICY_DISABLE_CAMERA}.
     */
    public boolean usesPolicy(int policyIdent) {
        return (mUsesPolicies & (1<<policyIdent)) != 0;
+39 −0
Original line number Diff line number Diff line
@@ -1227,6 +1227,45 @@ public class DevicePolicyManager {
        return ENCRYPTION_STATUS_UNSUPPORTED;
    }

    /**
     * Called by an application that is administering the device to disable all cameras
     * on the device.  After setting this, no applications will be able to access any cameras
     * on the device.
     *
     * <p>The calling device admin must have requested
     * {@link DeviceAdminInfo#USES_POLICY_DISABLE_CAMERA} to be able to call
     * this method; if it has not, a security exception will be thrown.
     *
     * @param admin Which {@link DeviceAdminReceiver} this request is associated with.
     * @param disabled Whether or not the camera should be disabled.
     */
    public void setCameraDisabled(ComponentName admin, boolean disabled) {
        if (mService != null) {
            try {
                mService.setCameraDisabled(admin, disabled);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed talking with device policy service", e);
            }
        }
    }

    /**
     * Determine whether or not the device's cameras have been disabled either by the current
     * admin, if specified, or all admins.
     * @param admin The name of the admin component to check, or null to check if any admins
     * have disabled the camera
     */
    public boolean getCameraDisabled(ComponentName admin) {
        if (mService != null) {
            try {
                return mService.getCameraDisabled(admin);
            } catch (RemoteException e) {
                Log.w(TAG, "Failed talking with device policy service", e);
            }
        }
        return false;
    }

    /**
     * @hide
     */
+3 −0
Original line number Diff line number Diff line
@@ -79,6 +79,9 @@ interface IDevicePolicyManager {
    boolean getStorageEncryption(in ComponentName who);
    int getStorageEncryptionStatus();

    void setCameraDisabled(in ComponentName who, boolean disabled);
    boolean getCameraDisabled(in ComponentName who);

    void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing);
    boolean isAdminActive(in ComponentName policyReceiver);
    List<ComponentName> getActiveAdmins();
+4 −0
Original line number Diff line number Diff line
@@ -1479,6 +1479,10 @@
    <!-- Description of policy access to require encrypted storage [CHAR LIMIT=110]-->
    <string name="policydesc_encryptedStorage">Require that stored application data be encrypted
        </string>
    <!-- Title of policy access to disable all device cameras [CHAR LIMIT=30]-->
    <string name="policylab_disableCamera">Disable cameras</string>
    <!-- Description of policy access to disable all device cameras [CHAR LIMIT=110]-->
    <string name="policydesc_disableCamera">Prevent use of all device cameras</string>

    <!-- The order of these is important, don't reorder without changing Contacts.java --> <skip />
    <!-- Phone number types from android.provider.Contacts. This could be used when adding a new phone number for a contact, for example. -->
Loading