blob: c81fc1dec7abf5f44677d658bf5012760f0c7586 [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 {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800106 // The uid for a given element in the attribution chain.
107 repeated int32 uid = 1;
108 // The (optional) string tag for an element in the attribution chain. If the
109 // element has no tag, it is encoded as an empty string.
110 repeated string tag = 2;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700111}
112
Yao Chend54f9dd2017-10-17 17:37:48 +0000113/*
114 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800115 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000116 *
117 * RULES:
118 * - The field ids for each atom must start at 1, and count upwards by 1.
119 * Skipping field ids is not allowed.
120 * - These form an API, so renaming, renumbering or removing fields is
121 * not allowed between android releases. (This is not currently enforced,
122 * but there will be a tool to enforce this restriction).
123 * - The types must be built-in protocol buffer types, namely, no sub-messages
124 * are allowed (yet). The bytes type is also not allowed.
125 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800126 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000127 * - If an atom represents work that can be attributed to an app, there can
128 * be exactly one WorkSource field. It must be field number 1.
129 * - A field that is a uid should be a string field, tagged with the [xxx]
130 * annotation. The generated code on android will be represented by UIDs,
131 * and those UIDs will be translated in xxx to those strings.
132 *
133 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700134 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000135 * - If there is a UID, it goes first. Think in an object-oriented fashion.
136 * *****************************************************************************
137 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700138
Yao Chend54f9dd2017-10-17 17:37:48 +0000139/**
140 * Logs when the screen state changes.
141 *
142 * Logged from:
143 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
144 */
145message ScreenStateChanged {
146 // TODO: Use the real screen state.
147 enum State {
148 STATE_UNKNOWN = 0;
149 STATE_OFF = 1;
150 STATE_ON = 2;
151 STATE_DOZE = 3;
152 STATE_DOZE_SUSPEND = 4;
153 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800154 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000155 }
156 // New screen state.
157 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700158}
Yao Chend54f9dd2017-10-17 17:37:48 +0000159
160/**
Bookatzc1a050a2017-10-10 15:49:28 -0700161 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000162 *
163 * Logged from:
164 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
165 */
Bookatzc1a050a2017-10-10 15:49:28 -0700166message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000167 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
168
169 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700170 // TODO: Use the real (mapped) process states.
Yao Chend54f9dd2017-10-17 17:37:48 +0000171 optional int32 state = 2;
172}
173
174/**
Bookatzc1a050a2017-10-10 15:49:28 -0700175 * Logs that a process started, finished, crashed, or ANRed.
176 *
177 * Logged from:
178 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
179 */
180message ProcessLifeCycleStateChanged {
181 // TODO: Use the real (mapped) process states.
182 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
183
184 // TODO: What is this?
185 optional string name = 2;
186
Bookatzddccf0a2017-11-28 16:48:14 -0800187 // What lifecycle state the process changed to.
188 // This enum is specific to atoms.proto.
189 enum Event {
190 PROCESS_FINISHED = 0;
191 PROCESS_STARTED = 1;
192 PROCESS_CRASHED = 2;
193 PROCESS_ANRED = 3;
194 }
195 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700196}
197
Bookatzc1a050a2017-10-10 15:49:28 -0700198/**
199 * Logs when the ble scan state changes.
200 *
201 * Logged from:
202 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
203 */
204message BleScanStateChanged {
205 // TODO: Add attribution instead of uid.
206 optional int32 uid = 1;
207
208 enum State {
209 OFF = 0;
210 ON = 1;
211 }
212 optional State state = 2;
213}
214
215/**
216 * Logs when an unoptimized ble scan state changes.
217 *
218 * Logged from:
219 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
220 */
221// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
222message BleUnoptimizedScanStateChanged {
223 // TODO: Add attribution instead of uid.
224 optional int32 uid = 1;
225
226 enum State {
227 OFF = 0;
228 ON = 1;
229 }
230 optional State state = 2;
231}
232
233/**
234 * Logs reporting of a ble scan finding results.
235 *
236 * Logged from:
237 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
238 */
239// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
240message BleScanResultReceived {
241 // TODO: Add attribution instead of uid.
242 optional int32 uid = 1;
243
244 // Number of ble scan results returned.
245 optional int32 num_of_results = 2;
246}
247
248/**
249 * Logs when a sensor state changes.
250 *
251 * Logged from:
252 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
253 */
254message SensorStateChanged {
255 // TODO: Add attribution instead of uid.
256 optional int32 uid = 1;
257
258 // TODO: Is there a way to get the actual name of the sensor?
259 // The id (int) of the sensor.
260 optional int32 sensor_id = 2;
261
262 enum State {
263 OFF = 0;
264 ON = 1;
265 }
266 optional State state = 3;
267}
268
269
270/**
271 * Logs when GPS state changes.
272 *
273 * Logged from:
274 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
275 */
276message GpsScanStateChanged {
277 // TODO: Add attribution instead of uid.
278 optional int32 uid = 1;
279
280 enum State {
281 OFF = 0;
282 ON = 1;
283 }
284 optional State state = 2;
285}
286
287
288/**
289 * Logs when a sync manager sync state changes.
290 *
291 * Logged from:
292 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
293 */
294message SyncStateChanged {
295 // TODO: Add attribution instead of uid.
296 optional int32 uid = 1;
297
298 // Name of the sync (as named in the app)
299 optional string name = 2;
300
301 enum State {
302 OFF = 0;
303 ON = 1;
304 }
305 optional State state = 3;
306}
307
308/**
309 * Logs when a job scheduler job state changes.
310 *
311 * Logged from:
312 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
313 */
314message ScheduledJobStateChanged {
315 // TODO: Add attribution instead of uid.
316 optional int32 uid = 1;
317
318 // Name of the job (as named in the app)
319 optional string name = 2;
320
321 enum State {
322 OFF = 0;
323 ON = 1;
324 }
325 optional State state = 3;
326
327 // TODO: Consider adding the stopReason (int)
328}
329
330/**
331 * Logs when the audio state changes.
332 *
333 * Logged from:
334 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
335 */
336message AudioStateChanged {
337 // TODO: Add attribution instead of uid.
338 optional int32 uid = 1;
339
340 enum State {
341 OFF = 0;
342 ON = 1;
343 }
344 optional State state = 2;
345}
346
347/**
348 * Logs when the video codec state changes.
349 *
350 * Logged from:
351 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
352 */
353message MediaCodecActivityChanged {
354 // TODO: Add attribution instead of uid.
355 optional int32 uid = 1;
356
357 enum State {
358 OFF = 0;
359 ON = 1;
360 }
361 optional State state = 2;
362}
363
364/**
365 * Logs when the flashlight state changes.
366 *
367 * Logged from:
368 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
369 */
370message FlashlightStateChanged {
371 // TODO: Add attribution instead of uid.
372 optional int32 uid = 1;
373
374 enum State {
375 OFF = 0;
376 ON = 1;
377 }
378 optional State state = 2;
379}
380
381/**
382 * Logs when the camera state changes.
383 *
384 * Logged from:
385 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
386 */
387message CameraStateChanged {
388 // TODO: Add attribution instead of uid.
389 optional int32 uid = 1;
390
391 enum State {
392 OFF = 0;
393 ON = 1;
394 }
395 optional State state = 2;
396}
397
398/**
399 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000400 *
401 * Logged from:
402 * TODO
403 */
Bookatzd6746242017-10-24 18:39:35 -0700404message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000405 // TODO: Add attribution instead of uid.
406 optional int32 uid = 1;
407
Bookatzc1a050a2017-10-10 15:49:28 -0700408 // Type of wakelock.
409 enum Type {
410 PARTIAL = 0;
411 FULL = 1;
412 WINDOW = 2;
413 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800414 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700415
416 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
417 optional string tag = 3;
418
419 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800420 RELEASE = 0;
421 ACQUIRE = 1;
422 CHANGE_RELEASE = 2;
423 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700424 }
425 optional State state = 4;
426}
427
428/**
Bookatzc1a050a2017-10-10 15:49:28 -0700429 * Logs when a partial wakelock is considered 'long' (over 1 min).
430 *
431 * Logged from:
432 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
433 */
434message LongPartialWakelockStateChanged {
435 // TODO: Add attribution instead of uid?
436 optional int32 uid = 1;
437
Yao Chend54f9dd2017-10-17 17:37:48 +0000438 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
439 optional string tag = 2;
440
Bookatzc1a050a2017-10-10 15:49:28 -0700441 // TODO: I have no idea what this is.
442 optional string history_tag = 3;
443
444 enum State {
445 OFF = 0;
446 ON = 1;
447 }
448 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000449}
450
Bookatzc1a050a2017-10-10 15:49:28 -0700451/**
452 * Logs Battery Saver state change.
453 *
454 * Logged from:
455 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
456 */
457message BatterySaverModeStateChanged {
458 enum State {
459 OFF = 0;
460 ON = 1;
461 }
462 optional State state = 1;
463}
464
465/**
466 * Logs Doze mode state change.
467 *
468 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800469 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700470 */
471message DeviceIdleModeStateChanged {
472 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800473 enum State {
474 DEVICE_IDLE_MODE_OFF = 0;
475 DEVICE_IDLE_MODE_LIGHT = 1;
476 DEVICE_IDLE_MODE_DEEP = 2;
477 }
478 optional State state = 1;
479}
480
481
482/**
483 * Logs state change of Doze mode including maintenance windows.
484 *
485 * Logged from:
486 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
487 */
488message DeviceIdlingModeStateChanged {
489 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
490 enum State {
491 DEVICE_IDLE_MODE_OFF = 0;
492 DEVICE_IDLE_MODE_LIGHT = 1;
493 DEVICE_IDLE_MODE_DEEP = 2;
494 }
495 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700496}
497
498/**
499 * Logs screen brightness level.
500 *
501 * Logged from:
502 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
503 */
504message ScreenBrightnessChanged {
505 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
506 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700507}
508
509/**
510 * Logs battery level (percent full, from 0 to 100).
511 *
512 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700513 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700514 */
515message BatteryLevelChanged {
516 // Battery level. Should be in [0, 100].
517 optional int32 battery_level = 1;
518}
519
520/**
521 * Logs change in charging status of the device.
522 *
523 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700524 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700525 */
526message ChargingStateChanged {
527 // TODO: Link directly to BatteryManager.java's constants (via a proto).
528 enum State {
529 BATTERY_STATUS_UNKNOWN = 1;
530 BATTERY_STATUS_CHARGING = 2;
531 BATTERY_STATUS_DISCHARGING = 3;
532 BATTERY_STATUS_NOT_CHARGING = 4;
533 BATTERY_STATUS_FULL = 5;
534 }
535 optional State charging_state = 1;
536}
537
538/**
539 * Logs whether the device is plugged in, and what power source it is using.
540 *
541 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700542 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700543 */
544message PluggedStateChanged {
545 // TODO: Link directly to BatteryManager.java's constants (via a proto).
546 enum State {
547 // Note that NONE is not in BatteryManager.java's constants.
548 BATTERY_PLUGGED_NONE = 0;
549 // Power source is an AC charger.
550 BATTERY_PLUGGED_AC = 1;
551 // Power source is a USB port.
552 BATTERY_PLUGGED_USB = 2;
553 // Power source is wireless.
554 BATTERY_PLUGGED_WIRELESS = 4;
555 }
556 optional State plugged_state = 1;
557}
558
559/**
560 * Logs the temperature of the device, in tenths of a degree Celsius.
561 *
562 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700563 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700564 */
565message DeviceTemperatureReported {
566 // Temperature in tenths of a degree C.
567 optional int32 temperature = 1;
568}
569
570// TODO: Define this more precisely.
571// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
572/**
573 * Logs when the device turns off or on.
574 *
575 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700576 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700577 */
578message DeviceOnStatusChanged {
579 enum State {
580 OFF = 0;
581 ON = 1;
582 }
583 optional State state = 1;
584}
585
586/**
587 * Logs when an app's wakeup alarm fires.
588 *
589 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700590 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700591 */
592message WakeupAlarmOccurred {
593 // TODO: Add attribution instead of uid?
594 optional int32 uid = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800595
596 // Name of the wakeup alarm.
597 optional string tag = 2;
598}
599
600/**
601 * Logs when an an app causes the mobile radio to change state.
602 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
603 *
604 * Logged from:
605 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
606 */
607message MobileRadioPowerStateChanged {
608 // TODO: Add attribution instead of uid?
609 optional int32 uid = 1;
610
611 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
612 enum PowerState {
613 DC_POWER_STATE_LOW = 1;
614 DC_POWER_STATE_MEDIUM = 2;
615 DC_POWER_STATE_HIGH = 3;
616 }
617 optional PowerState power_state = 2;
618}
619
620/**
621 * Logs when an an app causes the wifi radio to change state.
622 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
623 *
624 * Logged from:
625 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
626 */
627message WifiRadioPowerStateChanged {
628 // TODO: Add attribution instead of uid?
629 optional int32 uid = 1;
630
631 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
632 enum PowerState {
633 DC_POWER_STATE_LOW = 1;
634 DC_POWER_STATE_MEDIUM = 2;
635 DC_POWER_STATE_HIGH = 3;
636 }
637 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700638}
639
640/**
641 * Logs kernel wakeup reasons and aborts.
642 *
643 * Logged from:
644 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
645 */
646message KernelWakeupReported {
647 // Name of the kernel wakeup reason (or abort).
648 optional string wakeup_reason_name = 1;
649
650 // Duration (in microseconds) for the wake-up interrupt to be serviced.
651 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700652}
653
654/**
655 * Logs wifi locks held by an app.
656 *
657 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700658 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700659 */
660message WifiLockStateChanged {
661 // TODO: Add attribution instead of uid.
662 optional int32 uid = 1;
663
664 enum State {
665 OFF = 0;
666 ON = 1;
667 }
668 optional State state = 2;
669}
670
671/**
672 * Logs wifi signal strength changes.
673 *
674 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700675 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700676 */
677message WifiSignalStrengthChanged {
678 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
679 enum SignalStrength {
680 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
681 SIGNAL_STRENGTH_POOR = 1;
682 SIGNAL_STRENGTH_MODERATE = 2;
683 SIGNAL_STRENGTH_GOOD = 3;
684 SIGNAL_STRENGTH_GREAT = 4;
685 }
686 optional SignalStrength signal_strength = 1;
687}
688
689/**
690 * Logs wifi scans performed by an app.
691 *
692 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700693 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700694 */
695message WifiScanStateChanged {
696 // TODO: Add attribution instead of uid.
697 optional int32 uid = 1;
698
699 enum State {
700 OFF = 0;
701 ON = 1;
702 }
703 optional State state = 2;
704}
705
706/**
707 * Logs phone signal strength changes.
708 *
709 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700710 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700711 */
712message PhoneSignalStrengthChanged {
713 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
714 enum SignalStrength {
715 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
716 SIGNAL_STRENGTH_POOR = 1;
717 SIGNAL_STRENGTH_MODERATE = 2;
718 SIGNAL_STRENGTH_GOOD = 3;
719 SIGNAL_STRENGTH_GREAT = 4;
720 }
721 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700722}
723
724/**
725 * Logs that a setting was updated.
726 * Logged from:
727 * frameworks/base/core/java/android/provider/Settings.java
728 * The tag and is_default allow resetting of settings to default values based on the specified
729 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
730 */
731message SettingChanged {
732 // The name of the setting.
733 optional string setting = 1;
734
735 // The change being imposed on this setting. May represent a number, eg "3".
736 optional string value = 2;
737
738 // The new value of this setting. For most settings, this is same as value. For some settings,
739 // value is +X or -X where X represents an element in a set. For example, if the previous value
740 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
741 // The +/- feature is currently only used for location_providers_allowed.
742 optional string new_value = 3;
743
744 // The previous value of this setting.
745 optional string prev_value = 4;
746
747 // The tag used with the is_default for resetting sets of settings. This is generally null.
748 optional string tag = 5;
749
750 // 1 indicates that this setting with tag should be resettable.
751 optional int32 is_default = 6;
752
753 // The user ID associated. Defined in android/os/UserHandle.java
754 optional int32 user = 7;
755}
Chenjie Yub3dda412017-10-24 13:41:59 -0700756
Chenjie Yu05013b32017-11-21 10:21:41 -0800757/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700758 * Logs activity going to foreground or background
759 *
760 * Logged from:
761 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
762 */
763message ActivityForegroundStateChanged {
764 enum Activity {
765 MOVE_TO_BACKGROUND = 0;
766 MOVE_TO_FOREGROUND = 1;
767 }
768 optional int32 uid = 1;
769 optional string pkg_name = 2;
770 optional string class_name = 3;
771 optional Activity activity = 4;
772}
David Chenc8a43242017-10-17 16:23:28 -0700773
774/**
David Chen9e3808c2017-11-20 17:25:34 -0800775 * Logs when an error is written to dropbox.
776 * Logged from:
777 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
778 */
779message DropboxErrorChanged {
780 // The uid if available. -1 means not available.
781 optional int32 uid = 1;
782
783 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
784 optional string tag = 2;
785
786 // The name of the process.
787 optional string process_name = 3;
788
789 // The pid if available. -1 means not available.
790 optional int32 pid = 4;
791
792 // 1 indicates is instant app. -1 indicates Not applicable.
793 optional int32 is_instant_app = 5;
794
795 // The activity name if available.
796 optional string activity_name = 6;
797
798 // 1 indicates in foreground. -1 indicates not available.
799 optional int32 is_foreground = 7;
800}
801
802/**
David Chenc8a43242017-10-17 16:23:28 -0700803 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
804 *
805 * Pulled from:
806 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
807 */
808message WifiBytesTransferred {
809 optional int32 uid = 1;
810
811 optional int64 rx_bytes = 2;
812
813 optional int64 rx_packets = 3;
814
815 optional int64 tx_bytes = 4;
816
817 optional int64 tx_packets = 5;
818}
819
820/**
821 * Pulls bytes transferred via wifi (separated by foreground and background usage).
822 *
823 * Pulled from:
824 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
825 */
826message WifiBytesTransferredByFgBg {
827 optional int32 uid = 1;
828
829 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
830 optional int32 is_foreground = 2;
831
832 optional int64 rx_bytes = 3;
833
834 optional int64 rx_packets = 4;
835
836 optional int64 tx_bytes = 5;
837
838 optional int64 tx_packets = 6;
839}
840
841/**
842 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
843 *
844 * Pulled from:
845 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
846 */
847message MobileBytesTransferred {
848 optional int32 uid = 1;
849
850 optional int64 rx_bytes = 2;
851
852 optional int64 rx_packets = 3;
853
854 optional int64 tx_bytes = 4;
855
856 optional int64 tx_packets = 5;
857}
858
859/**
860 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
861 *
862 * Pulled from:
863 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
864 */
865message MobileBytesTransferredByFgBg {
866 optional int32 uid = 1;
867
868 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
869 optional int32 is_foreground = 2;
870
871 optional int64 rx_bytes = 3;
872
873 optional int64 rx_packets = 4;
874
875 optional int64 tx_bytes = 5;
876
877 optional int64 tx_packets = 6;
878}
879
880/**
881 * Pulls the kernel wakelock durations. This atom is adapted from
882 * android/internal/os/KernelWakelockStats.java
883 *
884 * Pulled from:
885 * StatsCompanionService using KernelWakelockReader.
886 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700887message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700888 optional string name = 1;
889
890 optional int32 count = 2;
891
892 optional int32 version = 3;
893
894 optional int64 time = 4;
895}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700896
Chenjie Yu05013b32017-11-21 10:21:41 -0800897/**
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700898 * Pulls PowerStatePlatformSleepState.
899 *
900 * Definition here:
901 * hardware/interfaces/power/1.0/types.hal
902 */
903message PowerStatePlatformSleepStatePulled {
904 optional string name = 1;
905 optional uint64 residency_in_msec_since_boot = 2;
906 optional uint64 total_transitions = 3;
907 optional bool supported_only_in_suspend = 4;
908}
909
910/**
911 * Pulls PowerStateVoter.
912 *
913 * Definition here:
914 * hardware/interfaces/power/1.0/types.hal
915 */
916message PowerStateVoterPulled {
917 optional string power_state_platform_sleep_state_name = 1;
918 optional string power_state_voter_name = 2;
919 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
920 optional uint64 total_number_of_times_voted_since_boot = 4;
921}
922
923/**
924 * Pulls PowerStateSubsystemSleepState.
925 *
926 * Definition here:
927 * hardware/interfaces/power/1.1/types.hal
928 */
929message PowerStateSubsystemSleepStatePulled {
930 optional string power_state_subsystem_name = 1;
931 optional string power_state_subsystem_sleep_state_name = 2;
932 optional uint64 residency_in_msec_since_boot = 3;
933 optional uint64 total_transitions = 4;
934 optional uint64 last_entry_timestamp_ms = 5;
935 optional bool supported_only_in_suspend = 6;
936}
David Chen21582962017-11-01 17:32:46 -0700937
938/**
939 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
940 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
941 * attributed back to the parent (host) uid. One example is Chrome.
942 *
943 * Logged from:
944 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
945 */
946message IsolatedUidChanged {
947 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
948 optional int32 parent_uid = 1;
949
950 optional int32 isolated_uid = 2;
951
952 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
953 // be removed before if it's used for another parent uid.
954 optional int32 is_create = 3;
955}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700956
Chenjie Yu05013b32017-11-21 10:21:41 -0800957/**
Chenjie Yu7f8def92017-11-03 09:33:15 -0700958 * Pulls Cpu time per frequency.
959 * Note: this should be pulled for gauge metric only, without condition.
960 * The puller keeps internal state of last values. It should not be pulled by
961 * different metrics.
962 * The pulled data is delta of cpu time from last pull, calculated as
963 * following:
964 * if current time is larger than last value, take delta between the two.
965 * if current time is smaller than last value, there must be a cpu
966 * hotplug event, and the current time is taken as delta.
967 */
968message CpuTimePerFreqPulled {
969 optional uint32 cluster = 1;
970 optional uint32 freq_index = 2;
971 optional uint64 time = 3;
972}
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800973
Chenjie Yu05013b32017-11-21 10:21:41 -0800974/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800975 * Pulls Cpu Time Per Uid.
976 * Note that isolated process uid time should be attributed to host uids.
977 */
978message CpuTimePerUidPulled {
979 optional uint64 uid = 1;
980 optional uint64 user_time_ms = 2;
981 optional uint64 sys_time_ms = 3;
982}
983
984/**
985 * Pulls Cpu Time Per Uid per frequency.
986 * Note that isolated process uid time should be attributed to host uids.
987 * For each uid, we order the time by descending frequencies.
988 */
989message CpuTimePerUidFreqPulled {
990 optional uint64 uid = 1;
991 optional uint64 freq_idx = 2;
992 optional uint64 time_ms = 3;
993}
Hugo Benichi884970e2017-11-14 22:42:46 +0900994
995/*
996 * Logs the reception of an incoming network packet causing the main system to wake up for
997 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
998 * and processed by WakeupController.cpp.
999 */
1000message PacketWakeupOccurred {
1001 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1002 // delivered nowhere.
1003 optional int32 uid = 1;
1004 // The interface name on which the packet was received.
1005 optional string iface = 2;
1006 // The ethertype value of the packet.
1007 optional int32 ethertype = 3;
1008 // String representation of the destination MAC address of the packet.
1009 optional string destination_hardware_address = 4;
1010 // String representation of the source address of the packet if this was an IP packet.
1011 optional string source_ip = 5;
1012 // String representation of the destination address of the packet if this was an IP packet.
1013 optional string destination_ip = 6;
1014 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1015 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1016 // families.
1017 optional int32 ip_next_header = 7;
1018 // The source port if this was a TCP or UDP packet.
1019 optional int32 source_port = 8;
1020 // The destination port if this was a TCP or UDP packet.
1021 optional int32 destination_port = 9;
1022}
Chenjie Yu05013b32017-11-21 10:21:41 -08001023
1024/**
1025 * Pulls Wifi Controller Activity Energy Info
1026 */
1027message WifiActivityEnergyInfoPulled {
1028 // timestamp(wall clock) of record creation
1029 optional uint64 timestamp_ms = 1;
1030 // stack reported state
1031 // TODO: replace this with proto enum
1032 optional int32 stack_state = 2;
1033 // tx time in ms
1034 optional uint64 controller_tx_time_ms = 3;
1035 // rx time in ms
1036 optional uint64 controller_rx_time_ms = 4;
1037 // idle time in ms
1038 optional uint64 controller_idle_time_ms = 5;
1039 // product of current(mA), voltage(V) and time(ms)
1040 optional uint64 controller_energy_used = 6;
1041}
1042
1043/**
1044 * Pulls Modem Activity Energy Info
1045 */
1046message ModemActivityInfoPulled {
1047 // timestamp(wall clock) of record creation
1048 optional uint64 timestamp_ms = 1;
1049 // sleep time in ms.
1050 optional uint64 sleep_time_ms = 2;
1051 // idle time in ms
1052 optional uint64 controller_idle_time_ms = 3;
1053 /**
1054 * Tx power index
1055 * index 0 = tx_power < 0dBm
1056 * index 1 = 0dBm < tx_power < 5dBm
1057 * index 2 = 5dBm < tx_power < 15dBm
1058 * index 3 = 15dBm < tx_power < 20dBm
1059 * index 4 = tx_power > 20dBm
1060 */
1061 // tx time in ms at power level 0
1062 optional uint64 controller_tx_time_pl0_ms = 4;
1063 // tx time in ms at power level 1
1064 optional uint64 controller_tx_time_pl1_ms = 5;
1065 // tx time in ms at power level 2
1066 optional uint64 controller_tx_time_pl2_ms = 6;
1067 // tx time in ms at power level 3
1068 optional uint64 controller_tx_time_pl3_ms = 7;
1069 // tx time in ms at power level 4
1070 optional uint64 controller_tx_time_pl4_ms = 8;
1071 // rx time in ms at power level 5
1072 optional uint64 controller_rx_time_ms = 9;
1073 // product of current(mA), voltage(V) and time(ms)
1074 optional uint64 energy_used = 10;
Yangster-maccfdf3a42017-12-06 13:42:38 -08001075}