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

Commit 6ad77ee8 authored by Adam Cohen's avatar Adam Cohen Committed by Android Git Automerger
Browse files

am 416d4862: am 24d230e9: am 16a3f4c9: am 42164efa: Merge "Ensuring...

am 416d4862: am 24d230e9: am 16a3f4c9: am 42164efa: Merge "Ensuring bindAppWidget isn\'t called until boot completed (issue 7469267)" into jb-mr1-lockscreen-dev

* commit '416d4862':
  Ensuring bindAppWidget isn't called until boot completed (issue 7469267)
parents 7df23b0c 416d4862
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ public class KeyguardHostView extends KeyguardViewBase {
    private SecurityMode mCurrentSecuritySelection = SecurityMode.Invalid;
    private int mAppWidgetToShow;

    private boolean mBootCompleted = false;
    private boolean mCheckAppWidgetConsistencyOnBootCompleted = false;

    protected Runnable mLaunchRunnable;

    protected int mFailedAttempts;
@@ -140,6 +143,19 @@ public class KeyguardHostView extends KeyguardViewBase {
        }
    }

    private KeyguardUpdateMonitorCallback mUpdateMonitorCallbacks =
            new KeyguardUpdateMonitorCallback() {
        @Override
        public void onBootCompleted() {
            mBootCompleted = true;
            if (mCheckAppWidgetConsistencyOnBootCompleted) {
                checkAppWidgetConsistency();
                mSwitchPageRunnable.run();
                mCheckAppWidgetConsistencyOnBootCompleted = false;
            }
        }
    };

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        boolean result = super.onTouchEvent(ev);
@@ -263,12 +279,14 @@ public class KeyguardHostView extends KeyguardViewBase {
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
        mAppWidgetHost.startListening();
        KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallbacks);
    }

    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mAppWidgetHost.stopListening();
        KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallbacks);
    }

    private AppWidgetHost getAppWidgetHost() {
@@ -1086,8 +1104,13 @@ public class KeyguardHostView extends KeyguardViewBase {
        }
        return appWidgetId;
    }

    public void checkAppWidgetConsistency() {
        // Since this method may bind a widget (which we can't do until boot completed) we
        // may have to defer it until after boot complete.
        if (!mBootCompleted) {
            mCheckAppWidgetConsistencyOnBootCompleted = true;
            return;
        }
        final int childCount = mAppWidgetContainer.getChildCount();
        boolean widgetPageExists = false;
        for (int i = 0; i < childCount; i++) {
+20 −0
Original line number Diff line number Diff line
@@ -81,6 +81,8 @@ public class KeyguardUpdateMonitor {
    private static final int MSG_USER_SWITCHED = 310;
    private static final int MSG_USER_REMOVED = 311;
    private static final int MSG_KEYGUARD_VISIBILITY_CHANGED = 312;
    protected static final int MSG_BOOT_COMPLETED = 313;


    private static KeyguardUpdateMonitor sInstance;

@@ -152,6 +154,9 @@ public class KeyguardUpdateMonitor {
                case MSG_KEYGUARD_VISIBILITY_CHANGED:
                    handleKeyguardVisibilityChanged(msg.arg1);
                    break;
                case MSG_BOOT_COMPLETED:
                    handleBootCompleted();
                    break;

            }
        }
@@ -198,6 +203,8 @@ public class KeyguardUpdateMonitor {
            } else if (Intent.ACTION_USER_REMOVED.equals(action)) {
                mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_REMOVED,
                       intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0));
            } else if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
                mHandler.sendMessage(mHandler.obtainMessage(MSG_BOOT_COMPLETED));
            }
        }
    };
@@ -340,6 +347,7 @@ public class KeyguardUpdateMonitor {
        filter.addAction(AudioManager.RINGER_MODE_CHANGED_ACTION);
        filter.addAction(DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED);
        filter.addAction(Intent.ACTION_USER_REMOVED);
        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
        context.registerReceiver(mBroadcastReceiver, filter);

        try {
@@ -419,6 +427,18 @@ public class KeyguardUpdateMonitor {
        }
    }

    /**
     * Handle {@link #MSG_BOOT_COMPLETED}
     */
    protected void handleBootCompleted() {
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onBootCompleted();
            }
        }
    }

    /**
     * Handle {@link #MSG_USER_SWITCHED}
     */
+8 −0
Original line number Diff line number Diff line
@@ -99,4 +99,12 @@ class KeyguardUpdateMonitorCallback {
     * Called when a user is removed.
     */
    void onUserRemoved(int userId) { }

    /**
     * Called when boot completed.
     *
     * Note, this callback will only be received if boot complete occurs after registering with
     * KeyguardUpdateMonitor.
     */
    void onBootCompleted() { }
}