• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.shade
18 
19 import android.content.res.Configuration
20 import com.android.app.tracing.coroutines.TrackTracer
21 
22 /**
23  * Centralized logging for shade-related events to a dedicated Perfetto track.
24  *
25  * Used by shade components to log events to a track named [TRACK_NAME]. This consolidates
26  * shade-specific events into a single track for easier analysis in Perfetto, rather than scattering
27  * them across various threads' logs.
28  */
29 object ShadeTraceLogger {
30     val t = TrackTracer(trackName = "ShadeTraceLogger", trackGroup = "shade")
31 
32     @JvmStatic
logOnMovedToDisplaynull33     fun logOnMovedToDisplay(displayId: Int, config: Configuration) {
34         t.instant { "onMovedToDisplay(displayId=$displayId, dpi=${config.densityDpi})" }
35     }
36 
37     @JvmStatic
logOnConfigChangednull38     fun logOnConfigChanged(config: Configuration) {
39         t.instant {
40             "NotificationShadeWindowView#onConfigurationChanged(dpi=${config.densityDpi}, " +
41                     "smallestWidthDp=${config.smallestScreenWidthDp})"
42         }
43     }
44 
45     @JvmStatic
logMoveShadeWindowTonull46     fun logMoveShadeWindowTo(displayId: Int) {
47         t.instant { "moveShadeWindowTo(displayId=$displayId)" }
48     }
49 
traceReparentingnull50     suspend fun traceReparenting(r: suspend () -> Unit) {
51         t.traceAsync({ "reparenting" }) { r() }
52     }
53 
traceWaitForExpansionnull54     inline fun traceWaitForExpansion(expansion: Float, r: () -> Unit) {
55         t.traceAsync({ "waiting for shade expansion to match $expansion" }) { r() }
56     }
57 }
58