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

Commit 68dc9455 authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge changes Ib5ce8e77,Iae383f7c into main

* changes:
  On fold/unfold, recalculate notif count immediately
  Apply shade state transition to OCCLUDED
parents 1cc44052 a314b132
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectValues
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
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.DOZING
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
@@ -37,6 +38,7 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import junit.framework.Assert.assertEquals
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Test
@@ -242,7 +244,8 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
    @Test
    fun transitionValue() =
        testScope.runTest {
            val startedSteps by collectValues(underTest.transitionValue(state = DOZING))
            resetTransitionValueReplayCache(setOf(AOD, DOZING, LOCKSCREEN))
            val transitionValues by collectValues(underTest.transitionValue(state = DOZING))

            val toSteps =
                listOf(
@@ -266,12 +269,14 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
                runCurrent()
            }

            assertThat(startedSteps).isEqualTo(listOf(0f, 0.5f, 1f, 1f, 0.5f, 0f))
            assertThat(transitionValues).isEqualTo(listOf(0f, 0.5f, 1f, 1f, 0.5f, 0f))
        }

    @Test
    fun transitionValue_canceled_toAnotherState() =
        testScope.runTest {
            resetTransitionValueReplayCache(setOf(AOD, GONE, LOCKSCREEN))

            val transitionValuesGone by collectValues(underTest.transitionValue(state = GONE))
            val transitionValuesAod by collectValues(underTest.transitionValue(state = AOD))
            val transitionValuesLs by collectValues(underTest.transitionValue(state = LOCKSCREEN))
@@ -297,6 +302,8 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
    @Test
    fun transitionValue_canceled_backToOriginalState() =
        testScope.runTest {
            resetTransitionValueReplayCache(setOf(AOD, GONE))

            val transitionValuesGone by collectValues(underTest.transitionValue(state = GONE))
            val transitionValuesAod by collectValues(underTest.transitionValue(state = AOD))

@@ -1395,4 +1402,8 @@ class KeyguardTransitionInteractorTest : SysuiTestCase() {
            testScope.runCurrent()
        }
    }

    private fun resetTransitionValueReplayCache(states: Set<KeyguardState>) {
        states.forEach { (underTest.transitionValue(it) as MutableSharedFlow).resetReplayCache() }
    }
}
+41 −0
Original line number Diff line number Diff line
@@ -585,6 +585,12 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            notificationCount = 25
            sharedNotificationContainerInteractor.notificationStackChanged()
            assertThat(maxNotifications).isEqualTo(25)

            // Also ensure another collection starts with the same value. As an example, folding
            // then unfolding will restart the coroutine and it must get the last value immediately.
            val newMaxNotifications by
                collectLastValue(underTest.getMaxNotifications(calculateSpace))
            assertThat(newMaxNotifications).isEqualTo(25)
        }

    @Test
@@ -759,6 +765,41 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    fun alphaDoesNotUpdateWhileOcclusionTransitionIsRunning() =
        testScope.runTest {
            val viewState = ViewStateAccessor()
            val alpha by collectLastValue(underTest.keyguardAlpha(viewState))

            showLockscreen()
            // OCCLUDED transition gets to 90% complete
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.OCCLUDED,
                    transitionState = TransitionState.STARTED,
                    value = 0f,
                )
            )
            runCurrent()
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.OCCLUDED,
                    transitionState = TransitionState.RUNNING,
                    value = 0.9f,
                )
            )
            runCurrent()

            // At this point, alpha should be zero
            assertThat(alpha).isEqualTo(0f)

            // An attempt to override by the shade should be ignored
            shadeRepository.setQsExpansion(0.5f)
            assertThat(alpha).isEqualTo(0f)
        }

    @Test
    fun alphaWhenGoneIsSetToOne() =
        testScope.runTest {
+1 −0
Original line number Diff line number Diff line
@@ -218,5 +218,6 @@ constructor(
        private val DEFAULT_DURATION = 500.milliseconds
        val TO_LOCKSCREEN_DURATION = 933.milliseconds
        val TO_AOD_DURATION = DEFAULT_DURATION
        val TO_DOZING_DURATION = DEFAULT_DURATION
    }
}
+5 −3
Original line number Diff line number Diff line
@@ -85,9 +85,11 @@ constructor(
    private fun getTransitionValueFlow(state: KeyguardState): MutableSharedFlow<Float> {
        return transitionValueCache.getOrPut(state) {
            MutableSharedFlow<Float>(
                    replay = 1,
                    extraBufferCapacity = 2,
                    onBufferOverflow = BufferOverflow.DROP_OLDEST
                )
                .also { it.tryEmit(0f) }
        }
    }

+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ constructor(
    private val lockscreenToPrimaryBouncerTransitionViewModel:
        LockscreenToPrimaryBouncerTransitionViewModel,
    private val occludedToAodTransitionViewModel: OccludedToAodTransitionViewModel,
    private val occludedToDozingTransitionViewModel: OccludedToDozingTransitionViewModel,
    private val occludedToLockscreenTransitionViewModel: OccludedToLockscreenTransitionViewModel,
    private val primaryBouncerToAodTransitionViewModel: PrimaryBouncerToAodTransitionViewModel,
    private val primaryBouncerToGoneTransitionViewModel: PrimaryBouncerToGoneTransitionViewModel,
@@ -228,6 +229,7 @@ constructor(
                        lockscreenToOccludedTransitionViewModel.lockscreenAlpha,
                        lockscreenToPrimaryBouncerTransitionViewModel.lockscreenAlpha,
                        occludedToAodTransitionViewModel.lockscreenAlpha,
                        occludedToDozingTransitionViewModel.lockscreenAlpha,
                        occludedToLockscreenTransitionViewModel.lockscreenAlpha,
                        primaryBouncerToAodTransitionViewModel.lockscreenAlpha,
                        primaryBouncerToGoneTransitionViewModel.lockscreenAlpha,
Loading