From 83dbe11921fa888f7361cbda95df4e8cdf79c538 Mon Sep 17 00:00:00 2001 From: Jordan Demeulenaere Date: Fri, 7 Jan 2022 12:00:13 +0100 Subject: [PATCH] Fade out UFPS icon when launching an app over it (1/2) Before this CL, the UDFPS affordance would instantly disappear after launching an Activity (like Device Controls) over the lockscreen. This CL now nicely fades out the affordance during the launch animation, unless the Activity requested the UDFPS (like the Wallet). See b/213555622#comment1 for before/after videos. Bug: 213555622 Test: Open device controls and wallet over lockscreen Change-Id: I589a4a6c10a118d05fae87b70d14c924d468b63f --- packages/SystemUI/animation/Android.bp | 2 +- .../animation/ActivityLaunchAnimator.kt | 38 ++++++++++++++++--- .../systemui/biometrics/UdfpsController.java | 9 ++++- .../biometrics/UdfpsControllerOverlay.kt | 7 +++- .../UdfpsKeyguardViewController.java | 38 ++++++++++++++++++- .../systemui/statusbar/phone/StatusBar.java | 23 +++++++---- .../animation/ActivityLaunchAnimatorTest.kt | 13 +++++-- .../biometrics/UdfpsControllerOverlayTest.kt | 4 +- .../biometrics/UdfpsControllerTest.java | 6 ++- .../UdfpsKeyguardViewControllerTest.java | 6 ++- 10 files changed, 122 insertions(+), 24 deletions(-) diff --git a/packages/SystemUI/animation/Android.bp b/packages/SystemUI/animation/Android.bp index 1b15d20d2c52d..46adfeba0fb0a 100644 --- a/packages/SystemUI/animation/Android.bp +++ b/packages/SystemUI/animation/Android.bp @@ -39,5 +39,5 @@ android_library { ], manifest: "AndroidManifest.xml", - + kotlincflags: ["-Xjvm-default=enable"], } diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt index a0d335db92d65..08d217d15a5ae 100644 --- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt +++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt @@ -95,6 +95,9 @@ class ActivityLaunchAnimator( */ var callback: Callback? = null + /** The set of [Listener] that should be notified of any animation started by this animator. */ + private val listeners = LinkedHashSet() + /** * Start an intent and animate the opening window. The intent will be started by running * [intentStarter], which should use the provided [RemoteAnimationAdapter] and return the launch @@ -214,6 +217,16 @@ class ActivityLaunchAnimator( } } + /** Add a [Listener] that can listen to launch animations. */ + fun addListener(listener: Listener) { + listeners.add(listener) + } + + /** Remove a [Listener]. */ + fun removeListener(listener: Listener) { + listeners.remove(listener) + } + /** Create a new animation [Runner] controlled by [controller]. */ @VisibleForTesting fun createRunner(controller: Controller): Runner = Runner(controller) @@ -234,13 +247,27 @@ class ActivityLaunchAnimator( /** Hide the keyguard and animate using [runner]. */ fun hideKeyguardWithAnimation(runner: IRemoteAnimationRunner) - /** Enable/disable window blur so they don't overlap with the window launch animation **/ - fun setBlursDisabledForAppLaunch(disabled: Boolean) - /* Get the background color of [task]. */ fun getBackgroundColor(task: TaskInfo): Int } + interface Listener { + /** Called when an activity launch animation started. */ + @JvmDefault + fun onLaunchAnimationStart() {} + + /** + * Called when an activity launch animation is finished. This will be called if and only if + * [onLaunchAnimationStart] was called earlier. + */ + @JvmDefault + fun onLaunchAnimationEnd() {} + + /** Called when an activity launch animation made progress. */ + @JvmDefault + fun onLaunchAnimationProgress(linearProgress: Float) {} + } + /** * A controller that takes care of applying the animation to an expanding view. * @@ -396,12 +423,12 @@ class ActivityLaunchAnimator( val delegate = this.controller val controller = object : LaunchAnimator.Controller by delegate { override fun onLaunchAnimationStart(isExpandingFullyAbove: Boolean) { - callback.setBlursDisabledForAppLaunch(true) + listeners.forEach { it.onLaunchAnimationStart() } delegate.onLaunchAnimationStart(isExpandingFullyAbove) } override fun onLaunchAnimationEnd(isExpandingFullyAbove: Boolean) { - callback.setBlursDisabledForAppLaunch(false) + listeners.forEach { it.onLaunchAnimationEnd() } iCallback?.invoke() delegate.onLaunchAnimationEnd(isExpandingFullyAbove) } @@ -413,6 +440,7 @@ class ActivityLaunchAnimator( ) { applyStateToWindow(window, state) navigationBar?.let { applyStateToNavigationBar(it, state, linearProgress) } + listeners.forEach { it.onLaunchAnimationProgress(linearProgress) } delegate.onLaunchAnimationProgress(state, progress, linearProgress) } } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index fd7ae323e88f1..d20844143ad61 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -53,6 +53,7 @@ import android.view.accessibility.AccessibilityManager; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.LatencyTracker; import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.doze.DozeReceiver; @@ -130,6 +131,7 @@ public class UdfpsController implements DozeReceiver { // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple // sensors, this, in addition to a lot of the code here, will be updated. @VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps; + @NonNull private final ActivityLaunchAnimator mActivityLaunchAnimator; // Tracks the velocity of a touch to help filter out the touches that move too fast. @Nullable private VelocityTracker mVelocityTracker; @@ -198,7 +200,8 @@ public class UdfpsController implements DozeReceiver { mLockscreenShadeTransitionController, mConfigurationController, mSystemClock, mKeyguardStateController, mUnlockedScreenOffAnimationController, mSensorProps, mHbmProvider, - reason, callback, UdfpsController.this::onTouch))); + reason, callback, UdfpsController.this::onTouch, + mActivityLaunchAnimator))); } @Override @@ -487,7 +490,8 @@ public class UdfpsController implements DozeReceiver { @NonNull SystemClock systemClock, @NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, @NonNull SystemUIDialogManager dialogManager, - @NonNull LatencyTracker latencyTracker) { + @NonNull LatencyTracker latencyTracker, + @NonNull ActivityLaunchAnimator activityLaunchAnimator) { mContext = context; mExecution = execution; mVibrator = vibrator; @@ -516,6 +520,7 @@ public class UdfpsController implements DozeReceiver { mSystemClock = systemClock; mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mLatencyTracker = latencyTracker; + mActivityLaunchAnimator = activityLaunchAnimator; mSensorProps = findFirstUdfps(); // At least one UDFPS sensor exists diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt index e0912508d1780..590963b2ff485 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt @@ -41,6 +41,7 @@ import android.view.accessibility.AccessibilityManager.TouchExplorationStateChan import androidx.annotation.LayoutRes import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.R +import com.android.systemui.animation.ActivityLaunchAnimator import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.LockscreenShadeTransitionController @@ -81,7 +82,8 @@ class UdfpsControllerOverlay( private var hbmProvider: UdfpsHbmProvider, @ShowReason val requestReason: Int, private val controllerCallback: IUdfpsOverlayControllerCallback, - private val onTouch: (View, MotionEvent, Boolean) -> Boolean + private val onTouch: (View, MotionEvent, Boolean) -> Boolean, + private val activityLaunchAnimator: ActivityLaunchAnimator ) { /** The view, when [isShowing], or null. */ var overlayView: UdfpsView? = null @@ -200,7 +202,8 @@ class UdfpsControllerOverlay( keyguardStateController, unlockedScreenOffAnimationController, dialogManager, - controller + controller, + activityLaunchAnimator ) } BiometricOverlayConstants.REASON_AUTH_BP -> { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java index d90a746b0f79c..8b7aa093600c5 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java @@ -25,6 +25,7 @@ import android.view.MotionEvent; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.R; +import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.dump.DumpManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.LockscreenShadeTransitionController; @@ -55,6 +56,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController