blob: e0d9ce7d88029eadccd94c5f64b5a995469d52a9 [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;
Hugo Benichi884970e2017-11-14 22:42:46 +090076 PacketWakeupOccurred packet_wakeup_occurred = 44;
David Chen9e3808c2017-11-20 17:25:34 -080077 DropboxErrorChanged dropbox_error_changed = 45;
Bookatzc1a050a2017-10-10 15:49:28 -070078 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000079 }
David Chenc8a43242017-10-17 16:23:28 -070080
81 // Pulled events will start at field 1000.
82 oneof pulled {
83 WifiBytesTransferred wifi_bytes_transferred = 1000;
84 WifiBytesTransferredByFgBg wifi_bytes_transferred_by_fg_bg = 1001;
85 MobileBytesTransferred mobile_bytes_transferred = 1002;
86 MobileBytesTransferredByFgBg mobile_bytes_transferred_by_fg_bg = 1003;
Chenjie Yu5305e1d2017-10-31 13:49:36 -070087 KernelWakelockPulled kernel_wakelock_pulled = 1004;
88 PowerStatePlatformSleepStatePulled power_state_platform_sleep_state_pulled = 1005;
89 PowerStateVoterPulled power_state_voter_pulled = 1006;
90 PowerStateSubsystemSleepStatePulled power_state_subsystem_sleep_state_pulled = 1007;
Chenjie Yu7f8def92017-11-03 09:33:15 -070091 CpuTimePerFreqPulled cpu_time_per_freq_pulled = 1008;
Chenjie Yue33bc3b2017-11-06 17:56:44 -080092 CpuTimePerUidPulled cpu_time_per_uid_pulled = 1009;
93 CpuTimePerUidFreqPulled cpu_time_per_uid_freq_pulled = 1010;
Chenjie Yu05013b32017-11-21 10:21:41 -080094 WifiActivityEnergyInfoPulled wifi_activity_energy_info_pulled = 1011;
95 ModemActivityInfoPulled modem_activity_info_pulled = 1012;
David Chenc8a43242017-10-17 16:23:28 -070096 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070097}
98
Yao Chend54f9dd2017-10-17 17:37:48 +000099/**
100 * A WorkSource represents the chained attribution of applications that
101 * resulted in a particular bit of work being done.
102 */
103message WorkSource {
104 // TODO
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700105}
106
Yao Chend54f9dd2017-10-17 17:37:48 +0000107/*
108 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800109 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000110 *
111 * RULES:
112 * - The field ids for each atom must start at 1, and count upwards by 1.
113 * Skipping field ids is not allowed.
114 * - These form an API, so renaming, renumbering or removing fields is
115 * not allowed between android releases. (This is not currently enforced,
116 * but there will be a tool to enforce this restriction).
117 * - The types must be built-in protocol buffer types, namely, no sub-messages
118 * are allowed (yet). The bytes type is also not allowed.
119 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800120 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000121 * - If an atom represents work that can be attributed to an app, there can
122 * be exactly one WorkSource field. It must be field number 1.
123 * - A field that is a uid should be a string field, tagged with the [xxx]
124 * annotation. The generated code on android will be represented by UIDs,
125 * and those UIDs will be translated in xxx to those strings.
126 *
127 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700128 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000129 * - If there is a UID, it goes first. Think in an object-oriented fashion.
130 * *****************************************************************************
131 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700132
Yao Chend54f9dd2017-10-17 17:37:48 +0000133/**
134 * Logs when the screen state changes.
135 *
136 * Logged from:
137 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
138 */
139message ScreenStateChanged {
140 // TODO: Use the real screen state.
141 enum State {
142 STATE_UNKNOWN = 0;
143 STATE_OFF = 1;
144 STATE_ON = 2;
145 STATE_DOZE = 3;
146 STATE_DOZE_SUSPEND = 4;
147 STATE_VR = 5;
148 }
149 // New screen state.
150 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700151}
Yao Chend54f9dd2017-10-17 17:37:48 +0000152
153/**
Bookatzc1a050a2017-10-10 15:49:28 -0700154 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000155 *
156 * Logged from:
157 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
158 */
Bookatzc1a050a2017-10-10 15:49:28 -0700159message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000160 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
161
162 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700163 // TODO: Use the real (mapped) process states.
Yao Chend54f9dd2017-10-17 17:37:48 +0000164 optional int32 state = 2;
165}
166
167/**
Bookatzc1a050a2017-10-10 15:49:28 -0700168 * Logs that a process started, finished, crashed, or ANRed.
169 *
170 * Logged from:
171 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
172 */
173message ProcessLifeCycleStateChanged {
174 // TODO: Use the real (mapped) process states.
175 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
176
177 // TODO: What is this?
178 optional string name = 2;
179
180 // The state.
181 // TODO: Use an enum.
182 optional int32 event = 3;
183}
184
185
186
187/**
188 * Logs when the ble scan state changes.
189 *
190 * Logged from:
191 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
192 */
193message BleScanStateChanged {
194 // TODO: Add attribution instead of uid.
195 optional int32 uid = 1;
196
197 enum State {
198 OFF = 0;
199 ON = 1;
200 }
201 optional State state = 2;
202}
203
204/**
205 * Logs when an unoptimized ble scan state changes.
206 *
207 * Logged from:
208 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
209 */
210// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
211message BleUnoptimizedScanStateChanged {
212 // TODO: Add attribution instead of uid.
213 optional int32 uid = 1;
214
215 enum State {
216 OFF = 0;
217 ON = 1;
218 }
219 optional State state = 2;
220}
221
222/**
223 * Logs reporting of a ble scan finding results.
224 *
225 * Logged from:
226 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
227 */
228// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
229message BleScanResultReceived {
230 // TODO: Add attribution instead of uid.
231 optional int32 uid = 1;
232
233 // Number of ble scan results returned.
234 optional int32 num_of_results = 2;
235}
236
237/**
238 * Logs when a sensor state changes.
239 *
240 * Logged from:
241 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
242 */
243message SensorStateChanged {
244 // TODO: Add attribution instead of uid.
245 optional int32 uid = 1;
246
247 // TODO: Is there a way to get the actual name of the sensor?
248 // The id (int) of the sensor.
249 optional int32 sensor_id = 2;
250
251 enum State {
252 OFF = 0;
253 ON = 1;
254 }
255 optional State state = 3;
256}
257
258
259/**
260 * Logs when GPS state changes.
261 *
262 * Logged from:
263 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
264 */
265message GpsScanStateChanged {
266 // TODO: Add attribution instead of uid.
267 optional int32 uid = 1;
268
269 enum State {
270 OFF = 0;
271 ON = 1;
272 }
273 optional State state = 2;
274}
275
276
277/**
278 * Logs when a sync manager sync state changes.
279 *
280 * Logged from:
281 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
282 */
283message SyncStateChanged {
284 // TODO: Add attribution instead of uid.
285 optional int32 uid = 1;
286
287 // Name of the sync (as named in the app)
288 optional string name = 2;
289
290 enum State {
291 OFF = 0;
292 ON = 1;
293 }
294 optional State state = 3;
295}
296
297/**
298 * Logs when a job scheduler job state changes.
299 *
300 * Logged from:
301 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
302 */
303message ScheduledJobStateChanged {
304 // TODO: Add attribution instead of uid.
305 optional int32 uid = 1;
306
307 // Name of the job (as named in the app)
308 optional string name = 2;
309
310 enum State {
311 OFF = 0;
312 ON = 1;
313 }
314 optional State state = 3;
315
316 // TODO: Consider adding the stopReason (int)
317}
318
319/**
320 * Logs when the audio state changes.
321 *
322 * Logged from:
323 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
324 */
325message AudioStateChanged {
326 // TODO: Add attribution instead of uid.
327 optional int32 uid = 1;
328
329 enum State {
330 OFF = 0;
331 ON = 1;
332 }
333 optional State state = 2;
334}
335
336/**
337 * Logs when the video codec state changes.
338 *
339 * Logged from:
340 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
341 */
342message MediaCodecActivityChanged {
343 // TODO: Add attribution instead of uid.
344 optional int32 uid = 1;
345
346 enum State {
347 OFF = 0;
348 ON = 1;
349 }
350 optional State state = 2;
351}
352
353/**
354 * Logs when the flashlight state changes.
355 *
356 * Logged from:
357 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
358 */
359message FlashlightStateChanged {
360 // TODO: Add attribution instead of uid.
361 optional int32 uid = 1;
362
363 enum State {
364 OFF = 0;
365 ON = 1;
366 }
367 optional State state = 2;
368}
369
370/**
371 * Logs when the camera state changes.
372 *
373 * Logged from:
374 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
375 */
376message CameraStateChanged {
377 // TODO: Add attribution instead of uid.
378 optional int32 uid = 1;
379
380 enum State {
381 OFF = 0;
382 ON = 1;
383 }
384 optional State state = 2;
385}
386
387/**
388 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000389 *
390 * Logged from:
391 * TODO
392 */
Bookatzd6746242017-10-24 18:39:35 -0700393message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000394 // TODO: Add attribution instead of uid.
395 optional int32 uid = 1;
396
Bookatzc1a050a2017-10-10 15:49:28 -0700397 // Type of wakelock.
398 enum Type {
399 PARTIAL = 0;
400 FULL = 1;
401 WINDOW = 2;
402 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800403 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700404
405 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
406 optional string tag = 3;
407
408 enum State {
409 OFF = 0;
410 ON = 1;
411 }
412 optional State state = 4;
413}
414
415/**
416 * Logs when an app is holding a wakelock, regardless of the wakelock's name.
417 *
418 * Logged from:
419 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
420 */
421message UidWakelockStateChanged {
422 // TODO: Add attribution instead of uid.
423 optional int32 uid = 1;
424
425 // Type of wakelock.
426 enum Type {
427 PARTIAL = 0;
428 FULL = 1;
429 WINDOW = 2;
430 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800431 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700432
433 enum State {
434 OFF = 0;
435 ON = 1;
436 }
437 optional State state = 3;
438}
439
440/**
441 * Logs when a partial wakelock is considered 'long' (over 1 min).
442 *
443 * Logged from:
444 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
445 */
446message LongPartialWakelockStateChanged {
447 // TODO: Add attribution instead of uid?
448 optional int32 uid = 1;
449
Yao Chend54f9dd2017-10-17 17:37:48 +0000450 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
451 optional string tag = 2;
452
Bookatzc1a050a2017-10-10 15:49:28 -0700453 // TODO: I have no idea what this is.
454 optional string history_tag = 3;
455
456 enum State {
457 OFF = 0;
458 ON = 1;
459 }
460 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000461}
462
Bookatzc1a050a2017-10-10 15:49:28 -0700463/**
464 * Logs Battery Saver state change.
465 *
466 * Logged from:
467 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
468 */
469message BatterySaverModeStateChanged {
470 enum State {
471 OFF = 0;
472 ON = 1;
473 }
474 optional State state = 1;
475}
476
477/**
478 * Logs Doze mode state change.
479 *
480 * Logged from:
481 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
482 */
483message DeviceIdleModeStateChanged {
484 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
485 optional int32 state = 1;
486}
487
488/**
489 * Logs screen brightness level.
490 *
491 * Logged from:
492 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
493 */
494message ScreenBrightnessChanged {
495 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
496 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700497}
498
499/**
500 * Logs battery level (percent full, from 0 to 100).
501 *
502 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700503 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700504 */
505message BatteryLevelChanged {
506 // Battery level. Should be in [0, 100].
507 optional int32 battery_level = 1;
508}
509
510/**
511 * Logs change in charging status of the device.
512 *
513 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700514 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700515 */
516message ChargingStateChanged {
517 // TODO: Link directly to BatteryManager.java's constants (via a proto).
518 enum State {
519 BATTERY_STATUS_UNKNOWN = 1;
520 BATTERY_STATUS_CHARGING = 2;
521 BATTERY_STATUS_DISCHARGING = 3;
522 BATTERY_STATUS_NOT_CHARGING = 4;
523 BATTERY_STATUS_FULL = 5;
524 }
525 optional State charging_state = 1;
526}
527
528/**
529 * Logs whether the device is plugged in, and what power source it is using.
530 *
531 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700532 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700533 */
534message PluggedStateChanged {
535 // TODO: Link directly to BatteryManager.java's constants (via a proto).
536 enum State {
537 // Note that NONE is not in BatteryManager.java's constants.
538 BATTERY_PLUGGED_NONE = 0;
539 // Power source is an AC charger.
540 BATTERY_PLUGGED_AC = 1;
541 // Power source is a USB port.
542 BATTERY_PLUGGED_USB = 2;
543 // Power source is wireless.
544 BATTERY_PLUGGED_WIRELESS = 4;
545 }
546 optional State plugged_state = 1;
547}
548
549/**
550 * Logs the temperature of the device, in tenths of a degree Celsius.
551 *
552 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700553 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700554 */
555message DeviceTemperatureReported {
556 // Temperature in tenths of a degree C.
557 optional int32 temperature = 1;
558}
559
560// TODO: Define this more precisely.
561// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
562/**
563 * Logs when the device turns off or on.
564 *
565 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700566 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700567 */
568message DeviceOnStatusChanged {
569 enum State {
570 OFF = 0;
571 ON = 1;
572 }
573 optional State state = 1;
574}
575
576/**
577 * Logs when an app's wakeup alarm fires.
578 *
579 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700580 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700581 */
582message WakeupAlarmOccurred {
583 // TODO: Add attribution instead of uid?
584 optional int32 uid = 1;
585}
586
587/**
588 * Logs kernel wakeup reasons and aborts.
589 *
590 * Logged from:
591 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
592 */
593message KernelWakeupReported {
594 // Name of the kernel wakeup reason (or abort).
595 optional string wakeup_reason_name = 1;
596
597 // Duration (in microseconds) for the wake-up interrupt to be serviced.
598 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700599}
600
601/**
602 * Logs wifi locks held by an app.
603 *
604 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700605 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700606 */
607message WifiLockStateChanged {
608 // TODO: Add attribution instead of uid.
609 optional int32 uid = 1;
610
611 enum State {
612 OFF = 0;
613 ON = 1;
614 }
615 optional State state = 2;
616}
617
618/**
619 * Logs wifi signal strength changes.
620 *
621 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700622 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700623 */
624message WifiSignalStrengthChanged {
625 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
626 enum SignalStrength {
627 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
628 SIGNAL_STRENGTH_POOR = 1;
629 SIGNAL_STRENGTH_MODERATE = 2;
630 SIGNAL_STRENGTH_GOOD = 3;
631 SIGNAL_STRENGTH_GREAT = 4;
632 }
633 optional SignalStrength signal_strength = 1;
634}
635
636/**
637 * Logs wifi scans performed by an app.
638 *
639 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700640 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700641 */
642message WifiScanStateChanged {
643 // TODO: Add attribution instead of uid.
644 optional int32 uid = 1;
645
646 enum State {
647 OFF = 0;
648 ON = 1;
649 }
650 optional State state = 2;
651}
652
653/**
654 * Logs phone signal strength changes.
655 *
656 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700657 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700658 */
659message PhoneSignalStrengthChanged {
660 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
661 enum SignalStrength {
662 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
663 SIGNAL_STRENGTH_POOR = 1;
664 SIGNAL_STRENGTH_MODERATE = 2;
665 SIGNAL_STRENGTH_GOOD = 3;
666 SIGNAL_STRENGTH_GREAT = 4;
667 }
668 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700669}
670
671/**
672 * Logs that a setting was updated.
673 * Logged from:
674 * frameworks/base/core/java/android/provider/Settings.java
675 * The tag and is_default allow resetting of settings to default values based on the specified
676 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
677 */
678message SettingChanged {
679 // The name of the setting.
680 optional string setting = 1;
681
682 // The change being imposed on this setting. May represent a number, eg "3".
683 optional string value = 2;
684
685 // The new value of this setting. For most settings, this is same as value. For some settings,
686 // value is +X or -X where X represents an element in a set. For example, if the previous value
687 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
688 // The +/- feature is currently only used for location_providers_allowed.
689 optional string new_value = 3;
690
691 // The previous value of this setting.
692 optional string prev_value = 4;
693
694 // The tag used with the is_default for resetting sets of settings. This is generally null.
695 optional string tag = 5;
696
697 // 1 indicates that this setting with tag should be resettable.
698 optional int32 is_default = 6;
699
700 // The user ID associated. Defined in android/os/UserHandle.java
701 optional int32 user = 7;
702}
Chenjie Yub3dda412017-10-24 13:41:59 -0700703
Chenjie Yu05013b32017-11-21 10:21:41 -0800704/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700705 * Logs activity going to foreground or background
706 *
707 * Logged from:
708 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
709 */
710message ActivityForegroundStateChanged {
711 enum Activity {
712 MOVE_TO_BACKGROUND = 0;
713 MOVE_TO_FOREGROUND = 1;
714 }
715 optional int32 uid = 1;
716 optional string pkg_name = 2;
717 optional string class_name = 3;
718 optional Activity activity = 4;
719}
David Chenc8a43242017-10-17 16:23:28 -0700720
721/**
David Chen9e3808c2017-11-20 17:25:34 -0800722 * Logs when an error is written to dropbox.
723 * Logged from:
724 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
725 */
726message DropboxErrorChanged {
727 // The uid if available. -1 means not available.
728 optional int32 uid = 1;
729
730 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
731 optional string tag = 2;
732
733 // The name of the process.
734 optional string process_name = 3;
735
736 // The pid if available. -1 means not available.
737 optional int32 pid = 4;
738
739 // 1 indicates is instant app. -1 indicates Not applicable.
740 optional int32 is_instant_app = 5;
741
742 // The activity name if available.
743 optional string activity_name = 6;
744
745 // 1 indicates in foreground. -1 indicates not available.
746 optional int32 is_foreground = 7;
747}
748
749/**
David Chenc8a43242017-10-17 16:23:28 -0700750 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
751 *
752 * Pulled from:
753 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
754 */
755message WifiBytesTransferred {
756 optional int32 uid = 1;
757
758 optional int64 rx_bytes = 2;
759
760 optional int64 rx_packets = 3;
761
762 optional int64 tx_bytes = 4;
763
764 optional int64 tx_packets = 5;
765}
766
767/**
768 * Pulls bytes transferred via wifi (separated by foreground and background usage).
769 *
770 * Pulled from:
771 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
772 */
773message WifiBytesTransferredByFgBg {
774 optional int32 uid = 1;
775
776 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
777 optional int32 is_foreground = 2;
778
779 optional int64 rx_bytes = 3;
780
781 optional int64 rx_packets = 4;
782
783 optional int64 tx_bytes = 5;
784
785 optional int64 tx_packets = 6;
786}
787
788/**
789 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
790 *
791 * Pulled from:
792 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
793 */
794message MobileBytesTransferred {
795 optional int32 uid = 1;
796
797 optional int64 rx_bytes = 2;
798
799 optional int64 rx_packets = 3;
800
801 optional int64 tx_bytes = 4;
802
803 optional int64 tx_packets = 5;
804}
805
806/**
807 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
808 *
809 * Pulled from:
810 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
811 */
812message MobileBytesTransferredByFgBg {
813 optional int32 uid = 1;
814
815 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
816 optional int32 is_foreground = 2;
817
818 optional int64 rx_bytes = 3;
819
820 optional int64 rx_packets = 4;
821
822 optional int64 tx_bytes = 5;
823
824 optional int64 tx_packets = 6;
825}
826
827/**
828 * Pulls the kernel wakelock durations. This atom is adapted from
829 * android/internal/os/KernelWakelockStats.java
830 *
831 * Pulled from:
832 * StatsCompanionService using KernelWakelockReader.
833 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700834message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700835 optional string name = 1;
836
837 optional int32 count = 2;
838
839 optional int32 version = 3;
840
841 optional int64 time = 4;
842}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700843
Chenjie Yu05013b32017-11-21 10:21:41 -0800844/**
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700845 * Pulls PowerStatePlatformSleepState.
846 *
847 * Definition here:
848 * hardware/interfaces/power/1.0/types.hal
849 */
850message PowerStatePlatformSleepStatePulled {
851 optional string name = 1;
852 optional uint64 residency_in_msec_since_boot = 2;
853 optional uint64 total_transitions = 3;
854 optional bool supported_only_in_suspend = 4;
855}
856
857/**
858 * Pulls PowerStateVoter.
859 *
860 * Definition here:
861 * hardware/interfaces/power/1.0/types.hal
862 */
863message PowerStateVoterPulled {
864 optional string power_state_platform_sleep_state_name = 1;
865 optional string power_state_voter_name = 2;
866 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
867 optional uint64 total_number_of_times_voted_since_boot = 4;
868}
869
870/**
871 * Pulls PowerStateSubsystemSleepState.
872 *
873 * Definition here:
874 * hardware/interfaces/power/1.1/types.hal
875 */
876message PowerStateSubsystemSleepStatePulled {
877 optional string power_state_subsystem_name = 1;
878 optional string power_state_subsystem_sleep_state_name = 2;
879 optional uint64 residency_in_msec_since_boot = 3;
880 optional uint64 total_transitions = 4;
881 optional uint64 last_entry_timestamp_ms = 5;
882 optional bool supported_only_in_suspend = 6;
883}
David Chen21582962017-11-01 17:32:46 -0700884
885/**
886 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
887 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
888 * attributed back to the parent (host) uid. One example is Chrome.
889 *
890 * Logged from:
891 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
892 */
893message IsolatedUidChanged {
894 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
895 optional int32 parent_uid = 1;
896
897 optional int32 isolated_uid = 2;
898
899 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
900 // be removed before if it's used for another parent uid.
901 optional int32 is_create = 3;
902}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700903
Chenjie Yu05013b32017-11-21 10:21:41 -0800904/**
Chenjie Yu7f8def92017-11-03 09:33:15 -0700905 * Pulls Cpu time per frequency.
906 * Note: this should be pulled for gauge metric only, without condition.
907 * The puller keeps internal state of last values. It should not be pulled by
908 * different metrics.
909 * The pulled data is delta of cpu time from last pull, calculated as
910 * following:
911 * if current time is larger than last value, take delta between the two.
912 * if current time is smaller than last value, there must be a cpu
913 * hotplug event, and the current time is taken as delta.
914 */
915message CpuTimePerFreqPulled {
916 optional uint32 cluster = 1;
917 optional uint32 freq_index = 2;
918 optional uint64 time = 3;
919}
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800920
Chenjie Yu05013b32017-11-21 10:21:41 -0800921/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800922 * Pulls Cpu Time Per Uid.
923 * Note that isolated process uid time should be attributed to host uids.
924 */
925message CpuTimePerUidPulled {
926 optional uint64 uid = 1;
927 optional uint64 user_time_ms = 2;
928 optional uint64 sys_time_ms = 3;
929}
930
931/**
932 * Pulls Cpu Time Per Uid per frequency.
933 * Note that isolated process uid time should be attributed to host uids.
934 * For each uid, we order the time by descending frequencies.
935 */
936message CpuTimePerUidFreqPulled {
937 optional uint64 uid = 1;
938 optional uint64 freq_idx = 2;
939 optional uint64 time_ms = 3;
940}
Hugo Benichi884970e2017-11-14 22:42:46 +0900941
942/*
943 * Logs the reception of an incoming network packet causing the main system to wake up for
944 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
945 * and processed by WakeupController.cpp.
946 */
947message PacketWakeupOccurred {
948 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
949 // delivered nowhere.
950 optional int32 uid = 1;
951 // The interface name on which the packet was received.
952 optional string iface = 2;
953 // The ethertype value of the packet.
954 optional int32 ethertype = 3;
955 // String representation of the destination MAC address of the packet.
956 optional string destination_hardware_address = 4;
957 // String representation of the source address of the packet if this was an IP packet.
958 optional string source_ip = 5;
959 // String representation of the destination address of the packet if this was an IP packet.
960 optional string destination_ip = 6;
961 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
962 // field if this was an IPv6 packet. The range of possible values is the same for both IP
963 // families.
964 optional int32 ip_next_header = 7;
965 // The source port if this was a TCP or UDP packet.
966 optional int32 source_port = 8;
967 // The destination port if this was a TCP or UDP packet.
968 optional int32 destination_port = 9;
969}
Chenjie Yu05013b32017-11-21 10:21:41 -0800970
971/**
972 * Pulls Wifi Controller Activity Energy Info
973 */
974message WifiActivityEnergyInfoPulled {
975 // timestamp(wall clock) of record creation
976 optional uint64 timestamp_ms = 1;
977 // stack reported state
978 // TODO: replace this with proto enum
979 optional int32 stack_state = 2;
980 // tx time in ms
981 optional uint64 controller_tx_time_ms = 3;
982 // rx time in ms
983 optional uint64 controller_rx_time_ms = 4;
984 // idle time in ms
985 optional uint64 controller_idle_time_ms = 5;
986 // product of current(mA), voltage(V) and time(ms)
987 optional uint64 controller_energy_used = 6;
988}
989
990/**
991 * Pulls Modem Activity Energy Info
992 */
993message ModemActivityInfoPulled {
994 // timestamp(wall clock) of record creation
995 optional uint64 timestamp_ms = 1;
996 // sleep time in ms.
997 optional uint64 sleep_time_ms = 2;
998 // idle time in ms
999 optional uint64 controller_idle_time_ms = 3;
1000 /**
1001 * Tx power index
1002 * index 0 = tx_power < 0dBm
1003 * index 1 = 0dBm < tx_power < 5dBm
1004 * index 2 = 5dBm < tx_power < 15dBm
1005 * index 3 = 15dBm < tx_power < 20dBm
1006 * index 4 = tx_power > 20dBm
1007 */
1008 // tx time in ms at power level 0
1009 optional uint64 controller_tx_time_pl0_ms = 4;
1010 // tx time in ms at power level 1
1011 optional uint64 controller_tx_time_pl1_ms = 5;
1012 // tx time in ms at power level 2
1013 optional uint64 controller_tx_time_pl2_ms = 6;
1014 // tx time in ms at power level 3
1015 optional uint64 controller_tx_time_pl3_ms = 7;
1016 // tx time in ms at power level 4
1017 optional uint64 controller_tx_time_pl4_ms = 8;
1018 // rx time in ms at power level 5
1019 optional uint64 controller_rx_time_ms = 9;
1020 // product of current(mA), voltage(V) and time(ms)
1021 optional uint64 energy_used = 10;
1022}