blob: 20e7c600938eb8c6c4f54bed84f160bd15fdee39 [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;
David Chenc8a43242017-10-17 16:23:28 -070094 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070095}
96
Yao Chend54f9dd2017-10-17 17:37:48 +000097/**
98 * A WorkSource represents the chained attribution of applications that
99 * resulted in a particular bit of work being done.
100 */
101message WorkSource {
102 // TODO
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700103}
104
Yao Chend54f9dd2017-10-17 17:37:48 +0000105/*
106 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800107 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000108 *
109 * RULES:
110 * - The field ids for each atom must start at 1, and count upwards by 1.
111 * Skipping field ids is not allowed.
112 * - These form an API, so renaming, renumbering or removing fields is
113 * not allowed between android releases. (This is not currently enforced,
114 * but there will be a tool to enforce this restriction).
115 * - The types must be built-in protocol buffer types, namely, no sub-messages
116 * are allowed (yet). The bytes type is also not allowed.
117 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800118 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000119 * - If an atom represents work that can be attributed to an app, there can
120 * be exactly one WorkSource field. It must be field number 1.
121 * - A field that is a uid should be a string field, tagged with the [xxx]
122 * annotation. The generated code on android will be represented by UIDs,
123 * and those UIDs will be translated in xxx to those strings.
124 *
125 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700126 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000127 * - If there is a UID, it goes first. Think in an object-oriented fashion.
128 * *****************************************************************************
129 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700130
Yao Chend54f9dd2017-10-17 17:37:48 +0000131/**
132 * Logs when the screen state changes.
133 *
134 * Logged from:
135 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
136 */
137message ScreenStateChanged {
138 // TODO: Use the real screen state.
139 enum State {
140 STATE_UNKNOWN = 0;
141 STATE_OFF = 1;
142 STATE_ON = 2;
143 STATE_DOZE = 3;
144 STATE_DOZE_SUSPEND = 4;
145 STATE_VR = 5;
146 }
147 // New screen state.
148 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700149}
Yao Chend54f9dd2017-10-17 17:37:48 +0000150
151/**
Bookatzc1a050a2017-10-10 15:49:28 -0700152 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000153 *
154 * Logged from:
155 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
156 */
Bookatzc1a050a2017-10-10 15:49:28 -0700157message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000158 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
159
160 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700161 // TODO: Use the real (mapped) process states.
Yao Chend54f9dd2017-10-17 17:37:48 +0000162 optional int32 state = 2;
163}
164
165/**
Bookatzc1a050a2017-10-10 15:49:28 -0700166 * Logs that a process started, finished, crashed, or ANRed.
167 *
168 * Logged from:
169 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
170 */
171message ProcessLifeCycleStateChanged {
172 // TODO: Use the real (mapped) process states.
173 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
174
175 // TODO: What is this?
176 optional string name = 2;
177
178 // The state.
179 // TODO: Use an enum.
180 optional int32 event = 3;
181}
182
183
184
185/**
186 * Logs when the ble scan state changes.
187 *
188 * Logged from:
189 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
190 */
191message BleScanStateChanged {
192 // TODO: Add attribution instead of uid.
193 optional int32 uid = 1;
194
195 enum State {
196 OFF = 0;
197 ON = 1;
198 }
199 optional State state = 2;
200}
201
202/**
203 * Logs when an unoptimized ble scan state changes.
204 *
205 * Logged from:
206 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
207 */
208// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
209message BleUnoptimizedScanStateChanged {
210 // TODO: Add attribution instead of uid.
211 optional int32 uid = 1;
212
213 enum State {
214 OFF = 0;
215 ON = 1;
216 }
217 optional State state = 2;
218}
219
220/**
221 * Logs reporting of a ble scan finding results.
222 *
223 * Logged from:
224 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
225 */
226// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
227message BleScanResultReceived {
228 // TODO: Add attribution instead of uid.
229 optional int32 uid = 1;
230
231 // Number of ble scan results returned.
232 optional int32 num_of_results = 2;
233}
234
235/**
236 * Logs when a sensor state changes.
237 *
238 * Logged from:
239 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
240 */
241message SensorStateChanged {
242 // TODO: Add attribution instead of uid.
243 optional int32 uid = 1;
244
245 // TODO: Is there a way to get the actual name of the sensor?
246 // The id (int) of the sensor.
247 optional int32 sensor_id = 2;
248
249 enum State {
250 OFF = 0;
251 ON = 1;
252 }
253 optional State state = 3;
254}
255
256
257/**
258 * Logs when GPS state changes.
259 *
260 * Logged from:
261 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
262 */
263message GpsScanStateChanged {
264 // TODO: Add attribution instead of uid.
265 optional int32 uid = 1;
266
267 enum State {
268 OFF = 0;
269 ON = 1;
270 }
271 optional State state = 2;
272}
273
274
275/**
276 * Logs when a sync manager sync state changes.
277 *
278 * Logged from:
279 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
280 */
281message SyncStateChanged {
282 // TODO: Add attribution instead of uid.
283 optional int32 uid = 1;
284
285 // Name of the sync (as named in the app)
286 optional string name = 2;
287
288 enum State {
289 OFF = 0;
290 ON = 1;
291 }
292 optional State state = 3;
293}
294
295/**
296 * Logs when a job scheduler job state changes.
297 *
298 * Logged from:
299 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
300 */
301message ScheduledJobStateChanged {
302 // TODO: Add attribution instead of uid.
303 optional int32 uid = 1;
304
305 // Name of the job (as named in the app)
306 optional string name = 2;
307
308 enum State {
309 OFF = 0;
310 ON = 1;
311 }
312 optional State state = 3;
313
314 // TODO: Consider adding the stopReason (int)
315}
316
317/**
318 * Logs when the audio state changes.
319 *
320 * Logged from:
321 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
322 */
323message AudioStateChanged {
324 // TODO: Add attribution instead of uid.
325 optional int32 uid = 1;
326
327 enum State {
328 OFF = 0;
329 ON = 1;
330 }
331 optional State state = 2;
332}
333
334/**
335 * Logs when the video codec state changes.
336 *
337 * Logged from:
338 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
339 */
340message MediaCodecActivityChanged {
341 // TODO: Add attribution instead of uid.
342 optional int32 uid = 1;
343
344 enum State {
345 OFF = 0;
346 ON = 1;
347 }
348 optional State state = 2;
349}
350
351/**
352 * Logs when the flashlight state changes.
353 *
354 * Logged from:
355 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
356 */
357message FlashlightStateChanged {
358 // TODO: Add attribution instead of uid.
359 optional int32 uid = 1;
360
361 enum State {
362 OFF = 0;
363 ON = 1;
364 }
365 optional State state = 2;
366}
367
368/**
369 * Logs when the camera state changes.
370 *
371 * Logged from:
372 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
373 */
374message CameraStateChanged {
375 // TODO: Add attribution instead of uid.
376 optional int32 uid = 1;
377
378 enum State {
379 OFF = 0;
380 ON = 1;
381 }
382 optional State state = 2;
383}
384
385/**
386 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000387 *
388 * Logged from:
389 * TODO
390 */
Bookatzd6746242017-10-24 18:39:35 -0700391message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000392 // TODO: Add attribution instead of uid.
393 optional int32 uid = 1;
394
Bookatzc1a050a2017-10-10 15:49:28 -0700395 // Type of wakelock.
396 enum Type {
397 PARTIAL = 0;
398 FULL = 1;
399 WINDOW = 2;
400 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800401 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700402
403 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
404 optional string tag = 3;
405
406 enum State {
407 OFF = 0;
408 ON = 1;
409 }
410 optional State state = 4;
411}
412
413/**
414 * Logs when an app is holding a wakelock, regardless of the wakelock's name.
415 *
416 * Logged from:
417 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
418 */
419message UidWakelockStateChanged {
420 // TODO: Add attribution instead of uid.
421 optional int32 uid = 1;
422
423 // Type of wakelock.
424 enum Type {
425 PARTIAL = 0;
426 FULL = 1;
427 WINDOW = 2;
428 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800429 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700430
431 enum State {
432 OFF = 0;
433 ON = 1;
434 }
435 optional State state = 3;
436}
437
438/**
439 * Logs when a partial wakelock is considered 'long' (over 1 min).
440 *
441 * Logged from:
442 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
443 */
444message LongPartialWakelockStateChanged {
445 // TODO: Add attribution instead of uid?
446 optional int32 uid = 1;
447
Yao Chend54f9dd2017-10-17 17:37:48 +0000448 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
449 optional string tag = 2;
450
Bookatzc1a050a2017-10-10 15:49:28 -0700451 // TODO: I have no idea what this is.
452 optional string history_tag = 3;
453
454 enum State {
455 OFF = 0;
456 ON = 1;
457 }
458 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000459}
460
Bookatzc1a050a2017-10-10 15:49:28 -0700461/**
462 * Logs Battery Saver state change.
463 *
464 * Logged from:
465 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
466 */
467message BatterySaverModeStateChanged {
468 enum State {
469 OFF = 0;
470 ON = 1;
471 }
472 optional State state = 1;
473}
474
475/**
476 * Logs Doze mode state change.
477 *
478 * Logged from:
479 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
480 */
481message DeviceIdleModeStateChanged {
482 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
483 optional int32 state = 1;
484}
485
486/**
487 * Logs screen brightness level.
488 *
489 * Logged from:
490 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
491 */
492message ScreenBrightnessChanged {
493 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
494 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700495}
496
497/**
498 * Logs battery level (percent full, from 0 to 100).
499 *
500 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700501 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700502 */
503message BatteryLevelChanged {
504 // Battery level. Should be in [0, 100].
505 optional int32 battery_level = 1;
506}
507
508/**
509 * Logs change in charging status of the device.
510 *
511 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700512 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700513 */
514message ChargingStateChanged {
515 // TODO: Link directly to BatteryManager.java's constants (via a proto).
516 enum State {
517 BATTERY_STATUS_UNKNOWN = 1;
518 BATTERY_STATUS_CHARGING = 2;
519 BATTERY_STATUS_DISCHARGING = 3;
520 BATTERY_STATUS_NOT_CHARGING = 4;
521 BATTERY_STATUS_FULL = 5;
522 }
523 optional State charging_state = 1;
524}
525
526/**
527 * Logs whether the device is plugged in, and what power source it is using.
528 *
529 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700530 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700531 */
532message PluggedStateChanged {
533 // TODO: Link directly to BatteryManager.java's constants (via a proto).
534 enum State {
535 // Note that NONE is not in BatteryManager.java's constants.
536 BATTERY_PLUGGED_NONE = 0;
537 // Power source is an AC charger.
538 BATTERY_PLUGGED_AC = 1;
539 // Power source is a USB port.
540 BATTERY_PLUGGED_USB = 2;
541 // Power source is wireless.
542 BATTERY_PLUGGED_WIRELESS = 4;
543 }
544 optional State plugged_state = 1;
545}
546
547/**
548 * Logs the temperature of the device, in tenths of a degree Celsius.
549 *
550 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700551 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700552 */
553message DeviceTemperatureReported {
554 // Temperature in tenths of a degree C.
555 optional int32 temperature = 1;
556}
557
558// TODO: Define this more precisely.
559// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
560/**
561 * Logs when the device turns off or on.
562 *
563 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700564 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700565 */
566message DeviceOnStatusChanged {
567 enum State {
568 OFF = 0;
569 ON = 1;
570 }
571 optional State state = 1;
572}
573
574/**
575 * Logs when an app's wakeup alarm fires.
576 *
577 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700578 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700579 */
580message WakeupAlarmOccurred {
581 // TODO: Add attribution instead of uid?
582 optional int32 uid = 1;
583}
584
585/**
586 * Logs kernel wakeup reasons and aborts.
587 *
588 * Logged from:
589 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
590 */
591message KernelWakeupReported {
592 // Name of the kernel wakeup reason (or abort).
593 optional string wakeup_reason_name = 1;
594
595 // Duration (in microseconds) for the wake-up interrupt to be serviced.
596 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700597}
598
599/**
600 * Logs wifi locks held by an app.
601 *
602 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700603 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700604 */
605message WifiLockStateChanged {
606 // TODO: Add attribution instead of uid.
607 optional int32 uid = 1;
608
609 enum State {
610 OFF = 0;
611 ON = 1;
612 }
613 optional State state = 2;
614}
615
616/**
617 * Logs wifi signal strength changes.
618 *
619 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700620 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700621 */
622message WifiSignalStrengthChanged {
623 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
624 enum SignalStrength {
625 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
626 SIGNAL_STRENGTH_POOR = 1;
627 SIGNAL_STRENGTH_MODERATE = 2;
628 SIGNAL_STRENGTH_GOOD = 3;
629 SIGNAL_STRENGTH_GREAT = 4;
630 }
631 optional SignalStrength signal_strength = 1;
632}
633
634/**
635 * Logs wifi scans performed by an app.
636 *
637 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700638 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700639 */
640message WifiScanStateChanged {
641 // TODO: Add attribution instead of uid.
642 optional int32 uid = 1;
643
644 enum State {
645 OFF = 0;
646 ON = 1;
647 }
648 optional State state = 2;
649}
650
651/**
652 * Logs phone signal strength changes.
653 *
654 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700655 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700656 */
657message PhoneSignalStrengthChanged {
658 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
659 enum SignalStrength {
660 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
661 SIGNAL_STRENGTH_POOR = 1;
662 SIGNAL_STRENGTH_MODERATE = 2;
663 SIGNAL_STRENGTH_GOOD = 3;
664 SIGNAL_STRENGTH_GREAT = 4;
665 }
666 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700667}
668
669/**
670 * Logs that a setting was updated.
671 * Logged from:
672 * frameworks/base/core/java/android/provider/Settings.java
673 * The tag and is_default allow resetting of settings to default values based on the specified
674 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
675 */
676message SettingChanged {
677 // The name of the setting.
678 optional string setting = 1;
679
680 // The change being imposed on this setting. May represent a number, eg "3".
681 optional string value = 2;
682
683 // The new value of this setting. For most settings, this is same as value. For some settings,
684 // value is +X or -X where X represents an element in a set. For example, if the previous value
685 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
686 // The +/- feature is currently only used for location_providers_allowed.
687 optional string new_value = 3;
688
689 // The previous value of this setting.
690 optional string prev_value = 4;
691
692 // The tag used with the is_default for resetting sets of settings. This is generally null.
693 optional string tag = 5;
694
695 // 1 indicates that this setting with tag should be resettable.
696 optional int32 is_default = 6;
697
698 // The user ID associated. Defined in android/os/UserHandle.java
699 optional int32 user = 7;
700}
Chenjie Yub3dda412017-10-24 13:41:59 -0700701
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700702/*
703 * Logs activity going to foreground or background
704 *
705 * Logged from:
706 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
707 */
708message ActivityForegroundStateChanged {
709 enum Activity {
710 MOVE_TO_BACKGROUND = 0;
711 MOVE_TO_FOREGROUND = 1;
712 }
713 optional int32 uid = 1;
714 optional string pkg_name = 2;
715 optional string class_name = 3;
716 optional Activity activity = 4;
717}
David Chenc8a43242017-10-17 16:23:28 -0700718
719/**
David Chen9e3808c2017-11-20 17:25:34 -0800720 * Logs when an error is written to dropbox.
721 * Logged from:
722 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
723 */
724message DropboxErrorChanged {
725 // The uid if available. -1 means not available.
726 optional int32 uid = 1;
727
728 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
729 optional string tag = 2;
730
731 // The name of the process.
732 optional string process_name = 3;
733
734 // The pid if available. -1 means not available.
735 optional int32 pid = 4;
736
737 // 1 indicates is instant app. -1 indicates Not applicable.
738 optional int32 is_instant_app = 5;
739
740 // The activity name if available.
741 optional string activity_name = 6;
742
743 // 1 indicates in foreground. -1 indicates not available.
744 optional int32 is_foreground = 7;
745}
746
747/**
David Chenc8a43242017-10-17 16:23:28 -0700748 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
749 *
750 * Pulled from:
751 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
752 */
753message WifiBytesTransferred {
754 optional int32 uid = 1;
755
756 optional int64 rx_bytes = 2;
757
758 optional int64 rx_packets = 3;
759
760 optional int64 tx_bytes = 4;
761
762 optional int64 tx_packets = 5;
763}
764
765/**
766 * Pulls bytes transferred via wifi (separated by foreground and background usage).
767 *
768 * Pulled from:
769 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
770 */
771message WifiBytesTransferredByFgBg {
772 optional int32 uid = 1;
773
774 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
775 optional int32 is_foreground = 2;
776
777 optional int64 rx_bytes = 3;
778
779 optional int64 rx_packets = 4;
780
781 optional int64 tx_bytes = 5;
782
783 optional int64 tx_packets = 6;
784}
785
786/**
787 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
788 *
789 * Pulled from:
790 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
791 */
792message MobileBytesTransferred {
793 optional int32 uid = 1;
794
795 optional int64 rx_bytes = 2;
796
797 optional int64 rx_packets = 3;
798
799 optional int64 tx_bytes = 4;
800
801 optional int64 tx_packets = 5;
802}
803
804/**
805 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
806 *
807 * Pulled from:
808 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
809 */
810message MobileBytesTransferredByFgBg {
811 optional int32 uid = 1;
812
813 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
814 optional int32 is_foreground = 2;
815
816 optional int64 rx_bytes = 3;
817
818 optional int64 rx_packets = 4;
819
820 optional int64 tx_bytes = 5;
821
822 optional int64 tx_packets = 6;
823}
824
825/**
826 * Pulls the kernel wakelock durations. This atom is adapted from
827 * android/internal/os/KernelWakelockStats.java
828 *
829 * Pulled from:
830 * StatsCompanionService using KernelWakelockReader.
831 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700832message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700833 optional string name = 1;
834
835 optional int32 count = 2;
836
837 optional int32 version = 3;
838
839 optional int64 time = 4;
840}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700841
842/*
843 * Pulls PowerStatePlatformSleepState.
844 *
845 * Definition here:
846 * hardware/interfaces/power/1.0/types.hal
847 */
848message PowerStatePlatformSleepStatePulled {
849 optional string name = 1;
850 optional uint64 residency_in_msec_since_boot = 2;
851 optional uint64 total_transitions = 3;
852 optional bool supported_only_in_suspend = 4;
853}
854
855/**
856 * Pulls PowerStateVoter.
857 *
858 * Definition here:
859 * hardware/interfaces/power/1.0/types.hal
860 */
861message PowerStateVoterPulled {
862 optional string power_state_platform_sleep_state_name = 1;
863 optional string power_state_voter_name = 2;
864 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
865 optional uint64 total_number_of_times_voted_since_boot = 4;
866}
867
868/**
869 * Pulls PowerStateSubsystemSleepState.
870 *
871 * Definition here:
872 * hardware/interfaces/power/1.1/types.hal
873 */
874message PowerStateSubsystemSleepStatePulled {
875 optional string power_state_subsystem_name = 1;
876 optional string power_state_subsystem_sleep_state_name = 2;
877 optional uint64 residency_in_msec_since_boot = 3;
878 optional uint64 total_transitions = 4;
879 optional uint64 last_entry_timestamp_ms = 5;
880 optional bool supported_only_in_suspend = 6;
881}
David Chen21582962017-11-01 17:32:46 -0700882
883/**
884 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
885 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
886 * attributed back to the parent (host) uid. One example is Chrome.
887 *
888 * Logged from:
889 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
890 */
891message IsolatedUidChanged {
892 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
893 optional int32 parent_uid = 1;
894
895 optional int32 isolated_uid = 2;
896
897 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
898 // be removed before if it's used for another parent uid.
899 optional int32 is_create = 3;
900}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700901
902/*
903 * Pulls Cpu time per frequency.
904 * Note: this should be pulled for gauge metric only, without condition.
905 * The puller keeps internal state of last values. It should not be pulled by
906 * different metrics.
907 * The pulled data is delta of cpu time from last pull, calculated as
908 * following:
909 * if current time is larger than last value, take delta between the two.
910 * if current time is smaller than last value, there must be a cpu
911 * hotplug event, and the current time is taken as delta.
912 */
913message CpuTimePerFreqPulled {
914 optional uint32 cluster = 1;
915 optional uint32 freq_index = 2;
916 optional uint64 time = 3;
917}
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800918
919/*
920 * Pulls Cpu Time Per Uid.
921 * Note that isolated process uid time should be attributed to host uids.
922 */
923message CpuTimePerUidPulled {
924 optional uint64 uid = 1;
925 optional uint64 user_time_ms = 2;
926 optional uint64 sys_time_ms = 3;
927}
928
929/**
930 * Pulls Cpu Time Per Uid per frequency.
931 * Note that isolated process uid time should be attributed to host uids.
932 * For each uid, we order the time by descending frequencies.
933 */
934message CpuTimePerUidFreqPulled {
935 optional uint64 uid = 1;
936 optional uint64 freq_idx = 2;
937 optional uint64 time_ms = 3;
938}
Hugo Benichi884970e2017-11-14 22:42:46 +0900939
940/*
941 * Logs the reception of an incoming network packet causing the main system to wake up for
942 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
943 * and processed by WakeupController.cpp.
944 */
945message PacketWakeupOccurred {
946 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
947 // delivered nowhere.
948 optional int32 uid = 1;
949 // The interface name on which the packet was received.
950 optional string iface = 2;
951 // The ethertype value of the packet.
952 optional int32 ethertype = 3;
953 // String representation of the destination MAC address of the packet.
954 optional string destination_hardware_address = 4;
955 // String representation of the source address of the packet if this was an IP packet.
956 optional string source_ip = 5;
957 // String representation of the destination address of the packet if this was an IP packet.
958 optional string destination_ip = 6;
959 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
960 // field if this was an IPv6 packet. The range of possible values is the same for both IP
961 // families.
962 optional int32 ip_next_header = 7;
963 // The source port if this was a TCP or UDP packet.
964 optional int32 source_port = 8;
965 // The destination port if this was a TCP or UDP packet.
966 optional int32 destination_port = 9;
967}