Merge "Transitions - Allow ->GONE to be canceled" into tm-qpr-dev
This commit is contained in:
@@ -31,8 +31,10 @@ import javax.inject.Inject
|
|||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@SysUISingleton
|
@SysUISingleton
|
||||||
@@ -87,6 +89,9 @@ constructor(
|
|||||||
private fun listenForDreamingToOccluded() {
|
private fun listenForDreamingToOccluded() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
keyguardInteractor.isDreaming
|
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(
|
.sample(
|
||||||
combine(
|
combine(
|
||||||
keyguardInteractor.isKeyguardOccluded,
|
keyguardInteractor.isKeyguardOccluded,
|
||||||
|
|||||||
@@ -50,10 +50,9 @@ constructor(
|
|||||||
private fun listenForGoneToDreaming() {
|
private fun listenForGoneToDreaming() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
keyguardInteractor.isAbleToDream
|
keyguardInteractor.isAbleToDream
|
||||||
.sample(keyguardTransitionInteractor.finishedKeyguardState, ::Pair)
|
.sample(keyguardTransitionInteractor.startedKeyguardTransitionStep, ::Pair)
|
||||||
.collect { pair ->
|
.collect { (isAbleToDream, lastStartedStep) ->
|
||||||
val (isAbleToDream, keyguardState) = pair
|
if (isAbleToDream && lastStartedStep.to == KeyguardState.GONE) {
|
||||||
if (isAbleToDream && keyguardState == KeyguardState.GONE) {
|
|
||||||
keyguardTransitionRepository.startTransition(
|
keyguardTransitionRepository.startTransition(
|
||||||
TransitionInfo(
|
TransitionInfo(
|
||||||
name,
|
name,
|
||||||
@@ -72,15 +71,15 @@ constructor(
|
|||||||
keyguardInteractor.wakefulnessModel
|
keyguardInteractor.wakefulnessModel
|
||||||
.sample(
|
.sample(
|
||||||
combine(
|
combine(
|
||||||
keyguardTransitionInteractor.finishedKeyguardState,
|
keyguardTransitionInteractor.startedKeyguardTransitionStep,
|
||||||
keyguardInteractor.isAodAvailable,
|
keyguardInteractor.isAodAvailable,
|
||||||
::Pair
|
::Pair
|
||||||
),
|
),
|
||||||
::toTriple
|
::toTriple
|
||||||
)
|
)
|
||||||
.collect { (wakefulnessState, keyguardState, isAodAvailable) ->
|
.collect { (wakefulnessState, lastStartedStep, isAodAvailable) ->
|
||||||
if (
|
if (
|
||||||
keyguardState == KeyguardState.GONE &&
|
lastStartedStep.to == KeyguardState.GONE &&
|
||||||
wakefulnessState.state == WakefulnessState.STARTING_TO_SLEEP
|
wakefulnessState.state == WakefulnessState.STARTING_TO_SLEEP
|
||||||
) {
|
) {
|
||||||
keyguardTransitionRepository.startTransition(
|
keyguardTransitionRepository.startTransition(
|
||||||
|
|||||||
Reference in New Issue
Block a user