From 6262172bbdead0787fd0cc03c77cfcf0a8272aaf Mon Sep 17 00:00:00 2001 From: Michal Brzezinski Date: Thu, 28 Jul 2022 21:51:37 +0200 Subject: [PATCH] Fixing shade expanded after unfolding and unlocking with fingerprint Making sure setLeaveOpenOnKeyguardHide(true) is called only when we're not on keyguard as there we don't want to keep the state of shade when going from unfolding Bug: 238752588 Test: folded keyguard -> unfold -> unlock with fingerprint -> shade should not be visible Test: CentralSurfacesImplTest Change-Id: I39acef2cfb69c622401fc6e5a2e974d7fe68487b --- .../statusbar/phone/CentralSurfacesImpl.java | 4 +++- .../statusbar/phone/CentralSurfacesImplTest.java | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 6cd028ecd2c0d..deedb328379ff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -1112,7 +1112,6 @@ public class CentralSurfacesImpl extends CoreStartable implements isFolded, willGoToSleep, isShadeOpen, leaveOpen)); } if (leaveOpen) { - mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); if (mKeyguardStateController.isShowing()) { // When device state changes on keyguard we don't want to keep the state of // the shade and instead we open clean state of keyguard with shade closed. @@ -1121,6 +1120,9 @@ public class CentralSurfacesImpl extends CoreStartable implements // expanded. To prevent that we can close QS which resets QS and some parts of // the shade to its default state. Read more in b/201537421 mCloseQsBeforeScreenOff = true; + } else { + // below makes shade stay open when going from folded to unfolded + mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); } } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index c6fb0ce34e859..248b1270cfc4e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -976,6 +976,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase { @Test public void deviceStateChange_unfolded_shadeOpen_setsLeaveOpenOnKeyguardHide() { + when(mKeyguardStateController.isShowing()).thenReturn(false); setFoldedStates(FOLD_STATE_FOLDED); setGoToSleepStates(FOLD_STATE_FOLDED); when(mNotificationPanelViewController.isFullyExpanded()).thenReturn(true); @@ -985,6 +986,19 @@ public class CentralSurfacesImplTest extends SysuiTestCase { verify(mStatusBarStateController).setLeaveOpenOnKeyguardHide(true); } + @Test + public void deviceStateChange_unfolded_shadeOpen_onKeyguard_doesNotSetLeaveOpenOnKeyguardHide() { + when(mKeyguardStateController.isShowing()).thenReturn(true); + setFoldedStates(FOLD_STATE_FOLDED); + setGoToSleepStates(FOLD_STATE_FOLDED); + when(mNotificationPanelViewController.isFullyExpanded()).thenReturn(true); + + setDeviceState(FOLD_STATE_UNFOLDED); + + verify(mStatusBarStateController, never()).setLeaveOpenOnKeyguardHide(true); + } + + @Test public void deviceStateChange_unfolded_shadeClose_doesNotSetLeaveOpenOnKeyguardHide() { setFoldedStates(FOLD_STATE_FOLDED);