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
This commit is contained in:
@@ -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() {}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import androidx.concurrent.futures.CallbackToFutureAdapter;
|
||||
import androidx.concurrent.futures.CallbackToFutureAdapter.Completer;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
import com.android.systemui.dagger.qualifiers.Background;
|
||||
import com.android.systemui.screenshot.ScrollCaptureClient.CaptureResult;
|
||||
import com.android.systemui.screenshot.ScrollCaptureClient.Session;
|
||||
@@ -61,6 +62,7 @@ public class ScrollCaptureController {
|
||||
private final Context mContext;
|
||||
private final Executor mBgExecutor;
|
||||
private final ImageTileSet mImageTileSet;
|
||||
private final UiEventLogger mEventLogger;
|
||||
private final ScrollCaptureClient mClient;
|
||||
|
||||
private Completer<LongScreenshot> mCaptureCompleter;
|
||||
@@ -69,6 +71,7 @@ public class ScrollCaptureController {
|
||||
private Session mSession;
|
||||
private ListenableFuture<CaptureResult> mTileFuture;
|
||||
private ListenableFuture<Void> mEndFuture;
|
||||
private String mWindowOwner;
|
||||
|
||||
static class LongScreenshot {
|
||||
private final ImageTileSet mImageTileSet;
|
||||
@@ -135,11 +138,12 @@ public class ScrollCaptureController {
|
||||
|
||||
@Inject
|
||||
ScrollCaptureController(Context context, @Background Executor bgExecutor,
|
||||
ScrollCaptureClient client, ImageTileSet imageTileSet) {
|
||||
ScrollCaptureClient client, ImageTileSet imageTileSet, UiEventLogger logger) {
|
||||
mContext = context;
|
||||
mBgExecutor = bgExecutor;
|
||||
mClient = client;
|
||||
mImageTileSet = imageTileSet;
|
||||
mEventLogger = logger;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -157,6 +161,7 @@ public class ScrollCaptureController {
|
||||
ListenableFuture<LongScreenshot> run(ScrollCaptureResponse response) {
|
||||
return CallbackToFutureAdapter.getFuture(completer -> {
|
||||
mCaptureCompleter = completer;
|
||||
mWindowOwner = response.getPackageName();
|
||||
mBgExecutor.execute(() -> {
|
||||
float maxPages = Settings.Secure.getFloat(mContext.getContentResolver(),
|
||||
SETTING_KEY_MAX_PAGES, MAX_PAGES_DEFAULT);
|
||||
@@ -173,11 +178,13 @@ public class ScrollCaptureController {
|
||||
if (LogConfig.DEBUG_SCROLL) {
|
||||
Log.d(TAG, "got session " + mSession);
|
||||
}
|
||||
mEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_STARTED, 0, mWindowOwner);
|
||||
requestNextTile(0);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
// Failure to start, propagate to caller
|
||||
Log.e(TAG, "session start failed!");
|
||||
mCaptureCompleter.setException(e);
|
||||
mEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_FAILURE, 0, mWindowOwner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,6 +304,11 @@ public class ScrollCaptureController {
|
||||
if (LogConfig.DEBUG_SCROLL) {
|
||||
Log.d(TAG, "finishCapture()");
|
||||
}
|
||||
if (mImageTileSet.getHeight() > 0) {
|
||||
mEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_COMPLETED, 0, mWindowOwner);
|
||||
} else {
|
||||
mEventLogger.log(ScreenshotEvent.SCREENSHOT_LONG_SCREENSHOT_FAILURE, 0, mWindowOwner);
|
||||
}
|
||||
mEndFuture = mSession.end();
|
||||
mEndFuture.addListener(() -> {
|
||||
if (LogConfig.DEBUG_SCROLL) {
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.view.ScrollCaptureResponse;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.testing.UiEventLoggerFake;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.screenshot.ScrollCaptureClient.Session;
|
||||
|
||||
@@ -274,7 +275,8 @@ public class ScrollCaptureControllerTest extends SysuiTestCase {
|
||||
when(client.start(/* response */ any(), /* maxPages */ anyFloat()))
|
||||
.thenReturn(immediateFuture(session));
|
||||
return new ScrollCaptureController(context, context.getMainExecutor(),
|
||||
client, new ImageTileSet(context.getMainThreadHandler()));
|
||||
client, new ImageTileSet(context.getMainThreadHandler()),
|
||||
new UiEventLoggerFake());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7061,6 +7061,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
"requestScrollCapture: caught exception dispatching to window."
|
||||
+ "token=%s", targetWindow.mClient.asBinder());
|
||||
responseBuilder.setWindowTitle(targetWindow.getName());
|
||||
responseBuilder.setPackageName(targetWindow.getOwningPackage());
|
||||
responseBuilder.setDescription(String.format("caught exception: %s", e));
|
||||
listener.onScrollCaptureResponse(responseBuilder.build());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user