From 1360612760a9a14207dd882dbf398ead4da3c321 Mon Sep 17 00:00:00 2001 From: Ahan Wu Date: Sun, 25 Oct 2020 11:53:45 +0000 Subject: [PATCH] Instrument CUJ for HUN and App launch from notification Use InteractionJankMonitor to instrument CUJs, including: - HUN appear / disappear - Notification add / remove - App launch from notification Bug: 169220845 Bug: 169740111 Test: Manually Change-Id: I88002f086b49cac15613e754985ab9a8be6bbd52 --- cmds/statsd/src/atoms.proto | 5 +++++ .../internal/jank/InteractionJankMonitor.java | 20 +++++++++++++++++++ .../notification/ActivityLaunchAnimator.java | 20 +++++++++++++++++++ .../row/ActivatableNotificationView.java | 17 ++++++++++++++++ 4 files changed, 62 insertions(+) diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 084959b5071ad..cdf87e9b9aaf0 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -5301,6 +5301,11 @@ message UIInteractionFrameInfoReported { LAUNCHER_APP_CLOSE_TO_HOME = 10; LAUNCHER_APP_CLOSE_TO_PIP = 11; LAUNCHER_QUICK_SWITCH = 12; + SHADE_HEADS_UP_APPEAR = 13; + SHADE_HEADS_UP_DISAPPEAR = 14; + SHADE_NOTIFICATION_ADD = 15; + SHADE_NOTIFICATION_REMOVE = 16; + SHADE_APP_LAUNCH = 17; } optional InteractionType interaction_type = 1; diff --git a/core/java/com/android/internal/jank/InteractionJankMonitor.java b/core/java/com/android/internal/jank/InteractionJankMonitor.java index 3624f0d347255..ec97520a689b8 100644 --- a/core/java/com/android/internal/jank/InteractionJankMonitor.java +++ b/core/java/com/android/internal/jank/InteractionJankMonitor.java @@ -22,7 +22,12 @@ import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_IN import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_LAUNCH_FROM_RECENTS; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_QUICK_SWITCH; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__NOTIFICATION_SHADE_SWIPE; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_APP_LAUNCH; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_EXPAND_COLLAPSE_LOCK; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_HEADS_UP_APPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_HEADS_UP_DISAPPEAR; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_NOTIFICATION_ADD; +import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_NOTIFICATION_REMOVE; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_QS_EXPAND_COLLAPSE; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_QS_SCROLL_SWIPE; import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_ROW_EXPAND; @@ -67,6 +72,11 @@ public class InteractionJankMonitor { public static final int CUJ_LAUNCHER_APP_CLOSE_TO_HOME = 9; public static final int CUJ_LAUNCHER_APP_CLOSE_TO_PIP = 10; public static final int CUJ_LAUNCHER_QUICK_SWITCH = 11; + public static final int CUJ_NOTIFICATION_HEADS_UP_APPEAR = 12; + public static final int CUJ_NOTIFICATION_HEADS_UP_DISAPPEAR = 13; + public static final int CUJ_NOTIFICATION_ADD = 14; + public static final int CUJ_NOTIFICATION_REMOVE = 15; + public static final int CUJ_NOTIFICATION_APP_START = 16; private static final int NO_STATSD_LOGGING = -1; @@ -87,6 +97,11 @@ public class InteractionJankMonitor { UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_CLOSE_TO_HOME, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_CLOSE_TO_PIP, UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_QUICK_SWITCH, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_HEADS_UP_APPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_HEADS_UP_DISAPPEAR, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_NOTIFICATION_ADD, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_NOTIFICATION_REMOVE, + UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_APP_LAUNCH, }; private static volatile InteractionJankMonitor sInstance; @@ -112,6 +127,11 @@ public class InteractionJankMonitor { CUJ_LAUNCHER_APP_CLOSE_TO_HOME, CUJ_LAUNCHER_APP_CLOSE_TO_PIP, CUJ_LAUNCHER_QUICK_SWITCH, + CUJ_NOTIFICATION_HEADS_UP_APPEAR, + CUJ_NOTIFICATION_HEADS_UP_DISAPPEAR, + CUJ_NOTIFICATION_ADD, + CUJ_NOTIFICATION_REMOVE, + CUJ_NOTIFICATION_APP_START, }) @Retention(RetentionPolicy.SOURCE) public @interface CujType {} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java index 382715a3fb77d..45e8098e71d3f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/ActivityLaunchAnimator.java @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification; +import static com.android.internal.jank.InteractionJankMonitor.CUJ_NOTIFICATION_APP_START; + import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; @@ -32,6 +34,7 @@ import android.view.SyncRtSurfaceTransactionApplier; import android.view.SyncRtSurfaceTransactionApplier.SurfaceParams; import android.view.View; +import com.android.internal.jank.InteractionJankMonitor; import com.android.internal.policy.ScreenDecorationsUtils; import com.android.systemui.Interpolators; import com.android.systemui.statusbar.NotificationShadeDepthController; @@ -226,10 +229,27 @@ public class ActivityLaunchAnimator { } }); anim.addListener(new AnimatorListenerAdapter() { + private boolean mWasCancelled; + + @Override + public void onAnimationStart(Animator animation) { + InteractionJankMonitor.getInstance().begin(CUJ_NOTIFICATION_APP_START); + } + + @Override + public void onAnimationCancel(Animator animation) { + mWasCancelled = true; + } + @Override public void onAnimationEnd(Animator animation) { setExpandAnimationRunning(false); invokeCallback(iRemoteAnimationFinishedCallback); + if (!mWasCancelled) { + InteractionJankMonitor.getInstance().end(CUJ_NOTIFICATION_APP_START); + } else { + InteractionJankMonitor.getInstance().cancel(CUJ_NOTIFICATION_APP_START); + } } }); anim.start(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index 094e8661d2623..10273cbbebad7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -33,6 +33,7 @@ import android.view.accessibility.AccessibilityManager; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; +import com.android.internal.jank.InteractionJankMonitor; import com.android.systemui.Gefingerpoken; import com.android.systemui.Interpolators; import com.android.systemui.R; @@ -750,12 +751,16 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView if (!mWasCancelled) { enableAppearDrawing(false); onAppearAnimationFinished(isAppearing); + InteractionJankMonitor.getInstance().end(getCujType(isAppearing)); + } else { + InteractionJankMonitor.getInstance().cancel(getCujType(isAppearing)); } } @Override public void onAnimationStart(Animator animation) { mWasCancelled = false; + InteractionJankMonitor.getInstance().begin(getCujType(isAppearing)); } @Override @@ -766,6 +771,18 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView mAppearAnimator.start(); } + private int getCujType(boolean isAppearing) { + if (mIsHeadsUpAnimation) { + return isAppearing + ? InteractionJankMonitor.CUJ_NOTIFICATION_HEADS_UP_APPEAR + : InteractionJankMonitor.CUJ_NOTIFICATION_HEADS_UP_DISAPPEAR; + } else { + return isAppearing + ? InteractionJankMonitor.CUJ_NOTIFICATION_ADD + : InteractionJankMonitor.CUJ_NOTIFICATION_REMOVE; + } + } + protected void onAppearAnimationFinished(boolean wasAppearing) { }