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

Commit df39b491 authored by Matt Pietal's avatar Matt Pietal
Browse files

Fix AOD icon flicker during GONE->AOD

Visibility was being changed during GONE-AOD transition. Disallow this
and make sure the alpha/visibility states are consistent

Fixes: 322157767
Test: atest KeyguardRootViewModelTest
Test: use GONE->AOD and observe notif icons state changes
Flag: ACONFIG com.android.systemui.keyguard_shade_migration_nssl
DEVELOPMENT

Change-Id: I321d80232799bc649840a35feba598c8281c454e
parent 70bc7fb1
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -115,6 +115,23 @@ class KeyguardRootViewModelTest : SysuiTestCase() {
            assertThat(isVisible?.isAnimating).isFalse()
        }

    @Test
    fun iconContainer_isNotVisible_onKeyguard_dontShowWhenGoneToAodTransitionRunning() =
        testScope.runTest {
            val isVisible by collectLastValue(underTest.isNotifIconContainerVisible)
            runCurrent()
            keyguardTransitionRepository.sendTransitionSteps(
                from = KeyguardState.GONE,
                to = KeyguardState.AOD,
                testScope,
            )
            whenever(screenOffAnimationController.shouldShowAodIconsWhenShade()).thenReturn(false)
            runCurrent()

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

    @Test
    fun iconContainer_isVisible_bypassEnabled() =
        testScope.runTest {
+9 −5
Original line number Diff line number Diff line
@@ -145,9 +145,7 @@ object KeyguardRootViewBinder {
                        launch {
                            viewModel.burnInLayerVisibility.collect { visibility ->
                                childViews[burnInLayerId]?.visibility = visibility
                                // Reset alpha only for the icons, as they currently have their
                                // own animator
                                childViews[aodNotificationIconContainerId]?.alpha = 0f
                                childViews[aodNotificationIconContainerId]?.visibility = visibility
                            }
                        }

@@ -435,11 +433,17 @@ object KeyguardRootViewBinder {
            }
        when {
            !isVisible.isAnimating -> {
                alpha = 1f
                if (!KeyguardShadeMigrationNssl.isEnabled) {
                    translationY = 0f
                }
                visibility = if (isVisible.value) View.VISIBLE else View.INVISIBLE
                visibility =
                    if (isVisible.value) {
                        alpha = 1f
                        View.VISIBLE
                    } else {
                        alpha = 0f
                        View.INVISIBLE
                    }
            }
            newAodTransition() -> {
                animateInIconTranslation()
+14 −1
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.KeyguardState.AOD
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.statusbar.notification.domain.interactor.NotificationsKeyguardInteractor
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.phone.ScreenOffAnimationController
@@ -48,6 +50,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onStart

@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
@@ -78,6 +81,12 @@ constructor(

    val goneToAodTransition = keyguardTransitionInteractor.transition(from = GONE, to = AOD)

    private val goneToAodTransitionRunning: Flow<Boolean> =
        goneToAodTransition
            .map { it.transitionState == STARTED || it.transitionState == RUNNING }
            .onStart { emit(false) }
            .distinctUntilChanged()

    /** Last point that the root view was tapped */
    val lastRootViewTapPosition: Flow<Point?> = keyguardInteractor.lastRootViewTapPosition

@@ -138,6 +147,7 @@ constructor(
    /** Is the notification icon container visible? */
    val isNotifIconContainerVisible: Flow<AnimatedValue<Boolean>> =
        combine(
                goneToAodTransitionRunning,
                keyguardTransitionInteractor.finishedKeyguardState.map {
                    KeyguardState.lockscreenVisibleInState(it)
                },
@@ -145,6 +155,7 @@ constructor(
                areNotifsFullyHiddenAnimated(),
                isPulseExpandingAnimated(),
            ) {
                goneToAodTransitionRunning: Boolean,
                onKeyguard: Boolean,
                isBypassEnabled: Boolean,
                notifsFullyHidden: AnimatedValue<Boolean>,
@@ -154,7 +165,9 @@ constructor(
                    // 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
                    // animating in the AOD UI and will be switching to KEYGUARD shortly.
                    !onKeyguard && !screenOffAnimationController.shouldShowAodIconsWhenShade() ->
                    goneToAodTransitionRunning ||
                        (!onKeyguard &&
                            !screenOffAnimationController.shouldShowAodIconsWhenShade()) ->
                        AnimatedValue.NotAnimating(false)
                    else ->
                        zip(notifsFullyHidden, pulseExpanding) {