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

Commit b9b9fce5 authored by Manali Bhutiyani's avatar Manali Bhutiyani Committed by Android (Google) Code Review
Browse files

Merge "[MinMode] Change (un)lock transition for MinMode" into main

parents a9b4978d 7635cb10
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.keyguard.data.fakeLightRevealScrimRepository
import com.android.systemui.keyguard.data.repository.DEFAULT_REVEAL_DURATION
import com.android.systemui.keyguard.data.repository.MINMODE_REVEAL_DURATION
import com.android.systemui.keyguard.data.repository.DEFAULT_REVEAL_EFFECT
import com.android.systemui.keyguard.data.repository.FakeLightRevealScrimRepository
import com.android.systemui.keyguard.data.repository.FakeLightRevealScrimRepository.RevealAnimatorRequest
@@ -30,6 +31,7 @@ import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepos
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.minmode.fakeMinModeManager
import com.android.systemui.kosmos.testScope
import com.android.systemui.power.data.repository.fakePowerRepository
import com.android.systemui.power.shared.model.WakeSleepReason
@@ -45,6 +47,7 @@ import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito
@@ -63,6 +66,8 @@ class LightRevealScrimInteractorTest : SysuiTestCase() {

    private val fakePowerRepository = kosmos.fakePowerRepository

    private val fakeMinModeManager = kosmos.fakeMinModeManager

    private val underTest = kosmos.lightRevealScrimInteractor

    private val reveal1 =
@@ -75,6 +80,11 @@ class LightRevealScrimInteractorTest : SysuiTestCase() {
            override fun setRevealAmountOnScrim(amount: Float, scrim: LightRevealScrim) {}
        }

    @Before
    fun setup() {
        fakeMinModeManager.setMinModeEnabled(false)
    }

    @Test
    fun lightRevealEffect_doesNotChangeDuringKeyguardTransition() =
        kosmos.testScope.runTest {
@@ -153,6 +163,25 @@ class LightRevealScrimInteractorTest : SysuiTestCase() {
                )
        }

    @Test
    fun transitionToAod_powerButton_minModeEnabled_animatesTheScrim() =
        kosmos.testScope.runTest {
            fakeMinModeManager.setMinModeEnabled(true)
            updateWakefulness(goToSleepReason = WakeSleepReason.POWER_BUTTON)
            runCurrent()

            // Transition to AOD
            fakeKeyguardTransitionRepository.sendTransitionStep(
                TransitionStep(to = KeyguardState.AOD, transitionState = TransitionState.STARTED)
            )
            runCurrent()

            assertThat(fakeLightRevealScrimRepository.revealAnimatorRequests.last())
                .isEqualTo(
                    RevealAnimatorRequest(reveal = false, duration = MINMODE_REVEAL_DURATION)
                )
        }

    @Test
    fun maxAlpha_doesNotSupportAmbientMode() =
        kosmos.testScope.runTest {
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ import kotlinx.coroutines.flow.stateIn

val DEFAULT_REVEAL_EFFECT = LiftReveal
const val DEFAULT_REVEAL_DURATION = 500L
const val MINMODE_REVEAL_DURATION = 100L

/**
 * Encapsulates state relevant to the light reveal scrim, the view used to reveal/hide screen
+8 −0
Original line number Diff line number Diff line
@@ -21,9 +21,11 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.keyguard.data.repository.DEFAULT_REVEAL_DURATION
import com.android.systemui.keyguard.data.repository.MINMODE_REVEAL_DURATION
import com.android.systemui.keyguard.data.repository.LightRevealScrimRepository
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.minmode.MinModeManager
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.shared.model.ScreenPowerState
import com.android.systemui.power.shared.model.WakeSleepReason
@@ -32,6 +34,7 @@ import com.android.systemui.statusbar.LightRevealEffect
import com.android.systemui.util.kotlin.BooleanFlowOperators.anyOf
import com.android.systemui.util.kotlin.sample
import dagger.Lazy
import java.util.Optional
import javax.inject.Inject
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
@@ -52,7 +55,10 @@ constructor(
    private val scrimLogger: ScrimLogger,
    private val powerInteractor: Lazy<PowerInteractor>,
    @Background backgroundDispatcher: CoroutineDispatcher,
    private val minModeManagerOptional: Optional<MinModeManager>,
) {
    private val minModeManager = minModeManagerOptional.orElse(null)

    init {
        listenForStartedKeyguardTransitionStep()
    }
@@ -68,6 +74,8 @@ constructor(
                        // This is needed to play the fold to AOD animation which starts with
                        // fully black screen (see FoldAodAnimationController)
                        0L
                    } else if (minModeManager?.isMinModeEnabled() == true) {
                        MINMODE_REVEAL_DURATION
                    } else {
                        DEFAULT_REVEAL_DURATION
                    }
+3 −0
Original line number Diff line number Diff line
@@ -20,8 +20,10 @@ import com.android.keyguard.logging.scrimLogger
import com.android.systemui.keyguard.data.lightRevealScrimRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.minmode.fakeMinModeManager
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.power.domain.interactor.powerInteractor
import java.util.Optional

val Kosmos.lightRevealScrimInteractor by
    Kosmos.Fixture {
@@ -32,5 +34,6 @@ val Kosmos.lightRevealScrimInteractor by
            scrimLogger,
            { powerInteractor },
            backgroundDispatcher = testDispatcher,
            Optional.of(fakeMinModeManager),
        )
    }
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import com.android.systemui.keyguard.domain.interactor.pulseExpansionInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.minModeManager
import com.android.systemui.minmode.minModeManager
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.ui.viewmodel.notificationShadeWindowModel
import com.android.systemui.statusbar.notification.icon.ui.viewmodel.notificationIconContainerAlwaysOnDisplayViewModel
Loading