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

Commit e434e7c0 authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Add nullability annotations

Test: N/A
Flag: EXEMPT adding annotations

Change-Id: I3751cbe73d5a81b00e0bca8c1b6b097edf9b007a
parent dde5de71
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");
        }
    }
}
+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);
    }