From a836e7d65f15fa887ed41cf97e5f0b0ac698ade8 Mon Sep 17 00:00:00 2001 From: Nick Chameyev Date: Thu, 27 Jan 2022 10:30:17 +0000 Subject: [PATCH] [Folding to AOD] Do not delay keyguard show when folding Disables delaying of keyguard show when starting the folding to AOD animation so keyguard is always ready when we fold foldable devices. For unlocked screen off animation this is necessary to avoid junk as showing keyguard is expensive. For fold to AOD animation the first frame is black so junk is not visible, so we can execute this. This change keeps the unlocked screen off animation behavior the same and disables delaying keyguard show for folding to AOD animation. Bug: 215703534 Test: fold and quickly press power button => check that keyguard is visible Test: fold to AOD and press power button => keyguard visible Test: lock/unlock using power button Change-Id: I0a08ffa182e00fff4faf5b7c8218d463ddb5eeaf --- .../statusbar/phone/ScreenOffAnimationController.kt | 8 ++++++-- .../phone/UnlockedScreenOffAnimationController.kt | 6 ++++++ .../android/systemui/unfold/FoldAodAnimationController.kt | 4 ---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt index 091831f360222..ea61a8b94e7e9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScreenOffAnimationController.kt @@ -113,14 +113,16 @@ class ScreenOffAnimationController @Inject constructor( * the animation ends */ fun shouldDelayKeyguardShow(): Boolean = - animations.any { it.shouldPlayAnimation() } + animations.any { it.shouldDelayKeyguardShow() } /** * Return true while we want to ignore requests to show keyguard, we need to handle pending * keyguard lock requests manually + * + * @see [com.android.systemui.keyguard.KeyguardViewMediator.maybeHandlePendingLock] */ fun isKeyguardShowDelayed(): Boolean = - animations.any { it.isAnimationPlaying() } + animations.any { it.isKeyguardShowDelayed() } /** * Return true to ignore requests to hide keyguard @@ -211,6 +213,8 @@ interface ScreenOffAnimation { fun shouldAnimateInKeyguard(): Boolean = false fun animateInKeyguard(keyguardView: View, after: Runnable) = after.run() + fun shouldDelayKeyguardShow(): Boolean = false + fun isKeyguardShowDelayed(): Boolean = false fun isKeyguardHideDelayed(): Boolean = false fun shouldHideScrimOnWakeUp(): Boolean = false fun overrideNotificationsDozeAmount(): Boolean = false diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt index cc65ca0251394..0abe8e489638f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/UnlockedScreenOffAnimationController.kt @@ -136,6 +136,12 @@ class UnlockedScreenOffAnimationController @Inject constructor( globalSettings.getFloat(Settings.Global.ANIMATOR_DURATION_SCALE, 1f) } + override fun shouldDelayKeyguardShow(): Boolean = + shouldPlayAnimation() + + override fun isKeyguardShowDelayed(): Boolean = + isAnimationPlaying() + /** * Animates in the provided keyguard view, ending in the same position that it will be in on * AOD. diff --git a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt index c481fc94c5260..2e627a872c247 100644 --- a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt @@ -20,7 +20,6 @@ import android.os.Handler import android.os.PowerManager import android.provider.Settings import com.android.systemui.dagger.qualifiers.Main -import com.android.systemui.keyguard.KeyguardViewMediator import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.statusbar.LightRevealScrim import com.android.systemui.statusbar.phone.ScreenOffAnimation @@ -28,7 +27,6 @@ import com.android.systemui.statusbar.phone.StatusBar import com.android.systemui.statusbar.policy.CallbackController import com.android.systemui.unfold.FoldAodAnimationController.FoldAodAnimationStatus import com.android.systemui.util.settings.GlobalSettings -import dagger.Lazy import javax.inject.Inject /** @@ -40,7 +38,6 @@ class FoldAodAnimationController @Inject constructor( @Main private val handler: Handler, - private val keyguardViewMediatorLazy: Lazy, private val wakefulnessLifecycle: WakefulnessLifecycle, private val globalSettings: GlobalSettings ) : CallbackController, ScreenOffAnimation, WakefulnessLifecycle.Observer { @@ -57,7 +54,6 @@ constructor( statusBar.notificationPanelViewController.startFoldToAodAnimation { // End action isAnimationPlaying = false - keyguardViewMediatorLazy.get().maybeHandlePendingLock() } }