diff options
6 files changed, 48 insertions, 1 deletions
diff --git a/core/java/com/android/internal/inputmethod/ImeTracingServerImpl.java b/core/java/com/android/internal/inputmethod/ImeTracingServerImpl.java index 20ff83f5f68e..f885a7e775ed 100644 --- a/core/java/com/android/internal/inputmethod/ImeTracingServerImpl.java +++ b/core/java/com/android/internal/inputmethod/ImeTracingServerImpl.java @@ -21,6 +21,7 @@ import static android.os.Build.IS_USER; import android.annotation.Nullable; import android.os.RemoteException; import android.os.ServiceManager.ServiceNotFoundException; +import android.os.SystemClock; import android.util.Log; import android.util.proto.ProtoOutputStream; import android.view.inputmethod.InputMethodEditorTraceProto.InputMethodClientsTraceFileProto; @@ -34,6 +35,7 @@ import com.android.internal.util.TraceBuffer; import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.util.concurrent.TimeUnit; /** * An implementation of {@link ImeTracing} for the system_server process. @@ -139,18 +141,30 @@ class ImeTracingServerImpl extends ImeTracing { private void writeTracesToFilesLocked() { try { + long timeOffsetNs = + TimeUnit.NANOSECONDS.convert(System.currentTimeMillis(), TimeUnit.NANOSECONDS) + - SystemClock.elapsedRealtimeNanos(); + ProtoOutputStream clientsProto = new ProtoOutputStream(); clientsProto.write(InputMethodClientsTraceFileProto.MAGIC_NUMBER, MAGIC_NUMBER_CLIENTS_VALUE); + clientsProto.write(InputMethodClientsTraceFileProto.REAL_TO_ELAPSED_TIME_OFFSET_NANOS, + timeOffsetNs); mBufferClients.writeTraceToFile(mTraceFileClients, clientsProto); ProtoOutputStream imsProto = new ProtoOutputStream(); - imsProto.write(InputMethodServiceTraceFileProto.MAGIC_NUMBER, MAGIC_NUMBER_IMS_VALUE); + imsProto.write(InputMethodServiceTraceFileProto.MAGIC_NUMBER, + MAGIC_NUMBER_IMS_VALUE); + imsProto.write(InputMethodServiceTraceFileProto.REAL_TO_ELAPSED_TIME_OFFSET_NANOS, + timeOffsetNs); mBufferIms.writeTraceToFile(mTraceFileIms, imsProto); ProtoOutputStream immsProto = new ProtoOutputStream(); immsProto.write(InputMethodManagerServiceTraceFileProto.MAGIC_NUMBER, MAGIC_NUMBER_IMMS_VALUE); + immsProto.write( + InputMethodManagerServiceTraceFileProto.REAL_TO_ELAPSED_TIME_OFFSET_NANOS, + timeOffsetNs); mBufferImms.writeTraceToFile(mTraceFileImms, immsProto); resetBuffers(); diff --git a/core/proto/android/server/accessibilitytrace.proto b/core/proto/android/server/accessibilitytrace.proto index 0ce39abfe352..6b77be3c748d 100644 --- a/core/proto/android/server/accessibilitytrace.proto +++ b/core/proto/android/server/accessibilitytrace.proto @@ -39,6 +39,10 @@ message AccessibilityTraceFileProto { optional fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */ repeated AccessibilityTraceProto entry = 2; + + /* 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 = 3; } /* one accessibility trace entry. */ diff --git a/core/proto/android/server/windowmanagertrace.proto b/core/proto/android/server/windowmanagertrace.proto index f502961d2c45..257f79b0d6bb 100644 --- a/core/proto/android/server/windowmanagertrace.proto +++ b/core/proto/android/server/windowmanagertrace.proto @@ -38,6 +38,10 @@ message WindowManagerTraceFileProto { optional fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */ repeated WindowManagerTraceProto entry = 2; + + /* 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 = 3; } /* one window manager trace entry. */ diff --git a/core/proto/android/view/inputmethod/inputmethodeditortrace.proto b/core/proto/android/view/inputmethod/inputmethodeditortrace.proto index 8e4377ca124c..a4281a72fb8e 100644 --- a/core/proto/android/view/inputmethod/inputmethodeditortrace.proto +++ b/core/proto/android/view/inputmethod/inputmethodeditortrace.proto @@ -50,6 +50,10 @@ message InputMethodClientsTraceFileProto { in MagicNumber */ optional fixed64 magic_number = 1; repeated InputMethodClientsTraceProto entry = 2; + + /* 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 = 3; } /* One dump entry for clients that use InputMethod. */ @@ -96,6 +100,10 @@ message InputMethodServiceTraceFileProto { in MagicNumber */ optional fixed64 magic_number = 1; repeated InputMethodServiceTraceProto entry = 2; + + /* 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 = 3; } /* One dump entry for InputMethodService. */ @@ -129,6 +137,10 @@ message InputMethodManagerServiceTraceFileProto { in MagicNumber */ optional fixed64 magic_number = 1; repeated InputMethodManagerServiceTraceProto entry = 2; + + /* 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 = 3; } /* One dump entry for InputMethodManagerService. */ diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index f1dbad61a76d..c04b19558770 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -30,6 +30,7 @@ import static com.android.server.accessibility.AccessibilityTraceFileProto.ENTRY import static com.android.server.accessibility.AccessibilityTraceFileProto.MAGIC_NUMBER; import static com.android.server.accessibility.AccessibilityTraceFileProto.MAGIC_NUMBER_H; import static com.android.server.accessibility.AccessibilityTraceFileProto.MAGIC_NUMBER_L; +import static com.android.server.accessibility.AccessibilityTraceFileProto.REAL_TO_ELAPSED_TIME_OFFSET_NANOS; import static com.android.server.accessibility.AccessibilityTraceProto.ACCESSIBILITY_SERVICE; import static com.android.server.accessibility.AccessibilityTraceProto.CALENDAR_TIME; import static com.android.server.accessibility.AccessibilityTraceProto.CALLING_PARAMS; @@ -116,6 +117,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.concurrent.TimeUnit; /** * This class contains the accessibility related logic of the window manager. @@ -2215,6 +2217,11 @@ final class AccessibilityController { try { ProtoOutputStream proto = new ProtoOutputStream(); proto.write(MAGIC_NUMBER, MAGIC_NUMBER_VALUE); + long timeOffsetNs = + TimeUnit.NANOSECONDS.convert(System.currentTimeMillis(), + TimeUnit.NANOSECONDS) + - SystemClock.elapsedRealtimeNanos(); + proto.write(REAL_TO_ELAPSED_TIME_OFFSET_NANOS, timeOffsetNs); mBuffer.writeTraceToFile(mTraceFile, proto); } catch (IOException e) { Slog.e(TAG, "Unable to write buffer to file", e); diff --git a/services/core/java/com/android/server/wm/WindowTracing.java b/services/core/java/com/android/server/wm/WindowTracing.java index ca834c56e0f0..efcca5d28416 100644 --- a/services/core/java/com/android/server/wm/WindowTracing.java +++ b/services/core/java/com/android/server/wm/WindowTracing.java @@ -22,6 +22,7 @@ import static com.android.server.wm.WindowManagerTraceFileProto.ENTRY; import static com.android.server.wm.WindowManagerTraceFileProto.MAGIC_NUMBER; import static com.android.server.wm.WindowManagerTraceFileProto.MAGIC_NUMBER_H; import static com.android.server.wm.WindowManagerTraceFileProto.MAGIC_NUMBER_L; +import static com.android.server.wm.WindowManagerTraceFileProto.REAL_TO_ELAPSED_TIME_OFFSET_NANOS; import static com.android.server.wm.WindowManagerTraceProto.ELAPSED_REALTIME_NANOS; import static com.android.server.wm.WindowManagerTraceProto.WHERE; import static com.android.server.wm.WindowManagerTraceProto.WINDOW_MANAGER_SERVICE; @@ -40,6 +41,7 @@ import com.android.internal.util.TraceBuffer; import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.util.concurrent.TimeUnit; /** * A class that allows window manager to dump its state continuously to a trace file, such that a @@ -352,6 +354,10 @@ class WindowTracing { Trace.traceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "writeTraceToFileLocked"); ProtoOutputStream proto = new ProtoOutputStream(); proto.write(MAGIC_NUMBER, MAGIC_NUMBER_VALUE); + long timeOffsetNs = + TimeUnit.NANOSECONDS.convert(System.currentTimeMillis(), TimeUnit.NANOSECONDS) + - SystemClock.elapsedRealtimeNanos(); + proto.write(REAL_TO_ELAPSED_TIME_OFFSET_NANOS, timeOffsetNs); mBuffer.writeTraceToFile(mTraceFile, proto); } catch (IOException e) { Log.e(TAG, "Unable to write buffer to file", e); |