Properly reset security policy when device admin revoked

* Simplify the logic in the onDisabled() receiver.  Make sure
  security policy keys are *always* disabled.
* Eliminate unused variable and unused receiver.

Bug: 2576145
Change-Id: I3665a1d300edfb77e02737c08aee22bc977f4968
This commit is contained in:
Andrew Stadler 2010-04-06 22:17:21 -07:00
parent be4287970b
commit 856e09d76a

View File

@ -50,7 +50,6 @@ public class SecurityPolicy {
private ComponentName mAdminName; private ComponentName mAdminName;
private PolicySet mAggregatePolicy; private PolicySet mAggregatePolicy;
private boolean mNotificationActive; private boolean mNotificationActive;
private boolean mAdminEnabled;
/* package */ static final PolicySet NO_POLICY_SET = /* package */ static final PolicySet NO_POLICY_SET =
new PolicySet(0, PolicySet.PASSWORD_MODE_NONE, 0, 0, false); new PolicySet(0, PolicySet.PASSWORD_MODE_NONE, 0, 0, false);
@ -635,13 +634,11 @@ public class SecurityPolicy {
} }
/** /**
* Internal handler for enabled/disabled transitions. Handles DeviceAdmin.onEnabled and * Internal handler for enabled->disabled transitions. Resets all security keys
* and DeviceAdmin.onDisabled. * forcing EAS to resync security state.
*/ */
/* package */ void onAdminEnabled(boolean isEnabled) { /* package */ void onAdminEnabled(boolean isEnabled) {
if (isEnabled && !mAdminEnabled) { if (!isEnabled) {
// TODO: transition to enabled state
} else if (!isEnabled && mAdminEnabled) {
// transition to disabled state // transition to disabled state
// Response: clear *all* security state information from the accounts, forcing // Response: clear *all* security state information from the accounts, forcing
// them back to the initial configurations requiring policy administration // them back to the initial configurations requiring policy administration
@ -651,7 +648,6 @@ public class SecurityPolicy {
mContext.getContentResolver().update(Account.CONTENT_URI, cv, null, null); mContext.getContentResolver().update(Account.CONTENT_URI, cv, null, null);
updatePolicies(-1); updatePolicies(-1);
} }
mAdminEnabled = isEnabled;
} }
/** /**
@ -669,7 +665,7 @@ public class SecurityPolicy {
public void onEnabled(Context context, Intent intent) { public void onEnabled(Context context, Intent intent) {
SecurityPolicy.getInstance(context).onAdminEnabled(true); SecurityPolicy.getInstance(context).onAdminEnabled(true);
} }
/** /**
* Called prior to the administrator being disabled. * Called prior to the administrator being disabled.
*/ */
@ -677,7 +673,7 @@ public class SecurityPolicy {
public void onDisabled(Context context, Intent intent) { public void onDisabled(Context context, Intent intent) {
SecurityPolicy.getInstance(context).onAdminEnabled(false); SecurityPolicy.getInstance(context).onAdminEnabled(false);
} }
/** /**
* Called after the user has changed their password. * Called after the user has changed their password.
*/ */