Merge "Traces with real-to-elapsed time offset"
This commit is contained in:
committed by
Android (Google) Code Review
commit
621ab3d490
@@ -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();
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user