blob: c37f05e16508315f12b12203bd1858a48702127f [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 {
Chenjie Yu31d14d72017-12-12 17:54:33 -080088 WifiBytesTransfer wifi_bytes_transfer = 1000;
89 WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 1001;
90 MobileBytesTransfer mobile_bytes_transfer = 1002;
91 MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 1003;
92 KernelWakelock kernel_wakelock = 1004;
93 PlatformSleepState platform_sleep_state = 1005;
94 SleepStateVoter sleep_state_voter = 1006;
95 SubsystemSleepState subsystem_sleep_state = 1007;
96 CpuTimePerFreq cpu_time_per_freq = 1008;
97 CpuTimePerUid cpu_time_per_uid = 1009;
98 CpuTimePerUidFreq cpu_time_per_uid_freq = 1010;
99 WifiActivityEnergyInfo wifi_activity_energy_info = 1011;
100 ModemActivityInfo modem_activity_info = 1012;
Yangster-mac7604aea2017-12-11 22:55:49 -0800101 AttributionChainDummyAtom attribution_chain_dummy_atom = 10000;
David Chenc8a43242017-10-17 16:23:28 -0700102 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700103}
104
Yao Chend54f9dd2017-10-17 17:37:48 +0000105/**
Yangster-mac7604aea2017-12-11 22:55:49 -0800106 * An attribution represents an application or module that is part of process where a particular bit
107 * of work is done.
Yao Chend54f9dd2017-10-17 17:37:48 +0000108 */
Yangster-mac7604aea2017-12-11 22:55:49 -0800109message Attribution {
110 // The uid for an application or module.
111 optional int32 uid = 1;
112 // The string tag for the attribution node.
113 optional string tag = 2;
114}
115
116/**
117 * An attribution chain represents the chained attributions of applications or modules that
118 * resulted in a particular bit of work being done.
119 * The ordering of the attributions is that of calls, that is uid = [A, B, C] if A calls B that
120 * calls C.
121 */
122message AttributionChain {
123 repeated Attribution attribution = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700124}
125
Yao Chend54f9dd2017-10-17 17:37:48 +0000126/*
127 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800128 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000129 *
130 * RULES:
131 * - The field ids for each atom must start at 1, and count upwards by 1.
132 * Skipping field ids is not allowed.
133 * - These form an API, so renaming, renumbering or removing fields is
134 * not allowed between android releases. (This is not currently enforced,
135 * but there will be a tool to enforce this restriction).
136 * - The types must be built-in protocol buffer types, namely, no sub-messages
137 * are allowed (yet). The bytes type is also not allowed.
138 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800139 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000140 * - If an atom represents work that can be attributed to an app, there can
Yangster-mac7604aea2017-12-11 22:55:49 -0800141 * be exactly one AttributionChain field. It must be field number 1.
Yao Chend54f9dd2017-10-17 17:37:48 +0000142 * - A field that is a uid should be a string field, tagged with the [xxx]
143 * annotation. The generated code on android will be represented by UIDs,
144 * and those UIDs will be translated in xxx to those strings.
145 *
146 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700147 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000148 * - If there is a UID, it goes first. Think in an object-oriented fashion.
149 * *****************************************************************************
150 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700151
Yangster-mac7604aea2017-12-11 22:55:49 -0800152message AttributionChainDummyAtom {
153 optional AttributionChain attribution_chain = 1;
154 optional int32 value = 2;
155}
156
Yao Chend54f9dd2017-10-17 17:37:48 +0000157/**
158 * Logs when the screen state changes.
159 *
160 * Logged from:
161 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
162 */
163message ScreenStateChanged {
164 // TODO: Use the real screen state.
165 enum State {
166 STATE_UNKNOWN = 0;
167 STATE_OFF = 1;
168 STATE_ON = 2;
169 STATE_DOZE = 3;
170 STATE_DOZE_SUSPEND = 4;
171 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800172 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000173 }
174 // New screen state.
175 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700176}
Yao Chend54f9dd2017-10-17 17:37:48 +0000177
178/**
Bookatzc1a050a2017-10-10 15:49:28 -0700179 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000180 *
181 * Logged from:
182 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
183 */
Bookatzc1a050a2017-10-10 15:49:28 -0700184message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000185 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
186
187 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700188 // TODO: Use the real (mapped) process states.
Joe Onorato62c220b2017-11-18 20:32:56 -0800189 optional android.app.ProcessState state = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000190}
191
192/**
Bookatzc1a050a2017-10-10 15:49:28 -0700193 * Logs that a process started, finished, crashed, or ANRed.
194 *
195 * Logged from:
196 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
197 */
198message ProcessLifeCycleStateChanged {
199 // TODO: Use the real (mapped) process states.
200 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
201
202 // TODO: What is this?
203 optional string name = 2;
204
Bookatzddccf0a2017-11-28 16:48:14 -0800205 // What lifecycle state the process changed to.
206 // This enum is specific to atoms.proto.
207 enum Event {
208 PROCESS_FINISHED = 0;
209 PROCESS_STARTED = 1;
210 PROCESS_CRASHED = 2;
211 PROCESS_ANRED = 3;
212 }
213 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700214}
215
Bookatzc1a050a2017-10-10 15:49:28 -0700216/**
217 * Logs when the ble scan state changes.
218 *
219 * Logged from:
220 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
221 */
222message BleScanStateChanged {
223 // TODO: Add attribution instead of uid.
224 optional int32 uid = 1;
225
226 enum State {
227 OFF = 0;
228 ON = 1;
229 }
230 optional State state = 2;
231}
232
233/**
234 * Logs when an unoptimized ble scan state changes.
235 *
236 * Logged from:
237 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
238 */
239// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
240message BleUnoptimizedScanStateChanged {
241 // TODO: Add attribution instead of uid.
242 optional int32 uid = 1;
243
244 enum State {
245 OFF = 0;
246 ON = 1;
247 }
248 optional State state = 2;
249}
250
251/**
252 * Logs reporting of a ble scan finding results.
253 *
254 * Logged from:
255 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
256 */
257// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
258message BleScanResultReceived {
259 // TODO: Add attribution instead of uid.
260 optional int32 uid = 1;
261
262 // Number of ble scan results returned.
263 optional int32 num_of_results = 2;
264}
265
266/**
267 * Logs when a sensor state changes.
268 *
269 * Logged from:
270 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
271 */
272message SensorStateChanged {
273 // TODO: Add attribution instead of uid.
274 optional int32 uid = 1;
275
276 // TODO: Is there a way to get the actual name of the sensor?
277 // The id (int) of the sensor.
278 optional int32 sensor_id = 2;
279
280 enum State {
281 OFF = 0;
282 ON = 1;
283 }
284 optional State state = 3;
285}
286
287
288/**
289 * Logs when GPS state changes.
290 *
291 * Logged from:
292 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
293 */
294message GpsScanStateChanged {
295 // TODO: Add attribution instead of uid.
296 optional int32 uid = 1;
297
298 enum State {
299 OFF = 0;
300 ON = 1;
301 }
302 optional State state = 2;
303}
304
305
306/**
307 * Logs when a sync manager sync state changes.
308 *
309 * Logged from:
310 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
311 */
312message SyncStateChanged {
313 // TODO: Add attribution instead of uid.
314 optional int32 uid = 1;
315
316 // Name of the sync (as named in the app)
317 optional string name = 2;
318
319 enum State {
320 OFF = 0;
321 ON = 1;
322 }
323 optional State state = 3;
324}
325
326/**
327 * Logs when a job scheduler job state changes.
328 *
329 * Logged from:
330 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
331 */
332message ScheduledJobStateChanged {
333 // TODO: Add attribution instead of uid.
334 optional int32 uid = 1;
335
336 // Name of the job (as named in the app)
337 optional string name = 2;
338
339 enum State {
340 OFF = 0;
341 ON = 1;
342 }
343 optional State state = 3;
344
345 // TODO: Consider adding the stopReason (int)
346}
347
348/**
349 * Logs when the audio state changes.
350 *
351 * Logged from:
352 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
353 */
354message AudioStateChanged {
355 // TODO: Add attribution instead of uid.
356 optional int32 uid = 1;
357
358 enum State {
359 OFF = 0;
360 ON = 1;
361 }
362 optional State state = 2;
363}
364
365/**
366 * Logs when the video codec state changes.
367 *
368 * Logged from:
369 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
370 */
371message MediaCodecActivityChanged {
372 // TODO: Add attribution instead of uid.
373 optional int32 uid = 1;
374
375 enum State {
376 OFF = 0;
377 ON = 1;
378 }
379 optional State state = 2;
380}
381
382/**
383 * Logs when the flashlight state changes.
384 *
385 * Logged from:
386 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
387 */
388message FlashlightStateChanged {
389 // TODO: Add attribution instead of uid.
390 optional int32 uid = 1;
391
392 enum State {
393 OFF = 0;
394 ON = 1;
395 }
396 optional State state = 2;
397}
398
399/**
400 * Logs when the camera state changes.
401 *
402 * Logged from:
403 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
404 */
405message CameraStateChanged {
406 // TODO: Add attribution instead of uid.
407 optional int32 uid = 1;
408
409 enum State {
410 OFF = 0;
411 ON = 1;
412 }
413 optional State state = 2;
414}
415
416/**
417 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000418 *
419 * Logged from:
420 * TODO
421 */
Bookatzd6746242017-10-24 18:39:35 -0700422message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000423 // TODO: Add attribution instead of uid.
424 optional int32 uid = 1;
425
Bookatzc1a050a2017-10-10 15:49:28 -0700426 // Type of wakelock.
427 enum Type {
428 PARTIAL = 0;
429 FULL = 1;
430 WINDOW = 2;
431 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800432 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700433
434 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
435 optional string tag = 3;
436
437 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800438 RELEASE = 0;
439 ACQUIRE = 1;
440 CHANGE_RELEASE = 2;
441 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700442 }
443 optional State state = 4;
444}
445
446/**
Bookatzc1a050a2017-10-10 15:49:28 -0700447 * Logs when a partial wakelock is considered 'long' (over 1 min).
448 *
449 * Logged from:
450 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
451 */
452message LongPartialWakelockStateChanged {
453 // TODO: Add attribution instead of uid?
454 optional int32 uid = 1;
455
Yao Chend54f9dd2017-10-17 17:37:48 +0000456 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
457 optional string tag = 2;
458
Bookatzc1a050a2017-10-10 15:49:28 -0700459 // TODO: I have no idea what this is.
460 optional string history_tag = 3;
461
462 enum State {
463 OFF = 0;
464 ON = 1;
465 }
466 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000467}
468
Bookatzc1a050a2017-10-10 15:49:28 -0700469/**
470 * Logs Battery Saver state change.
471 *
472 * Logged from:
473 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
474 */
475message BatterySaverModeStateChanged {
476 enum State {
477 OFF = 0;
478 ON = 1;
479 }
480 optional State state = 1;
481}
482
483/**
484 * Logs Doze mode state change.
485 *
486 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800487 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700488 */
489message DeviceIdleModeStateChanged {
490 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800491 enum State {
492 DEVICE_IDLE_MODE_OFF = 0;
493 DEVICE_IDLE_MODE_LIGHT = 1;
494 DEVICE_IDLE_MODE_DEEP = 2;
495 }
496 optional State state = 1;
497}
498
499
500/**
501 * Logs state change of Doze mode including maintenance windows.
502 *
503 * Logged from:
504 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
505 */
506message DeviceIdlingModeStateChanged {
507 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
508 enum State {
509 DEVICE_IDLE_MODE_OFF = 0;
510 DEVICE_IDLE_MODE_LIGHT = 1;
511 DEVICE_IDLE_MODE_DEEP = 2;
512 }
513 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700514}
515
516/**
517 * Logs screen brightness level.
518 *
519 * Logged from:
520 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
521 */
522message ScreenBrightnessChanged {
523 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
524 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700525}
526
527/**
528 * Logs battery level (percent full, from 0 to 100).
529 *
530 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700531 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700532 */
533message BatteryLevelChanged {
534 // Battery level. Should be in [0, 100].
535 optional int32 battery_level = 1;
536}
537
538/**
539 * Logs change in charging status of the device.
540 *
541 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700542 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700543 */
544message ChargingStateChanged {
545 // TODO: Link directly to BatteryManager.java's constants (via a proto).
546 enum State {
547 BATTERY_STATUS_UNKNOWN = 1;
548 BATTERY_STATUS_CHARGING = 2;
549 BATTERY_STATUS_DISCHARGING = 3;
550 BATTERY_STATUS_NOT_CHARGING = 4;
551 BATTERY_STATUS_FULL = 5;
552 }
553 optional State charging_state = 1;
554}
555
556/**
557 * Logs whether the device is plugged in, and what power source it is using.
558 *
559 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700560 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700561 */
562message PluggedStateChanged {
563 // TODO: Link directly to BatteryManager.java's constants (via a proto).
564 enum State {
565 // Note that NONE is not in BatteryManager.java's constants.
566 BATTERY_PLUGGED_NONE = 0;
567 // Power source is an AC charger.
568 BATTERY_PLUGGED_AC = 1;
569 // Power source is a USB port.
570 BATTERY_PLUGGED_USB = 2;
571 // Power source is wireless.
572 BATTERY_PLUGGED_WIRELESS = 4;
573 }
574 optional State plugged_state = 1;
575}
576
577/**
578 * Logs the temperature of the device, in tenths of a degree Celsius.
579 *
580 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700581 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700582 */
583message DeviceTemperatureReported {
584 // Temperature in tenths of a degree C.
585 optional int32 temperature = 1;
586}
587
588// TODO: Define this more precisely.
589// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
590/**
591 * Logs when the device turns off or on.
592 *
593 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700594 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700595 */
596message DeviceOnStatusChanged {
597 enum State {
598 OFF = 0;
599 ON = 1;
600 }
601 optional State state = 1;
602}
603
604/**
605 * Logs when an app's wakeup alarm fires.
606 *
607 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700608 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700609 */
610message WakeupAlarmOccurred {
611 // TODO: Add attribution instead of uid?
612 optional int32 uid = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800613
614 // Name of the wakeup alarm.
615 optional string tag = 2;
616}
617
618/**
619 * Logs when an an app causes the mobile radio to change state.
620 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
621 *
622 * Logged from:
623 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
624 */
625message MobileRadioPowerStateChanged {
626 // TODO: Add attribution instead of uid?
627 optional int32 uid = 1;
628
629 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
630 enum PowerState {
631 DC_POWER_STATE_LOW = 1;
632 DC_POWER_STATE_MEDIUM = 2;
633 DC_POWER_STATE_HIGH = 3;
634 }
635 optional PowerState power_state = 2;
636}
637
638/**
639 * Logs when an an app causes the wifi radio to change state.
640 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
641 *
642 * Logged from:
643 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
644 */
645message WifiRadioPowerStateChanged {
646 // TODO: Add attribution instead of uid?
647 optional int32 uid = 1;
648
649 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
650 enum PowerState {
651 DC_POWER_STATE_LOW = 1;
652 DC_POWER_STATE_MEDIUM = 2;
653 DC_POWER_STATE_HIGH = 3;
654 }
655 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700656}
657
658/**
659 * Logs kernel wakeup reasons and aborts.
660 *
661 * Logged from:
662 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
663 */
664message KernelWakeupReported {
665 // Name of the kernel wakeup reason (or abort).
666 optional string wakeup_reason_name = 1;
667
668 // Duration (in microseconds) for the wake-up interrupt to be serviced.
669 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700670}
671
672/**
673 * Logs wifi locks held by an app.
674 *
675 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700676 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700677 */
678message WifiLockStateChanged {
679 // TODO: Add attribution instead of uid.
680 optional int32 uid = 1;
681
682 enum State {
683 OFF = 0;
684 ON = 1;
685 }
686 optional State state = 2;
687}
688
689/**
690 * Logs wifi signal strength changes.
691 *
692 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700693 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700694 */
695message WifiSignalStrengthChanged {
696 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
697 enum SignalStrength {
698 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
699 SIGNAL_STRENGTH_POOR = 1;
700 SIGNAL_STRENGTH_MODERATE = 2;
701 SIGNAL_STRENGTH_GOOD = 3;
702 SIGNAL_STRENGTH_GREAT = 4;
703 }
704 optional SignalStrength signal_strength = 1;
705}
706
707/**
708 * Logs wifi scans performed by an app.
709 *
710 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700711 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700712 */
713message WifiScanStateChanged {
714 // TODO: Add attribution instead of uid.
715 optional int32 uid = 1;
716
717 enum State {
718 OFF = 0;
719 ON = 1;
720 }
721 optional State state = 2;
722}
723
724/**
725 * Logs phone signal strength changes.
726 *
727 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700728 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700729 */
730message PhoneSignalStrengthChanged {
731 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
732 enum SignalStrength {
733 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
734 SIGNAL_STRENGTH_POOR = 1;
735 SIGNAL_STRENGTH_MODERATE = 2;
736 SIGNAL_STRENGTH_GOOD = 3;
737 SIGNAL_STRENGTH_GREAT = 4;
738 }
739 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700740}
741
742/**
743 * Logs that a setting was updated.
744 * Logged from:
745 * frameworks/base/core/java/android/provider/Settings.java
746 * The tag and is_default allow resetting of settings to default values based on the specified
747 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
748 */
749message SettingChanged {
750 // The name of the setting.
751 optional string setting = 1;
752
753 // The change being imposed on this setting. May represent a number, eg "3".
754 optional string value = 2;
755
756 // The new value of this setting. For most settings, this is same as value. For some settings,
757 // value is +X or -X where X represents an element in a set. For example, if the previous value
758 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
759 // The +/- feature is currently only used for location_providers_allowed.
760 optional string new_value = 3;
761
762 // The previous value of this setting.
763 optional string prev_value = 4;
764
765 // The tag used with the is_default for resetting sets of settings. This is generally null.
766 optional string tag = 5;
767
768 // 1 indicates that this setting with tag should be resettable.
769 optional int32 is_default = 6;
770
771 // The user ID associated. Defined in android/os/UserHandle.java
772 optional int32 user = 7;
773}
Chenjie Yub3dda412017-10-24 13:41:59 -0700774
Chenjie Yu05013b32017-11-21 10:21:41 -0800775/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700776 * Logs activity going to foreground or background
777 *
778 * Logged from:
779 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
780 */
781message ActivityForegroundStateChanged {
782 enum Activity {
783 MOVE_TO_BACKGROUND = 0;
784 MOVE_TO_FOREGROUND = 1;
785 }
786 optional int32 uid = 1;
787 optional string pkg_name = 2;
788 optional string class_name = 3;
789 optional Activity activity = 4;
790}
David Chenc8a43242017-10-17 16:23:28 -0700791
792/**
David Chen9e3808c2017-11-20 17:25:34 -0800793 * Logs when an error is written to dropbox.
794 * Logged from:
795 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
796 */
797message DropboxErrorChanged {
798 // The uid if available. -1 means not available.
799 optional int32 uid = 1;
800
801 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
802 optional string tag = 2;
803
804 // The name of the process.
805 optional string process_name = 3;
806
807 // The pid if available. -1 means not available.
808 optional int32 pid = 4;
809
810 // 1 indicates is instant app. -1 indicates Not applicable.
811 optional int32 is_instant_app = 5;
812
813 // The activity name if available.
814 optional string activity_name = 6;
815
816 // 1 indicates in foreground. -1 indicates not available.
817 optional int32 is_foreground = 7;
818}
819
David Chen0a368b22017-12-06 16:28:16 -0800820/*
821 * Allows other apps to push events into statsd.
822 * Logged from:
823 * frameworks/base/core/java/android/util/StatsLog.java
824 */
825message AppHook {
826 // The uid of the application that sent this custom atom.
827 optional int32 uid = 1;
828
829 // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
830 optional int32 label = 2;
831
832 // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
833 // predicates for the metrics).
834 enum State {
835 UNKNOWN = 0;
836 UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
837 STOP = 2;
838 START = 3;
839 }
840 optional State state = 3;
841}
842
David Chen9e3808c2017-11-20 17:25:34 -0800843/**
David Chenc8a43242017-10-17 16:23:28 -0700844 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
845 *
846 * Pulled from:
847 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
848 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800849message WifiBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -0700850 optional int32 uid = 1;
851
852 optional int64 rx_bytes = 2;
853
854 optional int64 rx_packets = 3;
855
856 optional int64 tx_bytes = 4;
857
858 optional int64 tx_packets = 5;
859}
860
861/**
862 * Pulls bytes transferred via wifi (separated by foreground and background usage).
863 *
864 * Pulled from:
865 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
866 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800867message WifiBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -0700868 optional int32 uid = 1;
869
870 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
871 optional int32 is_foreground = 2;
872
873 optional int64 rx_bytes = 3;
874
875 optional int64 rx_packets = 4;
876
877 optional int64 tx_bytes = 5;
878
879 optional int64 tx_packets = 6;
880}
881
882/**
883 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
884 *
885 * Pulled from:
886 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
887 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800888message MobileBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -0700889 optional int32 uid = 1;
890
891 optional int64 rx_bytes = 2;
892
893 optional int64 rx_packets = 3;
894
895 optional int64 tx_bytes = 4;
896
897 optional int64 tx_packets = 5;
898}
899
900/**
901 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
902 *
903 * Pulled from:
904 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
905 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800906message MobileBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -0700907 optional int32 uid = 1;
908
909 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
910 optional int32 is_foreground = 2;
911
912 optional int64 rx_bytes = 3;
913
914 optional int64 rx_packets = 4;
915
916 optional int64 tx_bytes = 5;
917
918 optional int64 tx_packets = 6;
919}
920
921/**
922 * Pulls the kernel wakelock durations. This atom is adapted from
923 * android/internal/os/KernelWakelockStats.java
924 *
925 * Pulled from:
926 * StatsCompanionService using KernelWakelockReader.
927 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800928message KernelWakelock {
David Chenc8a43242017-10-17 16:23:28 -0700929 optional string name = 1;
930
931 optional int32 count = 2;
932
933 optional int32 version = 3;
934
935 optional int64 time = 4;
936}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700937
Chenjie Yu05013b32017-11-21 10:21:41 -0800938/**
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700939 * Pulls PowerStatePlatformSleepState.
940 *
941 * Definition here:
942 * hardware/interfaces/power/1.0/types.hal
943 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800944message PlatformSleepState {
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700945 optional string name = 1;
946 optional uint64 residency_in_msec_since_boot = 2;
947 optional uint64 total_transitions = 3;
948 optional bool supported_only_in_suspend = 4;
949}
950
951/**
952 * Pulls PowerStateVoter.
953 *
954 * Definition here:
955 * hardware/interfaces/power/1.0/types.hal
956 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800957message SleepStateVoter {
958 optional string platform_sleep_state_name = 1;
959 optional string voter_name = 2;
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700960 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
961 optional uint64 total_number_of_times_voted_since_boot = 4;
962}
963
964/**
965 * Pulls PowerStateSubsystemSleepState.
966 *
967 * Definition here:
968 * hardware/interfaces/power/1.1/types.hal
969 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800970message SubsystemSleepState {
971 optional string subsystem_name = 1;
972 optional string subsystem_sleep_state_name = 2;
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700973 optional uint64 residency_in_msec_since_boot = 3;
974 optional uint64 total_transitions = 4;
975 optional uint64 last_entry_timestamp_ms = 5;
976 optional bool supported_only_in_suspend = 6;
977}
David Chen21582962017-11-01 17:32:46 -0700978
979/**
980 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
981 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
982 * attributed back to the parent (host) uid. One example is Chrome.
983 *
984 * Logged from:
985 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
986 */
987message IsolatedUidChanged {
988 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
989 optional int32 parent_uid = 1;
990
991 optional int32 isolated_uid = 2;
992
993 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
994 // be removed before if it's used for another parent uid.
995 optional int32 is_create = 3;
996}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700997
Chenjie Yu05013b32017-11-21 10:21:41 -0800998/**
Chenjie Yu7f8def92017-11-03 09:33:15 -0700999 * Pulls Cpu time per frequency.
1000 * Note: this should be pulled for gauge metric only, without condition.
1001 * The puller keeps internal state of last values. It should not be pulled by
1002 * different metrics.
1003 * The pulled data is delta of cpu time from last pull, calculated as
1004 * following:
1005 * if current time is larger than last value, take delta between the two.
1006 * if current time is smaller than last value, there must be a cpu
1007 * hotplug event, and the current time is taken as delta.
1008 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001009message CpuTimePerFreq {
Chenjie Yu7f8def92017-11-03 09:33:15 -07001010 optional uint32 cluster = 1;
1011 optional uint32 freq_index = 2;
Chenjie Yu31d14d72017-12-12 17:54:33 -08001012 optional uint64 time_ms = 3;
Chenjie Yu7f8def92017-11-03 09:33:15 -07001013}
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001014
Chenjie Yu05013b32017-11-21 10:21:41 -08001015/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001016 * Pulls Cpu Time Per Uid.
1017 * Note that isolated process uid time should be attributed to host uids.
1018 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001019message CpuTimePerUid {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001020 optional uint64 uid = 1;
1021 optional uint64 user_time_ms = 2;
1022 optional uint64 sys_time_ms = 3;
1023}
1024
1025/**
1026 * Pulls Cpu Time Per Uid per frequency.
1027 * Note that isolated process uid time should be attributed to host uids.
1028 * For each uid, we order the time by descending frequencies.
1029 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001030message CpuTimePerUidFreq {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001031 optional uint64 uid = 1;
1032 optional uint64 freq_idx = 2;
1033 optional uint64 time_ms = 3;
1034}
Hugo Benichi884970e2017-11-14 22:42:46 +09001035
1036/*
1037 * Logs the reception of an incoming network packet causing the main system to wake up for
1038 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1039 * and processed by WakeupController.cpp.
1040 */
1041message PacketWakeupOccurred {
1042 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1043 // delivered nowhere.
1044 optional int32 uid = 1;
1045 // The interface name on which the packet was received.
1046 optional string iface = 2;
1047 // The ethertype value of the packet.
1048 optional int32 ethertype = 3;
1049 // String representation of the destination MAC address of the packet.
1050 optional string destination_hardware_address = 4;
1051 // String representation of the source address of the packet if this was an IP packet.
1052 optional string source_ip = 5;
1053 // String representation of the destination address of the packet if this was an IP packet.
1054 optional string destination_ip = 6;
1055 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1056 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1057 // families.
1058 optional int32 ip_next_header = 7;
1059 // The source port if this was a TCP or UDP packet.
1060 optional int32 source_port = 8;
1061 // The destination port if this was a TCP or UDP packet.
1062 optional int32 destination_port = 9;
1063}
Chenjie Yu05013b32017-11-21 10:21:41 -08001064
1065/**
1066 * Pulls Wifi Controller Activity Energy Info
1067 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001068message WifiActivityEnergyInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001069 // timestamp(wall clock) of record creation
1070 optional uint64 timestamp_ms = 1;
1071 // stack reported state
1072 // TODO: replace this with proto enum
1073 optional int32 stack_state = 2;
1074 // tx time in ms
1075 optional uint64 controller_tx_time_ms = 3;
1076 // rx time in ms
1077 optional uint64 controller_rx_time_ms = 4;
1078 // idle time in ms
1079 optional uint64 controller_idle_time_ms = 5;
1080 // product of current(mA), voltage(V) and time(ms)
1081 optional uint64 controller_energy_used = 6;
1082}
1083
1084/**
1085 * Pulls Modem Activity Energy Info
1086 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001087message ModemActivityInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001088 // timestamp(wall clock) of record creation
1089 optional uint64 timestamp_ms = 1;
1090 // sleep time in ms.
1091 optional uint64 sleep_time_ms = 2;
1092 // idle time in ms
1093 optional uint64 controller_idle_time_ms = 3;
1094 /**
1095 * Tx power index
1096 * index 0 = tx_power < 0dBm
1097 * index 1 = 0dBm < tx_power < 5dBm
1098 * index 2 = 5dBm < tx_power < 15dBm
1099 * index 3 = 15dBm < tx_power < 20dBm
1100 * index 4 = tx_power > 20dBm
1101 */
1102 // tx time in ms at power level 0
1103 optional uint64 controller_tx_time_pl0_ms = 4;
1104 // tx time in ms at power level 1
1105 optional uint64 controller_tx_time_pl1_ms = 5;
1106 // tx time in ms at power level 2
1107 optional uint64 controller_tx_time_pl2_ms = 6;
1108 // tx time in ms at power level 3
1109 optional uint64 controller_tx_time_pl3_ms = 7;
1110 // tx time in ms at power level 4
1111 optional uint64 controller_tx_time_pl4_ms = 8;
1112 // rx time in ms at power level 5
1113 optional uint64 controller_rx_time_ms = 9;
1114 // product of current(mA), voltage(V) and time(ms)
1115 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001116}