• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.view.MotionEvent
20 import com.android.systemui.log.LogBuffer
21 import com.android.systemui.log.core.LogLevel
22 import com.android.systemui.log.dagger.ShadeLog
23 import com.android.systemui.shade.ShadeViewController.Companion.FLING_COLLAPSE
24 import com.android.systemui.shade.ShadeViewController.Companion.FLING_EXPAND
25 import com.android.systemui.shade.ShadeViewController.Companion.FLING_HIDE
26 import com.google.errorprone.annotations.CompileTimeConstant
27 import javax.inject.Inject
28 
29 private const val TAG = "systemui.shade"
30 
31 /** Lightweight logging utility for the Shade. */
32 class ShadeLogger @Inject constructor(@ShadeLog private val buffer: LogBuffer) {
vnull33     fun v(@CompileTimeConstant msg: String) {
34         buffer.log(TAG, LogLevel.VERBOSE, msg)
35     }
36 
dnull37     fun d(@CompileTimeConstant msg: String) {
38         buffer.log(TAG, LogLevel.DEBUG, msg)
39     }
40 
onQsInterceptMoveQsTrackingEnablednull41     fun onQsInterceptMoveQsTrackingEnabled(h: Float) {
42         buffer.log(
43             TAG,
44             LogLevel.VERBOSE,
45             { double1 = h.toDouble() },
46             { "onQsIntercept: move action, QS tracking enabled. h = $double1" }
47         )
48     }
49 
logQsTrackingNotStartednull50     fun logQsTrackingNotStarted(
51         initialTouchY: Float,
52         y: Float,
53         h: Float,
54         touchSlop: Float,
55         qsExpanded: Boolean,
56         keyguardShowing: Boolean,
57         qsExpansionEnabled: Boolean,
58         downTime: Long
59     ) {
60         buffer.log(
61             TAG,
62             LogLevel.VERBOSE,
63             {
64                 int1 = initialTouchY.toInt()
65                 int2 = y.toInt()
66                 long1 = h.toLong()
67                 double1 = touchSlop.toDouble()
68                 bool1 = qsExpanded
69                 bool2 = keyguardShowing
70                 bool3 = qsExpansionEnabled
71                 str1 = downTime.toString()
72             },
73             {
74                 "QsTrackingNotStarted: downTime=$str1,initTouchY=$int1,y=$int2,h=$long1," +
75                     "slop=$double1,qsExpanded=$bool1,keyguardShowing=$bool2,qsExpansion=$bool3"
76             }
77         )
78     }
79 
logMotionEventnull80     fun logMotionEvent(event: MotionEvent, message: String) {
81         buffer.log(
82             TAG,
83             LogLevel.VERBOSE,
84             {
85                 str1 = message
86                 long1 = event.eventTime
87                 long2 = event.downTime
88                 int1 = event.action
89                 int2 = event.classification
90             },
91             { "$str1: eventTime=$long1,downTime=$long2,action=$int1,class=$int2" }
92         )
93     }
94 
95     /** Logs motion event dispatch results from NotificationShadeWindowViewController. */
logShadeWindowDispatchnull96     fun logShadeWindowDispatch(event: MotionEvent, message: String, result: Boolean?) {
97         buffer.log(
98             TAG,
99             LogLevel.VERBOSE,
100             {
101                 str1 = message
102                 long1 = event.eventTime
103                 long2 = event.downTime
104             },
105             {
106                 val prefix =
107                     when (result) {
108                         true -> "SHADE TOUCH REROUTED"
109                         false -> "SHADE TOUCH BLOCKED"
110                         null -> "SHADE TOUCH DISPATCHED"
111                     }
112                 "$prefix: eventTime=$long1,downTime=$long2, reason=$str1"
113             }
114         )
115     }
116 
logMotionEventStatusBarStatenull117     fun logMotionEventStatusBarState(event: MotionEvent, statusBarState: Int, message: String) {
118         buffer.log(
119             TAG,
120             LogLevel.VERBOSE,
121             {
122                 str1 = message
123                 long1 = event.eventTime
124                 long2 = event.downTime
125                 int1 = event.action
126                 int2 = statusBarState
127                 double1 = event.y.toDouble()
128             },
129             {
130                 "$str1\neventTime=$long1,downTime=$long2,y=$double1,action=$int1," +
131                     "statusBarState=${when (int2) {
132                                 0 -> "SHADE"
133                                 1 -> "KEYGUARD"
134                                 2 -> "SHADE_LOCKED"
135                                 else -> "UNKNOWN:$int2"
136                             }}"
137             }
138         )
139     }
140 
logExpansionChangednull141     fun logExpansionChanged(
142         message: String,
143         fraction: Float,
144         expanded: Boolean,
145         tracking: Boolean,
146         dragDownPxAmount: Float,
147     ) {
148         buffer.log(
149             TAG,
150             LogLevel.VERBOSE,
151             {
152                 str1 = message
153                 double1 = fraction.toDouble()
154                 bool1 = expanded
155                 bool2 = tracking
156                 long1 = dragDownPxAmount.toLong()
157             },
158             {
159                 "$str1 fraction=$double1,expanded=$bool1," +
160                     "tracking=$bool2," +
161                     "dragDownPxAmount=$dragDownPxAmount"
162             }
163         )
164     }
165 
logHasVibratednull166     fun logHasVibrated(hasVibratedOnOpen: Boolean, fraction: Float) {
167         buffer.log(
168             TAG,
169             LogLevel.VERBOSE,
170             {
171                 bool1 = hasVibratedOnOpen
172                 double1 = fraction.toDouble()
173             },
174             { "hasVibratedOnOpen=$bool1, expansionFraction=$double1" }
175         )
176     }
177 
logQsExpandImmediateChangednull178     fun logQsExpandImmediateChanged(newValue: Boolean) {
179         buffer.log(TAG, LogLevel.VERBOSE, { bool1 = newValue }, { "qsExpandImmediate=$bool1" })
180     }
181 
logQsExpansionChangednull182     fun logQsExpansionChanged(
183         message: String,
184         qsExpanded: Boolean,
185         qsMinExpansionHeight: Int,
186         qsMaxExpansionHeight: Int,
187         stackScrollerOverscrolling: Boolean,
188         qsAnimatorExpand: Boolean,
189         animatingQs: Boolean
190     ) {
191         buffer.log(
192             TAG,
193             LogLevel.VERBOSE,
194             {
195                 str1 = message
196                 bool1 = qsExpanded
197                 int1 = qsMinExpansionHeight
198                 int2 = qsMaxExpansionHeight
199                 bool2 = stackScrollerOverscrolling
200                 bool3 = qsAnimatorExpand
201                 // 0 = false, 1 = true
202                 long1 = animatingQs.compareTo(false).toLong()
203             },
204             {
205                 "$str1 qsExpanded=$bool1,qsMinExpansionHeight=$int1,qsMaxExpansionHeight=$int2," +
206                     "stackScrollerOverscrolling=$bool2,qsAnimatorExpand=$bool3," +
207                     "animatingQs=$long1"
208             }
209         )
210     }
211 
logSingleTapUpnull212     fun logSingleTapUp(isDozing: Boolean, singleTapEnabled: Boolean, isNotDocked: Boolean) {
213         buffer.log(
214             TAG,
215             LogLevel.DEBUG,
216             {
217                 bool1 = isDozing
218                 bool2 = singleTapEnabled
219                 bool3 = isNotDocked
220             },
221             {
222                 "PulsingGestureListener#onSingleTapUp all of this must true for single " +
223                     "tap to be detected: isDozing: $bool1, singleTapEnabled: $bool2," +
224                     " isNotDocked: $bool3"
225             }
226         )
227     }
228 
logSingleTapUpFalsingStatenull229     fun logSingleTapUpFalsingState(proximityIsNotNear: Boolean, isNotFalseTap: Boolean) {
230         buffer.log(
231             TAG,
232             LogLevel.DEBUG,
233             {
234                 bool1 = proximityIsNotNear
235                 bool2 = isNotFalseTap
236             },
237             {
238                 "PulsingGestureListener#onSingleTapUp all of this must true for single " +
239                     "tap to be detected: proximityIsNotNear: $bool1, isNotFalseTap: $bool2"
240             }
241         )
242     }
243 
logNotInterceptingTouchInstantExpandingnull244     fun logNotInterceptingTouchInstantExpanding(
245         instantExpanding: Boolean,
246         notificationsDragEnabled: Boolean,
247         touchDisabled: Boolean
248     ) {
249         buffer.log(
250             TAG,
251             LogLevel.VERBOSE,
252             {
253                 bool1 = instantExpanding
254                 bool2 = notificationsDragEnabled
255                 bool3 = touchDisabled
256             },
257             {
258                 "NPVC not intercepting touch, instantExpanding: $bool1, " +
259                     "!notificationsDragEnabled: $bool2, touchDisabled: $bool3"
260             }
261         )
262     }
263 
logLastFlingWasExpandingnull264     fun logLastFlingWasExpanding(expand: Boolean) {
265         buffer.log(
266             TAG,
267             LogLevel.VERBOSE,
268             { bool1 = expand },
269             { "NPVC mLastFlingWasExpanding set to: $bool1" }
270         )
271     }
272 
logFlingExpandsnull273     fun logFlingExpands(
274         vel: Float,
275         vectorVel: Float,
276         interactionType: Int,
277         minVelocityPxPerSecond: Float,
278         expansionOverHalf: Boolean,
279         allowExpandForSmallExpansion: Boolean
280     ) {
281         buffer.log(
282             TAG,
283             LogLevel.VERBOSE,
284             {
285                 int1 = interactionType
286                 long1 = vel.toLong()
287                 long2 = vectorVel.toLong()
288                 double1 = minVelocityPxPerSecond.toDouble()
289                 bool1 = expansionOverHalf
290                 bool2 = allowExpandForSmallExpansion
291             },
292             {
293                 "NPVC flingExpands called with vel: $long1, vectorVel: $long2, " +
294                     "interactionType: $int1, minVelocityPxPerSecond: $double1 " +
295                     "expansionOverHalf: $bool1, allowExpandForSmallExpansion: $bool2"
296             }
297         )
298     }
299 
logEndMotionEventnull300     fun logEndMotionEvent(
301         msg: String,
302         forceCancel: Boolean,
303         expand: Boolean,
304     ) {
305         buffer.log(
306             TAG,
307             LogLevel.VERBOSE,
308             {
309                 str1 = msg
310                 bool1 = forceCancel
311                 bool2 = expand
312             },
313             { "$str1; force=$bool1; expand=$bool2" }
314         )
315     }
316 
logPanelClosedOnDownnull317     fun logPanelClosedOnDown(
318         msg: String,
319         panelClosedOnDown: Boolean,
320         expandFraction: Float,
321     ) {
322         buffer.log(
323             TAG,
324             LogLevel.VERBOSE,
325             {
326                 str1 = msg
327                 bool1 = panelClosedOnDown
328                 double1 = expandFraction.toDouble()
329             },
330             { "$str1; mPanelClosedOnDown=$bool1; mExpandedFraction=$double1" }
331         )
332     }
333 
logPanelStateChangednull334     fun logPanelStateChanged(@PanelState panelState: Int) {
335         buffer.log(
336             TAG,
337             LogLevel.VERBOSE,
338             { str1 = panelState.panelStateToString() },
339             { "New panel State: $str1" }
340         )
341     }
342 
flingQsnull343     fun flingQs(flingType: Int, isClick: Boolean) {
344         buffer.log(
345             TAG,
346             LogLevel.VERBOSE,
347             {
348                 str1 = flingTypeToString(flingType)
349                 bool1 = isClick
350             },
351             { "QS fling with type $str1, originated from click: $isClick" }
352         )
353     }
354 
flingTypeToStringnull355     private fun flingTypeToString(flingType: Int) =
356         when (flingType) {
357             FLING_EXPAND -> "FLING_EXPAND"
358             FLING_COLLAPSE -> "FLING_COLLAPSE"
359             FLING_HIDE -> "FLING_HIDE"
360             else -> "UNKNOWN"
361         }
362 
logSplitShadeChangednull363     fun logSplitShadeChanged(splitShadeEnabled: Boolean) {
364         buffer.log(
365             TAG,
366             LogLevel.VERBOSE,
367             { bool1 = splitShadeEnabled },
368             { "Split shade state changed: split shade ${if (bool1) "enabled" else "disabled"}" }
369         )
370     }
371 
logUpdateNotificationPanelTouchStatenull372     fun logUpdateNotificationPanelTouchState(
373         disabled: Boolean,
374         isGoingToSleep: Boolean,
375         shouldControlScreenOff: Boolean,
376         deviceInteractive: Boolean,
377         isPulsing: Boolean,
378     ) {
379         buffer.log(
380             TAG,
381             LogLevel.VERBOSE,
382             {
383                 bool1 = disabled
384                 bool2 = isGoingToSleep
385                 bool3 = shouldControlScreenOff
386                 bool4 = deviceInteractive
387                 str1 = isPulsing.toString()
388             },
389             {
390                 "CentralSurfaces updateNotificationPanelTouchState set disabled to: $bool1\n" +
391                     "isGoingToSleep: $bool2, !shouldControlScreenOff: $bool3," +
392                     "!mDeviceInteractive: $bool4, !isPulsing: $str1"
393             }
394         )
395     }
396 
logNoTouchDispatchnull397     fun logNoTouchDispatch(
398         isTrackingBarGesture: Boolean,
399         isExpandAnimationRunning: Boolean,
400     ) {
401         buffer.log(
402             TAG,
403             LogLevel.VERBOSE,
404             {
405                 bool1 = isTrackingBarGesture
406                 bool2 = isExpandAnimationRunning
407             },
408             {
409                 "NSWVC: touch not dispatched: isTrackingBarGesture: $bool1, " +
410                     "isExpandAnimationRunning: $bool2"
411             }
412         )
413     }
414 
logKeyguardStatudBarVisibiliynull415     fun logKeyguardStatudBarVisibiliy(
416         visibility: Boolean,
417         isOnAod: Boolean,
418         animatingUnlockedShadeToKeyguardBypass: Boolean,
419         oldShadeState: Int,
420         newShadeState: Int,
421     ) {
422         buffer.log(
423             TAG,
424             LogLevel.VERBOSE,
425             {
426                 bool1 = visibility
427                 bool2 = isOnAod
428                 bool3 = animatingUnlockedShadeToKeyguardBypass
429                 int1 = oldShadeState
430                 int2 = newShadeState
431             },
432             {
433                 "Setting keyguard status bar visibility to: $bool1, isOnAod: $bool2" +
434                     "oldShadeState: $int1, newShadeState: $int2," +
435                     "animatingUnlockedShadeToKeyguardBypass: $bool3"
436             }
437         )
438     }
439 }
440