Add real to elapsed offset to shell transition trace am: 541c4b6021

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22988307

Change-Id: I2d90cd2c03d522147484023effce6ee5cdce45ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Pablo Gamito
2023-05-05 12:52:34 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ message WmShellTransitionTraceProto {
required fixed64 magic_number = 1;
repeated Transition transitions = 2;
repeated HandlerMapping handlerMappings = 3;
/* offset between real-time clock and elapsed time clock in nanoseconds.
Calculated as: 1000000 * System.currentTimeMillis() - SystemClock.elapsedRealtimeNanos() */
optional fixed64 real_to_elapsed_time_offset_nanos = 4;
}
message Transition {

View File

@@ -28,7 +28,6 @@ import android.os.Trace;
import android.util.Log;
import com.android.internal.util.TraceBuffer;
import com.android.wm.shell.nano.HandlerMapping;
import com.android.wm.shell.sysui.ShellCommandHandler;
import com.google.protobuf.nano.MessageNano;
@@ -41,6 +40,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.TimeUnit;
/**
* Helper class to collect and dump transition traces.
@@ -241,6 +241,10 @@ public class Tracer implements ShellCommandHandler.ShellCommandActionHandler {
new com.android.wm.shell.nano.WmShellTransitionTraceProto();
proto.magicNumber = MAGIC_NUMBER_VALUE;
writeHandlerMappingToProto(proto);
long timeOffsetNs =
TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis())
- SystemClock.elapsedRealtimeNanos();
proto.realToElapsedTimeOffsetNanos = timeOffsetNs;
int pid = android.os.Process.myPid();
LogAndPrintln.i(pw, "Writing file to " + file.getAbsolutePath()
+ " from process " + pid);