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

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

Merge "Ensure AOD icons don't appear on lockscreen" into main

parents b41c9964 791b8956
Loading
Loading
Loading
Loading
+44 −8
Original line number Diff line number Diff line
@@ -19,11 +19,13 @@

package com.android.systemui.keyguard.ui.viewmodel

import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import android.view.View
import androidx.test.filters.SmallTest
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.systemui.Flags as AConfigFlags
import com.android.systemui.Flags.FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR
import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT
import com.android.systemui.Flags.FLAG_NEW_AOD_TRANSITION
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.data.repository.communalSceneRepository
@@ -68,6 +70,11 @@ import platform.test.runner.parameterized.Parameters

@SmallTest
@RunWith(ParameterizedAndroidJunit4::class)
@EnableFlags(
    FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT,
    FLAG_NEW_AOD_TRANSITION,
    FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR
)
class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
@@ -102,13 +109,6 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()

    @Before
    fun setUp() {
        mSetFlagsRule.enableFlags(FLAG_NEW_AOD_TRANSITION)
        if (!SceneContainerFlag.isEnabled) {
            mSetFlagsRule.enableFlags(AConfigFlags.FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR)
            mSetFlagsRule.disableFlags(
                AConfigFlags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT,
            )
        }
        kosmos.sceneContainerRepository.setTransitionState(transitionState)
    }

@@ -212,6 +212,11 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
        testScope.runTest {
            val isVisible by collectLastValue(underTest.isNotifIconContainerVisible)
            runCurrent()
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.DOZING,
                testScope,
            )
            notificationsKeyguardInteractor.setPulseExpanding(false)
            deviceEntryRepository.setBypassEnabled(false)
            whenever(dozeParameters.alwaysOn).thenReturn(false)
@@ -227,6 +232,11 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
        testScope.runTest {
            val isVisible by collectLastValue(underTest.isNotifIconContainerVisible)
            runCurrent()
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.DOZING,
                testScope,
            )
            notificationsKeyguardInteractor.setPulseExpanding(false)
            deviceEntryRepository.setBypassEnabled(false)
            whenever(dozeParameters.alwaysOn).thenReturn(true)
@@ -243,6 +253,11 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
        testScope.runTest {
            val isVisible by collectLastValue(underTest.isNotifIconContainerVisible)
            runCurrent()
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.LOCKSCREEN,
                to = KeyguardState.DOZING,
                testScope,
            )
            notificationsKeyguardInteractor.setPulseExpanding(false)
            deviceEntryRepository.setBypassEnabled(false)
            whenever(dozeParameters.alwaysOn).thenReturn(true)
@@ -254,6 +269,27 @@ class KeyguardRootViewModelTest(flags: FlagsParameterization) : SysuiTestCase()
            assertThat(isVisible?.isAnimating).isTrue()
        }

    @Test
    fun iconContainer_isNotVisible_bypassDisabled_onLockscreen() =
        testScope.runTest {
            val isVisible by collectLastValue(underTest.isNotifIconContainerVisible)
            runCurrent()
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.AOD,
                to = KeyguardState.LOCKSCREEN,
                testScope,
            )
            notificationsKeyguardInteractor.setPulseExpanding(false)
            deviceEntryRepository.setBypassEnabled(false)
            whenever(dozeParameters.alwaysOn).thenReturn(true)
            whenever(dozeParameters.displayNeedsBlanking).thenReturn(false)
            notificationsKeyguardInteractor.setNotificationsFullyHidden(true)
            runCurrent()

            assertThat(isVisible?.value).isFalse()
            assertThat(isVisible?.isAnimating).isTrue()
        }

    @Test
    fun isIconContainerVisible_stopAnimation() =
        testScope.runTest {
+0 −2
Original line number Diff line number Diff line
@@ -207,14 +207,12 @@ object KeyguardRootViewBinder {
                        launch {
                            viewModel.burnInLayerVisibility.collect { visibility ->
                                childViews[burnInLayerId]?.visibility = visibility
                                childViews[aodNotificationIconContainerId]?.visibility = visibility
                            }
                        }

                        launch {
                            viewModel.burnInLayerAlpha.collect { alpha ->
                                childViews[statusViewId]?.alpha = alpha
                                childViews[aodNotificationIconContainerId]?.alpha = alpha
                            }
                        }

+14 −7
Original line number Diff line number Diff line
@@ -320,19 +320,24 @@ constructor(
    val isNotifIconContainerVisible: StateFlow<AnimatedValue<Boolean>> =
        combine(
                goneToAodTransitionRunning,
                keyguardTransitionInteractor
                    .transitionValue(LOCKSCREEN)
                    .map { it > 0f }
                    .onStart { emit(false) },
                keyguardTransitionInteractor.finishedKeyguardState.map {
                    KeyguardState.lockscreenVisibleInState(it)
                },
                deviceEntryInteractor.isBypassEnabled,
                areNotifsFullyHiddenAnimated(),
                isPulseExpandingAnimated(),
            ) {
                goneToAodTransitionRunning: Boolean,
                onKeyguard: Boolean,
                isBypassEnabled: Boolean,
                notifsFullyHidden: AnimatedValue<Boolean>,
                pulseExpanding: AnimatedValue<Boolean>,
                ->
            ) { flows ->
                val goneToAodTransitionRunning = flows[0] as Boolean
                val isOnLockscreen = flows[1] as Boolean
                val onKeyguard = flows[2] as Boolean
                val isBypassEnabled = flows[3] as Boolean
                val notifsFullyHidden = flows[4] as AnimatedValue<Boolean>
                val pulseExpanding = flows[5] as AnimatedValue<Boolean>

                when {
                    // Hide the AOD icons if we're not in the KEYGUARD state unless the screen off
                    // animation is playing, in which case we want them to be visible if we're
@@ -351,6 +356,8 @@ constructor(
                                isBypassEnabled -> true
                                // If we are pulsing (and not bypassing), then we are hidden
                                isPulseExpanding -> false
                                // Besides bypass above, they should not be visible on lockscreen
                                isOnLockscreen -> false
                                // If notifs are fully gone, then we're visible
                                areNotifsFullyHidden -> true
                                // Otherwise, we're hidden