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

Commit 8ff37389 authored by Matt Pietal's avatar Matt Pietal
Browse files

Code review feedback

Minor improvements to clean up some code

Bug: 331748021
Test: atest SystemUITests
Flag: N/A
Change-Id: Ie846d6104e4ef303f655dbc147814ae529b4d0ac
parent 6e4d1c48
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -296,7 +296,7 @@ constructor(

    private fun listenForSchedulingWatchdog() {
        keyguardTransitionInteractor
            .transition(from = null, to = KeyguardState.GONE)
            .transition(to = KeyguardState.GONE)
            .filter { it.transitionState == TransitionState.FINISHED }
            .onEach {
                // We deliberately want to run this in background because scheduleWatchdog does
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ constructor(
            .distinctUntilChanged()

    val transitionEnded =
        keyguardTransitionInteractor.transition(from = DREAMING, to = null).filter { step ->
        keyguardTransitionInteractor.transition(from = DREAMING).filter { step ->
            step.transitionState == TransitionState.FINISHED ||
                step.transitionState == TransitionState.CANCELED
        }
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ constructor(

        applicationScope.launch(bgDispatcher) {
            // We drop 1 to avoid triggering on initial collect().
            keyguardTransitionInteractor.transition(from = null, to = GONE).collect { transition ->
            keyguardTransitionInteractor.transition(to = GONE).collect { transition ->
                if (transition.transitionState == TransitionState.FINISHED) {
                    onKeyguardGone()
                }
+5 −6
Original line number Diff line number Diff line
@@ -157,7 +157,7 @@ constructor(
     * Receive all [TransitionStep] matching a filter of [from]->[to]. Allow nulls in order to match
     * any transition, for instance (any)->GONE.
     */
    fun transition(from: KeyguardState?, to: KeyguardState?): Flow<TransitionStep> {
    fun transition(from: KeyguardState? = null, to: KeyguardState? = null): Flow<TransitionStep> {
        if (from == null && to == null) {
            throw IllegalArgumentException("from and to cannot both be null")
        }
@@ -198,8 +198,7 @@ constructor(

    /** The last [TransitionStep] with a [TransitionState] of FINISHED */
    val finishedKeyguardTransitionStep: Flow<TransitionStep> =
        repository.transitions
            .filter { step -> step.transitionState == TransitionState.FINISHED }
        repository.transitions.filter { step -> step.transitionState == TransitionState.FINISHED }

    /** The destination state of the last [TransitionState.STARTED] transition. */
    val startedKeyguardState: SharedFlow<KeyguardState> =
@@ -377,7 +376,7 @@ constructor(
        state: KeyguardState,
    ): Flow<Boolean> {
        return getOrCreateFlow(Edge(from = null, to = state))
            .mapLatest { it.transitionState.isActive() }
            .mapLatest { it.transitionState.isTransitioning() }
            .onStart { emit(false) }
            .distinctUntilChanged()
    }
@@ -391,7 +390,7 @@ constructor(
        to: KeyguardState,
    ): Flow<Boolean> {
        return getOrCreateFlow(Edge(from = from, to = to))
            .mapLatest { it.transitionState.isActive() }
            .mapLatest { it.transitionState.isTransitioning() }
            .onStart { emit(false) }
            .distinctUntilChanged()
    }
@@ -403,7 +402,7 @@ constructor(
        state: KeyguardState,
    ): Flow<Boolean> {
        return getOrCreateFlow(Edge(from = state, to = null))
            .mapLatest { it.transitionState.isActive() }
            .mapLatest { it.transitionState.isTransitioning() }
            .onStart { emit(false) }
            .distinctUntilChanged()
    }
+5 −5
Original line number Diff line number Diff line
@@ -19,20 +19,20 @@ package com.android.systemui.keyguard.shared.model
enum class TransitionState {
    /* Transition has begun. */
    STARTED {
        override fun isActive() = true
        override fun isTransitioning() = true
    },
    /* Transition is actively running. */
    RUNNING {
        override fun isActive() = true
        override fun isTransitioning() = true
    },
    /* Transition has completed successfully. */
    FINISHED {
        override fun isActive() = false
        override fun isTransitioning() = false
    },
    /* Transition has been interrupted, and not completed successfully. */
    CANCELED {
        override fun isActive() = false
        override fun isTransitioning() = false
    };

    abstract fun isActive(): Boolean
    abstract fun isTransitioning(): Boolean
}
Loading