blob: ba93febe8ad4fa280b660f2cd103c34751c5dc8d [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;
49 // 10-20 are temporarily reserved for wakelocks etc.
Bookatzd6746242017-10-24 18:39:35 -070050 WakelockStateChanged wakelock_state_changed = 10;
Bookatzc1a050a2017-10-10 15:49:28 -070051 UidWakelockStateChanged uid_wakelock_state_changed = 11;
52 LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 12;
53 BatterySaverModeStateChanged battery_saver_mode_state_changed = 21;
54 DeviceIdleModeStateChanged device_idle_mode_state_changed = 22;
55 AudioStateChanged audio_state_changed = 23;
56 MediaCodecActivityChanged media_codec_activity_changed = 24;
57 CameraStateChanged camera_state_changed = 25;
58 FlashlightStateChanged flashlight_state_changed = 26;
59 UidProcessStateChanged uid_process_state_changed = 27;
60 ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28;
61 ScreenStateChanged screen_state_changed = 29;
Bookatz8c6571b2017-10-24 15:04:41 -070062 BatteryLevelChanged battery_level_changed = 30;
63 ChargingStateChanged charging_state_changed = 31;
64 PluggedStateChanged plugged_state_changed = 32;
65 DeviceTemperatureReported device_temperature_reported = 33;
66 DeviceOnStatusChanged device_on_status_changed = 34;
67 WakeupAlarmOccurred wakeup_alarm_occurred = 35;
68 KernelWakeupReported kernel_wakeup_reported = 36;
Bookatze5885242017-10-24 20:10:31 -070069 WifiLockStateChanged wifi_lock_state_changed = 37;
70 WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
71 WifiScanStateChanged wifi_scan_state_changed = 39;
72 PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
David Chenc28b2bb2017-10-24 12:52:52 -070073 SettingChanged setting_changed = 41;
David Chenc8a43242017-10-17 16:23:28 -070074 ActivityForegroundStateChanged activity_foreground_state_changed = 42;
David Chen21582962017-11-01 17:32:46 -070075 IsolatedUidChanged isolated_uid_changed = 43;
Bookatzc1a050a2017-10-10 15:49:28 -070076 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000077 }
David Chenc8a43242017-10-17 16:23:28 -070078
79 // Pulled events will start at field 1000.
80 oneof pulled {
81 WifiBytesTransferred wifi_bytes_transferred = 1000;
82 WifiBytesTransferredByFgBg wifi_bytes_transferred_by_fg_bg = 1001;
83 MobileBytesTransferred mobile_bytes_transferred = 1002;
84 MobileBytesTransferredByFgBg mobile_bytes_transferred_by_fg_bg = 1003;
Chenjie Yu5305e1d2017-10-31 13:49:36 -070085 KernelWakelockPulled kernel_wakelock_pulled = 1004;
86 PowerStatePlatformSleepStatePulled power_state_platform_sleep_state_pulled = 1005;
87 PowerStateVoterPulled power_state_voter_pulled = 1006;
88 PowerStateSubsystemSleepStatePulled power_state_subsystem_sleep_state_pulled = 1007;
Chenjie Yu7f8def92017-11-03 09:33:15 -070089 CpuTimePerFreqPulled cpu_time_per_freq_pulled = 1008;
Chenjie Yue33bc3b2017-11-06 17:56:44 -080090 CpuTimePerUidPulled cpu_time_per_uid_pulled = 1009;
91 CpuTimePerUidFreqPulled cpu_time_per_uid_freq_pulled = 1010;
David Chenc8a43242017-10-17 16:23:28 -070092 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070093}
94
Yao Chend54f9dd2017-10-17 17:37:48 +000095/**
96 * A WorkSource represents the chained attribution of applications that
97 * resulted in a particular bit of work being done.
98 */
99message WorkSource {
100 // TODO
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700101}
102
Yao Chend54f9dd2017-10-17 17:37:48 +0000103/*
104 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800105 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000106 *
107 * RULES:
108 * - The field ids for each atom must start at 1, and count upwards by 1.
109 * Skipping field ids is not allowed.
110 * - These form an API, so renaming, renumbering or removing fields is
111 * not allowed between android releases. (This is not currently enforced,
112 * but there will be a tool to enforce this restriction).
113 * - The types must be built-in protocol buffer types, namely, no sub-messages
114 * are allowed (yet). The bytes type is also not allowed.
115 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800116 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000117 * - If an atom represents work that can be attributed to an app, there can
118 * be exactly one WorkSource field. It must be field number 1.
119 * - A field that is a uid should be a string field, tagged with the [xxx]
120 * annotation. The generated code on android will be represented by UIDs,
121 * and those UIDs will be translated in xxx to those strings.
122 *
123 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700124 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000125 * - If there is a UID, it goes first. Think in an object-oriented fashion.
126 * *****************************************************************************
127 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700128
Yao Chend54f9dd2017-10-17 17:37:48 +0000129/**
130 * Logs when the screen state changes.
131 *
132 * Logged from:
133 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
134 */
135message ScreenStateChanged {
136 // TODO: Use the real screen state.
137 enum State {
138 STATE_UNKNOWN = 0;
139 STATE_OFF = 1;
140 STATE_ON = 2;
141 STATE_DOZE = 3;
142 STATE_DOZE_SUSPEND = 4;
143 STATE_VR = 5;
144 }
145 // New screen state.
146 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700147}
Yao Chend54f9dd2017-10-17 17:37:48 +0000148
149/**
Bookatzc1a050a2017-10-10 15:49:28 -0700150 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000151 *
152 * Logged from:
153 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
154 */
Bookatzc1a050a2017-10-10 15:49:28 -0700155message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000156 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
157
158 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700159 // TODO: Use the real (mapped) process states.
Yao Chend54f9dd2017-10-17 17:37:48 +0000160 optional int32 state = 2;
161}
162
163/**
Bookatzc1a050a2017-10-10 15:49:28 -0700164 * Logs that a process started, finished, crashed, or ANRed.
165 *
166 * Logged from:
167 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
168 */
169message ProcessLifeCycleStateChanged {
170 // TODO: Use the real (mapped) process states.
171 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
172
173 // TODO: What is this?
174 optional string name = 2;
175
176 // The state.
177 // TODO: Use an enum.
178 optional int32 event = 3;
179}
180
181
182
183/**
184 * Logs when the ble scan state changes.
185 *
186 * Logged from:
187 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
188 */
189message BleScanStateChanged {
190 // TODO: Add attribution instead of uid.
191 optional int32 uid = 1;
192
193 enum State {
194 OFF = 0;
195 ON = 1;
196 }
197 optional State state = 2;
198}
199
200/**
201 * Logs when an unoptimized ble scan state changes.
202 *
203 * Logged from:
204 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
205 */
206// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
207message BleUnoptimizedScanStateChanged {
208 // TODO: Add attribution instead of uid.
209 optional int32 uid = 1;
210
211 enum State {
212 OFF = 0;
213 ON = 1;
214 }
215 optional State state = 2;
216}
217
218/**
219 * Logs reporting of a ble scan finding results.
220 *
221 * Logged from:
222 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
223 */
224// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
225message BleScanResultReceived {
226 // TODO: Add attribution instead of uid.
227 optional int32 uid = 1;
228
229 // Number of ble scan results returned.
230 optional int32 num_of_results = 2;
231}
232
233/**
234 * Logs when a sensor state changes.
235 *
236 * Logged from:
237 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
238 */
239message SensorStateChanged {
240 // TODO: Add attribution instead of uid.
241 optional int32 uid = 1;
242
243 // TODO: Is there a way to get the actual name of the sensor?
244 // The id (int) of the sensor.
245 optional int32 sensor_id = 2;
246
247 enum State {
248 OFF = 0;
249 ON = 1;
250 }
251 optional State state = 3;
252}
253
254
255/**
256 * Logs when GPS state changes.
257 *
258 * Logged from:
259 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
260 */
261message GpsScanStateChanged {
262 // TODO: Add attribution instead of uid.
263 optional int32 uid = 1;
264
265 enum State {
266 OFF = 0;
267 ON = 1;
268 }
269 optional State state = 2;
270}
271
272
273/**
274 * Logs when a sync manager sync state changes.
275 *
276 * Logged from:
277 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
278 */
279message SyncStateChanged {
280 // TODO: Add attribution instead of uid.
281 optional int32 uid = 1;
282
283 // Name of the sync (as named in the app)
284 optional string name = 2;
285
286 enum State {
287 OFF = 0;
288 ON = 1;
289 }
290 optional State state = 3;
291}
292
293/**
294 * Logs when a job scheduler job state changes.
295 *
296 * Logged from:
297 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
298 */
299message ScheduledJobStateChanged {
300 // TODO: Add attribution instead of uid.
301 optional int32 uid = 1;
302
303 // Name of the job (as named in the app)
304 optional string name = 2;
305
306 enum State {
307 OFF = 0;
308 ON = 1;
309 }
310 optional State state = 3;
311
312 // TODO: Consider adding the stopReason (int)
313}
314
315/**
316 * Logs when the audio state changes.
317 *
318 * Logged from:
319 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
320 */
321message AudioStateChanged {
322 // TODO: Add attribution instead of uid.
323 optional int32 uid = 1;
324
325 enum State {
326 OFF = 0;
327 ON = 1;
328 }
329 optional State state = 2;
330}
331
332/**
333 * Logs when the video codec state changes.
334 *
335 * Logged from:
336 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
337 */
338message MediaCodecActivityChanged {
339 // TODO: Add attribution instead of uid.
340 optional int32 uid = 1;
341
342 enum State {
343 OFF = 0;
344 ON = 1;
345 }
346 optional State state = 2;
347}
348
349/**
350 * Logs when the flashlight state changes.
351 *
352 * Logged from:
353 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
354 */
355message FlashlightStateChanged {
356 // TODO: Add attribution instead of uid.
357 optional int32 uid = 1;
358
359 enum State {
360 OFF = 0;
361 ON = 1;
362 }
363 optional State state = 2;
364}
365
366/**
367 * Logs when the camera state changes.
368 *
369 * Logged from:
370 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
371 */
372message CameraStateChanged {
373 // TODO: Add attribution instead of uid.
374 optional int32 uid = 1;
375
376 enum State {
377 OFF = 0;
378 ON = 1;
379 }
380 optional State state = 2;
381}
382
383/**
384 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000385 *
386 * Logged from:
387 * TODO
388 */
Bookatzd6746242017-10-24 18:39:35 -0700389message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000390 // TODO: Add attribution instead of uid.
391 optional int32 uid = 1;
392
Bookatzc1a050a2017-10-10 15:49:28 -0700393 // Type of wakelock.
394 enum Type {
395 PARTIAL = 0;
396 FULL = 1;
397 WINDOW = 2;
398 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800399 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700400
401 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
402 optional string tag = 3;
403
404 enum State {
405 OFF = 0;
406 ON = 1;
407 }
408 optional State state = 4;
409}
410
411/**
412 * Logs when an app is holding a wakelock, regardless of the wakelock's name.
413 *
414 * Logged from:
415 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
416 */
417message UidWakelockStateChanged {
418 // TODO: Add attribution instead of uid.
419 optional int32 uid = 1;
420
421 // Type of wakelock.
422 enum Type {
423 PARTIAL = 0;
424 FULL = 1;
425 WINDOW = 2;
426 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800427 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700428
429 enum State {
430 OFF = 0;
431 ON = 1;
432 }
433 optional State state = 3;
434}
435
436/**
437 * Logs when a partial wakelock is considered 'long' (over 1 min).
438 *
439 * Logged from:
440 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
441 */
442message LongPartialWakelockStateChanged {
443 // TODO: Add attribution instead of uid?
444 optional int32 uid = 1;
445
Yao Chend54f9dd2017-10-17 17:37:48 +0000446 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
447 optional string tag = 2;
448
Bookatzc1a050a2017-10-10 15:49:28 -0700449 // TODO: I have no idea what this is.
450 optional string history_tag = 3;
451
452 enum State {
453 OFF = 0;
454 ON = 1;
455 }
456 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000457}
458
Bookatzc1a050a2017-10-10 15:49:28 -0700459/**
460 * Logs Battery Saver state change.
461 *
462 * Logged from:
463 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
464 */
465message BatterySaverModeStateChanged {
466 enum State {
467 OFF = 0;
468 ON = 1;
469 }
470 optional State state = 1;
471}
472
473/**
474 * Logs Doze mode state change.
475 *
476 * Logged from:
477 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
478 */
479message DeviceIdleModeStateChanged {
480 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
481 optional int32 state = 1;
482}
483
484/**
485 * Logs screen brightness level.
486 *
487 * Logged from:
488 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
489 */
490message ScreenBrightnessChanged {
491 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
492 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700493}
494
495/**
496 * Logs battery level (percent full, from 0 to 100).
497 *
498 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700499 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700500 */
501message BatteryLevelChanged {
502 // Battery level. Should be in [0, 100].
503 optional int32 battery_level = 1;
504}
505
506/**
507 * Logs change in charging status of the device.
508 *
509 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700510 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700511 */
512message ChargingStateChanged {
513 // TODO: Link directly to BatteryManager.java's constants (via a proto).
514 enum State {
515 BATTERY_STATUS_UNKNOWN = 1;
516 BATTERY_STATUS_CHARGING = 2;
517 BATTERY_STATUS_DISCHARGING = 3;
518 BATTERY_STATUS_NOT_CHARGING = 4;
519 BATTERY_STATUS_FULL = 5;
520 }
521 optional State charging_state = 1;
522}
523
524/**
525 * Logs whether the device is plugged in, and what power source it is using.
526 *
527 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700528 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700529 */
530message PluggedStateChanged {
531 // TODO: Link directly to BatteryManager.java's constants (via a proto).
532 enum State {
533 // Note that NONE is not in BatteryManager.java's constants.
534 BATTERY_PLUGGED_NONE = 0;
535 // Power source is an AC charger.
536 BATTERY_PLUGGED_AC = 1;
537 // Power source is a USB port.
538 BATTERY_PLUGGED_USB = 2;
539 // Power source is wireless.
540 BATTERY_PLUGGED_WIRELESS = 4;
541 }
542 optional State plugged_state = 1;
543}
544
545/**
546 * Logs the temperature of the device, in tenths of a degree Celsius.
547 *
548 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700549 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700550 */
551message DeviceTemperatureReported {
552 // Temperature in tenths of a degree C.
553 optional int32 temperature = 1;
554}
555
556// TODO: Define this more precisely.
557// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
558/**
559 * Logs when the device turns off or on.
560 *
561 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700562 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700563 */
564message DeviceOnStatusChanged {
565 enum State {
566 OFF = 0;
567 ON = 1;
568 }
569 optional State state = 1;
570}
571
572/**
573 * Logs when an app's wakeup alarm fires.
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 WakeupAlarmOccurred {
579 // TODO: Add attribution instead of uid?
580 optional int32 uid = 1;
581}
582
583/**
584 * Logs kernel wakeup reasons and aborts.
585 *
586 * Logged from:
587 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
588 */
589message KernelWakeupReported {
590 // Name of the kernel wakeup reason (or abort).
591 optional string wakeup_reason_name = 1;
592
593 // Duration (in microseconds) for the wake-up interrupt to be serviced.
594 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700595}
596
597/**
598 * Logs wifi locks held by an app.
599 *
600 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700601 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700602 */
603message WifiLockStateChanged {
604 // TODO: Add attribution instead of uid.
605 optional int32 uid = 1;
606
607 enum State {
608 OFF = 0;
609 ON = 1;
610 }
611 optional State state = 2;
612}
613
614/**
615 * Logs wifi signal strength changes.
616 *
617 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700618 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700619 */
620message WifiSignalStrengthChanged {
621 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
622 enum SignalStrength {
623 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
624 SIGNAL_STRENGTH_POOR = 1;
625 SIGNAL_STRENGTH_MODERATE = 2;
626 SIGNAL_STRENGTH_GOOD = 3;
627 SIGNAL_STRENGTH_GREAT = 4;
628 }
629 optional SignalStrength signal_strength = 1;
630}
631
632/**
633 * Logs wifi scans performed by an app.
634 *
635 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700636 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700637 */
638message WifiScanStateChanged {
639 // TODO: Add attribution instead of uid.
640 optional int32 uid = 1;
641
642 enum State {
643 OFF = 0;
644 ON = 1;
645 }
646 optional State state = 2;
647}
648
649/**
650 * Logs phone signal strength changes.
651 *
652 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700653 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700654 */
655message PhoneSignalStrengthChanged {
656 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
657 enum SignalStrength {
658 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
659 SIGNAL_STRENGTH_POOR = 1;
660 SIGNAL_STRENGTH_MODERATE = 2;
661 SIGNAL_STRENGTH_GOOD = 3;
662 SIGNAL_STRENGTH_GREAT = 4;
663 }
664 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700665}
666
667/**
668 * Logs that a setting was updated.
669 * Logged from:
670 * frameworks/base/core/java/android/provider/Settings.java
671 * The tag and is_default allow resetting of settings to default values based on the specified
672 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
673 */
674message SettingChanged {
675 // The name of the setting.
676 optional string setting = 1;
677
678 // The change being imposed on this setting. May represent a number, eg "3".
679 optional string value = 2;
680
681 // The new value of this setting. For most settings, this is same as value. For some settings,
682 // value is +X or -X where X represents an element in a set. For example, if the previous value
683 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
684 // The +/- feature is currently only used for location_providers_allowed.
685 optional string new_value = 3;
686
687 // The previous value of this setting.
688 optional string prev_value = 4;
689
690 // The tag used with the is_default for resetting sets of settings. This is generally null.
691 optional string tag = 5;
692
693 // 1 indicates that this setting with tag should be resettable.
694 optional int32 is_default = 6;
695
696 // The user ID associated. Defined in android/os/UserHandle.java
697 optional int32 user = 7;
698}
Chenjie Yub3dda412017-10-24 13:41:59 -0700699
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700700/*
701 * Logs activity going to foreground or background
702 *
703 * Logged from:
704 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
705 */
706message ActivityForegroundStateChanged {
707 enum Activity {
708 MOVE_TO_BACKGROUND = 0;
709 MOVE_TO_FOREGROUND = 1;
710 }
711 optional int32 uid = 1;
712 optional string pkg_name = 2;
713 optional string class_name = 3;
714 optional Activity activity = 4;
715}
David Chenc8a43242017-10-17 16:23:28 -0700716
717/**
718 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
719 *
720 * Pulled from:
721 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
722 */
723message WifiBytesTransferred {
724 optional int32 uid = 1;
725
726 optional int64 rx_bytes = 2;
727
728 optional int64 rx_packets = 3;
729
730 optional int64 tx_bytes = 4;
731
732 optional int64 tx_packets = 5;
733}
734
735/**
736 * Pulls bytes transferred via wifi (separated by foreground and background usage).
737 *
738 * Pulled from:
739 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
740 */
741message WifiBytesTransferredByFgBg {
742 optional int32 uid = 1;
743
744 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
745 optional int32 is_foreground = 2;
746
747 optional int64 rx_bytes = 3;
748
749 optional int64 rx_packets = 4;
750
751 optional int64 tx_bytes = 5;
752
753 optional int64 tx_packets = 6;
754}
755
756/**
757 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
758 *
759 * Pulled from:
760 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
761 */
762message MobileBytesTransferred {
763 optional int32 uid = 1;
764
765 optional int64 rx_bytes = 2;
766
767 optional int64 rx_packets = 3;
768
769 optional int64 tx_bytes = 4;
770
771 optional int64 tx_packets = 5;
772}
773
774/**
775 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
776 *
777 * Pulled from:
778 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
779 */
780message MobileBytesTransferredByFgBg {
781 optional int32 uid = 1;
782
783 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
784 optional int32 is_foreground = 2;
785
786 optional int64 rx_bytes = 3;
787
788 optional int64 rx_packets = 4;
789
790 optional int64 tx_bytes = 5;
791
792 optional int64 tx_packets = 6;
793}
794
795/**
796 * Pulls the kernel wakelock durations. This atom is adapted from
797 * android/internal/os/KernelWakelockStats.java
798 *
799 * Pulled from:
800 * StatsCompanionService using KernelWakelockReader.
801 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700802message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700803 optional string name = 1;
804
805 optional int32 count = 2;
806
807 optional int32 version = 3;
808
809 optional int64 time = 4;
810}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700811
812/*
813 * Pulls PowerStatePlatformSleepState.
814 *
815 * Definition here:
816 * hardware/interfaces/power/1.0/types.hal
817 */
818message PowerStatePlatformSleepStatePulled {
819 optional string name = 1;
820 optional uint64 residency_in_msec_since_boot = 2;
821 optional uint64 total_transitions = 3;
822 optional bool supported_only_in_suspend = 4;
823}
824
825/**
826 * Pulls PowerStateVoter.
827 *
828 * Definition here:
829 * hardware/interfaces/power/1.0/types.hal
830 */
831message PowerStateVoterPulled {
832 optional string power_state_platform_sleep_state_name = 1;
833 optional string power_state_voter_name = 2;
834 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
835 optional uint64 total_number_of_times_voted_since_boot = 4;
836}
837
838/**
839 * Pulls PowerStateSubsystemSleepState.
840 *
841 * Definition here:
842 * hardware/interfaces/power/1.1/types.hal
843 */
844message PowerStateSubsystemSleepStatePulled {
845 optional string power_state_subsystem_name = 1;
846 optional string power_state_subsystem_sleep_state_name = 2;
847 optional uint64 residency_in_msec_since_boot = 3;
848 optional uint64 total_transitions = 4;
849 optional uint64 last_entry_timestamp_ms = 5;
850 optional bool supported_only_in_suspend = 6;
851}
David Chen21582962017-11-01 17:32:46 -0700852
853/**
854 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
855 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
856 * attributed back to the parent (host) uid. One example is Chrome.
857 *
858 * Logged from:
859 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
860 */
861message IsolatedUidChanged {
862 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
863 optional int32 parent_uid = 1;
864
865 optional int32 isolated_uid = 2;
866
867 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
868 // be removed before if it's used for another parent uid.
869 optional int32 is_create = 3;
870}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700871
872/*
873 * Pulls Cpu time per frequency.
874 * Note: this should be pulled for gauge metric only, without condition.
875 * The puller keeps internal state of last values. It should not be pulled by
876 * different metrics.
877 * The pulled data is delta of cpu time from last pull, calculated as
878 * following:
879 * if current time is larger than last value, take delta between the two.
880 * if current time is smaller than last value, there must be a cpu
881 * hotplug event, and the current time is taken as delta.
882 */
883message CpuTimePerFreqPulled {
884 optional uint32 cluster = 1;
885 optional uint32 freq_index = 2;
886 optional uint64 time = 3;
887}
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800888
889/*
890 * Pulls Cpu Time Per Uid.
891 * Note that isolated process uid time should be attributed to host uids.
892 */
893message CpuTimePerUidPulled {
894 optional uint64 uid = 1;
895 optional uint64 user_time_ms = 2;
896 optional uint64 sys_time_ms = 3;
897}
898
899/**
900 * Pulls Cpu Time Per Uid per frequency.
901 * Note that isolated process uid time should be attributed to host uids.
902 * For each uid, we order the time by descending frequencies.
903 */
904message CpuTimePerUidFreqPulled {
905 optional uint64 uid = 1;
906 optional uint64 freq_idx = 2;
907 optional uint64 time_ms = 3;
908}