Merge "Update DevicePolicyManager with ability to disable keyguard widgets" into jb-mr1-dev
This commit is contained in:
@@ -4179,6 +4179,7 @@ package android.app.admin {
|
|||||||
field public static final android.os.Parcelable.Creator CREATOR;
|
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_ENCRYPTED_STORAGE = 7; // 0x7
|
||||||
field public static final int USES_POLICY_DISABLE_CAMERA = 8; // 0x8
|
field public static final int USES_POLICY_DISABLE_CAMERA = 8; // 0x8
|
||||||
|
field public static final int USES_POLICY_DISABLE_KEYGUARD_WIDGETS = 9; // 0x9
|
||||||
field public static final int USES_POLICY_EXPIRE_PASSWORD = 6; // 0x6
|
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_FORCE_LOCK = 3; // 0x3
|
||||||
field public static final int USES_POLICY_LIMIT_PASSWORD = 0; // 0x0
|
field public static final int USES_POLICY_LIMIT_PASSWORD = 0; // 0x0
|
||||||
@@ -4214,6 +4215,7 @@ package android.app.admin {
|
|||||||
method public java.util.List<android.content.ComponentName> getActiveAdmins();
|
method public java.util.List<android.content.ComponentName> getActiveAdmins();
|
||||||
method public boolean getCameraDisabled(android.content.ComponentName);
|
method public boolean getCameraDisabled(android.content.ComponentName);
|
||||||
method public int getCurrentFailedPasswordAttempts();
|
method public int getCurrentFailedPasswordAttempts();
|
||||||
|
method public int getKeyguardWidgetsDisabled(android.content.ComponentName);
|
||||||
method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
|
method public int getMaximumFailedPasswordsForWipe(android.content.ComponentName);
|
||||||
method public long getMaximumTimeToLock(android.content.ComponentName);
|
method public long getMaximumTimeToLock(android.content.ComponentName);
|
||||||
method public long getPasswordExpiration(android.content.ComponentName);
|
method public long getPasswordExpiration(android.content.ComponentName);
|
||||||
@@ -4237,6 +4239,7 @@ package android.app.admin {
|
|||||||
method public void removeActiveAdmin(android.content.ComponentName);
|
method public void removeActiveAdmin(android.content.ComponentName);
|
||||||
method public boolean resetPassword(java.lang.String, int);
|
method public boolean resetPassword(java.lang.String, int);
|
||||||
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
method public void setCameraDisabled(android.content.ComponentName, boolean);
|
||||||
|
method public void setKeyguardWidgetsDisabled(android.content.ComponentName, int);
|
||||||
method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
|
method public void setMaximumFailedPasswordsForWipe(android.content.ComponentName, int);
|
||||||
method public void setMaximumTimeToLock(android.content.ComponentName, long);
|
method public void setMaximumTimeToLock(android.content.ComponentName, long);
|
||||||
method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
|
method public void setPasswordExpirationTimeout(android.content.ComponentName, long);
|
||||||
@@ -4260,6 +4263,8 @@ package android.app.admin {
|
|||||||
field public static final int ENCRYPTION_STATUS_UNSUPPORTED = 0; // 0x0
|
field public static final int ENCRYPTION_STATUS_UNSUPPORTED = 0; // 0x0
|
||||||
field public static final java.lang.String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION";
|
field public static final java.lang.String EXTRA_ADD_EXPLANATION = "android.app.extra.ADD_EXPLANATION";
|
||||||
field public static final java.lang.String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN";
|
field public static final java.lang.String EXTRA_DEVICE_ADMIN = "android.app.extra.DEVICE_ADMIN";
|
||||||
|
field public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 2147483647; // 0x7fffffff
|
||||||
|
field public static final int KEYGUARD_DISABLE_WIDGETS_NONE = 0; // 0x0
|
||||||
field public static final int PASSWORD_QUALITY_ALPHABETIC = 262144; // 0x40000
|
field public static final int PASSWORD_QUALITY_ALPHABETIC = 262144; // 0x40000
|
||||||
field public static final int PASSWORD_QUALITY_ALPHANUMERIC = 327680; // 0x50000
|
field public static final int PASSWORD_QUALITY_ALPHANUMERIC = 327680; // 0x50000
|
||||||
field public static final int PASSWORD_QUALITY_BIOMETRIC_WEAK = 32768; // 0x8000
|
field public static final int PASSWORD_QUALITY_BIOMETRIC_WEAK = 32768; // 0x8000
|
||||||
|
|||||||
@@ -138,6 +138,14 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public static final int USES_POLICY_DISABLE_CAMERA = 8;
|
public static final int USES_POLICY_DISABLE_CAMERA = 8;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A type of policy that this device admin can use: disables use of keyguard widgets.
|
||||||
|
*
|
||||||
|
* <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;
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public static class PolicyInfo {
|
public static class PolicyInfo {
|
||||||
public final int ident;
|
public final int ident;
|
||||||
@@ -185,6 +193,10 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_DISABLE_CAMERA, "disable-camera",
|
sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_DISABLE_CAMERA, "disable-camera",
|
||||||
com.android.internal.R.string.policylab_disableCamera,
|
com.android.internal.R.string.policylab_disableCamera,
|
||||||
com.android.internal.R.string.policydesc_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));
|
||||||
|
|
||||||
for (int i=0; i<sPoliciesDisplayOrder.size(); i++) {
|
for (int i=0; i<sPoliciesDisplayOrder.size(); i++) {
|
||||||
PolicyInfo pi = sPoliciesDisplayOrder.get(i);
|
PolicyInfo pi = sPoliciesDisplayOrder.get(i);
|
||||||
|
|||||||
@@ -1154,6 +1154,16 @@ public class DevicePolicyManager {
|
|||||||
public static final String ACTION_START_ENCRYPTION
|
public static final String ACTION_START_ENCRYPTION
|
||||||
= "android.app.action.START_ENCRYPTION";
|
= "android.app.action.START_ENCRYPTION";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widgets are enabled in keyguard
|
||||||
|
*/
|
||||||
|
public static final int KEYGUARD_DISABLE_WIDGETS_NONE = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable all keyguard widgets
|
||||||
|
*/
|
||||||
|
public static final int KEYGUARD_DISABLE_WIDGETS_ALL = 0x7fffffff;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by an application that is administering the device to
|
* Called by an application that is administering the device to
|
||||||
* request that the storage system be encrypted.
|
* request that the storage system be encrypted.
|
||||||
@@ -1283,6 +1293,46 @@ public class DevicePolicyManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* <p>The calling device admin must have requested
|
||||||
|
* {@link DeviceAdminInfo#USES_POLICY_DISABLE_KEYGUARD_WIDGETS} 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).
|
||||||
|
*/
|
||||||
|
public void setKeyguardWidgetsDisabled(ComponentName admin, int which) {
|
||||||
|
if (mService != null) {
|
||||||
|
try {
|
||||||
|
mService.setKeyguardWidgetsDisabled(admin, which);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "Failed talking with device policy service", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether or not widgets 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.
|
||||||
|
*/
|
||||||
|
public int getKeyguardWidgetsDisabled(ComponentName admin) {
|
||||||
|
if (mService != null) {
|
||||||
|
try {
|
||||||
|
return mService.getKeyguardWidgetsDisabled(admin);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
Log.w(TAG, "Failed talking with device policy service", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return KEYGUARD_DISABLE_WIDGETS_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -82,6 +82,9 @@ interface IDevicePolicyManager {
|
|||||||
void setCameraDisabled(in ComponentName who, boolean disabled);
|
void setCameraDisabled(in ComponentName who, boolean disabled);
|
||||||
boolean getCameraDisabled(in ComponentName who);
|
boolean getCameraDisabled(in ComponentName who);
|
||||||
|
|
||||||
|
void setKeyguardWidgetsDisabled(in ComponentName who, int which);
|
||||||
|
int getKeyguardWidgetsDisabled(in ComponentName who);
|
||||||
|
|
||||||
void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing);
|
void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing);
|
||||||
boolean isAdminActive(in ComponentName policyReceiver);
|
boolean isAdminActive(in ComponentName policyReceiver);
|
||||||
List<ComponentName> getActiveAdmins();
|
List<ComponentName> getActiveAdmins();
|
||||||
|
|||||||
@@ -710,6 +710,7 @@
|
|||||||
<java-symbol type="string" name="policydesc_setGlobalProxy" />
|
<java-symbol type="string" name="policydesc_setGlobalProxy" />
|
||||||
<java-symbol type="string" name="policydesc_watchLogin" />
|
<java-symbol type="string" name="policydesc_watchLogin" />
|
||||||
<java-symbol type="string" name="policydesc_wipeData" />
|
<java-symbol type="string" name="policydesc_wipeData" />
|
||||||
|
<java-symbol type="string" name="policydesc_disableKeyguardWidgets" />
|
||||||
<java-symbol type="string" name="policylab_disableCamera" />
|
<java-symbol type="string" name="policylab_disableCamera" />
|
||||||
<java-symbol type="string" name="policylab_encryptedStorage" />
|
<java-symbol type="string" name="policylab_encryptedStorage" />
|
||||||
<java-symbol type="string" name="policylab_expirePassword" />
|
<java-symbol type="string" name="policylab_expirePassword" />
|
||||||
@@ -719,6 +720,7 @@
|
|||||||
<java-symbol type="string" name="policylab_setGlobalProxy" />
|
<java-symbol type="string" name="policylab_setGlobalProxy" />
|
||||||
<java-symbol type="string" name="policylab_watchLogin" />
|
<java-symbol type="string" name="policylab_watchLogin" />
|
||||||
<java-symbol type="string" name="policylab_wipeData" />
|
<java-symbol type="string" name="policylab_wipeData" />
|
||||||
|
<java-symbol type="string" name="policylab_disableKeyguardWidgets" />
|
||||||
<java-symbol type="string" name="postalTypeCustom" />
|
<java-symbol type="string" name="postalTypeCustom" />
|
||||||
<java-symbol type="string" name="postalTypeHome" />
|
<java-symbol type="string" name="postalTypeHome" />
|
||||||
<java-symbol type="string" name="postalTypeOther" />
|
<java-symbol type="string" name="postalTypeOther" />
|
||||||
|
|||||||
@@ -1693,6 +1693,10 @@
|
|||||||
<string name="policylab_disableCamera">Disable cameras</string>
|
<string name="policylab_disableCamera">Disable cameras</string>
|
||||||
<!-- Description of policy access to disable all device cameras [CHAR LIMIT=110]-->
|
<!-- Description of policy access to disable all device cameras [CHAR LIMIT=110]-->
|
||||||
<string name="policydesc_disableCamera">Prevent use of all device cameras.</string>
|
<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>
|
||||||
|
<!-- 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>
|
||||||
|
|
||||||
<!-- The order of these is important, don't reorder without changing Contacts.java --> <skip />
|
<!-- 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. -->
|
<!-- Phone number types from android.provider.Contacts. This could be used when adding a new phone number for a contact, for example. -->
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
protected void onAttachedToWindow() {
|
protected void onAttachedToWindow() {
|
||||||
super.onAttachedToWindow();
|
super.onAttachedToWindow();
|
||||||
mAppWidgetHost.startListening();
|
mAppWidgetHost.startListening();
|
||||||
populateWidgets();
|
maybePopulateWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -581,7 +581,12 @@ public class KeyguardHostView extends KeyguardViewBase {
|
|||||||
addWidget(view);
|
addWidget(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateWidgets() {
|
private void maybePopulateWidgets() {
|
||||||
|
if (mLockPatternUtils.getDevicePolicyManager().getKeyguardWidgetsDisabled(null)
|
||||||
|
!= DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_NONE) {
|
||||||
|
Log.v(TAG, "Keyguard widgets disabled because of device policy admin");
|
||||||
|
return;
|
||||||
|
}
|
||||||
SharedPreferences prefs = mContext.getSharedPreferences(
|
SharedPreferences prefs = mContext.getSharedPreferences(
|
||||||
KEYGUARD_WIDGET_PREFS, Context.MODE_PRIVATE);
|
KEYGUARD_WIDGET_PREFS, Context.MODE_PRIVATE);
|
||||||
for (String key : prefs.getAll().keySet()) {
|
for (String key : prefs.getAll().keySet()) {
|
||||||
|
|||||||
@@ -177,6 +177,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
static final long DEF_PASSWORD_EXPIRATION_DATE = 0;
|
static final long DEF_PASSWORD_EXPIRATION_DATE = 0;
|
||||||
long passwordExpirationDate = DEF_PASSWORD_EXPIRATION_DATE;
|
long passwordExpirationDate = DEF_PASSWORD_EXPIRATION_DATE;
|
||||||
|
|
||||||
|
static final int DEF_KEYGUARD_WIDGET_DISABLED = 0; // none
|
||||||
|
int disableKeyguardWidgets = DEF_KEYGUARD_WIDGET_DISABLED;
|
||||||
|
|
||||||
boolean encryptionRequested = false;
|
boolean encryptionRequested = false;
|
||||||
boolean disableCamera = false;
|
boolean disableCamera = false;
|
||||||
|
|
||||||
@@ -286,6 +289,11 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
out.attribute(null, "value", Boolean.toString(disableCamera));
|
out.attribute(null, "value", Boolean.toString(disableCamera));
|
||||||
out.endTag(null, "disable-camera");
|
out.endTag(null, "disable-camera");
|
||||||
}
|
}
|
||||||
|
if (disableKeyguardWidgets != DEF_KEYGUARD_WIDGET_DISABLED) {
|
||||||
|
out.startTag(null, "disable-keyguard-widgets");
|
||||||
|
out.attribute(null, "value", Integer.toString(disableKeyguardWidgets));
|
||||||
|
out.endTag(null, "disable-keyguard-widgets");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void readFromXml(XmlPullParser parser)
|
void readFromXml(XmlPullParser parser)
|
||||||
@@ -2093,6 +2101,46 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selectively disable keyguard widgets.
|
||||||
|
*/
|
||||||
|
public void setKeyguardWidgetsDisabled(ComponentName who, int which) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (who == null) {
|
||||||
|
throw new NullPointerException("ComponentName is null");
|
||||||
|
}
|
||||||
|
ActiveAdmin ap = getActiveAdminForCallerLocked(who,
|
||||||
|
DeviceAdminInfo.USES_POLICY_DISABLE_KEYGUARD_WIDGETS);
|
||||||
|
if ((ap.disableKeyguardWidgets & which) != which) {
|
||||||
|
ap.disableKeyguardWidgets |= which;
|
||||||
|
saveSettingsLocked();
|
||||||
|
}
|
||||||
|
syncDeviceCapabilitiesLocked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the disabled state for widgets in keyguard for the given admin,
|
||||||
|
* or the aggregate of all active admins if who is null.
|
||||||
|
*/
|
||||||
|
public int getKeyguardWidgetsDisabled(ComponentName who) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (who != null) {
|
||||||
|
ActiveAdmin admin = getActiveAdminUncheckedLocked(who);
|
||||||
|
return (admin != null) ? admin.disableKeyguardWidgets : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine whether or not keyguard widgets are disabled for any active admins.
|
||||||
|
final int N = mAdminList.size();
|
||||||
|
int which = 0;
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
ActiveAdmin admin = mAdminList.get(i);
|
||||||
|
which |= admin.disableKeyguardWidgets;
|
||||||
|
}
|
||||||
|
return which;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
|
||||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
|
||||||
|
|||||||
Reference in New Issue
Block a user