Make DPM API for disabling keyguard widgets more generic

This change renames the widget-specific API to be more generic
to allow further disabling of keyguard-specific customizations
in the future.  Currently only allows disabling widgets and the
secure camera but can now easily be extended to disable other
features we add.

Fixes bug: 7021368

Change-Id: I3934cc2e7c64e0c6d511efb86980fc38a849708d
diff --git a/core/java/android/app/admin/DeviceAdminInfo.java b/core/java/android/app/admin/DeviceAdminInfo.java
index c8062ca..b351811 100644
--- a/core/java/android/app/admin/DeviceAdminInfo.java
+++ b/core/java/android/app/admin/DeviceAdminInfo.java
@@ -144,7 +144,7 @@
      * <p>To control this policy, the device admin must have a "disable-keyguard-widgets"
      * tag in the "uses-policies" section of its meta-data.
      */
-    public static final int USES_POLICY_DISABLE_KEYGUARD_WIDGETS = 9;
+    public static final int USES_POLICY_DISABLE_KEYGUARD_FEATURES = 9;
 
     /** @hide */
     public static class PolicyInfo {
@@ -194,9 +194,9 @@
                 com.android.internal.R.string.policylab_disableCamera,
                 com.android.internal.R.string.policydesc_disableCamera));
         sPoliciesDisplayOrder.add(new PolicyInfo(
-                USES_POLICY_DISABLE_KEYGUARD_WIDGETS, "disable-keyguard-widgets",
-                com.android.internal.R.string.policylab_disableKeyguardWidgets,
-                com.android.internal.R.string.policydesc_disableKeyguardWidgets));
+                USES_POLICY_DISABLE_KEYGUARD_FEATURES, "disable-keyguard-features",
+                com.android.internal.R.string.policylab_disableKeyguardFeatures,
+                com.android.internal.R.string.policydesc_disableKeyguardFeatures));
 
         for (int i=0; i<sPoliciesDisplayOrder.size(); i++) {
             PolicyInfo pi = sPoliciesDisplayOrder.get(i);
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 600d02a..6966793 100755
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -1215,12 +1215,22 @@
     /**
      * Widgets are enabled in keyguard
      */
-    public static final int KEYGUARD_DISABLE_WIDGETS_NONE = 0;
+    public static final int KEYGUARD_DISABLE_FEATURES_NONE = 0;
 
     /**
      * Disable all keyguard widgets
      */
-    public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 0x7fffffff;
+    public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 1 << 0;
+
+    /**
+     * Disable the camera on secure keyguard screens (e.g. PIN/Pattern/Password)
+     */
+    public static final int KEYGUARD_DISABLE_SECURE_CAMERA = 1 << 1;
+
+    /**
+     * Disable all current and future keyguard customizations
+     */
+    public static final int KEYGUARD_DISABLE_FEATURES_ALL = 0x7fffffff;
 
     /**
      * Called by an application that is administering the device to
@@ -1362,22 +1372,22 @@
     }
 
     /**
-     * Called by an application that is administering the device to disable adding widgets to
-     * keyguard.  After setting this, keyguard widgets will be disabled according to the state
-     * provided.
+     * Called by an application that is administering the device to disable keyguard customizations,
+     * such as widgets. After setting this, keyguard features will be disabled according to the
+     * provided feature list.
      *
      * <p>The calling device admin must have requested
-     * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_WIDGETS} to be able to call
+     * {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_FEATURES} 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 which {@link DevicePolicyManager#KEYGUARD_DISABLE_WIDGETS_ALL} or
-     * {@link DevicePolicyManager#KEYGUARD_DISABLE_WIDGETS_NONE} (the default).
+     * {@link DevicePolicyManager#KEYGUARD_DISABLE_FEATURES_NONE} (the default).
      */
-    public void setKeyguardWidgetsDisabled(ComponentName admin, int which) {
+    public void setKeyguardDisabledFeatures(ComponentName admin, int which) {
         if (mService != null) {
             try {
-                mService.setKeyguardWidgetsDisabled(admin, which, UserHandle.myUserId());
+                mService.setKeyguardDisabledFeatures(admin, which, UserHandle.myUserId());
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
@@ -1385,25 +1395,25 @@
     }
 
     /**
-     * Determine whether or not widgets have been disabled in keyguard either by the current
+     * Determine whether or not features have been disabled in keyguard 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 widgets in keyguard.
+     * have disabled features in keyguard.
      */
-    public int getKeyguardWidgetsDisabled(ComponentName admin) {
-        return getKeyguardWidgetsDisabled(admin, UserHandle.myUserId());
+    public int getKeyguardDisabledFeatures(ComponentName admin) {
+        return getKeyguardDisabledFeatures(admin, UserHandle.myUserId());
     }
 
     /** @hide per-user version */
-    public int getKeyguardWidgetsDisabled(ComponentName admin, int userHandle) {
+    public int getKeyguardDisabledFeatures(ComponentName admin, int userHandle) {
         if (mService != null) {
             try {
-                return mService.getKeyguardWidgetsDisabled(admin, userHandle);
+                return mService.getKeyguardDisabledFeatures(admin, userHandle);
             } catch (RemoteException e) {
                 Log.w(TAG, "Failed talking with device policy service", e);
             }
         }
-        return KEYGUARD_DISABLE_WIDGETS_NONE;
+        return KEYGUARD_DISABLE_FEATURES_NONE;
     }
 
     /**
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index bdfb177..e061ab3 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -82,8 +82,8 @@
     void setCameraDisabled(in ComponentName who, boolean disabled, int userHandle);
     boolean getCameraDisabled(in ComponentName who, int userHandle);
 
-    void setKeyguardWidgetsDisabled(in ComponentName who, int which, int userHandle);
-    int getKeyguardWidgetsDisabled(in ComponentName who, int userHandle);
+    void setKeyguardDisabledFeatures(in ComponentName who, int which, int userHandle);
+    int getKeyguardDisabledFeatures(in ComponentName who, int userHandle);
 
     void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing, int userHandle);
     boolean isAdminActive(in ComponentName policyReceiver, int userHandle);
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 761bfba..ae2cffe 100755
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -878,7 +878,7 @@
     <!-- [CHAR LIMIT=NONE] Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permdesc_freezeScreen">Allows the application to temporarily freeze
         the screen for a full-screen transition.</string>
-    
+
     <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
     <string name="permlab_injectEvents">press keys and control buttons</string>
     <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
@@ -1810,9 +1810,9 @@
     <!-- Description of policy access to disable all device cameras [CHAR LIMIT=110]-->
     <string name="policydesc_disableCamera">Prevent use of all device cameras.</string>
     <!-- Title of policy access to disable all device cameras [CHAR LIMIT=30]-->
-    <string name="policylab_disableKeyguardWidgets">Disable widgets on keyguard</string>
+    <string name="policylab_disableKeyguardFeatures">Disable features in keyguard</string>
     <!-- Description of policy access to disable all device cameras [CHAR LIMIT=110]-->
-    <string name="policydesc_disableKeyguardWidgets">Prevent use of some or all widgets on keyguard.</string>
+    <string name="policydesc_disableKeyguardFeatures">Prevent use of some features in keyguard.</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. -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 5612360..6dd3fc9 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -630,7 +630,7 @@
   <java-symbol type="string" name="policydesc_setGlobalProxy" />
   <java-symbol type="string" name="policydesc_watchLogin" />
   <java-symbol type="string" name="policydesc_wipeData" />
-  <java-symbol type="string" name="policydesc_disableKeyguardWidgets" />
+  <java-symbol type="string" name="policydesc_disableKeyguardFeatures" />
   <java-symbol type="string" name="policylab_disableCamera" />
   <java-symbol type="string" name="policylab_encryptedStorage" />
   <java-symbol type="string" name="policylab_expirePassword" />
@@ -640,7 +640,7 @@
   <java-symbol type="string" name="policylab_setGlobalProxy" />
   <java-symbol type="string" name="policylab_watchLogin" />
   <java-symbol type="string" name="policylab_wipeData" />
-  <java-symbol type="string" name="policylab_disableKeyguardWidgets" />
+  <java-symbol type="string" name="policylab_disableKeyguardFeatures" />
   <java-symbol type="string" name="postalTypeCustom" />
   <java-symbol type="string" name="postalTypeHome" />
   <java-symbol type="string" name="postalTypeOther" />