Merge "Transitions - Allow ->GONE to be canceled" into tm-qpr-dev am: 74fb070d3b
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20965244 Change-Id: I163e6f390295cafe52337f2db7e92c3ecbd37ffe Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -31,8 +31,10 @@ import javax.inject.Inject
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@SysUISingleton
|
||||
@@ -87,6 +89,9 @@ constructor(
|
||||
private fun listenForDreamingToOccluded() {
|
||||
scope.launch {
|
||||
keyguardInteractor.isDreaming
|
||||
// Add a slight delay, as dreaming and occluded events will arrive with a small gap
|
||||
// in time. This prevents a transition to OCCLUSION happening prematurely.
|
||||
.onEach { delay(50) }
|
||||
.sample(
|
||||
combine(
|
||||
keyguardInteractor.isKeyguardOccluded,
|
||||
|
||||
@@ -50,10 +50,9 @@ constructor(
|
||||
private fun listenForGoneToDreaming() {
|
||||
scope.launch {
|
||||
keyguardInteractor.isAbleToDream
|
||||
.sample(keyguardTransitionInteractor.finishedKeyguardState, ::Pair)
|
||||
.collect { pair ->
|
||||
val (isAbleToDream, keyguardState) = pair
|
||||
if (isAbleToDream && keyguardState == KeyguardState.GONE) {
|
||||
.sample(keyguardTransitionInteractor.startedKeyguardTransitionStep, ::Pair)
|
||||
.collect { (isAbleToDream, lastStartedStep) ->
|
||||
if (isAbleToDream && lastStartedStep.to == KeyguardState.GONE) {
|
||||
keyguardTransitionRepository.startTransition(
|
||||
TransitionInfo(
|
||||
name,
|
||||
@@ -72,15 +71,15 @@ constructor(
|
||||
keyguardInteractor.wakefulnessModel
|
||||
.sample(
|
||||
combine(
|
||||
keyguardTransitionInteractor.finishedKeyguardState,
|
||||
keyguardTransitionInteractor.startedKeyguardTransitionStep,
|
||||
keyguardInteractor.isAodAvailable,
|
||||
::Pair
|
||||
),
|
||||
::toTriple
|
||||
)
|
||||
.collect { (wakefulnessState, keyguardState, isAodAvailable) ->
|
||||
.collect { (wakefulnessState, lastStartedStep, isAodAvailable) ->
|
||||
if (
|
||||
keyguardState == KeyguardState.GONE &&
|
||||
lastStartedStep.to == KeyguardState.GONE &&
|
||||
wakefulnessState.state == WakefulnessState.STARTING_TO_SLEEP
|
||||
) {
|
||||
keyguardTransitionRepository.startTransition(
|
||||
|
||||
Reference in New Issue
Block a user