John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 19 | import android.annotation.IntDef; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 20 | import android.util.TimeUtils; |
| 21 | |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 22 | import androidx.annotation.NonNull; |
| 23 | |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 24 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 25 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 26 | import com.android.systemui.DumpController; |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 27 | import com.android.systemui.Dumpable; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 28 | |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 29 | import java.io.FileDescriptor; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 30 | import java.io.PrintWriter; |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 31 | import java.lang.annotation.Retention; |
| 32 | import java.lang.annotation.RetentionPolicy; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 33 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 34 | import javax.inject.Inject; |
| 35 | import javax.inject.Singleton; |
| 36 | |
| 37 | /** |
| 38 | * Logs doze events for debugging and triaging purposes. Logs are dumped in bugreports or on demand: |
| 39 | * adb shell dumpsys activity service com.android.systemui/.SystemUIService \ |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 40 | * dependency DumpController DozeLog,DozeStats |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 41 | */ |
| 42 | @Singleton |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 43 | public class DozeLog implements Dumpable { |
| 44 | private final DozeLogger mLogger; |
Beverly | 3ae892b | 2019-12-05 14:33:09 -0500 | [diff] [blame] | 45 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 46 | private boolean mPulsing; |
| 47 | private long mSince; |
| 48 | private SummaryStats mPickupPulseNearVibrationStats; |
| 49 | private SummaryStats mPickupPulseNotNearVibrationStats; |
| 50 | private SummaryStats mNotificationPulseStats; |
| 51 | private SummaryStats mScreenOnPulsingStats; |
| 52 | private SummaryStats mScreenOnNotPulsingStats; |
| 53 | private SummaryStats mEmergencyCallStats; |
| 54 | private SummaryStats[][] mProxStats; // [reason][near/far] |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 55 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 56 | @Inject |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 57 | public DozeLog( |
| 58 | KeyguardUpdateMonitor keyguardUpdateMonitor, |
| 59 | DumpController dumpController, |
| 60 | DozeLogger logger) { |
| 61 | mLogger = logger; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 62 | mSince = System.currentTimeMillis(); |
| 63 | mPickupPulseNearVibrationStats = new SummaryStats(); |
| 64 | mPickupPulseNotNearVibrationStats = new SummaryStats(); |
| 65 | mNotificationPulseStats = new SummaryStats(); |
| 66 | mScreenOnPulsingStats = new SummaryStats(); |
| 67 | mScreenOnNotPulsingStats = new SummaryStats(); |
| 68 | mEmergencyCallStats = new SummaryStats(); |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 69 | mProxStats = new SummaryStats[TOTAL_REASONS][2]; |
| 70 | for (int i = 0; i < TOTAL_REASONS; i++) { |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 71 | mProxStats[i][0] = new SummaryStats(); |
| 72 | mProxStats[i][1] = new SummaryStats(); |
| 73 | } |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 74 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 75 | if (keyguardUpdateMonitor != null) { |
| 76 | keyguardUpdateMonitor.registerCallback(mKeyguardCallback); |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 77 | } |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 78 | |
| 79 | dumpController.registerDumpable("DumpStats", this); |
Jorim Jaggi | 8396970 | 2015-06-05 14:59:24 -0700 | [diff] [blame] | 80 | } |
| 81 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 82 | /** |
| 83 | * Appends pickup wakeup event to the logs |
| 84 | */ |
| 85 | public void tracePickupWakeUp(boolean withinVibrationThreshold) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 86 | mLogger.logPickupWakeup(withinVibrationThreshold); |
| 87 | (withinVibrationThreshold ? mPickupPulseNearVibrationStats |
| 88 | : mPickupPulseNotNearVibrationStats).append(); |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 89 | } |
| 90 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 91 | /** |
| 92 | * Appends pulse started event to the logs. |
| 93 | * @param reason why the pulse started |
| 94 | */ |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 95 | public void tracePulseStart(@Reason int reason) { |
| 96 | mLogger.logPulseStart(reason); |
| 97 | mPulsing = true; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Appends pulse finished event to the logs |
| 102 | */ |
| 103 | public void tracePulseFinish() { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 104 | mLogger.logPulseFinish(); |
| 105 | mPulsing = false; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Appends pulse event to the logs |
| 110 | */ |
| 111 | public void traceNotificationPulse() { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 112 | mLogger.logNotificationPulse(); |
| 113 | mNotificationPulseStats.append(); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Appends dozing event to the logs |
| 118 | * @param dozing true if dozing, else false |
| 119 | */ |
| 120 | public void traceDozing(boolean dozing) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 121 | mLogger.logDozing(dozing); |
| 122 | mPulsing = false; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Appends fling event to the logs |
| 127 | */ |
| 128 | public void traceFling(boolean expand, boolean aboveThreshold, boolean thresholdNeeded, |
John Spurlock | ee98df7 | 2014-09-30 09:56:05 -0400 | [diff] [blame] | 129 | boolean screenOnFromTouch) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 130 | mLogger.logFling(expand, aboveThreshold, thresholdNeeded, screenOnFromTouch); |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 131 | } |
| 132 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 133 | /** |
| 134 | * Appends emergency call event to the logs |
| 135 | */ |
| 136 | public void traceEmergencyCall() { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 137 | mLogger.logEmergencyCall(); |
| 138 | mEmergencyCallStats.append(); |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 139 | } |
| 140 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 141 | /** |
| 142 | * Appends keyguard bouncer changed event to the logs |
| 143 | * @param showing true if the keyguard bouncer is showing, else false |
| 144 | */ |
| 145 | public void traceKeyguardBouncerChanged(boolean showing) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 146 | mLogger.logKeyguardBouncerChanged(showing); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Appends screen-on event to the logs |
| 151 | */ |
| 152 | public void traceScreenOn() { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 153 | mLogger.logScreenOn(mPulsing); |
| 154 | (mPulsing ? mScreenOnPulsingStats : mScreenOnNotPulsingStats).append(); |
| 155 | mPulsing = false; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Appends screen-off event to the logs |
| 160 | * @param why reason the screen is off |
| 161 | */ |
| 162 | public void traceScreenOff(int why) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 163 | mLogger.logScreenOff(why); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Appends missed tick event to the logs |
| 168 | * @param delay of the missed tick |
| 169 | */ |
| 170 | public void traceMissedTick(String delay) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 171 | mLogger.logMissedTick(delay); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Appends time tick scheduled event to the logs |
| 176 | * @param when time tick scheduled at |
| 177 | * @param triggerAt time tick trigger at |
| 178 | */ |
| 179 | public void traceTimeTickScheduled(long when, long triggerAt) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 180 | mLogger.logTimeTickScheduled(when, triggerAt); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | /** |
| 184 | * Appends keyguard visibility change event to the logs |
| 185 | * @param showing whether the keyguard is now showing |
| 186 | */ |
| 187 | public void traceKeyguard(boolean showing) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 188 | mLogger.logKeyguardVisibilityChange(showing); |
| 189 | if (!showing) mPulsing = false; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | /** |
| 193 | * Appends doze state changed event to the logs |
| 194 | * @param state new DozeMachine state |
| 195 | */ |
| 196 | public void traceState(DozeMachine.State state) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 197 | mLogger.logDozeStateChanged(state); |
Adrian Roos | a6c03f8 | 2017-07-26 16:20:30 +0200 | [diff] [blame] | 198 | } |
| 199 | |
Lucas Dupin | b2d9f48 | 2018-11-16 18:55:13 -0800 | [diff] [blame] | 200 | /** |
Lucas Dupin | b2d9f48 | 2018-11-16 18:55:13 -0800 | [diff] [blame] | 201 | * Appends wake-display event to the logs. |
| 202 | * @param wake if we're waking up or sleeping. |
| 203 | */ |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 204 | public void traceWakeDisplay(boolean wake) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 205 | mLogger.logWakeDisplay(wake); |
Lucas Dupin | c81702e | 2018-08-09 15:41:55 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 208 | /** |
| 209 | * Appends proximity result event to the logs |
| 210 | * @param near true if near, else false |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 211 | * @param reason why proximity result was triggered |
| 212 | */ |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 213 | public void traceProximityResult(boolean near, long millis, @Reason int reason) { |
| 214 | mLogger.logProximityResult(near, millis, reason); |
| 215 | mProxStats[reason][near ? 0 : 1].append(); |
John Spurlock | 92b8d41 | 2014-10-03 17:12:40 -0400 | [diff] [blame] | 216 | } |
| 217 | |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 218 | @Override |
| 219 | public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) { |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 220 | synchronized (DozeLog.class) { |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 221 | pw.print(" Doze summary stats (for "); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 222 | TimeUtils.formatDuration(System.currentTimeMillis() - mSince, pw); |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 223 | pw.println("):"); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 224 | mPickupPulseNearVibrationStats.dump(pw, "Pickup pulse (near vibration)"); |
| 225 | mPickupPulseNotNearVibrationStats.dump(pw, "Pickup pulse (not near vibration)"); |
| 226 | mNotificationPulseStats.dump(pw, "Notification pulse"); |
| 227 | mScreenOnPulsingStats.dump(pw, "Screen on (pulsing)"); |
| 228 | mScreenOnNotPulsingStats.dump(pw, "Screen on (not pulsing)"); |
| 229 | mEmergencyCallStats.dump(pw, "Emergency call"); |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 230 | for (int i = 0; i < TOTAL_REASONS; i++) { |
| 231 | final String reason = reasonToString(i); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 232 | mProxStats[i][0].dump(pw, "Proximity near (" + reason + ")"); |
| 233 | mProxStats[i][1].dump(pw, "Proximity far (" + reason + ")"); |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 234 | } |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 238 | /** |
| 239 | * Appends pulse dropped event to logs |
| 240 | */ |
| 241 | public void tracePulseDropped(boolean pulsePending, DozeMachine.State state, boolean blocked) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 242 | mLogger.logPulseDropped(pulsePending, state, blocked); |
Lucas Dupin | c0b8111 | 2019-07-25 18:56:12 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 245 | /** |
| 246 | * Appends pulse dropped event to logs |
| 247 | * @param reason why the pulse was dropped |
| 248 | */ |
| 249 | public void tracePulseDropped(String reason) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 250 | mLogger.logPulseDropped(reason); |
Adrian Roos | d35d4ca | 2017-04-19 14:31:03 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 253 | /** |
| 254 | * Appends pulse touch displayed by prox sensor event to logs |
| 255 | * @param disabled |
| 256 | */ |
| 257 | public void tracePulseTouchDisabledByProx(boolean disabled) { |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 258 | mLogger.logPulseTouchDisabledByProx(disabled); |
Adrian Roos | d35d4ca | 2017-04-19 14:31:03 -0700 | [diff] [blame] | 259 | } |
| 260 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 261 | /** |
| 262 | * Appends sensor triggered event to logs |
| 263 | * @param reason why the sensor was triggered |
| 264 | */ |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 265 | public void traceSensor(@Reason int reason) { |
| 266 | mLogger.logSensorTriggered(reason); |
Adrian Roos | 2ca9cd7 | 2017-07-03 15:14:37 +0200 | [diff] [blame] | 267 | } |
| 268 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 269 | private class SummaryStats { |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 270 | private int mCount; |
| 271 | |
| 272 | public void append() { |
| 273 | mCount++; |
| 274 | } |
| 275 | |
| 276 | public void dump(PrintWriter pw, String type) { |
John Spurlock | eab28e6 | 2014-11-29 11:33:49 -0500 | [diff] [blame] | 277 | if (mCount == 0) return; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 278 | pw.print(" "); |
| 279 | pw.print(type); |
| 280 | pw.print(": n="); |
| 281 | pw.print(mCount); |
| 282 | pw.print(" ("); |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 283 | final double perHr = (double) mCount / (System.currentTimeMillis() - mSince) |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 284 | * 1000 * 60 * 60; |
| 285 | pw.print(perHr); |
| 286 | pw.print("/hr)"); |
| 287 | pw.println(); |
| 288 | } |
| 289 | } |
John Spurlock | bee3b0a | 2014-09-29 11:30:12 -0400 | [diff] [blame] | 290 | |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 291 | private final KeyguardUpdateMonitorCallback mKeyguardCallback = |
John Spurlock | bee3b0a | 2014-09-29 11:30:12 -0400 | [diff] [blame] | 292 | new KeyguardUpdateMonitorCallback() { |
| 293 | @Override |
| 294 | public void onEmergencyCallAction() { |
| 295 | traceEmergencyCall(); |
| 296 | } |
| 297 | |
| 298 | @Override |
| 299 | public void onKeyguardBouncerChanged(boolean bouncer) { |
| 300 | traceKeyguardBouncerChanged(bouncer); |
| 301 | } |
| 302 | |
| 303 | @Override |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 304 | public void onStartedWakingUp() { |
John Spurlock | bee3b0a | 2014-09-29 11:30:12 -0400 | [diff] [blame] | 305 | traceScreenOn(); |
| 306 | } |
| 307 | |
| 308 | @Override |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 309 | public void onFinishedGoingToSleep(int why) { |
John Spurlock | bee3b0a | 2014-09-29 11:30:12 -0400 | [diff] [blame] | 310 | traceScreenOff(why); |
| 311 | } |
| 312 | |
| 313 | @Override |
| 314 | public void onKeyguardVisibilityChanged(boolean showing) { |
| 315 | traceKeyguard(showing); |
| 316 | } |
| 317 | }; |
Beverly | cc4a62f | 2019-09-26 14:55:28 -0400 | [diff] [blame] | 318 | |
Ned Burns | 30d6770 | 2020-01-28 12:58:45 -0500 | [diff] [blame] | 319 | /** |
| 320 | * Converts the reason (integer) to a user-readable string |
| 321 | */ |
| 322 | public static String reasonToString(@Reason int pulseReason) { |
| 323 | switch (pulseReason) { |
| 324 | case PULSE_REASON_INTENT: return "intent"; |
| 325 | case PULSE_REASON_NOTIFICATION: return "notification"; |
| 326 | case PULSE_REASON_SENSOR_SIGMOTION: return "sigmotion"; |
| 327 | case REASON_SENSOR_PICKUP: return "pickup"; |
| 328 | case REASON_SENSOR_DOUBLE_TAP: return "doubletap"; |
| 329 | case PULSE_REASON_SENSOR_LONG_PRESS: return "longpress"; |
| 330 | case PULSE_REASON_DOCKING: return "docking"; |
| 331 | case PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN: return "wakelockscreen"; |
| 332 | case REASON_SENSOR_WAKE_UP: return "wakeup"; |
| 333 | case REASON_SENSOR_TAP: return "tap"; |
| 334 | default: throw new IllegalArgumentException("invalid reason: " + pulseReason); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | @Retention(RetentionPolicy.SOURCE) |
| 339 | @IntDef({PULSE_REASON_NONE, PULSE_REASON_INTENT, PULSE_REASON_NOTIFICATION, |
| 340 | PULSE_REASON_SENSOR_SIGMOTION, REASON_SENSOR_PICKUP, REASON_SENSOR_DOUBLE_TAP, |
| 341 | PULSE_REASON_SENSOR_LONG_PRESS, PULSE_REASON_DOCKING, REASON_SENSOR_WAKE_UP, |
| 342 | PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN, REASON_SENSOR_TAP}) |
| 343 | public @interface Reason {} |
| 344 | public static final int PULSE_REASON_NONE = -1; |
| 345 | public static final int PULSE_REASON_INTENT = 0; |
| 346 | public static final int PULSE_REASON_NOTIFICATION = 1; |
| 347 | public static final int PULSE_REASON_SENSOR_SIGMOTION = 2; |
| 348 | public static final int REASON_SENSOR_PICKUP = 3; |
| 349 | public static final int REASON_SENSOR_DOUBLE_TAP = 4; |
| 350 | public static final int PULSE_REASON_SENSOR_LONG_PRESS = 5; |
| 351 | public static final int PULSE_REASON_DOCKING = 6; |
| 352 | public static final int REASON_SENSOR_WAKE_UP = 7; |
| 353 | public static final int PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN = 8; |
| 354 | public static final int REASON_SENSOR_TAP = 9; |
| 355 | |
| 356 | public static final int TOTAL_REASONS = 10; |
John Spurlock | 813552c | 2014-09-19 08:30:21 -0400 | [diff] [blame] | 357 | } |