Loading core/java/android/window/SplashScreenView.java +28 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACK import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION; import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; import static com.android.internal.jank.InteractionJankMonitor.CUJ_SPLASHSCREEN_AVD; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -54,6 +58,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import com.android.internal.R; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.policy.DecorView; import com.android.internal.util.ContrastColorUtil; Loading Loading @@ -487,6 +492,23 @@ public final class SplashScreenView extends FrameLayout { } IconAnimateListener aniDrawable = (IconAnimateListener) iconDrawable; aniDrawable.prepareAnimate(duration, this::animationStartCallback); aniDrawable.setAnimationJankMonitoring(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { InteractionJankMonitor.getInstance().cancel(CUJ_SPLASHSCREEN_AVD); } @Override public void onAnimationEnd(Animator animation) { InteractionJankMonitor.getInstance().end(CUJ_SPLASHSCREEN_AVD); } @Override public void onAnimationStart(Animator animation) { InteractionJankMonitor.getInstance().begin( SplashScreenView.this, CUJ_SPLASHSCREEN_AVD); } }); } private void animationStartCallback() { Loading Loading @@ -669,6 +691,12 @@ public final class SplashScreenView extends FrameLayout { * Stop animation. */ void stopAnimation(); /** * Provides a chance to start interaction jank monitoring in avd animation. * @param listener a listener to start jank monitoring */ default void setAnimationJankMonitoring(AnimatorListenerAdapter listener) {} } /** Loading core/java/com/android/internal/jank/InteractionJankMonitor.java +12 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_IN import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_ROW_EXPAND; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_ROW_SWIPE; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_SCROLL_FLING; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_AVD; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_EXIT_ANIM; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__USER_SWITCH; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION; Loading Loading @@ -173,6 +175,8 @@ public class InteractionJankMonitor { public static final int CUJ_PIP_TRANSITION = 35; public static final int CUJ_WALLPAPER_TRANSITION = 36; public static final int CUJ_USER_SWITCH = 37; public static final int CUJ_SPLASHSCREEN_AVD = 38; public static final int CUJ_SPLASHSCREEN_EXIT_ANIM = 39; private static final int NO_STATSD_LOGGING = -1; Loading Loading @@ -219,6 +223,8 @@ public class InteractionJankMonitor { UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__PIP_TRANSITION, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__USER_SWITCH, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_AVD, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_EXIT_ANIM, }; private static volatile InteractionJankMonitor sInstance; Loading Loading @@ -277,6 +283,8 @@ public class InteractionJankMonitor { CUJ_PIP_TRANSITION, CUJ_WALLPAPER_TRANSITION, CUJ_USER_SWITCH, CUJ_SPLASHSCREEN_AVD, CUJ_SPLASHSCREEN_EXIT_ANIM, }) @Retention(RetentionPolicy.SOURCE) public @interface CujType { Loading Loading @@ -672,6 +680,10 @@ public class InteractionJankMonitor { return "WALLPAPER_TRANSITION"; case CUJ_USER_SWITCH: return "USER_SWITCH"; case CUJ_SPLASHSCREEN_AVD: return "SPLASHSCREEN_AVD"; case CUJ_SPLASHSCREEN_EXIT_ANIM: return "SPLASHSCREEN_EXIT_ANIM"; } return "UNKNOWN"; } Loading libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashScreenExitAnimation.java +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.wm.shell.startingsurface; import static android.view.Choreographer.CALLBACK_COMMIT; import static android.view.View.GONE; import static com.android.internal.jank.InteractionJankMonitor.CUJ_SPLASHSCREEN_EXIT_ANIM; import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; Loading @@ -42,6 +44,7 @@ import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; import android.window.SplashScreenView; import com.android.internal.jank.InteractionJankMonitor; import com.android.wm.shell.R; import com.android.wm.shell.animation.Interpolators; import com.android.wm.shell.common.TransactionPool; Loading Loading @@ -311,17 +314,19 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener { @Override public void onAnimationStart(Animator animation) { // ignore InteractionJankMonitor.getInstance().begin(mSplashScreenView, CUJ_SPLASHSCREEN_EXIT_ANIM); } @Override public void onAnimationEnd(Animator animation) { reset(); InteractionJankMonitor.getInstance().end(CUJ_SPLASHSCREEN_EXIT_ANIM); } @Override public void onAnimationCancel(Animator animation) { reset(); InteractionJankMonitor.getInstance().cancel(CUJ_SPLASHSCREEN_EXIT_ANIM); } @Override Loading libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenIconDrawableFactory.java +18 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.startingsurface; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.annotation.ColorInt; import android.annotation.NonNull; Loading Loading @@ -263,17 +264,23 @@ public class SplashscreenIconDrawableFactory { * A lightweight AdaptiveIconDrawable which support foreground to be Animatable, and keep this * drawable masked by config_icon_mask. */ private static class AnimatableIconAnimateListener extends AdaptiveForegroundDrawable public static class AnimatableIconAnimateListener extends AdaptiveForegroundDrawable implements SplashScreenView.IconAnimateListener { private Animatable mAnimatableIcon; private Animator mIconAnimator; private boolean mAnimationTriggered; private AnimatorListenerAdapter mJankMonitoringListener; AnimatableIconAnimateListener(@NonNull Drawable foregroundDrawable) { super(foregroundDrawable); mForegroundDrawable.setCallback(mCallback); } @Override public void setAnimationJankMonitoring(AnimatorListenerAdapter listener) { mJankMonitoringListener = listener; } @Override public boolean prepareAnimate(long duration, Runnable startListener) { mAnimatableIcon = (Animatable) mForegroundDrawable; Loading @@ -286,6 +293,9 @@ public class SplashscreenIconDrawableFactory { startListener.run(); } try { if (mJankMonitoringListener != null) { mJankMonitoringListener.onAnimationStart(animation); } mAnimatableIcon.start(); } catch (Exception ex) { Log.e(TAG, "Error while running the splash screen animated icon", ex); Loading @@ -296,11 +306,17 @@ public class SplashscreenIconDrawableFactory { @Override public void onAnimationEnd(Animator animation) { mAnimatableIcon.stop(); if (mJankMonitoringListener != null) { mJankMonitoringListener.onAnimationEnd(animation); } } @Override public void onAnimationCancel(Animator animation) { mAnimatableIcon.stop(); if (mJankMonitoringListener != null) { mJankMonitoringListener.onAnimationCancel(animation); } } @Override Loading @@ -316,6 +332,7 @@ public class SplashscreenIconDrawableFactory { public void stopAnimation() { if (mIconAnimator != null && mIconAnimator.isRunning()) { mIconAnimator.end(); mJankMonitoringListener = null; } } Loading Loading
core/java/android/window/SplashScreenView.java +28 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACK import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION; import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; import static com.android.internal.jank.InteractionJankMonitor.CUJ_SPLASHSCREEN_AVD; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.annotation.ColorInt; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -54,6 +58,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import com.android.internal.R; import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.policy.DecorView; import com.android.internal.util.ContrastColorUtil; Loading Loading @@ -487,6 +492,23 @@ public final class SplashScreenView extends FrameLayout { } IconAnimateListener aniDrawable = (IconAnimateListener) iconDrawable; aniDrawable.prepareAnimate(duration, this::animationStartCallback); aniDrawable.setAnimationJankMonitoring(new AnimatorListenerAdapter() { @Override public void onAnimationCancel(Animator animation) { InteractionJankMonitor.getInstance().cancel(CUJ_SPLASHSCREEN_AVD); } @Override public void onAnimationEnd(Animator animation) { InteractionJankMonitor.getInstance().end(CUJ_SPLASHSCREEN_AVD); } @Override public void onAnimationStart(Animator animation) { InteractionJankMonitor.getInstance().begin( SplashScreenView.this, CUJ_SPLASHSCREEN_AVD); } }); } private void animationStartCallback() { Loading Loading @@ -669,6 +691,12 @@ public final class SplashScreenView extends FrameLayout { * Stop animation. */ void stopAnimation(); /** * Provides a chance to start interaction jank monitoring in avd animation. * @param listener a listener to start jank monitoring */ default void setAnimationJankMonitoring(AnimatorListenerAdapter listener) {} } /** Loading
core/java/com/android/internal/jank/InteractionJankMonitor.java +12 −0 Original line number Diff line number Diff line Loading @@ -58,6 +58,8 @@ import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_IN import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_ROW_EXPAND; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_ROW_SWIPE; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_SCROLL_FLING; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_AVD; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_EXIT_ANIM; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__STATUS_BAR_APP_LAUNCH_FROM_CALL_CHIP; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__USER_SWITCH; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION; Loading Loading @@ -173,6 +175,8 @@ public class InteractionJankMonitor { public static final int CUJ_PIP_TRANSITION = 35; public static final int CUJ_WALLPAPER_TRANSITION = 36; public static final int CUJ_USER_SWITCH = 37; public static final int CUJ_SPLASHSCREEN_AVD = 38; public static final int CUJ_SPLASHSCREEN_EXIT_ANIM = 39; private static final int NO_STATSD_LOGGING = -1; Loading Loading @@ -219,6 +223,8 @@ public class InteractionJankMonitor { UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__PIP_TRANSITION, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__USER_SWITCH, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_AVD, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLASHSCREEN_EXIT_ANIM, }; private static volatile InteractionJankMonitor sInstance; Loading Loading @@ -277,6 +283,8 @@ public class InteractionJankMonitor { CUJ_PIP_TRANSITION, CUJ_WALLPAPER_TRANSITION, CUJ_USER_SWITCH, CUJ_SPLASHSCREEN_AVD, CUJ_SPLASHSCREEN_EXIT_ANIM, }) @Retention(RetentionPolicy.SOURCE) public @interface CujType { Loading Loading @@ -672,6 +680,10 @@ public class InteractionJankMonitor { return "WALLPAPER_TRANSITION"; case CUJ_USER_SWITCH: return "USER_SWITCH"; case CUJ_SPLASHSCREEN_AVD: return "SPLASHSCREEN_AVD"; case CUJ_SPLASHSCREEN_EXIT_ANIM: return "SPLASHSCREEN_EXIT_ANIM"; } return "UNKNOWN"; } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashScreenExitAnimation.java +6 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.wm.shell.startingsurface; import static android.view.Choreographer.CALLBACK_COMMIT; import static android.view.View.GONE; import static com.android.internal.jank.InteractionJankMonitor.CUJ_SPLASHSCREEN_EXIT_ANIM; import android.animation.Animator; import android.animation.ValueAnimator; import android.content.Context; Loading @@ -42,6 +44,7 @@ import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; import android.window.SplashScreenView; import com.android.internal.jank.InteractionJankMonitor; import com.android.wm.shell.R; import com.android.wm.shell.animation.Interpolators; import com.android.wm.shell.common.TransactionPool; Loading Loading @@ -311,17 +314,19 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener { @Override public void onAnimationStart(Animator animation) { // ignore InteractionJankMonitor.getInstance().begin(mSplashScreenView, CUJ_SPLASHSCREEN_EXIT_ANIM); } @Override public void onAnimationEnd(Animator animation) { reset(); InteractionJankMonitor.getInstance().end(CUJ_SPLASHSCREEN_EXIT_ANIM); } @Override public void onAnimationCancel(Animator animation) { reset(); InteractionJankMonitor.getInstance().cancel(CUJ_SPLASHSCREEN_EXIT_ANIM); } @Override Loading
libs/WindowManager/Shell/src/com/android/wm/shell/startingsurface/SplashscreenIconDrawableFactory.java +18 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.wm.shell.startingsurface; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.annotation.ColorInt; import android.annotation.NonNull; Loading Loading @@ -263,17 +264,23 @@ public class SplashscreenIconDrawableFactory { * A lightweight AdaptiveIconDrawable which support foreground to be Animatable, and keep this * drawable masked by config_icon_mask. */ private static class AnimatableIconAnimateListener extends AdaptiveForegroundDrawable public static class AnimatableIconAnimateListener extends AdaptiveForegroundDrawable implements SplashScreenView.IconAnimateListener { private Animatable mAnimatableIcon; private Animator mIconAnimator; private boolean mAnimationTriggered; private AnimatorListenerAdapter mJankMonitoringListener; AnimatableIconAnimateListener(@NonNull Drawable foregroundDrawable) { super(foregroundDrawable); mForegroundDrawable.setCallback(mCallback); } @Override public void setAnimationJankMonitoring(AnimatorListenerAdapter listener) { mJankMonitoringListener = listener; } @Override public boolean prepareAnimate(long duration, Runnable startListener) { mAnimatableIcon = (Animatable) mForegroundDrawable; Loading @@ -286,6 +293,9 @@ public class SplashscreenIconDrawableFactory { startListener.run(); } try { if (mJankMonitoringListener != null) { mJankMonitoringListener.onAnimationStart(animation); } mAnimatableIcon.start(); } catch (Exception ex) { Log.e(TAG, "Error while running the splash screen animated icon", ex); Loading @@ -296,11 +306,17 @@ public class SplashscreenIconDrawableFactory { @Override public void onAnimationEnd(Animator animation) { mAnimatableIcon.stop(); if (mJankMonitoringListener != null) { mJankMonitoringListener.onAnimationEnd(animation); } } @Override public void onAnimationCancel(Animator animation) { mAnimatableIcon.stop(); if (mJankMonitoringListener != null) { mJankMonitoringListener.onAnimationCancel(animation); } } @Override Loading @@ -316,6 +332,7 @@ public class SplashscreenIconDrawableFactory { public void stopAnimation() { if (mIconAnimator != null && mIconAnimator.isRunning()) { mIconAnimator.end(); mJankMonitoringListener = null; } } Loading