summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorDanesh Mondegarian <daneshm90@gmail.com>2013-06-02 17:08:41 -0400
committerDanesh Mondegarian <daneshm90@gmail.com>2013-06-17 16:00:49 -0400
commit5f18cfad7a726abd0a79d0938eab7c37fa582937 (patch)
treedbe3c4bfedb0951228fee2471d0e59714319eb2a /policy
parent44d22ba5d90b340cb99566ee99ac0b5f4fb2e826 (diff)
downloadframeworks_base-5f18cfad7a726abd0a79d0938eab7c37fa582937.zip
frameworks_base-5f18cfad7a726abd0a79d0938eab7c37fa582937.tar.gz
frameworks_base-5f18cfad7a726abd0a79d0938eab7c37fa582937.tar.bz2
Lockscreen : Fix widgets disabled
Currently, when keyguard widgets are disabled via the DevicePolicyManager, a default widget if specified via widget_default_package_name/widget_default_class_name is added on the main screen, and if not successful the default status widget is added. However in its current state, each cycle of the lockscreen alternates between the two widgets. Reason is, the default app widget is constantly recycled on screen power cycles, and in such events, when checkAppWidgetConsistency() fails to add the widget (since the id is no longer valid), it toggles back to the default status widget, and resets the stored id. Next cycle a new id is allocated and it works and so on ... This patchset addresses this issue by not removing the default status widget if not necessary, hence preserving its id and fixing the toggling issue. Change-Id: I6b21d18346fed5accc72141097939c92ee9aaa3c
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 3a8918d..ca8b130 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -144,7 +144,6 @@ public class KeyguardHostView extends KeyguardViewBase {
mAppWidgetHost = new AppWidgetHost(
context, APPWIDGET_HOST_ID, mOnClickHandler, Looper.myLooper());
mAppWidgetHost.setUserId(mUserId);
- cleanupAppWidgetIds();
mAppWidgetManager = AppWidgetManager.getInstance(mContext);
mSecurityModel = new KeyguardSecurityModel(context);
@@ -158,6 +157,7 @@ public class KeyguardHostView extends KeyguardViewBase {
mCameraDisabled = dpm.getCameraDisabled(null);
}
+ cleanupAppWidgetIds();
mSafeModeEnabled = LockPatternUtils.isSafeModeEnabled();
mUserSetupCompleted = Settings.Secure.getIntForUser(mContext.getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;
@@ -187,9 +187,22 @@ public class KeyguardHostView extends KeyguardViewBase {
// that are triggered by deleteAppWidgetId, which is why we're doing this
int[] appWidgetIdsInKeyguardSettings = mLockPatternUtils.getAppWidgets();
int[] appWidgetIdsBoundToHost = mAppWidgetHost.getAppWidgetIds();
+ int fallbackWidgetId = mLockPatternUtils.getFallbackAppWidgetId();
for (int i = 0; i < appWidgetIdsBoundToHost.length; i++) {
int appWidgetId = appWidgetIdsBoundToHost[i];
if (!contains(appWidgetIdsInKeyguardSettings, appWidgetId)) {
+ if (appWidgetId == fallbackWidgetId) {
+ if (widgetsDisabledByDpm()) {
+ // Ignore attempts to delete the fallback widget when widgets
+ // are disabled
+ continue;
+ } else {
+ // Reset fallback widget id in the event that widgets have been
+ // enabled, and fallback widget is being deleted
+ mLockPatternUtils.writeFallbackAppWidgetId(
+ AppWidgetManager.INVALID_APPWIDGET_ID);
+ }
+ }
Log.d(TAG, "Found a appWidgetId that's not being used by keyguard, deleting id "
+ appWidgetId);
mAppWidgetHost.deleteAppWidgetId(appWidgetId);
@@ -447,7 +460,8 @@ public class KeyguardHostView extends KeyguardViewBase {
if (deletePermanently) {
final int appWidgetId = ((KeyguardWidgetFrame) v).getContentAppWidgetId();
if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID &&
- appWidgetId != LockPatternUtils.ID_DEFAULT_STATUS_WIDGET) {
+ appWidgetId != LockPatternUtils.ID_DEFAULT_STATUS_WIDGET &&
+ appWidgetId != mLockPatternUtils.getFallbackAppWidgetId()) {
mAppWidgetHost.deleteAppWidgetId(appWidgetId);
}
}