Add jank instrumentation for occlude/unocclude/launcher unlock.

Fixes: 241195239
Test: grab a trace
Change-Id: If9af9aa95ddff26c9baf5101fb5aa45389e532eb
This commit is contained in:
Josh Tsuji
2022-08-11 17:02:54 -04:00
parent 9958359ced
commit 64a3f7394a
3 changed files with 46 additions and 8 deletions

View File

@@ -29,7 +29,9 @@ 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_WIDGET;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_OPEN_ALL_APPS;
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__LAUNCHER_UNLOCK_ENTRANCE_ANIMATION;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_LAUNCH_CAMERA;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_OCCLUSION;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PASSWORD_APPEAR;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PASSWORD_DISAPPEAR;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PATTERN_APPEAR;
@@ -219,6 +221,8 @@ public class InteractionJankMonitor {
public static final int CUJ_TASKBAR_EXPAND = 60;
public static final int CUJ_TASKBAR_COLLAPSE = 61;
public static final int CUJ_SHADE_CLEAR_ALL = 62;
public static final int CUJ_LAUNCHER_UNLOCK_ENTRANCE_ANIMATION = 63;
public static final int CUJ_LOCKSCREEN_OCCLUSION = 64;
private static final int NO_STATSD_LOGGING = -1;
@@ -290,6 +294,8 @@ public class InteractionJankMonitor {
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__TASKBAR_EXPAND,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__TASKBAR_COLLAPSE,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_CLEAR_ALL,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_UNLOCK_ENTRANCE_ANIMATION,
UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_OCCLUSION,
};
private static volatile InteractionJankMonitor sInstance;
@@ -372,7 +378,9 @@ public class InteractionJankMonitor {
CUJ_USER_DIALOG_OPEN,
CUJ_TASKBAR_EXPAND,
CUJ_TASKBAR_COLLAPSE,
CUJ_SHADE_CLEAR_ALL
CUJ_SHADE_CLEAR_ALL,
CUJ_LAUNCHER_UNLOCK_ENTRANCE_ANIMATION,
CUJ_LOCKSCREEN_OCCLUSION
})
@Retention(RetentionPolicy.SOURCE)
public @interface CujType {
@@ -864,6 +872,10 @@ public class InteractionJankMonitor {
return "TASKBAR_COLLAPSE";
case CUJ_SHADE_CLEAR_ALL:
return "SHADE_CLEAR_ALL";
case CUJ_LAUNCHER_UNLOCK_ENTRANCE_ANIMATION:
return "LAUNCHER_UNLOCK_ENTRANCE_ANIMATION";
case CUJ_LOCKSCREEN_OCCLUSION:
return "LOCKSCREEN_OCCLUSION";
}
return "UNKNOWN";
}

View File

