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

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

Merge changes I915fb1ae,I3751cbe7 into main

* changes:
  Add support for location viewer config location
  Add nullability annotations
parents 8d93cff7 1ec1bba3
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -930,38 +930,48 @@ public class PerfettoProtoLogImpl extends IProtoLogClient.Stub implements IProto
    }

    private static class Message {
        @Nullable
        private final Long mMessageHash;
        @Nullable
        private final Integer mMessageMask;
        @Nullable
        private final String mMessageString;

        private Message(Long messageHash, int messageMask) {
        private Message(long messageHash, int messageMask) {
            this.mMessageHash = messageHash;
            this.mMessageMask = messageMask;
            this.mMessageString = null;
        }

        private Message(String messageString) {
        private Message(@NonNull String messageString) {
            this.mMessageHash = null;
            final List<Integer> argTypes = LogDataType.parseFormatString(messageString);
            this.mMessageMask = LogDataType.logDataTypesToBitMask(argTypes);
            this.mMessageString = messageString;
        }

        private int getMessageMask() {
        @Nullable
        private Integer getMessageMask() {
            return mMessageMask;
        }

        @Nullable
        private String getMessage() {
            return mMessageString;
        }

        @Nullable
        private String getMessage(@NonNull ProtoLogViewerConfigReader viewerConfigReader) {
            if (mMessageString != null) {
                return mMessageString;
            }

            if (mMessageHash != null) {
                return viewerConfigReader.getViewerString(mMessageHash);
            }

            throw new RuntimeException("Both mMessageString and mMessageHash should never be null");
        }
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.Gro
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MESSAGES;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MessageData.GROUP_ID;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MessageData.LEVEL;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MessageData.LOCATION;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MessageData.MESSAGE;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MessageData.MESSAGE_ID;
import static android.internal.perfetto.protos.TracePacketOuterClass.TracePacket.PROTOLOG_VIEWER_CONFIG;
@@ -446,6 +447,7 @@ public final class ProtoLogConfigurationService extends IProtoLogConfigurationSe
                case (int) MESSAGE -> os.write(MESSAGE, pis.readString(MESSAGE));
                case (int) LEVEL -> os.write(LEVEL, pis.readInt(LEVEL));
                case (int) GROUP_ID -> os.write(GROUP_ID, pis.readInt(GROUP_ID));
                case (int) LOCATION -> os.write(LOCATION, pis.readString(LOCATION));
                default ->
                    throw new RuntimeException(
                            "Unexpected field id " + pis.getFieldNumber());
+1 −2
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ package com.android.internal.protolog;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.GROUPS;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.Group.ID;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.Group.NAME;

import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MESSAGES;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MessageData.MESSAGE;
import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.MessageData.MESSAGE_ID;
@@ -11,7 +10,6 @@ import static android.internal.perfetto.protos.Protolog.ProtoLogViewerConfig.Mes

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.Log;
import android.util.LongSparseArray;
import android.util.proto.ProtoInputStream;

@@ -38,6 +36,7 @@ public class ProtoLogViewerConfigReader {
     * Returns message format string for its hash or null if unavailable
     * or the viewer config is not loaded into memory.
     */
    @Nullable
    public synchronized String getViewerString(long messageHash) {
        return mLogMessageMap.get(messageHash);
    }