From 856e09d76ab62272e660fd4a08e25637f17319a0 Mon Sep 17 00:00:00 2001 From: Andrew Stadler Date: Tue, 6 Apr 2010 22:17:21 -0700 Subject: [PATCH] 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 --- src/com/android/email/SecurityPolicy.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/com/android/email/SecurityPolicy.java b/src/com/android/email/SecurityPolicy.java index b96486580..243482473 100644 --- a/src/com/android/email/SecurityPolicy.java +++ b/src/com/android/email/SecurityPolicy.java @@ -50,7 +50,6 @@ public class SecurityPolicy { private ComponentName mAdminName; private PolicySet mAggregatePolicy; private boolean mNotificationActive; - private boolean mAdminEnabled; /* package */ static final PolicySet NO_POLICY_SET = 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 - * and DeviceAdmin.onDisabled. + * Internal handler for enabled->disabled transitions. Resets all security keys + * forcing EAS to resync security state. */ /* package */ void onAdminEnabled(boolean isEnabled) { - if (isEnabled && !mAdminEnabled) { - // TODO: transition to enabled state - } else if (!isEnabled && mAdminEnabled) { + if (!isEnabled) { // transition to disabled state // Response: clear *all* security state information from the accounts, forcing // 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); updatePolicies(-1); } - mAdminEnabled = isEnabled; } /** @@ -669,7 +665,7 @@ public class SecurityPolicy { public void onEnabled(Context context, Intent intent) { SecurityPolicy.getInstance(context).onAdminEnabled(true); } - + /** * Called prior to the administrator being disabled. */ @@ -677,7 +673,7 @@ public class SecurityPolicy { public void onDisabled(Context context, Intent intent) { SecurityPolicy.getInstance(context).onAdminEnabled(false); } - + /** * Called after the user has changed their password. */