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

Commit ac5a8564 authored by Stefan Andonian's avatar Stefan Andonian Committed by Automerger Merge Worker
Browse files

Revert "Revert "Add Winscope Magic Number to ViewCapture data output."" am: fa1e28d3

parents 77e9d66c fa1e28d3
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 {