Accelerate wallpaper unlock transition
Flagged version of ag/24904329.
With this CL:
- The lock wallpaper fade out starts with no delay, as soon as the
shade starts to disappear, and lasts 83ms in total
- The home wallpaper fade in starts after a short delay of 67ms, so
the lock wallpaper is almost gone when the home wallpaper appears.
The fade in total duration is 167ms
Flag: ACONFIG com.android.systemui.Flags.fast_unlock_transition DEVELOPMENT
Bug: 298186160
Test: manual
Test: atest KeyguardUnlockAnimationControllerTest
Change-Id: I33af089261c99e319298015a766a165b0400f9cb
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 77c4aa6..d8d3f87 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -188,3 +188,9 @@
bug: "305049544"
}
+flag {
+ name: "fast_unlock_transition"
+ namespace: "systemui"
+ description: "Faster wallpaper unlock transition"
+ bug: "298186160"
+}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt
index c8c06ae..01ba0d2 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt
@@ -41,6 +41,7 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
+import com.android.systemui.Flags.fastUnlockTransition
import com.android.systemui.plugins.BcSmartspaceDataPlugin
import com.android.systemui.shared.recents.utilities.Utilities
import com.android.systemui.shared.system.ActivityManagerWrapper
@@ -98,7 +99,8 @@
* from a tap on the unlock icon, or from the bouncer. This is not relevant if the lockscreen is
* swiped away via a touch gesture, or when it's flinging expanded/collapsed after a swipe.
*/
-const val UNLOCK_ANIMATION_DURATION_MS = 200L
+const val LEGACY_UNLOCK_ANIMATION_DURATION_MS = 200L
+const val UNLOCK_ANIMATION_DURATION_MS = 167L
/**
* How long the in-window launcher icon animation takes. This is used if the launcher is underneath
@@ -112,19 +114,22 @@
/**
* How long to wait for the shade to get out of the way before starting the canned unlock animation.
*/
-const val CANNED_UNLOCK_START_DELAY = 100L
+const val LEGACY_CANNED_UNLOCK_START_DELAY = 100L
+const val CANNED_UNLOCK_START_DELAY = 67L
/**
* Duration for the alpha animation on the surface behind. This plays to fade in the surface during
* a swipe to unlock (and to fade it back out if the swipe is cancelled).
*/
-const val SURFACE_BEHIND_SWIPE_FADE_DURATION_MS = 175L
+const val LEGACY_SURFACE_BEHIND_SWIPE_FADE_DURATION_MS = 175L
+const val SURFACE_BEHIND_FADE_OUT_DURATION_MS = 83L
/**
* Start delay for the surface behind animation, used so that the lockscreen can get out of the way
* before the surface begins appearing.
*/
-const val UNLOCK_ANIMATION_SURFACE_BEHIND_START_DELAY_MS = 75L
+const val LEGACY_UNLOCK_ANIMATION_SURFACE_BEHIND_START_DELAY_MS = 75L
+const val SURFACE_BEHIND_FADE_OUT_START_DELAY_MS = 0L
/**
* Initiates, controls, and ends the keyguard unlock animation.
@@ -327,7 +332,7 @@
init {
with(surfaceBehindAlphaAnimator) {
- duration = SURFACE_BEHIND_SWIPE_FADE_DURATION_MS
+ duration = surfaceBehindFadeOutDurationMs()
interpolator = Interpolators.LINEAR
addUpdateListener { valueAnimator: ValueAnimator ->
surfaceBehindAlpha = valueAnimator.animatedValue as Float
@@ -355,8 +360,10 @@
}
with(wallpaperCannedUnlockAnimator) {
- duration = LAUNCHER_ICONS_ANIMATION_DURATION_MS
- interpolator = Interpolators.ALPHA_OUT
+ duration = if (fastUnlockTransition()) UNLOCK_ANIMATION_DURATION_MS
+ else LAUNCHER_ICONS_ANIMATION_DURATION_MS
+ interpolator = if (fastUnlockTransition()) Interpolators.LINEAR
+ else Interpolators.ALPHA_OUT
addUpdateListener { valueAnimator: ValueAnimator ->
setWallpaperAppearAmount(valueAnimator.animatedValue as Float)
}
@@ -370,8 +377,8 @@
}
with(surfaceBehindEntryAnimator) {
- duration = UNLOCK_ANIMATION_DURATION_MS
- startDelay = UNLOCK_ANIMATION_SURFACE_BEHIND_START_DELAY_MS
+ duration = unlockAnimationDurationMs()
+ startDelay = surfaceBehindFadeOutStartDelayMs()
interpolator = Interpolators.TOUCH_RESPONSE
addUpdateListener { valueAnimator: ValueAnimator ->
surfaceBehindAlpha = valueAnimator.animatedValue as Float
@@ -573,7 +580,7 @@
try {
launcherUnlockController?.playUnlockAnimation(
true,
- UNLOCK_ANIMATION_DURATION_MS + CANNED_UNLOCK_START_DELAY,
+ unlockAnimationDurationMs() + cannedUnlockStartDelayMs(),
0 /* startDelay */)
} catch (e: DeadObjectException) {
// Hello! If you are here investigating a bug where Launcher is blank (no icons)
@@ -602,12 +609,15 @@
// Notify if waking from AOD only
val isWakeAndUnlockNotFromDream = biometricUnlockControllerLazy.get().isWakeAndUnlock &&
biometricUnlockControllerLazy.get().mode != MODE_WAKE_AND_UNLOCK_FROM_DREAM
+
+ val duration = if (fastUnlockTransition()) UNLOCK_ANIMATION_DURATION_MS
+ else LAUNCHER_ICONS_ANIMATION_DURATION_MS
listeners.forEach {
it.onUnlockAnimationStarted(
playingCannedUnlockAnimation /* playingCannedAnimation */,
isWakeAndUnlockNotFromDream /* isWakeAndUnlockNotFromDream */,
- CANNED_UNLOCK_START_DELAY /* unlockStartDelay */,
- LAUNCHER_ICONS_ANIMATION_DURATION_MS /* unlockAnimationDuration */) }
+ cannedUnlockStartDelayMs() /* unlockStartDelay */,
+ duration /* unlockAnimationDuration */) }
// Finish the keyguard remote animation if the dismiss amount has crossed the threshold.
// Check it here in case there is no more change to the dismiss amount after the last change
@@ -675,7 +685,7 @@
launcherUnlockController?.playUnlockAnimation(
true /* unlocked */,
LAUNCHER_ICONS_ANIMATION_DURATION_MS /* duration */,
- CANNED_UNLOCK_START_DELAY /* startDelay */)
+ cannedUnlockStartDelayMs() /* startDelay */)
} catch (e: DeadObjectException) {
// Hello! If you are here investigating a bug where Launcher is blank (no icons)
// then the below assumption about Launcher's destruction was incorrect. This
@@ -696,9 +706,10 @@
lockscreenSmartspace?.visibility = View.INVISIBLE
}
- // As soon as the shade has animated out of the way, start the canned unlock animation,
+ // As soon as the shade starts animating out of the way, start the canned unlock animation,
// which will finish keyguard exit when it completes. The in-window animations in the
// Launcher window will end on their own.
+ if (fastUnlockTransition()) hideKeyguardViewAfterRemoteAnimation()
handler.postDelayed({
if (keyguardViewMediator.get().isShowingAndNotOccluded &&
!keyguardStateController.isKeyguardGoingAway) {
@@ -709,12 +720,12 @@
if ((wallpaperTargets?.isNotEmpty() == true)) {
fadeInWallpaper()
- hideKeyguardViewAfterRemoteAnimation()
+ if (!fastUnlockTransition()) hideKeyguardViewAfterRemoteAnimation()
} else {
keyguardViewMediator.get().exitKeyguardAndFinishSurfaceBehindRemoteAnimation(
false /* cancelled */)
}
- }, CANNED_UNLOCK_START_DELAY)
+ }, cannedUnlockStartDelayMs())
}
/**
@@ -1130,6 +1141,43 @@
?: false
}
+ /**
+ * Temporary method for b/298186160
+ * TODO (b/298186160) replace references with the constant itself when flag is removed
+ */
+ private fun cannedUnlockStartDelayMs(): Long {
+ return if (fastUnlockTransition()) CANNED_UNLOCK_START_DELAY
+ else LEGACY_CANNED_UNLOCK_START_DELAY
+ }
+
+ /**
+ * Temporary method for b/298186160
+ * TODO (b/298186160) replace references with the constant itself when flag is removed
+ */
+ private fun unlockAnimationDurationMs(): Long {
+ return if (fastUnlockTransition()) UNLOCK_ANIMATION_DURATION_MS
+ else LEGACY_UNLOCK_ANIMATION_DURATION_MS
+ }
+
+ /**
+ * Temporary method for b/298186160
+ * TODO (b/298186160) replace references with the constant itself when flag is removed
+ */
+ private fun surfaceBehindFadeOutDurationMs(): Long {
+ return if (fastUnlockTransition()) SURFACE_BEHIND_FADE_OUT_DURATION_MS
+ else LEGACY_SURFACE_BEHIND_SWIPE_FADE_DURATION_MS
+ }
+
+ /**
+ * Temporary method for b/298186160
+ * TODO (b/298186160) replace references with the constant itself when flag is removed
+ */
+ private fun surfaceBehindFadeOutStartDelayMs(): Long {
+ return if (fastUnlockTransition()) SURFACE_BEHIND_FADE_OUT_START_DELAY_MS
+ else LEGACY_UNLOCK_ANIMATION_SURFACE_BEHIND_START_DELAY_MS
+ }
+
+
companion object {
fun isFoldable(context: Context): Boolean {