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

Commit ea7d4491 authored by Paul Hobbs's avatar Paul Hobbs Committed by Android (Google) Code Review
Browse files

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

Revert submission 27770576

Reason for revert: breaks tests listed in b/346405951

Reverted changes: /q/submissionid:27770576

Change-Id: I9c610c08255bc86b5153da0d754330dc086fb6d3
parent c492897f
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -185,11 +185,25 @@ constructor(
    /**
     * Sets the lockscreen state WM-side by calling ATMS#setLockScreenShown.
     *
     * If [lockscreenShowing] is null, it means we don't know if the lockscreen is showing yet. This
     * will be decided by the [KeyguardTransitionBootInteractor] shortly.
     * [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.
     */
    private fun setWmLockscreenState(
        lockscreenShowing: Boolean? = this.isLockscreenShowing,
        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."
                    )
                },
        aodVisible: Boolean = this.isAodVisible
    ) {
        Log.d(
@@ -199,27 +213,10 @@ 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
+1 −3
Original line number Diff line number Diff line
@@ -100,11 +100,9 @@ class WindowManagerLockscreenVisibilityManagerTest : SysuiTestCase() {
    }

    @Test
    fun testAodVisible_noLockscreenShownCallYet_doesNotShowLockscreenUntilLater() {
    fun testAodVisible_noLockscreenShownCallYet_defaultsToShowLockscreen() {
        underTest.setAodVisible(false)
        verifyNoMoreInteractions(activityTaskManagerService)

        underTest.setLockscreenShown(true)
        verify(activityTaskManagerService).setLockScreenShown(true, false)
        verifyNoMoreInteractions(activityTaskManagerService)
    }