blob: 221a55438f739f0ce75151c00117df1f46a3169b [file] [log] [blame]
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -07001/*
2 * Copyright (C) 2017 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
17syntax = "proto2";
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070018
Yao Chend54f9dd2017-10-17 17:37:48 +000019// TODO: Not the right package and class name
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070020package android.os.statsd;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070021option java_package = "com.android.os";
Stefan Lafonae2df012017-11-14 09:17:21 -080022option java_outer_classname = "AtomsProto";
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070023
Joe Onorato62c220b2017-11-18 20:32:56 -080024import "frameworks/base/core/proto/android/app/activitymanager.proto";
25
Yao Chend54f9dd2017-10-17 17:37:48 +000026/**
Stefan Lafonae2df012017-11-14 09:17:21 -080027 * The master atom class. This message defines all of the available
Yao Chend54f9dd2017-10-17 17:37:48 +000028 * raw stats log events from the Android system, also known as "atoms."
29 *
30 * This field contains a single oneof with all of the available messages.
31 * The stats-log-api-gen tool runs as part of the Android build and
32 * generates the android.util.StatsLog class, which contains the constants
33 * and methods that Android uses to log.
34 *
Stefan Lafonae2df012017-11-14 09:17:21 -080035 * This Atom class is not actually built into the Android system.
Yao Chend54f9dd2017-10-17 17:37:48 +000036 * Instead, statsd on Android constructs these messages synthetically,
37 * in the format defined here and in stats_log.proto.
38 */
Stefan Lafonae2df012017-11-14 09:17:21 -080039message Atom {
40 // Pushed atoms start at 2.
David Chenc8a43242017-10-17 16:23:28 -070041 oneof pushed {
Bookatzc1a050a2017-10-10 15:49:28 -070042 // For StatsLog reasons, 1 is illegal and will not work. Must start at 2.
43 BleScanStateChanged ble_scan_state_changed = 2;
44 BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
45 BleScanResultReceived ble_scan_result_received = 4;
46 SensorStateChanged sensor_state_changed = 5;
47 GpsScanStateChanged gps_scan_state_changed = 6; // TODO: untested
48 SyncStateChanged sync_state_changed = 7;
49 ScheduledJobStateChanged scheduled_job_state_changed = 8;
50 ScreenBrightnessChanged screen_brightness_changed = 9;
Bookatzd6746242017-10-24 18:39:35 -070051 WakelockStateChanged wakelock_state_changed = 10;
Bookatzddccf0a2017-11-28 16:48:14 -080052 LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 11;
53 MobileRadioPowerStateChanged mobile_radio_power_state_changed = 12;
54 WifiRadioPowerStateChanged wifi_radio_power_state_changed = 13;
55 // TODO: 14-19 are blank, but need not be
56 BatterySaverModeStateChanged battery_saver_mode_state_changed = 20;
57 DeviceIdleModeStateChanged device_idle_mode_state_changed = 21;
58 DeviceIdlingModeStateChanged device_idling_mode_state_changed = 22;
Bookatzc1a050a2017-10-10 15:49:28 -070059 AudioStateChanged audio_state_changed = 23;
60 MediaCodecActivityChanged media_codec_activity_changed = 24;
61 CameraStateChanged camera_state_changed = 25;
62 FlashlightStateChanged flashlight_state_changed = 26;
63 UidProcessStateChanged uid_process_state_changed = 27;
64 ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28;
65 ScreenStateChanged screen_state_changed = 29;
Bookatz8c6571b2017-10-24 15:04:41 -070066 BatteryLevelChanged battery_level_changed = 30;
67 ChargingStateChanged charging_state_changed = 31;
68 PluggedStateChanged plugged_state_changed = 32;
69 DeviceTemperatureReported device_temperature_reported = 33;
70 DeviceOnStatusChanged device_on_status_changed = 34;
71 WakeupAlarmOccurred wakeup_alarm_occurred = 35;
72 KernelWakeupReported kernel_wakeup_reported = 36;
Bookatze5885242017-10-24 20:10:31 -070073 WifiLockStateChanged wifi_lock_state_changed = 37;
74 WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
75 WifiScanStateChanged wifi_scan_state_changed = 39;
76 PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
David Chenc28b2bb2017-10-24 12:52:52 -070077 SettingChanged setting_changed = 41;
David Chenc8a43242017-10-17 16:23:28 -070078 ActivityForegroundStateChanged activity_foreground_state_changed = 42;
David Chen21582962017-11-01 17:32:46 -070079 IsolatedUidChanged isolated_uid_changed = 43;
Hugo Benichi884970e2017-11-14 22:42:46 +090080 PacketWakeupOccurred packet_wakeup_occurred = 44;
David Chen9e3808c2017-11-20 17:25:34 -080081 DropboxErrorChanged dropbox_error_changed = 45;
Bookatz8fcd09a2017-12-18 13:01:10 -080082 AnomalyDetected anomaly_detected = 46;
83 AppHook app_hook = 47;
Bookatzc1a050a2017-10-10 15:49:28 -070084 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000085 }
David Chenc8a43242017-10-17 16:23:28 -070086
87 // Pulled events will start at field 1000.
88 oneof pulled {
Chenjie Yu31d14d72017-12-12 17:54:33 -080089 WifiBytesTransfer wifi_bytes_transfer = 1000;
90 WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 1001;
91 MobileBytesTransfer mobile_bytes_transfer = 1002;
92 MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 1003;
93 KernelWakelock kernel_wakelock = 1004;
94 PlatformSleepState platform_sleep_state = 1005;
95 SleepStateVoter sleep_state_voter = 1006;
96 SubsystemSleepState subsystem_sleep_state = 1007;
97 CpuTimePerFreq cpu_time_per_freq = 1008;
98 CpuTimePerUid cpu_time_per_uid = 1009;
99 CpuTimePerUidFreq cpu_time_per_uid_freq = 1010;
100 WifiActivityEnergyInfo wifi_activity_energy_info = 1011;
101 ModemActivityInfo modem_activity_info = 1012;
Yangster-mac7604aea2017-12-11 22:55:49 -0800102 AttributionChainDummyAtom attribution_chain_dummy_atom = 10000;
David Chenc8a43242017-10-17 16:23:28 -0700103 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700104}
105
Yao Chend54f9dd2017-10-17 17:37:48 +0000106/**
Yangster-mac20877162017-12-22 17:19:39 -0800107 * This proto represents a node of an attribution chain.
108 * Note: All attribution chains are represented as a repeated field of type
109 * AttributionNode. It is understood that in such arrays, the order is that
110 * of calls, that is [A, B, C] if A calls B that calls C.
Yao Chend54f9dd2017-10-17 17:37:48 +0000111 */
Yangster-mac20877162017-12-22 17:19:39 -0800112message AttributionNode {
113 // The uid for a given element in the attribution chain.
Yangster-mac7604aea2017-12-11 22:55:49 -0800114 optional int32 uid = 1;
Yangster-mac7604aea2017-12-11 22:55:49 -0800115
Yangster-mac20877162017-12-22 17:19:39 -0800116 // The (optional) string tag for an element in the attribution chain. If the
117 // element has no tag, it is encoded as an empty string.
118 optional string tag = 2;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700119}
120
Yao Chend54f9dd2017-10-17 17:37:48 +0000121/*
122 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800123 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000124 *
125 * RULES:
126 * - The field ids for each atom must start at 1, and count upwards by 1.
127 * Skipping field ids is not allowed.
128 * - These form an API, so renaming, renumbering or removing fields is
129 * not allowed between android releases. (This is not currently enforced,
130 * but there will be a tool to enforce this restriction).
131 * - The types must be built-in protocol buffer types, namely, no sub-messages
132 * are allowed (yet). The bytes type is also not allowed.
133 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800134 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000135 * - If an atom represents work that can be attributed to an app, there can
Yangster-mac7604aea2017-12-11 22:55:49 -0800136 * be exactly one AttributionChain field. It must be field number 1.
Yao Chend54f9dd2017-10-17 17:37:48 +0000137 * - A field that is a uid should be a string field, tagged with the [xxx]
138 * annotation. The generated code on android will be represented by UIDs,
139 * and those UIDs will be translated in xxx to those strings.
140 *
141 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700142 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000143 * - If there is a UID, it goes first. Think in an object-oriented fashion.
144 * *****************************************************************************
145 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700146
Yangster-mac7604aea2017-12-11 22:55:49 -0800147message AttributionChainDummyAtom {
Yangster-mac20877162017-12-22 17:19:39 -0800148 repeated AttributionNode attribution_node = 1;
Yangster-mac7604aea2017-12-11 22:55:49 -0800149 optional int32 value = 2;
150}
151
Yao Chend54f9dd2017-10-17 17:37:48 +0000152/**
153 * Logs when the screen state changes.
154 *
155 * Logged from:
156 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
157 */
158message ScreenStateChanged {
159 // TODO: Use the real screen state.
160 enum State {
161 STATE_UNKNOWN = 0;
162 STATE_OFF = 1;
163 STATE_ON = 2;
164 STATE_DOZE = 3;
165 STATE_DOZE_SUSPEND = 4;
166 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800167 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000168 }
169 // New screen state.
170 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700171}
Yao Chend54f9dd2017-10-17 17:37:48 +0000172
173/**
Bookatzc1a050a2017-10-10 15:49:28 -0700174 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000175 *
176 * Logged from:
177 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
178 */
Bookatzc1a050a2017-10-10 15:49:28 -0700179message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000180 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
181
182 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700183 // TODO: Use the real (mapped) process states.
Joe Onorato62c220b2017-11-18 20:32:56 -0800184 optional android.app.ProcessState state = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000185}
186
187/**
Bookatzc1a050a2017-10-10 15:49:28 -0700188 * Logs that a process started, finished, crashed, or ANRed.
189 *
190 * Logged from:
191 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
192 */
193message ProcessLifeCycleStateChanged {
194 // TODO: Use the real (mapped) process states.
195 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
196
197 // TODO: What is this?
198 optional string name = 2;
199
Bookatzddccf0a2017-11-28 16:48:14 -0800200 // What lifecycle state the process changed to.
201 // This enum is specific to atoms.proto.
202 enum Event {
203 PROCESS_FINISHED = 0;
204 PROCESS_STARTED = 1;
205 PROCESS_CRASHED = 2;
206 PROCESS_ANRED = 3;
207 }
208 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700209}
210
Bookatzc1a050a2017-10-10 15:49:28 -0700211/**
212 * Logs when the ble scan state changes.
213 *
214 * Logged from:
215 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
216 */
217message BleScanStateChanged {
218 // TODO: Add attribution instead of uid.
219 optional int32 uid = 1;
220
221 enum State {
222 OFF = 0;
223 ON = 1;
224 }
225 optional State state = 2;
226}
227
228/**
229 * Logs when an unoptimized ble scan state changes.
230 *
231 * Logged from:
232 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
233 */
234// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
235message BleUnoptimizedScanStateChanged {
236 // TODO: Add attribution instead of uid.
237 optional int32 uid = 1;
238
239 enum State {
240 OFF = 0;
241 ON = 1;
242 }
243 optional State state = 2;
244}
245
246/**
247 * Logs reporting of a ble scan finding results.
248 *
249 * Logged from:
250 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
251 */
252// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
253message BleScanResultReceived {
254 // TODO: Add attribution instead of uid.
255 optional int32 uid = 1;
256
257 // Number of ble scan results returned.
258 optional int32 num_of_results = 2;
259}
260
261/**
262 * Logs when a sensor state changes.
263 *
264 * Logged from:
265 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
266 */
267message SensorStateChanged {
268 // TODO: Add attribution instead of uid.
269 optional int32 uid = 1;
270
271 // TODO: Is there a way to get the actual name of the sensor?
272 // The id (int) of the sensor.
273 optional int32 sensor_id = 2;
274
275 enum State {
276 OFF = 0;
277 ON = 1;
278 }
279 optional State state = 3;
280}
281
282
283/**
284 * Logs when GPS state changes.
285 *
286 * Logged from:
287 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
288 */
289message GpsScanStateChanged {
290 // TODO: Add attribution instead of uid.
291 optional int32 uid = 1;
292
293 enum State {
294 OFF = 0;
295 ON = 1;
296 }
297 optional State state = 2;
298}
299
300
301/**
302 * Logs when a sync manager sync state changes.
303 *
304 * Logged from:
305 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
306 */
307message SyncStateChanged {
308 // TODO: Add attribution instead of uid.
309 optional int32 uid = 1;
310
311 // Name of the sync (as named in the app)
312 optional string name = 2;
313
314 enum State {
315 OFF = 0;
316 ON = 1;
317 }
318 optional State state = 3;
319}
320
321/**
322 * Logs when a job scheduler job state changes.
323 *
324 * Logged from:
325 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
326 */
327message ScheduledJobStateChanged {
328 // TODO: Add attribution instead of uid.
329 optional int32 uid = 1;
330
331 // Name of the job (as named in the app)
332 optional string name = 2;
333
334 enum State {
335 OFF = 0;
336 ON = 1;
337 }
338 optional State state = 3;
339
340 // TODO: Consider adding the stopReason (int)
341}
342
343/**
344 * Logs when the audio state changes.
345 *
346 * Logged from:
347 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
348 */
349message AudioStateChanged {
350 // TODO: Add attribution instead of uid.
351 optional int32 uid = 1;
352
353 enum State {
354 OFF = 0;
355 ON = 1;
356 }
357 optional State state = 2;
358}
359
360/**
361 * Logs when the video codec state changes.
362 *
363 * Logged from:
364 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
365 */
366message MediaCodecActivityChanged {
367 // TODO: Add attribution instead of uid.
368 optional int32 uid = 1;
369
370 enum State {
371 OFF = 0;
372 ON = 1;
373 }
374 optional State state = 2;
375}
376
377/**
378 * Logs when the flashlight state changes.
379 *
380 * Logged from:
381 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
382 */
383message FlashlightStateChanged {
384 // TODO: Add attribution instead of uid.
385 optional int32 uid = 1;
386
387 enum State {
388 OFF = 0;
389 ON = 1;
390 }
391 optional State state = 2;
392}
393
394/**
395 * Logs when the camera state changes.
396 *
397 * Logged from:
398 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
399 */
400message CameraStateChanged {
401 // TODO: Add attribution instead of uid.
402 optional int32 uid = 1;
403
404 enum State {
405 OFF = 0;
406 ON = 1;
407 }
408 optional State state = 2;
409}
410
411/**
412 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000413 *
414 * Logged from:
415 * TODO
416 */
Bookatzd6746242017-10-24 18:39:35 -0700417message WakelockStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800418 repeated AttributionNode attribution_node = 1;
Yao Chend54f9dd2017-10-17 17:37:48 +0000419
Bookatzc1a050a2017-10-10 15:49:28 -0700420 // Type of wakelock.
421 enum Type {
422 PARTIAL = 0;
423 FULL = 1;
424 WINDOW = 2;
425 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800426 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700427
428 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
429 optional string tag = 3;
430
431 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800432 RELEASE = 0;
433 ACQUIRE = 1;
434 CHANGE_RELEASE = 2;
435 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700436 }
437 optional State state = 4;
438}
439
440/**
Bookatzc1a050a2017-10-10 15:49:28 -0700441 * Logs when a partial wakelock is considered 'long' (over 1 min).
442 *
443 * Logged from:
444 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
445 */
446message LongPartialWakelockStateChanged {
447 // TODO: Add attribution instead of uid?
448 optional int32 uid = 1;
449
Yao Chend54f9dd2017-10-17 17:37:48 +0000450 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
451 optional string tag = 2;
452
Bookatzc1a050a2017-10-10 15:49:28 -0700453 // TODO: I have no idea what this is.
454 optional string history_tag = 3;
455
456 enum State {
457 OFF = 0;
458 ON = 1;
459 }
460 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000461}
462
Bookatzc1a050a2017-10-10 15:49:28 -0700463/**
464 * Logs Battery Saver state change.
465 *
466 * Logged from:
467 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
468 */
469message BatterySaverModeStateChanged {
470 enum State {
471 OFF = 0;
472 ON = 1;
473 }
474 optional State state = 1;
475}
476
477/**
478 * Logs Doze mode state change.
479 *
480 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800481 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700482 */
483message DeviceIdleModeStateChanged {
484 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800485 enum State {
486 DEVICE_IDLE_MODE_OFF = 0;
487 DEVICE_IDLE_MODE_LIGHT = 1;
488 DEVICE_IDLE_MODE_DEEP = 2;
489 }
490 optional State state = 1;
491}
492
493
494/**
495 * Logs state change of Doze mode including maintenance windows.
496 *
497 * Logged from:
498 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
499 */
500message DeviceIdlingModeStateChanged {
501 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
502 enum State {
503 DEVICE_IDLE_MODE_OFF = 0;
504 DEVICE_IDLE_MODE_LIGHT = 1;
505 DEVICE_IDLE_MODE_DEEP = 2;
506 }
507 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700508}
509
510/**
511 * Logs screen brightness level.
512 *
513 * Logged from:
514 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
515 */
516message ScreenBrightnessChanged {
517 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
518 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700519}
520
521/**
522 * Logs battery level (percent full, from 0 to 100).
523 *
524 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700525 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700526 */
527message BatteryLevelChanged {
528 // Battery level. Should be in [0, 100].
529 optional int32 battery_level = 1;
530}
531
532/**
533 * Logs change in charging status of the device.
534 *
535 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700536 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700537 */
538message ChargingStateChanged {
539 // TODO: Link directly to BatteryManager.java's constants (via a proto).
540 enum State {
541 BATTERY_STATUS_UNKNOWN = 1;
542 BATTERY_STATUS_CHARGING = 2;
543 BATTERY_STATUS_DISCHARGING = 3;
544 BATTERY_STATUS_NOT_CHARGING = 4;
545 BATTERY_STATUS_FULL = 5;
546 }
547 optional State charging_state = 1;
548}
549
550/**
551 * Logs whether the device is plugged in, and what power source it is using.
552 *
553 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700554 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700555 */
556message PluggedStateChanged {
557 // TODO: Link directly to BatteryManager.java's constants (via a proto).
558 enum State {
559 // Note that NONE is not in BatteryManager.java's constants.
560 BATTERY_PLUGGED_NONE = 0;
561 // Power source is an AC charger.
562 BATTERY_PLUGGED_AC = 1;
563 // Power source is a USB port.
564 BATTERY_PLUGGED_USB = 2;
565 // Power source is wireless.
566 BATTERY_PLUGGED_WIRELESS = 4;
567 }
568 optional State plugged_state = 1;
569}
570
571/**
572 * Logs the temperature of the device, in tenths of a degree Celsius.
573 *
574 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700575 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700576 */
577message DeviceTemperatureReported {
578 // Temperature in tenths of a degree C.
579 optional int32 temperature = 1;
580}
581
582// TODO: Define this more precisely.
583// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
584/**
585 * Logs when the device turns off or on.
586 *
587 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700588 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700589 */
590message DeviceOnStatusChanged {
591 enum State {
592 OFF = 0;
593 ON = 1;
594 }
595 optional State state = 1;
596}
597
598/**
599 * Logs when an app's wakeup alarm fires.
600 *
601 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700602 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700603 */
604message WakeupAlarmOccurred {
605 // TODO: Add attribution instead of uid?
606 optional int32 uid = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800607
608 // Name of the wakeup alarm.
609 optional string tag = 2;
610}
611
612/**
613 * Logs when an an app causes the mobile radio to change state.
614 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
615 *
616 * Logged from:
617 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
618 */
619message MobileRadioPowerStateChanged {
620 // TODO: Add attribution instead of uid?
621 optional int32 uid = 1;
622
623 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
624 enum PowerState {
625 DC_POWER_STATE_LOW = 1;
626 DC_POWER_STATE_MEDIUM = 2;
627 DC_POWER_STATE_HIGH = 3;
628 }
629 optional PowerState power_state = 2;
630}
631
632/**
633 * Logs when an an app causes the wifi radio to change state.
634 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
635 *
636 * Logged from:
637 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
638 */
639message WifiRadioPowerStateChanged {
640 // TODO: Add attribution instead of uid?
641 optional int32 uid = 1;
642
643 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
644 enum PowerState {
645 DC_POWER_STATE_LOW = 1;
646 DC_POWER_STATE_MEDIUM = 2;
647 DC_POWER_STATE_HIGH = 3;
648 }
649 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700650}
651
652/**
653 * Logs kernel wakeup reasons and aborts.
654 *
655 * Logged from:
656 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
657 */
658message KernelWakeupReported {
659 // Name of the kernel wakeup reason (or abort).
660 optional string wakeup_reason_name = 1;
661
662 // Duration (in microseconds) for the wake-up interrupt to be serviced.
663 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700664}
665
666/**
667 * Logs wifi locks held by an app.
668 *
669 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700670 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700671 */
672message WifiLockStateChanged {
673 // TODO: Add attribution instead of uid.
674 optional int32 uid = 1;
675
676 enum State {
677 OFF = 0;
678 ON = 1;
679 }
680 optional State state = 2;
681}
682
683/**
684 * Logs wifi signal strength changes.
685 *
686 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700687 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700688 */
689message WifiSignalStrengthChanged {
690 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
691 enum SignalStrength {
692 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
693 SIGNAL_STRENGTH_POOR = 1;
694 SIGNAL_STRENGTH_MODERATE = 2;
695 SIGNAL_STRENGTH_GOOD = 3;
696 SIGNAL_STRENGTH_GREAT = 4;
697 }
698 optional SignalStrength signal_strength = 1;
699}
700
701/**
702 * Logs wifi scans performed by an app.
703 *
704 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700705 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700706 */
707message WifiScanStateChanged {
708 // TODO: Add attribution instead of uid.
709 optional int32 uid = 1;
710
711 enum State {
712 OFF = 0;
713 ON = 1;
714 }
715 optional State state = 2;
716}
717
718/**
719 * Logs phone signal strength changes.
720 *
721 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700722 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700723 */
724message PhoneSignalStrengthChanged {
725 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
726 enum SignalStrength {
727 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
728 SIGNAL_STRENGTH_POOR = 1;
729 SIGNAL_STRENGTH_MODERATE = 2;
730 SIGNAL_STRENGTH_GOOD = 3;
731 SIGNAL_STRENGTH_GREAT = 4;
732 }
733 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700734}
735
736/**
737 * Logs that a setting was updated.
738 * Logged from:
739 * frameworks/base/core/java/android/provider/Settings.java
740 * The tag and is_default allow resetting of settings to default values based on the specified
741 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
742 */
743message SettingChanged {
744 // The name of the setting.
745 optional string setting = 1;
746
747 // The change being imposed on this setting. May represent a number, eg "3".
748 optional string value = 2;
749
750 // The new value of this setting. For most settings, this is same as value. For some settings,
751 // value is +X or -X where X represents an element in a set. For example, if the previous value
752 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
753 // The +/- feature is currently only used for location_providers_allowed.
754 optional string new_value = 3;
755
756 // The previous value of this setting.
757 optional string prev_value = 4;
758
759 // The tag used with the is_default for resetting sets of settings. This is generally null.
760 optional string tag = 5;
761
762 // 1 indicates that this setting with tag should be resettable.
763 optional int32 is_default = 6;
764
765 // The user ID associated. Defined in android/os/UserHandle.java
766 optional int32 user = 7;
767}
Chenjie Yub3dda412017-10-24 13:41:59 -0700768
Chenjie Yu05013b32017-11-21 10:21:41 -0800769/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700770 * Logs activity going to foreground or background
771 *
772 * Logged from:
773 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
774 */
775message ActivityForegroundStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800776 optional int32 uid = 1;
777 optional string pkg_name = 2;
778 optional string class_name = 3;
779
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700780 enum Activity {
781 MOVE_TO_BACKGROUND = 0;
782 MOVE_TO_FOREGROUND = 1;
783 }
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700784 optional Activity activity = 4;
785}
David Chenc8a43242017-10-17 16:23:28 -0700786
787/**
David Chen9e3808c2017-11-20 17:25:34 -0800788 * Logs when an error is written to dropbox.
789 * Logged from:
790 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
791 */
792message DropboxErrorChanged {
793 // The uid if available. -1 means not available.
794 optional int32 uid = 1;
795
796 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
797 optional string tag = 2;
798
799 // The name of the process.
800 optional string process_name = 3;
801
802 // The pid if available. -1 means not available.
803 optional int32 pid = 4;
804
805 // 1 indicates is instant app. -1 indicates Not applicable.
806 optional int32 is_instant_app = 5;
807
808 // The activity name if available.
809 optional string activity_name = 6;
810
811 // 1 indicates in foreground. -1 indicates not available.
812 optional int32 is_foreground = 7;
813}
814
David Chen0a368b22017-12-06 16:28:16 -0800815/*
816 * Allows other apps to push events into statsd.
817 * Logged from:
818 * frameworks/base/core/java/android/util/StatsLog.java
819 */
820message AppHook {
821 // The uid of the application that sent this custom atom.
822 optional int32 uid = 1;
823
824 // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
825 optional int32 label = 2;
826
827 // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
828 // predicates for the metrics).
829 enum State {
830 UNKNOWN = 0;
831 UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
832 STOP = 2;
833 START = 3;
834 }
835 optional State state = 3;
836}
837
David Chen9e3808c2017-11-20 17:25:34 -0800838/**
Bookatz8fcd09a2017-12-18 13:01:10 -0800839 * Logs when statsd detects an anomaly.
840 *
841 * Logged from:
842 * frameworks/base/cmds/statsd/src/anomaly/AnomalyTracker.cpp
843 */
844message AnomalyDetected {
845 // Uid that owns the config whose anomaly detection alert fired.
846 optional int32 config_uid = 1;
847
Yangster-mac94e197c2018-01-02 16:03:03 -0800848 // Id of the config whose anomaly detection alert fired.
849 optional int64 config_id = 2;
Bookatz8fcd09a2017-12-18 13:01:10 -0800850
Yangster-mac94e197c2018-01-02 16:03:03 -0800851 // Id of the alert (i.e. name of the anomaly that was detected).
852 optional int64 alert_id = 3;
Bookatz8fcd09a2017-12-18 13:01:10 -0800853}
854
855/**
David Chenc8a43242017-10-17 16:23:28 -0700856 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
857 *
858 * Pulled from:
859 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
860 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800861message WifiBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -0700862 optional int32 uid = 1;
863
864 optional int64 rx_bytes = 2;
865
866 optional int64 rx_packets = 3;
867
868 optional int64 tx_bytes = 4;
869
870 optional int64 tx_packets = 5;
871}
872
873/**
874 * Pulls bytes transferred via wifi (separated by foreground and background usage).
875 *
876 * Pulled from:
877 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
878 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800879message WifiBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -0700880 optional int32 uid = 1;
881
882 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
883 optional int32 is_foreground = 2;
884
885 optional int64 rx_bytes = 3;
886
887 optional int64 rx_packets = 4;
888
889 optional int64 tx_bytes = 5;
890
891 optional int64 tx_packets = 6;
892}
893
894/**
895 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
896 *
897 * Pulled from:
898 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
899 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800900message MobileBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -0700901 optional int32 uid = 1;
902
903 optional int64 rx_bytes = 2;
904
905 optional int64 rx_packets = 3;
906
907 optional int64 tx_bytes = 4;
908
909 optional int64 tx_packets = 5;
910}
911
912/**
913 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
914 *
915 * Pulled from:
916 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
917 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800918message MobileBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -0700919 optional int32 uid = 1;
920
921 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
922 optional int32 is_foreground = 2;
923
924 optional int64 rx_bytes = 3;
925
926 optional int64 rx_packets = 4;
927
928 optional int64 tx_bytes = 5;
929
930 optional int64 tx_packets = 6;
931}
932
933/**
934 * Pulls the kernel wakelock durations. This atom is adapted from
935 * android/internal/os/KernelWakelockStats.java
936 *
937 * Pulled from:
938 * StatsCompanionService using KernelWakelockReader.
939 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800940message KernelWakelock {
David Chenc8a43242017-10-17 16:23:28 -0700941 optional string name = 1;
942
943 optional int32 count = 2;
944
945 optional int32 version = 3;
946
947 optional int64 time = 4;
948}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700949
Chenjie Yu05013b32017-11-21 10:21:41 -0800950/**
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700951 * Pulls PowerStatePlatformSleepState.
952 *
953 * Definition here:
954 * hardware/interfaces/power/1.0/types.hal
955 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800956message PlatformSleepState {
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700957 optional string name = 1;
958 optional uint64 residency_in_msec_since_boot = 2;
959 optional uint64 total_transitions = 3;
960 optional bool supported_only_in_suspend = 4;
961}
962
963/**
964 * Pulls PowerStateVoter.
965 *
966 * Definition here:
967 * hardware/interfaces/power/1.0/types.hal
968 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800969message SleepStateVoter {
970 optional string platform_sleep_state_name = 1;
971 optional string voter_name = 2;
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700972 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
973 optional uint64 total_number_of_times_voted_since_boot = 4;
974}
975
976/**
977 * Pulls PowerStateSubsystemSleepState.
978 *
979 * Definition here:
980 * hardware/interfaces/power/1.1/types.hal
981 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800982message SubsystemSleepState {
983 optional string subsystem_name = 1;
984 optional string subsystem_sleep_state_name = 2;
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700985 optional uint64 residency_in_msec_since_boot = 3;
986 optional uint64 total_transitions = 4;
987 optional uint64 last_entry_timestamp_ms = 5;
988 optional bool supported_only_in_suspend = 6;
989}
David Chen21582962017-11-01 17:32:46 -0700990
991/**
992 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
993 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
994 * attributed back to the parent (host) uid. One example is Chrome.
995 *
996 * Logged from:
997 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
998 */
999message IsolatedUidChanged {
1000 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
1001 optional int32 parent_uid = 1;
1002
1003 optional int32 isolated_uid = 2;
1004
1005 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
1006 // be removed before if it's used for another parent uid.
1007 optional int32 is_create = 3;
1008}
Chenjie Yu7f8def92017-11-03 09:33:15 -07001009
Chenjie Yu05013b32017-11-21 10:21:41 -08001010/**
Chenjie Yu7f8def92017-11-03 09:33:15 -07001011 * Pulls Cpu time per frequency.
1012 * Note: this should be pulled for gauge metric only, without condition.
1013 * The puller keeps internal state of last values. It should not be pulled by
1014 * different metrics.
1015 * The pulled data is delta of cpu time from last pull, calculated as
1016 * following:
1017 * if current time is larger than last value, take delta between the two.
1018 * if current time is smaller than last value, there must be a cpu
1019 * hotplug event, and the current time is taken as delta.
1020 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001021message CpuTimePerFreq {
Chenjie Yu7f8def92017-11-03 09:33:15 -07001022 optional uint32 cluster = 1;
1023 optional uint32 freq_index = 2;
Chenjie Yu31d14d72017-12-12 17:54:33 -08001024 optional uint64 time_ms = 3;
Chenjie Yu7f8def92017-11-03 09:33:15 -07001025}
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001026
Chenjie Yu05013b32017-11-21 10:21:41 -08001027/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001028 * Pulls Cpu Time Per Uid.
1029 * Note that isolated process uid time should be attributed to host uids.
1030 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001031message CpuTimePerUid {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001032 optional uint64 uid = 1;
1033 optional uint64 user_time_ms = 2;
1034 optional uint64 sys_time_ms = 3;
1035}
1036
1037/**
1038 * Pulls Cpu Time Per Uid per frequency.
1039 * Note that isolated process uid time should be attributed to host uids.
1040 * For each uid, we order the time by descending frequencies.
1041 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001042message CpuTimePerUidFreq {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001043 optional uint64 uid = 1;
1044 optional uint64 freq_idx = 2;
1045 optional uint64 time_ms = 3;
1046}
Hugo Benichi884970e2017-11-14 22:42:46 +09001047
1048/*
1049 * Logs the reception of an incoming network packet causing the main system to wake up for
1050 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1051 * and processed by WakeupController.cpp.
1052 */
1053message PacketWakeupOccurred {
1054 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1055 // delivered nowhere.
1056 optional int32 uid = 1;
1057 // The interface name on which the packet was received.
1058 optional string iface = 2;
1059 // The ethertype value of the packet.
1060 optional int32 ethertype = 3;
1061 // String representation of the destination MAC address of the packet.
1062 optional string destination_hardware_address = 4;
1063 // String representation of the source address of the packet if this was an IP packet.
1064 optional string source_ip = 5;
1065 // String representation of the destination address of the packet if this was an IP packet.
1066 optional string destination_ip = 6;
1067 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1068 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1069 // families.
1070 optional int32 ip_next_header = 7;
1071 // The source port if this was a TCP or UDP packet.
1072 optional int32 source_port = 8;
1073 // The destination port if this was a TCP or UDP packet.
1074 optional int32 destination_port = 9;
1075}
Chenjie Yu05013b32017-11-21 10:21:41 -08001076
1077/**
1078 * Pulls Wifi Controller Activity Energy Info
1079 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001080message WifiActivityEnergyInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001081 // timestamp(wall clock) of record creation
1082 optional uint64 timestamp_ms = 1;
1083 // stack reported state
1084 // TODO: replace this with proto enum
1085 optional int32 stack_state = 2;
1086 // tx time in ms
1087 optional uint64 controller_tx_time_ms = 3;
1088 // rx time in ms
1089 optional uint64 controller_rx_time_ms = 4;
1090 // idle time in ms
1091 optional uint64 controller_idle_time_ms = 5;
1092 // product of current(mA), voltage(V) and time(ms)
1093 optional uint64 controller_energy_used = 6;
1094}
1095
1096/**
1097 * Pulls Modem Activity Energy Info
1098 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001099message ModemActivityInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001100 // timestamp(wall clock) of record creation
1101 optional uint64 timestamp_ms = 1;
1102 // sleep time in ms.
1103 optional uint64 sleep_time_ms = 2;
1104 // idle time in ms
1105 optional uint64 controller_idle_time_ms = 3;
1106 /**
1107 * Tx power index
1108 * index 0 = tx_power < 0dBm
1109 * index 1 = 0dBm < tx_power < 5dBm
1110 * index 2 = 5dBm < tx_power < 15dBm
1111 * index 3 = 15dBm < tx_power < 20dBm
1112 * index 4 = tx_power > 20dBm
1113 */
1114 // tx time in ms at power level 0
1115 optional uint64 controller_tx_time_pl0_ms = 4;
1116 // tx time in ms at power level 1
1117 optional uint64 controller_tx_time_pl1_ms = 5;
1118 // tx time in ms at power level 2
1119 optional uint64 controller_tx_time_pl2_ms = 6;
1120 // tx time in ms at power level 3
1121 optional uint64 controller_tx_time_pl3_ms = 7;
1122 // tx time in ms at power level 4
1123 optional uint64 controller_tx_time_pl4_ms = 8;
1124 // rx time in ms at power level 5
1125 optional uint64 controller_rx_time_ms = 9;
1126 // product of current(mA), voltage(V) and time(ms)
1127 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001128}