blob: a516ca3a603a822326168b1c291da8036eca7d30 [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;
David Chenc8a43242017-10-17 16:23:28 -070090 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070091}
92
Yao Chend54f9dd2017-10-17 17:37:48 +000093/**
94 * A WorkSource represents the chained attribution of applications that
95 * resulted in a particular bit of work being done.
96 */
97message WorkSource {
98 // TODO
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070099}
100
Yao Chend54f9dd2017-10-17 17:37:48 +0000101/*
102 * *****************************************************************************
103 * Below are all of the individual atoms that are logged by Android via statsd
104 * and Westworld.
105 *
106 * RULES:
107 * - The field ids for each atom must start at 1, and count upwards by 1.
108 * Skipping field ids is not allowed.
109 * - These form an API, so renaming, renumbering or removing fields is
110 * not allowed between android releases. (This is not currently enforced,
111 * but there will be a tool to enforce this restriction).
112 * - The types must be built-in protocol buffer types, namely, no sub-messages
113 * are allowed (yet). The bytes type is also not allowed.
114 * - The CamelCase name of the message type should match the
115 * underscore_separated name as defined in StatsEvent.
116 * - If an atom represents work that can be attributed to an app, there can
117 * be exactly one WorkSource field. It must be field number 1.
118 * - A field that is a uid should be a string field, tagged with the [xxx]
119 * annotation. The generated code on android will be represented by UIDs,
120 * and those UIDs will be translated in xxx to those strings.
121 *
122 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700123 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000124 * - If there is a UID, it goes first. Think in an object-oriented fashion.
125 * *****************************************************************************
126 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700127
Yao Chend54f9dd2017-10-17 17:37:48 +0000128/**
129 * Logs when the screen state changes.
130 *
131 * Logged from:
132 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
133 */
134message ScreenStateChanged {
135 // TODO: Use the real screen state.
136 enum State {
137 STATE_UNKNOWN = 0;
138 STATE_OFF = 1;
139 STATE_ON = 2;
140 STATE_DOZE = 3;
141 STATE_DOZE_SUSPEND = 4;
142 STATE_VR = 5;
143 }
144 // New screen state.
145 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700146}
Yao Chend54f9dd2017-10-17 17:37:48 +0000147
148/**
Bookatzc1a050a2017-10-10 15:49:28 -0700149 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000150 *
151 * Logged from:
152 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
153 */
Bookatzc1a050a2017-10-10 15:49:28 -0700154message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000155 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
156
157 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700158 // TODO: Use the real (mapped) process states.
Yao Chend54f9dd2017-10-17 17:37:48 +0000159 optional int32 state = 2;
160}
161
162/**
Bookatzc1a050a2017-10-10 15:49:28 -0700163 * Logs that a process started, finished, crashed, or ANRed.
164 *
165 * Logged from:
166 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
167 */
168message ProcessLifeCycleStateChanged {
169 // TODO: Use the real (mapped) process states.
170 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
171
172 // TODO: What is this?
173 optional string name = 2;
174
175 // The state.
176 // TODO: Use an enum.
177 optional int32 event = 3;
178}
179
180
181
182/**
183 * Logs when the ble scan state changes.
184 *
185 * Logged from:
186 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
187 */
188message BleScanStateChanged {
189 // TODO: Add attribution instead of uid.
190 optional int32 uid = 1;
191
192 enum State {
193 OFF = 0;
194 ON = 1;
195 }
196 optional State state = 2;
197}
198
199/**
200 * Logs when an unoptimized ble scan state changes.
201 *
202 * Logged from:
203 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
204 */
205// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
206message BleUnoptimizedScanStateChanged {
207 // TODO: Add attribution instead of uid.
208 optional int32 uid = 1;
209
210 enum State {
211 OFF = 0;
212 ON = 1;
213 }
214 optional State state = 2;
215}
216
217/**
218 * Logs reporting of a ble scan finding results.
219 *
220 * Logged from:
221 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
222 */
223// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
224message BleScanResultReceived {
225 // TODO: Add attribution instead of uid.
226 optional int32 uid = 1;
227
228 // Number of ble scan results returned.
229 optional int32 num_of_results = 2;
230}
231
232/**
233 * Logs when a sensor state changes.
234 *
235 * Logged from:
236 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
237 */
238message SensorStateChanged {
239 // TODO: Add attribution instead of uid.
240 optional int32 uid = 1;
241
242 // TODO: Is there a way to get the actual name of the sensor?
243 // The id (int) of the sensor.
244 optional int32 sensor_id = 2;
245
246 enum State {
247 OFF = 0;
248 ON = 1;
249 }
250 optional State state = 3;
251}
252
253
254/**
255 * Logs when GPS state changes.
256 *
257 * Logged from:
258 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
259 */
260message GpsScanStateChanged {
261 // TODO: Add attribution instead of uid.
262 optional int32 uid = 1;
263
264 enum State {
265 OFF = 0;
266 ON = 1;
267 }
268 optional State state = 2;
269}
270
271
272/**
273 * Logs when a sync manager sync state changes.
274 *
275 * Logged from:
276 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
277 */
278message SyncStateChanged {
279 // TODO: Add attribution instead of uid.
280 optional int32 uid = 1;
281
282 // Name of the sync (as named in the app)
283 optional string name = 2;
284
285 enum State {
286 OFF = 0;
287 ON = 1;
288 }
289 optional State state = 3;
290}
291
292/**
293 * Logs when a job scheduler job state changes.
294 *
295 * Logged from:
296 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
297 */
298message ScheduledJobStateChanged {
299 // TODO: Add attribution instead of uid.
300 optional int32 uid = 1;
301
302 // Name of the job (as named in the app)
303 optional string name = 2;
304
305 enum State {
306 OFF = 0;
307 ON = 1;
308 }
309 optional State state = 3;
310
311 // TODO: Consider adding the stopReason (int)
312}
313
314/**
315 * Logs when the audio state changes.
316 *
317 * Logged from:
318 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
319 */
320message AudioStateChanged {
321 // TODO: Add attribution instead of uid.
322 optional int32 uid = 1;
323
324 enum State {
325 OFF = 0;
326 ON = 1;
327 }
328 optional State state = 2;
329}
330
331/**
332 * Logs when the video codec state changes.
333 *
334 * Logged from:
335 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
336 */
337message MediaCodecActivityChanged {
338 // TODO: Add attribution instead of uid.
339 optional int32 uid = 1;
340
341 enum State {
342 OFF = 0;
343 ON = 1;
344 }
345 optional State state = 2;
346}
347
348/**
349 * Logs when the flashlight state changes.
350 *
351 * Logged from:
352 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
353 */
354message FlashlightStateChanged {
355 // TODO: Add attribution instead of uid.
356 optional int32 uid = 1;
357
358 enum State {
359 OFF = 0;
360 ON = 1;
361 }
362 optional State state = 2;
363}
364
365/**
366 * Logs when the camera state changes.
367 *
368 * Logged from:
369 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
370 */
371message CameraStateChanged {
372 // TODO: Add attribution instead of uid.
373 optional int32 uid = 1;
374
375 enum State {
376 OFF = 0;
377 ON = 1;
378 }
379 optional State state = 2;
380}
381
382/**
383 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000384 *
385 * Logged from:
386 * TODO
387 */
Bookatzd6746242017-10-24 18:39:35 -0700388message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000389 // TODO: Add attribution instead of uid.
390 optional int32 uid = 1;
391
Bookatzc1a050a2017-10-10 15:49:28 -0700392 // Type of wakelock.
393 enum Type {
394 PARTIAL = 0;
395 FULL = 1;
396 WINDOW = 2;
397 }
398 optional int32 type = 2;
399
400 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
401 optional string tag = 3;
402
403 enum State {
404 OFF = 0;
405 ON = 1;
406 }
407 optional State state = 4;
408}
409
410/**
411 * Logs when an app is holding a wakelock, regardless of the wakelock's name.
412 *
413 * Logged from:
414 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
415 */
416message UidWakelockStateChanged {
417 // TODO: Add attribution instead of uid.
418 optional int32 uid = 1;
419
420 // Type of wakelock.
421 enum Type {
422 PARTIAL = 0;
423 FULL = 1;
424 WINDOW = 2;
425 }
426 optional int32 type = 2;
427
428 enum State {
429 OFF = 0;
430 ON = 1;
431 }
432 optional State state = 3;
433}
434
435/**
436 * Logs when a partial wakelock is considered 'long' (over 1 min).
437 *
438 * Logged from:
439 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
440 */
441message LongPartialWakelockStateChanged {
442 // TODO: Add attribution instead of uid?
443 optional int32 uid = 1;
444
Yao Chend54f9dd2017-10-17 17:37:48 +0000445 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
446 optional string tag = 2;
447
Bookatzc1a050a2017-10-10 15:49:28 -0700448 // TODO: I have no idea what this is.
449 optional string history_tag = 3;
450
451 enum State {
452 OFF = 0;
453 ON = 1;
454 }
455 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000456}
457
Bookatzc1a050a2017-10-10 15:49:28 -0700458/**
459 * Logs Battery Saver state change.
460 *
461 * Logged from:
462 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
463 */
464message BatterySaverModeStateChanged {
465 enum State {
466 OFF = 0;
467 ON = 1;
468 }
469 optional State state = 1;
470}
471
472/**
473 * Logs Doze mode state change.
474 *
475 * Logged from:
476 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
477 */
478message DeviceIdleModeStateChanged {
479 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
480 optional int32 state = 1;
481}
482
483/**
484 * Logs screen brightness level.
485 *
486 * Logged from:
487 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
488 */
489message ScreenBrightnessChanged {
490 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
491 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700492}
493
494/**
495 * Logs battery level (percent full, from 0 to 100).
496 *
497 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700498 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700499 */
500message BatteryLevelChanged {
501 // Battery level. Should be in [0, 100].
502 optional int32 battery_level = 1;
503}
504
505/**
506 * Logs change in charging status of the device.
507 *
508 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700509 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700510 */
511message ChargingStateChanged {
512 // TODO: Link directly to BatteryManager.java's constants (via a proto).
513 enum State {
514 BATTERY_STATUS_UNKNOWN = 1;
515 BATTERY_STATUS_CHARGING = 2;
516 BATTERY_STATUS_DISCHARGING = 3;
517 BATTERY_STATUS_NOT_CHARGING = 4;
518 BATTERY_STATUS_FULL = 5;
519 }
520 optional State charging_state = 1;
521}
522
523/**
524 * Logs whether the device is plugged in, and what power source it is using.
525 *
526 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700527 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700528 */
529message PluggedStateChanged {
530 // TODO: Link directly to BatteryManager.java's constants (via a proto).
531 enum State {
532 // Note that NONE is not in BatteryManager.java's constants.
533 BATTERY_PLUGGED_NONE = 0;
534 // Power source is an AC charger.
535 BATTERY_PLUGGED_AC = 1;
536 // Power source is a USB port.
537 BATTERY_PLUGGED_USB = 2;
538 // Power source is wireless.
539 BATTERY_PLUGGED_WIRELESS = 4;
540 }
541 optional State plugged_state = 1;
542}
543
544/**
545 * Logs the temperature of the device, in tenths of a degree Celsius.
546 *
547 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700548 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700549 */
550message DeviceTemperatureReported {
551 // Temperature in tenths of a degree C.
552 optional int32 temperature = 1;
553}
554
555// TODO: Define this more precisely.
556// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
557/**
558 * Logs when the device turns off or on.
559 *
560 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700561 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700562 */
563message DeviceOnStatusChanged {
564 enum State {
565 OFF = 0;
566 ON = 1;
567 }
568 optional State state = 1;
569}
570
571/**
572 * Logs when an app's wakeup alarm fires.
573 *
574 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700575 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700576 */
577message WakeupAlarmOccurred {
578 // TODO: Add attribution instead of uid?
579 optional int32 uid = 1;
580}
581
582/**
583 * Logs kernel wakeup reasons and aborts.
584 *
585 * Logged from:
586 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
587 */
588message KernelWakeupReported {
589 // Name of the kernel wakeup reason (or abort).
590 optional string wakeup_reason_name = 1;
591
592 // Duration (in microseconds) for the wake-up interrupt to be serviced.
593 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700594}
595
596/**
597 * Logs wifi locks held by an app.
598 *
599 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700600 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700601 */
602message WifiLockStateChanged {
603 // TODO: Add attribution instead of uid.
604 optional int32 uid = 1;
605
606 enum State {
607 OFF = 0;
608 ON = 1;
609 }
610 optional State state = 2;
611}
612
613/**
614 * Logs wifi signal strength changes.
615 *
616 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700617 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700618 */
619message WifiSignalStrengthChanged {
620 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
621 enum SignalStrength {
622 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
623 SIGNAL_STRENGTH_POOR = 1;
624 SIGNAL_STRENGTH_MODERATE = 2;
625 SIGNAL_STRENGTH_GOOD = 3;
626 SIGNAL_STRENGTH_GREAT = 4;
627 }
628 optional SignalStrength signal_strength = 1;
629}
630
631/**
632 * Logs wifi scans performed by an app.
633 *
634 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700635 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700636 */
637message WifiScanStateChanged {
638 // TODO: Add attribution instead of uid.
639 optional int32 uid = 1;
640
641 enum State {
642 OFF = 0;
643 ON = 1;
644 }
645 optional State state = 2;
646}
647
648/**
649 * Logs phone signal strength changes.
650 *
651 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700652 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700653 */
654message PhoneSignalStrengthChanged {
655 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
656 enum SignalStrength {
657 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
658 SIGNAL_STRENGTH_POOR = 1;
659 SIGNAL_STRENGTH_MODERATE = 2;
660 SIGNAL_STRENGTH_GOOD = 3;
661 SIGNAL_STRENGTH_GREAT = 4;
662 }
663 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700664}
665
666/**
667 * Logs that a setting was updated.
668 * Logged from:
669 * frameworks/base/core/java/android/provider/Settings.java
670 * The tag and is_default allow resetting of settings to default values based on the specified
671 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
672 */
673message SettingChanged {
674 // The name of the setting.
675 optional string setting = 1;
676
677 // The change being imposed on this setting. May represent a number, eg "3".
678 optional string value = 2;
679
680 // The new value of this setting. For most settings, this is same as value. For some settings,
681 // value is +X or -X where X represents an element in a set. For example, if the previous value
682 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
683 // The +/- feature is currently only used for location_providers_allowed.
684 optional string new_value = 3;
685
686 // The previous value of this setting.
687 optional string prev_value = 4;
688
689 // The tag used with the is_default for resetting sets of settings. This is generally null.
690 optional string tag = 5;
691
692 // 1 indicates that this setting with tag should be resettable.
693 optional int32 is_default = 6;
694
695 // The user ID associated. Defined in android/os/UserHandle.java
696 optional int32 user = 7;
697}
Chenjie Yub3dda412017-10-24 13:41:59 -0700698
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700699/*
700 * Logs activity going to foreground or background
701 *
702 * Logged from:
703 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
704 */
705message ActivityForegroundStateChanged {
706 enum Activity {
707 MOVE_TO_BACKGROUND = 0;
708 MOVE_TO_FOREGROUND = 1;
709 }
710 optional int32 uid = 1;
711 optional string pkg_name = 2;
712 optional string class_name = 3;
713 optional Activity activity = 4;
714}
David Chenc8a43242017-10-17 16:23:28 -0700715
716/**
717 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
718 *
719 * Pulled from:
720 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
721 */
722message WifiBytesTransferred {
723 optional int32 uid = 1;
724
725 optional int64 rx_bytes = 2;
726
727 optional int64 rx_packets = 3;
728
729 optional int64 tx_bytes = 4;
730
731 optional int64 tx_packets = 5;
732}
733
734/**
735 * Pulls bytes transferred via wifi (separated by foreground and background usage).
736 *
737 * Pulled from:
738 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
739 */
740message WifiBytesTransferredByFgBg {
741 optional int32 uid = 1;
742
743 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
744 optional int32 is_foreground = 2;
745
746 optional int64 rx_bytes = 3;
747
748 optional int64 rx_packets = 4;
749
750 optional int64 tx_bytes = 5;
751
752 optional int64 tx_packets = 6;
753}
754
755/**
756 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
757 *
758 * Pulled from:
759 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
760 */
761message MobileBytesTransferred {
762 optional int32 uid = 1;
763
764 optional int64 rx_bytes = 2;
765
766 optional int64 rx_packets = 3;
767
768 optional int64 tx_bytes = 4;
769
770 optional int64 tx_packets = 5;
771}
772
773/**
774 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
775 *
776 * Pulled from:
777 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
778 */
779message MobileBytesTransferredByFgBg {
780 optional int32 uid = 1;
781
782 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
783 optional int32 is_foreground = 2;
784
785 optional int64 rx_bytes = 3;
786
787 optional int64 rx_packets = 4;
788
789 optional int64 tx_bytes = 5;
790
791 optional int64 tx_packets = 6;
792}
793
794/**
795 * Pulls the kernel wakelock durations. This atom is adapted from
796 * android/internal/os/KernelWakelockStats.java
797 *
798 * Pulled from:
799 * StatsCompanionService using KernelWakelockReader.
800 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700801message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700802 optional string name = 1;
803
804 optional int32 count = 2;
805
806 optional int32 version = 3;
807
808 optional int64 time = 4;
809}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700810
811/*
812 * Pulls PowerStatePlatformSleepState.
813 *
814 * Definition here:
815 * hardware/interfaces/power/1.0/types.hal
816 */
817message PowerStatePlatformSleepStatePulled {
818 optional string name = 1;
819 optional uint64 residency_in_msec_since_boot = 2;
820 optional uint64 total_transitions = 3;
821 optional bool supported_only_in_suspend = 4;
822}
823
824/**
825 * Pulls PowerStateVoter.
826 *
827 * Definition here:
828 * hardware/interfaces/power/1.0/types.hal
829 */
830message PowerStateVoterPulled {
831 optional string power_state_platform_sleep_state_name = 1;
832 optional string power_state_voter_name = 2;
833 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
834 optional uint64 total_number_of_times_voted_since_boot = 4;
835}
836
837/**
838 * Pulls PowerStateSubsystemSleepState.
839 *
840 * Definition here:
841 * hardware/interfaces/power/1.1/types.hal
842 */
843message PowerStateSubsystemSleepStatePulled {
844 optional string power_state_subsystem_name = 1;
845 optional string power_state_subsystem_sleep_state_name = 2;
846 optional uint64 residency_in_msec_since_boot = 3;
847 optional uint64 total_transitions = 4;
848 optional uint64 last_entry_timestamp_ms = 5;
849 optional bool supported_only_in_suspend = 6;
850}
David Chen21582962017-11-01 17:32:46 -0700851
852/**
Chenjie Yu7f8def92017-11-03 09:33:15 -0700853<<<<<<< HEAD
David Chen21582962017-11-01 17:32:46 -0700854 * 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}