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
diff --git a/packages/SystemUI/animation/Android.bp b/packages/SystemUI/animation/Android.bp
index 1b15d20..46adfeb 100644
--- a/packages/SystemUI/animation/Android.bp
+++ b/packages/SystemUI/animation/Android.bp
@@ -39,5 +39,5 @@
     ],
 
     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 a0d335d..08d217d 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 @@
      */
     var callback: Callback? = null
 
+    /** The set of [Listener] that should be notified of any animation started by this animator. */
+    private val listeners = LinkedHashSet<Listener>()
+
     /**
      * 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 @@
         }
     }
 
+    /** 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 @@
         /** 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 @@
             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 @@
                 ) {
                     applyStateToWindow(window, state)
                     navigationBar?.let { applyStateToNavigationBar(it, state, linearProgress) }
+                    listeners.forEach { it.onLaunchAnimationProgress(linearProgress) }
                     delegate.onLaunchAnimationProgress(state, progress, linearProgress)
                 }
             }