Skip to content

Commit 9be6207

Browse files
author
Jeff DeCew
committed
Allow forcing status bar state changes and do so when the screen turns off.
This adds a force flag, which we will use when turning the screen off to make sure that all UI components are reset to the SHADE state regardless. Bug: 189575031 Test: make a call; lock screen; pull down shade Merged-In: I79baeb71ac5d1ed45602ac55cdca996b3bed0ac3 Change-Id: I79baeb71ac5d1ed45602ac55cdca996b3bed0ac3
1 parent 231a42b commit 9be6207

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/StatusBarStateControllerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ public int getState() {
134134
}
135135

136136
@Override
137-
public boolean setState(int state) {
137+
public boolean setState(int state, boolean force) {
138138
if (state > MAX_STATE || state < MIN_STATE) {
139139
throw new IllegalArgumentException("Invalid state " + state);
140140
}
141-
if (state == mState) {
141+
if (!force && state == mState) {
142142
return false;
143143
}
144144

packages/SystemUI/src/com/android/systemui/statusbar/SysuiStatusBarStateController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,19 @@ public interface SysuiStatusBarStateController extends StatusBarStateController
5858
* @param state see {@link StatusBarState} for valid options
5959
* @return {@code true} if the state changed, else {@code false}
6060
*/
61-
boolean setState(int state);
61+
default boolean setState(int state) {
62+
return setState(state, false /* force */);
63+
}
64+
65+
/**
66+
* Update the status bar state
67+
* @param state see {@link StatusBarState} for valid options
68+
* @param force whether to set the state even if it's the same as the current state. This will
69+
* dispatch the state to all StatusBarStateListeners, ensuring that all listening
70+
* components are reset to this state.
71+
* @return {@code true} if the state was changed or set forcefully
72+
*/
73+
boolean setState(int state, boolean force);
6274

6375
/**
6476
* Update the dozing state from {@link StatusBar}'s perspective

packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3152,6 +3152,10 @@ public boolean isFullScreenUserSwitcherState() {
31523152
}
31533153

31543154
boolean updateIsKeyguard() {
3155+
return updateIsKeyguard(false /* force */);
3156+
}
3157+
3158+
boolean updateIsKeyguard(boolean force) {
31553159
boolean wakeAndUnlocking = mBiometricUnlockController.getMode()
31563160
== BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
31573161

@@ -3174,7 +3178,7 @@ boolean updateIsKeyguard() {
31743178
showKeyguardImpl();
31753179
}
31763180
} else {
3177-
return hideKeyguardImpl();
3181+
return hideKeyguardImpl(force);
31783182
}
31793183
return false;
31803184
}
@@ -3305,11 +3309,11 @@ private void runLaunchTransitionEndRunnable() {
33053309
/**
33063310
* @return true if we would like to stay in the shade, false if it should go away entirely
33073311
*/
3308-
public boolean hideKeyguardImpl() {
3312+
public boolean hideKeyguardImpl(boolean force) {
33093313
mIsKeyguard = false;
33103314
Trace.beginSection("StatusBar#hideKeyguard");
33113315
boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide();
3312-
if (!(mStatusBarStateController.setState(StatusBarState.SHADE))) {
3316+
if (!(mStatusBarStateController.setState(StatusBarState.SHADE, force))) {
33133317
//TODO: StatusBarStateController should probably know about hiding the keyguard and
33143318
// notify listeners.
33153319

@@ -3736,7 +3740,8 @@ public void onFinishedGoingToSleep() {
37363740
// is correct.
37373741
mHandler.post(() -> onCameraLaunchGestureDetected(mLastCameraLaunchSource));
37383742
}
3739-
updateIsKeyguard();
3743+
// When finished going to sleep, force the status bar state to avoid stale state.
3744+
updateIsKeyguard(true /* force */);
37403745
}
37413746

37423747
@Override

packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,14 @@ public void testShowKeyguardImplementation_setsState() {
809809

810810
// By default, showKeyguardImpl sets state to KEYGUARD.
811811
mStatusBar.showKeyguardImpl();
812-
verify(mStatusBarStateController).setState(eq(StatusBarState.KEYGUARD));
812+
verify(mStatusBarStateController).setState(
813+
eq(StatusBarState.KEYGUARD), eq(false) /* force */);
813814

814815
// If useFullscreenUserSwitcher is true, state is set to FULLSCREEN_USER_SWITCHER.
815816
when(mUserSwitcherController.useFullscreenUserSwitcher()).thenReturn(true);
816817
mStatusBar.showKeyguardImpl();
817-
verify(mStatusBarStateController).setState(eq(StatusBarState.FULLSCREEN_USER_SWITCHER));
818+
verify(mStatusBarStateController).setState(
819+
eq(StatusBarState.FULLSCREEN_USER_SWITCHER), eq(false) /* force */);
818820
}
819821

820822
@Test

0 commit comments

Comments
 (0)