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

Commit eb47748c authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "DeliQueue: implement dump and dumpDebug" into main

parents 259b7c0c 1725920f
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -1327,13 +1327,19 @@ public final class MessageQueue {

    @NeverCompile
    void dump(Printer pw, String prefix, Handler h) {
        //TODO: fill in later
        pw.println(prefix + "(MessageQueue is using DeliQueue implementation)");
        final int n = mStack.dump(pw, prefix, h);
        pw.println(prefix + "(Total messages: " + n + ", polling=" + isPolling()
                + ", quitting=" + mStack.isQuitting() + ")");
    }

    @NeverCompile
    void dumpDebug(ProtoOutputStream proto, long fieldId) {
        //TODO: fill in later
        final long messageQueueToken = proto.start(fieldId);
        mStack.dumpDebug(proto);
        proto.write(MessageQueueProto.IS_POLLING_LOCKED, isPolling());
        proto.write(MessageQueueProto.IS_QUITTING, mStack.isQuitting());
        proto.end(messageQueueToken);
    }

    private void incAndTraceMessageCount(Message msg, long when) {
+2 −0
Original line number Diff line number Diff line
@@ -683,6 +683,8 @@ public final class Message implements Parcelable {
            b.append(arg1);
        }

        b.append(" async=");
        b.append(isAsynchronous());
        b.append(" heapIndex=");
        b.append(heapIndex);
        b.append(" }");
+27 −0
Original line number Diff line number Diff line
@@ -18,6 +18,10 @@ package android.os;

import android.annotation.Nullable;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.util.Printer;
import android.util.proto.ProtoOutputStream;

import dalvik.annotation.optimization.NeverCompile;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
@@ -386,4 +390,27 @@ public final class MessageStack {
        return mSyncHeap.size() + mAsyncHeap.size();
    }

    @NeverCompile
    int dump(Printer pw, String prefix, Handler h) {
        final long now = SystemClock.uptimeMillis();
        int n = 0;
        Message msg = (Message) sTop.getAcquire(this);
        while (msg != null) {
            if (h == null || h == msg.target) {
                pw.println(prefix + "Message " + n + ": " + msg.toString(now));
            }
            msg = msg.next;
            n++;
        }
        return n;
    }

    @NeverCompile
    void dumpDebug(ProtoOutputStream proto) {
        Message msg = (Message) sTop.getAcquire(this);
        while (msg != null) {
            msg.dumpDebug(proto, MessageQueueProto.MESSAGES);
            msg = msg.next;
        }
    }
}