Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73119894 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Lockscreen : Fix widgets disabled" into cm-10.1

parents fc5f644a 5f18cfad
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -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);
                }
            }