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.dagger.ShadeLog 21 import com.android.systemui.plugins.log.LogBuffer 22 import com.android.systemui.plugins.log.LogLevel 23 import com.android.systemui.shade.NotificationPanelViewController.FLING_COLLAPSE 24 import com.android.systemui.shade.NotificationPanelViewController.FLING_EXPAND 25 import com.android.systemui.shade.NotificationPanelViewController.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 ) { 59 buffer.log( 60 TAG, 61 LogLevel.VERBOSE, 62 { 63 int1 = initialTouchY.toInt() 64 int2 = y.toInt() 65 long1 = h.toLong() 66 double1 = touchSlop.toDouble() 67 bool1 = qsExpanded 68 bool2 = keyguardShowing 69 bool3 = qsExpansionEnabled 70 }, 71 { 72 "QsTrackingNotStarted: initTouchY=$int1,y=$int2,h=$long1,slop=$double1,qsExpanded" + 73 "=$bool1,keyguardShowing=$bool2,qsExpansion=$bool3" 74 } 75 ) 76 } 77 logMotionEventnull78 fun logMotionEvent(event: MotionEvent, message: String) { 79 buffer.log( 80 TAG, 81 LogLevel.VERBOSE, 82 { 83 str1 = message 84 long1 = event.eventTime 85 long2 = event.downTime 86 int1 = event.action 87 int2 = event.classification 88 double1 = event.y.toDouble() 89 }, 90 { 91 "$str1\neventTime=$long1,downTime=$long2,y=$double1,action=$int1,class=$int2" 92 } 93 ) 94 } 95 logMotionEventStatusBarStatenull96 fun logMotionEventStatusBarState(event: MotionEvent, statusBarState: Int, message: String) { 97 buffer.log( 98 TAG, 99 LogLevel.VERBOSE, 100 { 101 str1 = message 102 long1 = event.eventTime 103 long2 = event.downTime 104 int1 = event.action 105 int2 = statusBarState 106 double1 = event.y.toDouble() 107 }, 108 { 109 "$str1\neventTime=$long1,downTime=$long2,y=$double1,action=$int1," + 110 "statusBarState=${when (int2) { 111 0 -> "SHADE" 112 1 -> "KEYGUARD" 113 2 -> "SHADE_LOCKED" 114 else -> "UNKNOWN:$int2" 115 }}" 116 } 117 ) 118 } 119 logExpansionChangednull120 fun logExpansionChanged( 121 message: String, 122 fraction: Float, 123 expanded: Boolean, 124 tracking: Boolean, 125 dragDownPxAmount: Float, 126 ) { 127 buffer.log( 128 TAG, 129 LogLevel.VERBOSE, 130 { 131 str1 = message 132 double1 = fraction.toDouble() 133 bool1 = expanded 134 bool2 = tracking 135 long1 = dragDownPxAmount.toLong() 136 }, 137 { 138 "$str1 fraction=$double1,expanded=$bool1," + 139 "tracking=$bool2," + "dragDownPxAmount=$dragDownPxAmount" 140 } 141 ) 142 } 143 logHasVibratednull144 fun logHasVibrated(hasVibratedOnOpen: Boolean, fraction: Float) { 145 buffer.log( 146 TAG, 147 LogLevel.VERBOSE, 148 { 149 bool1 = hasVibratedOnOpen 150 double1 = fraction.toDouble() 151 }, 152 { "hasVibratedOnOpen=$bool1, expansionFraction=$double1" } 153 ) 154 } 155 logQsExpandImmediateChangednull156 fun logQsExpandImmediateChanged(newValue: Boolean) { 157 buffer.log( 158 TAG, 159 LogLevel.VERBOSE, 160 { 161 bool1 = newValue 162 }, 163 { "qsExpandImmediate=$bool1" } 164 ) 165 } 166 logQsExpansionChangednull167 fun logQsExpansionChanged( 168 message: String, 169 qsExpanded: Boolean, 170 qsMinExpansionHeight: Int, 171 qsMaxExpansionHeight: Int, 172 stackScrollerOverscrolling: Boolean, 173 qsAnimatorExpand: Boolean, 174 animatingQs: Boolean 175 ) { 176 buffer.log( 177 TAG, 178 LogLevel.VERBOSE, 179 { 180 str1 = message 181 bool1 = qsExpanded 182 int1 = qsMinExpansionHeight 183 int2 = qsMaxExpansionHeight 184 bool2 = stackScrollerOverscrolling 185 bool3 = qsAnimatorExpand 186 // 0 = false, 1 = true 187 long1 = animatingQs.compareTo(false).toLong() 188 }, 189 { 190 "$str1 qsExpanded=$bool1,qsMinExpansionHeight=$int1,qsMaxExpansionHeight=$int2," + 191 "stackScrollerOverscrolling=$bool2,qsAnimatorExpand=$bool3," + 192 "animatingQs=$long1" 193 } 194 ) 195 } 196 logSingleTapUpnull197 fun logSingleTapUp(isDozing: Boolean, singleTapEnabled: Boolean, isNotDocked: Boolean) { 198 buffer.log( 199 TAG, 200 LogLevel.DEBUG, 201 { 202 bool1 = isDozing 203 bool2 = singleTapEnabled 204 bool3 = isNotDocked 205 }, 206 { 207 "PulsingGestureListener#onSingleTapUp all of this must true for single " + 208 "tap to be detected: isDozing: $bool1, singleTapEnabled: $bool2, isNotDocked: $bool3" 209 }) 210 } 211 logSingleTapUpFalsingStatenull212 fun logSingleTapUpFalsingState(proximityIsNotNear: Boolean, isNotFalseTap: Boolean) { 213 buffer.log( 214 TAG, 215 LogLevel.DEBUG, 216 { 217 bool1 = proximityIsNotNear 218 bool2 = isNotFalseTap 219 }, 220 { 221 "PulsingGestureListener#onSingleTapUp all of this must true for single " + 222 "tap to be detected: proximityIsNotNear: $bool1, isNotFalseTap: $bool2" 223 } 224 ) 225 } 226 logNotInterceptingTouchInstantExpandingnull227 fun logNotInterceptingTouchInstantExpanding( 228 instantExpanding: Boolean, 229 notificationsDragEnabled: Boolean, 230 touchDisabled: Boolean 231 ) { 232 buffer.log( 233 TAG, 234 LogLevel.VERBOSE, 235 { 236 bool1 = instantExpanding 237 bool2 = notificationsDragEnabled 238 bool3 = touchDisabled 239 }, 240 { 241 "NPVC not intercepting touch, instantExpanding: $bool1, " + 242 "!notificationsDragEnabled: $bool2, touchDisabled: $bool3" 243 } 244 ) 245 } 246 logLastFlingWasExpandingnull247 fun logLastFlingWasExpanding(expand: Boolean) { 248 buffer.log( 249 TAG, 250 LogLevel.VERBOSE, 251 { bool1 = expand }, 252 { "NPVC mLastFlingWasExpanding set to: $bool1" } 253 ) 254 } 255 flingQsnull256 fun flingQs(flingType: Int, isClick: Boolean) { 257 buffer.log( 258 TAG, 259 LogLevel.VERBOSE, 260 { 261 str1 = flingTypeToString(flingType) 262 bool1 = isClick 263 }, 264 { "QS fling with type $str1, originated from click: $isClick" } 265 ) 266 } 267 flingTypeToStringnull268 private fun flingTypeToString(flingType: Int) = when (flingType) { 269 FLING_EXPAND -> "FLING_EXPAND" 270 FLING_COLLAPSE -> "FLING_COLLAPSE" 271 FLING_HIDE -> "FLING_HIDE" 272 else -> "UNKNOWN" 273 } 274 logSplitShadeChangednull275 fun logSplitShadeChanged(splitShadeEnabled: Boolean) { 276 buffer.log( 277 TAG, 278 LogLevel.VERBOSE, 279 { bool1 = splitShadeEnabled }, 280 { "Split shade state changed: split shade ${if (bool1) "enabled" else "disabled"}" } 281 ) 282 } 283 logNotificationsTopPaddingnull284 fun logNotificationsTopPadding(message: String, padding: Int) { 285 buffer.log( 286 TAG, 287 LogLevel.VERBOSE, 288 { 289 str1 = message 290 int1 = padding 291 }, 292 { "QSC NotificationsTopPadding $str1: $int1"} 293 ) 294 } 295 logClippingTopBoundnull296 fun logClippingTopBound(message: String, top: Int) { 297 buffer.log( 298 TAG, 299 LogLevel.VERBOSE, 300 { 301 str1 = message 302 int1 = top 303 }, 304 { "QSC ClippingTopBound $str1: $int1" } 305 ) 306 } 307 logNotificationsClippingTopBoundnull308 fun logNotificationsClippingTopBound(top: Int, nsslTop: Int) { 309 buffer.log( 310 TAG, 311 LogLevel.VERBOSE, 312 { 313 int1 = top 314 int2 = nsslTop 315 }, 316 { "QSC NotificationsClippingTopBound set to $int1 - $int2" } 317 ) 318 } 319 } 320