diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index ba67a821a15db..d6351df97cf38 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -99,6 +99,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private static final int MSG_SCREEN_TURNED_ON = 319; private static final int MSG_SCREEN_TURNED_OFF = 320; private static final int MSG_NFC_UNLOCK = 321; + private static final int MSG_KEYGUARD_BOUNCER_CHANGED = 322; private static KeyguardUpdateMonitor sInstance; @@ -111,6 +112,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private int mRingMode; private int mPhoneState; private boolean mKeyguardIsVisible; + private boolean mBouncer; private boolean mBootCompleted; // Device provisioning state @@ -155,7 +157,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { handleRingerModeChange(msg.arg1); break; case MSG_PHONE_STATE_CHANGED: - handlePhoneStateChanged((String)msg.obj); + handlePhoneStateChanged((String) msg.obj); break; case MSG_CLOCK_VISIBILITY_CHANGED: handleClockVisibilityChanged(); @@ -167,7 +169,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { handleDevicePolicyManagerStateChanged(); break; case MSG_USER_SWITCHING: - handleUserSwitching(msg.arg1, (IRemoteCallback)msg.obj); + handleUserSwitching(msg.arg1, (IRemoteCallback) msg.obj); break; case MSG_USER_SWITCH_COMPLETE: handleUserSwitchComplete(msg.arg1); @@ -178,6 +180,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { case MSG_KEYGUARD_VISIBILITY_CHANGED: handleKeyguardVisibilityChanged(msg.arg1); break; + case MSG_KEYGUARD_BOUNCER_CHANGED: + handleKeyguardBouncerChanged(msg.arg1); + break; case MSG_BOOT_COMPLETED: handleBootCompleted(); break; @@ -886,6 +891,22 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } } + /** + * Handle {@link #MSG_KEYGUARD_BOUNCER_CHANGED} + * @see #sendKeyguardBouncerChanged(boolean) + */ + private void handleKeyguardBouncerChanged(int bouncer) { + if (DEBUG) Log.d(TAG, "handleKeyguardBouncerChanged(" + bouncer + ")"); + boolean isBouncer = (bouncer == 1); + mBouncer = isBouncer; + for (int i = 0; i < mCallbacks.size(); i++) { + KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); + if (cb != null) { + cb.onKeyguardBouncerChanged(isBouncer); + } + } + } + /** * Handle {@link #MSG_REPORT_EMERGENCY_CALL_ACTION} */ @@ -902,6 +923,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { return mKeyguardIsVisible; } + /** + * @return if the keyguard is currently in bouncer mode. + */ + public boolean isKeyguardBouncer() { + return mBouncer; + } + public boolean isSwitchingUser() { return mSwitchingUser; } @@ -1021,6 +1049,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { message.sendToTarget(); } + /** + * @see #handleKeyguardBouncerChanged(int) + */ + public void sendKeyguardBouncerChanged(boolean showingBouncer) { + if (DEBUG) Log.d(TAG, "sendKeyguardBouncerChanged(" + showingBouncer + ")"); + Message message = mHandler.obtainMessage(MSG_KEYGUARD_BOUNCER_CHANGED); + message.arg1 = showingBouncer ? 1 : 0; + message.sendToTarget(); + } + public void reportClockVisible(boolean visible) { mClockVisible = visible; mHandler.obtainMessage(MSG_CLOCK_VISIBILITY_CHANGED).sendToTarget(); diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java index 7be4cec8b45eb..91a024fb9288d 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java @@ -86,6 +86,12 @@ public class KeyguardUpdateMonitorCallback { mShowing = showing; } + /** + * Called when the keyguard enters or leaves bouncer mode. + * @param bouncer if true, keyguard is now in bouncer mode. + */ + public void onKeyguardBouncerChanged(boolean bouncer) { } + /** * Called when visibility of lockscreen clock changes, such as when * obscured by a widget. diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index f812e8c384ac8..e73e904370ded 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -807,7 +807,6 @@ public class KeyguardViewMediator extends SystemUI { */ public void setOccluded(boolean isOccluded) { if (DEBUG) Log.d(TAG, "setOccluded " + isOccluded); - mUpdateMonitor.sendKeyguardVisibilityChanged(!isOccluded); mHandler.removeMessages(SET_OCCLUDED); Message msg = mHandler.obtainMessage(SET_OCCLUDED, (isOccluded ? 1 : 0), 0); mHandler.sendMessage(msg); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 2ae21acd85188..77b760ed6b3f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -26,6 +26,7 @@ import android.view.ViewGroup; import com.android.internal.policy.IKeyguardShowCallback; import com.android.internal.widget.LockPatternUtils; +import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.ViewMediatorCallback; /** @@ -51,6 +52,12 @@ public class StatusBarKeyguardViewManager { private boolean mShowing; private boolean mOccluded; + private boolean mFirstUpdate = true; + private boolean mLastShowing; + private boolean mLastOccluded; + private boolean mLastBouncerShowing; + private boolean mLastBouncerDismissible; + public StatusBarKeyguardViewManager(Context context, ViewMediatorCallback callback, LockPatternUtils lockPatternUtils) { mContext = context; @@ -208,21 +215,48 @@ public class StatusBarKeyguardViewManager { private void updateStates() { int vis = mContainer.getSystemUiVisibility(); - boolean bouncerDismissable = mBouncer.isShowing() && !mBouncer.needsFullscreenBouncer(); - if (bouncerDismissable || !mShowing) { - mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK); - } else { - mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK); - } - if (mPhoneStatusBar.getNavigationBarView() != null) { - if (!(mShowing && !mOccluded) || mBouncer.isShowing()) { - mPhoneStatusBar.getNavigationBarView().setVisibility(View.VISIBLE); + boolean showing = mShowing; + boolean occluded = mOccluded; + boolean bouncerShowing = mBouncer.isShowing(); + boolean bouncerDismissible = bouncerShowing && !mBouncer.needsFullscreenBouncer(); + + if ((bouncerDismissible || !showing) != (mLastBouncerDismissible || !mLastShowing) + || mFirstUpdate) { + if (bouncerDismissible || !showing) { + mContainer.setSystemUiVisibility(vis & ~View.STATUS_BAR_DISABLE_BACK); } else { - mPhoneStatusBar.getNavigationBarView().setVisibility(View.GONE); + mContainer.setSystemUiVisibility(vis | View.STATUS_BAR_DISABLE_BACK); } } - mStatusBarWindowManager.setBouncerShowing(mBouncer.isShowing()); - mPhoneStatusBar.setBouncerShowing(mBouncer.isShowing()); + if ((!(showing && !occluded) || bouncerShowing) + != (!(mLastShowing && !mLastOccluded) || mLastBouncerShowing) || mFirstUpdate) { + if (mPhoneStatusBar.getNavigationBarView() != null) { + if (!(showing && !occluded) || bouncerShowing) { + mPhoneStatusBar.getNavigationBarView().setVisibility(View.VISIBLE); + } else { + mPhoneStatusBar.getNavigationBarView().setVisibility(View.GONE); + } + } + } + + if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { + mStatusBarWindowManager.setBouncerShowing(bouncerShowing); + mPhoneStatusBar.setBouncerShowing(bouncerShowing); + } + + KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext); + if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { + updateMonitor.sendKeyguardVisibilityChanged(showing && !occluded); + } + if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { + updateMonitor.sendKeyguardBouncerChanged(bouncerShowing); + } + + mFirstUpdate = false; + mLastShowing = showing; + mLastOccluded = occluded; + mLastBouncerShowing = bouncerShowing; + mLastBouncerDismissible = bouncerDismissible; } public boolean onMenuPressed() {