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