blob: 617919d7b69c667c8fbb64a497fde7a950ae7081 [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;
Bookatzc1a050a2017-10-10 15:49:28 -070082 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000083 }
David Chenc8a43242017-10-17 16:23:28 -070084
85 // Pulled events will start at field 1000.
86 oneof pulled {
87 WifiBytesTransferred wifi_bytes_transferred = 1000;
88 WifiBytesTransferredByFgBg wifi_bytes_transferred_by_fg_bg = 1001;
89 MobileBytesTransferred mobile_bytes_transferred = 1002;
90 MobileBytesTransferredByFgBg mobile_bytes_transferred_by_fg_bg = 1003;
Chenjie Yu5305e1d2017-10-31 13:49:36 -070091 KernelWakelockPulled kernel_wakelock_pulled = 1004;
92 PowerStatePlatformSleepStatePulled power_state_platform_sleep_state_pulled = 1005;
93 PowerStateVoterPulled power_state_voter_pulled = 1006;
94 PowerStateSubsystemSleepStatePulled power_state_subsystem_sleep_state_pulled = 1007;
Chenjie Yu7f8def92017-11-03 09:33:15 -070095 CpuTimePerFreqPulled cpu_time_per_freq_pulled = 1008;
Chenjie Yue33bc3b2017-11-06 17:56:44 -080096 CpuTimePerUidPulled cpu_time_per_uid_pulled = 1009;
97 CpuTimePerUidFreqPulled cpu_time_per_uid_freq_pulled = 1010;
Chenjie Yu05013b32017-11-21 10:21:41 -080098 WifiActivityEnergyInfoPulled wifi_activity_energy_info_pulled = 1011;
99 ModemActivityInfoPulled modem_activity_info_pulled = 1012;
Yangster-mac7604aea2017-12-11 22:55:49 -0800100 AttributionChainDummyAtom attribution_chain_dummy_atom = 10000;
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/**
Yangster-mac7604aea2017-12-11 22:55:49 -0800105 * An attribution represents an application or module that is part of process where a particular bit
106 * of work is done.
Yao Chend54f9dd2017-10-17 17:37:48 +0000107 */
Yangster-mac7604aea2017-12-11 22:55:49 -0800108message Attribution {
109 // The uid for an application or module.
110 optional int32 uid = 1;
111 // The string tag for the attribution node.
112 optional string tag = 2;
113}
114
115/**
116 * An attribution chain represents the chained attributions of applications or modules that
117 * resulted in a particular bit of work being done.
118 * The ordering of the attributions is that of calls, that is uid = [A, B, C] if A calls B that
119 * calls C.
120 */
121message AttributionChain {
122 repeated Attribution attribution = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700123}
124
Yao Chend54f9dd2017-10-17 17:37:48 +0000125/*
126 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800127 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000128 *
129 * RULES:
130 * - The field ids for each atom must start at 1, and count upwards by 1.
131 * Skipping field ids is not allowed.
132 * - These form an API, so renaming, renumbering or removing fields is
133 * not allowed between android releases. (This is not currently enforced,
134 * but there will be a tool to enforce this restriction).
135 * - The types must be built-in protocol buffer types, namely, no sub-messages
136 * are allowed (yet). The bytes type is also not allowed.
137 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800138 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000139 * - If an atom represents work that can be attributed to an app, there can
Yangster-mac7604aea2017-12-11 22:55:49 -0800140 * be exactly one AttributionChain field. It must be field number 1.
Yao Chend54f9dd2017-10-17 17:37:48 +0000141 * - A field that is a uid should be a string field, tagged with the [xxx]
142 * annotation. The generated code on android will be represented by UIDs,
143 * and those UIDs will be translated in xxx to those strings.
144 *
145 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700146 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000147 * - If there is a UID, it goes first. Think in an object-oriented fashion.
148 * *****************************************************************************
149 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700150
Yangster-mac7604aea2017-12-11 22:55:49 -0800151message AttributionChainDummyAtom {
152 optional AttributionChain attribution_chain = 1;
153 optional int32 value = 2;
154}
155
Yao Chend54f9dd2017-10-17 17:37:48 +0000156/**
157 * Logs when the screen state changes.
158 *
159 * Logged from:
160 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
161 */
162message ScreenStateChanged {
163 // TODO: Use the real screen state.
164 enum State {
165 STATE_UNKNOWN = 0;
166 STATE_OFF = 1;
167 STATE_ON = 2;
168 STATE_DOZE = 3;
169 STATE_DOZE_SUSPEND = 4;
170 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800171 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000172 }
173 // New screen state.
174 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700175}
Yao Chend54f9dd2017-10-17 17:37:48 +0000176
177/**
Bookatzc1a050a2017-10-10 15:49:28 -0700178 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000179 *
180 * Logged from:
181 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
182 */
Bookatzc1a050a2017-10-10 15:49:28 -0700183message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000184 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
185
186 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700187 // TODO: Use the real (mapped) process states.
Joe Onorato62c220b2017-11-18 20:32:56 -0800188 optional android.app.ProcessState state = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000189}
190
191/**
Bookatzc1a050a2017-10-10 15:49:28 -0700192 * Logs that a process started, finished, crashed, or ANRed.
193 *
194 * Logged from:
195 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
196 */
197message ProcessLifeCycleStateChanged {
198 // TODO: Use the real (mapped) process states.
199 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
200
201 // TODO: What is this?
202 optional string name = 2;
203
Bookatzddccf0a2017-11-28 16:48:14 -0800204 // What lifecycle state the process changed to.
205 // This enum is specific to atoms.proto.
206 enum Event {
207 PROCESS_FINISHED = 0;
208 PROCESS_STARTED = 1;
209 PROCESS_CRASHED = 2;
210 PROCESS_ANRED = 3;
211 }
212 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700213}
214
Bookatzc1a050a2017-10-10 15:49:28 -0700215/**
216 * Logs when the ble scan state changes.
217 *
218 * Logged from:
219 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
220 */
221message BleScanStateChanged {
222 // TODO: Add attribution instead of uid.
223 optional int32 uid = 1;
224
225 enum State {
226 OFF = 0;
227 ON = 1;
228 }
229 optional State state = 2;
230}
231
232/**
233 * Logs when an unoptimized ble scan state changes.
234 *
235 * Logged from:
236 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
237 */
238// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
239message BleUnoptimizedScanStateChanged {
240 // TODO: Add attribution instead of uid.
241 optional int32 uid = 1;
242
243 enum State {
244 OFF = 0;
245 ON = 1;
246 }
247 optional State state = 2;
248}
249
250/**
251 * Logs reporting of a ble scan finding results.
252 *
253 * Logged from:
254 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
255 */
256// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
257message BleScanResultReceived {
258 // TODO: Add attribution instead of uid.
259 optional int32 uid = 1;
260
261 // Number of ble scan results returned.
262 optional int32 num_of_results = 2;
263}
264
265/**
266 * Logs when a sensor state changes.
267 *
268 * Logged from:
269 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
270 */
271message SensorStateChanged {
272 // TODO: Add attribution instead of uid.
273 optional int32 uid = 1;
274
275 // TODO: Is there a way to get the actual name of the sensor?
276 // The id (int) of the sensor.
277 optional int32 sensor_id = 2;
278
279 enum State {
280 OFF = 0;
281 ON = 1;
282 }
283 optional State state = 3;
284}
285
286
287/**
288 * Logs when GPS state changes.
289 *
290 * Logged from:
291 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
292 */
293message GpsScanStateChanged {
294 // TODO: Add attribution instead of uid.
295 optional int32 uid = 1;
296
297 enum State {
298 OFF = 0;
299 ON = 1;
300 }
301 optional State state = 2;
302}
303
304
305/**
306 * Logs when a sync manager sync state changes.
307 *
308 * Logged from:
309 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
310 */
311message SyncStateChanged {
312 // TODO: Add attribution instead of uid.
313 optional int32 uid = 1;
314
315 // Name of the sync (as named in the app)
316 optional string name = 2;
317
318 enum State {
319 OFF = 0;
320 ON = 1;
321 }
322 optional State state = 3;
323}
324
325/**
326 * Logs when a job scheduler job state changes.
327 *
328 * Logged from:
329 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
330 */
331message ScheduledJobStateChanged {
332 // TODO: Add attribution instead of uid.
333 optional int32 uid = 1;
334
335 // Name of the job (as named in the app)
336 optional string name = 2;
337
338 enum State {
339 OFF = 0;
340 ON = 1;
341 }
342 optional State state = 3;
343
344 // TODO: Consider adding the stopReason (int)
345}
346
347/**
348 * Logs when the audio state changes.
349 *
350 * Logged from:
351 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
352 */
353message AudioStateChanged {
354 // TODO: Add attribution instead of uid.
355 optional int32 uid = 1;
356
357 enum State {
358 OFF = 0;
359 ON = 1;
360 }
361 optional State state = 2;
362}
363
364/**
365 * Logs when the video codec state changes.
366 *
367 * Logged from:
368 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
369 */
370message MediaCodecActivityChanged {
371 // TODO: Add attribution instead of uid.
372 optional int32 uid = 1;
373
374 enum State {
375 OFF = 0;
376 ON = 1;
377 }
378 optional State state = 2;
379}
380
381/**
382 * Logs when the flashlight state changes.
383 *
384 * Logged from:
385 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
386 */
387message FlashlightStateChanged {
388 // TODO: Add attribution instead of uid.
389 optional int32 uid = 1;
390
391 enum State {
392 OFF = 0;
393 ON = 1;
394 }
395 optional State state = 2;
396}
397
398/**
399 * Logs when the camera state changes.
400 *
401 * Logged from:
402 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
403 */
404message CameraStateChanged {
405 // TODO: Add attribution instead of uid.
406 optional int32 uid = 1;
407
408 enum State {
409 OFF = 0;
410 ON = 1;
411 }
412 optional State state = 2;
413}
414
415/**
416 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000417 *
418 * Logged from:
419 * TODO
420 */
Bookatzd6746242017-10-24 18:39:35 -0700421message WakelockStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000422 // TODO: Add attribution instead of uid.
423 optional int32 uid = 1;
424
Bookatzc1a050a2017-10-10 15:49:28 -0700425 // Type of wakelock.
426 enum Type {
427 PARTIAL = 0;
428 FULL = 1;
429 WINDOW = 2;
430 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800431 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700432
433 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
434 optional string tag = 3;
435
436 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800437 RELEASE = 0;
438 ACQUIRE = 1;
439 CHANGE_RELEASE = 2;
440 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700441 }
442 optional State state = 4;
443}
444
445/**
Bookatzc1a050a2017-10-10 15:49:28 -0700446 * Logs when a partial wakelock is considered 'long' (over 1 min).
447 *
448 * Logged from:
449 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
450 */
451message LongPartialWakelockStateChanged {
452 // TODO: Add attribution instead of uid?
453 optional int32 uid = 1;
454
Yao Chend54f9dd2017-10-17 17:37:48 +0000455 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
456 optional string tag = 2;
457
Bookatzc1a050a2017-10-10 15:49:28 -0700458 // TODO: I have no idea what this is.
459 optional string history_tag = 3;
460
461 enum State {
462 OFF = 0;
463 ON = 1;
464 }
465 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000466}
467
Bookatzc1a050a2017-10-10 15:49:28 -0700468/**
469 * Logs Battery Saver state change.
470 *
471 * Logged from:
472 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
473 */
474message BatterySaverModeStateChanged {
475 enum State {
476 OFF = 0;
477 ON = 1;
478 }
479 optional State state = 1;
480}
481
482/**
483 * Logs Doze mode state change.
484 *
485 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800486 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700487 */
488message DeviceIdleModeStateChanged {
489 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800490 enum State {
491 DEVICE_IDLE_MODE_OFF = 0;
492 DEVICE_IDLE_MODE_LIGHT = 1;
493 DEVICE_IDLE_MODE_DEEP = 2;
494 }
495 optional State state = 1;
496}
497
498
499/**
500 * Logs state change of Doze mode including maintenance windows.
501 *
502 * Logged from:
503 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
504 */
505message DeviceIdlingModeStateChanged {
506 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
507 enum State {
508 DEVICE_IDLE_MODE_OFF = 0;
509 DEVICE_IDLE_MODE_LIGHT = 1;
510 DEVICE_IDLE_MODE_DEEP = 2;
511 }
512 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700513}
514
515/**
516 * Logs screen brightness level.
517 *
518 * Logged from:
519 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
520 */
521message ScreenBrightnessChanged {
522 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
523 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700524}
525
526/**
527 * Logs battery level (percent full, from 0 to 100).
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 BatteryLevelChanged {
533 // Battery level. Should be in [0, 100].
534 optional int32 battery_level = 1;
535}
536
537/**
538 * Logs change in charging status of the device.
539 *
540 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700541 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700542 */
543message ChargingStateChanged {
544 // TODO: Link directly to BatteryManager.java's constants (via a proto).
545 enum State {
546 BATTERY_STATUS_UNKNOWN = 1;
547 BATTERY_STATUS_CHARGING = 2;
548 BATTERY_STATUS_DISCHARGING = 3;
549 BATTERY_STATUS_NOT_CHARGING = 4;
550 BATTERY_STATUS_FULL = 5;
551 }
552 optional State charging_state = 1;
553}
554
555/**
556 * Logs whether the device is plugged in, and what power source it is using.
557 *
558 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700559 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700560 */
561message PluggedStateChanged {
562 // TODO: Link directly to BatteryManager.java's constants (via a proto).
563 enum State {
564 // Note that NONE is not in BatteryManager.java's constants.
565 BATTERY_PLUGGED_NONE = 0;
566 // Power source is an AC charger.
567 BATTERY_PLUGGED_AC = 1;
568 // Power source is a USB port.
569 BATTERY_PLUGGED_USB = 2;
570 // Power source is wireless.
571 BATTERY_PLUGGED_WIRELESS = 4;
572 }
573 optional State plugged_state = 1;
574}
575
576/**
577 * Logs the temperature of the device, in tenths of a degree Celsius.
578 *
579 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700580 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700581 */
582message DeviceTemperatureReported {
583 // Temperature in tenths of a degree C.
584 optional int32 temperature = 1;
585}
586
587// TODO: Define this more precisely.
588// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
589/**
590 * Logs when the device turns off or on.
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 DeviceOnStatusChanged {
596 enum State {
597 OFF = 0;
598 ON = 1;
599 }
600 optional State state = 1;
601}
602
603/**
604 * Logs when an app's wakeup alarm fires.
605 *
606 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700607 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700608 */
609message WakeupAlarmOccurred {
610 // TODO: Add attribution instead of uid?
611 optional int32 uid = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800612
613 // Name of the wakeup alarm.
614 optional string tag = 2;
615}
616
617/**
618 * Logs when an an app causes the mobile radio to change state.
619 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
620 *
621 * Logged from:
622 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
623 */
624message MobileRadioPowerStateChanged {
625 // TODO: Add attribution instead of uid?
626 optional int32 uid = 1;
627
628 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
629 enum PowerState {
630 DC_POWER_STATE_LOW = 1;
631 DC_POWER_STATE_MEDIUM = 2;
632 DC_POWER_STATE_HIGH = 3;
633 }
634 optional PowerState power_state = 2;
635}
636
637/**
638 * Logs when an an app causes the wifi radio to change state.
639 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
640 *
641 * Logged from:
642 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
643 */
644message WifiRadioPowerStateChanged {
645 // TODO: Add attribution instead of uid?
646 optional int32 uid = 1;
647
648 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
649 enum PowerState {
650 DC_POWER_STATE_LOW = 1;
651 DC_POWER_STATE_MEDIUM = 2;
652 DC_POWER_STATE_HIGH = 3;
653 }
654 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700655}
656
657/**
658 * Logs kernel wakeup reasons and aborts.
659 *
660 * Logged from:
661 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
662 */
663message KernelWakeupReported {
664 // Name of the kernel wakeup reason (or abort).
665 optional string wakeup_reason_name = 1;
666
667 // Duration (in microseconds) for the wake-up interrupt to be serviced.
668 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700669}
670
671/**
672 * Logs wifi locks held by an app.
673 *
674 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700675 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700676 */
677message WifiLockStateChanged {
678 // TODO: Add attribution instead of uid.
679 optional int32 uid = 1;
680
681 enum State {
682 OFF = 0;
683 ON = 1;
684 }
685 optional State state = 2;
686}
687
688/**
689 * Logs wifi signal strength changes.
690 *
691 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700692 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700693 */
694message WifiSignalStrengthChanged {
695 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
696 enum SignalStrength {
697 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
698 SIGNAL_STRENGTH_POOR = 1;
699 SIGNAL_STRENGTH_MODERATE = 2;
700 SIGNAL_STRENGTH_GOOD = 3;
701 SIGNAL_STRENGTH_GREAT = 4;
702 }
703 optional SignalStrength signal_strength = 1;
704}
705
706/**
707 * Logs wifi scans performed by an app.
708 *
709 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700710 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700711 */
712message WifiScanStateChanged {
713 // TODO: Add attribution instead of uid.
714 optional int32 uid = 1;
715
716 enum State {
717 OFF = 0;
718 ON = 1;
719 }
720 optional State state = 2;
721}
722
723/**
724 * Logs phone signal strength changes.
725 *
726 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700727 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700728 */
729message PhoneSignalStrengthChanged {
730 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
731 enum SignalStrength {
732 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
733 SIGNAL_STRENGTH_POOR = 1;
734 SIGNAL_STRENGTH_MODERATE = 2;
735 SIGNAL_STRENGTH_GOOD = 3;
736 SIGNAL_STRENGTH_GREAT = 4;
737 }
738 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700739}
740
741/**
742 * Logs that a setting was updated.
743 * Logged from:
744 * frameworks/base/core/java/android/provider/Settings.java
745 * The tag and is_default allow resetting of settings to default values based on the specified
746 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
747 */
748message SettingChanged {
749 // The name of the setting.
750 optional string setting = 1;
751
752 // The change being imposed on this setting. May represent a number, eg "3".
753 optional string value = 2;
754
755 // The new value of this setting. For most settings, this is same as value. For some settings,
756 // value is +X or -X where X represents an element in a set. For example, if the previous value
757 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
758 // The +/- feature is currently only used for location_providers_allowed.
759 optional string new_value = 3;
760
761 // The previous value of this setting.
762 optional string prev_value = 4;
763
764 // The tag used with the is_default for resetting sets of settings. This is generally null.
765 optional string tag = 5;
766
767 // 1 indicates that this setting with tag should be resettable.
768 optional int32 is_default = 6;
769
770 // The user ID associated. Defined in android/os/UserHandle.java
771 optional int32 user = 7;
772}
Chenjie Yub3dda412017-10-24 13:41:59 -0700773
Chenjie Yu05013b32017-11-21 10:21:41 -0800774/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700775 * Logs activity going to foreground or background
776 *
777 * Logged from:
778 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
779 */
780message ActivityForegroundStateChanged {
781 enum Activity {
782 MOVE_TO_BACKGROUND = 0;
783 MOVE_TO_FOREGROUND = 1;
784 }
785 optional int32 uid = 1;
786 optional string pkg_name = 2;
787 optional string class_name = 3;
788 optional Activity activity = 4;
789}
David Chenc8a43242017-10-17 16:23:28 -0700790
791/**
David Chen9e3808c2017-11-20 17:25:34 -0800792 * Logs when an error is written to dropbox.
793 * Logged from:
794 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
795 */
796message DropboxErrorChanged {
797 // The uid if available. -1 means not available.
798 optional int32 uid = 1;
799
800 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
801 optional string tag = 2;
802
803 // The name of the process.
804 optional string process_name = 3;
805
806 // The pid if available. -1 means not available.
807 optional int32 pid = 4;
808
809 // 1 indicates is instant app. -1 indicates Not applicable.
810 optional int32 is_instant_app = 5;
811
812 // The activity name if available.
813 optional string activity_name = 6;
814
815 // 1 indicates in foreground. -1 indicates not available.
816 optional int32 is_foreground = 7;
817}
818
819/**
David Chenc8a43242017-10-17 16:23:28 -0700820 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
821 *
822 * Pulled from:
823 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
824 */
825message WifiBytesTransferred {
826 optional int32 uid = 1;
827
828 optional int64 rx_bytes = 2;
829
830 optional int64 rx_packets = 3;
831
832 optional int64 tx_bytes = 4;
833
834 optional int64 tx_packets = 5;
835}
836
837/**
838 * Pulls bytes transferred via wifi (separated by foreground and background usage).
839 *
840 * Pulled from:
841 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
842 */
843message WifiBytesTransferredByFgBg {
844 optional int32 uid = 1;
845
846 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
847 optional int32 is_foreground = 2;
848
849 optional int64 rx_bytes = 3;
850
851 optional int64 rx_packets = 4;
852
853 optional int64 tx_bytes = 5;
854
855 optional int64 tx_packets = 6;
856}
857
858/**
859 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
860 *
861 * Pulled from:
862 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
863 */
864message MobileBytesTransferred {
865 optional int32 uid = 1;
866
867 optional int64 rx_bytes = 2;
868
869 optional int64 rx_packets = 3;
870
871 optional int64 tx_bytes = 4;
872
873 optional int64 tx_packets = 5;
874}
875
876/**
877 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
878 *
879 * Pulled from:
880 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
881 */
882message MobileBytesTransferredByFgBg {
883 optional int32 uid = 1;
884
885 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
886 optional int32 is_foreground = 2;
887
888 optional int64 rx_bytes = 3;
889
890 optional int64 rx_packets = 4;
891
892 optional int64 tx_bytes = 5;
893
894 optional int64 tx_packets = 6;
895}
896
897/**
898 * Pulls the kernel wakelock durations. This atom is adapted from
899 * android/internal/os/KernelWakelockStats.java
900 *
901 * Pulled from:
902 * StatsCompanionService using KernelWakelockReader.
903 */
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700904message KernelWakelockPulled {
David Chenc8a43242017-10-17 16:23:28 -0700905 optional string name = 1;
906
907 optional int32 count = 2;
908
909 optional int32 version = 3;
910
911 optional int64 time = 4;
912}
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700913
Chenjie Yu05013b32017-11-21 10:21:41 -0800914/**
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700915 * Pulls PowerStatePlatformSleepState.
916 *
917 * Definition here:
918 * hardware/interfaces/power/1.0/types.hal
919 */
920message PowerStatePlatformSleepStatePulled {
921 optional string name = 1;
922 optional uint64 residency_in_msec_since_boot = 2;
923 optional uint64 total_transitions = 3;
924 optional bool supported_only_in_suspend = 4;
925}
926
927/**
928 * Pulls PowerStateVoter.
929 *
930 * Definition here:
931 * hardware/interfaces/power/1.0/types.hal
932 */
933message PowerStateVoterPulled {
934 optional string power_state_platform_sleep_state_name = 1;
935 optional string power_state_voter_name = 2;
936 optional uint64 total_time_in_msec_voted_for_since_boot = 3;
937 optional uint64 total_number_of_times_voted_since_boot = 4;
938}
939
940/**
941 * Pulls PowerStateSubsystemSleepState.
942 *
943 * Definition here:
944 * hardware/interfaces/power/1.1/types.hal
945 */
946message PowerStateSubsystemSleepStatePulled {
947 optional string power_state_subsystem_name = 1;
948 optional string power_state_subsystem_sleep_state_name = 2;
949 optional uint64 residency_in_msec_since_boot = 3;
950 optional uint64 total_transitions = 4;
951 optional uint64 last_entry_timestamp_ms = 5;
952 optional bool supported_only_in_suspend = 6;
953}
David Chen21582962017-11-01 17:32:46 -0700954
955/**
956 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
957 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
958 * attributed back to the parent (host) uid. One example is Chrome.
959 *
960 * Logged from:
961 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
962 */
963message IsolatedUidChanged {
964 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
965 optional int32 parent_uid = 1;
966
967 optional int32 isolated_uid = 2;
968
969 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
970 // be removed before if it's used for another parent uid.
971 optional int32 is_create = 3;
972}
Chenjie Yu7f8def92017-11-03 09:33:15 -0700973
Chenjie Yu05013b32017-11-21 10:21:41 -0800974/**
Chenjie Yu7f8def92017-11-03 09:33:15 -0700975 * Pulls Cpu time per frequency.
976 * Note: this should be pulled for gauge metric only, without condition.
977 * The puller keeps internal state of last values. It should not be pulled by
978 * different metrics.
979 * The pulled data is delta of cpu time from last pull, calculated as
980 * following:
981 * if current time is larger than last value, take delta between the two.
982 * if current time is smaller than last value, there must be a cpu
983 * hotplug event, and the current time is taken as delta.
984 */
985message CpuTimePerFreqPulled {
986 optional uint32 cluster = 1;
987 optional uint32 freq_index = 2;
988 optional uint64 time = 3;
989}
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800990
Chenjie Yu05013b32017-11-21 10:21:41 -0800991/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -0800992 * Pulls Cpu Time Per Uid.
993 * Note that isolated process uid time should be attributed to host uids.
994 */
995message CpuTimePerUidPulled {
996 optional uint64 uid = 1;
997 optional uint64 user_time_ms = 2;
998 optional uint64 sys_time_ms = 3;
999}
1000
1001/**
1002 * Pulls Cpu Time Per Uid per frequency.
1003 * Note that isolated process uid time should be attributed to host uids.
1004 * For each uid, we order the time by descending frequencies.
1005 */
1006message CpuTimePerUidFreqPulled {
1007 optional uint64 uid = 1;
1008 optional uint64 freq_idx = 2;
1009 optional uint64 time_ms = 3;
1010}
Hugo Benichi884970e2017-11-14 22:42:46 +09001011
1012/*
1013 * Logs the reception of an incoming network packet causing the main system to wake up for
1014 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1015 * and processed by WakeupController.cpp.
1016 */
1017message PacketWakeupOccurred {
1018 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1019 // delivered nowhere.
1020 optional int32 uid = 1;
1021 // The interface name on which the packet was received.
1022 optional string iface = 2;
1023 // The ethertype value of the packet.
1024 optional int32 ethertype = 3;
1025 // String representation of the destination MAC address of the packet.
1026 optional string destination_hardware_address = 4;
1027 // String representation of the source address of the packet if this was an IP packet.
1028 optional string source_ip = 5;
1029 // String representation of the destination address of the packet if this was an IP packet.
1030 optional string destination_ip = 6;
1031 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1032 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1033 // families.
1034 optional int32 ip_next_header = 7;
1035 // The source port if this was a TCP or UDP packet.
1036 optional int32 source_port = 8;
1037 // The destination port if this was a TCP or UDP packet.
1038 optional int32 destination_port = 9;
1039}
Chenjie Yu05013b32017-11-21 10:21:41 -08001040
1041/**
1042 * Pulls Wifi Controller Activity Energy Info
1043 */
1044message WifiActivityEnergyInfoPulled {
1045 // timestamp(wall clock) of record creation
1046 optional uint64 timestamp_ms = 1;
1047 // stack reported state
1048 // TODO: replace this with proto enum
1049 optional int32 stack_state = 2;
1050 // tx time in ms
1051 optional uint64 controller_tx_time_ms = 3;
1052 // rx time in ms
1053 optional uint64 controller_rx_time_ms = 4;
1054 // idle time in ms
1055 optional uint64 controller_idle_time_ms = 5;
1056 // product of current(mA), voltage(V) and time(ms)
1057 optional uint64 controller_energy_used = 6;
1058}
1059
1060/**
1061 * Pulls Modem Activity Energy Info
1062 */
1063message ModemActivityInfoPulled {
1064 // timestamp(wall clock) of record creation
1065 optional uint64 timestamp_ms = 1;
1066 // sleep time in ms.
1067 optional uint64 sleep_time_ms = 2;
1068 // idle time in ms
1069 optional uint64 controller_idle_time_ms = 3;
1070 /**
1071 * Tx power index
1072 * index 0 = tx_power < 0dBm
1073 * index 1 = 0dBm < tx_power < 5dBm
1074 * index 2 = 5dBm < tx_power < 15dBm
1075 * index 3 = 15dBm < tx_power < 20dBm
1076 * index 4 = tx_power > 20dBm
1077 */
1078 // tx time in ms at power level 0
1079 optional uint64 controller_tx_time_pl0_ms = 4;
1080 // tx time in ms at power level 1
1081 optional uint64 controller_tx_time_pl1_ms = 5;
1082 // tx time in ms at power level 2
1083 optional uint64 controller_tx_time_pl2_ms = 6;
1084 // tx time in ms at power level 3
1085 optional uint64 controller_tx_time_pl3_ms = 7;
1086 // tx time in ms at power level 4
1087 optional uint64 controller_tx_time_pl4_ms = 8;
1088 // rx time in ms at power level 5
1089 optional uint64 controller_rx_time_ms = 9;
1090 // product of current(mA), voltage(V) and time(ms)
1091 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001092}