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

Commit e0bc2d6e authored by Andreas Miko's avatar Andreas Miko
Browse files

[SceneContainer] Log SceneFramework to Logcat

Logs should appear in bugreports in logcat such that they are easy to
correlate with other events.

Bug: NONE
Flag: com.android.systemui.scene_container
Test: NONE
Change-Id: Ieb39f19d799d44787b886dfa482cab7047f3d8d3
parent 91010ec5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class QSTileLoggerTest : SysuiTestCase() {
    @Before
    fun setup() {
        MockitoAnnotations.initMocks(this)
        whenever(logBufferFactory.create(any(), any(), any())).thenReturn(logBuffer)
        whenever(logBufferFactory.create(any(), any(), any(), any())).thenReturn(logBuffer)
        val tileSpec: TileSpec = TileSpec.create("chatty_tile")
        underTest =
            QSTileLogger(mapOf(tileSpec to chattyLogBuffer), logBufferFactory, statusBarController)
+8 −3
Original line number Diff line number Diff line
@@ -19,10 +19,13 @@ package com.android.systemui.log
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dump.DumpManager
import com.android.systemui.log.LogBufferHelper.Companion.adjustMaxSize
import com.android.systemui.log.echo.LogcatEchoTrackerAlways
import javax.inject.Inject

@SysUISingleton
class LogBufferFactory @Inject constructor(
class LogBufferFactory
@Inject
constructor(
    private val dumpManager: DumpManager,
    private val logcatEchoTracker: LogcatEchoTracker
) {
@@ -30,9 +33,11 @@ class LogBufferFactory @Inject constructor(
    fun create(
        name: String,
        maxSize: Int,
        systrace: Boolean = true
        systrace: Boolean = true,
        alwaysLogToLogcat: Boolean = false,
    ): LogBuffer {
        val buffer = LogBuffer(name, adjustMaxSize(maxSize), logcatEchoTracker, systrace)
        val echoTracker = if (alwaysLogToLogcat) LogcatEchoTrackerAlways else logcatEchoTracker
        val buffer = LogBuffer(name, adjustMaxSize(maxSize), echoTracker, systrace)
        dumpManager.registerBuffer(name, buffer)
        return buffer
    }
+2 −1
Original line number Diff line number Diff line
@@ -612,7 +612,8 @@ public class LogModule {
    @SysUISingleton
    @SceneFrameworkLog
    public static LogBuffer provideSceneFrameworkLogBuffer(LogBufferFactory factory) {
        return factory.create("SceneFramework", 50);
        return factory
                .create("SceneFramework", 50, /* systrace */ true, /* alwaysLogToLogcat */  true);
    }

    /** Provides a {@link LogBuffer} for the bluetooth QS tile dialog. */
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.echo

import com.android.systemui.log.LogcatEchoTracker
import com.android.systemui.log.core.LogLevel

/**
 * The buffer and all of its tags will be logged to logcat at all times.
 *
 * This can be used for buffers that are important and should appear in bugreports in logcat
 * directly.
 */
object LogcatEchoTrackerAlways : LogcatEchoTracker {
    override fun isBufferLoggable(bufferName: String, level: LogLevel): Boolean = true

    override fun isTagLoggable(tagName: String, level: LogLevel): Boolean = true
}