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

Commit 198ade35 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't log SysuiLog to logcat by default"

parents ee13435b 712a7cd8
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ public class SysuiLog implements Dumpable {
    private final Object mDataLock = new Object();
    private final String mId;
    private final int mMaxLogs;
    private boolean mEnabled;
    protected boolean mEnabled;
    protected boolean mLogToLogcatEnabled;

    @VisibleForTesting protected ArrayDeque<Event> mTimeline;

@@ -62,14 +63,18 @@ public class SysuiLog implements Dumpable {
     */
    public SysuiLog(DumpController dumpController, String id, int maxDebugLogs, int maxLogs) {
        this(dumpController, id, sDebuggable ? maxDebugLogs : maxLogs,
                SystemProperties.getBoolean(SYSPROP_ENABLED_PREFIX + id, DEFAULT_ENABLED));
                SystemProperties.getBoolean(SYSPROP_ENABLED_PREFIX + id, DEFAULT_ENABLED),
                SystemProperties.getBoolean(SYSPROP_LOGCAT_ENABLED_PREFIX + id,
                        DEFAULT_LOGCAT_ENABLED));
    }

    @VisibleForTesting
    protected SysuiLog(DumpController dumpController, String id, int maxLogs, boolean enabled) {
    protected SysuiLog(DumpController dumpController, String id, int maxLogs, boolean enabled,
            boolean logcatEnabled) {
        mId = id;
        mMaxLogs = maxLogs;
        mEnabled = enabled;
        mLogToLogcatEnabled = logcatEnabled;
        mTimeline = mEnabled ? new ArrayDeque<>(mMaxLogs) : null;
        dumpController.registerDumpable(mId, this);
    }
@@ -96,7 +101,7 @@ public class SysuiLog implements Dumpable {
            mTimeline.add(event);
        }

        if (LOG_TO_LOGCAT_ENABLED) {
        if (mLogToLogcatEnabled) {
            final String strEvent = eventToString(event);
            switch (event.getLogLevel()) {
                case Event.VERBOSE:
@@ -162,9 +167,10 @@ public class SysuiLog implements Dumpable {
    }

    private static boolean sDebuggable = Build.IS_DEBUGGABLE;
    private static final String SYSPROP_ENABLED_PREFIX = "sysui.log.enabled.";
    private static final boolean LOG_TO_LOGCAT_ENABLED = sDebuggable;
    private static final String SYSPROP_ENABLED_PREFIX = "persist.sysui.log.enabled.";
    private static final String SYSPROP_LOGCAT_ENABLED_PREFIX = "persist.sysui.log.enabled.logcat.";
    private static final boolean DEFAULT_ENABLED = sDebuggable;
    private static final boolean DEFAULT_LOGCAT_ENABLED = false;
    private static final int DEFAULT_MAX_DEBUG_LOGS = 100;
    private static final int DEFAULT_MAX_LOGS = 50;
}
+3 −3
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class SysuiLogTest extends SysuiTestCase {

    @Test
    public void testLogDisabled_noLogsWritten() {
        mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, false);
        mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, false, false);
        assertEquals(mSysuiLog.mTimeline, null);

        mSysuiLog.log(new Event("msg"));
@@ -57,7 +57,7 @@ public class SysuiLogTest extends SysuiTestCase {

    @Test
    public void testLogEnabled_logWritten() {
        mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
        mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true, false);
        assertEquals(mSysuiLog.mTimeline.size(), 0);

        mSysuiLog.log(new Event("msg"));
@@ -66,7 +66,7 @@ public class SysuiLogTest extends SysuiTestCase {

    @Test
    public void testMaxLogs() {
        mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true);
        mSysuiLog = new SysuiLog(mDumpController, TEST_ID, MAX_LOGS, true, false);
        assertEquals(mSysuiLog.mTimeline.size(), 0);

        final String msg = "msg";