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

Commit 7e1b0ac8 authored by Ned Burns's avatar Ned Burns Committed by Automerger Merge Worker
Browse files

Merge "Create LogBuffers with LogBufferFactory" into sc-dev am: 536adc2c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13554965

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I6f8a75b9978ad761d9fc051aaca0b6d248999d81
parents f67c8008 536adc2c
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.systemui.log

import android.util.Log
import com.android.systemui.dump.DumpManager
import com.android.systemui.log.dagger.LogModule
import java.io.PrintWriter
import java.text.SimpleDateFormat
@@ -58,7 +57,7 @@ import java.util.Locale
 * In either case, `level` can be any of `verbose`, `debug`, `info`, `warn`, `error`, `assert`, or
 * the first letter of any of the previous.
 *
 * Buffers are provided by [LogModule].
 * Buffers are provided by [LogModule]. Instances should be created using a [LogBufferFactory].
 *
 * @param name The name of this buffer
 * @param maxLogs The maximum number of messages to keep in memory at any one time, including the
@@ -77,10 +76,6 @@ class LogBuffer(
    var frozen = false
        private set

    fun attach(dumpManager: DumpManager) {
        dumpManager.registerBuffer(name, this)
    }

    /**
     * Logs a message to the log buffer
     *
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.log

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import javax.inject.Inject

@SysUISingleton
class LogBufferFactory @Inject constructor(
    private val dumpManager: DumpManager,
    private val logcatEchoTracker: LogcatEchoTracker
) {
    @JvmOverloads
    fun create(name: String, maxPoolSize: Int, flexSize: Int = 10): LogBuffer {
        val buffer = LogBuffer(name, maxPoolSize, flexSize, logcatEchoTracker)
        dumpManager.registerBuffer(name, buffer)
        return buffer
    }
}
+17 −49
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@ import android.os.Looper;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.log.LogBuffer;
import com.android.systemui.log.LogBufferFactory;
import com.android.systemui.log.LogcatEchoTracker;
import com.android.systemui.log.LogcatEchoTrackerDebug;
import com.android.systemui.log.LogcatEchoTrackerProd;
@@ -40,96 +40,64 @@ public class LogModule {
    @Provides
    @SysUISingleton
    @DozeLog
    public static LogBuffer provideDozeLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer("DozeLog", 100, 10, bufferFilter);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer provideDozeLogBuffer(LogBufferFactory factory) {
        return factory.create("DozeLog", 100);
    }

    /** Provides a logging buffer for all logs related to the data layer of notifications. */
    @Provides
    @SysUISingleton
    @NotificationLog
    public static LogBuffer provideNotificationsLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer("NotifLog", 1000, 10, bufferFilter);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer provideNotificationsLogBuffer(LogBufferFactory factory) {
        return factory.create("NotifLog", 1000);
    }

    /** Provides a logging buffer for all logs related to managing notification sections. */
    @Provides
    @SysUISingleton
    @NotificationSectionLog
    public static LogBuffer provideNotificationSectionLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer("NotifSectionLog", 1000, 10, bufferFilter);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer provideNotificationSectionLogBuffer(LogBufferFactory factory) {
        return factory.create("NotifSectionLog", 1000);
    }

    /** Provides a logging buffer for all logs related to the data layer of notifications. */
    @Provides
    @SysUISingleton
    @NotifInteractionLog
    public static LogBuffer provideNotifInteractionLogBuffer(
            LogcatEchoTracker echoTracker,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer("NotifInteractionLog", 50, 10, echoTracker);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer provideNotifInteractionLogBuffer(LogBufferFactory factory) {
        return factory.create("NotifInteractionLog", 50);
    }

    /** Provides a logging buffer for all logs related to Quick Settings. */
    @Provides
    @SysUISingleton
    @QSLog
    public static LogBuffer provideQuickSettingsLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer("QSLog", 500, 10, bufferFilter);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer provideQuickSettingsLogBuffer(LogBufferFactory factory) {
        return factory.create("QSLog", 500);
    }

    /** Provides a logging buffer for {@link com.android.systemui.broadcast.BroadcastDispatcher} */
    @Provides
    @SysUISingleton
    @BroadcastDispatcherLog
    public static LogBuffer provideBroadcastDispatcherLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer("BroadcastDispatcherLog", 500, 10, bufferFilter);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer provideBroadcastDispatcherLogBuffer(LogBufferFactory factory) {
        return factory.create("BroadcastDispatcherLog", 500);
    }

    /** Provides a logging buffer for all logs related to Toasts shown by SystemUI. */
    @Provides
    @SysUISingleton
    @ToastLog
    public static LogBuffer provideToastLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer("ToastLog", 50, 10, bufferFilter);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer provideToastLogBuffer(LogBufferFactory factory) {
        return factory.create("ToastLog", 50);
    }

    /** Provides a logging buffer for all logs related to privacy indicators in SystemUI. */
    @Provides
    @SysUISingleton
    @PrivacyLog
    public static LogBuffer providePrivacyLogBuffer(
            LogcatEchoTracker bufferFilter,
            DumpManager dumpManager) {
        LogBuffer buffer = new LogBuffer(("PrivacyLog"), 100, 10, bufferFilter);
        buffer.attach(dumpManager);
        return buffer;
    public static LogBuffer providePrivacyLogBuffer(LogBufferFactory factory) {
        return factory.create("PrivacyLog", 100);
    }

    /** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */