From b770e31605f14ebdd6c88d42b63115062da9771c Mon Sep 17 00:00:00 2001 From: Cosmin Băieș Date: Tue, 13 Feb 2024 11:55:52 +0100 Subject: Fix IMMS critical dump winscope compatibility Winscope expects the critical dump to be in the shape of a normal trace with a single entry, however we currently only dump one nested field of one entry message. This fixes the compatibility by ensuring the required shape, enabling better integration with winscope, and consistency with the critical dumps from window manager and surface flinger. Bug: 325016290 Test: n/a Change-Id: I3c1f4f03cf043500c70fb7dddb80454979a07a80 --- .../server/inputmethod/InputMethodManagerService.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index b8a63cd7941c..776787c14be3 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -204,6 +204,7 @@ import java.util.OptionalInt; import java.util.WeakHashMap; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.IntConsumer; @@ -5989,7 +5990,23 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @BinderThread private void dumpAsProtoNoCheck(FileDescriptor fd) { final ProtoOutputStream proto = new ProtoOutputStream(fd); + // Dump in the format of an ImeTracing trace with a single entry. + final long magicNumber = + ((long) InputMethodManagerServiceTraceFileProto.MAGIC_NUMBER_H << 32) + | InputMethodManagerServiceTraceFileProto.MAGIC_NUMBER_L; + final long timeOffsetNs = TimeUnit.MILLISECONDS.toNanos(System.currentTimeMillis()) + - SystemClock.elapsedRealtimeNanos(); + proto.write(InputMethodManagerServiceTraceFileProto.MAGIC_NUMBER, + magicNumber); + proto.write(InputMethodManagerServiceTraceFileProto.REAL_TO_ELAPSED_TIME_OFFSET_NANOS, + timeOffsetNs); + final long token = proto.start(InputMethodManagerServiceTraceFileProto.ENTRY); + proto.write(InputMethodManagerServiceTraceProto.ELAPSED_REALTIME_NANOS, + SystemClock.elapsedRealtimeNanos()); + proto.write(InputMethodManagerServiceTraceProto.WHERE, + "InputMethodManagerService.mPriorityDumper#dumpAsProtoNoCheck"); dumpDebug(proto, InputMethodManagerServiceTraceProto.INPUT_METHOD_MANAGER_SERVICE); + proto.end(token); proto.flush(); } }; -- cgit v1.2.3-59-g8ed1b