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

Commit 27e9829a authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Load viewer configs of groups that have logToLogcat enabled on registration

Otherwise we end up failing to convert the processed message ids at runtime when logging to logcat.

Bug: 352290057
Change-Id: I4383dbd3b3bbaae6780c43242b3b89384da0c98a
Flag: EXEMPT bug fix
Test: atest
parent 969a9dc5
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
@@ -423,6 +424,14 @@ public class LegacyProtoLogImpl implements IProtoLog {
        for (IProtoLogGroup group : protoLogGroups) {
            mLogGroups.put(group.name(), group);
        }

        final var hasGroupsLoggingToLogcat = Arrays.stream(protoLogGroups)
                .anyMatch(IProtoLogGroup::isLogToLogcat);

        final ILogger logger = (msg) -> Slog.i(TAG, msg);
        if (hasGroupsLoggingToLogcat) {
            mViewerConfig.loadViewerConfig(logger, mLegacyViewerConfigFilename);
        }
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -214,6 +214,13 @@ public class LegacyProtoLogImplTest {
        verify(mReader, never()).getViewerString(anyLong());
    }

    @Test
    public void loadViewerConfigOnLogcatGroupRegistration() {
        TestProtoLogGroup.TEST_GROUP.setLogToLogcat(true);
        mProtoLog.registerGroups(TestProtoLogGroup.TEST_GROUP);
        verify(mReader).loadViewerConfig(any(), any());
    }

    private static class ProtoLogData {
        Long mMessageHash = null;
        Long mElapsedTime = null;