Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e087075 authored by Josh Tsuji's avatar Josh Tsuji
Browse files

Revert "Revert "Don't call setLockScreenShown until we know if i..."

Revert submission 27773289-revert-27770576-DGMSFQBZGQ

Reason for revert: Test failure was unrelated

Reverted changes: /q/submissionid:27773289-revert-27770576-DGMSFQBZGQ

Change-Id: I1b3a411fad1e789d2035f808f3a51348168de162
parent 1b895828
Loading
Loading
Loading
Loading
+20 −17
Original line number Diff line number Diff line
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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)
    }