@@ -49,6 +49,8 @@ public final class InteractionJankMonitorWrapper {
InteractionJankMonitor.CUJ_LAUNCHER_APP_LAUNCH_FROM_WIDGET;
public static final int CUJ_SPLIT_SCREEN_ENTER =
InteractionJankMonitor.CUJ_SPLIT_SCREEN_ENTER;
public static final int CUJ_LAUNCHER_UNLOCK_ENTRANCE_ANIMATION =
InteractionJankMonitor.CUJ_LAUNCHER_UNLOCK_ENTRANCE_ANIMATION;
@IntDef({
CUJ_APP_LAUNCH_FROM_RECENTS,
@@ -57,6 +59,7 @@ public final class InteractionJankMonitorWrapper {
CUJ_APP_CLOSE_TO_PIP,
CUJ_QUICK_SWITCH,
CUJ_APP_LAUNCH_FROM_WIDGET,
CUJ_LAUNCHER_UNLOCK_ENTRANCE_ANIMATION
})
@Retention(RetentionPolicy.SOURCE)
public @interface CujType {

View File

@@ -22,6 +22,7 @@ import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.NAV_BAR_HANDLE_SHOW_OVER_LOCKSCREEN;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_OCCLUSION;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_TRANSITION_FROM_AOD;
import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_UNLOCK_ANIMATION;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_TRUSTAGENT_EXPIRED;
@@ -845,6 +846,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
if (launchIsFullScreen) {
mCentralSurfaces.instantCollapseNotificationPanel();
}
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_OCCLUSION);
}
@NonNull
@@ -991,6 +994,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
setOccluded(isKeyguardOccluded /* isOccluded */, false /* animate */);
Log.d(TAG, "Unocclude animation cancelled. Occluded state is now: "
+ mOccluded);
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION);
}
@Override
@@ -999,6 +1004,9 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
RemoteAnimationTarget[] nonApps,
IRemoteAnimationFinishedCallback finishedCallback) throws RemoteException {
Log.d(TAG, "UnoccludeAnimator#onAnimationStart. Set occluded = false.");
mInteractionJankMonitor.begin(
createInteractionJankMonitorConf(CUJ_LOCKSCREEN_OCCLUSION)
.setTag("UNOCCLUDE"));
setOccluded(false /* isOccluded */, true /* animate */);
if (apps == null || apps.length == 0 || apps[0] == null) {
@@ -1057,6 +1065,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
try {
finishedCallback.onAnimationFinished();
mUnoccludeAnimator = null;
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_OCCLUSION);
} catch (RemoteException e) {
e.printStackTrace();
}
@@ -2573,7 +2583,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
};
try {
mInteractionJankMonitor.begin(
createInteractionJankMonitorConf("RunRemoteAnimation"));
createInteractionJankMonitorConf(
CUJ_LOCKSCREEN_UNLOCK_ANIMATION, "RunRemoteAnimation"));
runner.onAnimationStart(WindowManager.TRANSIT_KEYGUARD_GOING_AWAY, apps,
wallpapers, nonApps, callback);
} catch (RemoteException e) {
@@ -2589,7 +2600,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
mSurfaceBehindRemoteAnimationRunning = true;
mInteractionJankMonitor.begin(
createInteractionJankMonitorConf("DismissPanel"));
createInteractionJankMonitorConf(
CUJ_LOCKSCREEN_UNLOCK_ANIMATION, "DismissPanel"));
// Pass the surface and metadata to the unlock animation controller.
mKeyguardUnlockAnimationControllerLazy.get()
@@ -2597,7 +2609,8 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
apps, startTime, mSurfaceBehindRemoteAnimationRequested);
} else {
mInteractionJankMonitor.begin(
createInteractionJankMonitorConf("RemoteAnimationDisabled"));
createInteractionJankMonitorConf(
CUJ_LOCKSCREEN_UNLOCK_ANIMATION, "RemoteAnimationDisabled"));
mKeyguardViewControllerLazy.get().hide(startTime, fadeoutDuration);
@@ -2677,10 +2690,15 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
sendUserPresentBroadcast();
}
private Configuration.Builder createInteractionJankMonitorConf(String tag) {
return Configuration.Builder.withView(CUJ_LOCKSCREEN_UNLOCK_ANIMATION,
mKeyguardViewControllerLazy.get().getViewRootImpl().getView())
.setTag(tag);
private Configuration.Builder createInteractionJankMonitorConf(int cuj) {
return createInteractionJankMonitorConf(cuj, null /* tag */);
}
private Configuration.Builder createInteractionJankMonitorConf(int cuj, @Nullable String tag) {
final Configuration.Builder builder = Configuration.Builder.withView(
cuj, mKeyguardViewControllerLazy.get().getViewRootImpl().getView());
return tag != null ? builder.setTag(tag) : builder;
}
/**
@@ -3291,6 +3309,10 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
IRemoteAnimationFinishedCallback finishedCallback) throws RemoteException {
super.onAnimationStart(transit, apps, wallpapers, nonApps, finishedCallback);
mInteractionJankMonitor.begin(
createInteractionJankMonitorConf(CUJ_LOCKSCREEN_OCCLUSION)
.setTag("OCCLUDE"));
// This is the first signal we have from WM that we're going to be occluded. Set our
// internal state to reflect that immediately, vs. waiting for the launch animator to
// begin. Otherwise, calls to setShowingLocked, etc. will not know that we're about to
@@ -3307,6 +3329,7 @@ public class KeyguardViewMediator extends CoreStartable implements Dumpable,
+ "Setting occluded state to: " + isKeyguardOccluded);
setOccluded(isKeyguardOccluded /* occluded */, false /* animate */);
mInteractionJankMonitor.cancel(CUJ_LOCKSCREEN_OCCLUSION);
}
}
}