Loading libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimator.kt +18 −20 Original line number Diff line number Diff line Loading @@ -19,12 +19,13 @@ package com.android.wm.shell.animation import android.util.ArrayMap import android.util.Log import android.view.View import androidx.dynamicanimation.animation.AnimationHandler import androidx.dynamicanimation.animation.DynamicAnimation import androidx.dynamicanimation.animation.FlingAnimation import androidx.dynamicanimation.animation.FloatPropertyCompat import androidx.dynamicanimation.animation.FrameCallbackScheduler import androidx.dynamicanimation.animation.SpringAnimation import androidx.dynamicanimation.animation.SpringForce import com.android.wm.shell.animation.PhysicsAnimator.Companion.getInstance import java.lang.ref.WeakReference import java.util.WeakHashMap Loading Loading @@ -124,10 +125,10 @@ class PhysicsAnimator<T> private constructor (target: T) { private var defaultFling: FlingConfig = globalDefaultFling /** * AnimationHandler to use if it need custom AnimationHandler, if this is null, it will use * the default AnimationHandler in the DynamicAnimation. * FrameCallbackScheduler to use if it need custom FrameCallbackScheduler, if this is null, * it will use the default FrameCallbackScheduler in the DynamicAnimation. */ private var customAnimationHandler: AnimationHandler? = null private var customScheduler: FrameCallbackScheduler? = null /** * Internal listeners that respond to DynamicAnimations updating and ending, and dispatch to Loading Loading @@ -454,11 +455,11 @@ class PhysicsAnimator<T> private constructor (target: T) { } /** * Set the custom AnimationHandler for all aniatmion in this animator. Set this with null for * restoring to default AnimationHandler. * Set the custom FrameCallbackScheduler for all aniatmion in this animator. Set this with null for * restoring to default FrameCallbackScheduler. */ fun setCustomAnimationHandler(handler: AnimationHandler) { this.customAnimationHandler = handler fun setCustomScheduler(scheduler: FrameCallbackScheduler) { this.customScheduler = scheduler } /** Starts the animations! */ Loading Loading @@ -510,10 +511,9 @@ class PhysicsAnimator<T> private constructor (target: T) { // springs) on this property before flinging. cancel(animatedProperty) // Apply the custom animation handler if it not null // Apply the custom animation scheduler if it not null val flingAnim = getFlingAnimation(animatedProperty, target) flingAnim.animationHandler = customAnimationHandler ?: flingAnim.animationHandler flingAnim.scheduler = customScheduler ?: flingAnim.scheduler // Apply the configuration and start the animation. flingAnim.also { flingConfig.applyToAnimation(it) }.start() Loading @@ -529,17 +529,16 @@ class PhysicsAnimator<T> private constructor (target: T) { // Apply the configuration and start the animation. val springAnim = getSpringAnimation(animatedProperty, target) // If customAnimationHander is exist and has not been set to the animation, // If customScheduler is exist and has not been set to the animation, // it should set here. if (customAnimationHandler != null && springAnim.animationHandler != customAnimationHandler) { if (customScheduler != null && springAnim.scheduler != customScheduler) { // Cancel the animation before set animation handler if (springAnim.isRunning) { cancel(animatedProperty) } // Apply the custom animation handler if it not null springAnim.animationHandler = customAnimationHandler ?: springAnim.animationHandler // Apply the custom scheduler handler if it not null springAnim.scheduler = customScheduler ?: springAnim.scheduler } // Apply the configuration and start the animation. Loading Loading @@ -597,10 +596,9 @@ class PhysicsAnimator<T> private constructor (target: T) { } } // Apply the custom animation handler if it not null // Apply the custom animation scheduler if it not null val springAnim = getSpringAnimation(animatedProperty, target) springAnim.animationHandler = customAnimationHandler ?: springAnim.animationHandler springAnim.scheduler = customScheduler ?: springAnim.scheduler // Apply the configuration and start the spring animation. springAnim.also { springConfig.applyToAnimation(it) }.start() Loading libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java +4 −7 Original line number Diff line number Diff line Loading @@ -36,8 +36,7 @@ import android.os.Debug; import android.os.Looper; import android.view.Choreographer; import androidx.dynamicanimation.animation.AnimationHandler; import androidx.dynamicanimation.animation.AnimationHandler.FrameCallbackScheduler; import androidx.dynamicanimation.animation.FrameCallbackScheduler; import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.R; Loading Loading @@ -89,7 +88,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, /** Coordinator instance for resolving conflicts with other floating content. */ private FloatingContentCoordinator mFloatingContentCoordinator; private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal = private ThreadLocal<FrameCallbackScheduler> mSfSchedulerThreadLocal = ThreadLocal.withInitial(() -> { final Looper initialLooper = Looper.myLooper(); final FrameCallbackScheduler scheduler = new FrameCallbackScheduler() { Loading @@ -105,8 +104,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, return Looper.myLooper() == initialLooper; } }; AnimationHandler handler = new AnimationHandler(scheduler); return handler; return scheduler; }); /** Loading Loading @@ -214,8 +212,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, // Note: Needs to get the shell main thread sf vsync animation handler mTemporaryBoundsPhysicsAnimator = PhysicsAnimator.getInstance( mPipBoundsState.getMotionBoundsState().getBoundsInMotion()); mTemporaryBoundsPhysicsAnimator.setCustomAnimationHandler( mSfAnimationHandlerThreadLocal.get()); mTemporaryBoundsPhysicsAnimator.setCustomScheduler(mSfSchedulerThreadLocal.get()); } @NonNull Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/animation/PhysicsAnimator.kt +18 −20 Original line number Diff line number Diff line Loading @@ -19,12 +19,13 @@ package com.android.wm.shell.animation import android.util.ArrayMap import android.util.Log import android.view.View import androidx.dynamicanimation.animation.AnimationHandler import androidx.dynamicanimation.animation.DynamicAnimation import androidx.dynamicanimation.animation.FlingAnimation import androidx.dynamicanimation.animation.FloatPropertyCompat import androidx.dynamicanimation.animation.FrameCallbackScheduler import androidx.dynamicanimation.animation.SpringAnimation import androidx.dynamicanimation.animation.SpringForce import com.android.wm.shell.animation.PhysicsAnimator.Companion.getInstance import java.lang.ref.WeakReference import java.util.WeakHashMap Loading Loading @@ -124,10 +125,10 @@ class PhysicsAnimator<T> private constructor (target: T) { private var defaultFling: FlingConfig = globalDefaultFling /** * AnimationHandler to use if it need custom AnimationHandler, if this is null, it will use * the default AnimationHandler in the DynamicAnimation. * FrameCallbackScheduler to use if it need custom FrameCallbackScheduler, if this is null, * it will use the default FrameCallbackScheduler in the DynamicAnimation. */ private var customAnimationHandler: AnimationHandler? = null private var customScheduler: FrameCallbackScheduler? = null /** * Internal listeners that respond to DynamicAnimations updating and ending, and dispatch to Loading Loading @@ -454,11 +455,11 @@ class PhysicsAnimator<T> private constructor (target: T) { } /** * Set the custom AnimationHandler for all aniatmion in this animator. Set this with null for * restoring to default AnimationHandler. * Set the custom FrameCallbackScheduler for all aniatmion in this animator. Set this with null for * restoring to default FrameCallbackScheduler. */ fun setCustomAnimationHandler(handler: AnimationHandler) { this.customAnimationHandler = handler fun setCustomScheduler(scheduler: FrameCallbackScheduler) { this.customScheduler = scheduler } /** Starts the animations! */ Loading Loading @@ -510,10 +511,9 @@ class PhysicsAnimator<T> private constructor (target: T) { // springs) on this property before flinging. cancel(animatedProperty) // Apply the custom animation handler if it not null // Apply the custom animation scheduler if it not null val flingAnim = getFlingAnimation(animatedProperty, target) flingAnim.animationHandler = customAnimationHandler ?: flingAnim.animationHandler flingAnim.scheduler = customScheduler ?: flingAnim.scheduler // Apply the configuration and start the animation. flingAnim.also { flingConfig.applyToAnimation(it) }.start() Loading @@ -529,17 +529,16 @@ class PhysicsAnimator<T> private constructor (target: T) { // Apply the configuration and start the animation. val springAnim = getSpringAnimation(animatedProperty, target) // If customAnimationHander is exist and has not been set to the animation, // If customScheduler is exist and has not been set to the animation, // it should set here. if (customAnimationHandler != null && springAnim.animationHandler != customAnimationHandler) { if (customScheduler != null && springAnim.scheduler != customScheduler) { // Cancel the animation before set animation handler if (springAnim.isRunning) { cancel(animatedProperty) } // Apply the custom animation handler if it not null springAnim.animationHandler = customAnimationHandler ?: springAnim.animationHandler // Apply the custom scheduler handler if it not null springAnim.scheduler = customScheduler ?: springAnim.scheduler } // Apply the configuration and start the animation. Loading Loading @@ -597,10 +596,9 @@ class PhysicsAnimator<T> private constructor (target: T) { } } // Apply the custom animation handler if it not null // Apply the custom animation scheduler if it not null val springAnim = getSpringAnimation(animatedProperty, target) springAnim.animationHandler = customAnimationHandler ?: springAnim.animationHandler springAnim.scheduler = customScheduler ?: springAnim.scheduler // Apply the configuration and start the spring animation. springAnim.also { springConfig.applyToAnimation(it) }.start() Loading
libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipMotionHelper.java +4 −7 Original line number Diff line number Diff line Loading @@ -36,8 +36,7 @@ import android.os.Debug; import android.os.Looper; import android.view.Choreographer; import androidx.dynamicanimation.animation.AnimationHandler; import androidx.dynamicanimation.animation.AnimationHandler.FrameCallbackScheduler; import androidx.dynamicanimation.animation.FrameCallbackScheduler; import com.android.internal.protolog.common.ProtoLog; import com.android.wm.shell.R; Loading Loading @@ -89,7 +88,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, /** Coordinator instance for resolving conflicts with other floating content. */ private FloatingContentCoordinator mFloatingContentCoordinator; private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal = private ThreadLocal<FrameCallbackScheduler> mSfSchedulerThreadLocal = ThreadLocal.withInitial(() -> { final Looper initialLooper = Looper.myLooper(); final FrameCallbackScheduler scheduler = new FrameCallbackScheduler() { Loading @@ -105,8 +104,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, return Looper.myLooper() == initialLooper; } }; AnimationHandler handler = new AnimationHandler(scheduler); return handler; return scheduler; }); /** Loading Loading @@ -214,8 +212,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback, // Note: Needs to get the shell main thread sf vsync animation handler mTemporaryBoundsPhysicsAnimator = PhysicsAnimator.getInstance( mPipBoundsState.getMotionBoundsState().getBoundsInMotion()); mTemporaryBoundsPhysicsAnimator.setCustomAnimationHandler( mSfAnimationHandlerThreadLocal.get()); mTemporaryBoundsPhysicsAnimator.setCustomScheduler(mSfSchedulerThreadLocal.get()); } @NonNull Loading