blob: 2e3560a221c2d54191a0ddcca640c2d747b83790 [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
Bookatzdb026a22018-01-10 19:01:56 -080024import "frameworks/base/core/proto/android/app/enums.proto";
Bookatz1a1b0462018-01-12 11:47:03 -080025import "frameworks/base/core/proto/android/os/enums.proto";
Bookatz8bdae8d2018-01-16 11:24:30 -080026import "frameworks/base/core/proto/android/server/enums.proto";
Bookatz1a1b0462018-01-12 11:47:03 -080027import "frameworks/base/core/proto/android/telephony/enums.proto";
28import "frameworks/base/core/proto/android/view/enums.proto";
Joe Onorato62c220b2017-11-18 20:32:56 -080029
Yao Chend54f9dd2017-10-17 17:37:48 +000030/**
Stefan Lafonae2df012017-11-14 09:17:21 -080031 * The master atom class. This message defines all of the available
Yao Chend54f9dd2017-10-17 17:37:48 +000032 * raw stats log events from the Android system, also known as "atoms."
33 *
34 * This field contains a single oneof with all of the available messages.
35 * The stats-log-api-gen tool runs as part of the Android build and
36 * generates the android.util.StatsLog class, which contains the constants
37 * and methods that Android uses to log.
38 *
Stefan Lafonae2df012017-11-14 09:17:21 -080039 * This Atom class is not actually built into the Android system.
Yao Chend54f9dd2017-10-17 17:37:48 +000040 * Instead, statsd on Android constructs these messages synthetically,
41 * in the format defined here and in stats_log.proto.
42 */
Stefan Lafonae2df012017-11-14 09:17:21 -080043message Atom {
44 // Pushed atoms start at 2.
David Chenc8a43242017-10-17 16:23:28 -070045 oneof pushed {
Bookatzc1a050a2017-10-10 15:49:28 -070046 // For StatsLog reasons, 1 is illegal and will not work. Must start at 2.
47 BleScanStateChanged ble_scan_state_changed = 2;
48 BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
49 BleScanResultReceived ble_scan_result_received = 4;
50 SensorStateChanged sensor_state_changed = 5;
Bookatzdb026a22018-01-10 19:01:56 -080051 GpsScanStateChanged gps_scan_state_changed = 6;
Bookatzc1a050a2017-10-10 15:49:28 -070052 SyncStateChanged sync_state_changed = 7;
53 ScheduledJobStateChanged scheduled_job_state_changed = 8;
54 ScreenBrightnessChanged screen_brightness_changed = 9;
Bookatzd6746242017-10-24 18:39:35 -070055 WakelockStateChanged wakelock_state_changed = 10;
Bookatzddccf0a2017-11-28 16:48:14 -080056 LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 11;
57 MobileRadioPowerStateChanged mobile_radio_power_state_changed = 12;
58 WifiRadioPowerStateChanged wifi_radio_power_state_changed = 13;
59 // TODO: 14-19 are blank, but need not be
60 BatterySaverModeStateChanged battery_saver_mode_state_changed = 20;
61 DeviceIdleModeStateChanged device_idle_mode_state_changed = 21;
62 DeviceIdlingModeStateChanged device_idling_mode_state_changed = 22;
Bookatzc1a050a2017-10-10 15:49:28 -070063 AudioStateChanged audio_state_changed = 23;
64 MediaCodecActivityChanged media_codec_activity_changed = 24;
65 CameraStateChanged camera_state_changed = 25;
66 FlashlightStateChanged flashlight_state_changed = 26;
67 UidProcessStateChanged uid_process_state_changed = 27;
68 ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28;
69 ScreenStateChanged screen_state_changed = 29;
Bookatz8c6571b2017-10-24 15:04:41 -070070 BatteryLevelChanged battery_level_changed = 30;
71 ChargingStateChanged charging_state_changed = 31;
72 PluggedStateChanged plugged_state_changed = 32;
73 DeviceTemperatureReported device_temperature_reported = 33;
74 DeviceOnStatusChanged device_on_status_changed = 34;
75 WakeupAlarmOccurred wakeup_alarm_occurred = 35;
76 KernelWakeupReported kernel_wakeup_reported = 36;
Bookatze5885242017-10-24 20:10:31 -070077 WifiLockStateChanged wifi_lock_state_changed = 37;
78 WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
79 WifiScanStateChanged wifi_scan_state_changed = 39;
80 PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
David Chenc28b2bb2017-10-24 12:52:52 -070081 SettingChanged setting_changed = 41;
David Chenc8a43242017-10-17 16:23:28 -070082 ActivityForegroundStateChanged activity_foreground_state_changed = 42;
David Chen21582962017-11-01 17:32:46 -070083 IsolatedUidChanged isolated_uid_changed = 43;
Hugo Benichi884970e2017-11-14 22:42:46 +090084 PacketWakeupOccurred packet_wakeup_occurred = 44;
David Chen9e3808c2017-11-20 17:25:34 -080085 DropboxErrorChanged dropbox_error_changed = 45;
Bookatz8fcd09a2017-12-18 13:01:10 -080086 AnomalyDetected anomaly_detected = 46;
87 AppHook app_hook = 47;
Olivier Gaillardaed7f122017-12-12 14:26:22 +000088 AppStartChanged app_start_changed = 48;
89 AppStartCancelChanged app_start_cancel_changed = 49;
90 AppStartFullyDrawnChanged app_start_fully_drawn_changed = 50;
Rajeev Kumar8a9fa052018-01-25 19:03:09 -080091 LmkKillOccurred lmk_kill_occurred = 51;
Chenjie Yu52cacc62017-12-08 18:11:45 -080092 PictureInPictureStateChanged picture_in_picture_state_changed = 52;
Tej Singh4503e102018-01-04 14:35:01 -080093 WifiMulticastLockStateChanged wifi_multicast_lock_state_changed = 53;
Rajeev Kumar8a9fa052018-01-25 19:03:09 -080094 LmkStateChanged lmk_state_changed = 54;
95 AppStartMemoryStateCaptured app_start_memory_state_captured = 55;
Tej Singh1ea42892018-01-19 09:27:00 -080096 ShutdownSequenceReported shutdown_sequence_reported = 56;
Tej Singh6483ea42018-01-25 17:45:49 -080097 BootSequenceReported boot_sequence_reported = 57;
Bookatzc1a050a2017-10-10 15:49:28 -070098 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000099 }
David Chenc8a43242017-10-17 16:23:28 -0700100
David Chen6e3e6cb2018-01-03 16:14:06 -0800101 // Pulled events will start at field 10000.
Tej Singhbf972d92018-01-10 20:51:13 -0800102 // Next: 10021
David Chenc8a43242017-10-17 16:23:28 -0700103 oneof pulled {
David Chen6e3e6cb2018-01-03 16:14:06 -0800104 WifiBytesTransfer wifi_bytes_transfer = 10000;
105 WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
106 MobileBytesTransfer mobile_bytes_transfer = 10002;
107 MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 10003;
Chenjie Yu9d7720b2018-01-24 10:34:48 -0800108 BluetoothBytesTransfer bluetooth_bytes_transfer = 10006;
David Chen6e3e6cb2018-01-03 16:14:06 -0800109 KernelWakelock kernel_wakelock = 10004;
Chenjie Yuc8b7f222018-01-11 23:25:57 -0800110 SubsystemSleepState subsystem_sleep_state = 10005;
David Chen6e3e6cb2018-01-03 16:14:06 -0800111 CpuTimePerFreq cpu_time_per_freq = 10008;
112 CpuTimePerUid cpu_time_per_uid = 10009;
113 CpuTimePerUidFreq cpu_time_per_uid_freq = 10010;
114 WifiActivityEnergyInfo wifi_activity_energy_info = 10011;
115 ModemActivityInfo modem_activity_info = 10012;
Chenjie Yu9d7720b2018-01-24 10:34:48 -0800116 BluetoothActivityInfo bluetooth_activity_info = 10007;
Rajeev Kumar8a9fa052018-01-25 19:03:09 -0800117 ProcessMemoryState process_memory_state = 10013;
Chenjie Yu9d7720b2018-01-24 10:34:48 -0800118 SystemElapsedRealtime system_elapsed_realtime = 10014;
119 SystemUptime system_uptime = 10015;
Chenjie Yu9da105b2018-01-13 12:41:08 -0800120 CpuActiveTime cpu_active_time = 10016;
121 CpuClusterTime cpu_cluster_time = 10017;
Chenjie Yu937d7422018-01-10 16:37:53 -0800122 DiskSpace disk_space = 10018;
Tej Singhbf972d92018-01-10 20:51:13 -0800123 RemainingBatteryCapacity remaining_battery_capacity = 10019;
124 FullBatteryCapacity full_battery_capacity = 10020;
David Chenc8a43242017-10-17 16:23:28 -0700125 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700126}
127
Yao Chend54f9dd2017-10-17 17:37:48 +0000128/**
Yangster-mac20877162017-12-22 17:19:39 -0800129 * This proto represents a node of an attribution chain.
130 * Note: All attribution chains are represented as a repeated field of type
131 * AttributionNode. It is understood that in such arrays, the order is that
132 * of calls, that is [A, B, C] if A calls B that calls C.
Yao Chend54f9dd2017-10-17 17:37:48 +0000133 */
Yangster-mac20877162017-12-22 17:19:39 -0800134message AttributionNode {
135 // The uid for a given element in the attribution chain.
Yangster-mac7604aea2017-12-11 22:55:49 -0800136 optional int32 uid = 1;
Yangster-mac7604aea2017-12-11 22:55:49 -0800137
Yangster-mac20877162017-12-22 17:19:39 -0800138 // The (optional) string tag for an element in the attribution chain. If the
139 // element has no tag, it is encoded as an empty string.
140 optional string tag = 2;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700141}
142
Yao Chend54f9dd2017-10-17 17:37:48 +0000143/*
144 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800145 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000146 *
147 * RULES:
148 * - The field ids for each atom must start at 1, and count upwards by 1.
149 * Skipping field ids is not allowed.
150 * - These form an API, so renaming, renumbering or removing fields is
151 * not allowed between android releases. (This is not currently enforced,
152 * but there will be a tool to enforce this restriction).
153 * - The types must be built-in protocol buffer types, namely, no sub-messages
154 * are allowed (yet). The bytes type is also not allowed.
155 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800156 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000157 * - If an atom represents work that can be attributed to an app, there can
Yangster-mac7604aea2017-12-11 22:55:49 -0800158 * be exactly one AttributionChain field. It must be field number 1.
Yao Chend54f9dd2017-10-17 17:37:48 +0000159 * - A field that is a uid should be a string field, tagged with the [xxx]
160 * annotation. The generated code on android will be represented by UIDs,
161 * and those UIDs will be translated in xxx to those strings.
162 *
163 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700164 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000165 * - If there is a UID, it goes first. Think in an object-oriented fashion.
166 * *****************************************************************************
167 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700168
Yao Chend54f9dd2017-10-17 17:37:48 +0000169/**
170 * Logs when the screen state changes.
171 *
172 * Logged from:
173 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
174 */
175message ScreenStateChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800176 // New screen state, from frameworks/base/core/proto/android/view/enums.proto.
177 optional android.view.DisplayStateEnum state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700178}
Yao Chend54f9dd2017-10-17 17:37:48 +0000179
180/**
Bookatzc1a050a2017-10-10 15:49:28 -0700181 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000182 *
183 * Logged from:
184 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
185 */
Bookatzc1a050a2017-10-10 15:49:28 -0700186message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000187 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
188
Bookatzdb026a22018-01-10 19:01:56 -0800189 // The state, from frameworks/base/core/proto/android/app/enums.proto.
190 optional android.app.ProcessStateEnum state = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000191}
192
193/**
Bookatzc1a050a2017-10-10 15:49:28 -0700194 * Logs that a process started, finished, crashed, or ANRed.
195 *
196 * Logged from:
197 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
198 */
199message ProcessLifeCycleStateChanged {
Bookatzc1a050a2017-10-10 15:49:28 -0700200 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 {
Yangster-macafad8c62018-01-05 22:30:49 -0800223 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700224
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 {
Yangster-macafad8c62018-01-05 22:30:49 -0800240 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700241
242 enum State {
243 OFF = 0;
244 ON = 1;
245 }
246 optional State state = 2;
247}
248
249/**
250 * Logs reporting of a ble scan finding results.
251 *
252 * Logged from:
253 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
254 */
255// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
256message BleScanResultReceived {
Yangster-macafad8c62018-01-05 22:30:49 -0800257 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700258
259 // Number of ble scan results returned.
260 optional int32 num_of_results = 2;
261}
262
263/**
264 * Logs when a sensor state changes.
265 *
266 * Logged from:
267 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
268 */
269message SensorStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800270 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700271
272 // TODO: Is there a way to get the actual name of the sensor?
273 // The id (int) of the sensor.
274 optional int32 sensor_id = 2;
275
276 enum State {
277 OFF = 0;
278 ON = 1;
279 }
280 optional State state = 3;
281}
282
283
284/**
285 * Logs when GPS state changes.
286 *
287 * Logged from:
288 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
289 */
290message GpsScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800291 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700292
293 enum State {
294 OFF = 0;
295 ON = 1;
296 }
297 optional State state = 2;
298}
299
300
301/**
302 * Logs when a sync manager sync state changes.
303 *
304 * Logged from:
305 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
306 */
307message SyncStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800308 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700309
310 // Name of the sync (as named in the app)
311 optional string name = 2;
312
313 enum State {
314 OFF = 0;
315 ON = 1;
316 }
317 optional State state = 3;
318}
319
320/**
321 * Logs when a job scheduler job state changes.
322 *
323 * Logged from:
324 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
325 */
326message ScheduledJobStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800327 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700328
329 // Name of the job (as named in the app)
330 optional string name = 2;
331
332 enum State {
Tej Singhd5747a62018-01-08 20:57:35 -0800333 FINISHED = 0;
334 STARTED = 1;
335 SCHEDULED = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700336 }
337 optional State state = 3;
338
339 // TODO: Consider adding the stopReason (int)
340}
341
342/**
343 * Logs when the audio state changes.
344 *
345 * Logged from:
346 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
347 */
348message AudioStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800349 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700350
351 enum State {
352 OFF = 0;
353 ON = 1;
354 }
355 optional State state = 2;
356}
357
358/**
359 * Logs when the video codec state changes.
360 *
361 * Logged from:
362 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
363 */
364message MediaCodecActivityChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800365 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700366
367 enum State {
368 OFF = 0;
369 ON = 1;
370 }
371 optional State state = 2;
372}
373
374/**
375 * Logs when the flashlight state changes.
376 *
377 * Logged from:
378 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
379 */
380message FlashlightStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800381 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700382
383 enum State {
384 OFF = 0;
385 ON = 1;
386 }
387 optional State state = 2;
388}
389
390/**
391 * Logs when the camera state changes.
392 *
393 * Logged from:
394 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
395 */
396message CameraStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800397 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700398
399 enum State {
400 OFF = 0;
401 ON = 1;
402 }
403 optional State state = 2;
404}
405
406/**
407 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000408 *
409 * Logged from:
410 * TODO
411 */
Bookatzd6746242017-10-24 18:39:35 -0700412message WakelockStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800413 repeated AttributionNode attribution_node = 1;
Yao Chend54f9dd2017-10-17 17:37:48 +0000414
Bookatz1a1b0462018-01-12 11:47:03 -0800415 // The type (level) of the wakelock; e.g. a partial wakelock or a full wakelock.
416 // From frameworks/base/core/proto/android/os/enums.proto.
417 optional android.os.WakeLockLevelEnum level = 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 {
Yangster-macafad8c62018-01-05 22:30:49 -0800438 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700439
Yao Chend54f9dd2017-10-17 17:37:48 +0000440 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
441 optional string tag = 2;
442
Bookatzc1a050a2017-10-10 15:49:28 -0700443 // TODO: I have no idea what this is.
444 optional string history_tag = 3;
445
446 enum State {
447 OFF = 0;
448 ON = 1;
449 }
450 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000451}
452
Bookatzc1a050a2017-10-10 15:49:28 -0700453/**
454 * Logs Battery Saver state change.
455 *
456 * Logged from:
457 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
458 */
459message BatterySaverModeStateChanged {
460 enum State {
461 OFF = 0;
462 ON = 1;
463 }
464 optional State state = 1;
465}
466
467/**
468 * Logs Doze mode state change.
469 *
470 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800471 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700472 */
473message DeviceIdleModeStateChanged {
Bookatz8bdae8d2018-01-16 11:24:30 -0800474 optional android.server.DeviceIdleModeEnum state = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800475}
476
477
478/**
479 * Logs state change of Doze mode including maintenance windows.
480 *
481 * Logged from:
482 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
483 */
484message DeviceIdlingModeStateChanged {
Bookatz8bdae8d2018-01-16 11:24:30 -0800485 optional android.server.DeviceIdleModeEnum state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700486}
487
488/**
489 * Logs screen brightness level.
490 *
491 * Logged from:
492 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
493 */
494message ScreenBrightnessChanged {
495 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
496 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700497}
498
499/**
500 * Logs battery level (percent full, from 0 to 100).
501 *
502 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700503 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700504 */
505message BatteryLevelChanged {
506 // Battery level. Should be in [0, 100].
507 optional int32 battery_level = 1;
508}
509
510/**
511 * Logs change in charging status of the device.
512 *
513 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700514 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700515 */
516message ChargingStateChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800517 // State of the battery, from frameworks/base/core/proto/android/os/enums.proto.
518 optional android.os.BatteryStatusEnum state = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700519}
520
521/**
522 * Logs whether the device is plugged in, and what power source it is using.
523 *
524 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700525 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700526 */
527message PluggedStateChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800528 // Whether the device is plugged in, from frameworks/base/core/proto/android/os/enums.proto.
529 optional android.os.BatteryPluggedStateEnum state = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700530}
531
532/**
533 * Logs the temperature of the device, in tenths of a degree Celsius.
534 *
535 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700536 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700537 */
538message DeviceTemperatureReported {
539 // Temperature in tenths of a degree C.
540 optional int32 temperature = 1;
541}
542
543// TODO: Define this more precisely.
544// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
545/**
546 * Logs when the device turns off or on.
547 *
548 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700549 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700550 */
551message DeviceOnStatusChanged {
552 enum State {
553 OFF = 0;
554 ON = 1;
555 }
556 optional State state = 1;
557}
558
559/**
560 * Logs when an app's wakeup alarm fires.
561 *
562 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700563 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700564 */
565message WakeupAlarmOccurred {
Yangster-macafad8c62018-01-05 22:30:49 -0800566 repeated AttributionNode attribution_node = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800567
568 // Name of the wakeup alarm.
569 optional string tag = 2;
570}
571
572/**
573 * Logs when an an app causes the mobile radio to change state.
574 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
575 *
576 * Logged from:
577 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
578 */
579message MobileRadioPowerStateChanged {
580 // TODO: Add attribution instead of uid?
581 optional int32 uid = 1;
582
Bookatz1a1b0462018-01-12 11:47:03 -0800583 // Power state, from frameworks/base/core/proto/android/telephony/enums.proto.
584 optional android.telephony.DataConnectionPowerStateEnum state = 2;
Bookatzddccf0a2017-11-28 16:48:14 -0800585}
586
587/**
588 * Logs when an an app causes the wifi radio to change state.
589 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
590 *
591 * Logged from:
592 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
593 */
594message WifiRadioPowerStateChanged {
595 // TODO: Add attribution instead of uid?
596 optional int32 uid = 1;
597
Bookatz1a1b0462018-01-12 11:47:03 -0800598 // Power state, from frameworks/base/core/proto/android/telephony/enums.proto.
599 optional android.telephony.DataConnectionPowerStateEnum state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700600}
601
602/**
603 * Logs kernel wakeup reasons and aborts.
604 *
605 * Logged from:
606 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
607 */
608message KernelWakeupReported {
609 // Name of the kernel wakeup reason (or abort).
610 optional string wakeup_reason_name = 1;
611
612 // Duration (in microseconds) for the wake-up interrupt to be serviced.
613 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700614}
615
616/**
617 * Logs wifi locks held by an app.
618 *
619 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700620 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700621 */
622message WifiLockStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800623 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700624
625 enum State {
626 OFF = 0;
627 ON = 1;
628 }
629 optional State state = 2;
630}
631
632/**
633 * Logs wifi signal strength changes.
634 *
635 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700636 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700637 */
638message WifiSignalStrengthChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800639 // Signal strength, from frameworks/base/core/proto/android/telephony/enums.proto.
640 optional android.telephony.SignalStrengthEnum signal_strength = 1;
Bookatze5885242017-10-24 20:10:31 -0700641}
642
643/**
644 * Logs wifi scans performed by an app.
645 *
646 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700647 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700648 */
649message WifiScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800650 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700651
652 enum State {
653 OFF = 0;
654 ON = 1;
655 }
656 optional State state = 2;
657}
658
659/**
Tej Singh4503e102018-01-04 14:35:01 -0800660 * Logs wifi multicast locks held by an app
661 *
662 * Logged from:
663 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
664 */
665message WifiMulticastLockStateChanged {
666 repeated AttributionNode attribution_node = 1;
667
668 enum State {
669 OFF = 0;
670 ON = 1;
671 }
672 optional State state = 2;
673}
674
675/**
Tej Singh1ea42892018-01-19 09:27:00 -0800676 * Logs shutdown reason and duration on next boot.
677 *
678 * Logged from:
679 * frameworks/base/core/java/com/android/server/BootReceiver.java
680 */
681message ShutdownSequenceReported {
682 // True if shutdown is for a reboot. Default: false if we do not know.
683 optional bool reboot = 1;
684
685 // Reason for shutdown. Eg: userrequested. Default: "<EMPTY>".
686 optional string reason = 2;
687
688 // Beginning of shutdown time in ms using wall clock time since unix epoch.
689 // Default: 0 if no start time received.
690 optional int64 start_time_ms = 3;
691
692 // Duration of shutdown in ms. Default: 0 if no duration received.
693 optional int64 duration_ms = 4;
694}
695
Tej Singh6483ea42018-01-25 17:45:49 -0800696
697/**
698 * Logs boot reason and duration.
699 *
700 * Logged from:
701 * system/core/bootstat/bootstat.cpp
702 */
703message BootSequenceReported {
704 // Reason for bootloader boot. Eg. reboot. See bootstat.cpp for larger list
705 // Default: "<EMPTY>" if not available.
706 optional string bootloader_reason = 1;
707
708 // Reason for system boot. Eg. bootloader, reboot,userrequested
709 // Default: "<EMPTY>" if not available.
710 optional string system_reason = 2;
711
712 // End of boot time in ms from unix epoch using system wall clock.
713 optional int64 end_time_ms = 3;
714
715 // Total boot duration in ms.
716 optional int64 total_duration_ms = 4;
717
718 // Bootloader duration in ms.
719 optional int64 bootloader_duration_ms = 5;
720
721 // Time since last boot in ms. Default: 0 if not available.
722 optional int64 time_since_last_boot = 6;
723}
724
Tej Singh1ea42892018-01-19 09:27:00 -0800725/**
Bookatze5885242017-10-24 20:10:31 -0700726 * Logs phone signal strength changes.
727 *
728 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700729 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700730 */
731message PhoneSignalStrengthChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800732 // Signal strength, from frameworks/base/core/proto/android/telephony/enums.proto.
733 optional android.telephony.SignalStrengthEnum signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700734}
735
736/**
737 * Logs that a setting was updated.
738 * Logged from:
739 * frameworks/base/core/java/android/provider/Settings.java
740 * The tag and is_default allow resetting of settings to default values based on the specified
741 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
742 */
743message SettingChanged {
744 // The name of the setting.
745 optional string setting = 1;
746
747 // The change being imposed on this setting. May represent a number, eg "3".
748 optional string value = 2;
749
750 // The new value of this setting. For most settings, this is same as value. For some settings,
751 // value is +X or -X where X represents an element in a set. For example, if the previous value
752 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
753 // The +/- feature is currently only used for location_providers_allowed.
754 optional string new_value = 3;
755
756 // The previous value of this setting.
757 optional string prev_value = 4;
758
759 // The tag used with the is_default for resetting sets of settings. This is generally null.
760 optional string tag = 5;
761
762 // 1 indicates that this setting with tag should be resettable.
763 optional int32 is_default = 6;
764
765 // The user ID associated. Defined in android/os/UserHandle.java
766 optional int32 user = 7;
767}
Chenjie Yub3dda412017-10-24 13:41:59 -0700768
Chenjie Yu05013b32017-11-21 10:21:41 -0800769/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700770 * Logs activity going to foreground or background
771 *
772 * Logged from:
773 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
774 */
775message ActivityForegroundStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800776 optional int32 uid = 1;
777 optional string pkg_name = 2;
778 optional string class_name = 3;
779
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700780 enum Activity {
781 MOVE_TO_BACKGROUND = 0;
782 MOVE_TO_FOREGROUND = 1;
783 }
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700784 optional Activity activity = 4;
785}
David Chenc8a43242017-10-17 16:23:28 -0700786
787/**
David Chen9e3808c2017-11-20 17:25:34 -0800788 * Logs when an error is written to dropbox.
789 * Logged from:
790 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
791 */
792message DropboxErrorChanged {
793 // The uid if available. -1 means not available.
794 optional int32 uid = 1;
795
796 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
797 optional string tag = 2;
798
799 // The name of the process.
800 optional string process_name = 3;
801
802 // The pid if available. -1 means not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800803 optional sint32 pid = 4;
David Chen9e3808c2017-11-20 17:25:34 -0800804
805 // 1 indicates is instant app. -1 indicates Not applicable.
David Chen6e3e6cb2018-01-03 16:14:06 -0800806 optional sint32 is_instant_app = 5;
David Chen9e3808c2017-11-20 17:25:34 -0800807
808 // The activity name if available.
809 optional string activity_name = 6;
810
David Chen6e3e6cb2018-01-03 16:14:06 -0800811 // The package name if available.
812 optional string package_name = 7;
813
David Chen9e3808c2017-11-20 17:25:34 -0800814 // 1 indicates in foreground. -1 indicates not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800815 optional sint32 is_foreground = 8;
David Chen9e3808c2017-11-20 17:25:34 -0800816}
817
David Chen0a368b22017-12-06 16:28:16 -0800818/*
819 * Allows other apps to push events into statsd.
820 * Logged from:
821 * frameworks/base/core/java/android/util/StatsLog.java
822 */
823message AppHook {
824 // The uid of the application that sent this custom atom.
825 optional int32 uid = 1;
826
827 // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
828 optional int32 label = 2;
829
830 // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
831 // predicates for the metrics).
832 enum State {
833 UNKNOWN = 0;
834 UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
835 STOP = 2;
836 START = 3;
837 }
838 optional State state = 3;
839}
840
David Chen9e3808c2017-11-20 17:25:34 -0800841/**
Bookatz8fcd09a2017-12-18 13:01:10 -0800842 * Logs when statsd detects an anomaly.
843 *
844 * Logged from:
845 * frameworks/base/cmds/statsd/src/anomaly/AnomalyTracker.cpp
846 */
847message AnomalyDetected {
848 // Uid that owns the config whose anomaly detection alert fired.
849 optional int32 config_uid = 1;
850
Yangster-mac94e197c2018-01-02 16:03:03 -0800851 // Id of the config whose anomaly detection alert fired.
852 optional int64 config_id = 2;
Bookatz8fcd09a2017-12-18 13:01:10 -0800853
Yangster-mac94e197c2018-01-02 16:03:03 -0800854 // Id of the alert (i.e. name of the anomaly that was detected).
855 optional int64 alert_id = 3;
Bookatz8fcd09a2017-12-18 13:01:10 -0800856}
857
Olivier Gaillardaed7f122017-12-12 14:26:22 +0000858message AppStartChanged {
859 // The uid if available. -1 means not available.
860 optional int32 uid = 1;
861
862 // The app package name.
863 optional string pkg_name = 2;
864
865 enum TransitionType {
866 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
867 WARM = 1;
868 HOT = 2;
869 COLD = 3;
870 }
871 // The transition type.
872 optional TransitionType type = 3;
873
874 // The activity name.
875 optional string activity_name = 4;
876
877 // The name of the calling app. Empty if not set.
878 optional string calling_pkg_name = 5;
879
880 // Whether the app is an instant app.
881 optional bool is_instant_app = 6;
882
883 // Device uptime when activity started.
884 optional int64 activity_start_msec = 7;
885
Bookatz80d11a02018-01-16 10:46:35 -0800886 optional android.app.AppTransitionReasonEnum reason = 8;
Olivier Gaillardaed7f122017-12-12 14:26:22 +0000887
888 optional int32 transition_delay_msec = 9;
889 // -1 if not set.
890 optional int32 starting_window_delay_msec = 10;
891 // -1 if not set.
892 optional int32 bind_application_delay_msec = 11;
893 optional int32 windows_drawn_delay_msec = 12;
894
895 // Empty if not set.
896 optional string launch_token = 13;
897
898}
899
900message AppStartCancelChanged {
901 // The uid if available. -1 means not available.
902 optional int32 uid = 1;
903
904 // The app package name.
905 optional string pkg_name = 2;
906
907 enum TransitionType {
908 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
909 WARM = 1;
910 HOT = 2;
911 COLD = 3;
912 }
913 // The transition type.
914 optional TransitionType type = 3;
915
916 // The activity name.
917 optional string activity_name = 4;
918}
919
920message AppStartFullyDrawnChanged {
921 // The uid if available. -1 means not available.
922 optional int32 uid = 1;
923
924 // The app package name.
925 optional string pkg_name = 2;
926
927 enum TransitionType {
928 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
929 WITH_BUNDLE = 1;
930 WITHOUT_BUNDLE = 2;
931 }
932 // The transition type.
933 optional TransitionType type = 3;
934
935 // The activity name.
936 optional string activity_name = 4;
937
938 optional bool transition_process_running = 5;
939
940 // App startup time (until call to Activity#reportFullyDrawn()).
941 optional int64 app_startup_time_ms = 6;
942}
943
Bookatz8fcd09a2017-12-18 13:01:10 -0800944/**
Chenjie Yu52cacc62017-12-08 18:11:45 -0800945 * Logs a picture-in-picture action
946 * Logged from:
947 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
948 * frameworks/base/services/core/java/com/android/server/am/ActivityStackSupervisor.java
949 * frameworks/base/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
950 */
951message PictureInPictureStateChanged {
952 optional int32 uid = 1;
953
954 optional string package_name = 2;
955
956 optional string class_name = 3;
957
958 // Picture-in-Picture action occurred, similar to
959 // frameworks/base/proto/src/metrics_constants.proto
960 enum State {
961 ENTERED = 1;
962 EXPANDED_TO_FULL_SCREEN = 2;
963 MINIMIZED = 3;
964 DISMISSED = 4;
965 }
966 optional State state = 4;
967}
968
969/**
David Chenc8a43242017-10-17 16:23:28 -0700970 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
971 *
972 * Pulled from:
973 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
974 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800975message WifiBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -0700976 optional int32 uid = 1;
977
978 optional int64 rx_bytes = 2;
979
980 optional int64 rx_packets = 3;
981
982 optional int64 tx_bytes = 4;
983
984 optional int64 tx_packets = 5;
985}
986
987/**
988 * Pulls bytes transferred via wifi (separated by foreground and background usage).
989 *
990 * Pulled from:
991 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
992 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800993message WifiBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -0700994 optional int32 uid = 1;
995
996 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
997 optional int32 is_foreground = 2;
998
999 optional int64 rx_bytes = 3;
1000
1001 optional int64 rx_packets = 4;
1002
1003 optional int64 tx_bytes = 5;
1004
1005 optional int64 tx_packets = 6;
1006}
1007
1008/**
1009 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
1010 *
1011 * Pulled from:
1012 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1013 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001014message MobileBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -07001015 optional int32 uid = 1;
1016
1017 optional int64 rx_bytes = 2;
1018
1019 optional int64 rx_packets = 3;
1020
1021 optional int64 tx_bytes = 4;
1022
1023 optional int64 tx_packets = 5;
1024}
1025
1026/**
1027 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
1028 *
1029 * Pulled from:
1030 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1031 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001032message MobileBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -07001033 optional int32 uid = 1;
1034
1035 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
1036 optional int32 is_foreground = 2;
1037
1038 optional int64 rx_bytes = 3;
1039
1040 optional int64 rx_packets = 4;
1041
1042 optional int64 tx_bytes = 5;
1043
1044 optional int64 tx_packets = 6;
1045}
1046
1047/**
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001048 * Pulls bytes transferred via bluetooth. It is pulled from Bluetooth controller.
1049 *
1050 * Pulled from:
1051 * StatsCompanionService
1052 */
1053message BluetoothBytesTransfer {
1054 optional int32 uid = 1;
1055
1056 optional int64 rx_bytes = 2;
1057
1058 optional int64 tx_bytes = 3;
1059}
1060
1061/**
David Chenc8a43242017-10-17 16:23:28 -07001062 * Pulls the kernel wakelock durations. This atom is adapted from
1063 * android/internal/os/KernelWakelockStats.java
1064 *
1065 * Pulled from:
1066 * StatsCompanionService using KernelWakelockReader.
1067 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001068message KernelWakelock {
David Chenc8a43242017-10-17 16:23:28 -07001069 optional string name = 1;
1070
1071 optional int32 count = 2;
1072
1073 optional int32 version = 3;
1074
1075 optional int64 time = 4;
1076}
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001077
Chenjie Yu05013b32017-11-21 10:21:41 -08001078/**
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001079 * Pulls low power state information. This includes platform and subsystem sleep state information,
1080 * PowerStatePlatformSleepState, PowerStateVoter or PowerStateSubsystemSleepState as defined in
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001081 * hardware/interfaces/power/1.0/types.hal
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001082 * hardware/interfaces/power/1.1/types.hal
1083 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001084message SubsystemSleepState {
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001085 // Name should be in the format of XXX.YYY where XXX is subsystem name,
1086 // YYY is corresponding voter name.
1087 // If there are no voters, the format should just be XXX (with no dot).
1088 // XXX and YYY should not contain a "." in it.
1089 optional string name = 1;
1090 // The number of times it entered, or voted for entering the sleep state
1091 optional uint64 count = 2;
1092 // The length of time spent in, or spent voting for, the sleep state
1093 optional uint64 timeMs = 3;
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001094}
David Chen21582962017-11-01 17:32:46 -07001095
1096/**
1097 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
1098 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
1099 * attributed back to the parent (host) uid. One example is Chrome.
1100 *
1101 * Logged from:
1102 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
1103 */
1104message IsolatedUidChanged {
1105 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
1106 optional int32 parent_uid = 1;
1107
1108 optional int32 isolated_uid = 2;
1109
1110 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
1111 // be removed before if it's used for another parent uid.
1112 optional int32 is_create = 3;
1113}
Chenjie Yu7f8def92017-11-03 09:33:15 -07001114
Chenjie Yu05013b32017-11-21 10:21:41 -08001115/**
Chenjie Yu7f8def92017-11-03 09:33:15 -07001116 * Pulls Cpu time per frequency.
Chenjie Yu1ee9b742018-01-10 16:02:57 -08001117 * Pulls the time the cpu spend on the frequency index. Frequency index
1118 * starts from highest to lowest. The value should be monotonically
1119 * increasing since boot. However, if there is a cpu
1120 * hotplug event, the value would be reset as well.
Chenjie Yu7f8def92017-11-03 09:33:15 -07001121 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001122message CpuTimePerFreq {
Chenjie Yu7f8def92017-11-03 09:33:15 -07001123 optional uint32 cluster = 1;
1124 optional uint32 freq_index = 2;
Chenjie Yu31d14d72017-12-12 17:54:33 -08001125 optional uint64 time_ms = 3;
Chenjie Yu7f8def92017-11-03 09:33:15 -07001126}
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001127
Chenjie Yu05013b32017-11-21 10:21:41 -08001128/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001129 * Pulls Cpu Time Per Uid.
1130 * Note that isolated process uid time should be attributed to host uids.
1131 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001132message CpuTimePerUid {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001133 optional uint64 uid = 1;
1134 optional uint64 user_time_ms = 2;
1135 optional uint64 sys_time_ms = 3;
1136}
1137
1138/**
1139 * Pulls Cpu Time Per Uid per frequency.
1140 * Note that isolated process uid time should be attributed to host uids.
1141 * For each uid, we order the time by descending frequencies.
1142 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001143message CpuTimePerUidFreq {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001144 optional uint64 uid = 1;
1145 optional uint64 freq_idx = 2;
1146 optional uint64 time_ms = 3;
1147}
Hugo Benichi884970e2017-11-14 22:42:46 +09001148
1149/*
1150 * Logs the reception of an incoming network packet causing the main system to wake up for
1151 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1152 * and processed by WakeupController.cpp.
1153 */
1154message PacketWakeupOccurred {
1155 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1156 // delivered nowhere.
1157 optional int32 uid = 1;
1158 // The interface name on which the packet was received.
1159 optional string iface = 2;
1160 // The ethertype value of the packet.
1161 optional int32 ethertype = 3;
1162 // String representation of the destination MAC address of the packet.
1163 optional string destination_hardware_address = 4;
1164 // String representation of the source address of the packet if this was an IP packet.
1165 optional string source_ip = 5;
1166 // String representation of the destination address of the packet if this was an IP packet.
1167 optional string destination_ip = 6;
1168 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1169 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1170 // families.
1171 optional int32 ip_next_header = 7;
1172 // The source port if this was a TCP or UDP packet.
1173 optional int32 source_port = 8;
1174 // The destination port if this was a TCP or UDP packet.
1175 optional int32 destination_port = 9;
1176}
Chenjie Yu05013b32017-11-21 10:21:41 -08001177
1178/**
1179 * Pulls Wifi Controller Activity Energy Info
1180 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001181message WifiActivityEnergyInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001182 // timestamp(wall clock) of record creation
1183 optional uint64 timestamp_ms = 1;
1184 // stack reported state
1185 // TODO: replace this with proto enum
1186 optional int32 stack_state = 2;
1187 // tx time in ms
1188 optional uint64 controller_tx_time_ms = 3;
1189 // rx time in ms
1190 optional uint64 controller_rx_time_ms = 4;
1191 // idle time in ms
1192 optional uint64 controller_idle_time_ms = 5;
1193 // product of current(mA), voltage(V) and time(ms)
1194 optional uint64 controller_energy_used = 6;
1195}
1196
1197/**
1198 * Pulls Modem Activity Energy Info
1199 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001200message ModemActivityInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001201 // timestamp(wall clock) of record creation
1202 optional uint64 timestamp_ms = 1;
1203 // sleep time in ms.
1204 optional uint64 sleep_time_ms = 2;
1205 // idle time in ms
1206 optional uint64 controller_idle_time_ms = 3;
1207 /**
1208 * Tx power index
1209 * index 0 = tx_power < 0dBm
1210 * index 1 = 0dBm < tx_power < 5dBm
1211 * index 2 = 5dBm < tx_power < 15dBm
1212 * index 3 = 15dBm < tx_power < 20dBm
1213 * index 4 = tx_power > 20dBm
1214 */
1215 // tx time in ms at power level 0
1216 optional uint64 controller_tx_time_pl0_ms = 4;
1217 // tx time in ms at power level 1
1218 optional uint64 controller_tx_time_pl1_ms = 5;
1219 // tx time in ms at power level 2
1220 optional uint64 controller_tx_time_pl2_ms = 6;
1221 // tx time in ms at power level 3
1222 optional uint64 controller_tx_time_pl3_ms = 7;
1223 // tx time in ms at power level 4
1224 optional uint64 controller_tx_time_pl4_ms = 8;
1225 // rx time in ms at power level 5
1226 optional uint64 controller_rx_time_ms = 9;
1227 // product of current(mA), voltage(V) and time(ms)
1228 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001229}
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001230
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001231/**
1232 * Pulls Bluetooth Activity Energy Info
1233 * Note: BluetoothBytesTransfer is pulled at the same time from the controller.
1234 */
1235message BluetoothActivityInfo {
1236 // timestamp(wall clock) of record creation
1237 optional uint64 timestamp_ms = 1;
1238 // bluetooth stack state
1239 optional int32 bluetooth_stack_state = 2;
1240 // tx time in ms
1241 optional uint64 controller_tx_time_ms = 3;
1242 // rx time in ms
1243 optional uint64 controller_rx_time_ms = 4;
1244 // idle time in ms
1245 optional uint64 controller_idle_time_ms = 5;
1246 // product of current(mA), voltage(V) and time(ms)
1247 optional uint64 energy_used = 6;
1248}
1249
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001250/*
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001251 * Logs the memory stats for an app on startup.
1252 * Logged from:
1253 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001254 */
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001255message AppStartMemoryStateCaptured {
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001256 // The uid if available. -1 means not available.
1257 optional int32 uid = 1;
1258
Rajeev Kumar27572b92018-01-23 16:12:51 -08001259 // The process name.
1260 optional string process_name = 2;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001261
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001262 // The activity name.
1263 optional string activity_name = 3;
1264
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001265 // # of page-faults
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001266 optional int64 pgfault = 4;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001267
1268 // # of major page-faults
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001269 optional int64 pgmajfault = 5;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001270
Rajeev Kumar90235992018-01-29 11:06:48 -08001271 // RSS
1272 optional int64 rss_in_bytes = 6;
1273
1274 // CACHE
1275 optional int64 cache_in_bytes = 7;
1276
1277 // SWAP
1278 optional int64 swap_in_bytes = 8;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001279}
1280
1281/*
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001282 * Logs the memory stats for a process.
1283 */
1284message ProcessMemoryState {
1285 // The uid if available. -1 means not available.
1286 optional int32 uid = 1;
1287
1288 // The process name.
1289 optional string process_name = 2;
1290
1291 // oom adj score.
1292 optional int32 oom_score = 3;
1293
1294 // # of page-faults
1295 optional int64 pgfault = 4;
1296
1297 // # of major page-faults
1298 optional int64 pgmajfault = 5;
1299
Rajeev Kumar90235992018-01-29 11:06:48 -08001300 // RSS
1301 optional int64 rss_in_bytes = 6;
1302
1303 // CACHE
1304 optional int64 cache_in_bytes = 7;
1305
1306 // SWAP
1307 optional int64 swap_in_bytes = 8;
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001308}
1309
1310/*
1311 * Logs the change in Low Memory Killer Daemon (LMKD) state which is used as start/stop boundaries
1312 * for LMK event.
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001313 * Logged from:
1314 * system/core/lmkd/lmkd.c
1315 */
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001316message LmkStateChanged {
1317 enum State {
1318 UNKNOWN = 0;
1319 START = 1;
1320 STOP = 2;
1321 }
1322 optional State state = 1;
1323}
1324
1325/*
1326 * Logs the event when Low Memory Killer Daemon (LMKD) kills a process to reduce memory pressure.
1327 * Logged from:
1328 * system/core/lmkd/lmkd.c
1329 */
1330message LmkKillOccurred {
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001331 // The uid if available. -1 means not available.
1332 optional int32 uid = 1;
1333
Rajeev Kumar27572b92018-01-23 16:12:51 -08001334 // The process name.
1335 optional string process_name = 2;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001336
1337 // oom adj score.
1338 optional int32 oom_score = 3;
1339
Rajeev Kumar27572b92018-01-23 16:12:51 -08001340 // # of page-faults
1341 optional int64 pgfault = 4;
1342
1343 // # of major page-faults
1344 optional int64 pgmajfault = 5;
1345
Rajeev Kumar90235992018-01-29 11:06:48 -08001346 // RSS
1347 optional int64 rss_in_bytes = 6;
1348
1349 // CACHE
1350 optional int64 cache_in_bytes = 7;
1351
1352 // SWAP
1353 optional int64 swap_in_bytes = 8;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001354}
Chenjie Yu9da105b2018-01-13 12:41:08 -08001355
1356/*
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001357 * Elapsed real time from SystemClock.
Chenjie Yu9da105b2018-01-13 12:41:08 -08001358 */
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001359message SystemElapsedRealtime {
1360 optional uint64 time_ms = 1;
Chenjie Yu9da105b2018-01-13 12:41:08 -08001361}
1362
1363/*
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001364 * Up time from SystemClock.
Chenjie Yu9da105b2018-01-13 12:41:08 -08001365 */
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001366message SystemUptime {
1367 // Milliseconds since the system was booted.
1368 // This clock stops when the system enters deep sleep (CPU off, display dark, device waiting
1369 // for external input).
1370 // It is not affected by clock scaling, idle, or other power saving mechanisms.
1371 optional uint64 uptime_ms = 1;
Chenjie Yu9da105b2018-01-13 12:41:08 -08001372}
1373
1374/*
1375 * Reads from /proc/uid_concurrent_active_time which has the format:
1376 * active: X (X is # cores)
1377 * [uid0]: [time-0] [time-1] [time-2] ... (# entries = # cores)
1378 * [uid1]: [time-0] [time-1] [time-2] ... ...
1379 * ...
1380 * Time-N means the CPU time a UID spent running concurrently with N other processes.
1381 * The file contains a monotonically increasing count of time for a single boot.
1382 */
1383message CpuActiveTime {
1384 optional uint64 uid = 1;
1385 optional uint64 idx = 2;
1386 optional uint64 time_ms = 3;
1387}
1388
1389/**
1390 * Reads from /proc/uid_concurrent_policy_time which has the format:
1391 * policy0: X policy4: Y (there are X cores on policy0, Y cores on policy4)
1392 * [uid0]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1393 * [uid1]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1394 * ...
1395 * Time-X-Y means the time a UID spent on clusterX running concurrently with Y other processes.
1396 * The file contains a monotonically increasing count of time for a single boot.
1397 */
1398message CpuClusterTime {
1399 optional uint64 uid = 1;
1400 optional uint64 idx = 2;
1401 optional uint64 time_ms = 3;
Chenjie Yu937d7422018-01-10 16:37:53 -08001402}
1403
1404/*
1405 * Pulls free disk space, for data, system partition and temporary directory.
1406 */
1407message DiskSpace {
1408 // available bytes in data partition
1409 optional uint64 data_available_bytes = 1;
1410 // available bytes in system partition
1411 optional uint64 system_available_bytes = 2;
1412 // available bytes in download cache or temp directories
1413 optional uint64 temp_available_bytes = 3;
1414}
Tej Singhbf972d92018-01-10 20:51:13 -08001415
1416/**
1417 * Pulls battery coulomb counter, which is the remaining battery charge in uAh.
1418 * Logged from: frameworks/base/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
1419 */
1420message RemainingBatteryCapacity {
1421 optional int32 charge_uAh = 1;
1422}
1423
1424/**
1425 * Pulls battery capacity, which is the battery capacity when full in uAh.
1426 * Logged from: frameworks/base/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
1427 */
1428message FullBatteryCapacity {
1429 optional int32 capacity_uAh = 1;
1430}