summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Pietal <mpietal@google.com>2023-04-25 19:44:27 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-05-05 06:45:22 +0000
commit1ce017c80c0941131d112489537f044d1d7d373f (patch)
tree0b2f1dc4974e8c816c9984657436961672208c58
parent8a49308e99ae5d2d9faf68667de5ba2c714d18fe (diff)
downloadbase-1ce017c80c0941131d112489537f044d1d7d373f.tar.gz
Make sure to reset isFoldHandled
A previous commit reset this flag in select circumstances. However, there are other paths that also need to be covered. Always reset isFoldHandled every single time the device has been folded and the screen has turned on. This should fully prevent errant calls to showAodUI(), which forces keyguard to show over any other screen. Paths that could've produced the issue involve: 1. Unfold and unlock 2. Fold the device, it should go to AOD 3. Cover the prox sensor (as if putting in purse/pocket) and let screen timeout until black. 4. Wait a few moments to let the device really sleep 5. Uncover sensor and unlock with Side FPS immediately Test: atest FoldAodAnimationsControllerTest Fixes: 273681779 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:dd564d207d24e83a5f724f632bf80e5ce6764046) Merged-In: I3260125fa545494c28e52ecf02825704ffbad295 Change-Id: I3260125fa545494c28e52ecf02825704ffbad295
-rw-r--r--packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt11
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt25
2 files changed, 32 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt
index 641cc45e01d8..29f67188d59d 100644
--- a/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/unfold/FoldAodAnimationController.kt
@@ -150,10 +150,6 @@ constructor(
pendingScrimReadyCallback = onReady
}
} else if (isFolded && !isFoldHandled && alwaysOnEnabled && isDozing) {
- // Screen turning on for the first time after folding and we are already dozing
- // We should play the folding to AOD animation
- isFoldHandled = true
-
setAnimationState(playing = true)
centralSurfaces.notificationPanelViewController.prepareFoldToAodAnimation()
@@ -169,6 +165,13 @@ constructor(
// No animation, call ready callback immediately
onReady.run()
}
+
+ if (isFolded) {
+ // Any time the screen turns on, this state needs to be reset if the device has been
+ // folded. Reaching this line implies AOD has been shown in one way or another,
+ // if enabled
+ isFoldHandled = true
+ }
}
/** Called when keyguard scrim opaque changed */
diff --git a/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt
index 7f64867d3868..f788229ddcfd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/unfold/FoldAodAnimationControllerTest.kt
@@ -198,6 +198,31 @@ class FoldAodAnimationControllerTest : SysuiTestCase() {
}
@Test
+ fun onFolded_onScreenTurningOnWithoutDozingThenWithDozing_doesNotLogLatency() =
+ runBlocking(IMMEDIATE) {
+ val job = underTest.listenForDozing(this)
+ keyguardRepository.setDozing(false)
+ setAodEnabled(enabled = true)
+
+ yield()
+
+ fold()
+ simulateScreenTurningOn()
+ reset(latencyTracker)
+
+ // Now enable dozing and trigger a second run through the aod animation code. It should
+ // not rerun the animation
+ keyguardRepository.setDozing(true)
+ yield()
+ simulateScreenTurningOn()
+
+ verify(latencyTracker, never()).onActionStart(any())
+ verify(latencyTracker, never()).onActionEnd(any())
+
+ job.cancel()
+ }
+
+ @Test
fun onFolded_animationCancelled_doesNotLogLatency() =
runBlocking(IMMEDIATE) {
val job = underTest.listenForDozing(this)