• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.doze
18 
19 import android.view.Display
20 import com.android.systemui.doze.DozeLog.Reason
21 import com.android.systemui.doze.DozeLog.reasonToString
22 import com.android.systemui.log.LogBuffer
23 import com.android.systemui.log.LogLevel.DEBUG
24 import com.android.systemui.log.LogLevel.ERROR
25 import com.android.systemui.log.LogLevel.INFO
26 import com.android.systemui.log.dagger.DozeLog
27 import java.text.SimpleDateFormat
28 import java.util.Date
29 import java.util.Locale
30 import javax.inject.Inject
31 
32 /** Interface for logging messages to the [DozeLog]. */
33 class DozeLogger @Inject constructor(
34     @DozeLog private val buffer: LogBuffer
35 ) {
logPickupWakeupnull36     fun logPickupWakeup(isWithinVibrationThreshold: Boolean) {
37         buffer.log(TAG, DEBUG, {
38             bool1 = isWithinVibrationThreshold
39         }, {
40             "PickupWakeup withinVibrationThreshold=$bool1"
41         })
42     }
43 
logPulseStartnull44     fun logPulseStart(@Reason reason: Int) {
45         buffer.log(TAG, INFO, {
46             int1 = reason
47         }, {
48             "Pulse start, reason=${reasonToString(int1)}"
49         })
50     }
51 
logPulseFinishnull52     fun logPulseFinish() {
53         buffer.log(TAG, INFO, {}, { "Pulse finish" })
54     }
55 
logNotificationPulsenull56     fun logNotificationPulse() {
57         buffer.log(TAG, INFO, {}, { "Notification pulse" })
58     }
59 
logDozingnull60     fun logDozing(isDozing: Boolean) {
61         buffer.log(TAG, INFO, {
62             bool1 = isDozing
63         }, {
64             "Dozing=$bool1"
65         })
66     }
67 
logDozingSuppressednull68     fun logDozingSuppressed(isDozingSuppressed: Boolean) {
69         buffer.log(TAG, INFO, {
70             bool1 = isDozingSuppressed
71         }, {
72             "DozingSuppressed=$bool1"
73         })
74     }
75 
logFlingnull76     fun logFling(
77         expand: Boolean,
78         aboveThreshold: Boolean,
79         thresholdNeeded: Boolean,
80         screenOnFromTouch: Boolean
81     ) {
82         buffer.log(TAG, DEBUG, {
83             bool1 = expand
84             bool2 = aboveThreshold
85             bool3 = thresholdNeeded
86             bool4 = screenOnFromTouch
87         }, {
88             "Fling expand=$bool1 aboveThreshold=$bool2 thresholdNeeded=$bool3 " +
89                     "screenOnFromTouch=$bool4"
90         })
91     }
92 
logEmergencyCallnull93     fun logEmergencyCall() {
94         buffer.log(TAG, INFO, {}, { "Emergency call" })
95     }
96 
logKeyguardBouncerChangednull97     fun logKeyguardBouncerChanged(isShowing: Boolean) {
98         buffer.log(TAG, INFO, {
99             bool1 = isShowing
100         }, {
101             "Keyguard bouncer changed, showing=$bool1"
102         })
103     }
104 
logScreenOnnull105     fun logScreenOn(isPulsing: Boolean) {
106         buffer.log(TAG, INFO, {
107             bool1 = isPulsing
108         }, {
109             "Screen on, pulsing=$bool1"
110         })
111     }
112 
logScreenOffnull113     fun logScreenOff(why: Int) {
114         buffer.log(TAG, INFO, {
115             int1 = why
116         }, {
117             "Screen off, why=$int1"
118         })
119     }
120 
logMissedTicknull121     fun logMissedTick(delay: String) {
122         buffer.log(TAG, ERROR, {
123             str1 = delay
124         }, {
125             "Missed AOD time tick by $str1"
126         })
127     }
128 
logTimeTickSchedulednull129     fun logTimeTickScheduled(whenAt: Long, triggerAt: Long) {
130         buffer.log(TAG, DEBUG, {
131             long1 = whenAt
132             long2 = triggerAt
133         }, {
134             "Time tick scheduledAt=${DATE_FORMAT.format(Date(long1))} " +
135                     "triggerAt=${DATE_FORMAT.format(Date(long2))}"
136         })
137     }
138 
logKeyguardVisibilityChangenull139     fun logKeyguardVisibilityChange(isShowing: Boolean) {
140         buffer.log(TAG, INFO, {
141             bool1 = isShowing
142         }, {
143             "Keyguard visibility change, isShowing=$bool1"
144         })
145     }
146 
logDozeStateChangednull147     fun logDozeStateChanged(state: DozeMachine.State) {
148         buffer.log(TAG, INFO, {
149             str1 = state.name
150         }, {
151             "Doze state changed to $str1"
152         })
153     }
154 
logStateChangedSentnull155     fun logStateChangedSent(state: DozeMachine.State) {
156         buffer.log(TAG, INFO, {
157             str1 = state.name
158         }, {
159             "Doze state sent to all DozeMachineParts stateSent=$str1"
160         })
161     }
162 
logDisplayStateChangednull163     fun logDisplayStateChanged(displayState: Int) {
164         buffer.log(TAG, INFO, {
165             str1 = Display.stateToString(displayState)
166         }, {
167             "Display state changed to $str1"
168         })
169     }
170 
logWakeDisplaynull171     fun logWakeDisplay(isAwake: Boolean, @Reason reason: Int) {
172         buffer.log(TAG, DEBUG, {
173             bool1 = isAwake
174             int1 = reason
175         }, {
176             "Display wakefulness changed, isAwake=$bool1, reason=${reasonToString(int1)}"
177         })
178     }
179 
logProximityResultnull180     fun logProximityResult(isNear: Boolean, millis: Long, @Reason reason: Int) {
181         buffer.log(TAG, DEBUG, {
182             bool1 = isNear
183             long1 = millis
184             int1 = reason
185         }, {
186             "Proximity result reason=${reasonToString(int1)} near=$bool1 millis=$long1"
187         })
188     }
189 
logPulseDroppednull190     fun logPulseDropped(pulsePending: Boolean, state: DozeMachine.State, blocked: Boolean) {
191         buffer.log(TAG, INFO, {
192             bool1 = pulsePending
193             str1 = state.name
194             bool2 = blocked
195         }, {
196             "Pulse dropped, pulsePending=$bool1 state=$str1 blocked=$bool2"
197         })
198     }
199 
logPulseDroppednull200     fun logPulseDropped(reason: String) {
201         buffer.log(TAG, INFO, {
202             str1 = reason
203         }, {
204             "Pulse dropped, why=$str1"
205         })
206     }
207 
logPulseTouchDisabledByProxnull208     fun logPulseTouchDisabledByProx(disabled: Boolean) {
209         buffer.log(TAG, DEBUG, {
210             bool1 = disabled
211         }, {
212             "Pulse touch modified by prox, disabled=$bool1"
213         })
214     }
215 
logSensorTriggerednull216     fun logSensorTriggered(@Reason reason: Int) {
217         buffer.log(TAG, DEBUG, {
218             int1 = reason
219         }, {
220             "Sensor triggered, type=${reasonToString(int1)}"
221         })
222     }
223 
logDozeSuppressednull224     fun logDozeSuppressed(state: DozeMachine.State) {
225         buffer.log(TAG, INFO, {
226             str1 = state.name
227         }, {
228             "Doze state suppressed, state=$str1"
229         })
230     }
231 
logDozeScreenBrightnessnull232     fun logDozeScreenBrightness(brightness: Int) {
233         buffer.log(TAG, INFO, {
234             int1 = brightness
235         }, {
236             "Doze screen brightness set, brightness=$int1"
237         })
238     }
239 
logSetAodDimmingScrimnull240     fun logSetAodDimmingScrim(scrimOpacity: Long) {
241         buffer.log(TAG, INFO, {
242             long1 = scrimOpacity
243         }, {
244             "Doze aod dimming scrim opacity set, opacity=$long1"
245         })
246     }
247 }
248 
249 private const val TAG = "DozeLog"
250 
251 val DATE_FORMAT = SimpleDateFormat("MM-dd HH:mm:ss.S", Locale.US)
252