blob: e58c53506c54e569ffa7b58042a1036d2f66450b [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;
Tej Singhbb8554a2018-01-26 11:59:14 -080098 DaveyOccurred davey_occurred = 58;
Chenjie Yue8904192017-12-08 19:12:57 -080099 OverlayStateChanged overlay_state_changed = 59;
Chenjie Yuccfe6452018-01-30 11:33:21 -0800100 ForegroundServiceStateChanged foreground_service_state_changed = 60;
Bookatzc1a050a2017-10-10 15:49:28 -0700101 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +0000102 }
David Chenc8a43242017-10-17 16:23:28 -0700103
David Chen6e3e6cb2018-01-03 16:14:06 -0800104 // Pulled events will start at field 10000.
Tej Singhbf972d92018-01-10 20:51:13 -0800105 // Next: 10021
David Chenc8a43242017-10-17 16:23:28 -0700106 oneof pulled {
David Chen6e3e6cb2018-01-03 16:14:06 -0800107 WifiBytesTransfer wifi_bytes_transfer = 10000;
108 WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
109 MobileBytesTransfer mobile_bytes_transfer = 10002;
110 MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 10003;
Chenjie Yu9d7720b2018-01-24 10:34:48 -0800111 BluetoothBytesTransfer bluetooth_bytes_transfer = 10006;
David Chen6e3e6cb2018-01-03 16:14:06 -0800112 KernelWakelock kernel_wakelock = 10004;
Chenjie Yuc8b7f222018-01-11 23:25:57 -0800113 SubsystemSleepState subsystem_sleep_state = 10005;
David Chen6e3e6cb2018-01-03 16:14:06 -0800114 CpuTimePerFreq cpu_time_per_freq = 10008;
115 CpuTimePerUid cpu_time_per_uid = 10009;
116 CpuTimePerUidFreq cpu_time_per_uid_freq = 10010;
117 WifiActivityEnergyInfo wifi_activity_energy_info = 10011;
118 ModemActivityInfo modem_activity_info = 10012;
Chenjie Yu9d7720b2018-01-24 10:34:48 -0800119 BluetoothActivityInfo bluetooth_activity_info = 10007;
Rajeev Kumar8a9fa052018-01-25 19:03:09 -0800120 ProcessMemoryState process_memory_state = 10013;
Chenjie Yu9d7720b2018-01-24 10:34:48 -0800121 SystemElapsedRealtime system_elapsed_realtime = 10014;
122 SystemUptime system_uptime = 10015;
Chenjie Yu9da105b2018-01-13 12:41:08 -0800123 CpuActiveTime cpu_active_time = 10016;
124 CpuClusterTime cpu_cluster_time = 10017;
Chenjie Yu937d7422018-01-10 16:37:53 -0800125 DiskSpace disk_space = 10018;
Tej Singhbf972d92018-01-10 20:51:13 -0800126 RemainingBatteryCapacity remaining_battery_capacity = 10019;
127 FullBatteryCapacity full_battery_capacity = 10020;
David Chenc8a43242017-10-17 16:23:28 -0700128 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700129}
130
Yao Chend54f9dd2017-10-17 17:37:48 +0000131/**
Yangster-mac20877162017-12-22 17:19:39 -0800132 * This proto represents a node of an attribution chain.
133 * Note: All attribution chains are represented as a repeated field of type
134 * AttributionNode. It is understood that in such arrays, the order is that
135 * of calls, that is [A, B, C] if A calls B that calls C.
Yao Chend54f9dd2017-10-17 17:37:48 +0000136 */
Yangster-mac20877162017-12-22 17:19:39 -0800137message AttributionNode {
138 // The uid for a given element in the attribution chain.
Yangster-mac7604aea2017-12-11 22:55:49 -0800139 optional int32 uid = 1;
Yangster-mac7604aea2017-12-11 22:55:49 -0800140
Yangster-mac20877162017-12-22 17:19:39 -0800141 // The (optional) string tag for an element in the attribution chain. If the
142 // element has no tag, it is encoded as an empty string.
143 optional string tag = 2;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700144}
145
Yao Chend54f9dd2017-10-17 17:37:48 +0000146/*
147 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800148 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000149 *
150 * RULES:
151 * - The field ids for each atom must start at 1, and count upwards by 1.
152 * Skipping field ids is not allowed.
153 * - These form an API, so renaming, renumbering or removing fields is
154 * not allowed between android releases. (This is not currently enforced,
155 * but there will be a tool to enforce this restriction).
156 * - The types must be built-in protocol buffer types, namely, no sub-messages
157 * are allowed (yet). The bytes type is also not allowed.
158 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800159 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000160 * - If an atom represents work that can be attributed to an app, there can
Yangster-mac7604aea2017-12-11 22:55:49 -0800161 * be exactly one AttributionChain field. It must be field number 1.
Yao Chend54f9dd2017-10-17 17:37:48 +0000162 * - A field that is a uid should be a string field, tagged with the [xxx]
163 * annotation. The generated code on android will be represented by UIDs,
164 * and those UIDs will be translated in xxx to those strings.
165 *
166 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700167 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000168 * - If there is a UID, it goes first. Think in an object-oriented fashion.
169 * *****************************************************************************
170 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700171
Yao Chend54f9dd2017-10-17 17:37:48 +0000172/**
173 * Logs when the screen state changes.
174 *
175 * Logged from:
176 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
177 */
178message ScreenStateChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800179 // New screen state, from frameworks/base/core/proto/android/view/enums.proto.
180 optional android.view.DisplayStateEnum state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700181}
Yao Chend54f9dd2017-10-17 17:37:48 +0000182
183/**
Bookatzc1a050a2017-10-10 15:49:28 -0700184 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000185 *
186 * Logged from:
187 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
188 */
Bookatzc1a050a2017-10-10 15:49:28 -0700189message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000190 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
191
Bookatzdb026a22018-01-10 19:01:56 -0800192 // The state, from frameworks/base/core/proto/android/app/enums.proto.
193 optional android.app.ProcessStateEnum state = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000194}
195
196/**
Bookatzc1a050a2017-10-10 15:49:28 -0700197 * Logs that a process started, finished, crashed, or ANRed.
198 *
199 * Logged from:
200 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
201 */
202message ProcessLifeCycleStateChanged {
Bookatzc1a050a2017-10-10 15:49:28 -0700203 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
204
205 // TODO: What is this?
206 optional string name = 2;
207
Bookatzddccf0a2017-11-28 16:48:14 -0800208 // What lifecycle state the process changed to.
209 // This enum is specific to atoms.proto.
210 enum Event {
211 PROCESS_FINISHED = 0;
212 PROCESS_STARTED = 1;
213 PROCESS_CRASHED = 2;
214 PROCESS_ANRED = 3;
215 }
216 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700217}
218
Bookatzc1a050a2017-10-10 15:49:28 -0700219/**
220 * Logs when the ble scan state changes.
221 *
222 * Logged from:
223 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
224 */
225message BleScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800226 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700227
228 enum State {
229 OFF = 0;
230 ON = 1;
231 }
232 optional State state = 2;
233}
234
235/**
236 * Logs when an unoptimized ble scan state changes.
237 *
238 * Logged from:
239 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
240 */
241// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
242message BleUnoptimizedScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800243 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700244
245 enum State {
246 OFF = 0;
247 ON = 1;
248 }
249 optional State state = 2;
250}
251
252/**
253 * Logs reporting of a ble scan finding results.
254 *
255 * Logged from:
256 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
257 */
258// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
259message BleScanResultReceived {
Yangster-macafad8c62018-01-05 22:30:49 -0800260 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700261
262 // Number of ble scan results returned.
263 optional int32 num_of_results = 2;
264}
265
266/**
267 * Logs when a sensor state changes.
268 *
269 * Logged from:
270 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
271 */
272message SensorStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800273 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700274
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 {
Yangster-macafad8c62018-01-05 22:30:49 -0800294 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700295
296 enum State {
297 OFF = 0;
298 ON = 1;
299 }
300 optional State state = 2;
301}
302
303
304/**
305 * Logs when a sync manager sync state changes.
306 *
307 * Logged from:
308 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
309 */
310message SyncStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800311 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700312
313 // Name of the sync (as named in the app)
314 optional string name = 2;
315
316 enum State {
317 OFF = 0;
318 ON = 1;
319 }
320 optional State state = 3;
321}
322
323/**
324 * Logs when a job scheduler job state changes.
325 *
326 * Logged from:
327 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
328 */
329message ScheduledJobStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800330 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700331
332 // Name of the job (as named in the app)
333 optional string name = 2;
334
335 enum State {
Tej Singhd5747a62018-01-08 20:57:35 -0800336 FINISHED = 0;
337 STARTED = 1;
338 SCHEDULED = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700339 }
340 optional State state = 3;
341
342 // TODO: Consider adding the stopReason (int)
343}
344
345/**
346 * Logs when the audio state changes.
347 *
348 * Logged from:
349 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
350 */
351message AudioStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800352 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700353
354 enum State {
355 OFF = 0;
356 ON = 1;
357 }
358 optional State state = 2;
359}
360
361/**
362 * Logs when the video codec state changes.
363 *
364 * Logged from:
365 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
366 */
367message MediaCodecActivityChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800368 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700369
370 enum State {
371 OFF = 0;
372 ON = 1;
373 }
374 optional State state = 2;
375}
376
377/**
378 * Logs when the flashlight state changes.
379 *
380 * Logged from:
381 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
382 */
383message FlashlightStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800384 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700385
386 enum State {
387 OFF = 0;
388 ON = 1;
389 }
390 optional State state = 2;
391}
392
393/**
394 * Logs when the camera state changes.
395 *
396 * Logged from:
397 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
398 */
399message CameraStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800400 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700401
402 enum State {
403 OFF = 0;
404 ON = 1;
405 }
406 optional State state = 2;
407}
408
409/**
410 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000411 *
412 * Logged from:
413 * TODO
414 */
Bookatzd6746242017-10-24 18:39:35 -0700415message WakelockStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800416 repeated AttributionNode attribution_node = 1;
Yao Chend54f9dd2017-10-17 17:37:48 +0000417
Bookatz1a1b0462018-01-12 11:47:03 -0800418 // The type (level) of the wakelock; e.g. a partial wakelock or a full wakelock.
419 // From frameworks/base/core/proto/android/os/enums.proto.
420 optional android.os.WakeLockLevelEnum level = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700421
422 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
423 optional string tag = 3;
424
425 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800426 RELEASE = 0;
427 ACQUIRE = 1;
428 CHANGE_RELEASE = 2;
429 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700430 }
431 optional State state = 4;
432}
433
434/**
Bookatzc1a050a2017-10-10 15:49:28 -0700435 * Logs when a partial wakelock is considered 'long' (over 1 min).
436 *
437 * Logged from:
438 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
439 */
440message LongPartialWakelockStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800441 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700442
Yao Chend54f9dd2017-10-17 17:37:48 +0000443 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
444 optional string tag = 2;
445
Bookatzc1a050a2017-10-10 15:49:28 -0700446 // TODO: I have no idea what this is.
447 optional string history_tag = 3;
448
449 enum State {
450 OFF = 0;
451 ON = 1;
452 }
453 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000454}
455
Bookatzc1a050a2017-10-10 15:49:28 -0700456/**
457 * Logs Battery Saver state change.
458 *
459 * Logged from:
460 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
461 */
462message BatterySaverModeStateChanged {
463 enum State {
464 OFF = 0;
465 ON = 1;
466 }
467 optional State state = 1;
468}
469
470/**
471 * Logs Doze mode state change.
472 *
473 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800474 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700475 */
476message DeviceIdleModeStateChanged {
Bookatz8bdae8d2018-01-16 11:24:30 -0800477 optional android.server.DeviceIdleModeEnum state = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800478}
479
480
481/**
482 * Logs state change of Doze mode including maintenance windows.
483 *
484 * Logged from:
485 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
486 */
487message DeviceIdlingModeStateChanged {
Bookatz8bdae8d2018-01-16 11:24:30 -0800488 optional android.server.DeviceIdleModeEnum state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700489}
490
491/**
492 * Logs screen brightness level.
493 *
494 * Logged from:
495 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
496 */
497message ScreenBrightnessChanged {
498 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
499 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700500}
501
502/**
503 * Logs battery level (percent full, from 0 to 100).
504 *
505 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700506 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700507 */
508message BatteryLevelChanged {
509 // Battery level. Should be in [0, 100].
510 optional int32 battery_level = 1;
511}
512
513/**
514 * Logs change in charging status of the device.
515 *
516 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700517 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700518 */
519message ChargingStateChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800520 // State of the battery, from frameworks/base/core/proto/android/os/enums.proto.
521 optional android.os.BatteryStatusEnum state = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700522}
523
524/**
525 * Logs whether the device is plugged in, and what power source it is using.
526 *
527 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700528 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700529 */
530message PluggedStateChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800531 // Whether the device is plugged in, from frameworks/base/core/proto/android/os/enums.proto.
532 optional android.os.BatteryPluggedStateEnum state = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700533}
534
535/**
536 * Logs the temperature of the device, in tenths of a degree Celsius.
537 *
538 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700539 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700540 */
541message DeviceTemperatureReported {
542 // Temperature in tenths of a degree C.
543 optional int32 temperature = 1;
544}
545
546// TODO: Define this more precisely.
547// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
548/**
549 * Logs when the device turns off or on.
550 *
551 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700552 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700553 */
554message DeviceOnStatusChanged {
555 enum State {
556 OFF = 0;
557 ON = 1;
558 }
559 optional State state = 1;
560}
561
562/**
563 * Logs when an app's wakeup alarm fires.
564 *
565 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700566 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700567 */
568message WakeupAlarmOccurred {
Yangster-macafad8c62018-01-05 22:30:49 -0800569 repeated AttributionNode attribution_node = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800570
571 // Name of the wakeup alarm.
572 optional string tag = 2;
573}
574
575/**
576 * Logs when an an app causes the mobile radio to change state.
577 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
578 *
579 * Logged from:
580 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
581 */
582message MobileRadioPowerStateChanged {
583 // TODO: Add attribution instead of uid?
584 optional int32 uid = 1;
585
Bookatz1a1b0462018-01-12 11:47:03 -0800586 // Power state, from frameworks/base/core/proto/android/telephony/enums.proto.
587 optional android.telephony.DataConnectionPowerStateEnum state = 2;
Bookatzddccf0a2017-11-28 16:48:14 -0800588}
589
590/**
591 * Logs when an an app causes the wifi radio to change state.
592 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
593 *
594 * Logged from:
595 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
596 */
597message WifiRadioPowerStateChanged {
598 // TODO: Add attribution instead of uid?
599 optional int32 uid = 1;
600
Bookatz1a1b0462018-01-12 11:47:03 -0800601 // Power state, from frameworks/base/core/proto/android/telephony/enums.proto.
602 optional android.telephony.DataConnectionPowerStateEnum state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700603}
604
605/**
606 * Logs kernel wakeup reasons and aborts.
607 *
608 * Logged from:
609 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
610 */
611message KernelWakeupReported {
612 // Name of the kernel wakeup reason (or abort).
613 optional string wakeup_reason_name = 1;
614
615 // Duration (in microseconds) for the wake-up interrupt to be serviced.
616 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700617}
618
619/**
620 * Logs wifi locks held by an app.
621 *
622 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700623 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700624 */
625message WifiLockStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800626 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700627
628 enum State {
629 OFF = 0;
630 ON = 1;
631 }
632 optional State state = 2;
633}
634
635/**
636 * Logs wifi signal strength changes.
637 *
638 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700639 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700640 */
641message WifiSignalStrengthChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800642 // Signal strength, from frameworks/base/core/proto/android/telephony/enums.proto.
643 optional android.telephony.SignalStrengthEnum signal_strength = 1;
Bookatze5885242017-10-24 20:10:31 -0700644}
645
646/**
647 * Logs wifi scans performed by an app.
648 *
649 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700650 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700651 */
652message WifiScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800653 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700654
655 enum State {
656 OFF = 0;
657 ON = 1;
658 }
659 optional State state = 2;
660}
661
662/**
Tej Singh4503e102018-01-04 14:35:01 -0800663 * Logs wifi multicast locks held by an app
664 *
665 * Logged from:
666 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
667 */
668message WifiMulticastLockStateChanged {
669 repeated AttributionNode attribution_node = 1;
670
671 enum State {
672 OFF = 0;
673 ON = 1;
674 }
675 optional State state = 2;
676}
677
678/**
Tej Singh1ea42892018-01-19 09:27:00 -0800679 * Logs shutdown reason and duration on next boot.
680 *
681 * Logged from:
682 * frameworks/base/core/java/com/android/server/BootReceiver.java
683 */
684message ShutdownSequenceReported {
685 // True if shutdown is for a reboot. Default: false if we do not know.
686 optional bool reboot = 1;
687
688 // Reason for shutdown. Eg: userrequested. Default: "<EMPTY>".
689 optional string reason = 2;
690
691 // Beginning of shutdown time in ms using wall clock time since unix epoch.
692 // Default: 0 if no start time received.
693 optional int64 start_time_ms = 3;
694
695 // Duration of shutdown in ms. Default: 0 if no duration received.
696 optional int64 duration_ms = 4;
697}
698
Tej Singh6483ea42018-01-25 17:45:49 -0800699
700/**
701 * Logs boot reason and duration.
702 *
703 * Logged from:
704 * system/core/bootstat/bootstat.cpp
705 */
706message BootSequenceReported {
707 // Reason for bootloader boot. Eg. reboot. See bootstat.cpp for larger list
708 // Default: "<EMPTY>" if not available.
709 optional string bootloader_reason = 1;
710
711 // Reason for system boot. Eg. bootloader, reboot,userrequested
712 // Default: "<EMPTY>" if not available.
713 optional string system_reason = 2;
714
715 // End of boot time in ms from unix epoch using system wall clock.
716 optional int64 end_time_ms = 3;
717
718 // Total boot duration in ms.
719 optional int64 total_duration_ms = 4;
720
721 // Bootloader duration in ms.
722 optional int64 bootloader_duration_ms = 5;
723
724 // Time since last boot in ms. Default: 0 if not available.
725 optional int64 time_since_last_boot = 6;
726}
727
Tej Singh1ea42892018-01-19 09:27:00 -0800728/**
Tej Singhbb8554a2018-01-26 11:59:14 -0800729 * Logs the duration of a davey (jank of >=700ms) when it occurs
730 *
731 * Logged from:
732 * frameworks/base/libs/hwui/JankTracker.cpp
733 */
734message DaveyOccurred {
735 // Amount of time it took to render the frame. Should be >=700ms.
736 optional int64 jank_duration_ms = 1;
737}
738
739/**
Bookatze5885242017-10-24 20:10:31 -0700740 * Logs phone signal strength changes.
741 *
742 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700743 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700744 */
745message PhoneSignalStrengthChanged {
Bookatz1a1b0462018-01-12 11:47:03 -0800746 // Signal strength, from frameworks/base/core/proto/android/telephony/enums.proto.
747 optional android.telephony.SignalStrengthEnum signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700748}
749
750/**
751 * Logs that a setting was updated.
752 * Logged from:
753 * frameworks/base/core/java/android/provider/Settings.java
754 * The tag and is_default allow resetting of settings to default values based on the specified
755 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
756 */
757message SettingChanged {
758 // The name of the setting.
759 optional string setting = 1;
760
761 // The change being imposed on this setting. May represent a number, eg "3".
762 optional string value = 2;
763
764 // The new value of this setting. For most settings, this is same as value. For some settings,
765 // value is +X or -X where X represents an element in a set. For example, if the previous value
766 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
767 // The +/- feature is currently only used for location_providers_allowed.
768 optional string new_value = 3;
769
770 // The previous value of this setting.
771 optional string prev_value = 4;
772
773 // The tag used with the is_default for resetting sets of settings. This is generally null.
774 optional string tag = 5;
775
Bookatz90867622018-01-31 15:05:57 -0800776 // True if this setting with tag should be resettable.
777 optional bool is_default = 6;
David Chenc28b2bb2017-10-24 12:52:52 -0700778
779 // The user ID associated. Defined in android/os/UserHandle.java
780 optional int32 user = 7;
781}
Chenjie Yub3dda412017-10-24 13:41:59 -0700782
Chenjie Yu05013b32017-11-21 10:21:41 -0800783/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700784 * Logs activity going to foreground or background
785 *
786 * Logged from:
787 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
788 */
789message ActivityForegroundStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800790 optional int32 uid = 1;
791 optional string pkg_name = 2;
792 optional string class_name = 3;
793
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700794 enum Activity {
795 MOVE_TO_BACKGROUND = 0;
796 MOVE_TO_FOREGROUND = 1;
797 }
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700798 optional Activity activity = 4;
799}
David Chenc8a43242017-10-17 16:23:28 -0700800
801/**
David Chen9e3808c2017-11-20 17:25:34 -0800802 * Logs when an error is written to dropbox.
803 * Logged from:
804 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
805 */
806message DropboxErrorChanged {
807 // The uid if available. -1 means not available.
808 optional int32 uid = 1;
809
810 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
811 optional string tag = 2;
812
813 // The name of the process.
814 optional string process_name = 3;
815
816 // The pid if available. -1 means not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800817 optional sint32 pid = 4;
David Chen9e3808c2017-11-20 17:25:34 -0800818
819 // 1 indicates is instant app. -1 indicates Not applicable.
David Chen6e3e6cb2018-01-03 16:14:06 -0800820 optional sint32 is_instant_app = 5;
David Chen9e3808c2017-11-20 17:25:34 -0800821
822 // The activity name if available.
823 optional string activity_name = 6;
824
David Chen6e3e6cb2018-01-03 16:14:06 -0800825 // The package name if available.
826 optional string package_name = 7;
827
David Chen9e3808c2017-11-20 17:25:34 -0800828 // 1 indicates in foreground. -1 indicates not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800829 optional sint32 is_foreground = 8;
David Chen9e3808c2017-11-20 17:25:34 -0800830}
831
David Chen0a368b22017-12-06 16:28:16 -0800832/*
833 * Allows other apps to push events into statsd.
834 * Logged from:
835 * frameworks/base/core/java/android/util/StatsLog.java
836 */
837message AppHook {
838 // The uid of the application that sent this custom atom.
839 optional int32 uid = 1;
840
841 // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
842 optional int32 label = 2;
843
844 // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
845 // predicates for the metrics).
846 enum State {
847 UNKNOWN = 0;
848 UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
849 STOP = 2;
850 START = 3;
851 }
852 optional State state = 3;
853}
854
David Chen9e3808c2017-11-20 17:25:34 -0800855/**
Bookatz8fcd09a2017-12-18 13:01:10 -0800856 * Logs when statsd detects an anomaly.
857 *
858 * Logged from:
859 * frameworks/base/cmds/statsd/src/anomaly/AnomalyTracker.cpp
860 */
861message AnomalyDetected {
862 // Uid that owns the config whose anomaly detection alert fired.
863 optional int32 config_uid = 1;
864
Yangster-mac94e197c2018-01-02 16:03:03 -0800865 // Id of the config whose anomaly detection alert fired.
866 optional int64 config_id = 2;
Bookatz8fcd09a2017-12-18 13:01:10 -0800867
Yangster-mac94e197c2018-01-02 16:03:03 -0800868 // Id of the alert (i.e. name of the anomaly that was detected).
869 optional int64 alert_id = 3;
Bookatz8fcd09a2017-12-18 13:01:10 -0800870}
871
Olivier Gaillardaed7f122017-12-12 14:26:22 +0000872message AppStartChanged {
873 // The uid if available. -1 means not available.
874 optional int32 uid = 1;
875
876 // The app package name.
877 optional string pkg_name = 2;
878
879 enum TransitionType {
880 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
881 WARM = 1;
882 HOT = 2;
883 COLD = 3;
884 }
885 // The transition type.
886 optional TransitionType type = 3;
887
888 // The activity name.
889 optional string activity_name = 4;
890
891 // The name of the calling app. Empty if not set.
892 optional string calling_pkg_name = 5;
893
894 // Whether the app is an instant app.
895 optional bool is_instant_app = 6;
896
897 // Device uptime when activity started.
898 optional int64 activity_start_msec = 7;
899
Bookatz80d11a02018-01-16 10:46:35 -0800900 optional android.app.AppTransitionReasonEnum reason = 8;
Olivier Gaillardaed7f122017-12-12 14:26:22 +0000901
902 optional int32 transition_delay_msec = 9;
903 // -1 if not set.
904 optional int32 starting_window_delay_msec = 10;
905 // -1 if not set.
906 optional int32 bind_application_delay_msec = 11;
907 optional int32 windows_drawn_delay_msec = 12;
908
909 // Empty if not set.
910 optional string launch_token = 13;
911
912}
913
914message AppStartCancelChanged {
915 // The uid if available. -1 means not available.
916 optional int32 uid = 1;
917
918 // The app package name.
919 optional string pkg_name = 2;
920
921 enum TransitionType {
922 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
923 WARM = 1;
924 HOT = 2;
925 COLD = 3;
926 }
927 // The transition type.
928 optional TransitionType type = 3;
929
930 // The activity name.
931 optional string activity_name = 4;
932}
933
934message AppStartFullyDrawnChanged {
935 // The uid if available. -1 means not available.
936 optional int32 uid = 1;
937
938 // The app package name.
939 optional string pkg_name = 2;
940
941 enum TransitionType {
942 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
943 WITH_BUNDLE = 1;
944 WITHOUT_BUNDLE = 2;
945 }
946 // The transition type.
947 optional TransitionType type = 3;
948
949 // The activity name.
950 optional string activity_name = 4;
951
952 optional bool transition_process_running = 5;
953
954 // App startup time (until call to Activity#reportFullyDrawn()).
955 optional int64 app_startup_time_ms = 6;
956}
957
Bookatz8fcd09a2017-12-18 13:01:10 -0800958/**
Chenjie Yu52cacc62017-12-08 18:11:45 -0800959 * Logs a picture-in-picture action
960 * Logged from:
961 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
962 * frameworks/base/services/core/java/com/android/server/am/ActivityStackSupervisor.java
963 * frameworks/base/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
964 */
965message PictureInPictureStateChanged {
966 optional int32 uid = 1;
967
968 optional string package_name = 2;
969
970 optional string class_name = 3;
971
972 // Picture-in-Picture action occurred, similar to
973 // frameworks/base/proto/src/metrics_constants.proto
974 enum State {
975 ENTERED = 1;
976 EXPANDED_TO_FULL_SCREEN = 2;
977 MINIMIZED = 3;
978 DISMISSED = 4;
979 }
980 optional State state = 4;
981}
982
983/**
Chenjie Yue8904192017-12-08 19:12:57 -0800984 * Logs overlay action
985 * Logged from:
986 * services/core/java/com/android/server/wm/Session.java
987 */
988message OverlayStateChanged {
989 optional int32 uid = 1;
990
991 optional string package_name = 2;
992
993 optional bool using_alert_window = 3;
994
995 enum State {
996 ENTERED = 1;
997 EXITED = 2;
998 }
999 optional State state = 4;
1000}
1001
Chenjie Yuccfe6452018-01-30 11:33:21 -08001002/*
1003 * Logs foreground service starts and stops.
1004 * Note that this is not when a service starts or stops, but when it is
1005 * considered foreground.
1006 * Logged from
1007 * //frameworks/base/services/core/java/com/android/server/am/ActiveServices.java
1008 */
1009message ForegroundServiceStateChanged {
1010 optional int32 uid = 1;
1011 // package_name + "/" + class_name
1012 optional string short_name = 2;
1013
1014 enum State {
1015 ENTER = 1;
1016 EXIT = 2;
1017 }
1018 optional State state = 3;
1019}
1020
Chenjie Yue8904192017-12-08 19:12:57 -08001021/**
David Chenc8a43242017-10-17 16:23:28 -07001022 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
1023 *
1024 * Pulled from:
1025 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
1026 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001027message WifiBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -07001028 optional int32 uid = 1;
1029
1030 optional int64 rx_bytes = 2;
1031
1032 optional int64 rx_packets = 3;
1033
1034 optional int64 tx_bytes = 4;
1035
1036 optional int64 tx_packets = 5;
1037}
1038
1039/**
1040 * Pulls bytes transferred via wifi (separated by foreground and background usage).
1041 *
1042 * Pulled from:
1043 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
1044 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001045message WifiBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -07001046 optional int32 uid = 1;
1047
1048 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
1049 optional int32 is_foreground = 2;
1050
1051 optional int64 rx_bytes = 3;
1052
1053 optional int64 rx_packets = 4;
1054
1055 optional int64 tx_bytes = 5;
1056
1057 optional int64 tx_packets = 6;
1058}
1059
1060/**
1061 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
1062 *
1063 * Pulled from:
1064 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1065 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001066message MobileBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -07001067 optional int32 uid = 1;
1068
1069 optional int64 rx_bytes = 2;
1070
1071 optional int64 rx_packets = 3;
1072
1073 optional int64 tx_bytes = 4;
1074
1075 optional int64 tx_packets = 5;
1076}
1077
1078/**
1079 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
1080 *
1081 * Pulled from:
1082 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1083 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001084message MobileBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -07001085 optional int32 uid = 1;
1086
1087 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
1088 optional int32 is_foreground = 2;
1089
1090 optional int64 rx_bytes = 3;
1091
1092 optional int64 rx_packets = 4;
1093
1094 optional int64 tx_bytes = 5;
1095
1096 optional int64 tx_packets = 6;
1097}
1098
1099/**
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001100 * Pulls bytes transferred via bluetooth. It is pulled from Bluetooth controller.
1101 *
1102 * Pulled from:
1103 * StatsCompanionService
1104 */
1105message BluetoothBytesTransfer {
1106 optional int32 uid = 1;
1107
1108 optional int64 rx_bytes = 2;
1109
1110 optional int64 tx_bytes = 3;
1111}
1112
1113/**
David Chenc8a43242017-10-17 16:23:28 -07001114 * Pulls the kernel wakelock durations. This atom is adapted from
1115 * android/internal/os/KernelWakelockStats.java
1116 *
1117 * Pulled from:
1118 * StatsCompanionService using KernelWakelockReader.
1119 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001120message KernelWakelock {
David Chenc8a43242017-10-17 16:23:28 -07001121 optional string name = 1;
1122
1123 optional int32 count = 2;
1124
1125 optional int32 version = 3;
1126
1127 optional int64 time = 4;
1128}
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001129
Chenjie Yu05013b32017-11-21 10:21:41 -08001130/**
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001131 * Pulls low power state information. This includes platform and subsystem sleep state information,
1132 * PowerStatePlatformSleepState, PowerStateVoter or PowerStateSubsystemSleepState as defined in
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001133 * hardware/interfaces/power/1.0/types.hal
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001134 * hardware/interfaces/power/1.1/types.hal
1135 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001136message SubsystemSleepState {
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001137 // Name should be in the format of XXX.YYY where XXX is subsystem name,
1138 // YYY is corresponding voter name.
1139 // If there are no voters, the format should just be XXX (with no dot).
1140 // XXX and YYY should not contain a "." in it.
1141 optional string name = 1;
1142 // The number of times it entered, or voted for entering the sleep state
1143 optional uint64 count = 2;
1144 // The length of time spent in, or spent voting for, the sleep state
1145 optional uint64 timeMs = 3;
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001146}
David Chen21582962017-11-01 17:32:46 -07001147
1148/**
1149 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
1150 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
1151 * attributed back to the parent (host) uid. One example is Chrome.
1152 *
1153 * Logged from:
1154 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
1155 */
1156message IsolatedUidChanged {
1157 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
1158 optional int32 parent_uid = 1;
1159
1160 optional int32 isolated_uid = 2;
1161
Bookatz90867622018-01-31 15:05:57 -08001162 // We expect an isolated uid to be removed before if it's used for another parent uid.
1163 enum Event {
1164 REMOVED = 0;
1165 CREATED = 1;
1166 }
1167 optional Event event = 3;
David Chen21582962017-11-01 17:32:46 -07001168}
Chenjie Yu7f8def92017-11-03 09:33:15 -07001169
Chenjie Yu05013b32017-11-21 10:21:41 -08001170/**
Chenjie Yu7f8def92017-11-03 09:33:15 -07001171 * Pulls Cpu time per frequency.
Chenjie Yu1ee9b742018-01-10 16:02:57 -08001172 * Pulls the time the cpu spend on the frequency index. Frequency index
1173 * starts from highest to lowest. The value should be monotonically
1174 * increasing since boot. However, if there is a cpu
1175 * hotplug event, the value would be reset as well.
Chenjie Yu7f8def92017-11-03 09:33:15 -07001176 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001177message CpuTimePerFreq {
Chenjie Yu7f8def92017-11-03 09:33:15 -07001178 optional uint32 cluster = 1;
1179 optional uint32 freq_index = 2;
Chenjie Yu31d14d72017-12-12 17:54:33 -08001180 optional uint64 time_ms = 3;
Chenjie Yu7f8def92017-11-03 09:33:15 -07001181}
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001182
Chenjie Yu05013b32017-11-21 10:21:41 -08001183/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001184 * Pulls Cpu Time Per Uid.
1185 * Note that isolated process uid time should be attributed to host uids.
1186 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001187message CpuTimePerUid {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001188 optional uint64 uid = 1;
1189 optional uint64 user_time_ms = 2;
1190 optional uint64 sys_time_ms = 3;
1191}
1192
1193/**
1194 * Pulls Cpu Time Per Uid per frequency.
1195 * Note that isolated process uid time should be attributed to host uids.
1196 * For each uid, we order the time by descending frequencies.
1197 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001198message CpuTimePerUidFreq {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001199 optional uint64 uid = 1;
1200 optional uint64 freq_idx = 2;
1201 optional uint64 time_ms = 3;
1202}
Hugo Benichi884970e2017-11-14 22:42:46 +09001203
1204/*
1205 * Logs the reception of an incoming network packet causing the main system to wake up for
1206 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1207 * and processed by WakeupController.cpp.
1208 */
1209message PacketWakeupOccurred {
1210 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1211 // delivered nowhere.
1212 optional int32 uid = 1;
1213 // The interface name on which the packet was received.
1214 optional string iface = 2;
1215 // The ethertype value of the packet.
1216 optional int32 ethertype = 3;
1217 // String representation of the destination MAC address of the packet.
1218 optional string destination_hardware_address = 4;
1219 // String representation of the source address of the packet if this was an IP packet.
1220 optional string source_ip = 5;
1221 // String representation of the destination address of the packet if this was an IP packet.
1222 optional string destination_ip = 6;
1223 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1224 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1225 // families.
1226 optional int32 ip_next_header = 7;
1227 // The source port if this was a TCP or UDP packet.
1228 optional int32 source_port = 8;
1229 // The destination port if this was a TCP or UDP packet.
1230 optional int32 destination_port = 9;
1231}
Chenjie Yu05013b32017-11-21 10:21:41 -08001232
1233/**
1234 * Pulls Wifi Controller Activity Energy Info
1235 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001236message WifiActivityEnergyInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001237 // timestamp(wall clock) of record creation
1238 optional uint64 timestamp_ms = 1;
1239 // stack reported state
1240 // TODO: replace this with proto enum
1241 optional int32 stack_state = 2;
1242 // tx time in ms
1243 optional uint64 controller_tx_time_ms = 3;
1244 // rx time in ms
1245 optional uint64 controller_rx_time_ms = 4;
1246 // idle time in ms
1247 optional uint64 controller_idle_time_ms = 5;
1248 // product of current(mA), voltage(V) and time(ms)
1249 optional uint64 controller_energy_used = 6;
1250}
1251
1252/**
1253 * Pulls Modem Activity Energy Info
1254 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001255message ModemActivityInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001256 // timestamp(wall clock) of record creation
1257 optional uint64 timestamp_ms = 1;
1258 // sleep time in ms.
1259 optional uint64 sleep_time_ms = 2;
1260 // idle time in ms
1261 optional uint64 controller_idle_time_ms = 3;
1262 /**
1263 * Tx power index
1264 * index 0 = tx_power < 0dBm
1265 * index 1 = 0dBm < tx_power < 5dBm
1266 * index 2 = 5dBm < tx_power < 15dBm
1267 * index 3 = 15dBm < tx_power < 20dBm
1268 * index 4 = tx_power > 20dBm
1269 */
1270 // tx time in ms at power level 0
1271 optional uint64 controller_tx_time_pl0_ms = 4;
1272 // tx time in ms at power level 1
1273 optional uint64 controller_tx_time_pl1_ms = 5;
1274 // tx time in ms at power level 2
1275 optional uint64 controller_tx_time_pl2_ms = 6;
1276 // tx time in ms at power level 3
1277 optional uint64 controller_tx_time_pl3_ms = 7;
1278 // tx time in ms at power level 4
1279 optional uint64 controller_tx_time_pl4_ms = 8;
1280 // rx time in ms at power level 5
1281 optional uint64 controller_rx_time_ms = 9;
1282 // product of current(mA), voltage(V) and time(ms)
1283 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001284}
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001285
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001286/**
1287 * Pulls Bluetooth Activity Energy Info
1288 * Note: BluetoothBytesTransfer is pulled at the same time from the controller.
1289 */
1290message BluetoothActivityInfo {
1291 // timestamp(wall clock) of record creation
1292 optional uint64 timestamp_ms = 1;
1293 // bluetooth stack state
1294 optional int32 bluetooth_stack_state = 2;
1295 // tx time in ms
1296 optional uint64 controller_tx_time_ms = 3;
1297 // rx time in ms
1298 optional uint64 controller_rx_time_ms = 4;
1299 // idle time in ms
1300 optional uint64 controller_idle_time_ms = 5;
1301 // product of current(mA), voltage(V) and time(ms)
1302 optional uint64 energy_used = 6;
1303}
1304
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001305/*
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001306 * Logs the memory stats for an app on startup.
1307 * Logged from:
1308 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001309 */
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001310message AppStartMemoryStateCaptured {
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001311 // The uid if available. -1 means not available.
1312 optional int32 uid = 1;
1313
Rajeev Kumar27572b92018-01-23 16:12:51 -08001314 // The process name.
1315 optional string process_name = 2;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001316
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001317 // The activity name.
1318 optional string activity_name = 3;
1319
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001320 // # of page-faults
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001321 optional int64 pgfault = 4;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001322
1323 // # of major page-faults
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001324 optional int64 pgmajfault = 5;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001325
Rajeev Kumar90235992018-01-29 11:06:48 -08001326 // RSS
1327 optional int64 rss_in_bytes = 6;
1328
1329 // CACHE
1330 optional int64 cache_in_bytes = 7;
1331
1332 // SWAP
1333 optional int64 swap_in_bytes = 8;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001334}
1335
1336/*
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001337 * Logs the memory stats for a process.
1338 */
1339message ProcessMemoryState {
1340 // The uid if available. -1 means not available.
1341 optional int32 uid = 1;
1342
1343 // The process name.
1344 optional string process_name = 2;
1345
1346 // oom adj score.
1347 optional int32 oom_score = 3;
1348
1349 // # of page-faults
1350 optional int64 pgfault = 4;
1351
1352 // # of major page-faults
1353 optional int64 pgmajfault = 5;
1354
Rajeev Kumar90235992018-01-29 11:06:48 -08001355 // RSS
1356 optional int64 rss_in_bytes = 6;
1357
1358 // CACHE
1359 optional int64 cache_in_bytes = 7;
1360
1361 // SWAP
1362 optional int64 swap_in_bytes = 8;
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001363}
1364
1365/*
1366 * Logs the change in Low Memory Killer Daemon (LMKD) state which is used as start/stop boundaries
1367 * for LMK event.
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001368 * Logged from:
1369 * system/core/lmkd/lmkd.c
1370 */
Rajeev Kumar8a9fa052018-01-25 19:03:09 -08001371message LmkStateChanged {
1372 enum State {
1373 UNKNOWN = 0;
1374 START = 1;
1375 STOP = 2;
1376 }
1377 optional State state = 1;
1378}
1379
1380/*
1381 * Logs the event when Low Memory Killer Daemon (LMKD) kills a process to reduce memory pressure.
1382 * Logged from:
1383 * system/core/lmkd/lmkd.c
1384 */
1385message LmkKillOccurred {
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001386 // The uid if available. -1 means not available.
1387 optional int32 uid = 1;
1388
Rajeev Kumar27572b92018-01-23 16:12:51 -08001389 // The process name.
1390 optional string process_name = 2;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001391
1392 // oom adj score.
1393 optional int32 oom_score = 3;
1394
Rajeev Kumar27572b92018-01-23 16:12:51 -08001395 // # of page-faults
1396 optional int64 pgfault = 4;
1397
1398 // # of major page-faults
1399 optional int64 pgmajfault = 5;
1400
Rajeev Kumar90235992018-01-29 11:06:48 -08001401 // RSS
1402 optional int64 rss_in_bytes = 6;
1403
1404 // CACHE
1405 optional int64 cache_in_bytes = 7;
1406
1407 // SWAP
1408 optional int64 swap_in_bytes = 8;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001409}
Chenjie Yu9da105b2018-01-13 12:41:08 -08001410
1411/*
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001412 * Elapsed real time from SystemClock.
Chenjie Yu9da105b2018-01-13 12:41:08 -08001413 */
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001414message SystemElapsedRealtime {
1415 optional uint64 time_ms = 1;
Chenjie Yu9da105b2018-01-13 12:41:08 -08001416}
1417
1418/*
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001419 * Up time from SystemClock.
Chenjie Yu9da105b2018-01-13 12:41:08 -08001420 */
Chenjie Yu9d7720b2018-01-24 10:34:48 -08001421message SystemUptime {
1422 // Milliseconds since the system was booted.
1423 // This clock stops when the system enters deep sleep (CPU off, display dark, device waiting
1424 // for external input).
1425 // It is not affected by clock scaling, idle, or other power saving mechanisms.
1426 optional uint64 uptime_ms = 1;
Chenjie Yu9da105b2018-01-13 12:41:08 -08001427}
1428
1429/*
1430 * Reads from /proc/uid_concurrent_active_time which has the format:
1431 * active: X (X is # cores)
1432 * [uid0]: [time-0] [time-1] [time-2] ... (# entries = # cores)
1433 * [uid1]: [time-0] [time-1] [time-2] ... ...
1434 * ...
1435 * Time-N means the CPU time a UID spent running concurrently with N other processes.
1436 * The file contains a monotonically increasing count of time for a single boot.
1437 */
1438message CpuActiveTime {
1439 optional uint64 uid = 1;
1440 optional uint64 idx = 2;
1441 optional uint64 time_ms = 3;
1442}
1443
1444/**
1445 * Reads from /proc/uid_concurrent_policy_time which has the format:
1446 * policy0: X policy4: Y (there are X cores on policy0, Y cores on policy4)
1447 * [uid0]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1448 * [uid1]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1449 * ...
1450 * Time-X-Y means the time a UID spent on clusterX running concurrently with Y other processes.
1451 * The file contains a monotonically increasing count of time for a single boot.
1452 */
1453message CpuClusterTime {
1454 optional uint64 uid = 1;
1455 optional uint64 idx = 2;
1456 optional uint64 time_ms = 3;
Chenjie Yu937d7422018-01-10 16:37:53 -08001457}
1458
1459/*
1460 * Pulls free disk space, for data, system partition and temporary directory.
1461 */
1462message DiskSpace {
1463 // available bytes in data partition
1464 optional uint64 data_available_bytes = 1;
1465 // available bytes in system partition
1466 optional uint64 system_available_bytes = 2;
1467 // available bytes in download cache or temp directories
1468 optional uint64 temp_available_bytes = 3;
1469}
Tej Singhbf972d92018-01-10 20:51:13 -08001470
1471/**
1472 * Pulls battery coulomb counter, which is the remaining battery charge in uAh.
1473 * Logged from: frameworks/base/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
1474 */
1475message RemainingBatteryCapacity {
1476 optional int32 charge_uAh = 1;
1477}
1478
1479/**
1480 * Pulls battery capacity, which is the battery capacity when full in uAh.
1481 * Logged from: frameworks/base/cmds/statsd/src/external/ResourceHealthManagerPuller.cpp
1482 */
1483message FullBatteryCapacity {
1484 optional int32 capacity_uAh = 1;
1485}
Chenjie Yuccfe6452018-01-30 11:33:21 -08001486