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

Commit ae90088e authored by Lucas Silva's avatar Lucas Silva
Browse files

Keep notifications hidden when dreaming

This avoids notifications flickering when tapping to exit the dream,
before the glanceable hub is shown. This is due to a race condition
between the unocclusion logic running which sets StatusBarState back to
KEYGUARD, and the transition from DREAMING->HUB running.

Fixes: 329091482
Flag: ACONFIG com.android.systemui.communal_hub TEAMFOOD
Test: atest SharedNotificationContainerViewModelTest
Change-Id: Ib96c06eeba630c35f048ca1c8479f349f922d11b
parent db6f702b
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -290,10 +290,15 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
        testScope.runTest {
            val alpha by collectLastValue(underTest.glanceableHubAlpha)

            // Start on dream
            showDream()
            // Start on lockscreen, notifications should be unhidden.
            showLockscreen()
            assertThat(alpha).isEqualTo(1f)

            // Transition to dream, notifications should be hidden so that transition
            // from dream->hub doesn't cause notification flicker.
            showDream()
            assertThat(alpha).isEqualTo(0f)

            // Start transitioning to glanceable hub
            val progress = 0.6f
            keyguardTransitionRepository.sendTransitionStep(
+6 −3
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.view.View
import android.view.WindowInsets
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.Flags.communalHub
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.ui.viewmodel.BurnInParameters
@@ -149,6 +150,7 @@ constructor(
                        }
                    }

                    if (communalHub()) {
                        launch {
                            viewModel.glanceableHubAlpha.collect {
                                controller.setMaxAlphaForGlanceableHub(it)
@@ -156,6 +158,7 @@ constructor(
                        }
                    }
                }
            }

        controller.setOnHeightChangedRunnable { viewModel.notificationStackChanged() }
        disposables += DisposableHandle { controller.setOnHeightChangedRunnable(null) }
+21 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.KeyguardState.ALTERNATE_BOUNCER
import com.android.systemui.keyguard.shared.model.KeyguardState.AOD
import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING
import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING
import com.android.systemui.keyguard.shared.model.KeyguardState.GLANCEABLE_HUB
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
@@ -241,7 +242,22 @@ constructor(
                started = SharingStarted.Eagerly,
                initialValue = false,
            )
            .dumpWhileCollecting("isOnGlanceableHubWithoutShade")
            .dumpValue("isOnGlanceableHubWithoutShade")

    /** Are we on the dream without the shade/qs? */
    private val isDreamingWithoutShade: Flow<Boolean> =
        combine(
                keyguardTransitionInteractor.isFinishedInState(DREAMING),
                isAnyExpanded,
            ) { isDreaming, isAnyExpanded ->
                isDreaming && !isAnyExpanded
            }
            .stateIn(
                scope = applicationScope,
                started = SharingStarted.Eagerly,
                initialValue = false,
            )
            .dumpValue("isDreamingWithoutShade")

    /**
     * Fade in if the user swipes the shade back up, not if collapsed by going to AOD. This is
@@ -459,6 +475,7 @@ constructor(
        combineTransform(
                isOnGlanceableHubWithoutShade,
                isOnLockscreen,
                isDreamingWithoutShade,
                merge(
                        lockscreenToGlanceableHubTransitionViewModel.notificationAlpha,
                        glanceableHubToLockscreenTransitionViewModel.notificationAlpha,
@@ -466,9 +483,9 @@ constructor(
                    // Manually emit on start because [notificationAlpha] only starts emitting
                    // when transitions start.
                    .onStart { emit(1f) }
            ) { isOnGlanceableHubWithoutShade, isOnLockscreen, alpha,
            ) { isOnGlanceableHubWithoutShade, isOnLockscreen, isDreamingWithoutShade, alpha,
                ->
                if (isOnGlanceableHubWithoutShade && !isOnLockscreen) {
                if ((isOnGlanceableHubWithoutShade || isDreamingWithoutShade) && !isOnLockscreen) {
                    // Notifications should not be visible on the glanceable hub.
                    // TODO(b/321075734): implement a way to actually set the notifications to
                    // gone while on the hub instead of just adjusting alpha
@@ -483,6 +500,7 @@ constructor(
                    emit(1f)
                }
            }
            .distinctUntilChanged()
            .dumpWhileCollecting("glanceableHubAlpha")

    /**