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

Commit 1a2a7e81 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add logging reasons to WmLsVis." into main

parents f3a70712 dc85151e
Loading
Loading
Loading
Loading
+16 −13
Original line number Diff line number Diff line
@@ -73,6 +73,10 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {

    /** Helper to strip out the logging reason from the lockscreen visibility flow. */
    private val lockscreenVisibilityBoolean by lazy {
        underTest.lockscreenVisibility.map { it.first }
    }
    private val lockscreenSurfaceVisibilityFlow = MutableStateFlow<Boolean?>(false)
    private val primaryBouncerSurfaceVisibilityFlow = MutableStateFlow<Boolean?>(false)
    private val surfaceBehindIsAnimatingFlow = MutableStateFlow(false)
@@ -536,7 +540,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
    @DisableSceneContainer
    fun lockscreenVisibility_visibleWhenGone() =
        kosmos.runTest {
            val values by collectValues(underTest.lockscreenVisibility)
            val values by collectValues(lockscreenVisibilityBoolean)

            // Start on LOCKSCREEN.
            fakeKeyguardTransitionRepository.sendTransitionStep(
@@ -603,7 +607,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
    @DisableSceneContainer
    fun testLockscreenVisibility_usesFromState_ifCanceled() =
        kosmos.runTest {
            val values by collectValues(underTest.lockscreenVisibility)
            val values by collectValues(lockscreenVisibilityBoolean)

            fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
@@ -698,7 +702,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
    @DisableSceneContainer
    fun testLockscreenVisibility_falseDuringTransitionToGone_fromCanceledGone() =
        kosmos.runTest {
            val values by collectValues(underTest.lockscreenVisibility)
            val values by collectValues(lockscreenVisibilityBoolean)

            fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
@@ -801,7 +805,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
    @DisableSceneContainer
    fun testLockscreenVisibility_trueDuringTransitionToGone_fromNotCanceledGone() =
        kosmos.runTest {
            val values by collectValues(underTest.lockscreenVisibility)
            val values by collectValues(lockscreenVisibilityBoolean)

            fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
@@ -917,7 +921,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
    @DisableSceneContainer
    fun testLockscreenVisibility_falseDuringWakeAndUnlockToGone_fromNotCanceledGone() =
        kosmos.runTest {
            val values by collectValues(underTest.lockscreenVisibility)
            val values by collectValues(lockscreenVisibilityBoolean)

            fakeKeyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
@@ -1045,7 +1049,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            val currentOverlays by collectLastValue(sceneInteractor.currentOverlays)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            val lockscreenVisibility by collectLastValue(lockscreenVisibilityBoolean)
            assertThat(lockscreenVisibility).isTrue()

            setSceneTransition(Idle(Scenes.Shade))
@@ -1134,7 +1138,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            val currentScene by collectLastValue(sceneInteractor.currentScene)
            assertThat(currentScene).isEqualTo(Scenes.Lockscreen)

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            val lockscreenVisibility by collectLastValue(lockscreenVisibilityBoolean)
            assertThat(lockscreenVisibility).isTrue()

            setSceneTransition(Idle(Scenes.Shade))
@@ -1241,7 +1245,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {

            setSceneTransition(Idle(Scenes.Lockscreen))

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            val lockscreenVisibility by collectLastValue(lockscreenVisibilityBoolean)
            assertThat(lockscreenVisibility).isTrue()

            setSceneTransition(Idle(Scenes.Shade))
@@ -1273,7 +1277,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {

            setSceneTransition(Idle(Scenes.Lockscreen))

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            val lockscreenVisibility by collectLastValue(lockscreenVisibilityBoolean)
            assertThat(lockscreenVisibility).isTrue()

            kosmos.authenticationInteractor.authenticate(FakeAuthenticationRepository.DEFAULT_PIN)
@@ -1296,7 +1300,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            setSceneTransition(Idle(Scenes.Gone))
            sceneInteractor.changeScene(Scenes.Gone, "")

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            val lockscreenVisibility by collectLastValue(lockscreenVisibilityBoolean)
            assertThat(lockscreenVisibility).isFalse()

            // Lockscreen vis remains false during Gone -> LS so the unlocked app content is visible
@@ -1322,7 +1326,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            setSceneTransition(Idle(Scenes.Gone))
            sceneInteractor.changeScene(Scenes.Gone, "")

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            val lockscreenVisibility by collectLastValue(lockscreenVisibilityBoolean)
            assertThat(lockscreenVisibility).isFalse()

            // Lockscreen vis remains false during Gone -> LS so the unlocked app content is visible
@@ -1351,7 +1355,7 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            setSceneTransition(Idle(Scenes.Gone))
            sceneInteractor.changeScene(Scenes.Gone, "")

            val lockscreenVisibility by collectLastValue(underTest.lockscreenVisibility)
            val lockscreenVisibility by collectLastValue(lockscreenVisibilityBoolean)
            assertThat(lockscreenVisibility).isFalse()

            // Lockscreen vis remains false during Gone -> LS so the unlocked app content is visible
@@ -1371,7 +1375,6 @@ class WindowManagerLockscreenVisibilityInteractorTest : SysuiTestCase() {
            assertThat(lockscreenVisibility).isFalse()
        }


    companion object {
        private val progress = MutableStateFlow(0f)

+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ constructor(
            .distinctUntilChanged()
            .flatMapLatest { shouldCheckLockscreenVisibility ->
                if (shouldCheckLockscreenVisibility) {
                    lockscreenVisibilityInteractor.lockscreenVisibility.map { !it }
                    lockscreenVisibilityInteractor.lockscreenVisibility.map { !it.first }
                } else {
                    flowOf(false)
                }
+6 −5
Original line number Diff line number Diff line
@@ -170,17 +170,17 @@ constructor(
                "setLockscreenShown(true) because we're setting the surface invisible " +
                    "and lockscreen is already showing.",
            )
            setLockscreenShown(true)
            setLockscreenShown(true, "requested surface invisible w/ lockscreen showing")
        }
    }

    fun setAodVisible(aodVisible: Boolean) {
        setWmLockscreenState(aodVisible = aodVisible)
        setWmLockscreenState(aodVisible = aodVisible, reason = "setAodVisible($aodVisible)")
    }

    /** Sets the visibility of the lockscreen. */
    fun setLockscreenShown(lockscreenShown: Boolean) {
        setWmLockscreenState(lockscreenShowing = lockscreenShown)
    fun setLockscreenShown(lockscreenShown: Boolean, reason: String = "") {
        setWmLockscreenState(lockscreenShowing = lockscreenShown, reason = reason)
    }

    /**
@@ -284,6 +284,7 @@ constructor(
    private fun setWmLockscreenState(
        lockscreenShowing: Boolean? = this.isLockscreenShowing,
        aodVisible: Boolean = this.isAodVisible,
        reason: String,
    ) {
        if (lockscreenShowing == null) {
            Log.d(
@@ -322,7 +323,7 @@ constructor(
                TAG,
                "ATMS#setLockScreenShown(" +
                    "isLockscreenShowing=$lockscreenShowing, " +
                    "aodVisible=$aodVisible).",
                    "aodVisible=$aodVisible): $reason",
            )
            if (enableNewKeyguardShellTransitions) {
                startKeyguardTransition(lockscreenShowing, aodVisible)
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ constructor(
            // This is not the only place we notify the lockNowCallbacks - there are cases where we
            // decide not to show the lockscreen despite being asked to, and we need to notify the
            // callback in those cases as well.
            wmLockscreenVisibilityInteractor.get().lockscreenVisibility.collect { visible ->
            wmLockscreenVisibilityInteractor.get().lockscreenVisibility.collect { (visible, _) ->
                if (visible) {
                    notifyShowLockscreenCallbacks()
                }
+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ constructor(
        }

        applicationScope.launch {
            wmLockscreenVisibilityInteractor.lockscreenVisibility.collect { visible ->
            wmLockscreenVisibilityInteractor.lockscreenVisibility.collect { (visible, _) ->
                val iterator = callbacks.iterator()
                withContext(backgroundDispatcher) {
                    while (iterator.hasNext()) {
Loading