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

Commit 85a8e2b6 authored by William Xiao's avatar William Xiao
Browse files

Fix keyguard notification flicker when transition to dream with shade open

This CL fixes a bug where the notification icons and notifications on
keyguard may show up briefly when transitioning from the lockscreen
with the notification shade open to the dream.

DreamController sends an ACTION_CLOSE_SYSTEM_DIALOGS intent when
starting the dream causing the notification shade to close quickly.
Normally, the KTF transition from LOCKSCREEN to DREAMING explicitly
sets the keyguard alpha to 0 when the transition starts. However the
collapse of the notification shade isn't coordinated with the dream's
launch in any way. This means that the shade collapse might finish
after the KTF transition has already started. This update of the shade
collapse causes the flicker as normally keyguard fades back in when the
shade collapses.

Bug: 409720192
Bug: 430694649
Test: atest SharedNotificationContainerViewModelTest
      also manually verified on device
Flag: com.android.systemui.lockscreen_shade_to_dream_transition_fix
Change-Id: Idf4a1911acf5571ffda4cd6b133958e478f7f71d
parent 1e3e76ae
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -1206,6 +1206,16 @@ flag {
  }
}

flag {
  name: "lockscreen_shade_to_dream_transition_fix"
  namespace: "systemui"
  description: "Flags a minor transition fix for starting the dream from lockscreen with shade open"
  bug: "409720192"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
    name: "dream_overlay_updated_ui"
    namespace: "systemui"
+37 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2
import com.android.systemui.Flags.FLAG_LOCKSCREEN_SHADE_TO_DREAM_TRANSITION_FIX
import com.android.systemui.SysuiTestCase
import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository
import com.android.systemui.common.shared.model.NotificationContainerBounds
@@ -1338,6 +1339,42 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
            assertThat(alpha).isEqualTo(1f)
        }

    @Test
    @EnableFlags(FLAG_LOCKSCREEN_SHADE_TO_DREAM_TRANSITION_FIX)
    @BrokenWithSceneContainer(430694649)
    fun alpha_isZero_duringLockscreenToDreamTransition() =
        kosmos.runTest {
            val viewState = ViewStateAccessor()
            val alpha by
                collectLastValue(underTest.keyguardAlpha(viewState, testScope.backgroundScope))

            showLockscreenWithQSExpanded()

            // Start lockscreen to dream transition, alpha is 0 once the transition starts.
            keyguardTransitionRepository.sendTransitionStep(
                from = LOCKSCREEN,
                to = DREAMING,
                value = 0f,
                transitionState = TransitionState.STARTED,
            )
            assertThat(alpha).isEqualTo(0f)

            keyguardTransitionRepository.sendTransitionStep(
                from = LOCKSCREEN,
                to = DREAMING,
                value = 0.5f,
                transitionState = TransitionState.RUNNING,
            )
            assertThat(alpha).isEqualTo(0f)

            // Shade collapse animation finishing up. This can happen in the real world as the shade
            // collapse and dream start are not synced in any way. Keyguard alpha should not change
            // even when this is happening as the transition is ongoing.
            shadeTestUtil.setLockscreenShadeExpansion(0.1f)
            shadeTestUtil.setQsExpansion(0.1f)
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    @DisableSceneContainer
    fun notificationAbsoluteBottom_maxNotificationChanged() =
+25 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package com.android.systemui.statusbar.notification.stack.ui.viewmodel
import android.content.Context
import androidx.annotation.VisibleForTesting
import com.android.app.tracing.coroutines.flow.flowName
import com.android.systemui.Flags
import com.android.systemui.Flags.glanceableHubV2
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.common.shared.model.NotificationContainerBounds
@@ -596,11 +597,31 @@ constructor(
            } else {
                interactor.configurationBasedDimensions.flatMapLatest { configurationBasedDimensions
                    ->
                    combineTransform(shadeInteractor.shadeExpansion, shadeInteractor.qsExpansion) {
                        shadeExpansion,
                        qsExpansion ->
                    combineTransform(
                        shadeInteractor.shadeExpansion,
                        shadeInteractor.qsExpansion,
                        keyguardTransitionInteractor.isInTransition(
                            // This branch is never triggered when scene container is enabled, the
                            // edge param is unused.
                            edge = Edge.create(from = LOCKSCREEN, to = Scenes.Dream),
                            edgeWithoutSceneContainer =
                                Edge.create(from = LOCKSCREEN, to = DREAMING),
                        ),
                    ) { shadeExpansion, qsExpansion, inLockscreenToDreamTransition ->
                        if (shadeExpansion > 0f || qsExpansion > 0f) {
                            if (configurationBasedDimensions.useSplitShade) {
                            if (
                                Flags.lockscreenShadeToDreamTransitionFix() &&
                                    inLockscreenToDreamTransition
                            ) {
                                // Don't show lock screen when transitioning to dream with the shade
                                // open. The shade is collapsed by ACTION_CLOSE_SYSTEM_DIALOGS that
                                // the system server sends when starting the dream. Since the shade
                                // collapse isn't synced with the dream starting, if the collapse
                                // animation finishes after the LOCKSCREN -> DREAMING transition
                                // starts, it can cause keyguard to show up again briefly during the
                                // transition.
                                emit(0f)
                            } else if (configurationBasedDimensions.useSplitShade) {
                                emit(1f)
                            } else if (qsExpansion == 1f) {
                                // Ensure HUNs will be visible in QS shade (at least while