From 0950ca8abc3503eec85cfc1b7a6cdd35d9c677e0 Mon Sep 17 00:00:00 2001 From: Nick Chameyev Date: Tue, 25 Jan 2022 16:48:33 +0000 Subject: [PATCH] Reset NotificationPanelView when pressing power button before fold to AOD animation When we hit power button during folding: before fold to AOD transition starts but after we prepared the starting params of NotificationPanelView it remained in this state (alpha = 0, translation = -x). So it led to an issue that user don't see the keyguard. Added logic that resets this view to its original state when we are waking up and the animation hasn't started yet. 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: I88b79aca462137723e174f2f4196cbd08d71f664 --- .../NotificationPanelViewController.java | 13 ++++++++++ .../systemui/statusbar/phone/StatusBar.java | 6 ++--- .../unfold/FoldAodAnimationController.kt | 25 +++++++++++++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index 016b953245b20..5d24d4aa79871 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -3896,6 +3896,15 @@ public class NotificationPanelViewController extends PanelViewController { mKeyguardStatusViewController.animateFoldToAod(); } + /** + * Cancels fold to AOD transition and resets view state + */ + public void cancelFoldToAodAnimation() { + cancelAnimation(); + resetAlpha(); + resetTranslation(); + } + /** */ public void setImportantForAccessibility(int mode) { mView.setImportantForAccessibility(mode); @@ -4014,6 +4023,10 @@ public class NotificationPanelViewController extends PanelViewController { mView.setTranslationX(0f); } + public void resetAlpha() { + mView.setAlpha(1f); + } + public ViewPropertyAnimator fadeOut(long startDelayMs, long durationMs, Runnable endAction) { return mView.animate().alpha(0).setStartDelay(startDelayMs).setDuration( durationMs).setInterpolator(Interpolators.ALPHA_OUT).withLayer().withEndAction( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 9a9e3bc587745..1551b02367d07 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -3001,7 +3001,7 @@ public class StatusBar extends CoreStartable implements } private void onLaunchTransitionFadingEnded() { - mNotificationPanelViewController.setAlpha(1.0f); + mNotificationPanelViewController.resetAlpha(); mNotificationPanelViewController.onAffordanceLaunchEnded(); releaseGestureWakeLock(); runLaunchTransitionEndRunnable(); @@ -3032,7 +3032,7 @@ public class StatusBar extends CoreStartable implements } updateScrimController(); mPresenter.updateMediaMetaData(false, true); - mNotificationPanelViewController.setAlpha(1); + mNotificationPanelViewController.resetAlpha(); mNotificationPanelViewController.fadeOut( FADE_KEYGUARD_START_DELAY, FADE_KEYGUARD_DURATION, this::onLaunchTransitionFadingEnded); @@ -3133,7 +3133,7 @@ public class StatusBar extends CoreStartable implements releaseGestureWakeLock(); mNotificationPanelViewController.onAffordanceLaunchEnded(); mNotificationPanelViewController.cancelAnimation(); - mNotificationPanelViewController.setAlpha(1f); + mNotificationPanelViewController.resetAlpha(); mNotificationPanelViewController.resetTranslation(); mNotificationPanelViewController.resetViewGroupFade(); updateDozingState(); diff --git a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt index aaf35afe936d9..c481fc94c5260 100644 --- a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt @@ -16,8 +16,10 @@ package com.android.systemui.unfold +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 @@ -37,6 +39,7 @@ import javax.inject.Inject class FoldAodAnimationController @Inject constructor( + @Main private val handler: Handler, private val keyguardViewMediatorLazy: Lazy, private val wakefulnessLifecycle: WakefulnessLifecycle, private val globalSettings: GlobalSettings @@ -50,6 +53,14 @@ constructor( private var shouldPlayAnimation = false private val statusListeners = arrayListOf() + private val startAnimationRunnable = Runnable { + statusBar.notificationPanelViewController.startFoldToAodAnimation { + // End action + isAnimationPlaying = false + keyguardViewMediatorLazy.get().maybeHandlePendingLock() + } + } + private var isAnimationPlaying = false override fun initialize(statusBar: StatusBar, lightRevealScrim: LightRevealScrim) { @@ -79,6 +90,11 @@ constructor( } override fun onStartedWakingUp() { + if (isAnimationPlaying) { + handler.removeCallbacks(startAnimationRunnable) + statusBar.notificationPanelViewController.cancelFoldToAodAnimation(); + } + shouldPlayAnimation = false isAnimationPlaying = false } @@ -115,11 +131,10 @@ constructor( fun onScreenTurnedOn() { if (shouldPlayAnimation) { - statusBar.notificationPanelViewController.startFoldToAodAnimation { - // End action - isAnimationPlaying = false - keyguardViewMediatorLazy.get().maybeHandlePendingLock() - } + handler.removeCallbacks(startAnimationRunnable) + + // Post starting the animation to the next frame to avoid junk due to inset changes + handler.post(startAnimationRunnable) shouldPlayAnimation = false } }