Skip to content
Snippets Groups Projects
Commit c492897f authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Don't call setLockScreenShown until we know if it's showing.

Early calls to setLockscreenShown with aodVisible=true/false were causing us to apply the default lockscreenShowing=true value, which causes problems if we boot with the lockscreen disabled.

The new KeyguardTransitionBootInteractor guarantees that we'll be provided a lockscreenShowing=true/false value soon after boot, so we can just wait for that.

Test: atest WindowManagerLockscreenVisibilityManagerTest
Flag: EXEMPT bugfix
Bug: 278086361
Change-Id: I50b3bd44a10efb1a7433af5a2468e83eba8f975a
parent 76ab55e4
No related branches found
No related tags found
No related merge requests found
......@@ -185,25 +185,11 @@ constructor(
/**
* Sets the lockscreen state WM-side by calling ATMS#setLockScreenShown.
*
* [lockscreenShowing] defaults to true, since it's only ever null during the boot sequence,
* when we haven't yet called ATMS#setLockScreenShown. Typically,
* setWmLockscreenState(lockscreenShowing = true) is called early in the boot sequence, before
* setWmLockscreenState(aodVisible = true), so we don't expect to need to use this default, but
* if so, true should be the right choice.
* If [lockscreenShowing] is null, it means we don't know if the lockscreen is showing yet. This
* will be decided by the [KeyguardTransitionBootInteractor] shortly.
*/
private fun setWmLockscreenState(
lockscreenShowing: Boolean =
this.isLockscreenShowing
?: true.also {
Log.d(
TAG,
"Using isLockscreenShowing=true default in setWmLockscreenState, " +
"because setAodVisible was called before the first " +
"setLockscreenShown call during boot. This is not typical, but is " +
"theoretically possible. If you're investigating the lockscreen " +
"showing unexpectedly, start here."
)
},
lockscreenShowing: Boolean? = this.isLockscreenShowing,
aodVisible: Boolean = this.isAodVisible
) {
Log.d(
......@@ -213,10 +199,27 @@ constructor(
"aodVisible=$aodVisible)."
)
if (lockscreenShowing == null) {
Log.d(
TAG,
"isAodVisible=$aodVisible, but lockscreenShowing=null. Waiting for" +
"non-null lockscreenShowing before calling ATMS#setLockScreenShown, which" +
"will happen once KeyguardTransitionBootInteractor starts the boot transition."
)
this.isAodVisible = aodVisible
return
}
if (this.isLockscreenShowing == lockscreenShowing && this.isAodVisible == aodVisible) {
return
}
Log.d(
TAG,
"ATMS#setLockScreenShown(" +
"isLockscreenShowing=$lockscreenShowing, " +
"aodVisible=$aodVisible)."
)
activityTaskManagerService.setLockScreenShown(lockscreenShowing, aodVisible)
this.isLockscreenShowing = lockscreenShowing
this.isAodVisible = aodVisible
......
......@@ -100,9 +100,11 @@ class WindowManagerLockscreenVisibilityManagerTest : SysuiTestCase() {
}
@Test
fun testAodVisible_noLockscreenShownCallYet_defaultsToShowLockscreen() {
fun testAodVisible_noLockscreenShownCallYet_doesNotShowLockscreenUntilLater() {
underTest.setAodVisible(false)
verifyNoMoreInteractions(activityTaskManagerService)
underTest.setLockscreenShown(true)
verify(activityTaskManagerService).setLockScreenShown(true, false)
verifyNoMoreInteractions(activityTaskManagerService)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment