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

Commit 95a14eec authored by Beverly's avatar Beverly
Browse files

Make device entry icon alpha a SharedFlow (hot flow)

Previously, it was possible for the device entry icon
to receive old alpha values from a cancelled transition.
For example: LOCKSCREEN => AOD => LOCKSCREEN

Test: enable aod, press power key to screen off/on
multiple times. observe device entry icon is the right alpha
Fixes: 329386658
Flag: ACONFIG com.android.systemui.device_entry_udfps_refactor TEAMFOOD

Change-Id: I2c8b1dfd1619a043c1689f07decddf9c9e96d58c
parent 7e37a4b0
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.keyguard.ui.viewmodel
import android.animation.FloatEvaluator
import android.animation.IntEvaluator
import com.android.keyguard.KeyguardViewController
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.deviceentry.domain.interactor.DeviceEntrySourceInteractor
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryUdfpsInteractor
@@ -33,9 +34,11 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor
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.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
@@ -45,6 +48,7 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.shareIn

/** Models the UI state for the containing device entry icon & long-press handling view. */
@ExperimentalCoroutinesApi
@@ -62,6 +66,7 @@ constructor(
    private val keyguardViewController: Lazy<KeyguardViewController>,
    private val deviceEntryInteractor: DeviceEntryInteractor,
    private val deviceEntrySourceInteractor: DeviceEntrySourceInteractor,
    @Application private val scope: CoroutineScope,
) {
    val isUdfpsSupported: StateFlow<Boolean> = deviceEntryUdfpsInteractor.isUdfpsSupported
    private val intEvaluator = IntEvaluator()
@@ -73,7 +78,10 @@ constructor(
    private val qsProgress: Flow<Float> = shadeInteractor.qsExpansion.onStart { emit(0f) }
    private val shadeExpansion: Flow<Float> = shadeInteractor.shadeExpansion.onStart { emit(0f) }
    private val transitionAlpha: Flow<Float> =
        transitions.map { it.deviceEntryParentViewAlpha }.merge()
        transitions
            .map { it.deviceEntryParentViewAlpha }
            .merge()
            .shareIn(scope, SharingStarted.WhileSubscribed())
    private val alphaMultiplierFromShadeExpansion: Flow<Float> =
        combine(
            showingAlternateBouncer,
+2 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInterac
import com.android.systemui.keyguard.ui.transitions.DeviceEntryIconTransition
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.shared.flag.sceneContainerFlags
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.statusbar.phone.statusBarKeyguardViewManager
@@ -50,5 +51,6 @@ val Kosmos.deviceEntryIconViewModel by Fixture {
        keyguardViewController = { statusBarKeyguardViewManager },
        deviceEntryInteractor = deviceEntryInteractor,
        deviceEntrySourceInteractor = deviceEntrySourceInteractor,
        scope = testScope.backgroundScope,
    )
}