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
|
||||||
|
|||||||
@@ -50,23 +50,23 @@ import java.util.HashMap;
|
|||||||
*/
|
*/
|
||||||
public final class DeviceAdminInfo implements Parcelable {
|
public final class DeviceAdminInfo implements Parcelable {
|
||||||
static final String TAG = "DeviceAdminInfo";
|
static final String TAG = "DeviceAdminInfo";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type of policy that this device admin can use: limit the passwords
|
* A type of policy that this device admin can use: limit the passwords
|
||||||
* that the user can select, via {@link DevicePolicyManager#setPasswordQuality}
|
* that the user can select, via {@link DevicePolicyManager#setPasswordQuality}
|
||||||
* and {@link DevicePolicyManager#setPasswordMinimumLength}.
|
* and {@link DevicePolicyManager#setPasswordMinimumLength}.
|
||||||
*
|
*
|
||||||
* <p>To control this policy, the device admin must have a "limit-password"
|
* <p>To control this policy, the device admin must have a "limit-password"
|
||||||
* tag in the "uses-policies" section of its meta-data.
|
* tag in the "uses-policies" section of its meta-data.
|
||||||
*/
|
*/
|
||||||
public static final int USES_POLICY_LIMIT_PASSWORD = 0;
|
public static final int USES_POLICY_LIMIT_PASSWORD = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type of policy that this device admin can use: able to watch login
|
* A type of policy that this device admin can use: able to watch login
|
||||||
* attempts from the user, via {@link DeviceAdminReceiver#ACTION_PASSWORD_FAILED},
|
* attempts from the user, via {@link DeviceAdminReceiver#ACTION_PASSWORD_FAILED},
|
||||||
* {@link DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED}, and
|
* {@link DeviceAdminReceiver#ACTION_PASSWORD_SUCCEEDED}, and
|
||||||
* {@link DevicePolicyManager#getCurrentFailedPasswordAttempts}.
|
* {@link DevicePolicyManager#getCurrentFailedPasswordAttempts}.
|
||||||
*
|
*
|
||||||
* <p>To control this policy, the device admin must have a "watch-login"
|
* <p>To control this policy, the device admin must have a "watch-login"
|
||||||
* tag in the "uses-policies" section of its meta-data.
|
* tag in the "uses-policies" section of its meta-data.
|
||||||
*/
|
*/
|
||||||
@@ -76,7 +76,7 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
* A type of policy that this device admin can use: able to reset the
|
* A type of policy that this device admin can use: able to reset the
|
||||||
* user's password via
|
* user's password via
|
||||||
* {@link DevicePolicyManager#resetPassword}.
|
* {@link DevicePolicyManager#resetPassword}.
|
||||||
*
|
*
|
||||||
* <p>To control this policy, the device admin must have a "reset-password"
|
* <p>To control this policy, the device admin must have a "reset-password"
|
||||||
* tag in the "uses-policies" section of its meta-data.
|
* tag in the "uses-policies" section of its meta-data.
|
||||||
*/
|
*/
|
||||||
@@ -87,7 +87,7 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
* to lock via{@link DevicePolicyManager#lockNow} or limit the
|
* to lock via{@link DevicePolicyManager#lockNow} or limit the
|
||||||
* maximum lock timeout for the device via
|
* maximum lock timeout for the device via
|
||||||
* {@link DevicePolicyManager#setMaximumTimeToLock}.
|
* {@link DevicePolicyManager#setMaximumTimeToLock}.
|
||||||
*
|
*
|
||||||
* <p>To control this policy, the device admin must have a "force-lock"
|
* <p>To control this policy, the device admin must have a "force-lock"
|
||||||
* tag in the "uses-policies" section of its meta-data.
|
* tag in the "uses-policies" section of its meta-data.
|
||||||
*/
|
*/
|
||||||
@@ -97,7 +97,7 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
* A type of policy that this device admin can use: able to factory
|
* A type of policy that this device admin can use: able to factory
|
||||||
* reset the device, erasing all of the user's data, via
|
* reset the device, erasing all of the user's data, via
|
||||||
* {@link DevicePolicyManager#wipeData}.
|
* {@link DevicePolicyManager#wipeData}.
|
||||||
*
|
*
|
||||||
* <p>To control this policy, the device admin must have a "wipe-data"
|
* <p>To control this policy, the device admin must have a "wipe-data"
|
||||||
* tag in the "uses-policies" section of its meta-data.
|
* tag in the "uses-policies" section of its meta-data.
|
||||||
*/
|
*/
|
||||||
@@ -138,13 +138,21 @@ 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;
|
||||||
final public String tag;
|
final public String tag;
|
||||||
final public int label;
|
final public int label;
|
||||||
final public int description;
|
final public int description;
|
||||||
|
|
||||||
public PolicyInfo(int identIn, String tagIn, int labelIn, int descriptionIn) {
|
public PolicyInfo(int identIn, String tagIn, int labelIn, int descriptionIn) {
|
||||||
ident = identIn;
|
ident = identIn;
|
||||||
tag = tagIn;
|
tag = tagIn;
|
||||||
@@ -152,11 +160,11 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
description = descriptionIn;
|
description = descriptionIn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArrayList<PolicyInfo> sPoliciesDisplayOrder = new ArrayList<PolicyInfo>();
|
static ArrayList<PolicyInfo> sPoliciesDisplayOrder = new ArrayList<PolicyInfo>();
|
||||||
static HashMap<String, Integer> sKnownPolicies = new HashMap<String, Integer>();
|
static HashMap<String, Integer> sKnownPolicies = new HashMap<String, Integer>();
|
||||||
static SparseArray<PolicyInfo> sRevKnownPolicies = new SparseArray<PolicyInfo>();
|
static SparseArray<PolicyInfo> sRevKnownPolicies = new SparseArray<PolicyInfo>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_WIPE_DATA, "wipe-data",
|
sPoliciesDisplayOrder.add(new PolicyInfo(USES_POLICY_WIPE_DATA, "wipe-data",
|
||||||
com.android.internal.R.string.policylab_wipeData,
|
com.android.internal.R.string.policylab_wipeData,
|
||||||
@@ -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);
|
||||||
@@ -192,25 +204,25 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
sKnownPolicies.put(pi.tag, pi.ident);
|
sKnownPolicies.put(pi.tag, pi.ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The BroadcastReceiver that implements this device admin component.
|
* The BroadcastReceiver that implements this device admin component.
|
||||||
*/
|
*/
|
||||||
final ResolveInfo mReceiver;
|
final ResolveInfo mReceiver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this should be visible to the user.
|
* Whether this should be visible to the user.
|
||||||
*/
|
*/
|
||||||
boolean mVisible;
|
boolean mVisible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The policies this administrator needs access to.
|
* The policies this administrator needs access to.
|
||||||
*/
|
*/
|
||||||
int mUsesPolicies;
|
int mUsesPolicies;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param context The Context in which we are parsing the device admin.
|
* @param context The Context in which we are parsing the device admin.
|
||||||
* @param receiver The ResolveInfo returned from the package manager about
|
* @param receiver The ResolveInfo returned from the package manager about
|
||||||
* this device admin's component.
|
* this device admin's component.
|
||||||
@@ -219,9 +231,9 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
mReceiver = receiver;
|
mReceiver = receiver;
|
||||||
ActivityInfo ai = receiver.activityInfo;
|
ActivityInfo ai = receiver.activityInfo;
|
||||||
|
|
||||||
PackageManager pm = context.getPackageManager();
|
PackageManager pm = context.getPackageManager();
|
||||||
|
|
||||||
XmlResourceParser parser = null;
|
XmlResourceParser parser = null;
|
||||||
try {
|
try {
|
||||||
parser = ai.loadXmlMetaData(pm, DeviceAdminReceiver.DEVICE_ADMIN_META_DATA);
|
parser = ai.loadXmlMetaData(pm, DeviceAdminReceiver.DEVICE_ADMIN_META_DATA);
|
||||||
@@ -229,30 +241,30 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
throw new XmlPullParserException("No "
|
throw new XmlPullParserException("No "
|
||||||
+ DeviceAdminReceiver.DEVICE_ADMIN_META_DATA + " meta-data");
|
+ DeviceAdminReceiver.DEVICE_ADMIN_META_DATA + " meta-data");
|
||||||
}
|
}
|
||||||
|
|
||||||
Resources res = pm.getResourcesForApplication(ai.applicationInfo);
|
Resources res = pm.getResourcesForApplication(ai.applicationInfo);
|
||||||
|
|
||||||
AttributeSet attrs = Xml.asAttributeSet(parser);
|
AttributeSet attrs = Xml.asAttributeSet(parser);
|
||||||
|
|
||||||
int type;
|
int type;
|
||||||
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
||||||
&& type != XmlPullParser.START_TAG) {
|
&& type != XmlPullParser.START_TAG) {
|
||||||
}
|
}
|
||||||
|
|
||||||
String nodeName = parser.getName();
|
String nodeName = parser.getName();
|
||||||
if (!"device-admin".equals(nodeName)) {
|
if (!"device-admin".equals(nodeName)) {
|
||||||
throw new XmlPullParserException(
|
throw new XmlPullParserException(
|
||||||
"Meta-data does not start with device-admin tag");
|
"Meta-data does not start with device-admin tag");
|
||||||
}
|
}
|
||||||
|
|
||||||
TypedArray sa = res.obtainAttributes(attrs,
|
TypedArray sa = res.obtainAttributes(attrs,
|
||||||
com.android.internal.R.styleable.DeviceAdmin);
|
com.android.internal.R.styleable.DeviceAdmin);
|
||||||
|
|
||||||
mVisible = sa.getBoolean(
|
mVisible = sa.getBoolean(
|
||||||
com.android.internal.R.styleable.DeviceAdmin_visible, true);
|
com.android.internal.R.styleable.DeviceAdmin_visible, true);
|
||||||
|
|
||||||
sa.recycle();
|
sa.recycle();
|
||||||
|
|
||||||
int outerDepth = parser.getDepth();
|
int outerDepth = parser.getDepth();
|
||||||
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
|
||||||
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
|
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
|
||||||
@@ -290,14 +302,14 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
mReceiver = ResolveInfo.CREATOR.createFromParcel(source);
|
mReceiver = ResolveInfo.CREATOR.createFromParcel(source);
|
||||||
mUsesPolicies = source.readInt();
|
mUsesPolicies = source.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the .apk package that implements this device admin.
|
* Return the .apk package that implements this device admin.
|
||||||
*/
|
*/
|
||||||
public String getPackageName() {
|
public String getPackageName() {
|
||||||
return mReceiver.activityInfo.packageName;
|
return mReceiver.activityInfo.packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the class name of the receiver component that implements
|
* Return the class name of the receiver component that implements
|
||||||
* this device admin.
|
* this device admin.
|
||||||
@@ -321,20 +333,20 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
return new ComponentName(mReceiver.activityInfo.packageName,
|
return new ComponentName(mReceiver.activityInfo.packageName,
|
||||||
mReceiver.activityInfo.name);
|
mReceiver.activityInfo.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the user-displayed label for this device admin.
|
* Load the user-displayed label for this device admin.
|
||||||
*
|
*
|
||||||
* @param pm Supply a PackageManager used to load the device admin's
|
* @param pm Supply a PackageManager used to load the device admin's
|
||||||
* resources.
|
* resources.
|
||||||
*/
|
*/
|
||||||
public CharSequence loadLabel(PackageManager pm) {
|
public CharSequence loadLabel(PackageManager pm) {
|
||||||
return mReceiver.loadLabel(pm);
|
return mReceiver.loadLabel(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load user-visible description associated with this device admin.
|
* Load user-visible description associated with this device admin.
|
||||||
*
|
*
|
||||||
* @param pm Supply a PackageManager used to load the device admin's
|
* @param pm Supply a PackageManager used to load the device admin's
|
||||||
* resources.
|
* resources.
|
||||||
*/
|
*/
|
||||||
@@ -351,17 +363,17 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
}
|
}
|
||||||
throw new NotFoundException();
|
throw new NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the user-displayed icon for this device admin.
|
* Load the user-displayed icon for this device admin.
|
||||||
*
|
*
|
||||||
* @param pm Supply a PackageManager used to load the device admin's
|
* @param pm Supply a PackageManager used to load the device admin's
|
||||||
* resources.
|
* resources.
|
||||||
*/
|
*/
|
||||||
public Drawable loadIcon(PackageManager pm) {
|
public Drawable loadIcon(PackageManager pm) {
|
||||||
return mReceiver.loadIcon(pm);
|
return mReceiver.loadIcon(pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this device admin would like to be visible to the
|
* Returns whether this device admin would like to be visible to the
|
||||||
* user, even when it is not enabled.
|
* user, even when it is not enabled.
|
||||||
@@ -369,7 +381,7 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return mVisible;
|
return mVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the device admin has requested that it be able to use
|
* Return true if the device admin has requested that it be able to use
|
||||||
* the given policy control. The possible policy identifier inputs are:
|
* the given policy control. The possible policy identifier inputs are:
|
||||||
@@ -382,7 +394,7 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
public boolean usesPolicy(int policyIdent) {
|
public boolean usesPolicy(int policyIdent) {
|
||||||
return (mUsesPolicies & (1<<policyIdent)) != 0;
|
return (mUsesPolicies & (1<<policyIdent)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the XML tag name for the given policy identifier. Valid identifiers
|
* Return the XML tag name for the given policy identifier. Valid identifiers
|
||||||
* are as per {@link #usesPolicy(int)}. If the given identifier is not
|
* are as per {@link #usesPolicy(int)}. If the given identifier is not
|
||||||
@@ -391,7 +403,7 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
public String getTagForPolicy(int policyIdent) {
|
public String getTagForPolicy(int policyIdent) {
|
||||||
return sRevKnownPolicies.get(policyIdent).tag;
|
return sRevKnownPolicies.get(policyIdent).tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public ArrayList<PolicyInfo> getUsedPolicies() {
|
public ArrayList<PolicyInfo> getUsedPolicies() {
|
||||||
ArrayList<PolicyInfo> res = new ArrayList<PolicyInfo>();
|
ArrayList<PolicyInfo> res = new ArrayList<PolicyInfo>();
|
||||||
@@ -403,25 +415,25 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void writePoliciesToXml(XmlSerializer out)
|
public void writePoliciesToXml(XmlSerializer out)
|
||||||
throws IllegalArgumentException, IllegalStateException, IOException {
|
throws IllegalArgumentException, IllegalStateException, IOException {
|
||||||
out.attribute(null, "flags", Integer.toString(mUsesPolicies));
|
out.attribute(null, "flags", Integer.toString(mUsesPolicies));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public void readPoliciesFromXml(XmlPullParser parser)
|
public void readPoliciesFromXml(XmlPullParser parser)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
mUsesPolicies = Integer.parseInt(
|
mUsesPolicies = Integer.parseInt(
|
||||||
parser.getAttributeValue(null, "flags"));
|
parser.getAttributeValue(null, "flags"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dump(Printer pw, String prefix) {
|
public void dump(Printer pw, String prefix) {
|
||||||
pw.println(prefix + "Receiver:");
|
pw.println(prefix + "Receiver:");
|
||||||
mReceiver.dump(pw, prefix + " ");
|
mReceiver.dump(pw, prefix + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "DeviceAdminInfo{" + mReceiver.activityInfo.name + "}";
|
return "DeviceAdminInfo{" + mReceiver.activityInfo.name + "}";
|
||||||
@@ -429,7 +441,7 @@ public final class DeviceAdminInfo implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to package this object into a {@link Parcel}.
|
* Used to package this object into a {@link Parcel}.
|
||||||
*
|
*
|
||||||
* @param dest The {@link Parcel} to be written.
|
* @param dest The {@link Parcel} to be written.
|
||||||
* @param flags The flags used for parceling.
|
* @param flags The flags used for parceling.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ interface IDevicePolicyManager {
|
|||||||
|
|
||||||
void setPasswordMinimumNonLetter(in ComponentName who, int length);
|
void setPasswordMinimumNonLetter(in ComponentName who, int length);
|
||||||
int getPasswordMinimumNonLetter(in ComponentName who);
|
int getPasswordMinimumNonLetter(in ComponentName who);
|
||||||
|
|
||||||
void setPasswordHistoryLength(in ComponentName who, int length);
|
void setPasswordHistoryLength(in ComponentName who, int length);
|
||||||
int getPasswordHistoryLength(in ComponentName who);
|
int getPasswordHistoryLength(in ComponentName who);
|
||||||
|
|
||||||
@@ -59,17 +59,17 @@ interface IDevicePolicyManager {
|
|||||||
|
|
||||||
boolean isActivePasswordSufficient();
|
boolean isActivePasswordSufficient();
|
||||||
int getCurrentFailedPasswordAttempts();
|
int getCurrentFailedPasswordAttempts();
|
||||||
|
|
||||||
void setMaximumFailedPasswordsForWipe(in ComponentName admin, int num);
|
void setMaximumFailedPasswordsForWipe(in ComponentName admin, int num);
|
||||||
int getMaximumFailedPasswordsForWipe(in ComponentName admin);
|
int getMaximumFailedPasswordsForWipe(in ComponentName admin);
|
||||||
|
|
||||||
boolean resetPassword(String password, int flags);
|
boolean resetPassword(String password, int flags);
|
||||||
|
|
||||||
void setMaximumTimeToLock(in ComponentName who, long timeMs);
|
void setMaximumTimeToLock(in ComponentName who, long timeMs);
|
||||||
long getMaximumTimeToLock(in ComponentName who);
|
long getMaximumTimeToLock(in ComponentName who);
|
||||||
|
|
||||||
void lockNow();
|
void lockNow();
|
||||||
|
|
||||||
void wipeData(int flags);
|
void wipeData(int flags);
|
||||||
|
|
||||||
ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
|
ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
|
||||||
@@ -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();
|
||||||
@@ -89,7 +92,7 @@ interface IDevicePolicyManager {
|
|||||||
void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result);
|
void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result);
|
||||||
void removeActiveAdmin(in ComponentName policyReceiver);
|
void removeActiveAdmin(in ComponentName policyReceiver);
|
||||||
boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy);
|
boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy);
|
||||||
|
|
||||||
void setActivePasswordState(int quality, int length, int letters, int uppercase, int lowercase,
|
void setActivePasswordState(int quality, int length, int letters, int uppercase, int lowercase,
|
||||||
int numbers, int symbols, int nonletter);
|
int numbers, int symbols, int nonletter);
|
||||||
void reportFailedPasswordAttempt();
|
void reportFailedPasswordAttempt();
|
||||||
|
|||||||
@@ -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