diff options
author | Selim Cinek <cinek@google.com> | 2022-01-07 18:53:03 +0100 |
---|---|---|
committer | Selim Cinek <cinek@google.com> | 2022-01-14 12:11:27 +0000 |
commit | 012f6bc71135af5baf355ff411c50267a4ae54ab (patch) | |
tree | 6eef7e543576b05abc31ebaceefe06b6a9de4693 | |
parent | d36f3eb79592b827e0823c6b8b46fd3d3c0f3a9f (diff) | |
download | base-012f6bc71135af5baf355ff411c50267a4ae54ab.tar.gz |
Fixed an issue where a user could't go to the locked shade from dozing
When waking up, the status bar state was immediately reset, stopping
the transition. We now migrate the behavior from the pulse expansion
to the ls shade transition controller and wait a bit longer.
Fixes: 201341772
Test: click on expand from pulsing
Change-Id: Ie7caa06b45c3fd4c2aec72dfecf82e76e06ff3f2
6 files changed, 49 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java b/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java index 2e1c9faf8848..474a81b9ce44 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/WakefulnessLifecycle.java @@ -138,6 +138,7 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe } setWakefulness(WAKEFULNESS_AWAKE); dispatch(Observer::onFinishedWakingUp); + dispatch(Observer::onPostFinishedWakingUp); } public void dispatchStartedGoingToSleep(@PowerManager.GoToSleepReason int pmSleepReason) { @@ -236,6 +237,12 @@ public class WakefulnessLifecycle extends Lifecycle<WakefulnessLifecycle.Observe public interface Observer { default void onStartedWakingUp() {} default void onFinishedWakingUp() {} + + /** + * Called after the finished waking up call, ensuring it's after all the other listeners, + * reacting to {@link #onFinishedWakingUp()} + */ + default void onPostFinishedWakingUp() {} default void onStartedGoingToSleep() {} default void onFinishedGoingToSleep() {} } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt index 029415bad5bb..f796265e48a0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/LockscreenShadeTransitionController.kt @@ -7,7 +7,6 @@ import android.animation.ValueAnimator import android.content.Context import android.content.res.Configuration import android.os.SystemClock -import android.util.DisplayMetrics import android.util.IndentingPrintWriter import android.util.MathUtils import android.view.MotionEvent @@ -24,6 +23,7 @@ import com.android.systemui.classifier.Classifier import com.android.systemui.classifier.FalsingCollector import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager +import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.media.MediaHierarchyManager import com.android.systemui.plugins.ActivityStarter.OnDismissAction import com.android.systemui.plugins.FalsingManager @@ -64,6 +64,7 @@ class LockscreenShadeTransitionController @Inject constructor( private val scrimController: ScrimController, private val depthController: NotificationShadeDepthController, private val context: Context, + wakefulnessLifecycle: WakefulnessLifecycle, configurationController: ConfigurationController, falsingManager: FalsingManager, dumpManager: DumpManager, @@ -120,6 +121,12 @@ class LockscreenShadeTransitionController @Inject constructor( private var nextHideKeyguardNeedsNoAnimation = false /** + * Are we currently waking up to the shade locked + */ + var isWakingToShadeLocked: Boolean = false + private set + + /** * The distance until we're showing the notifications when pulsing */ val distanceUntilShowingPulsingNotifications @@ -160,6 +167,13 @@ class LockscreenShadeTransitionController @Inject constructor( } } }) + wakefulnessLifecycle.addObserver(object : WakefulnessLifecycle.Observer { + override fun onPostFinishedWakingUp() { + // when finishing waking up, the UnlockedScreenOffAnimation has another attempt + // to reset keyguard. Let's do it in post + isWakingToShadeLocked = false + } + }) } private fun updateResources() { @@ -488,6 +502,10 @@ class LockscreenShadeTransitionController @Inject constructor( draggedDownEntry = entry } else { logger.logGoingToLockedShade(animationHandler != null) + if (statusBarStateController.isDozing) { + // Make sure we don't go back to keyguard immediately again after waking up + isWakingToShadeLocked = true + } statusBarStateController.setState(StatusBarState.SHADE_LOCKED) // This call needs to be after updating the shade state since otherwise // the scrimstate resets too early @@ -598,6 +616,7 @@ class LockscreenShadeTransitionController @Inject constructor( it.println("dragDownAmount: $dragDownAmount") it.println("isDragDownAnywhereEnabled: $isDragDownAnywhereEnabled") it.println("isFalsingCheckNeeded: $isFalsingCheckNeeded") + it.println("isWakingToShadeLocked: $isWakingToShadeLocked") it.println("hasPendingHandlerOnKeyguardDismiss: " + "${animationHandlerOnKeyguardDismiss != null}") } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt index ea51bd89df42..3fe108f2c951 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt @@ -107,8 +107,6 @@ constructor( private var mDraggedFarEnough: Boolean = false private var mStartingChild: ExpandableView? = null private var mPulsing: Boolean = false - var isWakingToShadeLocked: Boolean = false - private set private var velocityTracker: VelocityTracker? = null @@ -235,7 +233,6 @@ constructor( mStartingChild = null } if (statusBarStateController.isDozing) { - isWakingToShadeLocked = true wakeUpCoordinator.willWakeUp = true mPowerManager!!.wakeUp(SystemClock.uptimeMillis(), WAKE_REASON_GESTURE, "com.android.systemui:PULSEDRAG") @@ -333,10 +330,6 @@ constructor( mPulsing = pulsing } - fun onStartedWakingUp() { - isWakingToShadeLocked = false - } - override fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<out String>) { IndentingPrintWriter(pw, " ").let { it.println("PulseExpansionHandler:") @@ -344,7 +337,6 @@ constructor( it.println("isExpanding: $isExpanding") it.println("leavingLockscreen: $leavingLockscreen") it.println("mPulsing: $mPulsing") - it.println("isWakingToShadeLocked: $isWakingToShadeLocked") it.println("qsExpanded: $qsExpanded") it.println("bouncerShowing: $bouncerShowing") } 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 778a1e36392e..33212182cfcf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -2965,7 +2965,7 @@ public class StatusBar extends SystemUI implements mMessageRouter.cancelMessages(MSG_LAUNCH_TRANSITION_TIMEOUT); if (mUserSwitcherController != null && mUserSwitcherController.useFullscreenUserSwitcher()) { mStatusBarStateController.setState(StatusBarState.FULLSCREEN_USER_SWITCHER); - } else if (!mPulseExpansionHandler.isWakingToShadeLocked()) { + } else if (!mLockscreenShadeTransitionController.isWakingToShadeLocked()) { mStatusBarStateController.setState(StatusBarState.KEYGUARD); } updatePanelExpansionForKeyguard(); @@ -3570,7 +3570,6 @@ public class StatusBar extends SystemUI implements // once we fully woke up. updateRevealEffect(true /* wakingUp */); updateNotificationPanelTouchState(); - mPulseExpansionHandler.onStartedWakingUp(); // If we are waking up during the screen off animation, we should undo making the // expanded visible (we did that so the LightRevealScrim would be visible). diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/WakefulnessLifecycleTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/WakefulnessLifecycleTest.java index e453ff2dc7bf..fd282ccd2a74 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/WakefulnessLifecycleTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/WakefulnessLifecycleTest.java @@ -80,6 +80,7 @@ public class WakefulnessLifecycleTest extends SysuiTestCase { assertEquals(WakefulnessLifecycle.WAKEFULNESS_AWAKE, mWakefulness.getWakefulness()); verify(mWakefulnessObserver).onFinishedWakingUp(); + verify(mWakefulnessObserver).onPostFinishedWakingUp(); } @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt index 01a214b40f98..6f9cd87d5bb8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/LockscreenShadeTransitionControllerTest.kt @@ -4,13 +4,12 @@ import android.test.suitebuilder.annotation.SmallTest import android.testing.AndroidTestingRunner import android.testing.TestableLooper import android.testing.TestableLooper.RunWithLooper -import android.util.DisplayMetrics import com.android.systemui.ExpandHelper import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.FalsingCollector import com.android.systemui.dump.DumpManager -import com.android.systemui.log.LogBuffer +import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.media.MediaHierarchyManager import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.qs.QS @@ -64,12 +63,11 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { @Mock lateinit var lockScreenUserManager: NotificationLockscreenUserManager @Mock lateinit var falsingCollector: FalsingCollector @Mock lateinit var ambientState: AmbientState - @Mock lateinit var displayMetrics: DisplayMetrics + @Mock lateinit var wakefulnessLifecycle: WakefulnessLifecycle @Mock lateinit var mediaHierarchyManager: MediaHierarchyManager @Mock lateinit var scrimController: ScrimController @Mock lateinit var configurationController: ConfigurationController @Mock lateinit var falsingManager: FalsingManager - @Mock lateinit var buffer: LogBuffer @Mock lateinit var notificationPanelController: NotificationPanelViewController @Mock lateinit var nsslController: NotificationStackScrollLayoutController @Mock lateinit var depthController: NotificationShadeDepthController @@ -98,6 +96,7 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { mediaHierarchyManager = mediaHierarchyManager, scrimController = scrimController, depthController = depthController, + wakefulnessLifecycle = wakefulnessLifecycle, context = context, configurationController = configurationController, falsingManager = falsingManager, @@ -148,6 +147,23 @@ class LockscreenShadeTransitionControllerTest : SysuiTestCase() { } @Test + fun testWakingToShadeLockedWhenDozing() { + whenever(statusbarStateController.isDozing).thenReturn(true) + transitionController.goToLockedShade(null) + verify(statusbarStateController).setState(StatusBarState.SHADE_LOCKED) + assertTrue("Not waking to shade locked", transitionController.isWakingToShadeLocked) + } + + @Test + fun testNotWakingToShadeLockedWhenNotDozing() { + whenever(statusbarStateController.isDozing).thenReturn(false) + transitionController.goToLockedShade(null) + verify(statusbarStateController).setState(StatusBarState.SHADE_LOCKED) + assertFalse("Waking to shade locked when not dozing", + transitionController.isWakingToShadeLocked) + } + + @Test fun testGoToLockedShadeOnlyOnKeyguard() { whenever(statusbarStateController.state).thenReturn(StatusBarState.SHADE_LOCKED) transitionController.goToLockedShade(null) |