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 val entry = (startingChild as? ExpandableNotificationRow)?.entry 38 buffer.log(TAG, LogLevel.INFO, { 39 str1 = entry?.key ?: "no entry" 40 }, { 41 "Tried to drag down but can't drag down on $str1" 42 }) 43 } 44 logDragDownAbortednull45 fun logDragDownAborted() { 46 buffer.log(TAG, LogLevel.INFO, {}, { 47 "The drag down was aborted and reset to 0f." 48 }) 49 } 50 logDragDownStartednull51 fun logDragDownStarted(startingChild: ExpandableView?) { 52 val entry = (startingChild as? ExpandableNotificationRow)?.entry 53 buffer.log(TAG, LogLevel.INFO, { 54 str1 = entry?.key ?: "no entry" 55 }, { 56 "The drag down has started on $str1" 57 }) 58 } 59 logDraggedDownLockDownShadenull60 fun logDraggedDownLockDownShade(startingChild: View?) { 61 val entry = (startingChild as? ExpandableNotificationRow)?.entry 62 buffer.log(TAG, LogLevel.INFO, { 63 str1 = entry?.key ?: "no entry" 64 }, { 65 "Dragged down in locked down shade on $str1" 66 }) 67 } 68 logDraggedDownnull69 fun logDraggedDown(startingChild: View?, dragLengthY: Int) { 70 val entry = (startingChild as? ExpandableNotificationRow)?.entry 71 buffer.log(TAG, LogLevel.INFO, { 72 str1 = entry?.key ?: "no entry" 73 }, { 74 "Drag down succeeded on $str1" 75 }) 76 // Do logging to event log not just our own buffer 77 lockscreenGestureLogger.write( 78 MetricsEvent.ACTION_LS_SHADE, 79 (dragLengthY / displayMetrics.density).toInt(), 80 0 /* velocityDp */) 81 lockscreenGestureLogger.log( 82 LockscreenGestureLogger.LockscreenUiEvent.LOCKSCREEN_PULL_SHADE_OPEN) 83 } 84 logDragDownAmountResetnull85 fun logDragDownAmountReset() { 86 buffer.log(TAG, LogLevel.DEBUG, {}, { 87 "The drag down amount has been reset to 0f." 88 }) 89 } 90 logDefaultGoToFullShadeAnimationnull91 fun logDefaultGoToFullShadeAnimation(delay: Long) { 92 buffer.log(TAG, LogLevel.DEBUG, { 93 long1 = delay 94 }, { 95 "Default animation started to full shade with delay $long1" 96 }) 97 } 98 logTryGoToLockedShadenull99 fun logTryGoToLockedShade(keyguard: Boolean) { 100 buffer.log(TAG, LogLevel.INFO, { 101 bool1 = keyguard 102 }, { 103 "Trying to go to locked shade " + if (bool1) "from keyguard" else "not from keyguard" 104 }) 105 } 106 logShadeDisabledOnGoToLockedShadenull107 fun logShadeDisabledOnGoToLockedShade() { 108 buffer.log(TAG, LogLevel.WARNING, {}, { 109 "The shade was disabled when trying to go to the locked shade" 110 }) 111 } 112 logShowBouncerOnGoToLockedShadenull113 fun logShowBouncerOnGoToLockedShade() { 114 buffer.log(TAG, LogLevel.INFO, {}, { 115 "Showing bouncer when trying to go to the locked shade" 116 }) 117 } 118 logGoingToLockedShadenull119 fun logGoingToLockedShade(customAnimationHandler: Boolean) { 120 buffer.log(TAG, LogLevel.INFO, { 121 bool1 = customAnimationHandler 122 }, { 123 "Going to locked shade " + if (customAnimationHandler) "with" else "without" + 124 " a custom handler" 125 }) 126 } 127 logOnHideKeyguardnull128 fun logOnHideKeyguard() { 129 buffer.log(TAG, LogLevel.INFO, {}, { 130 "Notified that the keyguard is being hidden" 131 }) 132 } 133 logPulseExpansionStartednull134 fun logPulseExpansionStarted() { 135 buffer.log(TAG, LogLevel.INFO, {}, { 136 "Pulse Expansion has started" 137 }) 138 } 139 logPulseExpansionFinishednull140 fun logPulseExpansionFinished(cancelled: Boolean) { 141 if (cancelled) { 142 buffer.log(TAG, LogLevel.INFO, {}, { 143 "Pulse Expansion is requested to cancel" 144 }) 145 } else { 146 buffer.log(TAG, LogLevel.INFO, {}, { 147 "Pulse Expansion is requested to finish" 148 }) 149 } 150 } 151 logDragDownAnimationnull152 fun logDragDownAnimation(target: Float) { 153 buffer.log(TAG, LogLevel.DEBUG, { 154 double1 = target.toDouble() 155 }, { 156 "Drag down amount animating to " + double1 157 }) 158 } 159 logAnimationCancellednull160 fun logAnimationCancelled(isPulse: Boolean) { 161 if (isPulse) { 162 buffer.log(TAG, LogLevel.DEBUG, {}, { 163 "Pulse animation cancelled" 164 }) 165 } else { 166 buffer.log(TAG, LogLevel.DEBUG, {}, { 167 "drag down animation cancelled" 168 }) 169 } 170 } 171 logDragDownAmountResetWhenFullyCollapsednull172 fun logDragDownAmountResetWhenFullyCollapsed() { 173 buffer.log(TAG, LogLevel.WARNING, {}, { 174 "Drag down amount stuck and reset after shade was fully collapsed" 175 }) 176 } 177 logPulseHeightNotResetWhenFullyCollapsednull178 fun logPulseHeightNotResetWhenFullyCollapsed() { 179 buffer.log(TAG, LogLevel.WARNING, {}, { 180 "Pulse height stuck and reset after shade was fully collapsed" 181 }) 182 } 183 logGoingToLockedShadeAbortednull184 fun logGoingToLockedShadeAborted() { 185 buffer.log(TAG, LogLevel.INFO, {}, { 186 "Going to the Locked Shade has been aborted" 187 }) 188 } 189 } 190