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

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

Merge changes Id81c1b66,I87eb6cf2 into main

* changes:
  Smooth out tap-to-expand notification
  Ensure burn-in doesn't impede insets
parents e1ad5378 ffad99f0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ private fun rememberBurnInParameters(
        BurnInParameters(
            clockControllerProvider = { clock },
            topInset = topInset,
            statusViewTop = topmostTop,
            minViewY = topmostTop,
        )
    }
}
+69 −3
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ class AodBurnInViewModelTest : SysuiTestCase() {
    @Test
    fun translationAndScale_whenFullyDozing() =
        testScope.runTest {
            burnInParameters = burnInParameters.copy(statusViewTop = 100)
            burnInParameters = burnInParameters.copy(minViewY = 100)
            val translationX by collectLastValue(underTest.translationX(burnInParameters))
            val translationY by collectLastValue(underTest.translationY(burnInParameters))
            val scale by collectLastValue(underTest.scale(burnInParameters))
@@ -182,11 +182,77 @@ class AodBurnInViewModelTest : SysuiTestCase() {
        }

    @Test
    fun translationAndScale_whenFullyDozing_staysOutOfTopInset() =
    fun translationAndScale_whenFullyDozing_MigrationFlagOff_staysOutOfTopInset() =
        testScope.runTest {
            mSetFlagsRule.disableFlags(AConfigFlags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)

            burnInParameters =
                burnInParameters.copy(
                    minViewY = 100,
                    topInset = 80,
                )
            val translationX by collectLastValue(underTest.translationX(burnInParameters))
            val translationY by collectLastValue(underTest.translationY(burnInParameters))
            val scale by collectLastValue(underTest.scale(burnInParameters))

            // Set to dozing (on AOD)
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.GONE,
                    to = KeyguardState.AOD,
                    value = 1f,
                    transitionState = TransitionState.FINISHED
                ),
                validateStep = false,
            )

            // Trigger a change to the burn-in model
            burnInFlow.value =
                BurnInModel(
                    translationX = 20,
                    translationY = -30,
                    scale = 0.5f,
                )
            assertThat(translationX).isEqualTo(20)
            // -20 instead of -30, due to inset of 80
            assertThat(translationY).isEqualTo(-20)
            assertThat(scale)
                .isEqualTo(
                    BurnInScaleViewModel(
                        scale = 0.5f,
                        scaleClockOnly = true,
                    )
                )

            // Set to the beginning of GONE->AOD transition
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(
                    from = KeyguardState.GONE,
                    to = KeyguardState.AOD,
                    value = 0f,
                    transitionState = TransitionState.STARTED
                ),
                validateStep = false,
            )
            assertThat(translationX).isEqualTo(0)
            assertThat(translationY).isEqualTo(0)
            assertThat(scale)
                .isEqualTo(
                    BurnInScaleViewModel(
                        scale = 1f,
                        scaleClockOnly = true,
                    )
                )
        }

    @Test
    fun translationAndScale_whenFullyDozing_MigrationFlagOn_staysOutOfTopInset() =
        testScope.runTest {
            mSetFlagsRule.enableFlags(AConfigFlags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT)

            burnInParameters =
                burnInParameters.copy(
                    statusViewTop = 100,
                    minViewY = 100,
                    topInset = 80,
                )
            val translationX by collectLastValue(underTest.translationX(burnInParameters))
+34 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ 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.kosmos.testScope
import com.android.systemui.shade.data.repository.fakeShadeRepository
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -42,6 +43,7 @@ class AodToLockscreenTransitionViewModelTest : SysuiTestCase() {
    val kosmos = testKosmos()
    val testScope = kosmos.testScope
    val repository = kosmos.fakeKeyguardTransitionRepository
    val shadeRepository = kosmos.fakeShadeRepository
    val fingerprintPropertyRepository = kosmos.fingerprintPropertyRepository
    val underTest = kosmos.aodToLockscreenTransitionViewModel

@@ -58,6 +60,38 @@ class AodToLockscreenTransitionViewModelTest : SysuiTestCase() {
            deviceEntryParentViewAlpha.forEach { assertThat(it).isEqualTo(1f) }
        }

    @Test
    fun notificationAlpha_whenShadeIsExpanded_equalsOne() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.notificationAlpha)

            shadeRepository.setQsExpansion(0.5f)
            runCurrent()

            repository.sendTransitionStep(step(0f, TransitionState.STARTED))
            assertThat(alpha).isEqualTo(1f)
            repository.sendTransitionStep(step(0.5f))
            assertThat(alpha).isEqualTo(1f)
            repository.sendTransitionStep(step(1f))
            assertThat(alpha).isEqualTo(1f)
        }

    @Test
    fun notificationAlpha_whenShadeIsNotExpanded_usesTransitionValue() =
        testScope.runTest {
            val alpha by collectLastValue(underTest.notificationAlpha)

            shadeRepository.setQsExpansion(0f)
            runCurrent()

            repository.sendTransitionStep(step(0f, TransitionState.STARTED))
            assertThat(alpha).isEqualTo(0f)
            repository.sendTransitionStep(step(0.5f))
            assertThat(alpha).isEqualTo(0.5f)
            repository.sendTransitionStep(step(1f))
            assertThat(alpha).isEqualTo(1f)
        }

    @Test
    fun lockscreenAlphaStartsFromViewStateAccessorAlpha() =
        testScope.runTest {
+1 −1
Original line number Diff line number Diff line
@@ -681,7 +681,7 @@ class SharedNotificationContainerViewModelTest : SysuiTestCase() {
    @Test
    fun shadeCollapseFadeIn() =
        testScope.runTest {
            val fadeIn by collectLastValue(underTest.shadeCollpaseFadeIn)
            val fadeIn by collectLastValue(underTest.shadeCollapseFadeIn)

            // Start on lockscreen without the shade
            underTest.setShadeCollapseFadeInComplete(false)
+31 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.Rect
import android.view.HapticFeedbackConstants
import android.view.View
import android.view.View.OnLayoutChangeListener
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.view.ViewGroup.OnHierarchyChangeListener
import android.view.ViewPropertyAnimator
@@ -66,6 +67,7 @@ import com.android.systemui.util.ui.isAnimating
import com.android.systemui.util.ui.stopAnimating
import com.android.systemui.util.ui.value
import javax.inject.Provider
import kotlin.math.min
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.coroutineScope
@@ -345,7 +347,7 @@ object KeyguardRootViewBinder {
            }
        }

        onLayoutChangeListener = OnLayoutChange(viewModel, burnInParams)
        onLayoutChangeListener = OnLayoutChange(viewModel, childViews, burnInParams)
        view.addOnLayoutChangeListener(onLayoutChangeListener)

        // Views will be added or removed after the call to bind(). This is needed to avoid many
@@ -405,6 +407,7 @@ object KeyguardRootViewBinder {

    private class OnLayoutChange(
        private val viewModel: KeyguardRootViewModel,
        private val childViews: Map<Int, View>,
        private val burnInParams: MutableStateFlow<BurnInParameters>,
    ) : OnLayoutChangeListener {
        override fun onLayoutChange(
@@ -418,7 +421,7 @@ object KeyguardRootViewBinder {
            oldRight: Int,
            oldBottom: Int
        ) {
            view.findViewById<View>(R.id.nssl_placeholder)?.let { notificationListPlaceholder ->
            childViews[R.id.nssl_placeholder]?.let { notificationListPlaceholder ->
                // After layout, ensure the notifications are positioned correctly
                viewModel.onNotificationContainerBoundsChanged(
                    notificationListPlaceholder.top.toFloat(),
@@ -426,9 +429,33 @@ object KeyguardRootViewBinder {
                )
            }

            view.findViewById<View>(R.id.keyguard_status_view)?.let { statusView ->
                burnInParams.update { current -> current.copy(statusViewTop = statusView.top) }
            burnInParams.update { current ->
                current.copy(
                    minViewY =
                        if (migrateClocksToBlueprint()) {
                            // To ensure burn-in doesn't enroach the top inset, get the min top Y
                            childViews.entries.fold(Int.MAX_VALUE) { currentMin, (viewId, view) ->
                                min(
                                    currentMin,
                                    if (!isUserVisible(view)) {
                                        Int.MAX_VALUE
                                    } else {
                                        view.getTop()
                                    }
                                )
                            }
                        } else {
                            childViews[R.id.keyguard_status_view]?.top ?: 0
                        }
                )
            }
        }

        private fun isUserVisible(view: View): Boolean {
            return view.id != R.id.burn_in_layer &&
                view.visibility == VISIBLE &&
                view.width > 0 &&
                view.height > 0
        }
    }

Loading