If your administrator is already active, this will ordinarily return immediately (without
+ * user intervention). However, if your administrator has been updated and is requesting
+ * additional uses-policy flags, the user will be presented with the new list. New policies
+ * will not be available to the updated administrator until the user has accepted the new list.
*/
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
public static final String ACTION_ADD_DEVICE_ADMIN
@@ -178,6 +178,26 @@ public class DevicePolicyManager {
}
}
+ /**
+ * Returns true if an administrator has been granted a particular device policy. This can
+ * be used to check if the administrator was activated under an earlier set of policies,
+ * but requires additional policies after an upgrade.
+ *
+ * @param admin Which {@link DeviceAdminReceiver} this request is associated with. Must be
+ * an active administrator, or an exception will be thrown.
+ * @param usesPolicy Which uses-policy to check, as defined in {@link DeviceAdminInfo}.
+ */
+ public boolean hasGrantedPolicy(ComponentName admin, int usesPolicy) {
+ if (mService != null) {
+ try {
+ return mService.hasGrantedPolicy(admin, usesPolicy);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Failed talking with device policy service", e);
+ }
+ }
+ return false;
+ }
+
/**
* Constant for {@link #setPasswordQuality}: the policy has no requirements
* for the password. Note that quality constants are ordered so that higher
@@ -1075,10 +1095,10 @@ public class DevicePolicyManager {
/**
* @hide
*/
- public void setActiveAdmin(ComponentName policyReceiver) {
+ public void setActiveAdmin(ComponentName policyReceiver, boolean refreshing) {
if (mService != null) {
try {
- mService.setActiveAdmin(policyReceiver);
+ mService.setActiveAdmin(policyReceiver, refreshing);
} catch (RemoteException e) {
Log.w(TAG, "Failed talking with device policy service", e);
}
@@ -1086,6 +1106,7 @@ public class DevicePolicyManager {
}
/**
+ * Returns the DeviceAdminInfo as defined by the administrator's package info & meta-data
* @hide
*/
public DeviceAdminInfo getAdminInfo(ComponentName cn) {
diff --git a/core/java/android/app/admin/IDevicePolicyManager.aidl b/core/java/android/app/admin/IDevicePolicyManager.aidl
index 7acc83e2d375a..7504f5bf864a6 100644
--- a/core/java/android/app/admin/IDevicePolicyManager.aidl
+++ b/core/java/android/app/admin/IDevicePolicyManager.aidl
@@ -75,12 +75,13 @@ interface IDevicePolicyManager {
ComponentName setGlobalProxy(in ComponentName admin, String proxySpec, String exclusionList);
ComponentName getGlobalProxyAdmin();
- void setActiveAdmin(in ComponentName policyReceiver);
+ void setActiveAdmin(in ComponentName policyReceiver, boolean refreshing);
boolean isAdminActive(in ComponentName policyReceiver);
List