From 9df43f863e07fd7a9f904b0793d994b108eec087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Pomini?= Date: Thu, 1 Jun 2023 12:29:11 +0000 Subject: [PATCH] Hide keyguard earlier when exiting lockscreen Call hideKeyguardViewAfterRemoteAnimation earlier, when starting to fade in the home wallpaper. This call will hide the lock wallpaper. With this, then the lockscreen live wallpaper flag is enabled, hideKeyguardViewAfterRemoteAnimation will be called another time from exitKeyguardAndFinishSurfaceBehindRemoteAnimation in onAnimationEnd. But the second call will always be ignored. Replace the error log with an info log when the second call is ignored, since this is expected. Bug: 283390961 Bug: 284081102 Test: manual, unlock with/without bouncer, with fast/short swipe, with/without AOD, ... Change-Id: Icfd993cc222ee8fd59d25beecb982cc545104d82 --- .../systemui/keyguard/KeyguardService.java | 7 +++++-- .../KeyguardUnlockAnimationController.kt | 12 ++++++++---- .../keyguard/KeyguardViewMediator.java | 19 +++++++++++++++---- .../KeyguardUnlockAnimationControllerTest.kt | 6 +++++- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java index a8d22c48e7094..ac408a2abcabf 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java @@ -159,7 +159,8 @@ public class KeyguardService extends Service { // Wrap Keyguard going away animation. // Note: Also used for wrapping occlude by Dream animation. It works (with some redundancy). - public static IRemoteTransition wrap(IRemoteAnimationRunner runner) { + public static IRemoteTransition wrap(IRemoteAnimationRunner runner, + boolean lockscreenLiveWallpaperEnabled) { return new IRemoteTransition.Stub() { private final ArrayMap mLeashMap = new ArrayMap<>(); @@ -188,7 +189,9 @@ public class KeyguardService extends Service { } } initAlphaForAnimationTargets(t, apps); - initAlphaForAnimationTargets(t, wallpapers); + if (lockscreenLiveWallpaperEnabled) { + initAlphaForAnimationTargets(t, wallpapers); + } t.apply(); mFinishCallback = finishCallback; runner.onAnimationStart( diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt index 29a7fe7d061ad..c616992cb523e 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardUnlockAnimationController.kt @@ -19,6 +19,7 @@ package com.android.systemui.keyguard import android.animation.Animator import android.animation.AnimatorListenerAdapter import android.animation.ValueAnimator +import android.app.WallpaperManager import android.content.Context import android.graphics.Matrix import android.graphics.Rect @@ -148,7 +149,8 @@ class KeyguardUnlockAnimationController @Inject constructor( private val biometricUnlockControllerLazy: Lazy, private val statusBarStateController: SysuiStatusBarStateController, private val notificationShadeWindowController: NotificationShadeWindowController, - private val powerManager: PowerManager + private val powerManager: PowerManager, + private val wallpaperManager: WallpaperManager ) : KeyguardStateController.Callback, ISysuiUnlockAnimationController.Stub() { interface KeyguardUnlockAnimationListener { @@ -679,8 +681,10 @@ class KeyguardUnlockAnimationController @Inject constructor( return@postDelayed } - if (wallpaperTargets != null) { - fadeInWallpaper() + if ((wallpaperTargets?.isNotEmpty() == true) && + wallpaperManager.isLockscreenLiveWallpaperEnabled()) { + fadeInWallpaper() + hideKeyguardViewAfterRemoteAnimation() } else { keyguardViewMediator.get().exitKeyguardAndFinishSurfaceBehindRemoteAnimation( false /* cancelled */) @@ -954,7 +958,7 @@ class KeyguardUnlockAnimationController @Inject constructor( 0 /* fadeOutDuration */ ) } else { - Log.e(TAG, "#hideKeyguardViewAfterRemoteAnimation called when keyguard view is not " + + Log.i(TAG, "#hideKeyguardViewAfterRemoteAnimation called when keyguard view is not " + "showing. Ignoring...") } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 3b40d8602e6fe..9e1f461ef60b2 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -45,6 +45,7 @@ import android.app.AlarmManager; import android.app.BroadcastOptions; import android.app.PendingIntent; import android.app.StatusBarManager; +import android.app.WallpaperManager; import android.app.WindowConfiguration; import android.app.trust.TrustManager; import android.content.BroadcastReceiver; @@ -280,6 +281,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, private AlarmManager mAlarmManager; private AudioManager mAudioManager; private StatusBarManager mStatusBarManager; + private WallpaperManager mWallpaperManager; private final IStatusBarService mStatusBarService; private final IBinder mStatusBarDisableToken = new Binder(); private final UserTracker mUserTracker; @@ -1350,11 +1352,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, setShowingLocked(false /* showing */, true /* forceCallbacks */); } + boolean isLockscreenLwpEnabled = getWallpaperManager().isLockscreenLiveWallpaperEnabled(); mKeyguardTransitions.register( - KeyguardService.wrap(getExitAnimationRunner()), - KeyguardService.wrap(getOccludeAnimationRunner()), - KeyguardService.wrap(getOccludeByDreamAnimationRunner()), - KeyguardService.wrap(getUnoccludeAnimationRunner())); + KeyguardService.wrap(getExitAnimationRunner(), isLockscreenLwpEnabled), + KeyguardService.wrap(getOccludeAnimationRunner(), isLockscreenLwpEnabled), + KeyguardService.wrap(getOccludeByDreamAnimationRunner(), isLockscreenLwpEnabled), + KeyguardService.wrap(getUnoccludeAnimationRunner(), isLockscreenLwpEnabled)); final ContentResolver cr = mContext.getContentResolver(); @@ -1400,6 +1403,14 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mWorkLockController = new WorkLockActivityController(mContext, mUserTracker); } + // TODO(b/273443374) remove, temporary util to get a feature flag + private WallpaperManager getWallpaperManager() { + if (mWallpaperManager == null) { + mWallpaperManager = mContext.getSystemService(WallpaperManager.class); + } + return mWallpaperManager; + } + @Override public void start() { synchronized (this) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt index 477e076669b7c..001f81af5c2bb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardUnlockAnimationControllerTest.kt @@ -1,6 +1,7 @@ package com.android.systemui.keyguard import android.app.ActivityManager +import android.app.WallpaperManager import android.app.WindowConfiguration import android.graphics.Point import android.graphics.Rect @@ -64,6 +65,8 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { private lateinit var notificationShadeWindowController: NotificationShadeWindowController @Mock private lateinit var powerManager: PowerManager + @Mock + private lateinit var wallpaperManager: WallpaperManager @Mock private lateinit var launcherUnlockAnimationController: ILauncherUnlockAnimationController.Stub @@ -94,13 +97,14 @@ class KeyguardUnlockAnimationControllerTest : SysuiTestCase() { keyguardUnlockAnimationController = KeyguardUnlockAnimationController( context, keyguardStateController, { keyguardViewMediator }, keyguardViewController, featureFlags, { biometricUnlockController }, statusBarStateController, - notificationShadeWindowController, powerManager + notificationShadeWindowController, powerManager, wallpaperManager ) keyguardUnlockAnimationController.setLauncherUnlockController( launcherUnlockAnimationController) whenever(keyguardViewController.viewRootImpl).thenReturn(mock(ViewRootImpl::class.java)) whenever(powerManager.isInteractive).thenReturn(true) + whenever(wallpaperManager.isLockscreenLiveWallpaperEnabled).thenReturn(false) // All of these fields are final, so we can't mock them, but are needed so that the surface // appear amount setter doesn't short circuit.