Merge "Instrument jank of splash screen AVD and exit animation" into sc-v2-dev
This commit is contained in:
@@ -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_NAVIGATION;
|
||||||
import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
|
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.ColorInt;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
@@ -54,6 +58,7 @@ import android.widget.FrameLayout;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.android.internal.R;
|
import com.android.internal.R;
|
||||||
|
import com.android.internal.jank.InteractionJankMonitor;
|
||||||
import com.android.internal.policy.DecorView;
|
import com.android.internal.policy.DecorView;
|
||||||
import com.android.internal.util.ContrastColorUtil;
|
import com.android.internal.util.ContrastColorUtil;
|
||||||
|
|
||||||
@@ -487,6 +492,23 @@ public final class SplashScreenView extends FrameLayout {
|
|||||||
}
|
}
|
||||||
IconAnimateListener aniDrawable = (IconAnimateListener) iconDrawable;
|
IconAnimateListener aniDrawable = (IconAnimateListener) iconDrawable;
|
||||||
aniDrawable.prepareAnimate(duration, this::animationStartCallback);
|
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() {
|
private void animationStartCallback() {
|
||||||
@@ -669,6 +691,12 @@ public final class SplashScreenView extends FrameLayout {
|
|||||||
* Stop animation.
|
* Stop animation.
|
||||||
*/
|
*/
|
||||||
void stopAnimation();
|
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) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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_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_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__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__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__USER_SWITCH;
|
||||||
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION;
|
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION;
|
||||||
@@ -173,6 +175,8 @@ public class InteractionJankMonitor {
|
|||||||
public static final int CUJ_PIP_TRANSITION = 35;
|
public static final int CUJ_PIP_TRANSITION = 35;
|
||||||
public static final int CUJ_WALLPAPER_TRANSITION = 36;
|
public static final int CUJ_WALLPAPER_TRANSITION = 36;
|
||||||
public static final int CUJ_USER_SWITCH = 37;
|
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;
|
private static final int NO_STATSD_LOGGING = -1;
|
||||||
|
|
||||||
@@ -219,6 +223,8 @@ public class InteractionJankMonitor {
|
|||||||
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__PIP_TRANSITION,
|
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__PIP_TRANSITION,
|
||||||
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION,
|
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__WALLPAPER_TRANSITION,
|
||||||
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__USER_SWITCH,
|
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;
|
private static volatile InteractionJankMonitor sInstance;
|
||||||
@@ -277,6 +283,8 @@ public class InteractionJankMonitor {
|
|||||||
CUJ_PIP_TRANSITION,
|
CUJ_PIP_TRANSITION,
|
||||||
CUJ_WALLPAPER_TRANSITION,
|
CUJ_WALLPAPER_TRANSITION,
|
||||||
CUJ_USER_SWITCH,
|
CUJ_USER_SWITCH,
|
||||||
|
CUJ_SPLASHSCREEN_AVD,
|
||||||
|
CUJ_SPLASHSCREEN_EXIT_ANIM,
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface CujType {
|
public @interface CujType {
|
||||||
@@ -672,6 +680,10 @@ public class InteractionJankMonitor {
|
|||||||
return "WALLPAPER_TRANSITION";
|
return "WALLPAPER_TRANSITION";
|
||||||
case CUJ_USER_SWITCH:
|
case CUJ_USER_SWITCH:
|
||||||
return "USER_SWITCH";
|
return "USER_SWITCH";
|
||||||
|
case CUJ_SPLASHSCREEN_AVD:
|
||||||
|
return "SPLASHSCREEN_AVD";
|
||||||
|
case CUJ_SPLASHSCREEN_EXIT_ANIM:
|
||||||
|
return "SPLASHSCREEN_EXIT_ANIM";
|
||||||
}
|
}
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ package com.android.wm.shell.startingsurface;
|
|||||||
import static android.view.Choreographer.CALLBACK_COMMIT;
|
import static android.view.Choreographer.CALLBACK_COMMIT;
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
|
|
||||||
|
import static com.android.internal.jank.InteractionJankMonitor.CUJ_SPLASHSCREEN_EXIT_ANIM;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -42,6 +44,7 @@ import android.view.animation.Interpolator;
|
|||||||
import android.view.animation.PathInterpolator;
|
import android.view.animation.PathInterpolator;
|
||||||
import android.window.SplashScreenView;
|
import android.window.SplashScreenView;
|
||||||
|
|
||||||
|
import com.android.internal.jank.InteractionJankMonitor;
|
||||||
import com.android.wm.shell.R;
|
import com.android.wm.shell.R;
|
||||||
import com.android.wm.shell.animation.Interpolators;
|
import com.android.wm.shell.animation.Interpolators;
|
||||||
import com.android.wm.shell.common.TransactionPool;
|
import com.android.wm.shell.common.TransactionPool;
|
||||||
@@ -311,17 +314,19 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationStart(Animator animation) {
|
public void onAnimationStart(Animator animation) {
|
||||||
// ignore
|
InteractionJankMonitor.getInstance().begin(mSplashScreenView, CUJ_SPLASHSCREEN_EXIT_ANIM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
reset();
|
reset();
|
||||||
|
InteractionJankMonitor.getInstance().end(CUJ_SPLASHSCREEN_EXIT_ANIM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationCancel(Animator animation) {
|
public void onAnimationCancel(Animator animation) {
|
||||||
reset();
|
reset();
|
||||||
|
InteractionJankMonitor.getInstance().cancel(CUJ_SPLASHSCREEN_EXIT_ANIM);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.wm.shell.startingsurface;
|
|||||||
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
|
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
import android.annotation.ColorInt;
|
import android.annotation.ColorInt;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
@@ -263,17 +264,23 @@ public class SplashscreenIconDrawableFactory {
|
|||||||
* A lightweight AdaptiveIconDrawable which support foreground to be Animatable, and keep this
|
* A lightweight AdaptiveIconDrawable which support foreground to be Animatable, and keep this
|
||||||
* drawable masked by config_icon_mask.
|
* drawable masked by config_icon_mask.
|
||||||
*/
|
*/
|
||||||
private static class AnimatableIconAnimateListener extends AdaptiveForegroundDrawable
|
public static class AnimatableIconAnimateListener extends AdaptiveForegroundDrawable
|
||||||
implements SplashScreenView.IconAnimateListener {
|
implements SplashScreenView.IconAnimateListener {
|
||||||
private Animatable mAnimatableIcon;
|
private Animatable mAnimatableIcon;
|
||||||
private Animator mIconAnimator;
|
private Animator mIconAnimator;
|
||||||
private boolean mAnimationTriggered;
|
private boolean mAnimationTriggered;
|
||||||
|
private AnimatorListenerAdapter mJankMonitoringListener;
|
||||||
|
|
||||||
AnimatableIconAnimateListener(@NonNull Drawable foregroundDrawable) {
|
AnimatableIconAnimateListener(@NonNull Drawable foregroundDrawable) {
|
||||||
super(foregroundDrawable);
|
super(foregroundDrawable);
|
||||||
mForegroundDrawable.setCallback(mCallback);
|
mForegroundDrawable.setCallback(mCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAnimationJankMonitoring(AnimatorListenerAdapter listener) {
|
||||||
|
mJankMonitoringListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean prepareAnimate(long duration, Runnable startListener) {
|
public boolean prepareAnimate(long duration, Runnable startListener) {
|
||||||
mAnimatableIcon = (Animatable) mForegroundDrawable;
|
mAnimatableIcon = (Animatable) mForegroundDrawable;
|
||||||
@@ -286,6 +293,9 @@ public class SplashscreenIconDrawableFactory {
|
|||||||
startListener.run();
|
startListener.run();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (mJankMonitoringListener != null) {
|
||||||
|
mJankMonitoringListener.onAnimationStart(animation);
|
||||||
|
}
|
||||||
mAnimatableIcon.start();
|
mAnimatableIcon.start();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.e(TAG, "Error while running the splash screen animated icon", ex);
|
Log.e(TAG, "Error while running the splash screen animated icon", ex);
|
||||||
@@ -296,11 +306,17 @@ public class SplashscreenIconDrawableFactory {
|
|||||||
@Override
|
@Override
|
||||||
public void onAnimationEnd(Animator animation) {
|
public void onAnimationEnd(Animator animation) {
|
||||||
mAnimatableIcon.stop();
|
mAnimatableIcon.stop();
|
||||||
|
if (mJankMonitoringListener != null) {
|
||||||
|
mJankMonitoringListener.onAnimationEnd(animation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAnimationCancel(Animator animation) {
|
public void onAnimationCancel(Animator animation) {
|
||||||
mAnimatableIcon.stop();
|
mAnimatableIcon.stop();
|
||||||
|
if (mJankMonitoringListener != null) {
|
||||||
|
mJankMonitoringListener.onAnimationCancel(animation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -316,6 +332,7 @@ public class SplashscreenIconDrawableFactory {
|
|||||||
public void stopAnimation() {
|
public void stopAnimation() {
|
||||||
if (mIconAnimator != null && mIconAnimator.isRunning()) {
|
if (mIconAnimator != null && mIconAnimator.isRunning()) {
|
||||||
mIconAnimator.end();
|
mIconAnimator.end();
|
||||||
|
mJankMonitoringListener = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user