• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.dump
18 
19 import com.android.systemui.Dumpable
20 import com.android.systemui.log.LogBuffer
21 import com.android.systemui.log.table.TableLogBuffer
22 
23 /**
24  * A DumpsysEntry is a named, registered entry tracked by [DumpManager] which can be addressed and
25  * used both in a bugreport / dumpsys invocation or in an individual CLI implementation.
26  *
27  * The idea here is that we define every type that [DumpManager] knows about and defines the minimum
28  * shared interface between each type. So far, just [name] and [priority]. This way, [DumpManager]
29  * can just store them in separate maps and do the minimal amount of work to discriminate between
30  * them.
31  *
32  * Individual consumers can request these participants in a list via the relevant get* methods on
33  * [DumpManager]
34  */
35 sealed interface DumpsysEntry {
36     val name: String
37     val priority: DumpPriority
38 
39     data class DumpableEntry(
40         val dumpable: Dumpable,
41         override val name: String,
42         override val priority: DumpPriority,
43     ) : DumpsysEntry
44 
45     data class LogBufferEntry(
46         val buffer: LogBuffer,
47         override val name: String,
48     ) : DumpsysEntry {
49         // All buffers must be priority NORMAL, not CRITICAL, because they often contain a lot of
50         // data.
51         override val priority: DumpPriority = DumpPriority.NORMAL
52     }
53 
54     data class TableLogBufferEntry(
55         val table: TableLogBuffer,
56         override val name: String,
57     ) : DumpsysEntry {
58         // All buffers must be priority NORMAL, not CRITICAL, because they often contain a lot of
59         // data.
60         override val priority: DumpPriority = DumpPriority.NORMAL
61     }
62 }
63