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

Commit 52917fc9 authored by burakov's avatar burakov
Browse files

[bc25] Make Lockscreen notifications content-key agnostic.

In the shade scenes implementation, we had to hide notifications on the
lockscreen when the notifications shade is open, in order to prevent a
double-composition of the same ElementKey in the same scene
(notifications in the shade and in the lockscreen, both of which were
rendered by the NotificationsShadeScene composable). With STL overlays,
this is no longer needed.

Bug: 356596436
Flag: com.android.systemui.scene_container
Flag: com.android.systemui.dual_shade
Test: Updated unit tests.
Test: Existing unit tests still pass.
Change-Id: I39bc95cd7fcda70b0e7ea36c59a714d4bf33fef0
parent a5e9826e
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -73,9 +73,7 @@ constructor(
        val isShadeLayoutWide by viewModel.isShadeLayoutWide.collectAsStateWithLifecycle()
        val unfoldTranslations by viewModel.unfoldTranslations.collectAsStateWithLifecycle()
        val areNotificationsVisible by
            viewModel
                .areNotificationsVisible(contentKey)
                .collectAsStateWithLifecycle(initialValue = false)
            viewModel.areNotificationsVisible().collectAsStateWithLifecycle(initialValue = false)
        val isBypassEnabled by viewModel.isBypassEnabled.collectAsStateWithLifecycle()

        if (isBypassEnabled) {
+4 −36
Original line number Diff line number Diff line
@@ -128,8 +128,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
    fun areNotificationsVisible_splitShadeTrue_true() =
        with(kosmos) {
            testScope.runTest {
                val areNotificationsVisible by
                    collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen))
                val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible())
                shadeRepository.setShadeLayoutWide(true)
                fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE)

@@ -142,36 +141,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
    fun areNotificationsVisible_dualShadeWideOnLockscreen_true() =
        with(kosmos) {
            testScope.runTest {
                val areNotificationsVisible by
                    collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen))
                shadeRepository.setShadeLayoutWide(true)
                fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE)

                assertThat(areNotificationsVisible).isTrue()
            }
        }

    @Test
    @EnableFlags(DualShade.FLAG_NAME)
    fun areNotificationsVisible_dualShadeWideOnNotificationsShade_false() =
        with(kosmos) {
            testScope.runTest {
                val areNotificationsVisible by
                    collectLastValue(underTest.areNotificationsVisible(Scenes.NotificationsShade))
                shadeRepository.setShadeLayoutWide(true)
                fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE)

                assertThat(areNotificationsVisible).isFalse()
            }
        }

    @Test
    @EnableFlags(DualShade.FLAG_NAME)
    fun areNotificationsVisible_dualShadeWideOnQuickSettingsShade_true() =
        with(kosmos) {
            testScope.runTest {
                val areNotificationsVisible by
                    collectLastValue(underTest.areNotificationsVisible(Scenes.QuickSettingsShade))
                val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible())
                shadeRepository.setShadeLayoutWide(true)
                fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE)

@@ -184,8 +154,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
    fun areNotificationsVisible_withSmallClock_true() =
        with(kosmos) {
            testScope.runTest {
                val areNotificationsVisible by
                    collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen))
                val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible())
                fakeKeyguardClockRepository.setClockSize(ClockSize.SMALL)
                assertThat(areNotificationsVisible).isTrue()
            }
@@ -196,8 +165,7 @@ class LockscreenContentViewModelTest(flags: FlagsParameterization) : SysuiTestCa
    fun areNotificationsVisible_withLargeClock_false() =
        with(kosmos) {
            testScope.runTest {
                val areNotificationsVisible by
                    collectLastValue(underTest.areNotificationsVisible(Scenes.Lockscreen))
                val areNotificationsVisible by collectLastValue(underTest.areNotificationsVisible())
                fakeKeyguardClockRepository.setClockSize(ClockSize.LARGE)
                assertThat(areNotificationsVisible).isFalse()
            }
+2 −14
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.keyguard.ui.viewmodel

import android.content.res.Resources
import com.android.compose.animation.scene.ContentKey
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.biometrics.AuthController
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
@@ -27,7 +26,6 @@ import com.android.systemui.keyguard.shared.model.ClockSize
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.unfold.domain.interactor.UnfoldTransitionInteractor
import dagger.assisted.AssistedFactory
@@ -42,7 +40,6 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
@@ -103,17 +100,8 @@ constructor(
        }
    }

    /**
     * Returns a flow that indicates whether lockscreen notifications should be rendered in the
     * given [contentKey].
     */
    fun areNotificationsVisible(contentKey: ContentKey): Flow<Boolean> {
        // `Scenes.NotificationsShade` renders its own separate notifications stack, so when it's
        // open we avoid rendering the lockscreen notifications stack.
        if (contentKey == Scenes.NotificationsShade) {
            return flowOf(false)
        }

    /** Returns a flow that indicates whether lockscreen notifications should be rendered. */
    fun areNotificationsVisible(): Flow<Boolean> {
        return combine(
            clockSize,
            shadeInteractor.isShadeLayoutWide,