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

Commit b770e316 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

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
parent a60c144b
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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();
        }
    };