diff options
author | Andy Stadler <stadler@google.com> | 2010-12-08 15:56:45 -0800 |
---|---|---|
committer | Andy Stadler <stadler@google.com> | 2010-12-09 09:22:06 -0800 |
commit | c25f70a440ef9468085b8d98c8416c7e8b116753 (patch) | |
tree | bae3974ee89930c4449717027d9e573849c50018 /core | |
parent | ffec4385a38bc8cbb871d0330d3890d88d608f77 (diff) | |
download | frameworks_base-c25f70a440ef9468085b8d98c8416c7e8b116753.zip frameworks_base-c25f70a440ef9468085b8d98c8416c7e8b116753.tar.gz frameworks_base-c25f70a440ef9468085b8d98c8416c7e8b116753.tar.bz2 |
API CHANGE - Add hasGrantedPolicy() API
* Allows an app to detect that it needs to have additional policies granted
* Add "refreshing" parameter to setActiveAdmin() to handle this case
* Minor cleanups to eliminate warnings (mostly for unused things)
Bug: 3253179
Change-Id: I4bf639bf560557130bf98e8cfb75f996fac416f1
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/admin/DevicePolicyManager.java | 35 | ||||
-rw-r--r-- | core/java/android/app/admin/IDevicePolicyManager.aidl | 3 |
2 files changed, 30 insertions, 8 deletions
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java index f169cd7..1edbdb8 100644 --- a/core/java/android/app/admin/DevicePolicyManager.java +++ b/core/java/android/app/admin/DevicePolicyManager.java @@ -43,17 +43,12 @@ import java.util.List; */ public class DevicePolicyManager { private static String TAG = "DevicePolicyManager"; - private static boolean DEBUG = false; - private static boolean localLOGV = DEBUG || android.util.Config.LOGV; private final Context mContext; private final IDevicePolicyManager mService; - private final Handler mHandler; - private DevicePolicyManager(Context context, Handler handler) { mContext = context; - mHandler = handler; mService = IDevicePolicyManager.Stub.asInterface( ServiceManager.getService(Context.DEVICE_POLICY_SERVICE)); } @@ -74,6 +69,11 @@ public class DevicePolicyManager { * <p>You can optionally include the {@link #EXTRA_ADD_EXPLANATION} * field to provide the user with additional explanation (in addition * to your component's description) about what is being added. + * + * <p>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 @@ -179,6 +179,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 * values are more restrictive. @@ -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 7acc83e..7504f5b 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<ComponentName> getActiveAdmins(); boolean packageHasActiveAdmins(String packageName); void getRemoveWarning(in ComponentName policyReceiver, in RemoteCallback result); void removeActiveAdmin(in ComponentName policyReceiver); + boolean hasGrantedPolicy(in ComponentName policyReceiver, int usesPolicy); void setActivePasswordState(int quality, int length, int letters, int uppercase, int lowercase, int numbers, int symbols, int nonletter); |