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.statusbar.phone 18 19 import android.util.DisplayMetrics 20 import android.view.View 21 import com.android.internal.logging.nano.MetricsProto.MetricsEvent 22 import com.android.systemui.log.dagger.LSShadeTransitionLog 23 import com.android.systemui.log.LogBuffer 24 import com.android.systemui.log.core.LogLevel 25 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow 26 import com.android.systemui.statusbar.notification.row.ExpandableView 27 import javax.inject.Inject 28 29 private const val TAG = "LockscreenShadeTransitionController" 30 31 class LSShadeTransitionLogger @Inject constructor( 32 @LSShadeTransitionLog private val buffer: LogBuffer, 33 private val lockscreenGestureLogger: LockscreenGestureLogger, 34 private val displayMetrics: DisplayMetrics 35 ) { logUnSuccessfulDragDownnull36 fun logUnSuccessfulDragDown(startingChild: View?) { 37 buffer.log(TAG, LogLevel.INFO, { 38 str1 = (startingChild as? ExpandableNotificationRow)?.loggingKey ?: "no entry" 39 }, { 40 "Tried to drag down but can't drag down on $str1" 41 }) 42 } 43 logDragDownAbortednull44 fun logDragDownAborted() { 45 buffer.log(TAG, LogLevel.INFO, {}, { 46 "The drag down was aborted and reset to 0f." 47 }) 48 } 49 logDragDownStartednull50 fun logDragDownStarted(startingChild: ExpandableView?) { 51 buffer.log(TAG, LogLevel.INFO, { 52 str1 = (startingChild as? ExpandableNotificationRow)?.loggingKey ?: "no entry" 53 }, { 54 "The drag down has started on $str1" 55 }) 56 } 57 logDraggedDownLockDownShadenull58 fun logDraggedDownLockDownShade(startingChild: View?) { 59 buffer.log(TAG, LogLevel.INFO, { 60 str1 = (startingChild as? ExpandableNotificationRow)?.loggingKey ?: "no entry" 61 }, { 62 "Dragged down in locked down shade on $str1" 63 }) 64 } 65 logDraggedDownnull66 fun logDraggedDown(startingChild: View?, dragLengthY: Int) { 67 buffer.log(TAG, LogLevel.INFO, { 68 str1 = (startingChild as? ExpandableNotificationRow)?.loggingKey ?: "no entry" 69 }, { 70 "Drag down succeeded on $str1" 71 }) 72 // Do logging to event log not just our own buffer 73 lockscreenGestureLogger.write( 74 MetricsEvent.ACTION_LS_SHADE, 75 (dragLengthY / displayMetrics.density).toInt(), 76 0 /* velocityDp */) 77 lockscreenGestureLogger.log( 78 LockscreenGestureLogger.LockscreenUiEvent.LOCKSCREEN_PULL_SHADE_OPEN) 79 } 80 logDragDownAmountResetnull81 fun logDragDownAmountReset() { 82 buffer.log(TAG, LogLevel.DEBUG, {}, { 83 "The drag down amount has been reset to 0f." 84 }) 85 } 86 logDefaultGoToFullShadeAnimationnull87 fun logDefaultGoToFullShadeAnimation(delay: Long) { 88 buffer.log(TAG, LogLevel.DEBUG, { 89 long1 = delay 90 }, { 91 "Default animation started to full shade with delay $long1" 92 }) 93 } 94 logTryGoToLockedShadenull95 fun logTryGoToLockedShade(keyguard: Boolean) { 96 buffer.log(TAG, LogLevel.INFO, { 97 bool1 = keyguard 98 }, { 99 "Trying to go to locked shade " + if (bool1) "from keyguard" else "not from keyguard" 100 }) 101 } 102 logShadeDisabledOnGoToLockedShadenull103 fun logShadeDisabledOnGoToLockedShade() { 104 buffer.log(TAG, LogLevel.WARNING, {}, { 105 "The shade was disabled when trying to go to the locked shade" 106 }) 107 } 108 logShowBouncerOnGoToLockedShadenull109 fun logShowBouncerOnGoToLockedShade() { 110 buffer.log(TAG, LogLevel.INFO, {}, { 111 "Showing bouncer when trying to go to the locked shade" 112 }) 113 } 114 logGoingToLockedShadenull115 fun logGoingToLockedShade(customAnimationHandler: Boolean) { 116 buffer.log(TAG, LogLevel.INFO, { 117 bool1 = customAnimationHandler 118 }, { 119 "Going to locked shade " + if (customAnimationHandler) "with" else "without" + 120 " a custom handler" 121 }) 122 } 123 logOnHideKeyguardnull124 fun logOnHideKeyguard() { 125 buffer.log(TAG, LogLevel.INFO, {}, { 126 "Notified that the keyguard is being hidden" 127 }) 128 } 129 logPulseExpansionStartednull130 fun logPulseExpansionStarted() { 131 buffer.log(TAG, LogLevel.INFO, {}, { 132 "Pulse Expansion has started" 133 }) 134 } 135 logPulseExpansionFinishednull136 fun logPulseExpansionFinished(cancelled: Boolean) { 137 if (cancelled) { 138 buffer.log(TAG, LogLevel.INFO, {}, { 139 "Pulse Expansion is requested to cancel" 140 }) 141 } else { 142 buffer.log(TAG, LogLevel.INFO, {}, { 143 "Pulse Expansion is requested to finish" 144 }) 145 } 146 } 147 logDragDownAnimationnull148 fun logDragDownAnimation(target: Float) { 149 buffer.log(TAG, LogLevel.DEBUG, { 150 double1 = target.toDouble() 151 }, { 152 "Drag down amount animating to " + double1 153 }) 154 } 155 logAnimationCancellednull156 fun logAnimationCancelled(isPulse: Boolean) { 157 if (isPulse) { 158 buffer.log(TAG, LogLevel.DEBUG, {}, { 159 "Pulse animation cancelled" 160 }) 161 } else { 162 buffer.log(TAG, LogLevel.DEBUG, {}, { 163 "drag down animation cancelled" 164 }) 165 } 166 } 167 logDragDownAmountResetWhenFullyCollapsednull168 fun logDragDownAmountResetWhenFullyCollapsed() { 169 buffer.log(TAG, LogLevel.WARNING, {}, { 170 "Drag down amount stuck and reset after shade was fully collapsed" 171 }) 172 } 173 logPulseHeightNotResetWhenFullyCollapsednull174 fun logPulseHeightNotResetWhenFullyCollapsed() { 175 buffer.log(TAG, LogLevel.WARNING, {}, { 176 "Pulse height stuck and reset after shade was fully collapsed" 177 }) 178 } 179 logGoingToLockedShadeAbortednull180 fun logGoingToLockedShadeAborted() { 181 buffer.log(TAG, LogLevel.INFO, {}, { 182 "Going to the Locked Shade has been aborted" 183 }) 184 } 185 } 186