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

Commit f886420c authored by Andreas Miko's avatar Andreas Miko Committed by Android (Google) Code Review
Browse files

Merge "Disable second lightreveal" into main

parents 89e9b557 c15a5cea
Loading
Loading
Loading
Loading
+19 −10
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.keyguard.data.repository

import android.graphics.Point
import android.os.PowerManager.WAKE_REASON_UNKNOWN
import android.testing.TestableLooper
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
@@ -26,8 +27,9 @@ import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
import com.android.systemui.keyguard.shared.model.BiometricUnlockSource
import com.android.systemui.kosmos.testScope
import com.android.systemui.power.domain.interactor.PowerInteractor.Companion.setAwakeForTest
import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.power.data.repository.powerRepository
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.power.shared.model.WakefulnessState
import com.android.systemui.statusbar.CircleReveal
import com.android.systemui.statusbar.LightRevealEffect
import com.android.systemui.testKosmos
@@ -51,7 +53,7 @@ class LightRevealScrimRepositoryTest : SysuiTestCase() {
    private val kosmos = testKosmos()
    private val testScope = kosmos.testScope
    private val fakeKeyguardRepository = kosmos.fakeKeyguardRepository
    private val powerInteractor = kosmos.powerInteractor
    private val powerRepository = kosmos.powerRepository
    private lateinit var underTest: LightRevealScrimRepositoryImpl

    @get:Rule val animatorTestRule = AnimatorTestRule(this)
@@ -63,7 +65,7 @@ class LightRevealScrimRepositoryTest : SysuiTestCase() {
            LightRevealScrimRepositoryImpl(
                kosmos.fakeKeyguardRepository,
                context,
                kosmos.powerInteractor,
                powerRepository,
                mock()
            )
    }
@@ -73,7 +75,14 @@ class LightRevealScrimRepositoryTest : SysuiTestCase() {
        val values = mutableListOf<LightRevealEffect>()
        val job = launch { underTest.revealEffect.collect { values.add(it) } }

        powerInteractor.setAwakeForTest()
        powerRepository.updateWakefulness(
            rawState = WakefulnessState.STARTING_TO_WAKE,
            lastWakeReason = WakeSleepReason.fromPowerManagerWakeReason(WAKE_REASON_UNKNOWN),
            powerButtonLaunchGestureTriggered =
                powerRepository.wakefulness.value.powerButtonLaunchGestureTriggered,
        )
        powerRepository.updateWakefulness(rawState = WakefulnessState.AWAKE)

        // We should initially emit the default reveal effect.
        runCurrent()
        values.assertEffectsMatchPredicates({ it == DEFAULT_REVEAL_EFFECT })
@@ -171,7 +180,7 @@ class LightRevealScrimRepositoryTest : SysuiTestCase() {
        testScope.runTest {
            val value by collectLastValue(underTest.revealAmount)
            runCurrent()
            underTest.startRevealAmountAnimator(true)
            underTest.startRevealAmountAnimator(true, 500L)
            assertEquals(0.0f, value)
            animatorTestRule.advanceTimeBy(500L)
            assertEquals(1.0f, value)
@@ -183,11 +192,11 @@ class LightRevealScrimRepositoryTest : SysuiTestCase() {
        testScope.runTest {
            val value by collectLastValue(underTest.revealAmount)
            runCurrent()
            underTest.startRevealAmountAnimator(true)
            underTest.startRevealAmountAnimator(true, 500L)
            assertEquals(0.0f, value)
            animatorTestRule.advanceTimeBy(250L)
            assertEquals(0.5f, value)
            underTest.startRevealAmountAnimator(true)
            underTest.startRevealAmountAnimator(true, 500L)
            animatorTestRule.advanceTimeBy(250L)
            assertEquals(1.0f, value)
        }
@@ -198,9 +207,9 @@ class LightRevealScrimRepositoryTest : SysuiTestCase() {
        testScope.runTest {
            val lastValue by collectLastValue(underTest.revealAmount)
            runCurrent()
            underTest.startRevealAmountAnimator(true)
            underTest.startRevealAmountAnimator(true, 500L)
            animatorTestRule.advanceTimeBy(500L)
            underTest.startRevealAmountAnimator(false)
            underTest.startRevealAmountAnimator(false, 500L)
            animatorTestRule.advanceTimeBy(500L)
            assertEquals(0.0f, lastValue)
        }
+0 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import com.android.systemui.keyguard.data.repository.FakeLightRevealScrimReposit
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
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.statusbar.LightRevealEffect
import com.android.systemui.statusbar.LightRevealScrim
import com.android.systemui.testKosmos
@@ -50,7 +49,6 @@ class LightRevealScrimInteractorTest : SysuiTestCase() {
    private val fakeLightRevealScrimRepository = kosmos.fakeLightRevealScrimRepository

    private val fakeKeyguardTransitionRepository = kosmos.fakeKeyguardTransitionRepository
    private val testScope = kosmos.testScope

    private val underTest = kosmos.lightRevealScrimInteractor

+13 −7
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.android.keyguard.logging.ScrimLogger
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
import com.android.systemui.keyguard.shared.model.BiometricUnlockSource
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.data.repository.PowerRepository
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.power.shared.model.WakeSleepReason.TAP
import com.android.systemui.res.R
@@ -47,6 +47,7 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map

val DEFAULT_REVEAL_EFFECT = LiftReveal
const val DEFAULT_REVEAL_DURATION = 500L

/**
 * Encapsulates state relevant to the light reveal scrim, the view used to reveal/hide screen
@@ -63,7 +64,9 @@ interface LightRevealScrimRepository {

    val revealAmount: Flow<Float>

    fun startRevealAmountAnimator(reveal: Boolean)
    val isAnimating: Boolean

    fun startRevealAmountAnimator(reveal: Boolean, duration: Long = DEFAULT_REVEAL_DURATION)
}

@SysUISingleton
@@ -72,7 +75,7 @@ class LightRevealScrimRepositoryImpl
constructor(
    keyguardRepository: KeyguardRepository,
    val context: Context,
    powerInteractor: PowerInteractor,
    powerRepository: PowerRepository,
    private val scrimLogger: ScrimLogger,
) : LightRevealScrimRepository {
    companion object {
@@ -125,7 +128,7 @@ constructor(

    /** The reveal effect we'll use for the next non-biometric unlock (tap, power button, etc). */
    private val nonBiometricRevealEffect: Flow<LightRevealEffect?> =
        powerInteractor.detailedWakefulness.flatMapLatest { wakefulnessModel ->
        powerRepository.wakefulness.flatMapLatest { wakefulnessModel ->
            when {
                wakefulnessModel.isAwakeOrAsleepFrom(WakeSleepReason.POWER_BUTTON) ->
                    powerButtonRevealEffect
@@ -134,7 +137,7 @@ constructor(
            }
        }

    private val revealAmountAnimator = ValueAnimator.ofFloat(0f, 1f).apply { duration = 500 }
    private val revealAmountAnimator = ValueAnimator.ofFloat(0f, 1f)

    override val revealAmount: Flow<Float> = callbackFlow {
        val updateListener =
@@ -149,18 +152,21 @@ constructor(
        revealAmountAnimator.addUpdateListener(updateListener)
        awaitClose { revealAmountAnimator.removeUpdateListener(updateListener) }
    }
    override val isAnimating: Boolean
        get() = revealAmountAnimator.isRunning

    private var willBeOrIsRevealed: Boolean? = null

    override fun startRevealAmountAnimator(reveal: Boolean) {
    override fun startRevealAmountAnimator(reveal: Boolean, duration: Long) {
        if (reveal == willBeOrIsRevealed) return
        willBeOrIsRevealed = reveal
        revealAmountAnimator.duration = duration
        if (reveal && !revealAmountAnimator.isRunning) {
            revealAmountAnimator.start()
        } else {
            revealAmountAnimator.reverse()
        }
        scrimLogger.d(TAG, "startRevealAmountAnimator, reveal: ", reveal)
        scrimLogger.d(TAG, "startRevealAmountAnimator, reveal", reveal)
    }

    override val revealEffect =
+25 −24
Original line number Diff line number Diff line
@@ -25,14 +25,13 @@ import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.power.shared.model.ScreenPowerState
import com.android.systemui.statusbar.LightRevealEffect
import com.android.systemui.util.kotlin.sample
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.launch

@ExperimentalCoroutinesApi
@SysUISingleton
class LightRevealScrimInteractor
@Inject
@@ -41,7 +40,7 @@ constructor(
    private val lightRevealScrimRepository: LightRevealScrimRepository,
    @Application private val scope: CoroutineScope,
    private val scrimLogger: ScrimLogger,
    private val powerInteractor: PowerInteractor,
    private val powerInteractor: Lazy<PowerInteractor>,
) {
    init {
        listenForStartedKeyguardTransitionStep()
@@ -81,10 +80,11 @@ constructor(
        }

    private fun screenIsShowingContent() =
        powerInteractor.screenPowerState.value != ScreenPowerState.SCREEN_OFF &&
            powerInteractor.screenPowerState.value != ScreenPowerState.SCREEN_TURNING_ON
        powerInteractor.get().screenPowerState.value != ScreenPowerState.SCREEN_OFF &&
            powerInteractor.get().screenPowerState.value != ScreenPowerState.SCREEN_TURNING_ON

    companion object {
    val isAnimating: Boolean
        get() = lightRevealScrimRepository.isAnimating

    /**
     * Whether the light reveal scrim will be fully revealed (revealAmount = 1.0f) in the given
@@ -106,6 +106,7 @@ constructor(
        }
    }

    companion object {
        val TAG = LightRevealScrimInteractor::class.simpleName!!
    }
}
+9 −3
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.statusbar.notification.PropertyAnimator
import com.android.systemui.statusbar.notification.stack.AnimationProperties
import com.android.systemui.statusbar.notification.stack.StackStateAnimator
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.Flags.lightRevealMigration
import com.android.app.tracing.namedRunnable
import com.android.systemui.util.settings.GlobalSettings
import javax.inject.Inject
@@ -45,7 +46,7 @@ private const val ANIMATE_IN_KEYGUARD_DELAY = 600L
/**
 * Duration for the light reveal portion of the animation.
 */
private const val LIGHT_REVEAL_ANIMATION_DURATION = 750L
private const val LIGHT_REVEAL_ANIMATION_DURATION = 500L

/**
 * Controller for the unlocked screen off animation, which runs when the device is going to sleep
@@ -66,7 +67,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
    private val notifShadeWindowControllerLazy: dagger.Lazy<NotificationShadeWindowController>,
    private val interactionJankMonitor: InteractionJankMonitor,
    private val powerManager: PowerManager,
    private val handler: Handler = Handler(),
    private val handler: Handler = Handler()
) : WakefulnessLifecycle.Observer, ScreenOffAnimation {
    private lateinit var centralSurfaces: CentralSurfaces
    private lateinit var shadeViewController: ShadeViewController
@@ -95,6 +96,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        duration = LIGHT_REVEAL_ANIMATION_DURATION
        interpolator = Interpolators.LINEAR
        addUpdateListener {
            if (lightRevealMigration()) return@addUpdateListener
            if (lightRevealScrim.revealEffect !is CircleReveal) {
                lightRevealScrim.revealAmount = it.animatedValue as Float
            }
@@ -107,6 +109,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
        }
        addListener(object : AnimatorListenerAdapter() {
            override fun onAnimationCancel(animation: Animator) {
                if (lightRevealMigration()) return
                if (lightRevealScrim.revealEffect !is CircleReveal) {
                    lightRevealScrim.revealAmount = 1f
                }
@@ -371,7 +374,7 @@ class UnlockedScreenOffAnimationController @Inject constructor(
     * AOD UI.
     */
    override fun isAnimationPlaying(): Boolean {
        return lightRevealAnimationPlaying || aodUiAnimationPlaying
        return isScreenOffLightRevealAnimationPlaying() || aodUiAnimationPlaying
    }

    override fun shouldAnimateInKeyguard(): Boolean =
@@ -395,6 +398,9 @@ class UnlockedScreenOffAnimationController @Inject constructor(
    /**
     * Whether the light reveal animation is playing. The second part of the screen off animation,
     * where AOD animates in, might still be playing if this returns false.
     *
     * Note: This only refers to the specific light reveal animation that is playing during lock
     * therefore LightRevealScrimInteractor.isAnimating is not the desired response.
     */
    fun isScreenOffLightRevealAnimationPlaying(): Boolean {
        return lightRevealAnimationPlaying
Loading