1 package com.android.systemui.statusbar.notification.stack
2 
3 import android.view.ViewGroup
4 import com.android.systemui.log.LogBuffer
5 import com.android.systemui.log.core.LogLevel.DEBUG
6 import com.android.systemui.log.core.LogLevel.INFO
7 import com.android.systemui.log.core.LogLevel.ERROR
8 import com.android.systemui.log.dagger.NotificationHeadsUpLog
9 import com.android.systemui.log.dagger.NotificationRenderLog
10 import com.android.systemui.log.dagger.ShadeLog
11 import com.android.systemui.statusbar.notification.collection.NotificationEntry
12 import com.android.systemui.statusbar.notification.logKey
13 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_ADD
14 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_APPEAR
15 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR
16 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK
17 import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.AnimationEvent.ANIMATION_TYPE_HEADS_UP_OTHER
18 import com.google.errorprone.annotations.CompileTimeConstant
19 import javax.inject.Inject
20 
21 class NotificationStackScrollLogger @Inject constructor(
22     @NotificationHeadsUpLog private val buffer: LogBuffer,
23     @NotificationRenderLog private val notificationRenderBuffer: LogBuffer,
24     @ShadeLog private val shadeLogBuffer: LogBuffer,
25 ) {
hunAnimationSkippednull26     fun hunAnimationSkipped(entry: NotificationEntry, reason: String) {
27         buffer.log(TAG, INFO, {
28             str1 = entry.logKey
29             str2 = reason
30         }, {
31             "heads up animation skipped: key: $str1 reason: $str2"
32         })
33     }
hunAnimationEventAddednull34     fun hunAnimationEventAdded(entry: NotificationEntry, type: Int) {
35         val reason: String
36         reason = if (type == ANIMATION_TYPE_HEADS_UP_DISAPPEAR) {
37             "HEADS_UP_DISAPPEAR"
38         } else if (type == ANIMATION_TYPE_HEADS_UP_DISAPPEAR_CLICK) {
39             "HEADS_UP_DISAPPEAR_CLICK"
40         } else if (type == ANIMATION_TYPE_HEADS_UP_APPEAR) {
41             "HEADS_UP_APPEAR"
42         } else if (type == ANIMATION_TYPE_HEADS_UP_OTHER) {
43             "HEADS_UP_OTHER"
44         } else if (type == ANIMATION_TYPE_ADD) {
45             "ADD"
46         } else {
47             type.toString()
48         }
49         buffer.log(TAG, INFO, {
50             str1 = entry.logKey
51             str2 = reason
52         }, {
53             "heads up animation added: $str1 with type $str2"
54         })
55     }
56 
hunSkippedForUnexpectedStatenull57     fun hunSkippedForUnexpectedState(entry: NotificationEntry, expected: Boolean, actual: Boolean) {
58         buffer.log(TAG, INFO, {
59             str1 = entry.logKey
60             bool1 = expected
61             bool2 = actual
62         }, {
63             "HUN animation skipped for unexpected hun state: " +
64                     "key: $str1 expected: $bool1 actual: $bool2"
65         })
66     }
67 
logShadeDebugEventnull68     fun logShadeDebugEvent(@CompileTimeConstant msg: String) = shadeLogBuffer.log(TAG, DEBUG, msg)
69 
70     fun logEmptySpaceClick(
71         isBelowLastNotification: Boolean,
72         statusBarState: Int,
73         touchIsClick: Boolean,
74         motionEventDesc: String
75     ) {
76         shadeLogBuffer.log(TAG, DEBUG, {
77             int1 = statusBarState
78             bool1 = touchIsClick
79             bool2 = isBelowLastNotification
80             str1 = motionEventDesc
81         }, {
82             "handleEmptySpaceClick: statusBarState: $int1 isTouchAClick: $bool1 " +
83                     "isTouchBelowNotification: $bool2 motionEvent: $str1"
84         })
85     }
86 
transientNotificationRowTraversalCleanednull87     fun transientNotificationRowTraversalCleaned(entry: NotificationEntry, reason: String) {
88         notificationRenderBuffer.log(TAG, INFO, {
89             str1 = entry.logKey
90             str2 = reason
91         }, {
92             "transientNotificationRowTraversalCleaned: key: $str1 reason: $str2"
93         })
94     }
95 
addTransientChildNotificationToChildContainernull96     fun addTransientChildNotificationToChildContainer(
97             childEntry: NotificationEntry,
98             containerEntry: NotificationEntry,
99     ) {
100         notificationRenderBuffer.log(TAG, INFO, {
101             str1 = childEntry.logKey
102             str2 = containerEntry.logKey
103         }, {
104             "addTransientChildToContainer from onViewRemovedInternal: childKey: $str1 " +
105                     "-- containerKey: $str2"
106         })
107     }
108 
addTransientChildNotificationToNsslnull109     fun addTransientChildNotificationToNssl(
110             childEntry: NotificationEntry,
111     ) {
112         notificationRenderBuffer.log(TAG, INFO, {
113             str1 = childEntry.logKey
114         }, {
115             "addTransientRowToNssl from onViewRemovedInternal: childKey: $str1"
116         })
117     }
118 
addTransientChildNotificationToViewGroupnull119     fun addTransientChildNotificationToViewGroup(
120             childEntry: NotificationEntry,
121             container: ViewGroup
122     ) {
123         notificationRenderBuffer.log(TAG, ERROR, {
124             str1 = childEntry.logKey
125             str2 = container.toString()
126         }, {
127             "addTransientRowTo unhandled ViewGroup from onViewRemovedInternal: childKey: $str1 " +
128                     "-- ViewGroup: $str2"
129         })
130     }
131 
addTransientRownull132     fun addTransientRow(
133             childEntry: NotificationEntry,
134             index: Int
135     ) {
136         notificationRenderBuffer.log(
137                 TAG,
138                 INFO,
139                 {
140                     str1 = childEntry.logKey
141                     int1 = index
142                 },
143                 { "addTransientRow to NSSL: childKey: $str1 -- index: $int1" }
144         )
145     }
146 
removeTransientRownull147     fun removeTransientRow(
148             childEntry: NotificationEntry,
149     ) {
150         notificationRenderBuffer.log(
151                 TAG,
152                 INFO,
153                 {
154                     str1 = childEntry.logKey
155                 },
156                 { "removeTransientRow from NSSL: childKey: $str1" }
157         )
158     }
159 }
160 
161 private const val TAG = "NotificationStackScroll"