Print when the sysui dump actually starts. am: 1f89e284a4
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/24178708 Change-Id: Ib31480204795a6b6b6ca90a1c9674a922d5d74ea Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -16,12 +16,10 @@
|
|||||||
|
|
||||||
package com.android.systemui.dump
|
package com.android.systemui.dump
|
||||||
|
|
||||||
import android.content.Context
|
import android.icu.text.SimpleDateFormat
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.os.Trace
|
import android.os.Trace
|
||||||
import com.android.systemui.CoreStartable
|
|
||||||
import com.android.systemui.ProtoDumpable
|
import com.android.systemui.ProtoDumpable
|
||||||
import com.android.systemui.R
|
|
||||||
import com.android.systemui.dump.DumpHandler.Companion.PRIORITY_ARG_CRITICAL
|
import com.android.systemui.dump.DumpHandler.Companion.PRIORITY_ARG_CRITICAL
|
||||||
import com.android.systemui.dump.DumpHandler.Companion.PRIORITY_ARG_NORMAL
|
import com.android.systemui.dump.DumpHandler.Companion.PRIORITY_ARG_NORMAL
|
||||||
import com.android.systemui.dump.DumpsysEntry.DumpableEntry
|
import com.android.systemui.dump.DumpsysEntry.DumpableEntry
|
||||||
@@ -35,8 +33,9 @@ import java.io.BufferedOutputStream
|
|||||||
import java.io.FileDescriptor
|
import java.io.FileDescriptor
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Provider
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Oversees SystemUI's output during bug reports (and dumpsys in general)
|
* Oversees SystemUI's output during bug reports (and dumpsys in general)
|
||||||
@@ -77,6 +76,7 @@ import javax.inject.Provider
|
|||||||
* $ <invocation> dumpables
|
* $ <invocation> dumpables
|
||||||
* $ <invocation> buffers
|
* $ <invocation> buffers
|
||||||
* $ <invocation> tables
|
* $ <invocation> tables
|
||||||
|
* $ <invocation> all
|
||||||
*
|
*
|
||||||
* # Finally, the following will simulate what we dump during the CRITICAL and NORMAL sections of a
|
* # Finally, the following will simulate what we dump during the CRITICAL and NORMAL sections of a
|
||||||
* # bug report:
|
* # bug report:
|
||||||
@@ -91,10 +91,9 @@ import javax.inject.Provider
|
|||||||
class DumpHandler
|
class DumpHandler
|
||||||
@Inject
|
@Inject
|
||||||
constructor(
|
constructor(
|
||||||
private val context: Context,
|
|
||||||
private val dumpManager: DumpManager,
|
private val dumpManager: DumpManager,
|
||||||
private val logBufferEulogizer: LogBufferEulogizer,
|
private val logBufferEulogizer: LogBufferEulogizer,
|
||||||
private val startables: MutableMap<Class<*>, Provider<CoreStartable>>,
|
private val config: SystemUIConfigDumpable,
|
||||||
) {
|
) {
|
||||||
/** Dump the diagnostics! Behavior can be controlled via [args]. */
|
/** Dump the diagnostics! Behavior can be controlled via [args]. */
|
||||||
fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<String>) {
|
fun dump(fd: FileDescriptor, pw: PrintWriter, args: Array<String>) {
|
||||||
@@ -109,6 +108,8 @@ constructor(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pw.print("Dump starting: ")
|
||||||
|
pw.println(DATE_FORMAT.format(System.currentTimeMillis()))
|
||||||
when {
|
when {
|
||||||
parsedArgs.dumpPriority == PRIORITY_ARG_CRITICAL -> dumpCritical(pw, parsedArgs)
|
parsedArgs.dumpPriority == PRIORITY_ARG_CRITICAL -> dumpCritical(pw, parsedArgs)
|
||||||
parsedArgs.dumpPriority == PRIORITY_ARG_NORMAL && !parsedArgs.proto -> {
|
parsedArgs.dumpPriority == PRIORITY_ARG_NORMAL && !parsedArgs.proto -> {
|
||||||
@@ -129,6 +130,11 @@ constructor(
|
|||||||
"dumpables" -> dumpDumpables(pw, args)
|
"dumpables" -> dumpDumpables(pw, args)
|
||||||
"buffers" -> dumpBuffers(pw, args)
|
"buffers" -> dumpBuffers(pw, args)
|
||||||
"tables" -> dumpTables(pw, args)
|
"tables" -> dumpTables(pw, args)
|
||||||
|
"all" -> {
|
||||||
|
dumpDumpables(pw, args)
|
||||||
|
dumpBuffers(pw, args)
|
||||||
|
dumpTables(pw, args)
|
||||||
|
}
|
||||||
"config" -> dumpConfig(pw)
|
"config" -> dumpConfig(pw)
|
||||||
"help" -> dumpHelp(pw)
|
"help" -> dumpHelp(pw)
|
||||||
else -> {
|
else -> {
|
||||||
@@ -148,7 +154,6 @@ constructor(
|
|||||||
dumpDumpable(target, pw, args.rawArgs)
|
dumpDumpable(target, pw, args.rawArgs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dumpConfig(pw)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dumpNormal(pw: PrintWriter, args: ParsedArgs) {
|
private fun dumpNormal(pw: PrintWriter, args: ParsedArgs) {
|
||||||
@@ -251,53 +256,8 @@ constructor(
|
|||||||
.sortedBy { it.name }
|
.sortedBy { it.name }
|
||||||
.minByOrNull { it.name.length }
|
.minByOrNull { it.name.length }
|
||||||
|
|
||||||
private fun dumpDumpable(entry: DumpableEntry, pw: PrintWriter, args: Array<String>) {
|
|
||||||
pw.preamble(entry)
|
|
||||||
entry.dumpable.dump(pw, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun dumpBuffer(entry: LogBufferEntry, pw: PrintWriter, tailLength: Int) {
|
|
||||||
pw.preamble(entry)
|
|
||||||
entry.buffer.dump(pw, tailLength)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun dumpTableBuffer(buffer: TableLogBufferEntry, pw: PrintWriter, args: Array<String>) {
|
|
||||||
pw.preamble(buffer)
|
|
||||||
buffer.table.dump(pw, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun dumpConfig(pw: PrintWriter) {
|
private fun dumpConfig(pw: PrintWriter) {
|
||||||
pw.println("SystemUiServiceComponents configuration:")
|
config.dump(pw, arrayOf())
|
||||||
pw.print("vendor component: ")
|
|
||||||
pw.println(context.resources.getString(R.string.config_systemUIVendorServiceComponent))
|
|
||||||
val services: MutableList<String> =
|
|
||||||
startables.keys.map({ cls: Class<*> -> cls.simpleName }).toMutableList()
|
|
||||||
|
|
||||||
services.add(context.resources.getString(R.string.config_systemUIVendorServiceComponent))
|
|
||||||
dumpServiceList(pw, "global", services.toTypedArray())
|
|
||||||
dumpServiceList(pw, "per-user", R.array.config_systemUIServiceComponentsPerUser)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun dumpServiceList(pw: PrintWriter, type: String, resId: Int) {
|
|
||||||
val services: Array<String> = context.resources.getStringArray(resId)
|
|
||||||
dumpServiceList(pw, type, services)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun dumpServiceList(pw: PrintWriter, type: String, services: Array<String>?) {
|
|
||||||
pw.print(type)
|
|
||||||
pw.print(": ")
|
|
||||||
if (services == null) {
|
|
||||||
pw.println("N/A")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pw.print(services.size)
|
|
||||||
pw.println(" services")
|
|
||||||
for (i in services.indices) {
|
|
||||||
pw.print(" ")
|
|
||||||
pw.print(i)
|
|
||||||
pw.print(": ")
|
|
||||||
pw.println(services[i])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dumpHelp(pw: PrintWriter) {
|
private fun dumpHelp(pw: PrintWriter) {
|
||||||
@@ -426,13 +386,6 @@ constructor(
|
|||||||
const val DUMPSYS_DUMPABLE_DIVIDER =
|
const val DUMPSYS_DUMPABLE_DIVIDER =
|
||||||
"----------------------------------------------------------------------------"
|
"----------------------------------------------------------------------------"
|
||||||
|
|
||||||
/**
|
|
||||||
* Important: do not change this divider without updating any bug report processing tools
|
|
||||||
* (e.g. ABT), since this divider is used to determine boundaries for bug report views
|
|
||||||
*/
|
|
||||||
const val DUMPSYS_BUFFER_DIVIDER =
|
|
||||||
"============================================================================"
|
|
||||||
|
|
||||||
private fun findBestTargetMatch(c: Collection<DumpsysEntry>, target: String) =
|
private fun findBestTargetMatch(c: Collection<DumpsysEntry>, target: String) =
|
||||||
c.asSequence().filter { it.name.endsWith(target) }.minByOrNull { it.name.length }
|
c.asSequence().filter { it.name.endsWith(target) }.minByOrNull { it.name.length }
|
||||||
|
|
||||||
@@ -453,42 +406,71 @@ constructor(
|
|||||||
is DumpableEntry,
|
is DumpableEntry,
|
||||||
is TableLogBufferEntry -> {
|
is TableLogBufferEntry -> {
|
||||||
println()
|
println()
|
||||||
println(entry.name)
|
println("${entry.name}:")
|
||||||
println(DUMPSYS_DUMPABLE_DIVIDER)
|
println(DUMPSYS_DUMPABLE_DIVIDER)
|
||||||
}
|
}
|
||||||
is LogBufferEntry -> {
|
is LogBufferEntry -> {
|
||||||
println()
|
println()
|
||||||
println()
|
println()
|
||||||
println("BUFFER ${entry.name}:")
|
println("BUFFER ${entry.name}:")
|
||||||
println(DUMPSYS_BUFFER_DIVIDER)
|
println(DUMPSYS_DUMPABLE_DIVIDER)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private fun PrintWriter.footer(entry: DumpsysEntry, dumpTimeMillis: Long) {
|
||||||
* Zero-arg utility to write a [DumpableEntry] to the given [PrintWriter] in a
|
if (entry !is DumpableEntry) return
|
||||||
* dumpsys-appropriate format.
|
println()
|
||||||
*/
|
print(entry.priority)
|
||||||
private fun dumpDumpable(entry: DumpableEntry, pw: PrintWriter) {
|
print(" dump took ")
|
||||||
pw.preamble(entry)
|
print(dumpTimeMillis)
|
||||||
entry.dumpable.dump(pw, arrayOf())
|
print("ms -- ")
|
||||||
|
print(entry.name)
|
||||||
|
if (entry.priority == DumpPriority.CRITICAL && dumpTimeMillis > 25) {
|
||||||
|
print(" -- warning: individual dump time exceeds 5% of total CRITICAL dump time!")
|
||||||
|
}
|
||||||
|
println()
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun PrintWriter.wrapSection(entry: DumpsysEntry, block: () -> Unit) {
|
||||||
|
preamble(entry)
|
||||||
|
val dumpTime = measureTimeMillis(block)
|
||||||
|
footer(entry, dumpTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zero-arg utility to write a [LogBufferEntry] to the given [PrintWriter] in a
|
* Utility to write a [DumpableEntry] to the given [PrintWriter] in a
|
||||||
* dumpsys-appropriate format.
|
* dumpsys-appropriate format.
|
||||||
*/
|
*/
|
||||||
private fun dumpBuffer(entry: LogBufferEntry, pw: PrintWriter) {
|
private fun dumpDumpable(
|
||||||
pw.preamble(entry)
|
entry: DumpableEntry,
|
||||||
entry.buffer.dump(pw, 0)
|
pw: PrintWriter,
|
||||||
|
args: Array<String> = arrayOf(),
|
||||||
|
) = pw.wrapSection(entry) {
|
||||||
|
entry.dumpable.dump(pw, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zero-arg utility to write a [TableLogBufferEntry] to the given [PrintWriter] in a
|
* Utility to write a [LogBufferEntry] to the given [PrintWriter] in a
|
||||||
* dumpsys-appropriate format.
|
* dumpsys-appropriate format.
|
||||||
*/
|
*/
|
||||||
private fun dumpTableBuffer(entry: TableLogBufferEntry, pw: PrintWriter) {
|
private fun dumpBuffer(
|
||||||
pw.preamble(entry)
|
entry: LogBufferEntry,
|
||||||
entry.table.dump(pw, arrayOf())
|
pw: PrintWriter,
|
||||||
|
tailLength: Int = 0,
|
||||||
|
) = pw.wrapSection(entry) {
|
||||||
|
entry.buffer.dump(pw, tailLength)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to write a [TableLogBufferEntry] to the given [PrintWriter] in a
|
||||||
|
* dumpsys-appropriate format.
|
||||||
|
*/
|
||||||
|
private fun dumpTableBuffer(
|
||||||
|
entry: TableLogBufferEntry,
|
||||||
|
pw: PrintWriter,
|
||||||
|
args: Array<String> = arrayOf(),
|
||||||
|
) = pw.wrapSection(entry) {
|
||||||
|
entry.table.dump(pw, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -510,6 +492,7 @@ constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val DATE_FORMAT = SimpleDateFormat("MM-dd HH:mm:ss.SSS", Locale.US)
|
||||||
private val PRIORITY_OPTIONS = arrayOf(PRIORITY_ARG_CRITICAL, PRIORITY_ARG_NORMAL)
|
private val PRIORITY_OPTIONS = arrayOf(PRIORITY_ARG_CRITICAL, PRIORITY_ARG_NORMAL)
|
||||||
|
|
||||||
private val COMMANDS =
|
private val COMMANDS =
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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.dump
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.android.systemui.CoreStartable
|
||||||
|
import com.android.systemui.Dumpable
|
||||||
|
import com.android.systemui.R
|
||||||
|
import com.android.systemui.dagger.SysUISingleton
|
||||||
|
import java.io.PrintWriter
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Provider
|
||||||
|
|
||||||
|
@SysUISingleton
|
||||||
|
class SystemUIConfigDumpable
|
||||||
|
@Inject
|
||||||
|
constructor(
|
||||||
|
dumpManager: DumpManager,
|
||||||
|
private val context: Context,
|
||||||
|
private val startables: MutableMap<Class<*>, Provider<CoreStartable>>,
|
||||||
|
) : Dumpable {
|
||||||
|
init {
|
||||||
|
dumpManager.registerCriticalDumpable("SystemUiServiceComponents", this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun dump(pw: PrintWriter, args: Array<out String>) {
|
||||||
|
pw.println("SystemUiServiceComponents configuration:")
|
||||||
|
pw.print("vendor component: ")
|
||||||
|
pw.println(context.resources.getString(R.string.config_systemUIVendorServiceComponent))
|
||||||
|
val services: MutableList<String> =
|
||||||
|
startables.keys.map { cls: Class<*> -> cls.simpleName }.toMutableList()
|
||||||
|
|
||||||
|
services.add(context.resources.getString(R.string.config_systemUIVendorServiceComponent))
|
||||||
|
dumpServiceList(pw, "global", services.toTypedArray())
|
||||||
|
dumpServiceList(pw, "per-user", R.array.config_systemUIServiceComponentsPerUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun dumpServiceList(pw: PrintWriter, type: String, resId: Int) {
|
||||||
|
val services: Array<String> = context.resources.getStringArray(resId)
|
||||||
|
dumpServiceList(pw, type, services)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun dumpServiceList(pw: PrintWriter, type: String, services: Array<String>?) {
|
||||||
|
pw.print(type)
|
||||||
|
pw.print(": ")
|
||||||
|
if (services == null) {
|
||||||
|
pw.println("N/A")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pw.print(services.size)
|
||||||
|
pw.println(" services")
|
||||||
|
for (i in services.indices) {
|
||||||
|
pw.print(" ")
|
||||||
|
pw.print(i)
|
||||||
|
pw.print(": ")
|
||||||
|
pw.println(services[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,10 +26,6 @@ import com.android.systemui.log.table.TableLogBuffer
|
|||||||
import com.android.systemui.util.mockito.any
|
import com.android.systemui.util.mockito.any
|
||||||
import com.android.systemui.util.mockito.eq
|
import com.android.systemui.util.mockito.eq
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import java.io.FileDescriptor
|
|
||||||
import java.io.PrintWriter
|
|
||||||
import java.io.StringWriter
|
|
||||||
import javax.inject.Provider
|
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
@@ -37,6 +33,10 @@ import org.mockito.Mockito.anyInt
|
|||||||
import org.mockito.Mockito.never
|
import org.mockito.Mockito.never
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
import java.io.FileDescriptor
|
||||||
|
import java.io.PrintWriter
|
||||||
|
import java.io.StringWriter
|
||||||
|
import javax.inject.Provider
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
class DumpHandlerTest : SysuiTestCase() {
|
class DumpHandlerTest : SysuiTestCase() {
|
||||||
@@ -79,14 +79,12 @@ class DumpHandlerTest : SysuiTestCase() {
|
|||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
|
|
||||||
dumpHandler = DumpHandler(
|
val config = SystemUIConfigDumpable(
|
||||||
mContext,
|
dumpManager,
|
||||||
dumpManager,
|
mContext,
|
||||||
logBufferEulogizer,
|
mutableMapOf(EmptyCoreStartable::class.java to Provider { EmptyCoreStartable() }),
|
||||||
mutableMapOf(
|
|
||||||
EmptyCoreStartable::class.java to Provider { EmptyCoreStartable() }
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
dumpHandler = DumpHandler(dumpManager, logBufferEulogizer, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user