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

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

Merge "Use only one BurnInParameters for AoD Burn in" into main

parents 10bb656d ccd9ec45
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -42,8 +42,9 @@ fun Modifier.burnInAware(
    isClock: Boolean = false,
): Modifier {
    val translationYState = remember { mutableStateOf(0F) }
    val copiedParams = params.copy(translationY = { translationYState.value })
    val burnIn = viewModel.movement(copiedParams)
    viewModel.updateBurnInParams(params.copy(translationY = { translationYState.value }))

    val burnIn = viewModel.movement
    val translationX by
        burnIn.map { it.translationX.toFloat() }.collectAsStateWithLifecycle(initialValue = 0f)
    val translationY by
@@ -51,12 +52,7 @@ fun Modifier.burnInAware(
    translationYState.value = translationY
    val scaleViewModel by
        burnIn
            .map {
                BurnInScaleViewModel(
                    scale = it.scale,
                    scaleClockOnly = it.scaleClockOnly,
                )
            }
            .map { BurnInScaleViewModel(scale = it.scale, scaleClockOnly = it.scaleClockOnly) }
            .collectAsStateWithLifecycle(initialValue = BurnInScaleViewModel())

    return this.graphicsLayer {
@@ -72,8 +68,6 @@ fun Modifier.burnInAware(

/** Reports the "top" coordinate of the modified composable to the given [consumer]. */
@Composable
fun Modifier.onTopPlacementChanged(
    consumer: (Float) -> Unit,
): Modifier {
fun Modifier.onTopPlacementChanged(consumer: (Float) -> Unit): Modifier {
    return onPlaced { coordinates -> consumer(coordinates.boundsInWindow().top) }
}
+11 −10
Original line number Diff line number Diff line
@@ -91,12 +91,13 @@ class AodBurnInViewModelTest : SysuiTestCase() {
        kosmos.fakeKeyguardClockRepository.setCurrentClock(clockController)

        underTest = kosmos.aodBurnInViewModel
        underTest.updateBurnInParams(burnInParameters)
    }

    @Test
    fun movement_initializedToDefaultValues() =
        testScope.runTest {
            val movement by collectLastValue(underTest.movement(burnInParameters))
            val movement by collectLastValue(underTest.movement)
            assertThat(movement?.translationY).isEqualTo(0)
            assertThat(movement?.translationX).isEqualTo(0)
            assertThat(movement?.scale).isEqualTo(1f)
@@ -105,7 +106,7 @@ class AodBurnInViewModelTest : SysuiTestCase() {
    @Test
    fun translationAndScale_whenNotDozing() =
        testScope.runTest {
            val movement by collectLastValue(underTest.movement(burnInParameters))
            val movement by collectLastValue(underTest.movement)

            // Set to not dozing (on lockscreen)
            keyguardTransitionRepository.sendTransitionStep(
@@ -130,8 +131,8 @@ class AodBurnInViewModelTest : SysuiTestCase() {
    @Test
    fun translationAndScale_whenFullyDozing() =
        testScope.runTest {
            burnInParameters = burnInParameters.copy(minViewY = 100)
            val movement by collectLastValue(underTest.movement(burnInParameters))
            underTest.updateBurnInParams(burnInParameters.copy(minViewY = 100))
            val movement by collectLastValue(underTest.movement)

            // Set to dozing (on AOD)
            keyguardTransitionRepository.sendTransitionStep(
@@ -171,8 +172,8 @@ class AodBurnInViewModelTest : SysuiTestCase() {
    @DisableFlags(AConfigFlags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
    fun translationAndScale_whenFullyDozing_MigrationFlagOff_staysOutOfTopInset() =
        testScope.runTest {
            burnInParameters = burnInParameters.copy(minViewY = 100, topInset = 80)
            val movement by collectLastValue(underTest.movement(burnInParameters))
            underTest.updateBurnInParams(burnInParameters.copy(minViewY = 100, topInset = 80))
            val movement by collectLastValue(underTest.movement)

            // Set to dozing (on AOD)
            keyguardTransitionRepository.sendTransitionStep(
@@ -213,8 +214,8 @@ class AodBurnInViewModelTest : SysuiTestCase() {
    @EnableFlags(AConfigFlags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)
    fun translationAndScale_whenFullyDozing_MigrationFlagOn_staysOutOfTopInset() =
        testScope.runTest {
            burnInParameters = burnInParameters.copy(minViewY = 100, topInset = 80)
            val movement by collectLastValue(underTest.movement(burnInParameters))
            underTest.updateBurnInParams(burnInParameters.copy(minViewY = 100, topInset = 80))
            val movement by collectLastValue(underTest.movement)

            // Set to dozing (on AOD)
            keyguardTransitionRepository.sendTransitionStep(
@@ -256,7 +257,7 @@ class AodBurnInViewModelTest : SysuiTestCase() {
        testScope.runTest {
            whenever(clockController.config.useAlternateSmartspaceAODTransition).thenReturn(true)

            val movement by collectLastValue(underTest.movement(burnInParameters))
            val movement by collectLastValue(underTest.movement)

            // Set to dozing (on AOD)
            keyguardTransitionRepository.sendTransitionStep(
@@ -374,7 +375,7 @@ class AodBurnInViewModelTest : SysuiTestCase() {
            whenever(clockController.config.useAlternateSmartspaceAODTransition)
                .thenReturn(if (isWeatherClock) true else false)

            val movement by collectLastValue(underTest.movement(burnInParameters))
            val movement by collectLastValue(underTest.movement)

            // Set to dozing (on AOD)
            keyguardTransitionRepository.sendTransitionStep(
+4 −6
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel
import com.android.systemui.keyguard.ui.viewmodel.BurnInParameters
import com.android.systemui.keyguard.ui.viewmodel.ViewStateAccessor
import com.android.systemui.keyguard.ui.viewmodel.aodBurnInViewModel
import com.android.systemui.keyguard.ui.viewmodel.keyguardRootViewModel
@@ -70,7 +69,6 @@ import com.android.systemui.shade.mockLargeScreenHeaderHelper
import com.android.systemui.shade.shadeTestUtil
import com.android.systemui.statusbar.notification.stack.domain.interactor.sharedNotificationContainerInteractor
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.any
import com.google.common.collect.Range
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -155,7 +153,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
    fun setUp() {
        shadeTestUtil.setSplitShade(false)
        movementFlow = MutableStateFlow(BurnInModel())
        whenever(aodBurnInViewModel.movement(any())).thenReturn(movementFlow)
        whenever(aodBurnInViewModel.movement).thenReturn(movementFlow)
        underTest = kosmos.sharedNotificationContainerViewModel
    }

@@ -810,7 +808,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
    @DisableSceneContainer
    fun translationYUpdatesOnKeyguardForBurnIn() =
        testScope.runTest {
            val translationY by collectLastValue(underTest.translationY(BurnInParameters()))
            val translationY by collectLastValue(underTest.translationY)

            showLockscreen()
            assertThat(translationY).isEqualTo(0)
@@ -823,7 +821,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
    @DisableSceneContainer
    fun translationYUpdatesOnKeyguard() =
        testScope.runTest {
            val translationY by collectLastValue(underTest.translationY(BurnInParameters()))
            val translationY by collectLastValue(underTest.translationY)

            configurationRepository.setDimensionPixelSize(
                R.dimen.keyguard_translate_distance_on_swipe_up,
@@ -844,7 +842,7 @@ class SharedNotificationContainerViewModelTest(flags: FlagsParameterization) : S
    @DisableSceneContainer
    fun translationYDoesNotUpdateWhenShadeIsExpanded() =
        testScope.runTest {
            val translationY by collectLastValue(underTest.translationY(BurnInParameters()))
            val translationY by collectLastValue(underTest.translationY)

            configurationRepository.setDimensionPixelSize(
                R.dimen.keyguard_translate_distance_on_swipe_up,
+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.keyguard.domain.interactor
import com.android.keyguard.logging.KeyguardLogger
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.log.core.LogLevel.VERBOSE
import com.android.systemui.power.domain.interactor.PowerInteractor
@@ -44,6 +45,7 @@ constructor(
    private val powerInteractor: PowerInteractor,
    private val sharedNotificationContainerViewModel: SharedNotificationContainerViewModel,
    private val keyguardRootViewModel: KeyguardRootViewModel,
    private val aodBurnInViewModel: AodBurnInViewModel,
    private val shadeInteractor: ShadeInteractor,
    private val keyguardOcclusionInteractor: KeyguardOcclusionInteractor,
) {
@@ -132,7 +134,7 @@ constructor(
        }

        scope.launch {
            keyguardRootViewModel.burnInModel.debounce(20L).collect {
            aodBurnInViewModel.movement.debounce(20L).collect {
                logger.log(TAG, VERBOSE, "BurnInModel (debounced)", it)
            }
        }
+8 −9
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.shared.model.ClockSize
import com.android.systemui.keyguard.ui.view.layout.blueprints.transitions.IntraBlueprintTransition.Type
import com.android.systemui.keyguard.ui.view.layout.sections.ClockSection
import com.android.systemui.keyguard.ui.viewmodel.AodBurnInViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardClockViewModel
import com.android.systemui.keyguard.ui.viewmodel.KeyguardRootViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
@@ -58,6 +59,7 @@ object KeyguardClockViewBinder {
        keyguardClockInteractor: KeyguardClockInteractor,
        blueprintInteractor: KeyguardBlueprintInteractor,
        rootViewModel: KeyguardRootViewModel,
        aodBurnInViewModel: AodBurnInViewModel,
    ): DisposableHandle {
        val disposables = DisposableHandles()
        disposables +=
@@ -78,7 +80,7 @@ object KeyguardClockViewBinder {
                            updateBurnInLayer(
                                keyguardRootView,
                                viewModel,
                                viewModel.clockSize.value
                                viewModel.clockSize.value,
                            )
                            applyConstraints(clockSection, keyguardRootView, true)
                        }
@@ -114,7 +116,7 @@ object KeyguardClockViewBinder {
                        if (!MigrateClocksToBlueprint.isEnabled) return@launch
                        combine(
                                viewModel.hasAodIcons,
                                rootViewModel.isNotifIconContainerVisible.map { it.value }
                                rootViewModel.isNotifIconContainerVisible.map { it.value },
                            ) { hasIcon, isVisible ->
                                hasIcon && isVisible
                            }
@@ -130,13 +132,13 @@ object KeyguardClockViewBinder {

                    launch {
                        if (!MigrateClocksToBlueprint.isEnabled) return@launch
                        rootViewModel.burnInModel.collect { burnInModel ->
                        aodBurnInViewModel.movement.collect { burnInModel ->
                            viewModel.currentClock.value?.let {
                                it.largeClock.layout.applyAodBurnIn(
                                    AodClockBurnInModel(
                                        translationX = burnInModel.translationX.toFloat(),
                                        translationY = burnInModel.translationY.toFloat(),
                                        scale = burnInModel.scale
                                        scale = burnInModel.scale,
                                    )
                                )
                            }
@@ -175,7 +177,7 @@ object KeyguardClockViewBinder {
    private fun cleanupClockViews(
        currentClock: ClockController?,
        rootView: ConstraintLayout,
        burnInLayer: Layer?
        burnInLayer: Layer?,
    ) {
        if (lastClock == currentClock) {
            return
@@ -192,10 +194,7 @@ object KeyguardClockViewBinder {
    }

    @VisibleForTesting
    fun addClockViews(
        clockController: ClockController?,
        rootView: ConstraintLayout,
    ) {
    fun addClockViews(clockController: ClockController?, rootView: ConstraintLayout) {
        // We'll collect the same clock when exiting wallpaper picker without changing clock
        // so we need to remove clock views from parent before addView again
        clockController?.let { clock ->
Loading