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

Commit 6cd4a43d authored by Wu Ahan's avatar Wu Ahan Committed by Automerger Merge Worker
Browse files

Merge "Instrument jank of CUJ take screen shot" into tm-dev am: 009099e8 am:...

Merge "Instrument jank of CUJ take screen shot" into tm-dev am: 009099e8 am: 75073ffa am: c372e264

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17729988



Change-Id: I9e8bbb4d7dbe6af617a5f9a8bad41c02d305ea62
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 2cfbae43 c372e264
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_IN
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SUW_LOADING_TO_NEXT_FLOW;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SUW_LOADING_TO_SHOW_INFO_WITH_ACTIONS;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SUW_SHOW_FUNCTION_SCREEN_WITH_ACTIONS;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__TAKE_SCREENSHOT;
import static com.android.internal.util.FrameworkStatsLog.UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__UNFOLD_ANIM;
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;
@@ -194,6 +195,7 @@ public class InteractionJankMonitor {
    public static final int CUJ_LOCKSCREEN_LAUNCH_CAMERA = 51; // reserved.
    public static final int CUJ_SPLIT_SCREEN_RESIZE = 52;
    public static final int CUJ_SETTINGS_SLIDER = 53;
    public static final int CUJ_TAKE_SCREENSHOT = 54;

    private static final int NO_STATSD_LOGGING = -1;

@@ -256,6 +258,7 @@ public class InteractionJankMonitor {
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__LOCKSCREEN_LAUNCH_CAMERA,
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SPLIT_SCREEN_RESIZE,
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__SETTINGS_SLIDER,
            UIINTERACTION_FRAME_INFO_REPORTED__INTERACTION_TYPE__TAKE_SCREENSHOT,
    };

    private static volatile InteractionJankMonitor sInstance;
@@ -330,6 +333,7 @@ public class InteractionJankMonitor {
            CUJ_LOCKSCREEN_LAUNCH_CAMERA,
            CUJ_SPLIT_SCREEN_RESIZE,
            CUJ_SETTINGS_SLIDER,
            CUJ_TAKE_SCREENSHOT,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface CujType {
@@ -756,6 +760,8 @@ public class InteractionJankMonitor {
                return "CUJ_SPLIT_SCREEN_RESIZE";
            case CUJ_SETTINGS_SLIDER:
                return "SETTINGS_SLIDER";
            case CUJ_TAKE_SCREENSHOT:
                return "TAKE_SCREENSHOT";
        }
        return "UNKNOWN";
    }
+1 −0
Original line number Diff line number Diff line
@@ -484,6 +484,7 @@ public class ScreenshotController {
                setWindowFocusable(false);
            }
        });
        mScreenshotView.setDefaultTimeoutMillis(mScreenshotHandler.getDefaultTimeoutMillis());

        mScreenshotView.setOnKeyListener((v, keyCode, event) -> {
            if (keyCode == KeyEvent.KEYCODE_BACK) {
+54 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.screenshot;

import static android.content.res.Configuration.ORIENTATION_PORTRAIT;

import static com.android.internal.jank.InteractionJankMonitor.CUJ_TAKE_SCREENSHOT;
import static com.android.systemui.screenshot.LogConfig.DEBUG_ANIM;
import static com.android.systemui.screenshot.LogConfig.DEBUG_DISMISS;
import static com.android.systemui.screenshot.LogConfig.DEBUG_INPUT;
@@ -83,6 +84,7 @@ import android.widget.LinearLayout;

import androidx.constraintlayout.widget.ConstraintLayout;

import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.R;
import com.android.systemui.screenshot.ScreenshotController.SavedImageData.ActionTransition;
@@ -166,6 +168,9 @@ public class ScreenshotView extends FrameLayout implements
    private final ArrayList<OverlayActionChip> mSmartChips = new ArrayList<>();
    private PendingInteraction mPendingInteraction;

    private final InteractionJankMonitor mInteractionJankMonitor;
    private long mDefaultTimeoutOfTimeoutHandler;

    private enum PendingInteraction {
        PREVIEW,
        EDIT,
@@ -189,6 +194,7 @@ public class ScreenshotView extends FrameLayout implements
            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        mResources = mContext.getResources();
        mInteractionJankMonitor = getInteractionJankMonitorInstance();

        mFixedSize = mResources.getDimensionPixelSize(R.dimen.overlay_x_scale);

@@ -229,6 +235,14 @@ public class ScreenshotView extends FrameLayout implements
        });
    }

    private InteractionJankMonitor getInteractionJankMonitorInstance() {
        return InteractionJankMonitor.getInstance();
    }

    void setDefaultTimeoutMillis(long timeout) {
        mDefaultTimeoutOfTimeoutHandler = timeout;
    }

    public void hideScrollChip() {
        mScrollChip.setVisibility(View.GONE);
    }
@@ -395,6 +409,9 @@ public class ScreenshotView extends FrameLayout implements

            @Override
            public void onDismissComplete() {
                if (mInteractionJankMonitor.isInstrumenting(CUJ_TAKE_SCREENSHOT)) {
                    mInteractionJankMonitor.end(CUJ_TAKE_SCREENSHOT);
                }
                mCallbacks.onDismiss();
            }
        });
@@ -594,6 +611,20 @@ public class ScreenshotView extends FrameLayout implements
        dropInAnimation.play(borderFadeIn).after(toCorner);

        dropInAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                mInteractionJankMonitor.cancel(CUJ_TAKE_SCREENSHOT);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                InteractionJankMonitor.Configuration.Builder builder =
                        InteractionJankMonitor.Configuration.Builder.withView(
                                CUJ_TAKE_SCREENSHOT, mScreenshotPreview)
                                .setTag("DropIn");
                mInteractionJankMonitor.begin(builder);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (DEBUG_ANIM) {
@@ -620,7 +651,7 @@ public class ScreenshotView extends FrameLayout implements
                mScreenshotPreview.setX(finalPos.x - mScreenshotPreview.getWidth() / 2f);
                mScreenshotPreview.setY(finalPos.y - mScreenshotPreview.getHeight() / 2f);
                requestLayout();

                mInteractionJankMonitor.end(CUJ_TAKE_SCREENSHOT);
                createScreenshotActionsShadeAnimation().start();
            }
        });
@@ -691,6 +722,28 @@ public class ScreenshotView extends FrameLayout implements
        mActionsContainer.setVisibility(View.VISIBLE);
        mActionsContainerBackground.setVisibility(View.VISIBLE);

        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationCancel(Animator animation) {
                mInteractionJankMonitor.cancel(CUJ_TAKE_SCREENSHOT);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mInteractionJankMonitor.end(CUJ_TAKE_SCREENSHOT);
            }

            @Override
            public void onAnimationStart(Animator animation) {
                InteractionJankMonitor.Configuration.Builder builder =
                        InteractionJankMonitor.Configuration.Builder.withView(
                                CUJ_TAKE_SCREENSHOT, mScreenshotStatic)
                                .setTag("Actions")
                                .setTimeout(mDefaultTimeoutOfTimeoutHandler);
                mInteractionJankMonitor.begin(builder);
            }
        });

        animator.addUpdateListener(animation -> {
            float t = animation.getAnimatedFraction();
            float containerAlpha = t < alphaFraction ? t / alphaFraction : 1;
+4 −0
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ public class TimeoutHandler extends Handler {
        mDefaultTimeout = timeout;
    }

    int getDefaultTimeoutMillis() {
        return mDefaultTimeout;
    }

    /**
     * Cancel the current timeout, if any. To reset the delayed runnable use resetTimeout instead.
     */