blob: 3471737e7dd9d880529debeb1cab5527c9d42987 [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
Joe Onorato62c220b2017-11-18 20:32:56 -080024import "frameworks/base/core/proto/android/app/activitymanager.proto";
25
Yao Chend54f9dd2017-10-17 17:37:48 +000026/**
Stefan Lafonae2df012017-11-14 09:17:21 -080027 * The master atom class. This message defines all of the available
Yao Chend54f9dd2017-10-17 17:37:48 +000028 * raw stats log events from the Android system, also known as "atoms."
29 *
30 * This field contains a single oneof with all of the available messages.
31 * The stats-log-api-gen tool runs as part of the Android build and
32 * generates the android.util.StatsLog class, which contains the constants
33 * and methods that Android uses to log.
34 *
Stefan Lafonae2df012017-11-14 09:17:21 -080035 * This Atom class is not actually built into the Android system.
Yao Chend54f9dd2017-10-17 17:37:48 +000036 * Instead, statsd on Android constructs these messages synthetically,
37 * in the format defined here and in stats_log.proto.
38 */
Stefan Lafonae2df012017-11-14 09:17:21 -080039message Atom {
40 // Pushed atoms start at 2.
David Chenc8a43242017-10-17 16:23:28 -070041 oneof pushed {
Bookatzc1a050a2017-10-10 15:49:28 -070042 // For StatsLog reasons, 1 is illegal and will not work. Must start at 2.
43 BleScanStateChanged ble_scan_state_changed = 2;
44 BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
45 BleScanResultReceived ble_scan_result_received = 4;
46 SensorStateChanged sensor_state_changed = 5;
47 GpsScanStateChanged gps_scan_state_changed = 6; // TODO: untested
48 SyncStateChanged sync_state_changed = 7;
49 ScheduledJobStateChanged scheduled_job_state_changed = 8;
50 ScreenBrightnessChanged screen_brightness_changed = 9;
Bookatzd6746242017-10-24 18:39:35 -070051 WakelockStateChanged wakelock_state_changed = 10;
Bookatzddccf0a2017-11-28 16:48:14 -080052 LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 11;
53 MobileRadioPowerStateChanged mobile_radio_power_state_changed = 12;
54 WifiRadioPowerStateChanged wifi_radio_power_state_changed = 13;
55 // TODO: 14-19 are blank, but need not be
56 BatterySaverModeStateChanged battery_saver_mode_state_changed = 20;
57 DeviceIdleModeStateChanged device_idle_mode_state_changed = 21;
58 DeviceIdlingModeStateChanged device_idling_mode_state_changed = 22;
Bookatzc1a050a2017-10-10 15:49:28 -070059 AudioStateChanged audio_state_changed = 23;
60 MediaCodecActivityChanged media_codec_activity_changed = 24;
61 CameraStateChanged camera_state_changed = 25;
62 FlashlightStateChanged flashlight_state_changed = 26;
63 UidProcessStateChanged uid_process_state_changed = 27;
64 ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28;
65 ScreenStateChanged screen_state_changed = 29;
Bookatz8c6571b2017-10-24 15:04:41 -070066 BatteryLevelChanged battery_level_changed = 30;
67 ChargingStateChanged charging_state_changed = 31;
68 PluggedStateChanged plugged_state_changed = 32;
69 DeviceTemperatureReported device_temperature_reported = 33;
70 DeviceOnStatusChanged device_on_status_changed = 34;
71 WakeupAlarmOccurred wakeup_alarm_occurred = 35;
72 KernelWakeupReported kernel_wakeup_reported = 36;
Bookatze5885242017-10-24 20:10:31 -070073 WifiLockStateChanged wifi_lock_state_changed = 37;
74 WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
75 WifiScanStateChanged wifi_scan_state_changed = 39;
76 PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
David Chenc28b2bb2017-10-24 12:52:52 -070077 SettingChanged setting_changed = 41;
David Chenc8a43242017-10-17 16:23:28 -070078 ActivityForegroundStateChanged activity_foreground_state_changed = 42;
David Chen21582962017-11-01 17:32:46 -070079 IsolatedUidChanged isolated_uid_changed = 43;
Hugo Benichi884970e2017-11-14 22:42:46 +090080 PacketWakeupOccurred packet_wakeup_occurred = 44;
David Chen9e3808c2017-11-20 17:25:34 -080081 DropboxErrorChanged dropbox_error_changed = 45;
David Chen0a368b22017-12-06 16:28:16 -080082 AppHook app_hook = 46;
Bookatzc1a050a2017-10-10 15:49:28 -070083 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000084 }
David Chenc8a43242017-10-17 16:23:28 -070085
86 // Pulled events will start at field 1000.
87 oneof pulled {
88 WifiBytesTransferred wifi_bytes_transferred = 1000;
89 WifiBytesTransferredByFgBg wifi_bytes_transferred_by_fg_bg = 1001;
90 MobileBytesTransferred mobile_bytes_transferred = 1002;
91 MobileBytesTransferredByFgBg mobile_bytes_transferred_by_fg_bg = 1003;
Chenjie Yu5305e1d2017-10-31 13:49:36 -070092 KernelWakelockPulled kernel_wakelock_pulled = 1004;
93 PowerStatePlatformSleepStatePulled power_state_platform_sleep_state_pulled = 1005;
94 PowerStateVoterPulled power_state_voter_pulled = 1006;
95 PowerStateSubsystemSleepStatePulled power_state_subsystem_sleep_state_pulled = 1007;
Chenjie Yu7f8def92017-11-03 09:33:15 -070096 CpuTimePerFreqPulled cpu_time_per_freq_pulled = 1008;
Chenjie Yue33bc3b2017-11-06 17:56:44 -080097 CpuTimePerUidPulled cpu_time_per_uid_pulled = 1009;
98 CpuTimePerUidFreqPulled cpu_time_per_uid_freq_pulled = 1010;
Chenjie Yu05013b32017-11-21 10:21:41 -080099 WifiActivityEnergyInfoPulled wifi_activity_energy_info_pulled = 1011;
100 ModemActivityInfoPulled modem_activity_info_pulled = 1012;
David Chenc8a43242017-10-17 16:23:28 -0700101 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700102}
103
Yao Chend54f9dd2017-10-17 17:37:48 +0000104/**
105 * A WorkSource represents the chained attribution of applications that
106 * resulted in a particular bit of work being done.
107 */
108message WorkSource {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800109 // The uid for a given element in the attribution chain.
110 repeated int32 uid = 1;
111 // The (optional) string tag for an element in the attribution chain. If the
112 // element has no tag, it is encoded as an empty string.
113 repeated string tag = 2;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700114}
115
Yao Chend54f9dd2017-10-17 17:37:48 +0000116/*
117 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800118 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000119 *
120 * RULES:
121 * - The field ids for each atom must start at 1, and count upwards by 1.
122 * Skipping field ids is not allowed.
123 * - These form an API, so renaming, renumbering or removing fields is
124 * not allowed between android releases. (This is not currently enforced,
125 * but there will be a tool to enforce this restriction).
126 * - The types must be built-in protocol buffer types, namely, no sub-messages
127 * are allowed (yet). The bytes type is also not allowed.
128 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800129 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000130 * - If an atom represents work that can be attributed to an app, there can
131 * be exactly one WorkSource field. It must be field number 1.
132 * - A field that is a uid should be a string field, tagged with the [xxx]
133 * annotation. The generated code on android will be represented by UIDs,
134 * and those UIDs will be translated in xxx to those strings.
135 *
136 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700137 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000138 * - If there is a UID, it goes first. Think in an object-oriented fashion.
139 * *****************************************************************************
140 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700141
Yao Chend54f9dd2017-10-17 17:37:48 +0000142/**
143 * Logs when the screen state changes.
144 *
145 * Logged from:
146 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
147 */
148message ScreenStateChanged {
149 // TODO: Use the real screen state.
150 enum State {
151 STATE_UNKNOWN = 0;
152 STATE_OFF = 1;
153 STATE_ON = 2;
154 STATE_DOZE = 3;
155 STATE_DOZE_SUSPEND = 4;
156 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800157 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000158 }
159 // New screen state.
160 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700161}
Yao Chend54f9dd2017-10-17 17:37:48 +0000162
163/**
Bookatzc1a050a2017-10-10 15:49:28 -0700164 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000165 *
166 * Logged from:
167 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
168 */
Bookatzc1a050a2017-10-10 15:49:28 -0700169message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000170 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
171
172 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700173 // TODO: Use the real (mapped) process states.
Joe Onorato62c220b2017-11-18 20:32:56 -0800174 optional android.app.ProcessState state = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000175}
176
177/**
Bookatzc1a050a2017-10-10 15:49:28 -0700178 * Logs that a process started, finished, crashed, or ANRed.
179 *
180 * Logged from:
181 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
182 */
183message ProcessLifeCycleStateChanged {
184 // TODO: Use the real (mapped) process states.
185 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
186
187 // TODO: What is this?
188 optional string name = 2;
189
Bookatzddccf0a2017-11-28 16:48:14 -0800190 // What lifecycle state the process changed to.
191 // This enum is specific to atoms.proto.
192 enum Event {
193 PROCESS_FINISHED = 0;
194 PROCESS_STARTED = 1;
195 PROCESS_CRASHED = 2;
196 PROCESS_ANRED = 3;
197 }
198 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700199}
200
Bookatzc1a050a2017-10-10 15:49:28 -0700201/**
202 * Logs when the ble scan state changes.
203 *
204 * Logged from:
205 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
206 */
207message BleScanStateChanged {
208 // TODO: Add attribution instead of uid.
209 optional int32 uid = 1;
210
211 enum State {
212 OFF = 0;
213 ON = 1;
214 }
215 optional State state = 2;
216}
217
218/**
219 * Logs when an unoptimized ble scan state changes.
220 *
221 * Logged from:
222 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
223 */
224// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
225message BleUnoptimizedScanStateChanged {
226 // TODO: Add attribution instead of uid.
227 optional int32 uid = 1;
228
229 enum State {
230 OFF = 0;
231 ON = 1;
232 }
233 optional State state = 2;
234}
235
236/**
237 * Logs reporting of a ble scan finding results.
238 *
239 * Logged from:
240 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
241 */
242// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
243message BleScanResultReceived {
244 // TODO: Add attribution instead of uid.
245 optional int32 uid = 1;
246
247 // Number of ble scan results returned.
248 optional int32 num_of_results = 2;
249}
250
251/**
252 * Logs when a sensor state changes.
253 *
254 * Logged from:
255 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
256 */
257message SensorStateChanged {
258 // TODO: Add attribution instead of uid.
259 optional int32 uid = 1;
260
261 // TODO: Is there a way to get the actual name of the sensor?
262 // The id (int) of the sensor.
263 optional int32 sensor_id = 2;
264
265 enum State {
266 OFF = 0;
267 ON = 1;
268 }
269 optional State state = 3;
270}
271
272
273/**
274 * Logs when GPS state changes.
275 *
276 * Logged from:
277 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
278 */
279message GpsScanStateChanged {
280 // TODO: Add attribution instead of uid.
281 optional int32 uid = 1;
282
283 enum State {
284 OFF = 0;
285 ON = 1;
286 }
287 optional State state = 2;
288}
289
290
291/**
292 * Logs when a sync manager sync state changes.
293 *
294 * Logged from:
295 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
296 */
297message SyncStateChanged {
298 // TODO: Add attribution instead of uid.
299 optional int32 uid = 1;
300
301 // Name of the sync (as named in the app)
302 optional string name = 2;
303
304 enum State {
305 OFF = 0;
306 ON = 1;
307 }
308 optional State state = 3;
309}
310
311/**
312 * Logs when a job scheduler job state changes.
313 *
314 * Logged from:
315 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
316 */
317message ScheduledJobStateChanged {
318 // TODO: Add attribution instead of uid.
319 optional int32 uid = 1;
320
321 // Name of the job (as named in the app)
322 optional string name = 2;
323
324 enum State {
325 OFF = 0;
326 ON = 1;
327 }
328 optional State state = 3;
329
330 // TODO: Consider adding the stopReason (int)
331}
332
333/**
334 * Logs when the audio state changes.
335 *
336 * Logged from:
337 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
338 */
339message AudioStateChanged {
340 // TODO: Add attribution instead of uid.
341 optional int32 uid = 1;
342
343 enum State {
344 OFF = 0;
345 ON = 1;
346 }
347 optional State state = 2;
348}
349
350/**
351 * Logs when the video codec state changes.
352 *
353 * Logged from:
354 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
355 */
356message MediaCodecActivityChanged {
357 // TODO: Add attribution instead of uid.
358 optional int32 uid = 1;
359
360 enum State {
361 OFF = 0;
362 ON = 1;
363 }
364 optional State state = 2;
365}
366
367/**
368 * Logs when the flashlight state changes.
369 *
370 * Logged from:
371 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
372 */
373message FlashlightStateChanged {
374 // TODO: Add attribution instead of uid.
375 optional int32 uid = 1;
376
377 enum State {
378 OFF = 0;
379 ON = 1;
380 }
381 optional State state = 2;
382}
383
384/**
385 * Logs when the camera state changes.
386 *
387 * Logged from:
388 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
389 */
390message CameraStateChanged {
391 // TODO: Add attribution instead of uid.
392 optional int32 uid = 1;
393
394 enum State {
395 OFF = 0;
396 ON = 1;
397 }
398 optional State state = 2;
399}
400
401/**
402 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000403 *
404 * Logged from:
405 * TODO
406 */
Bookatzd6746242017-10-24 18:39:35 -0700407message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000408 // TODO: Add attribution instead of uid.
409 optional int32 uid = 1;
410
Bookatzc1a050a2017-10-10 15:49:28 -0700411 // Type of wakelock.
412 enum Type {
413 PARTIAL = 0;
414 FULL = 1;
415 WINDOW = 2;
416 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800417 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700418
419 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
420 optional string tag = 3;
421
422 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800423 RELEASE = 0;
424 ACQUIRE = 1;
425 CHANGE_RELEASE = 2;
426 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700427 }
428 optional State state = 4;
429}
430
431/**
Bookatzc1a050a2017-10-10 15:49:28 -0700432 * Logs when a partial wakelock is considered 'long' (over 1 min).
433 *
434 * Logged from:
435 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
436 */
437message LongPartialWakelockStateChanged {
438 // TODO: Add attribution instead of uid?
439 optional int32 uid = 1;
440
Yao Chend54f9dd2017-10-17 17:37:48 +0000441 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
442 optional string tag = 2;
443
Bookatzc1a050a2017-10-10 15:49:28 -0700444 // TODO: I have no idea what this is.
445 optional string history_tag = 3;
446
447 enum State {
448 OFF = 0;
449 ON = 1;
450 }
451 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000452}
453
Bookatzc1a050a2017-10-10 15:49:28 -0700454/**
455 * Logs Battery Saver state change.
456 *
457 * Logged from:
458 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
459 */
460message BatterySaverModeStateChanged {
461 enum State {
462 OFF = 0;
463 ON = 1;
464 }
465 optional State state = 1;
466}
467
468/**
469 * Logs Doze mode state change.
470 *
471 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800472 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700473 */
474message DeviceIdleModeStateChanged {
475 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800476 enum State {
477 DEVICE_IDLE_MODE_OFF = 0;
478 DEVICE_IDLE_MODE_LIGHT = 1;
479 DEVICE_IDLE_MODE_DEEP = 2;
480 }
481 optional State state = 1;
482}
483
484
485/**
486 * Logs state change of Doze mode including maintenance windows.
487 *
488 * Logged from:
489 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
490 */
491message DeviceIdlingModeStateChanged {
492 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
493 enum State {
494 DEVICE_IDLE_MODE_OFF = 0;
495 DEVICE_IDLE_MODE_LIGHT = 1;
496 DEVICE_IDLE_MODE_DEEP = 2;
497 }
498 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700499}
500
501/**
502 * Logs screen brightness level.
503 *
504 * Logged from:
505 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
506 */
507message ScreenBrightnessChanged {
508 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
509 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700510}
511
512/**
513 * Logs battery level (percent full, from 0 to 100).
514 *
515 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700516 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700517 */
518message BatteryLevelChanged {
519 // Battery level. Should be in [0, 100].
520 optional int32 battery_level = 1;
521}
522
523/**
524 * Logs change in charging status of the device.
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 ChargingStateChanged {
530 // TODO: Link directly to BatteryManager.java's constants (via a proto).
531 enum State {
532 BATTERY_STATUS_UNKNOWN = 1;
533 BATTERY_STATUS_CHARGING = 2;
534 BATTERY_STATUS_DISCHARGING = 3;
535 BATTERY_STATUS_NOT_CHARGING = 4;
536 BATTERY_STATUS_FULL = 5;
537 }
538 optional State charging_state = 1;
539}
540
541/**
542 * Logs whether the device is plugged in, and what power source it is using.
543 *
544 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700545 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700546 */
547message PluggedStateChanged {
548 // TODO: Link directly to BatteryManager.java's constants (via a proto).
549 enum State {
550 // Note that NONE is not in BatteryManager.java's constants.
551 BATTERY_PLUGGED_NONE = 0;
552 // Power source is an AC charger.
553 BATTERY_PLUGGED_AC = 1;
554 // Power source is a USB port.
555 BATTERY_PLUGGED_USB = 2;
556 // Power source is wireless.
557 BATTERY_PLUGGED_WIRELESS = 4;
558 }
559 optional State plugged_state = 1;
560}
561
562/**
563 * Logs the temperature of the device, in tenths of a degree Celsius.
564 *
565 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700566 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700567 */
568message DeviceTemperatureReported {
569 // Temperature in tenths of a degree C.
570 optional int32 temperature = 1;
571}
572
573// TODO: Define this more precisely.
574// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
575/**
576 * Logs when the device turns off or on.
577 *
578 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700579 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700580 */
581message DeviceOnStatusChanged {
582 enum State {
583 OFF = 0;
584 ON = 1;
585 }
586 optional State state = 1;
587}
588
589/**
590 * Logs when an app's wakeup alarm fires.
591 *
592 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700593 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700594 */
595message WakeupAlarmOccurred {
596 // TODO: Add attribution instead of uid?
597 optional int32 uid = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800598
599 // Name of the wakeup alarm.
600 optional string tag = 2;
601}
602
603/**
604 * Logs when an an app causes the mobile radio to change state.
605 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
606 *
607 * Logged from:
608 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
609 */
610message MobileRadioPowerStateChanged {
611 // TODO: Add attribution instead of uid?
612 optional int32 uid = 1;
613
614 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
615 enum PowerState {
616 DC_POWER_STATE_LOW = 1;
617 DC_POWER_STATE_MEDIUM = 2;
618 DC_POWER_STATE_HIGH = 3;
619 }
620 optional PowerState power_state = 2;
621}
622
623/**
624 * Logs when an an app causes the wifi radio to change state.
625 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
626 *
627 * Logged from:
628 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
629 */
630message WifiRadioPowerStateChanged {
631 // TODO: Add attribution instead of uid?
632 optional int32 uid = 1;
633
634 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
635 enum PowerState {
636 DC_POWER_STATE_LOW = 1;
637 DC_POWER_STATE_MEDIUM = 2;
638 DC_POWER_STATE_HIGH = 3;
639 }
640 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700641}
642
643/**
644 * Logs kernel wakeup reasons and aborts.
645 *
646 * Logged from:
647 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
648 */
649message KernelWakeupReported {
650 // Name of the kernel wakeup reason (or abort).
651 optional string wakeup_reason_name = 1;
652
653 // Duration (in microseconds) for the wake-up interrupt to be serviced.
654 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700655}
656
657/**
658 * Logs wifi locks held by an app.
659 *
660 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700661 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700662 */
663message WifiLockStateChanged {
664 // TODO: Add attribution instead of uid.
665 optional int32 uid = 1;
666
667 enum State {
668 OFF = 0;
669 ON = 1;
670 }
671 optional State state = 2;
672}
673
674/**
675 * Logs wifi signal strength changes.
676 *
677 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700678 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700679 */
680message WifiSignalStrengthChanged {
681 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
682 enum SignalStrength {
683 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
684 SIGNAL_STRENGTH_POOR = 1;
685 SIGNAL_STRENGTH_MODERATE = 2;
686 SIGNAL_STRENGTH_GOOD = 3;
687 SIGNAL_STRENGTH_GREAT = 4;
688 }
689 optional SignalStrength signal_strength = 1;
690}
691
692/**
693 * Logs wifi scans performed by an app.
694 *
695 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700696 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700697 */
698message WifiScanStateChanged {
699 // TODO: Add attribution instead of uid.
700 optional int32 uid = 1;
701
702 enum State {
703 OFF = 0;
704 ON = 1;
705 }
706 optional State state = 2;
707}
708
709/**
710 * Logs phone signal strength changes.
711 *
712 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700713 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700714 */
715message PhoneSignalStrengthChanged {
716 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
717 enum SignalStrength {
718 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
719 SIGNAL_STRENGTH_POOR = 1;
720 SIGNAL_STRENGTH_MODERATE = 2;
721 SIGNAL_STRENGTH_GOOD = 3;
722 SIGNAL_STRENGTH_GREAT = 4;
723 }
724 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700725}
726
727/**
728 * Logs that a setting was updated.
729 * Logged from:
730 * frameworks/base/core/java/android/provider/Settings.java
731 * The tag and is_default allow resetting of settings to default values based on the specified
732 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
733 */
734message SettingChanged {
735 // The name of the setting.
736 optional string setting = 1;
737
738 // The change being imposed on this setting. May represent a number, eg "3".
739 optional string value = 2;
740
741 // The new value of this setting. For most settings, this is same as value. For some settings,
742 // value is +X or -X where X represents an element in a set. For example, if the previous value
743 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
744 // The +/- feature is currently only used for location_providers_allowed.
745 optional string new_value = 3;
746
747 // The previous value of this setting.
748 optional string prev_value = 4;
749
750 // The tag used with the is_default for resetting sets of settings. This is generally null.
751 optional string tag = 5;
752
753 // 1 indicates that this setting with tag should be resettable.
754 optional int32 is_default = 6;
755
756 // The user ID associated. Defined in android/os/UserHandle.java
757 optional int32 user = 7;
758}
Chenjie Yub3dda412017-10-24 13:41:59 -0700759
Chenjie Yu05013b32017-11-21 10:21:41 -0800760/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700761 * Logs activity going to foreground or background
762 *
763 * Logged from:
764 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
765 */
766message ActivityForegroundStateChanged {
767 enum Activity {
768 MOVE_TO_BACKGROUND = 0;
769 MOVE_TO_FOREGROUND = 1;
770 }
771 optional int32 uid = 1;
772 optional string pkg_name = 2;
773 optional string class_name = 3;
774 optional Activity activity = 4;
775}
David Chenc8a43242017-10-17 16:23:28 -0700776
777/**
David Chen9e3808c2017-11-20 17:25:34 -0800778 * Logs when an error is written to dropbox.
779 * Logged from:
780 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
781 */
782message DropboxErrorChanged {
783 // The uid if available. -1 means not available.
784 optional int32 uid = 1;
785
786 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
787 optional string tag = 2;
788
789 // The name of the process.
790 optional string process_name = 3;
791
792 // The pid if available. -1 means not available.
793 optional int32 pid = 4;
794
795 // 1 indicates is instant app. -1 indicates Not applicable.
796 optional int32 is_instant_app = 5;
797
798 // The activity name if available.
799 optional string activity_name = 6;
800
801 // 1 indicates in foreground. -1 indicates not available.
802 optional int32 is_foreground = 7;
803}
804
David Chen0a368b22017-12-06 16:28:16 -0800805/*
806 * Allows other apps to push events into statsd.
807 * Logged from:
808 * frameworks/base/core/java/android/util/StatsLog.java
809 */
810message AppHook {
811 // The uid of the application that sent this custom atom.
812 optional int32 uid = 1;
813
814 // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
815 optional int32 label = 2;
816
817 // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
818 // predicates for the metrics).
819 enum State {
820 UNKNOWN = 0;
821 UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
822 STOP = 2;
823 START = 3;
824 }
825 optional State state = 3;
826}
827
David Chen9e3808c2017-11-20 17:25:34 -0800828/**
David Chenc8a43242017-10-17 16:23:28 -0700829 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
830 *
831 * Pulled from:
832 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
833 */
834message WifiBytesTransferred {
835 optional int32 uid = 1;
836
837 optional int64 rx_bytes = 2;
838
839 optional int64 rx_packets = 3;
840
841 optional int64 tx_bytes = 4;
842
843 optional int64 tx_packets = 5;
844}
845
846/**
847 * Pulls bytes transferred via wifi (separated by foreground and background usage).
848 *
849 * Pulled from:
850 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
851 */
852message WifiBytesTransferredByFgBg {
853 optional int32 uid = 1;
854
855 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
856 optional int32 is_foreground = 2;
857
858 optional int64 rx_bytes = 3;
859
860 optional int64 rx_packets = 4;
861
862 optional int64 tx_bytes = 5;
863
864 optional int64 tx_packets = 6;
865}
866
867/**
868 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
869 *
870 * Pulled from:
871 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
872 */
873message MobileBytesTransferred {
874 optional int32 uid = 1;
875
876 optional int64 rx_bytes = 2;
877
878 optional int64 rx_packets = 3;
879
880 optional int64 tx_bytes = 4;
881
882 optional int64 tx_packets = 5;
883}
884
885/**
886 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
887 *
888 * Pulled from:
889 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
890 */
891message MobileBytesTransferredByFgBg {
892 optional int32 uid = 1;
893
894 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
895 optional int32 is_foreground = 2;
896
897 optional int64 rx_bytes = 3;
898
899 optional int64 rx_packets = 4;
900
901 optional int64 tx_bytes = 5;
902
903 optional int64 tx_packets = 6;
904}
905
906/**
907 * Pulls the kernel wakelock durations. This atom is adapted from
908 * android/internal/os/KernelWakelockStats.java
909 *
910 * Pulled from:
911 * StatsCompanionService using KernelWakelockReader.
912 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700913message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700914 optional string name = 1;
915
916 optional int32 count = 2;
917
918 optional int32 version = 3;
919
920 optional int64 time = 4;
921}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700922
Chenjie Yu05013b32017-11-21 10:21:41 -0800923/**
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700924 * Pulls PowerStatePlatformSleepState.
925 *
926 * Definition here:
927 * hardware/interfaces/power/1.0/types.hal
928 */
929message PowerStatePlatformSleepStatePulled {
930 optional string name = 1;
931 optional uint64 residency_in_msec_since_boot = 2;
932 optional uint64 total_transitions = 3;
933 optional bool supported_only_in_suspend = 4;
934}
935
936/**
937 * Pulls PowerStateVoter.
938 *
939 * Definition here:
940 * hardware/interfaces/power/1.0/types.hal
941 */
942message PowerStateVoterPulled {
943 optional string power_state_platform_sleep_state_name = 1;
944 optional string power_state_voter_name = 2;
945 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
946 optional uint64 total_number_of_times_voted_since_boot = 4;
947}
948
949/**
950 * Pulls PowerStateSubsystemSleepState.
951 *
952 * Definition here:
953 * hardware/interfaces/power/1.1/types.hal
954 */
955message PowerStateSubsystemSleepStatePulled {
956 optional string power_state_subsystem_name = 1;
957 optional string power_state_subsystem_sleep_state_name = 2;
958 optional uint64 residency_in_msec_since_boot = 3;
959 optional uint64 total_transitions = 4;
960 optional uint64 last_entry_timestamp_ms = 5;
961 optional bool supported_only_in_suspend = 6;
962}
David Chen21582962017-11-01 17:32:46 -0700963
964/**
965 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
966 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
967 * attributed back to the parent (host) uid. One example is Chrome.
968 *
969 * Logged from:
970 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
971 */
972message IsolatedUidChanged {
973 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
974 optional int32 parent_uid = 1;
975
976 optional int32 isolated_uid = 2;
977
978 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
979 // be removed before if it's used for another parent uid.
980 optional int32 is_create = 3;
981}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700982
Chenjie Yu05013b32017-11-21 10:21:41 -0800983/**
Chenjie Yu7f8def92017-11-03 09:33:15 -0700984 * Pulls Cpu time per frequency.
985 * Note: this should be pulled for gauge metric only, without condition.
986 * The puller keeps internal state of last values. It should not be pulled by
987 * different metrics.
988 * The pulled data is delta of cpu time from last pull, calculated as
989 * following:
990 * if current time is larger than last value, take delta between the two.
991 * if current time is smaller than last value, there must be a cpu
992 * hotplug event, and the current time is taken as delta.
993 */
994message CpuTimePerFreqPulled {
995 optional uint32 cluster = 1;
996 optional uint32 freq_index = 2;
997 optional uint64 time = 3;
998}
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800999
Chenjie Yu05013b32017-11-21 10:21:41 -08001000/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001001 * Pulls Cpu Time Per Uid.
1002 * Note that isolated process uid time should be attributed to host uids.
1003 */
1004message CpuTimePerUidPulled {
1005 optional uint64 uid = 1;
1006 optional uint64 user_time_ms = 2;
1007 optional uint64 sys_time_ms = 3;
1008}
1009
1010/**
1011 * Pulls Cpu Time Per Uid per frequency.
1012 * Note that isolated process uid time should be attributed to host uids.
1013 * For each uid, we order the time by descending frequencies.
1014 */
1015message CpuTimePerUidFreqPulled {
1016 optional uint64 uid = 1;
1017 optional uint64 freq_idx = 2;
1018 optional uint64 time_ms = 3;
1019}
Hugo Benichi884970e2017-11-14 22:42:46 +09001020
1021/*
1022 * Logs the reception of an incoming network packet causing the main system to wake up for
1023 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1024 * and processed by WakeupController.cpp.
1025 */
1026message PacketWakeupOccurred {
1027 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1028 // delivered nowhere.
1029 optional int32 uid = 1;
1030 // The interface name on which the packet was received.
1031 optional string iface = 2;
1032 // The ethertype value of the packet.
1033 optional int32 ethertype = 3;
1034 // String representation of the destination MAC address of the packet.
1035 optional string destination_hardware_address = 4;
1036 // String representation of the source address of the packet if this was an IP packet.
1037 optional string source_ip = 5;
1038 // String representation of the destination address of the packet if this was an IP packet.
1039 optional string destination_ip = 6;
1040 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1041 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1042 // families.
1043 optional int32 ip_next_header = 7;
1044 // The source port if this was a TCP or UDP packet.
1045 optional int32 source_port = 8;
1046 // The destination port if this was a TCP or UDP packet.
1047 optional int32 destination_port = 9;
1048}
Chenjie Yu05013b32017-11-21 10:21:41 -08001049
1050/**
1051 * Pulls Wifi Controller Activity Energy Info
1052 */
1053message WifiActivityEnergyInfoPulled {
1054 // timestamp(wall clock) of record creation
1055 optional uint64 timestamp_ms = 1;
1056 // stack reported state
1057 // TODO: replace this with proto enum
1058 optional int32 stack_state = 2;
1059 // tx time in ms
1060 optional uint64 controller_tx_time_ms = 3;
1061 // rx time in ms
1062 optional uint64 controller_rx_time_ms = 4;
1063 // idle time in ms
1064 optional uint64 controller_idle_time_ms = 5;
1065 // product of current(mA), voltage(V) and time(ms)
1066 optional uint64 controller_energy_used = 6;
1067}
1068
1069/**
1070 * Pulls Modem Activity Energy Info
1071 */
1072message ModemActivityInfoPulled {
1073 // timestamp(wall clock) of record creation
1074 optional uint64 timestamp_ms = 1;
1075 // sleep time in ms.
1076 optional uint64 sleep_time_ms = 2;
1077 // idle time in ms
1078 optional uint64 controller_idle_time_ms = 3;
1079 /**
1080 * Tx power index
1081 * index 0 = tx_power < 0dBm
1082 * index 1 = 0dBm < tx_power < 5dBm
1083 * index 2 = 5dBm < tx_power < 15dBm
1084 * index 3 = 15dBm < tx_power < 20dBm
1085 * index 4 = tx_power > 20dBm
1086 */
1087 // tx time in ms at power level 0
1088 optional uint64 controller_tx_time_pl0_ms = 4;
1089 // tx time in ms at power level 1
1090 optional uint64 controller_tx_time_pl1_ms = 5;
1091 // tx time in ms at power level 2
1092 optional uint64 controller_tx_time_pl2_ms = 6;
1093 // tx time in ms at power level 3
1094 optional uint64 controller_tx_time_pl3_ms = 7;
1095 // tx time in ms at power level 4
1096 optional uint64 controller_tx_time_pl4_ms = 8;
1097 // rx time in ms at power level 5
1098 optional uint64 controller_rx_time_ms = 9;
1099 // product of current(mA), voltage(V) and time(ms)
1100 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001101}