blob: 968d08f909921ecc6a04a7c244d50b21d9ec63eb [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
Yao Chend54f9dd2017-10-17 17:37:48 +000024/**
Stefan Lafonae2df012017-11-14 09:17:21 -080025 * The master atom class. This message defines all of the available
Yao Chend54f9dd2017-10-17 17:37:48 +000026 * raw stats log events from the Android system, also known as "atoms."
27 *
28 * This field contains a single oneof with all of the available messages.
29 * The stats-log-api-gen tool runs as part of the Android build and
30 * generates the android.util.StatsLog class, which contains the constants
31 * and methods that Android uses to log.
32 *
Stefan Lafonae2df012017-11-14 09:17:21 -080033 * This Atom class is not actually built into the Android system.
Yao Chend54f9dd2017-10-17 17:37:48 +000034 * Instead, statsd on Android constructs these messages synthetically,
35 * in the format defined here and in stats_log.proto.
36 */
Stefan Lafonae2df012017-11-14 09:17:21 -080037message Atom {
38 // Pushed atoms start at 2.
David Chenc8a43242017-10-17 16:23:28 -070039 oneof pushed {
Bookatzc1a050a2017-10-10 15:49:28 -070040 // For StatsLog reasons, 1 is illegal and will not work. Must start at 2.
41 BleScanStateChanged ble_scan_state_changed = 2;
42 BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
43 BleScanResultReceived ble_scan_result_received = 4;
44 SensorStateChanged sensor_state_changed = 5;
45 GpsScanStateChanged gps_scan_state_changed = 6; // TODO: untested
46 SyncStateChanged sync_state_changed = 7;
47 ScheduledJobStateChanged scheduled_job_state_changed = 8;
48 ScreenBrightnessChanged screen_brightness_changed = 9;
Bookatzd6746242017-10-24 18:39:35 -070049 WakelockStateChanged wakelock_state_changed = 10;
Bookatzddccf0a2017-11-28 16:48:14 -080050 LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 11;
51 MobileRadioPowerStateChanged mobile_radio_power_state_changed = 12;
52 WifiRadioPowerStateChanged wifi_radio_power_state_changed = 13;
53 // TODO: 14-19 are blank, but need not be
54 BatterySaverModeStateChanged battery_saver_mode_state_changed = 20;
55 DeviceIdleModeStateChanged device_idle_mode_state_changed = 21;
56 DeviceIdlingModeStateChanged device_idling_mode_state_changed = 22;
Bookatzc1a050a2017-10-10 15:49:28 -070057 AudioStateChanged audio_state_changed = 23;
58 MediaCodecActivityChanged media_codec_activity_changed = 24;
59 CameraStateChanged camera_state_changed = 25;
60 FlashlightStateChanged flashlight_state_changed = 26;
61 UidProcessStateChanged uid_process_state_changed = 27;
62 ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28;
63 ScreenStateChanged screen_state_changed = 29;
Bookatz8c6571b2017-10-24 15:04:41 -070064 BatteryLevelChanged battery_level_changed = 30;
65 ChargingStateChanged charging_state_changed = 31;
66 PluggedStateChanged plugged_state_changed = 32;
67 DeviceTemperatureReported device_temperature_reported = 33;
68 DeviceOnStatusChanged device_on_status_changed = 34;
69 WakeupAlarmOccurred wakeup_alarm_occurred = 35;
70 KernelWakeupReported kernel_wakeup_reported = 36;
Bookatze5885242017-10-24 20:10:31 -070071 WifiLockStateChanged wifi_lock_state_changed = 37;
72 WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
73 WifiScanStateChanged wifi_scan_state_changed = 39;
74 PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
David Chenc28b2bb2017-10-24 12:52:52 -070075 SettingChanged setting_changed = 41;
David Chenc8a43242017-10-17 16:23:28 -070076 ActivityForegroundStateChanged activity_foreground_state_changed = 42;
David Chen21582962017-11-01 17:32:46 -070077 IsolatedUidChanged isolated_uid_changed = 43;
Hugo Benichi884970e2017-11-14 22:42:46 +090078 PacketWakeupOccurred packet_wakeup_occurred = 44;
David Chen9e3808c2017-11-20 17:25:34 -080079 DropboxErrorChanged dropbox_error_changed = 45;
Bookatzc1a050a2017-10-10 15:49:28 -070080 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000081 }
David Chenc8a43242017-10-17 16:23:28 -070082
83 // Pulled events will start at field 1000.
84 oneof pulled {
85 WifiBytesTransferred wifi_bytes_transferred = 1000;
86 WifiBytesTransferredByFgBg wifi_bytes_transferred_by_fg_bg = 1001;
87 MobileBytesTransferred mobile_bytes_transferred = 1002;
88 MobileBytesTransferredByFgBg mobile_bytes_transferred_by_fg_bg = 1003;
Chenjie Yu5305e1d2017-10-31 13:49:36 -070089 KernelWakelockPulled kernel_wakelock_pulled = 1004;
90 PowerStatePlatformSleepStatePulled power_state_platform_sleep_state_pulled = 1005;
91 PowerStateVoterPulled power_state_voter_pulled = 1006;
92 PowerStateSubsystemSleepStatePulled power_state_subsystem_sleep_state_pulled = 1007;
Chenjie Yu7f8def92017-11-03 09:33:15 -070093 CpuTimePerFreqPulled cpu_time_per_freq_pulled = 1008;
Chenjie Yue33bc3b2017-11-06 17:56:44 -080094 CpuTimePerUidPulled cpu_time_per_uid_pulled = 1009;
95 CpuTimePerUidFreqPulled cpu_time_per_uid_freq_pulled = 1010;
Chenjie Yu05013b32017-11-21 10:21:41 -080096 WifiActivityEnergyInfoPulled wifi_activity_energy_info_pulled = 1011;
97 ModemActivityInfoPulled modem_activity_info_pulled = 1012;
David Chenc8a43242017-10-17 16:23:28 -070098 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070099}
100
Yao Chend54f9dd2017-10-17 17:37:48 +0000101/**
102 * A WorkSource represents the chained attribution of applications that
103 * resulted in a particular bit of work being done.
104 */
105message WorkSource {
106 // TODO
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700107}
108
Yao Chend54f9dd2017-10-17 17:37:48 +0000109/*
110 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800111 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000112 *
113 * RULES:
114 * - The field ids for each atom must start at 1, and count upwards by 1.
115 * Skipping field ids is not allowed.
116 * - These form an API, so renaming, renumbering or removing fields is
117 * not allowed between android releases. (This is not currently enforced,
118 * but there will be a tool to enforce this restriction).
119 * - The types must be built-in protocol buffer types, namely, no sub-messages
120 * are allowed (yet). The bytes type is also not allowed.
121 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800122 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000123 * - If an atom represents work that can be attributed to an app, there can
124 * be exactly one WorkSource field. It must be field number 1.
125 * - A field that is a uid should be a string field, tagged with the [xxx]
126 * annotation. The generated code on android will be represented by UIDs,
127 * and those UIDs will be translated in xxx to those strings.
128 *
129 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700130 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000131 * - If there is a UID, it goes first. Think in an object-oriented fashion.
132 * *****************************************************************************
133 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700134
Yao Chend54f9dd2017-10-17 17:37:48 +0000135/**
136 * Logs when the screen state changes.
137 *
138 * Logged from:
139 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
140 */
141message ScreenStateChanged {
142 // TODO: Use the real screen state.
143 enum State {
144 STATE_UNKNOWN = 0;
145 STATE_OFF = 1;
146 STATE_ON = 2;
147 STATE_DOZE = 3;
148 STATE_DOZE_SUSPEND = 4;
149 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800150 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000151 }
152 // New screen state.
153 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700154}
Yao Chend54f9dd2017-10-17 17:37:48 +0000155
156/**
Bookatzc1a050a2017-10-10 15:49:28 -0700157 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000158 *
159 * Logged from:
160 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
161 */
Bookatzc1a050a2017-10-10 15:49:28 -0700162message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000163 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
164
165 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700166 // TODO: Use the real (mapped) process states.
Yao Chend54f9dd2017-10-17 17:37:48 +0000167 optional int32 state = 2;
168}
169
170/**
Bookatzc1a050a2017-10-10 15:49:28 -0700171 * Logs that a process started, finished, crashed, or ANRed.
172 *
173 * Logged from:
174 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
175 */
176message ProcessLifeCycleStateChanged {
177 // TODO: Use the real (mapped) process states.
178 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
179
180 // TODO: What is this?
181 optional string name = 2;
182
Bookatzddccf0a2017-11-28 16:48:14 -0800183 // What lifecycle state the process changed to.
184 // This enum is specific to atoms.proto.
185 enum Event {
186 PROCESS_FINISHED = 0;
187 PROCESS_STARTED = 1;
188 PROCESS_CRASHED = 2;
189 PROCESS_ANRED = 3;
190 }
191 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700192}
193
Bookatzc1a050a2017-10-10 15:49:28 -0700194/**
195 * Logs when the ble scan state changes.
196 *
197 * Logged from:
198 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
199 */
200message BleScanStateChanged {
201 // TODO: Add attribution instead of uid.
202 optional int32 uid = 1;
203
204 enum State {
205 OFF = 0;
206 ON = 1;
207 }
208 optional State state = 2;
209}
210
211/**
212 * Logs when an unoptimized ble scan state changes.
213 *
214 * Logged from:
215 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
216 */
217// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
218message BleUnoptimizedScanStateChanged {
219 // TODO: Add attribution instead of uid.
220 optional int32 uid = 1;
221
222 enum State {
223 OFF = 0;
224 ON = 1;
225 }
226 optional State state = 2;
227}
228
229/**
230 * Logs reporting of a ble scan finding results.
231 *
232 * Logged from:
233 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
234 */
235// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
236message BleScanResultReceived {
237 // TODO: Add attribution instead of uid.
238 optional int32 uid = 1;
239
240 // Number of ble scan results returned.
241 optional int32 num_of_results = 2;
242}
243
244/**
245 * Logs when a sensor state changes.
246 *
247 * Logged from:
248 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
249 */
250message SensorStateChanged {
251 // TODO: Add attribution instead of uid.
252 optional int32 uid = 1;
253
254 // TODO: Is there a way to get the actual name of the sensor?
255 // The id (int) of the sensor.
256 optional int32 sensor_id = 2;
257
258 enum State {
259 OFF = 0;
260 ON = 1;
261 }
262 optional State state = 3;
263}
264
265
266/**
267 * Logs when GPS state changes.
268 *
269 * Logged from:
270 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
271 */
272message GpsScanStateChanged {
273 // TODO: Add attribution instead of uid.
274 optional int32 uid = 1;
275
276 enum State {
277 OFF = 0;
278 ON = 1;
279 }
280 optional State state = 2;
281}
282
283
284/**
285 * Logs when a sync manager sync state changes.
286 *
287 * Logged from:
288 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
289 */
290message SyncStateChanged {
291 // TODO: Add attribution instead of uid.
292 optional int32 uid = 1;
293
294 // Name of the sync (as named in the app)
295 optional string name = 2;
296
297 enum State {
298 OFF = 0;
299 ON = 1;
300 }
301 optional State state = 3;
302}
303
304/**
305 * Logs when a job scheduler job state changes.
306 *
307 * Logged from:
308 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
309 */
310message ScheduledJobStateChanged {
311 // TODO: Add attribution instead of uid.
312 optional int32 uid = 1;
313
314 // Name of the job (as named in the app)
315 optional string name = 2;
316
317 enum State {
318 OFF = 0;
319 ON = 1;
320 }
321 optional State state = 3;
322
323 // TODO: Consider adding the stopReason (int)
324}
325
326/**
327 * Logs when the audio state changes.
328 *
329 * Logged from:
330 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
331 */
332message AudioStateChanged {
333 // TODO: Add attribution instead of uid.
334 optional int32 uid = 1;
335
336 enum State {
337 OFF = 0;
338 ON = 1;
339 }
340 optional State state = 2;
341}
342
343/**
344 * Logs when the video codec state changes.
345 *
346 * Logged from:
347 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
348 */
349message MediaCodecActivityChanged {
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 flashlight state changes.
362 *
363 * Logged from:
364 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
365 */
366message FlashlightStateChanged {
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 camera state changes.
379 *
380 * Logged from:
381 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
382 */
383message CameraStateChanged {
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 that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000396 *
397 * Logged from:
398 * TODO
399 */
Bookatzd6746242017-10-24 18:39:35 -0700400message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000401 // TODO: Add attribution instead of uid.
402 optional int32 uid = 1;
403
Bookatzc1a050a2017-10-10 15:49:28 -0700404 // Type of wakelock.
405 enum Type {
406 PARTIAL = 0;
407 FULL = 1;
408 WINDOW = 2;
409 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800410 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700411
412 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
413 optional string tag = 3;
414
415 enum State {
416 OFF = 0;
417 ON = 1;
418 }
419 optional State state = 4;
420}
421
422/**
Bookatzc1a050a2017-10-10 15:49:28 -0700423 * Logs when a partial wakelock is considered 'long' (over 1 min).
424 *
425 * Logged from:
426 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
427 */
428message LongPartialWakelockStateChanged {
429 // TODO: Add attribution instead of uid?
430 optional int32 uid = 1;
431
Yao Chend54f9dd2017-10-17 17:37:48 +0000432 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
433 optional string tag = 2;
434
Bookatzc1a050a2017-10-10 15:49:28 -0700435 // TODO: I have no idea what this is.
436 optional string history_tag = 3;
437
438 enum State {
439 OFF = 0;
440 ON = 1;
441 }
442 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000443}
444
Bookatzc1a050a2017-10-10 15:49:28 -0700445/**
446 * Logs Battery Saver state change.
447 *
448 * Logged from:
449 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
450 */
451message BatterySaverModeStateChanged {
452 enum State {
453 OFF = 0;
454 ON = 1;
455 }
456 optional State state = 1;
457}
458
459/**
460 * Logs Doze mode state change.
461 *
462 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800463 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700464 */
465message DeviceIdleModeStateChanged {
466 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800467 enum State {
468 DEVICE_IDLE_MODE_OFF = 0;
469 DEVICE_IDLE_MODE_LIGHT = 1;
470 DEVICE_IDLE_MODE_DEEP = 2;
471 }
472 optional State state = 1;
473}
474
475
476/**
477 * Logs state change of Doze mode including maintenance windows.
478 *
479 * Logged from:
480 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
481 */
482message DeviceIdlingModeStateChanged {
483 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
484 enum State {
485 DEVICE_IDLE_MODE_OFF = 0;
486 DEVICE_IDLE_MODE_LIGHT = 1;
487 DEVICE_IDLE_MODE_DEEP = 2;
488 }
489 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700490}
491
492/**
493 * Logs screen brightness level.
494 *
495 * Logged from:
496 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
497 */
498message ScreenBrightnessChanged {
499 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
500 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700501}
502
503/**
504 * Logs battery level (percent full, from 0 to 100).
505 *
506 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700507 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700508 */
509message BatteryLevelChanged {
510 // Battery level. Should be in [0, 100].
511 optional int32 battery_level = 1;
512}
513
514/**
515 * Logs change in charging status of the device.
516 *
517 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700518 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700519 */
520message ChargingStateChanged {
521 // TODO: Link directly to BatteryManager.java's constants (via a proto).
522 enum State {
523 BATTERY_STATUS_UNKNOWN = 1;
524 BATTERY_STATUS_CHARGING = 2;
525 BATTERY_STATUS_DISCHARGING = 3;
526 BATTERY_STATUS_NOT_CHARGING = 4;
527 BATTERY_STATUS_FULL = 5;
528 }
529 optional State charging_state = 1;
530}
531
532/**
533 * Logs whether the device is plugged in, and what power source it is using.
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 PluggedStateChanged {
539 // TODO: Link directly to BatteryManager.java's constants (via a proto).
540 enum State {
541 // Note that NONE is not in BatteryManager.java's constants.
542 BATTERY_PLUGGED_NONE = 0;
543 // Power source is an AC charger.
544 BATTERY_PLUGGED_AC = 1;
545 // Power source is a USB port.
546 BATTERY_PLUGGED_USB = 2;
547 // Power source is wireless.
548 BATTERY_PLUGGED_WIRELESS = 4;
549 }
550 optional State plugged_state = 1;
551}
552
553/**
554 * Logs the temperature of the device, in tenths of a degree Celsius.
555 *
556 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700557 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700558 */
559message DeviceTemperatureReported {
560 // Temperature in tenths of a degree C.
561 optional int32 temperature = 1;
562}
563
564// TODO: Define this more precisely.
565// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
566/**
567 * Logs when the device turns off or on.
568 *
569 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700570 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700571 */
572message DeviceOnStatusChanged {
573 enum State {
574 OFF = 0;
575 ON = 1;
576 }
577 optional State state = 1;
578}
579
580/**
581 * Logs when an app's wakeup alarm fires.
582 *
583 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700584 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700585 */
586message WakeupAlarmOccurred {
587 // TODO: Add attribution instead of uid?
588 optional int32 uid = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800589
590 // Name of the wakeup alarm.
591 optional string tag = 2;
592}
593
594/**
595 * Logs when an an app causes the mobile radio to change state.
596 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
597 *
598 * Logged from:
599 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
600 */
601message MobileRadioPowerStateChanged {
602 // TODO: Add attribution instead of uid?
603 optional int32 uid = 1;
604
605 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
606 enum PowerState {
607 DC_POWER_STATE_LOW = 1;
608 DC_POWER_STATE_MEDIUM = 2;
609 DC_POWER_STATE_HIGH = 3;
610 }
611 optional PowerState power_state = 2;
612}
613
614/**
615 * Logs when an an app causes the wifi radio to change state.
616 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
617 *
618 * Logged from:
619 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
620 */
621message WifiRadioPowerStateChanged {
622 // TODO: Add attribution instead of uid?
623 optional int32 uid = 1;
624
625 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
626 enum PowerState {
627 DC_POWER_STATE_LOW = 1;
628 DC_POWER_STATE_MEDIUM = 2;
629 DC_POWER_STATE_HIGH = 3;
630 }
631 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700632}
633
634/**
635 * Logs kernel wakeup reasons and aborts.
636 *
637 * Logged from:
638 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
639 */
640message KernelWakeupReported {
641 // Name of the kernel wakeup reason (or abort).
642 optional string wakeup_reason_name = 1;
643
644 // Duration (in microseconds) for the wake-up interrupt to be serviced.
645 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700646}
647
648/**
649 * Logs wifi locks held by an app.
650 *
651 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700652 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700653 */
654message WifiLockStateChanged {
655 // TODO: Add attribution instead of uid.
656 optional int32 uid = 1;
657
658 enum State {
659 OFF = 0;
660 ON = 1;
661 }
662 optional State state = 2;
663}
664
665/**
666 * Logs wifi signal strength changes.
667 *
668 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700669 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700670 */
671message WifiSignalStrengthChanged {
672 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
673 enum SignalStrength {
674 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
675 SIGNAL_STRENGTH_POOR = 1;
676 SIGNAL_STRENGTH_MODERATE = 2;
677 SIGNAL_STRENGTH_GOOD = 3;
678 SIGNAL_STRENGTH_GREAT = 4;
679 }
680 optional SignalStrength signal_strength = 1;
681}
682
683/**
684 * Logs wifi scans performed by an app.
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 WifiScanStateChanged {
690 // TODO: Add attribution instead of uid.
691 optional int32 uid = 1;
692
693 enum State {
694 OFF = 0;
695 ON = 1;
696 }
697 optional State state = 2;
698}
699
700/**
701 * Logs phone signal strength changes.
702 *
703 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700704 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700705 */
706message PhoneSignalStrengthChanged {
707 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
708 enum SignalStrength {
709 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
710 SIGNAL_STRENGTH_POOR = 1;
711 SIGNAL_STRENGTH_MODERATE = 2;
712 SIGNAL_STRENGTH_GOOD = 3;
713 SIGNAL_STRENGTH_GREAT = 4;
714 }
715 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700716}
717
718/**
719 * Logs that a setting was updated.
720 * Logged from:
721 * frameworks/base/core/java/android/provider/Settings.java
722 * The tag and is_default allow resetting of settings to default values based on the specified
723 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
724 */
725message SettingChanged {
726 // The name of the setting.
727 optional string setting = 1;
728
729 // The change being imposed on this setting. May represent a number, eg "3".
730 optional string value = 2;
731
732 // The new value of this setting. For most settings, this is same as value. For some settings,
733 // value is +X or -X where X represents an element in a set. For example, if the previous value
734 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
735 // The +/- feature is currently only used for location_providers_allowed.
736 optional string new_value = 3;
737
738 // The previous value of this setting.
739 optional string prev_value = 4;
740
741 // The tag used with the is_default for resetting sets of settings. This is generally null.
742 optional string tag = 5;
743
744 // 1 indicates that this setting with tag should be resettable.
745 optional int32 is_default = 6;
746
747 // The user ID associated. Defined in android/os/UserHandle.java
748 optional int32 user = 7;
749}
Chenjie Yub3dda412017-10-24 13:41:59 -0700750
Chenjie Yu05013b32017-11-21 10:21:41 -0800751/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700752 * Logs activity going to foreground or background
753 *
754 * Logged from:
755 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
756 */
757message ActivityForegroundStateChanged {
758 enum Activity {
759 MOVE_TO_BACKGROUND = 0;
760 MOVE_TO_FOREGROUND = 1;
761 }
762 optional int32 uid = 1;
763 optional string pkg_name = 2;
764 optional string class_name = 3;
765 optional Activity activity = 4;
766}
David Chenc8a43242017-10-17 16:23:28 -0700767
768/**
David Chen9e3808c2017-11-20 17:25:34 -0800769 * Logs when an error is written to dropbox.
770 * Logged from:
771 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
772 */
773message DropboxErrorChanged {
774 // The uid if available. -1 means not available.
775 optional int32 uid = 1;
776
777 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
778 optional string tag = 2;
779
780 // The name of the process.
781 optional string process_name = 3;
782
783 // The pid if available. -1 means not available.
784 optional int32 pid = 4;
785
786 // 1 indicates is instant app. -1 indicates Not applicable.
787 optional int32 is_instant_app = 5;
788
789 // The activity name if available.
790 optional string activity_name = 6;
791
792 // 1 indicates in foreground. -1 indicates not available.
793 optional int32 is_foreground = 7;
794}
795
796/**
David Chenc8a43242017-10-17 16:23:28 -0700797 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
798 *
799 * Pulled from:
800 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
801 */
802message WifiBytesTransferred {
803 optional int32 uid = 1;
804
805 optional int64 rx_bytes = 2;
806
807 optional int64 rx_packets = 3;
808
809 optional int64 tx_bytes = 4;
810
811 optional int64 tx_packets = 5;
812}
813
814/**
815 * Pulls bytes transferred via wifi (separated by foreground and background usage).
816 *
817 * Pulled from:
818 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
819 */
820message WifiBytesTransferredByFgBg {
821 optional int32 uid = 1;
822
823 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
824 optional int32 is_foreground = 2;
825
826 optional int64 rx_bytes = 3;
827
828 optional int64 rx_packets = 4;
829
830 optional int64 tx_bytes = 5;
831
832 optional int64 tx_packets = 6;
833}
834
835/**
836 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
837 *
838 * Pulled from:
839 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
840 */
841message MobileBytesTransferred {
842 optional int32 uid = 1;
843
844 optional int64 rx_bytes = 2;
845
846 optional int64 rx_packets = 3;
847
848 optional int64 tx_bytes = 4;
849
850 optional int64 tx_packets = 5;
851}
852
853/**
854 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
855 *
856 * Pulled from:
857 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
858 */
859message MobileBytesTransferredByFgBg {
860 optional int32 uid = 1;
861
862 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
863 optional int32 is_foreground = 2;
864
865 optional int64 rx_bytes = 3;
866
867 optional int64 rx_packets = 4;
868
869 optional int64 tx_bytes = 5;
870
871 optional int64 tx_packets = 6;
872}
873
874/**
875 * Pulls the kernel wakelock durations. This atom is adapted from
876 * android/internal/os/KernelWakelockStats.java
877 *
878 * Pulled from:
879 * StatsCompanionService using KernelWakelockReader.
880 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700881message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700882 optional string name = 1;
883
884 optional int32 count = 2;
885
886 optional int32 version = 3;
887
888 optional int64 time = 4;
889}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700890
Chenjie Yu05013b32017-11-21 10:21:41 -0800891/**
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700892 * Pulls PowerStatePlatformSleepState.
893 *
894 * Definition here:
895 * hardware/interfaces/power/1.0/types.hal
896 */
897message PowerStatePlatformSleepStatePulled {
898 optional string name = 1;
899 optional uint64 residency_in_msec_since_boot = 2;
900 optional uint64 total_transitions = 3;
901 optional bool supported_only_in_suspend = 4;
902}
903
904/**
905 * Pulls PowerStateVoter.
906 *
907 * Definition here:
908 * hardware/interfaces/power/1.0/types.hal
909 */
910message PowerStateVoterPulled {
911 optional string power_state_platform_sleep_state_name = 1;
912 optional string power_state_voter_name = 2;
913 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
914 optional uint64 total_number_of_times_voted_since_boot = 4;
915}
916
917/**
918 * Pulls PowerStateSubsystemSleepState.
919 *
920 * Definition here:
921 * hardware/interfaces/power/1.1/types.hal
922 */
923message PowerStateSubsystemSleepStatePulled {
924 optional string power_state_subsystem_name = 1;
925 optional string power_state_subsystem_sleep_state_name = 2;
926 optional uint64 residency_in_msec_since_boot = 3;
927 optional uint64 total_transitions = 4;
928 optional uint64 last_entry_timestamp_ms = 5;
929 optional bool supported_only_in_suspend = 6;
930}
David Chen21582962017-11-01 17:32:46 -0700931
932/**
933 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
934 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
935 * attributed back to the parent (host) uid. One example is Chrome.
936 *
937 * Logged from:
938 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
939 */
940message IsolatedUidChanged {
941 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
942 optional int32 parent_uid = 1;
943
944 optional int32 isolated_uid = 2;
945
946 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
947 // be removed before if it's used for another parent uid.
948 optional int32 is_create = 3;
949}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700950
Chenjie Yu05013b32017-11-21 10:21:41 -0800951/**
Chenjie Yu7f8def92017-11-03 09:33:15 -0700952 * Pulls Cpu time per frequency.
953 * Note: this should be pulled for gauge metric only, without condition.
954 * The puller keeps internal state of last values. It should not be pulled by
955 * different metrics.
956 * The pulled data is delta of cpu time from last pull, calculated as
957 * following:
958 * if current time is larger than last value, take delta between the two.
959 * if current time is smaller than last value, there must be a cpu
960 * hotplug event, and the current time is taken as delta.
961 */
962message CpuTimePerFreqPulled {
963 optional uint32 cluster = 1;
964 optional uint32 freq_index = 2;
965 optional uint64 time = 3;
966}
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800967
Chenjie Yu05013b32017-11-21 10:21:41 -0800968/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800969 * Pulls Cpu Time Per Uid.
970 * Note that isolated process uid time should be attributed to host uids.
971 */
972message CpuTimePerUidPulled {
973 optional uint64 uid = 1;
974 optional uint64 user_time_ms = 2;
975 optional uint64 sys_time_ms = 3;
976}
977
978/**
979 * Pulls Cpu Time Per Uid per frequency.
980 * Note that isolated process uid time should be attributed to host uids.
981 * For each uid, we order the time by descending frequencies.
982 */
983message CpuTimePerUidFreqPulled {
984 optional uint64 uid = 1;
985 optional uint64 freq_idx = 2;
986 optional uint64 time_ms = 3;
987}
Hugo Benichi884970e2017-11-14 22:42:46 +0900988
989/*
990 * Logs the reception of an incoming network packet causing the main system to wake up for
991 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
992 * and processed by WakeupController.cpp.
993 */
994message PacketWakeupOccurred {
995 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
996 // delivered nowhere.
997 optional int32 uid = 1;
998 // The interface name on which the packet was received.
999 optional string iface = 2;
1000 // The ethertype value of the packet.
1001 optional int32 ethertype = 3;
1002 // String representation of the destination MAC address of the packet.
1003 optional string destination_hardware_address = 4;
1004 // String representation of the source address of the packet if this was an IP packet.
1005 optional string source_ip = 5;
1006 // String representation of the destination address of the packet if this was an IP packet.
1007 optional string destination_ip = 6;
1008 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1009 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1010 // families.
1011 optional int32 ip_next_header = 7;
1012 // The source port if this was a TCP or UDP packet.
1013 optional int32 source_port = 8;
1014 // The destination port if this was a TCP or UDP packet.
1015 optional int32 destination_port = 9;
1016}
Chenjie Yu05013b32017-11-21 10:21:41 -08001017
1018/**
1019 * Pulls Wifi Controller Activity Energy Info
1020 */
1021message WifiActivityEnergyInfoPulled {
1022 // timestamp(wall clock) of record creation
1023 optional uint64 timestamp_ms = 1;
1024 // stack reported state
1025 // TODO: replace this with proto enum
1026 optional int32 stack_state = 2;
1027 // tx time in ms
1028 optional uint64 controller_tx_time_ms = 3;
1029 // rx time in ms
1030 optional uint64 controller_rx_time_ms = 4;
1031 // idle time in ms
1032 optional uint64 controller_idle_time_ms = 5;
1033 // product of current(mA), voltage(V) and time(ms)
1034 optional uint64 controller_energy_used = 6;
1035}
1036
1037/**
1038 * Pulls Modem Activity Energy Info
1039 */
1040message ModemActivityInfoPulled {
1041 // timestamp(wall clock) of record creation
1042 optional uint64 timestamp_ms = 1;
1043 // sleep time in ms.
1044 optional uint64 sleep_time_ms = 2;
1045 // idle time in ms
1046 optional uint64 controller_idle_time_ms = 3;
1047 /**
1048 * Tx power index
1049 * index 0 = tx_power < 0dBm
1050 * index 1 = 0dBm < tx_power < 5dBm
1051 * index 2 = 5dBm < tx_power < 15dBm
1052 * index 3 = 15dBm < tx_power < 20dBm
1053 * index 4 = tx_power > 20dBm
1054 */
1055 // tx time in ms at power level 0
1056 optional uint64 controller_tx_time_pl0_ms = 4;
1057 // tx time in ms at power level 1
1058 optional uint64 controller_tx_time_pl1_ms = 5;
1059 // tx time in ms at power level 2
1060 optional uint64 controller_tx_time_pl2_ms = 6;
1061 // tx time in ms at power level 3
1062 optional uint64 controller_tx_time_pl3_ms = 7;
1063 // tx time in ms at power level 4
1064 optional uint64 controller_tx_time_pl4_ms = 8;
1065 // rx time in ms at power level 5
1066 optional uint64 controller_rx_time_ms = 9;
1067 // product of current(mA), voltage(V) and time(ms)
1068 optional uint64 energy_used = 10;
1069}