diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 608d03cf52c91..a4781307e9392 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -709,6 +709,8 @@ public class StatusBar extends SystemUI implements DemoMode, private KeyguardMonitorImpl mKeyguardMonitor; private BatteryController mBatteryController; private boolean mPanelExpanded; + private boolean mKeyguardRequested; + private boolean mIsKeyguard; private LogMaker mStatusBarStateLog; private LockscreenGestureLogger mLockscreenGestureLogger = new LockscreenGestureLogger(); private NotificationIconAreaController mNotificationIconAreaController; @@ -4022,6 +4024,30 @@ public class StatusBar extends SystemUI implements DemoMode, } public void showKeyguard() { + mKeyguardRequested = true; + updateIsKeyguard(); + } + + public boolean hideKeyguard() { + mKeyguardRequested = false; + return updateIsKeyguard(); + } + + private boolean updateIsKeyguard() { + // For dozing, keyguard needs to be shown whenever the device is non-interactive. Otherwise + // there's no surface we can show to the user. + boolean keyguardForDozing = mDozingRequested && !mDeviceInteractive; + boolean shouldBeKeyguard = mKeyguardRequested || keyguardForDozing; + if (shouldBeKeyguard && !mIsKeyguard) { + showKeyguardImpl(); + } else if (!shouldBeKeyguard && mIsKeyguard) { + return hideKeyguardImpl(); + } + return false; + } + + public void showKeyguardImpl() { + mIsKeyguard = true; if (mLaunchTransitionFadingAway) { mNotificationPanel.animate().cancel(); onLaunchTransitionFadingEnded(); @@ -4175,7 +4201,8 @@ public class StatusBar extends SystemUI implements DemoMode, /** * @return true if we would like to stay in the shade, false if it should go away entirely */ - public boolean hideKeyguard() { + public boolean hideKeyguardImpl() { + mIsKeyguard = false; Trace.beginSection("StatusBar#hideKeyguard"); boolean staying = mLeaveOpenOnKeyguardHide; setBarState(StatusBarState.SHADE); @@ -4854,6 +4881,7 @@ public class StatusBar extends SystemUI implements DemoMode, } }); } + updateIsKeyguard(); } public void onStartedWakingUp() { @@ -4862,6 +4890,7 @@ public class StatusBar extends SystemUI implements DemoMode, mVisualStabilityManager.setScreenOn(true); mNotificationPanel.setTouchDisabled(false); updateVisibleToUser(); + updateIsKeyguard(); } public void onScreenTurningOn() { @@ -4976,6 +5005,7 @@ public class StatusBar extends SystemUI implements DemoMode, || mFingerprintUnlockController.getMode() == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; mStatusBarWindowManager.setDozing(mDozing); + mStatusBarKeyguardViewManager.setDozing(mDozing); updateDozingState(); Trace.endSection(); } 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 2a69c1e663bbc..3b09bec08cb05 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -84,6 +84,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected boolean mShowing; protected boolean mOccluded; protected boolean mRemoteInputActive; + private boolean mDozing; protected boolean mFirstUpdate = true; protected boolean mLastShowing; @@ -91,6 +92,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private boolean mLastBouncerShowing; private boolean mLastBouncerDismissible; protected boolean mLastRemoteInputActive; + private boolean mLastDozing; private OnDismissAction mAfterKeyguardGoneAction; private final ArrayList mAfterKeyguardGoneRunnables = new ArrayList<>(); @@ -239,6 +241,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb updateStates(); } + public void setDozing(boolean dozing) { + mDozing = dozing; + updateStates(); + } + public void onScreenTurnedOff() { mScreenTurnedOn = false; mStatusBar.onScreenTurnedOff(); @@ -481,11 +488,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private long getNavBarShowDelay() { if (mStatusBar.isKeyguardFadingAway()) { return mStatusBar.getKeyguardFadingAwayDelay(); - } else { - - // Keyguard is not going away, thus we are showing the navigation bar because the - // bouncer is appearing. + } else if (mBouncer.isShowing()) { return NAV_BAR_SHOW_DELAY_BOUNCER; + } else { + // No longer dozing, or remote input is active. No delay. + return 0; } } @@ -553,6 +560,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mLastBouncerShowing = bouncerShowing; mLastBouncerDismissible = bouncerDismissible; mLastRemoteInputActive = remoteInputActive; + mLastDozing = mDozing; mStatusBar.onKeyguardViewManagerStatesUpdated(); } @@ -561,14 +569,15 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb * @return Whether the navigation bar should be made visible based on the current state. */ protected boolean isNavBarVisible() { - return !(mShowing && !mOccluded) || mBouncer.isShowing() || mRemoteInputActive; + return !(mShowing && !mOccluded) && !mDozing || mBouncer.isShowing() || mRemoteInputActive; } /** * @return Whether the navigation bar was made visible based on the last known state. */ protected boolean getLastNavBarVisible() { - return !(mLastShowing && !mLastOccluded) || mLastBouncerShowing || mLastRemoteInputActive; + return !(mLastShowing && !mLastOccluded) && !mLastDozing || mLastBouncerShowing + || mLastRemoteInputActive; } public boolean shouldDismissOnMenuPressed() {