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

Commit 37761bd5 authored by Charles Yo's avatar Charles Yo Committed by Android Build Coastguard Worker
Browse files

Revert "Handle potentially null strings passed as ProtoLog parameter"

Revert submission 28147757-no-processing-protolog

Reason for revert: b/351458758

Reverted changes: /q/submissionid:28147757-no-processing-protolog
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3a3403a68868541f7759f328651177c370c1a63f)
Merged-In: Id57d46e0521064b61af5cb081d214568a548f33e
Change-Id: Id57d46e0521064b61af5cb081d214568a548f33e
parent 9aab1696
Loading
Loading
Loading
Loading
+4 −20
Original line number Diff line number Diff line
@@ -91,7 +91,6 @@ import java.util.concurrent.locks.ReentrantLock;
 */
public class PerfettoProtoLogImpl implements IProtoLog {
    private static final String LOG_TAG = "ProtoLog";
    public static final String NULL_STRING = "null";
    private final AtomicInteger mTracingInstances = new AtomicInteger();

    private final ProtoLogDataSource mDataSource = new ProtoLogDataSource(
@@ -321,14 +320,8 @@ public class PerfettoProtoLogImpl implements IProtoLog {
            StringBuilder builder = new StringBuilder("UNKNOWN MESSAGE");
            if (args != null) {
                builder.append(" args = (");
                builder.append(String.join(", ", Arrays.stream(args)
                        .map(it -> {
                            if (it == null) {
                                return "null";
                            } else {
                                return it.toString();
                            }
                        }).toList()));
                builder.append(String.join(", ", Arrays.stream(args).map(
                        Object::toString).toList()));
                builder.append(")");
            }
            messageString = builder.toString();
@@ -419,12 +412,8 @@ public class PerfettoProtoLogImpl implements IProtoLog {
                for (Object o : args) {
                    int type = LogDataType.bitmaskToLogDataType(message.getMessageMask(), argIndex);
                    if (type == LogDataType.STRING) {
                        if (o == null) {
                            internStringArg(ctx, NULL_STRING);
                        } else {
                        internStringArg(ctx, o.toString());
                    }
                    }
                    argIndex++;
                }
            }
@@ -466,12 +455,7 @@ public class PerfettoProtoLogImpl implements IProtoLog {
                    try {
                        switch (type) {
                            case LogDataType.STRING:
                                final int internedStringId;
                                if (o == null) {
                                    internedStringId = internStringArg(ctx, NULL_STRING);
                                } else {
                                    internedStringId = internStringArg(ctx, o.toString());
                                }
                                final int internedStringId = internStringArg(ctx, o.toString());
                                os.write(STR_PARAM_IIDS, internedStringId);
                                needsIncrementalState = true;
                                break;
+0 −23
Original line number Diff line number Diff line
@@ -688,29 +688,6 @@ public class PerfettoProtoLogImplTest {
                .isFalse();
    }

    @Test
    public void supportsNullString() throws IOException {
        PerfettoTraceMonitor traceMonitor =
                PerfettoTraceMonitor.newBuilder().enableProtoLog(true)
                        .build();

        try {
            traceMonitor.start();

            mProtoLog.log(LogLevel.DEBUG, TestProtoLogGroup.TEST_GROUP,
                    "My test null string: %s", null);
        } finally {
            traceMonitor.stop(mWriter);
        }

        final ResultReader reader = new ResultReader(mWriter.write(), mTraceConfig);
        final ProtoLogTrace protolog = reader.readProtoLogTrace();

        Truth.assertThat(protolog.messages).hasSize(1);
        Truth.assertThat(protolog.messages.get(0).getMessage())
                .isEqualTo("My test null string: null");
    }

    private enum TestProtoLogGroup implements IProtoLogGroup {
        TEST_GROUP(true, true, false, "TEST_TAG");