summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sherry Zhou <yuandizhou@google.com> 2025-02-26 03:41:16 +0000
committer Sherry Zhou <yuandizhou@google.com> 2025-02-26 03:52:18 +0000
commit0eb0b827cf67b8bd662d71b098f1e40a608f0eea (patch)
tree288ba910c6bb2f3feb6057b8b235c9f2b17fd59f
parentccb979d47754ec6dfaa42594becd5bb693bec68e (diff)
Fix shape is sometimes too small on lockscreen
Avoid sending wrong bounds from homescreen to wallpaper by filtering the FINISHED transitionStep to LOCKSCREEN, and filtering out the FINISHED transitionStep from LOCKSCREEN Test: manual test that no bounds is sent to wallpaper when unlocking Bug: 396667623 Flag: com.android.systemui.shared.extended_wallpaper_effects Change-Id: Ied576062ebdfb44ba0814b26c8db4505647055d2
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt11
-rw-r--r--packages/SystemUI/src/com/android/systemui/wallpapers/ui/viewmodel/WallpaperFocalAreaViewModel.kt29
2 files changed, 19 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
index c7791cda7046..4324eca9fe5a 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
@@ -88,7 +88,6 @@ import kotlin.math.min
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.DisposableHandle
import kotlinx.coroutines.flow.MutableStateFlow
-import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
@@ -374,17 +373,9 @@ object KeyguardRootViewBinder {
if (wallpaperFocalAreaViewModel.hasFocalArea.value) {
launch {
wallpaperFocalAreaViewModel.wallpaperFocalAreaBounds.collect {
- wallpaperFocalAreaBounds ->
- wallpaperFocalAreaViewModel.setFocalAreaBounds(
- wallpaperFocalAreaBounds
- )
+ wallpaperFocalAreaViewModel.setFocalAreaBounds(it)
}
}
- launch {
- wallpaperFocalAreaViewModel.wallpaperFocalAreaBounds
- .filterNotNull()
- .collect { wallpaperFocalAreaViewModel.setFocalAreaBounds(it) }
- }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallpapers/ui/viewmodel/WallpaperFocalAreaViewModel.kt b/packages/SystemUI/src/com/android/systemui/wallpapers/ui/viewmodel/WallpaperFocalAreaViewModel.kt
index 4cd49d03ad36..1e78b12db154 100644
--- a/packages/SystemUI/src/com/android/systemui/wallpapers/ui/viewmodel/WallpaperFocalAreaViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/wallpapers/ui/viewmodel/WallpaperFocalAreaViewModel.kt
@@ -26,6 +26,7 @@ import com.android.systemui.wallpapers.domain.interactor.WallpaperFocalAreaInter
import javax.inject.Inject
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.filter
+import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.map
class WallpaperFocalAreaViewModel
@@ -39,25 +40,31 @@ constructor(
val wallpaperFocalAreaBounds =
combine(
wallpaperFocalAreaInteractor.wallpaperFocalAreaBounds,
+ keyguardTransitionInteractor.startedKeyguardTransitionStep,
+ // Emit transition state when FINISHED instead of STARTED to avoid race with
+ // wakingup command, causing layout change command not be received.
keyguardTransitionInteractor
.transition(
edge = Edge.create(to = Scenes.Lockscreen),
edgeWithoutSceneContainer = Edge.create(to = KeyguardState.LOCKSCREEN),
)
- .filter { transitionStep ->
- // Should not filter by TransitionState.STARTED, it may race with
- // wakingup command, causing layout change command not be received.
- transitionStep.transitionState == TransitionState.FINISHED
- },
- ::Pair,
+ .filter { it.transitionState == TransitionState.FINISHED },
+ ::Triple,
)
- .map { (bounds, _) -> bounds }
+ .map { (bounds, startedStep, _) ->
+ // Avoid sending wrong bounds when transitioning from LOCKSCREEN to GONE
+ if (
+ startedStep.to == KeyguardState.LOCKSCREEN &&
+ startedStep.from != KeyguardState.LOCKSCREEN
+ ) {
+ bounds
+ } else {
+ null
+ }
+ }
+ .filterNotNull()
fun setFocalAreaBounds(bounds: RectF) {
wallpaperFocalAreaInteractor.setFocalAreaBounds(bounds)
}
-
- fun setTapPosition(x: Float, y: Float) {
- wallpaperFocalAreaInteractor.setTapPosition(x, y)
- }
}