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

Commit f88195c2 authored by Mark Renouf's avatar Mark Renouf Committed by Android (Google) Code Review
Browse files

Merge changes from topic "screenshots_logs" into sc-qpr1-dev

* changes:
  Log additional UiEvents for long screenshots, include packageName
  requestScrollCapture: provide package name on exception
  Return packageName to scroll capture requests from SysUI
parents 2ac8e599 66aa586b
Loading
Loading
Loading
Loading
+42 −7
Original line number Diff line number Diff line
@@ -53,6 +53,10 @@ public class ScrollCaptureResponse implements Parcelable {
    @Nullable
    private String mWindowTitle = null;

    /** The package which owns the window. */
    @Nullable
    private String mPackageName = null;

    /** Carries additional logging and debugging information when enabled. */
    @NonNull
    @DataClass.PluralOf("message")
@@ -77,7 +81,7 @@ public class ScrollCaptureResponse implements Parcelable {



    // Code below generated by codegen v1.0.22.
    // Code below generated by codegen v1.0.23.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
@@ -97,6 +101,7 @@ public class ScrollCaptureResponse implements Parcelable {
            @Nullable Rect windowBounds,
            @Nullable Rect boundsInWindow,
            @Nullable String windowTitle,
            @Nullable String packageName,
            @NonNull ArrayList<String> messages) {
        this.mDescription = description;
        com.android.internal.util.AnnotationValidations.validate(
@@ -105,6 +110,7 @@ public class ScrollCaptureResponse implements Parcelable {
        this.mWindowBounds = windowBounds;
        this.mBoundsInWindow = boundsInWindow;
        this.mWindowTitle = windowTitle;
        this.mPackageName = packageName;
        this.mMessages = messages;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mMessages);
@@ -152,6 +158,14 @@ public class ScrollCaptureResponse implements Parcelable {
        return mWindowTitle;
    }

    /**
     * The package name of the process the window is owned by.
     */
    @DataClass.Generated.Member
    public @Nullable String getPackageName() {
        return mPackageName;
    }

    /**
     * Carries additional logging and debugging information when enabled.
     */
@@ -172,6 +186,7 @@ public class ScrollCaptureResponse implements Parcelable {
                "windowBounds = " + mWindowBounds + ", " +
                "boundsInWindow = " + mBoundsInWindow + ", " +
                "windowTitle = " + mWindowTitle + ", " +
                "packageName = " + mPackageName + ", " +
                "messages = " + mMessages +
        " }";
    }
@@ -187,12 +202,14 @@ public class ScrollCaptureResponse implements Parcelable {
        if (mWindowBounds != null) flg |= 0x4;
        if (mBoundsInWindow != null) flg |= 0x8;
        if (mWindowTitle != null) flg |= 0x10;
        if (mPackageName != null) flg |= 0x20;
        dest.writeByte(flg);
        dest.writeString(mDescription);
        if (mConnection != null) dest.writeStrongInterface(mConnection);
        if (mWindowBounds != null) dest.writeTypedObject(mWindowBounds, flags);
        if (mBoundsInWindow != null) dest.writeTypedObject(mBoundsInWindow, flags);
        if (mWindowTitle != null) dest.writeString(mWindowTitle);
        if (mPackageName != null) dest.writeString(mPackageName);
        dest.writeStringList(mMessages);
    }

@@ -213,6 +230,7 @@ public class ScrollCaptureResponse implements Parcelable {
        Rect windowBounds = (flg & 0x4) == 0 ? null : (Rect) in.readTypedObject(Rect.CREATOR);
        Rect boundsInWindow = (flg & 0x8) == 0 ? null : (Rect) in.readTypedObject(Rect.CREATOR);
        String windowTitle = (flg & 0x10) == 0 ? null : in.readString();
        String packageName = (flg & 0x20) == 0 ? null : in.readString();
        ArrayList<String> messages = new ArrayList<>();
        in.readStringList(messages);

@@ -223,6 +241,7 @@ public class ScrollCaptureResponse implements Parcelable {
        this.mWindowBounds = windowBounds;
        this.mBoundsInWindow = boundsInWindow;
        this.mWindowTitle = windowTitle;
        this.mPackageName = packageName;
        this.mMessages = messages;
        com.android.internal.util.AnnotationValidations.validate(
                NonNull.class, null, mMessages);
@@ -256,6 +275,7 @@ public class ScrollCaptureResponse implements Parcelable {
        private @Nullable Rect mWindowBounds;
        private @Nullable Rect mBoundsInWindow;
        private @Nullable String mWindowTitle;
        private @Nullable String mPackageName;
        private @NonNull ArrayList<String> mMessages;

        private long mBuilderFieldsSet = 0L;
@@ -318,13 +338,24 @@ public class ScrollCaptureResponse implements Parcelable {
            return this;
        }

        /**
         * The package name of the process the window is owned by.
         */
        @DataClass.Generated.Member
        public @NonNull Builder setPackageName(@NonNull String value) {
            checkNotUsed();
            mBuilderFieldsSet |= 0x20;
            mPackageName = value;
            return this;
        }

        /**
         * Carries additional logging and debugging information when enabled.
         */
        @DataClass.Generated.Member
        public @NonNull Builder setMessages(@NonNull ArrayList<String> value) {
            checkNotUsed();
            mBuilderFieldsSet |= 0x20;
            mBuilderFieldsSet |= 0x40;
            mMessages = value;
            return this;
        }
@@ -340,7 +371,7 @@ public class ScrollCaptureResponse implements Parcelable {
        /** Builds the instance. This builder should not be touched after calling this! */
        public @NonNull ScrollCaptureResponse build() {
            checkNotUsed();
            mBuilderFieldsSet |= 0x40; // Mark builder used
            mBuilderFieldsSet |= 0x80; // Mark builder used

            if ((mBuilderFieldsSet & 0x1) == 0) {
                mDescription = "";
@@ -358,6 +389,9 @@ public class ScrollCaptureResponse implements Parcelable {
                mWindowTitle = null;
            }
            if ((mBuilderFieldsSet & 0x20) == 0) {
                mPackageName = null;
            }
            if ((mBuilderFieldsSet & 0x40) == 0) {
                mMessages = new ArrayList<>();
            }
            ScrollCaptureResponse o = new ScrollCaptureResponse(
@@ -366,12 +400,13 @@ public class ScrollCaptureResponse implements Parcelable {
                    mWindowBounds,
                    mBoundsInWindow,
                    mWindowTitle,
                    mPackageName,
                    mMessages);
            return o;
        }

        private void checkNotUsed() {
            if ((mBuilderFieldsSet & 0x40) != 0) {
            if ((mBuilderFieldsSet & 0x80) != 0) {
                throw new IllegalStateException(
                        "This Builder should not be reused. Use a new Builder instance instead");
            }
@@ -379,10 +414,10 @@ public class ScrollCaptureResponse implements Parcelable {
    }

    @DataClass.Generated(
            time = 1614833185795L,
            codegenVersion = "1.0.22",
            time = 1628630366187L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/view/ScrollCaptureResponse.java",
            inputSignatures = "private @android.annotation.NonNull java.lang.String mDescription\nprivate @android.annotation.Nullable @com.android.internal.util.DataClass.MaySetToNull android.view.IScrollCaptureConnection mConnection\nprivate @android.annotation.Nullable android.graphics.Rect mWindowBounds\nprivate @android.annotation.Nullable android.graphics.Rect mBoundsInWindow\nprivate @android.annotation.Nullable java.lang.String mWindowTitle\nprivate @android.annotation.NonNull @com.android.internal.util.DataClass.PluralOf(\"message\") java.util.ArrayList<java.lang.String> mMessages\npublic  boolean isConnected()\npublic  void close()\nclass ScrollCaptureResponse extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genGetters=true)")
            inputSignatures = "private @android.annotation.NonNull java.lang.String mDescription\nprivate @android.annotation.Nullable @com.android.internal.util.DataClass.MaySetToNull android.view.IScrollCaptureConnection mConnection\nprivate @android.annotation.Nullable android.graphics.Rect mWindowBounds\nprivate @android.annotation.Nullable android.graphics.Rect mBoundsInWindow\nprivate @android.annotation.Nullable java.lang.String mWindowTitle\nprivate @android.annotation.Nullable java.lang.String mPackageName\nprivate @android.annotation.NonNull @com.android.internal.util.DataClass.PluralOf(\"message\") java.util.ArrayList<java.lang.String> mMessages\npublic  boolean isConnected()\npublic  void close()\nclass ScrollCaptureResponse extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genGetters=true)")
    @Deprecated
    private void __metadata() {}

+1 −0
Original line number Diff line number Diff line
@@ -9493,6 +9493,7 @@ public final class ViewRootImpl implements ViewParent,

        ScrollCaptureResponse.Builder response = new ScrollCaptureResponse.Builder();
        response.setWindowTitle(getTitle().toString());
        response.setPackageName(mContext.getPackageName());

        StringWriter writer =  new StringWriter();
        IndentingPrintWriter pw = new IndentingPrintWriter(writer);
+1 −1
Original line number Diff line number Diff line
@@ -660,7 +660,7 @@ public class ScreenshotController {
                    + mLastScrollCaptureResponse.getWindowTitle() + "]");

            final ScrollCaptureResponse response = mLastScrollCaptureResponse;
            mScreenshotView.showScrollChip(/* onClick */ () -> {
            mScreenshotView.showScrollChip(response.getPackageName(), /* onClick */ () -> {
                DisplayMetrics displayMetrics = new DisplayMetrics();
                getDefaultDisplay().getRealMetrics(displayMetrics);
                Bitmap newScreenshot = captureScreenshot(
+7 −1
Original line number Diff line number Diff line
@@ -71,7 +71,13 @@ public enum ScreenshotEvent implements UiEventLogger.UiEventEnum {
    @UiEvent(doc = "User has shared a long screenshot")
    SCREENSHOT_LONG_SCREENSHOT_SHARE(689),
    @UiEvent(doc = "User has sent a long screenshot to the editor")
    SCREENSHOT_LONG_SCREENSHOT_EDIT(690);
    SCREENSHOT_LONG_SCREENSHOT_EDIT(690),
    @UiEvent(doc = "A long screenshot capture has started")
    SCREENSHOT_LONG_SCREENSHOT_STARTED(880),
    @UiEvent(doc = "The long screenshot capture failed")
    SCREENSHOT_LONG_SCREENSHOT_FAILURE(881),
    @UiEvent(doc = "The long screenshot capture completed successfully")
    SCREENSHOT_LONG_SCREENSHOT_COMPLETED(882);

    private final int mId;

+5 −3
Original line number Diff line number Diff line
@@ -242,19 +242,21 @@ public class ScreenshotView extends FrameLayout implements
    /**
     * Called to display the scroll action chip when support is detected.
     *
     * @param packageName the owning package of the window to be captured
     * @param onClick the action to take when the chip is clicked.
     */
    public void showScrollChip(Runnable onClick) {
    public void showScrollChip(String packageName, Runnable onClick) {
        if (DEBUG_SCROLL) {
            Log.d(TAG, "Showing Scroll option");
        }
        mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_IMPRESSION);
        mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_IMPRESSION, 0, packageName);
        mScrollChip.setVisibility(VISIBLE);
        mScrollChip.setOnClickListener((v) -> {
            if (DEBUG_INPUT) {
                Log.d(TAG, "scroll chip tapped");
            }
            mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_REQUESTED);
            mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_REQUESTED, 0,
                    packageName);
            onClick.run();
        });
    }
Loading