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

Commit 40ee53ed authored by Matt Pietal's avatar Matt Pietal
Browse files

Fix oscillating DREAMING states

Remove the delay, and use a debounce instead, which
will prevent oscillating dream values from emitting.

Fixes: 338634549
Test: atest KeyguardInteractorTest
Test: manual - follow repro steps in bug and test all
DREAMING cases
Flag: None

Change-Id: I9188d9f36c364926ce3b77f2b5eba9f3093e46df
parent 6195149f
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ import javax.inject.Provider
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
@@ -63,10 +62,10 @@ import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.combineTransform
import kotlinx.coroutines.flow.debounce
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
@@ -179,12 +178,7 @@ constructor(
                isDreaming && isDozeOff(dozeTransitionModel.to)
            }
            .sample(powerInteractor.isAwake) { isAbleToDream, isAwake -> isAbleToDream && isAwake }
            .flatMapLatest { isAbleToDream ->
                flow {
                    delay(50)
                    emit(isAbleToDream)
                }
            }
            .debounce(50L)
            .distinctUntilChanged()

    /** Whether the keyguard is showing or not. */