Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97f0fe27 authored by Ahan Wu's avatar Ahan Wu
Browse files

Instrument jank and latency of the unlock animation of lockscreen

Instrument jank and latency of unlock animation.

Bug: 169735612
Bug: 169735198
Bug: 169220953
Test: take trace to validate
Change-Id: I1721d7d3373f99b4aca618f86464d44ecd1e618e
parent c45abcf9
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_IN
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_PIN_DISAPPEAR;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_TRANSITION_FROM_AOD;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_TRANSITION_TO_AOD;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_UNLOCK_ANIMATION;
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__SETTINGS_PAGE_SCROLL;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SHADE_APP_LAUNCH;
@@ -150,6 +151,7 @@ public class InteractionJankMonitor {
    public static final int CUJ_LAUNCHER_ALL_APPS_SCROLL = 26;
    public static final int CUJ_LAUNCHER_APP_LAUNCH_FROM_WIDGET = 27;
    public static final int CUJ_SETTINGS_PAGE_SCROLL = 28;
    public static final int CUJ_LOCKSCREEN_UNLOCK_ANIMATION = 29;

    private static final int NO_STATSD_LOGGING = -1;

@@ -187,6 +189,7 @@ public class InteractionJankMonitor {
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_ALL_APPS_SCROLL,
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LAUNCHER_APP_LAUNCH_FROM_WIDGET,
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SETTINGS_PAGE_SCROLL,
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_UNLOCK_ANIMATION,
    };

    private static volatile InteractionJankMonitor sInstance;
@@ -235,6 +238,7 @@ public class InteractionJankMonitor {
            CUJ_LAUNCHER_ALL_APPS_SCROLL,
            CUJ_LAUNCHER_APP_LAUNCH_FROM_WIDGET,
            CUJ_SETTINGS_PAGE_SCROLL,
            CUJ_LOCKSCREEN_UNLOCK_ANIMATION,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface CujType {
@@ -548,29 +552,31 @@ public class InteractionJankMonitor {
            case CUJ_NOTIFICATION_APP_START:
                return "NOTIFICATION_APP_START";
            case CUJ_LOCKSCREEN_PASSWORD_APPEAR:
                return "CUJ_LOCKSCREEN_PASSWORD_APPEAR";
                return "LOCKSCREEN_PASSWORD_APPEAR";
            case CUJ_LOCKSCREEN_PATTERN_APPEAR:
                return "CUJ_LOCKSCREEN_PATTERN_APPEAR";
                return "LOCKSCREEN_PATTERN_APPEAR";
            case CUJ_LOCKSCREEN_PIN_APPEAR:
                return "CUJ_LOCKSCREEN_PIN_APPEAR";
                return "LOCKSCREEN_PIN_APPEAR";
            case CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR:
                return "CUJ_LOCKSCREEN_PASSWORD_DISAPPEAR";
                return "LOCKSCREEN_PASSWORD_DISAPPEAR";
            case CUJ_LOCKSCREEN_PATTERN_DISAPPEAR:
                return "CUJ_LOCKSCREEN_PATTERN_DISAPPEAR";
                return "LOCKSCREEN_PATTERN_DISAPPEAR";
            case CUJ_LOCKSCREEN_PIN_DISAPPEAR:
                return "CUJ_LOCKSCREEN_PIN_DISAPPEAR";
                return "LOCKSCREEN_PIN_DISAPPEAR";
            case CUJ_LOCKSCREEN_TRANSITION_FROM_AOD:
                return "CUJ_LOCKSCREEN_TRANSITION_FROM_AOD";
                return "LOCKSCREEN_TRANSITION_FROM_AOD";
            case CUJ_LOCKSCREEN_TRANSITION_TO_AOD:
                return "CUJ_LOCKSCREEN_TRANSITION_TO_AOD";
                return "LOCKSCREEN_TRANSITION_TO_AOD";
            case CUJ_LAUNCHER_OPEN_ALL_APPS :
                return "CUJ_LAUNCHER_OPEN_ALL_APPS";
                return "LAUNCHER_OPEN_ALL_APPS";
            case CUJ_LAUNCHER_ALL_APPS_SCROLL:
                return "CUJ_LAUNCHER_ALL_APPS_SCROLL";
                return "LAUNCHER_ALL_APPS_SCROLL";
            case CUJ_LAUNCHER_APP_LAUNCH_FROM_WIDGET:
                return "LAUNCHER_APP_LAUNCH_FROM_WIDGET";
            case CUJ_SETTINGS_PAGE_SCROLL:
                return "SETTINGS_PAGE_SCROLL";
            case CUJ_LOCKSCREEN_UNLOCK_ANIMATION:
                return "LOCKSCREEN_UNLOCK_ANIMATION";
        }
        return "UNKNOWN";
    }
+13 −3
Original line number Diff line number Diff line
@@ -105,6 +105,11 @@ public class LatencyTracker {
     */
    public static final int ACTION_ROTATE_SCREEN_CAMERA_CHECK = 10;

    /**
     * Time it takes to start unlock animation .
     */
    public static final int ACTION_LOCKSCREEN_UNLOCK = 11;

    private static final int[] ACTIONS_ALL = {
        ACTION_EXPAND_PANEL,
        ACTION_TOGGLE_RECENTS,
@@ -116,7 +121,8 @@ public class LatencyTracker {
        ACTION_FACE_WAKE_AND_UNLOCK,
        ACTION_START_RECENTS_ANIMATION,
        ACTION_ROTATE_SCREEN_SENSOR,
        ACTION_ROTATE_SCREEN_CAMERA_CHECK
        ACTION_ROTATE_SCREEN_CAMERA_CHECK,
        ACTION_LOCKSCREEN_UNLOCK
    };

    /** @hide */
@@ -131,7 +137,8 @@ public class LatencyTracker {
        ACTION_FACE_WAKE_AND_UNLOCK,
        ACTION_START_RECENTS_ANIMATION,
        ACTION_ROTATE_SCREEN_SENSOR,
        ACTION_ROTATE_SCREEN_CAMERA_CHECK
        ACTION_ROTATE_SCREEN_CAMERA_CHECK,
        ACTION_LOCKSCREEN_UNLOCK
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Action {
@@ -148,7 +155,8 @@ public class LatencyTracker {
            FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_FACE_WAKE_AND_UNLOCK,
            FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_START_RECENTS_ANIMATION,
            FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_SENSOR,
            FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_CAMERA_CHECK
            FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_ROTATE_SCREEN_CAMERA_CHECK,
            FrameworkStatsLog.UIACTION_LATENCY_REPORTED__ACTION__ACTION_LOCKSCREEN_UNLOCK
    };

    private static LatencyTracker sLatencyTracker;
@@ -229,6 +237,8 @@ public class LatencyTracker {
                return "ACTION_ROTATE_SCREEN_CAMERA_CHECK";
            case 11:
                return "ACTION_ROTATE_SCREEN_SENSOR";
            case 12:
                return "ACTION_LOCKSCREEN_UNLOCK";
            default:
                throw new IllegalArgumentException("Invalid action");
        }
+1 −0
Original line number Diff line number Diff line
@@ -172,6 +172,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
            getKeyguardSecurityCallback().reportUnlockAttempt(userId, true, 0);
            if (dismissKeyguard) {
                mDismissing = true;
                mLatencyTracker.onActionStart(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);
                getKeyguardSecurityCallback().dismiss(true, userId);
            }
        } else {
+1 −0
Original line number Diff line number Diff line
@@ -163,6 +163,7 @@ public class KeyguardPatternViewController
                getKeyguardSecurityCallback().reportUnlockAttempt(userId, true, 0);
                if (dismissKeyguard) {
                    mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
                    mLatencyTracker.onActionStart(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);
                    getKeyguardSecurityCallback().dismiss(true, userId);
                }
            } else {
+30 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
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_UNLOCK_ANIMATION;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.SOME_AUTH_REQUIRED_AFTER_USER_REQUEST;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_DPM_LOCK_NOW;
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_LOCKOUT;
@@ -82,6 +83,8 @@ import android.view.WindowManagerPolicyConstants;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.jank.InteractionJankMonitor.Configuration;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IKeyguardDrawnCallback;
import com.android.internal.policy.IKeyguardExitCallback;
@@ -2154,6 +2157,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
                playSounds(false);
            }

            LatencyTracker.getInstance(mContext)
                    .onActionEnd(LatencyTracker.ACTION_LOCKSCREEN_UNLOCK);

            IRemoteAnimationRunner runner = mKeyguardExitAnimationRunner;
            mKeyguardExitAnimationRunner = null;

@@ -2168,6 +2174,8 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
                                onKeyguardExitFinished();
                                mKeyguardViewControllerLazy.get().hide(0 /* startTime */,
                                        0 /* fadeoutDuration */);
                                InteractionJankMonitor.getInstance()
                                        .end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
                            }

                            @Override
@@ -2176,6 +2184,8 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
                            }
                        };
                try {
                    InteractionJankMonitor.getInstance().begin(
                            createInteractionJankMonitorConf("RunRemoteAnimation"));
                    runner.onAnimationStart(WindowManager.TRANSIT_KEYGUARD_GOING_AWAY, apps,
                            wallpapers, nonApps, callback);
                } catch (RemoteException e) {
@@ -2190,10 +2200,16 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
                mSurfaceBehindRemoteAnimationFinishedCallback = finishedCallback;
                mSurfaceBehindRemoteAnimationRunning = true;

                InteractionJankMonitor.getInstance().begin(
                        createInteractionJankMonitorConf("DismissPanel"));

                // Pass the surface and metadata to the unlock animation controller.
                mKeyguardUnlockAnimationControllerLazy.get().notifyStartKeyguardExitAnimation(
                        apps[0], startTime, mSurfaceBehindRemoteAnimationRequested);
            } else {
                InteractionJankMonitor.getInstance().begin(
                        createInteractionJankMonitorConf("RemoteAnimationDisabled"));

                mKeyguardViewControllerLazy.get().hide(startTime, fadeoutDuration);

                // TODO(bc-animation): When remote animation is enabled for keyguard exit animation,
@@ -2201,6 +2217,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
                // supported, so it's always null.
                mContext.getMainExecutor().execute(() -> {
                    if (finishedCallback == null) {
                        InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
                        return;
                    }

@@ -2227,6 +2244,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
                                finishedCallback.onAnimationFinished();
                            } catch (RemoteException e) {
                                Slog.e(TAG, "RemoteException");
                            } finally {
                                InteractionJankMonitor.getInstance()
                                        .end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
                            }
                        }

@@ -2236,6 +2256,9 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
                                finishedCallback.onAnimationFinished();
                            } catch (RemoteException e) {
                                Slog.e(TAG, "RemoteException");
                            } finally {
                                InteractionJankMonitor.getInstance()
                                        .cancel(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
                            }
                        }
                    });
@@ -2259,6 +2282,12 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
        sendUserPresentBroadcast();
    }

    private Configuration.Builder createInteractionJankMonitorConf(String tag) {
        return new Configuration.Builder(CUJ_LOCKSCREEN_UNLOCK_ANIMATION)
                .setView(mKeyguardViewControllerLazy.get().getViewRootImpl().getView())
                .setTag(tag);
    }

    /**
     * Whether we're currently animating between the keyguard and the app/launcher surface behind
     * it, or will be shortly (which happens if we started a fling to dismiss the keyguard).
@@ -2304,6 +2333,7 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable,
        finishSurfaceBehindRemoteAnimation();
        mSurfaceBehindRemoteAnimationRequested = false;
        mKeyguardUnlockAnimationControllerLazy.get().notifyFinishedKeyguardExitAnimation();
        InteractionJankMonitor.getInstance().end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
    }

    /**