summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Andonian <andonian@google.com>2023-06-20 19:01:48 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-06-20 19:01:48 +0000
commitac5a856413e23339356833488303a8065dd1c4ec (patch)
treef7ced7fc9d6c80cf5bed8e269cf8d9e042f2fa83
parent77e9d66cc63d1b44f930821812ad1e690d8626b0 (diff)
parentfa1e28d36c11c7f9e67ab732b2331e4d0c685ba3 (diff)
downloadsystemui-ac5a856413e23339356833488303a8065dd1c4ec.tar.gz
Revert "Revert "Add Winscope Magic Number to ViewCapture data output."" am: fa1e28d36c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/libs/systemui/+/23730785 Change-Id: I7726a6d2ed56bb0c450aafd1cf69132c146e6882 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java7
-rw-r--r--viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto16
2 files changed, 20 insertions, 3 deletions
diff --git a/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java b/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java
index bf8737a..e635e85 100644
--- a/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java
+++ b/viewcapturelib/src/com/android/app/viewcapture/ViewCapture.java
@@ -16,6 +16,9 @@
package com.android.app.viewcapture;
+import static com.android.app.viewcapture.data.ExportedData.MagicNumber.MAGIC_NUMBER_H;
+import static com.android.app.viewcapture.data.ExportedData.MagicNumber.MAGIC_NUMBER_L;
+
import android.content.Context;
import android.content.res.Resources;
import android.media.permission.SafeCloseable;
@@ -65,6 +68,9 @@ public abstract class ViewCapture {
private static final int PFLAG_INVALIDATED = 0x80000000;
private static final int PFLAG_DIRTY_MASK = 0x00200000;
+ private static final long MAGIC_NUMBER_FOR_WINSCOPE =
+ ((long) MAGIC_NUMBER_H.getNumber() << 32) | MAGIC_NUMBER_L.getNumber();
+
// Number of frames to keep in memory
private final int mMemorySize;
protected static final int DEFAULT_MEMORY_SIZE = 2000;
@@ -179,6 +185,7 @@ public abstract class ViewCapture {
throws InterruptedException, ExecutionException {
ArrayList<Class> classList = new ArrayList<>();
return ExportedData.newBuilder()
+ .setMagicNumber(MAGIC_NUMBER_FOR_WINSCOPE)
.setPackage(context.getPackageName())
.addAllWindowData(getWindowData(context, classList, l -> l.mIsActive).get())
.addAllClassname(toStringList(classList))
diff --git a/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto b/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto
index d4df2ae..6e71889 100644
--- a/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto
+++ b/viewcapturelib/src/com/android/app/viewcapture/proto/view_capture.proto
@@ -21,9 +21,19 @@ package com.android.app.viewcapture.data;
option java_multiple_files = true;
message ExportedData {
- repeated WindowData windowData = 1;
- optional string package = 2;
- repeated string classname = 3;
+ /* constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 | MagicNumber.MAGIC_NUMBER_L
+ (this is needed because enums have to be 32 bits and there's no nice way to put 64bit
+ constants into .proto files. */
+ enum MagicNumber {
+ INVALID = 0;
+ MAGIC_NUMBER_L = 0x65906578; /* AZAN (ASCII) */
+ MAGIC_NUMBER_H = 0x68658273; /* DARI (ASCII) */
+ }
+
+ optional fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */
+ repeated WindowData windowData = 2;
+ optional string package = 3;
+ repeated string classname = 4;
}
message WindowData {