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

Commit f9309850 authored by Kshitij Gupta's avatar Kshitij Gupta
Browse files

Keyguard: Defer doze-to-lockscreen transition on shade drag

- When the device transitions from dozing to the lockscreen at the same
  time the user pulls down the notification shade, their respective
  alpha animations can conflict, causing visual glitches.
- This change introduces logic to prioritize the shade drag animation.
  A new flow, dozingToLockscreenAlpha, monitors the shade expansion
  alpha. If the shade is being dragged, the doze-to-lockscreen alpha
  animation is suppressed by switching to an emptyFlow().

Bug: 419763981
Flag: com.android.systemui.defer_doze_transition_on_shade_drag
Test: atest KeyguardRootViewModelTest
Test: Manual - b/419763981#comment10
Change-Id: Ie037c88b7762a4d33a76380c558c42a2d48c8b12
parent f0e9f95d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2196,3 +2196,13 @@ flag {
    bug: "201143076"
    is_fixed_read_only: true
}

flag {
   name: "defer_doze_transition_on_shade_drag"
   namespace: "systemui"
   description: "Defer doze-to-lockscreen transition animation during notification shade drag"
   bug: "419763981"
   metadata {
        purpose: PURPOSE_BUGFIX
   }
}
+20 −5
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import kotlinx.coroutines.flow.combineTransform
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
@@ -256,6 +257,24 @@ constructor(
                .dumpWhileCollecting("zoomOutFromGlanceableHub")
        }

    private fun dozingToLockscreenAlpha(viewState: ViewStateAccessor) =
        alphaOnShadeExpansion
            .map { it < 1f }
            .distinctUntilChanged()
            .onStart { emit(false) }.flatMapLatest { isExpanding ->
                if (Flags.deferDozeTransitionOnShadeDrag() && isExpanding) {
                    // If shade is expanding, switch to a flow that never emits.
                    emptyFlow()
                } else {
                    // Otherwise, use the original flow.
                    if (Flags.newDozingKeyguardStates()) {
                        dozingToLockscreenTransitionViewModel.lockscreenAlpha(viewState)
                    } else {
                        dozingToLockscreenTransitionViewModel.lockscreenAlpha
                    }
                }
            }

    /** Last point that the root view was tapped */
    val lastRootViewTapPosition: Flow<Point?> =
        keyguardInteractor.lastRootViewTapPosition.dumpWhileCollecting("lastRootViewTapPosition")
@@ -314,11 +333,7 @@ constructor(
                        aodToGlanceableHubTransitionViewModel.lockscreenAlpha(viewState),
                        dozingToDreamingTransitionViewModel.lockscreenAlpha,
                        dozingToGoneTransitionViewModel.lockscreenAlpha(viewState),
                        if (Flags.newDozingKeyguardStates()) {
                            dozingToLockscreenTransitionViewModel.lockscreenAlpha(viewState)
                        } else {
                            dozingToLockscreenTransitionViewModel.lockscreenAlpha
                        },
                        dozingToLockscreenAlpha(viewState),
                        dozingToOccludedTransitionViewModel.lockscreenAlpha(viewState),
                        dozingToPrimaryBouncerTransitionViewModel.lockscreenAlpha,
                        dreamingToAodTransitionViewModel.lockscreenAlpha,