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

Commit 1148054e authored by Adrian Roos's avatar Adrian Roos
Browse files

ProtoLog: Fix bug in ProtoLogImpl.isEnabled and re-enable

Test: make droid && atest RelayoutPerfTest
Change-Id: I060063354a217682c7b4ff3b5f7db1c330a8a160
parent 2ca5d860
Loading
Loading
Loading
Loading
+1743 −0

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class ProtoLogImpl {

    /** Returns true iff logging is enabled for the given {@code IProtoLogGroup}. */
    public static boolean isEnabled(IProtoLogGroup group) {
        return group.isLogToProto()
        return group.isLogToLogcat()
                || (group.isLogToProto() && getSingleInstance().isProtoEnabled());
    }

+1 −1
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public enum ProtoLogGroup implements IProtoLogGroup {
    private static class Consts {
        private static final String TAG_WM = "WindowManager";

        private static final boolean ENABLE_DEBUG = false;
        private static final boolean ENABLE_DEBUG = true;
        private static final boolean ENABLE_LOG_TO_PROTO_DEBUG = true;
    }
}
+22 −4
Original line number Diff line number Diff line
@@ -44,14 +44,32 @@ public class ProtoLogIntegrationTest {
    @Test
    public void testProtoLogToolIntegration() {
        ProtoLogImpl mockedProtoLog = mock(ProtoLogImpl.class);
        ProtoLogImpl.setSingleInstance(mockedProtoLog);
        runWith(mockedProtoLog, () -> {
            ProtoLogGroup.testProtoLog();
        verify(mockedProtoLog).log(eq(ProtoLogImpl.LogLevel.ERROR), eq(
                ProtoLogGroup.TEST_GROUP),
        });
        verify(mockedProtoLog).log(eq(ProtoLogImpl.LogLevel.ERROR), eq(ProtoLogGroup.TEST_GROUP),
                anyInt(), eq(0b0010101001010111),
                eq(ProtoLogGroup.TEST_GROUP.isLogToLogcat()
                        ? "Test completed successfully: %b %d %o %x %e %g %f %% %s"
                        : null),
                eq(new Object[]{true, 1L, 2L, 3L, 0.4, 0.5, 0.6, "ok"}));
    }

    /**
     * Starts protolog for the duration of {@code runnable}, with a ProtoLogImpl instance installed.
     */
    private void runWith(ProtoLogImpl mockInstance, Runnable runnable) {
        ProtoLogImpl original = ProtoLogImpl.getSingleInstance();
        original.startProtoLog(null);
        try {
            ProtoLogImpl.setSingleInstance(mockInstance);
            try {
                runnable.run();
            } finally {
                ProtoLogImpl.setSingleInstance(original);
            }
        } finally {
            original.stopProtoLog(null, false);
        }
    }
}