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

Commit 25208813 authored by Sherry Zhou's avatar Sherry Zhou
Browse files

Fix lockscreen layout change is not successfully received by forcing emitting...

Fix lockscreen layout change is not successfully received by forcing emitting bounds when transition is finished

Bug: 441240189
Flag: com.android.systemui.shared.extended_wallpaper_effects
Test: atest WallpaperFocalAreaInteractorTest

Change-Id: I0317e11ba40797fe505ebab320c156b086ae31ef
parent 3df32c4e
Loading
Loading
Loading
Loading
+32 −41
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInterac
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
@@ -53,6 +52,7 @@ 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
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.launch

@@ -73,8 +73,7 @@ constructor(

    @OptIn(ExperimentalCoroutinesApi::class)
    val shouldCollectFocalArea =
        hasFocalArea
            .flatMapLatest { hasFocalArea ->
        hasFocalArea.flatMapLatest { hasFocalArea ->
            if (!hasFocalArea) {
                return@flatMapLatest flowOf(false)
            }
@@ -85,37 +84,29 @@ constructor(
                        transitionState.isTransitioningToLockscreenFromNonShade()
                }
            } else {
                    combine(
                            keyguardTransitionInteractor.startedKeyguardTransitionStep,
                            // Emit bounds when finishing transition to LOCKSCREEN to avoid race
                            // condition with COMMAND_WAKING_UP
                merge(
                        keyguardTransitionInteractor.startedKeyguardTransitionStep
                            .map { transitionStep ->
                                transitionStep.to == KeyguardState.LOCKSCREEN &&
                                    transitionStep.from != KeyguardState.LOCKSCREEN
                            }
                            .distinctUntilChanged(),
                        // Emit bounds when finishing transition to LOCKSCREEN to avoid
                        // getWallpaperTarget() and getPrevWallpaperTarget() are null and fail
                        // to send command
                        keyguardTransitionInteractor
                            .transition(
                                edge = Edge.create(to = Scenes.Lockscreen),
                                edgeWithoutSceneContainer =
                                    Edge.create(to = KeyguardState.LOCKSCREEN),
                            )
                                .filter { it.transitionState == TransitionState.FINISHED },
                            ::Pair,
                            .filter { it.transitionState == TransitionState.FINISHED }
                            .map { true },
                    )
                    // Enforce collecting wallpaperFocalAreaBounds after rebooting
                        .onStart {
                            emit(
                                Pair(
                                    TransitionStep(to = KeyguardState.LOCKSCREEN),
                                    TransitionStep(),
                                )
                            )
                        }
                        .map { (transitionStep, _) ->
                            // Subscribe to bounds within the period of transitioning to the
                            // lockscreen, prior to any transitions away.
                            transitionStep.to == KeyguardState.LOCKSCREEN &&
                                transitionStep.from != KeyguardState.LOCKSCREEN
                        }
                    .onStart { emit(true) }
            }
        }
            .distinctUntilChanged()

    @OptIn(ExperimentalCoroutinesApi::class)
    val wallpaperFocalAreaBoundsOnLockscreen: Flow<RectF> =