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

Commit d342e75d authored by Stefan Andonian's avatar Stefan Andonian
Browse files

Add Winscope Magic Number to ViewCapture data output.

This will enable the ViewCapture data to be uploaded to the Winscope UI.

Bug: 224595733
Test: Compilation worked well. Won't push this until go/web-hv is
operating normally with the new proto.

Change-Id: Ie6237b68aa26cc01c20a129fb04cfef7537d30dd
parent e7969d0c
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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))
+13 −3
Original line number Diff line number Diff line
@@ -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 {