blob: 7f0ebb45e2d767b1846f284d502a1ffbee49dc59 [file] [log] [blame]
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070018
Yao Chend54f9dd2017-10-17 17:37:48 +000019// TODO: Not the right package and class name
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070020package android.os.statsd;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070021option java_package = "com.android.os";
Stefan Lafonae2df012017-11-14 09:17:21 -080022option java_outer_classname = "AtomsProto";
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -070023
Joe Onorato62c220b2017-11-18 20:32:56 -080024import "frameworks/base/core/proto/android/app/activitymanager.proto";
25
Yao Chend54f9dd2017-10-17 17:37:48 +000026/**
Stefan Lafonae2df012017-11-14 09:17:21 -080027 * The master atom class. This message defines all of the available
Yao Chend54f9dd2017-10-17 17:37:48 +000028 * raw stats log events from the Android system, also known as "atoms."
29 *
30 * This field contains a single oneof with all of the available messages.
31 * The stats-log-api-gen tool runs as part of the Android build and
32 * generates the android.util.StatsLog class, which contains the constants
33 * and methods that Android uses to log.
34 *
Stefan Lafonae2df012017-11-14 09:17:21 -080035 * This Atom class is not actually built into the Android system.
Yao Chend54f9dd2017-10-17 17:37:48 +000036 * Instead, statsd on Android constructs these messages synthetically,
37 * in the format defined here and in stats_log.proto.
38 */
Stefan Lafonae2df012017-11-14 09:17:21 -080039message Atom {
40 // Pushed atoms start at 2.
David Chenc8a43242017-10-17 16:23:28 -070041 oneof pushed {
Bookatzc1a050a2017-10-10 15:49:28 -070042 // For StatsLog reasons, 1 is illegal and will not work. Must start at 2.
43 BleScanStateChanged ble_scan_state_changed = 2;
44 BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
45 BleScanResultReceived ble_scan_result_received = 4;
46 SensorStateChanged sensor_state_changed = 5;
47 GpsScanStateChanged gps_scan_state_changed = 6; // TODO: untested
48 SyncStateChanged sync_state_changed = 7;
49 ScheduledJobStateChanged scheduled_job_state_changed = 8;
50 ScreenBrightnessChanged screen_brightness_changed = 9;
Bookatzd6746242017-10-24 18:39:35 -070051 WakelockStateChanged wakelock_state_changed = 10;
Bookatzddccf0a2017-11-28 16:48:14 -080052 LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 11;
53 MobileRadioPowerStateChanged mobile_radio_power_state_changed = 12;
54 WifiRadioPowerStateChanged wifi_radio_power_state_changed = 13;
55 // TODO: 14-19 are blank, but need not be
56 BatterySaverModeStateChanged battery_saver_mode_state_changed = 20;
57 DeviceIdleModeStateChanged device_idle_mode_state_changed = 21;
58 DeviceIdlingModeStateChanged device_idling_mode_state_changed = 22;
Bookatzc1a050a2017-10-10 15:49:28 -070059 AudioStateChanged audio_state_changed = 23;
60 MediaCodecActivityChanged media_codec_activity_changed = 24;
61 CameraStateChanged camera_state_changed = 25;
62 FlashlightStateChanged flashlight_state_changed = 26;
63 UidProcessStateChanged uid_process_state_changed = 27;
64 ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28;
65 ScreenStateChanged screen_state_changed = 29;
Bookatz8c6571b2017-10-24 15:04:41 -070066 BatteryLevelChanged battery_level_changed = 30;
67 ChargingStateChanged charging_state_changed = 31;
68 PluggedStateChanged plugged_state_changed = 32;
69 DeviceTemperatureReported device_temperature_reported = 33;
70 DeviceOnStatusChanged device_on_status_changed = 34;
71 WakeupAlarmOccurred wakeup_alarm_occurred = 35;
72 KernelWakeupReported kernel_wakeup_reported = 36;
Bookatze5885242017-10-24 20:10:31 -070073 WifiLockStateChanged wifi_lock_state_changed = 37;
74 WifiSignalStrengthChanged wifi_signal_strength_changed = 38;
75 WifiScanStateChanged wifi_scan_state_changed = 39;
76 PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
David Chenc28b2bb2017-10-24 12:52:52 -070077 SettingChanged setting_changed = 41;
David Chenc8a43242017-10-17 16:23:28 -070078 ActivityForegroundStateChanged activity_foreground_state_changed = 42;
David Chen21582962017-11-01 17:32:46 -070079 IsolatedUidChanged isolated_uid_changed = 43;
Hugo Benichi884970e2017-11-14 22:42:46 +090080 PacketWakeupOccurred packet_wakeup_occurred = 44;
David Chen9e3808c2017-11-20 17:25:34 -080081 DropboxErrorChanged dropbox_error_changed = 45;
Bookatz8fcd09a2017-12-18 13:01:10 -080082 AnomalyDetected anomaly_detected = 46;
83 AppHook app_hook = 47;
Olivier Gaillardaed7f122017-12-12 14:26:22 +000084 AppStartChanged app_start_changed = 48;
85 AppStartCancelChanged app_start_cancel_changed = 49;
86 AppStartFullyDrawnChanged app_start_fully_drawn_changed = 50;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -080087 LmkEventOccurred lmk_event_occurred = 51;
Chenjie Yu52cacc62017-12-08 18:11:45 -080088 PictureInPictureStateChanged picture_in_picture_state_changed = 52;
Tej Singh4503e102018-01-04 14:35:01 -080089 WifiMulticastLockStateChanged wifi_multicast_lock_state_changed = 53;
Bookatzc1a050a2017-10-10 15:49:28 -070090 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000091 }
David Chenc8a43242017-10-17 16:23:28 -070092
David Chen6e3e6cb2018-01-03 16:14:06 -080093 // Pulled events will start at field 10000.
David Chenc8a43242017-10-17 16:23:28 -070094 oneof pulled {
David Chen6e3e6cb2018-01-03 16:14:06 -080095 WifiBytesTransfer wifi_bytes_transfer = 10000;
96 WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
97 MobileBytesTransfer mobile_bytes_transfer = 10002;
98 MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 10003;
99 KernelWakelock kernel_wakelock = 10004;
Chenjie Yuc8b7f222018-01-11 23:25:57 -0800100 SubsystemSleepState subsystem_sleep_state = 10005;
101 // 10006 and 10007 are free to use.
David Chen6e3e6cb2018-01-03 16:14:06 -0800102 CpuTimePerFreq cpu_time_per_freq = 10008;
103 CpuTimePerUid cpu_time_per_uid = 10009;
104 CpuTimePerUidFreq cpu_time_per_uid_freq = 10010;
105 WifiActivityEnergyInfo wifi_activity_energy_info = 10011;
106 ModemActivityInfo modem_activity_info = 10012;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -0800107 MemoryStat memory_stat = 10013;
Chenjie Yu9da105b2018-01-13 12:41:08 -0800108 CpuSuspendTime cpu_suspend_time = 10014;
109 CpuIdleTime cpu_idle_time = 10015;
110 CpuActiveTime cpu_active_time = 10016;
111 CpuClusterTime cpu_cluster_time = 10017;
Chenjie Yu937d7422018-01-10 16:37:53 -0800112 DiskSpace disk_space = 10018;
113 SystemUptime system_uptime = 10019;
David Chenc8a43242017-10-17 16:23:28 -0700114 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700115}
116
Yao Chend54f9dd2017-10-17 17:37:48 +0000117/**
Yangster-mac20877162017-12-22 17:19:39 -0800118 * This proto represents a node of an attribution chain.
119 * Note: All attribution chains are represented as a repeated field of type
120 * AttributionNode. It is understood that in such arrays, the order is that
121 * of calls, that is [A, B, C] if A calls B that calls C.
Yao Chend54f9dd2017-10-17 17:37:48 +0000122 */
Yangster-mac20877162017-12-22 17:19:39 -0800123message AttributionNode {
124 // The uid for a given element in the attribution chain.
Yangster-mac7604aea2017-12-11 22:55:49 -0800125 optional int32 uid = 1;
Yangster-mac7604aea2017-12-11 22:55:49 -0800126
Yangster-mac20877162017-12-22 17:19:39 -0800127 // The (optional) string tag for an element in the attribution chain. If the
128 // element has no tag, it is encoded as an empty string.
129 optional string tag = 2;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700130}
131
Yao Chend54f9dd2017-10-17 17:37:48 +0000132/*
133 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800134 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000135 *
136 * RULES:
137 * - The field ids for each atom must start at 1, and count upwards by 1.
138 * Skipping field ids is not allowed.
139 * - These form an API, so renaming, renumbering or removing fields is
140 * not allowed between android releases. (This is not currently enforced,
141 * but there will be a tool to enforce this restriction).
142 * - The types must be built-in protocol buffer types, namely, no sub-messages
143 * are allowed (yet). The bytes type is also not allowed.
144 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800145 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000146 * - If an atom represents work that can be attributed to an app, there can
Yangster-mac7604aea2017-12-11 22:55:49 -0800147 * be exactly one AttributionChain field. It must be field number 1.
Yao Chend54f9dd2017-10-17 17:37:48 +0000148 * - A field that is a uid should be a string field, tagged with the [xxx]
149 * annotation. The generated code on android will be represented by UIDs,
150 * and those UIDs will be translated in xxx to those strings.
151 *
152 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700153 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000154 * - If there is a UID, it goes first. Think in an object-oriented fashion.
155 * *****************************************************************************
156 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700157
Yao Chend54f9dd2017-10-17 17:37:48 +0000158/**
159 * Logs when the screen state changes.
160 *
161 * Logged from:
162 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
163 */
164message ScreenStateChanged {
165 // TODO: Use the real screen state.
166 enum State {
167 STATE_UNKNOWN = 0;
168 STATE_OFF = 1;
169 STATE_ON = 2;
170 STATE_DOZE = 3;
171 STATE_DOZE_SUSPEND = 4;
172 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800173 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000174 }
175 // New screen state.
176 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700177}
Yao Chend54f9dd2017-10-17 17:37:48 +0000178
179/**
Bookatzc1a050a2017-10-10 15:49:28 -0700180 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000181 *
182 * Logged from:
183 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
184 */
Bookatzc1a050a2017-10-10 15:49:28 -0700185message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000186 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
187
188 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700189 // TODO: Use the real (mapped) process states.
Joe Onorato62c220b2017-11-18 20:32:56 -0800190 optional android.app.ProcessState 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 {
200 // TODO: Use the real (mapped) process states.
201 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
202
203 // TODO: What is this?
204 optional string name = 2;
205
Bookatzddccf0a2017-11-28 16:48:14 -0800206 // What lifecycle state the process changed to.
207 // This enum is specific to atoms.proto.
208 enum Event {
209 PROCESS_FINISHED = 0;
210 PROCESS_STARTED = 1;
211 PROCESS_CRASHED = 2;
212 PROCESS_ANRED = 3;
213 }
214 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700215}
216
Bookatzc1a050a2017-10-10 15:49:28 -0700217/**
218 * Logs when the ble scan state changes.
219 *
220 * Logged from:
221 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
222 */
223message BleScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800224 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700225
226 enum State {
227 OFF = 0;
228 ON = 1;
229 }
230 optional State state = 2;
231}
232
233/**
234 * Logs when an unoptimized ble scan state changes.
235 *
236 * Logged from:
237 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
238 */
239// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
240message BleUnoptimizedScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800241 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700242
243 enum State {
244 OFF = 0;
245 ON = 1;
246 }
247 optional State state = 2;
248}
249
250/**
251 * Logs reporting of a ble scan finding results.
252 *
253 * Logged from:
254 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
255 */
256// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
257message BleScanResultReceived {
Yangster-macafad8c62018-01-05 22:30:49 -0800258 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700259
260 // Number of ble scan results returned.
261 optional int32 num_of_results = 2;
262}
263
264/**
265 * Logs when a sensor state changes.
266 *
267 * Logged from:
268 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
269 */
270message SensorStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800271 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700272
273 // TODO: Is there a way to get the actual name of the sensor?
274 // The id (int) of the sensor.
275 optional int32 sensor_id = 2;
276
277 enum State {
278 OFF = 0;
279 ON = 1;
280 }
281 optional State state = 3;
282}
283
284
285/**
286 * Logs when GPS state changes.
287 *
288 * Logged from:
289 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
290 */
291message GpsScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800292 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700293
294 enum State {
295 OFF = 0;
296 ON = 1;
297 }
298 optional State state = 2;
299}
300
301
302/**
303 * Logs when a sync manager sync state changes.
304 *
305 * Logged from:
306 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
307 */
308message SyncStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800309 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700310
311 // Name of the sync (as named in the app)
312 optional string name = 2;
313
314 enum State {
315 OFF = 0;
316 ON = 1;
317 }
318 optional State state = 3;
319}
320
321/**
322 * Logs when a job scheduler job state changes.
323 *
324 * Logged from:
325 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
326 */
327message ScheduledJobStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800328 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700329
330 // Name of the job (as named in the app)
331 optional string name = 2;
332
333 enum State {
Tej Singhd5747a62018-01-08 20:57:35 -0800334 FINISHED = 0;
335 STARTED = 1;
336 SCHEDULED = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700337 }
338 optional State state = 3;
339
340 // TODO: Consider adding the stopReason (int)
341}
342
343/**
344 * Logs when the audio state changes.
345 *
346 * Logged from:
347 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
348 */
349message AudioStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800350 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700351
352 enum State {
353 OFF = 0;
354 ON = 1;
355 }
356 optional State state = 2;
357}
358
359/**
360 * Logs when the video codec state changes.
361 *
362 * Logged from:
363 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
364 */
365message MediaCodecActivityChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800366 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700367
368 enum State {
369 OFF = 0;
370 ON = 1;
371 }
372 optional State state = 2;
373}
374
375/**
376 * Logs when the flashlight state changes.
377 *
378 * Logged from:
379 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
380 */
381message FlashlightStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800382 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700383
384 enum State {
385 OFF = 0;
386 ON = 1;
387 }
388 optional State state = 2;
389}
390
391/**
392 * Logs when the camera state changes.
393 *
394 * Logged from:
395 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
396 */
397message CameraStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800398 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700399
400 enum State {
401 OFF = 0;
402 ON = 1;
403 }
404 optional State state = 2;
405}
406
407/**
408 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000409 *
410 * Logged from:
411 * TODO
412 */
Bookatzd6746242017-10-24 18:39:35 -0700413message WakelockStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800414 repeated AttributionNode attribution_node = 1;
Yao Chend54f9dd2017-10-17 17:37:48 +0000415
Bookatzc1a050a2017-10-10 15:49:28 -0700416 // Type of wakelock.
417 enum Type {
418 PARTIAL = 0;
419 FULL = 1;
420 WINDOW = 2;
421 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800422 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700423
424 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
425 optional string tag = 3;
426
427 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800428 RELEASE = 0;
429 ACQUIRE = 1;
430 CHANGE_RELEASE = 2;
431 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700432 }
433 optional State state = 4;
434}
435
436/**
Bookatzc1a050a2017-10-10 15:49:28 -0700437 * Logs when a partial wakelock is considered 'long' (over 1 min).
438 *
439 * Logged from:
440 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
441 */
442message LongPartialWakelockStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800443 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700444
Yao Chend54f9dd2017-10-17 17:37:48 +0000445 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
446 optional string tag = 2;
447
Bookatzc1a050a2017-10-10 15:49:28 -0700448 // TODO: I have no idea what this is.
449 optional string history_tag = 3;
450
451 enum State {
452 OFF = 0;
453 ON = 1;
454 }
455 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000456}
457
Bookatzc1a050a2017-10-10 15:49:28 -0700458/**
459 * Logs Battery Saver state change.
460 *
461 * Logged from:
462 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
463 */
464message BatterySaverModeStateChanged {
465 enum State {
466 OFF = 0;
467 ON = 1;
468 }
469 optional State state = 1;
470}
471
472/**
473 * Logs Doze mode state change.
474 *
475 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800476 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700477 */
478message DeviceIdleModeStateChanged {
479 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800480 enum State {
481 DEVICE_IDLE_MODE_OFF = 0;
482 DEVICE_IDLE_MODE_LIGHT = 1;
483 DEVICE_IDLE_MODE_DEEP = 2;
484 }
485 optional State state = 1;
486}
487
488
489/**
490 * Logs state change of Doze mode including maintenance windows.
491 *
492 * Logged from:
493 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
494 */
495message DeviceIdlingModeStateChanged {
496 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
497 enum State {
498 DEVICE_IDLE_MODE_OFF = 0;
499 DEVICE_IDLE_MODE_LIGHT = 1;
500 DEVICE_IDLE_MODE_DEEP = 2;
501 }
502 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700503}
504
505/**
506 * Logs screen brightness level.
507 *
508 * Logged from:
509 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
510 */
511message ScreenBrightnessChanged {
512 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
513 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700514}
515
516/**
517 * Logs battery level (percent full, from 0 to 100).
518 *
519 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700520 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700521 */
522message BatteryLevelChanged {
523 // Battery level. Should be in [0, 100].
524 optional int32 battery_level = 1;
525}
526
527/**
528 * Logs change in charging status of the device.
529 *
530 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700531 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700532 */
533message ChargingStateChanged {
534 // TODO: Link directly to BatteryManager.java's constants (via a proto).
535 enum State {
536 BATTERY_STATUS_UNKNOWN = 1;
537 BATTERY_STATUS_CHARGING = 2;
538 BATTERY_STATUS_DISCHARGING = 3;
539 BATTERY_STATUS_NOT_CHARGING = 4;
540 BATTERY_STATUS_FULL = 5;
541 }
542 optional State charging_state = 1;
543}
544
545/**
546 * Logs whether the device is plugged in, and what power source it is using.
547 *
548 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700549 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700550 */
551message PluggedStateChanged {
552 // TODO: Link directly to BatteryManager.java's constants (via a proto).
553 enum State {
554 // Note that NONE is not in BatteryManager.java's constants.
555 BATTERY_PLUGGED_NONE = 0;
556 // Power source is an AC charger.
557 BATTERY_PLUGGED_AC = 1;
558 // Power source is a USB port.
559 BATTERY_PLUGGED_USB = 2;
560 // Power source is wireless.
561 BATTERY_PLUGGED_WIRELESS = 4;
562 }
563 optional State plugged_state = 1;
564}
565
566/**
567 * Logs the temperature of the device, in tenths of a degree Celsius.
568 *
569 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700570 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700571 */
572message DeviceTemperatureReported {
573 // Temperature in tenths of a degree C.
574 optional int32 temperature = 1;
575}
576
577// TODO: Define this more precisely.
578// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
579/**
580 * Logs when the device turns off or on.
581 *
582 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700583 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700584 */
585message DeviceOnStatusChanged {
586 enum State {
587 OFF = 0;
588 ON = 1;
589 }
590 optional State state = 1;
591}
592
593/**
594 * Logs when an app's wakeup alarm fires.
595 *
596 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700597 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700598 */
599message WakeupAlarmOccurred {
Yangster-macafad8c62018-01-05 22:30:49 -0800600 repeated AttributionNode attribution_node = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800601
602 // Name of the wakeup alarm.
603 optional string tag = 2;
604}
605
606/**
607 * Logs when an an app causes the mobile radio to change state.
608 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
609 *
610 * Logged from:
611 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
612 */
613message MobileRadioPowerStateChanged {
614 // TODO: Add attribution instead of uid?
615 optional int32 uid = 1;
616
617 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
618 enum PowerState {
619 DC_POWER_STATE_LOW = 1;
620 DC_POWER_STATE_MEDIUM = 2;
621 DC_POWER_STATE_HIGH = 3;
622 }
623 optional PowerState power_state = 2;
624}
625
626/**
627 * Logs when an an app causes the wifi radio to change state.
628 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
629 *
630 * Logged from:
631 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
632 */
633message WifiRadioPowerStateChanged {
634 // TODO: Add attribution instead of uid?
635 optional int32 uid = 1;
636
637 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
638 enum PowerState {
639 DC_POWER_STATE_LOW = 1;
640 DC_POWER_STATE_MEDIUM = 2;
641 DC_POWER_STATE_HIGH = 3;
642 }
643 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700644}
645
646/**
647 * Logs kernel wakeup reasons and aborts.
648 *
649 * Logged from:
650 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
651 */
652message KernelWakeupReported {
653 // Name of the kernel wakeup reason (or abort).
654 optional string wakeup_reason_name = 1;
655
656 // Duration (in microseconds) for the wake-up interrupt to be serviced.
657 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700658}
659
660/**
661 * Logs wifi locks held by an app.
662 *
663 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700664 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700665 */
666message WifiLockStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800667 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700668
669 enum State {
670 OFF = 0;
671 ON = 1;
672 }
673 optional State state = 2;
674}
675
676/**
677 * Logs wifi signal strength changes.
678 *
679 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700680 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700681 */
682message WifiSignalStrengthChanged {
683 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
684 enum SignalStrength {
685 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
686 SIGNAL_STRENGTH_POOR = 1;
687 SIGNAL_STRENGTH_MODERATE = 2;
688 SIGNAL_STRENGTH_GOOD = 3;
689 SIGNAL_STRENGTH_GREAT = 4;
690 }
691 optional SignalStrength signal_strength = 1;
692}
693
694/**
695 * Logs wifi scans performed by an app.
696 *
697 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700698 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700699 */
700message WifiScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800701 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700702
703 enum State {
704 OFF = 0;
705 ON = 1;
706 }
707 optional State state = 2;
708}
709
710/**
Tej Singh4503e102018-01-04 14:35:01 -0800711 * Logs wifi multicast locks held by an app
712 *
713 * Logged from:
714 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
715 */
716message WifiMulticastLockStateChanged {
717 repeated AttributionNode attribution_node = 1;
718
719 enum State {
720 OFF = 0;
721 ON = 1;
722 }
723 optional State state = 2;
724}
725
726/**
Bookatze5885242017-10-24 20:10:31 -0700727 * Logs phone signal strength changes.
728 *
729 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700730 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700731 */
732message PhoneSignalStrengthChanged {
733 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
734 enum SignalStrength {
735 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
736 SIGNAL_STRENGTH_POOR = 1;
737 SIGNAL_STRENGTH_MODERATE = 2;
738 SIGNAL_STRENGTH_GOOD = 3;
739 SIGNAL_STRENGTH_GREAT = 4;
740 }
741 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700742}
743
744/**
745 * Logs that a setting was updated.
746 * Logged from:
747 * frameworks/base/core/java/android/provider/Settings.java
748 * The tag and is_default allow resetting of settings to default values based on the specified
749 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
750 */
751message SettingChanged {
752 // The name of the setting.
753 optional string setting = 1;
754
755 // The change being imposed on this setting. May represent a number, eg "3".
756 optional string value = 2;
757
758 // The new value of this setting. For most settings, this is same as value. For some settings,
759 // value is +X or -X where X represents an element in a set. For example, if the previous value
760 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
761 // The +/- feature is currently only used for location_providers_allowed.
762 optional string new_value = 3;
763
764 // The previous value of this setting.
765 optional string prev_value = 4;
766
767 // The tag used with the is_default for resetting sets of settings. This is generally null.
768 optional string tag = 5;
769
770 // 1 indicates that this setting with tag should be resettable.
771 optional int32 is_default = 6;
772
773 // The user ID associated. Defined in android/os/UserHandle.java
774 optional int32 user = 7;
775}
Chenjie Yub3dda412017-10-24 13:41:59 -0700776
Chenjie Yu05013b32017-11-21 10:21:41 -0800777/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700778 * Logs activity going to foreground or background
779 *
780 * Logged from:
781 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
782 */
783message ActivityForegroundStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800784 optional int32 uid = 1;
785 optional string pkg_name = 2;
786 optional string class_name = 3;
787
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700788 enum Activity {
789 MOVE_TO_BACKGROUND = 0;
790 MOVE_TO_FOREGROUND = 1;
791 }
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700792 optional Activity activity = 4;
793}
David Chenc8a43242017-10-17 16:23:28 -0700794
795/**
David Chen9e3808c2017-11-20 17:25:34 -0800796 * Logs when an error is written to dropbox.
797 * Logged from:
798 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
799 */
800message DropboxErrorChanged {
801 // The uid if available. -1 means not available.
802 optional int32 uid = 1;
803
804 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
805 optional string tag = 2;
806
807 // The name of the process.
808 optional string process_name = 3;
809
810 // The pid if available. -1 means not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800811 optional sint32 pid = 4;
David Chen9e3808c2017-11-20 17:25:34 -0800812
813 // 1 indicates is instant app. -1 indicates Not applicable.
David Chen6e3e6cb2018-01-03 16:14:06 -0800814 optional sint32 is_instant_app = 5;
David Chen9e3808c2017-11-20 17:25:34 -0800815
816 // The activity name if available.
817 optional string activity_name = 6;
818
David Chen6e3e6cb2018-01-03 16:14:06 -0800819 // The package name if available.
820 optional string package_name = 7;
821
David Chen9e3808c2017-11-20 17:25:34 -0800822 // 1 indicates in foreground. -1 indicates not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800823 optional sint32 is_foreground = 8;
David Chen9e3808c2017-11-20 17:25:34 -0800824}
825
David Chen0a368b22017-12-06 16:28:16 -0800826/*
827 * Allows other apps to push events into statsd.
828 * Logged from:
829 * frameworks/base/core/java/android/util/StatsLog.java
830 */
831message AppHook {
832 // The uid of the application that sent this custom atom.
833 optional int32 uid = 1;
834
835 // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
836 optional int32 label = 2;
837
838 // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
839 // predicates for the metrics).
840 enum State {
841 UNKNOWN = 0;
842 UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
843 STOP = 2;
844 START = 3;
845 }
846 optional State state = 3;
847}
848
David Chen9e3808c2017-11-20 17:25:34 -0800849/**
Bookatz8fcd09a2017-12-18 13:01:10 -0800850 * Logs when statsd detects an anomaly.
851 *
852 * Logged from:
853 * frameworks/base/cmds/statsd/src/anomaly/AnomalyTracker.cpp
854 */
855message AnomalyDetected {
856 // Uid that owns the config whose anomaly detection alert fired.
857 optional int32 config_uid = 1;
858
Yangster-mac94e197c2018-01-02 16:03:03 -0800859 // Id of the config whose anomaly detection alert fired.
860 optional int64 config_id = 2;
Bookatz8fcd09a2017-12-18 13:01:10 -0800861
Yangster-mac94e197c2018-01-02 16:03:03 -0800862 // Id of the alert (i.e. name of the anomaly that was detected).
863 optional int64 alert_id = 3;
Bookatz8fcd09a2017-12-18 13:01:10 -0800864}
865
Olivier Gaillardaed7f122017-12-12 14:26:22 +0000866message AppStartChanged {
867 // The uid if available. -1 means not available.
868 optional int32 uid = 1;
869
870 // The app package name.
871 optional string pkg_name = 2;
872
873 enum TransitionType {
874 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
875 WARM = 1;
876 HOT = 2;
877 COLD = 3;
878 }
879 // The transition type.
880 optional TransitionType type = 3;
881
882 // The activity name.
883 optional string activity_name = 4;
884
885 // The name of the calling app. Empty if not set.
886 optional string calling_pkg_name = 5;
887
888 // Whether the app is an instant app.
889 optional bool is_instant_app = 6;
890
891 // Device uptime when activity started.
892 optional int64 activity_start_msec = 7;
893
894 // TODO: Update android/app/ActivityManagerInternal.java constants to depend on our proto enum.
895 enum TransitionReason {
896 APP_START_TRANSITION_REASON_UNKNOWN = 0;
897 SPLASH_SCREEN = 1;
898 WINDOWS_DRAWN = 2;
899 TIMEOUT = 3;
900 SNAPSHOT = 4;
901 }
902 optional TransitionReason reason = 8;
903
904 optional int32 transition_delay_msec = 9;
905 // -1 if not set.
906 optional int32 starting_window_delay_msec = 10;
907 // -1 if not set.
908 optional int32 bind_application_delay_msec = 11;
909 optional int32 windows_drawn_delay_msec = 12;
910
911 // Empty if not set.
912 optional string launch_token = 13;
913
914}
915
916message AppStartCancelChanged {
917 // The uid if available. -1 means not available.
918 optional int32 uid = 1;
919
920 // The app package name.
921 optional string pkg_name = 2;
922
923 enum TransitionType {
924 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
925 WARM = 1;
926 HOT = 2;
927 COLD = 3;
928 }
929 // The transition type.
930 optional TransitionType type = 3;
931
932 // The activity name.
933 optional string activity_name = 4;
934}
935
936message AppStartFullyDrawnChanged {
937 // The uid if available. -1 means not available.
938 optional int32 uid = 1;
939
940 // The app package name.
941 optional string pkg_name = 2;
942
943 enum TransitionType {
944 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
945 WITH_BUNDLE = 1;
946 WITHOUT_BUNDLE = 2;
947 }
948 // The transition type.
949 optional TransitionType type = 3;
950
951 // The activity name.
952 optional string activity_name = 4;
953
954 optional bool transition_process_running = 5;
955
956 // App startup time (until call to Activity#reportFullyDrawn()).
957 optional int64 app_startup_time_ms = 6;
958}
959
Bookatz8fcd09a2017-12-18 13:01:10 -0800960/**
Chenjie Yu52cacc62017-12-08 18:11:45 -0800961 * Logs a picture-in-picture action
962 * Logged from:
963 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
964 * frameworks/base/services/core/java/com/android/server/am/ActivityStackSupervisor.java
965 * frameworks/base/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
966 */
967message PictureInPictureStateChanged {
968 optional int32 uid = 1;
969
970 optional string package_name = 2;
971
972 optional string class_name = 3;
973
974 // Picture-in-Picture action occurred, similar to
975 // frameworks/base/proto/src/metrics_constants.proto
976 enum State {
977 ENTERED = 1;
978 EXPANDED_TO_FULL_SCREEN = 2;
979 MINIMIZED = 3;
980 DISMISSED = 4;
981 }
982 optional State state = 4;
983}
984
985/**
David Chenc8a43242017-10-17 16:23:28 -0700986 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
987 *
988 * Pulled from:
989 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
990 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800991message WifiBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -0700992 optional int32 uid = 1;
993
994 optional int64 rx_bytes = 2;
995
996 optional int64 rx_packets = 3;
997
998 optional int64 tx_bytes = 4;
999
1000 optional int64 tx_packets = 5;
1001}
1002
1003/**
1004 * Pulls bytes transferred via wifi (separated by foreground and background usage).
1005 *
1006 * Pulled from:
1007 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
1008 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001009message WifiBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -07001010 optional int32 uid = 1;
1011
1012 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
1013 optional int32 is_foreground = 2;
1014
1015 optional int64 rx_bytes = 3;
1016
1017 optional int64 rx_packets = 4;
1018
1019 optional int64 tx_bytes = 5;
1020
1021 optional int64 tx_packets = 6;
1022}
1023
1024/**
1025 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
1026 *
1027 * Pulled from:
1028 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1029 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001030message MobileBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -07001031 optional int32 uid = 1;
1032
1033 optional int64 rx_bytes = 2;
1034
1035 optional int64 rx_packets = 3;
1036
1037 optional int64 tx_bytes = 4;
1038
1039 optional int64 tx_packets = 5;
1040}
1041
1042/**
1043 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
1044 *
1045 * Pulled from:
1046 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1047 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001048message MobileBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -07001049 optional int32 uid = 1;
1050
1051 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
1052 optional int32 is_foreground = 2;
1053
1054 optional int64 rx_bytes = 3;
1055
1056 optional int64 rx_packets = 4;
1057
1058 optional int64 tx_bytes = 5;
1059
1060 optional int64 tx_packets = 6;
1061}
1062
1063/**
1064 * Pulls the kernel wakelock durations. This atom is adapted from
1065 * android/internal/os/KernelWakelockStats.java
1066 *
1067 * Pulled from:
1068 * StatsCompanionService using KernelWakelockReader.
1069 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001070message KernelWakelock {
David Chenc8a43242017-10-17 16:23:28 -07001071 optional string name = 1;
1072
1073 optional int32 count = 2;
1074
1075 optional int32 version = 3;
1076
1077 optional int64 time = 4;
1078}
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001079
Chenjie Yu05013b32017-11-21 10:21:41 -08001080/**
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001081 * Pulls low power state information. This includes platform and subsystem sleep state information,
1082 * PowerStatePlatformSleepState, PowerStateVoter or PowerStateSubsystemSleepState as defined in
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001083 * hardware/interfaces/power/1.0/types.hal
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001084 * hardware/interfaces/power/1.1/types.hal
1085 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001086message SubsystemSleepState {
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001087 // Name should be in the format of XXX.YYY where XXX is subsystem name,
1088 // YYY is corresponding voter name.
1089 // If there are no voters, the format should just be XXX (with no dot).
1090 // XXX and YYY should not contain a "." in it.
1091 optional string name = 1;
1092 // The number of times it entered, or voted for entering the sleep state
1093 optional uint64 count = 2;
1094 // The length of time spent in, or spent voting for, the sleep state
1095 optional uint64 timeMs = 3;
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001096}
David Chen21582962017-11-01 17:32:46 -07001097
1098/**
1099 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
1100 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
1101 * attributed back to the parent (host) uid. One example is Chrome.
1102 *
1103 * Logged from:
1104 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
1105 */
1106message IsolatedUidChanged {
1107 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
1108 optional int32 parent_uid = 1;
1109
1110 optional int32 isolated_uid = 2;
1111
1112 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
1113 // be removed before if it's used for another parent uid.
1114 optional int32 is_create = 3;
1115}
Chenjie Yu7f8def92017-11-03 09:33:15 -07001116
Chenjie Yu05013b32017-11-21 10:21:41 -08001117/**
Chenjie Yu7f8def92017-11-03 09:33:15 -07001118 * Pulls Cpu time per frequency.
Chenjie Yu1ee9b742018-01-10 16:02:57 -08001119 * Pulls the time the cpu spend on the frequency index. Frequency index
1120 * starts from highest to lowest. The value should be monotonically
1121 * increasing since boot. However, if there is a cpu
1122 * hotplug event, the value would be reset as well.
Chenjie Yu7f8def92017-11-03 09:33:15 -07001123 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001124message CpuTimePerFreq {
Chenjie Yu7f8def92017-11-03 09:33:15 -07001125 optional uint32 cluster = 1;
1126 optional uint32 freq_index = 2;
Chenjie Yu31d14d72017-12-12 17:54:33 -08001127 optional uint64 time_ms = 3;
Chenjie Yu7f8def92017-11-03 09:33:15 -07001128}
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001129
Chenjie Yu05013b32017-11-21 10:21:41 -08001130/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001131 * Pulls Cpu Time Per Uid.
1132 * Note that isolated process uid time should be attributed to host uids.
1133 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001134message CpuTimePerUid {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001135 optional uint64 uid = 1;
1136 optional uint64 user_time_ms = 2;
1137 optional uint64 sys_time_ms = 3;
1138}
1139
1140/**
1141 * Pulls Cpu Time Per Uid per frequency.
1142 * Note that isolated process uid time should be attributed to host uids.
1143 * For each uid, we order the time by descending frequencies.
1144 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001145message CpuTimePerUidFreq {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001146 optional uint64 uid = 1;
1147 optional uint64 freq_idx = 2;
1148 optional uint64 time_ms = 3;
1149}
Hugo Benichi884970e2017-11-14 22:42:46 +09001150
1151/*
1152 * Logs the reception of an incoming network packet causing the main system to wake up for
1153 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1154 * and processed by WakeupController.cpp.
1155 */
1156message PacketWakeupOccurred {
1157 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1158 // delivered nowhere.
1159 optional int32 uid = 1;
1160 // The interface name on which the packet was received.
1161 optional string iface = 2;
1162 // The ethertype value of the packet.
1163 optional int32 ethertype = 3;
1164 // String representation of the destination MAC address of the packet.
1165 optional string destination_hardware_address = 4;
1166 // String representation of the source address of the packet if this was an IP packet.
1167 optional string source_ip = 5;
1168 // String representation of the destination address of the packet if this was an IP packet.
1169 optional string destination_ip = 6;
1170 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1171 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1172 // families.
1173 optional int32 ip_next_header = 7;
1174 // The source port if this was a TCP or UDP packet.
1175 optional int32 source_port = 8;
1176 // The destination port if this was a TCP or UDP packet.
1177 optional int32 destination_port = 9;
1178}
Chenjie Yu05013b32017-11-21 10:21:41 -08001179
1180/**
1181 * Pulls Wifi Controller Activity Energy Info
1182 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001183message WifiActivityEnergyInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001184 // timestamp(wall clock) of record creation
1185 optional uint64 timestamp_ms = 1;
1186 // stack reported state
1187 // TODO: replace this with proto enum
1188 optional int32 stack_state = 2;
1189 // tx time in ms
1190 optional uint64 controller_tx_time_ms = 3;
1191 // rx time in ms
1192 optional uint64 controller_rx_time_ms = 4;
1193 // idle time in ms
1194 optional uint64 controller_idle_time_ms = 5;
1195 // product of current(mA), voltage(V) and time(ms)
1196 optional uint64 controller_energy_used = 6;
1197}
1198
1199/**
1200 * Pulls Modem Activity Energy Info
1201 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001202message ModemActivityInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001203 // timestamp(wall clock) of record creation
1204 optional uint64 timestamp_ms = 1;
1205 // sleep time in ms.
1206 optional uint64 sleep_time_ms = 2;
1207 // idle time in ms
1208 optional uint64 controller_idle_time_ms = 3;
1209 /**
1210 * Tx power index
1211 * index 0 = tx_power < 0dBm
1212 * index 1 = 0dBm < tx_power < 5dBm
1213 * index 2 = 5dBm < tx_power < 15dBm
1214 * index 3 = 15dBm < tx_power < 20dBm
1215 * index 4 = tx_power > 20dBm
1216 */
1217 // tx time in ms at power level 0
1218 optional uint64 controller_tx_time_pl0_ms = 4;
1219 // tx time in ms at power level 1
1220 optional uint64 controller_tx_time_pl1_ms = 5;
1221 // tx time in ms at power level 2
1222 optional uint64 controller_tx_time_pl2_ms = 6;
1223 // tx time in ms at power level 3
1224 optional uint64 controller_tx_time_pl3_ms = 7;
1225 // tx time in ms at power level 4
1226 optional uint64 controller_tx_time_pl4_ms = 8;
1227 // rx time in ms at power level 5
1228 optional uint64 controller_rx_time_ms = 9;
1229 // product of current(mA), voltage(V) and time(ms)
1230 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001231}
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001232
1233/*
1234 * Logs the memory stats for a process
1235 */
1236message MemoryStat {
1237 // The uid if available. -1 means not available.
1238 optional int32 uid = 1;
1239
1240 // The app package name.
1241 optional string pkg_name = 2;
1242
1243 // # of page-faults
1244 optional int64 pgfault = 3;
1245
1246 // # of major page-faults
1247 optional int64 pgmajfault = 4;
1248
1249 // RSS+CACHE(+SWAP)
1250 optional int64 usage_in_bytes = 5;
1251}
1252
1253/*
1254 * Logs the event when LMKD kills a process to reduce memory pressure
1255 * Logged from:
1256 * system/core/lmkd/lmkd.c
1257 */
1258message LmkEventOccurred {
1259 // The uid if available. -1 means not available.
1260 optional int32 uid = 1;
1261
1262 // The app package name.
1263 optional string pkg_name = 2;
1264
1265 // oom adj score.
1266 optional int32 oom_score = 3;
1267
1268 // Used as start/stop boundaries for the event
1269 enum State {
1270 UNKNOWN = 0;
1271 START = 1;
1272 END = 2;
1273 }
1274 optional State state = 4;
1275}
Chenjie Yu9da105b2018-01-13 12:41:08 -08001276
1277/*
1278 * Cpu syspend time for cpu power calculation.
1279 */
1280message CpuSuspendTime {
1281 optional uint64 time = 1;
1282}
1283
1284/*
1285 * Cpu idle time for cpu power calculation.
1286 */
1287message CpuIdleTime {
1288 optional uint64 time = 1;
1289}
1290
1291/*
1292 * Reads from /proc/uid_concurrent_active_time which has the format:
1293 * active: X (X is # cores)
1294 * [uid0]: [time-0] [time-1] [time-2] ... (# entries = # cores)
1295 * [uid1]: [time-0] [time-1] [time-2] ... ...
1296 * ...
1297 * Time-N means the CPU time a UID spent running concurrently with N other processes.
1298 * The file contains a monotonically increasing count of time for a single boot.
1299 */
1300message CpuActiveTime {
1301 optional uint64 uid = 1;
1302 optional uint64 idx = 2;
1303 optional uint64 time_ms = 3;
1304}
1305
1306/**
1307 * Reads from /proc/uid_concurrent_policy_time which has the format:
1308 * policy0: X policy4: Y (there are X cores on policy0, Y cores on policy4)
1309 * [uid0]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1310 * [uid1]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1311 * ...
1312 * Time-X-Y means the time a UID spent on clusterX running concurrently with Y other processes.
1313 * The file contains a monotonically increasing count of time for a single boot.
1314 */
1315message CpuClusterTime {
1316 optional uint64 uid = 1;
1317 optional uint64 idx = 2;
1318 optional uint64 time_ms = 3;
Chenjie Yu937d7422018-01-10 16:37:53 -08001319}
1320
1321/*
1322 * Pulls free disk space, for data, system partition and temporary directory.
1323 */
1324message DiskSpace {
1325 // available bytes in data partition
1326 optional uint64 data_available_bytes = 1;
1327 // available bytes in system partition
1328 optional uint64 system_available_bytes = 2;
1329 // available bytes in download cache or temp directories
1330 optional uint64 temp_available_bytes = 3;
1331}
1332
1333/*
1334 * Pulls system up time.
1335 */
1336message SystemUptime {
1337 // Milliseconds since the system was booted.
1338 // This clock stops when the system enters deep sleep (CPU off, display dark, device waiting
1339 // for external input).
1340 // It is not affected by clock scaling, idle, or other power saving mechanisms.
1341 optional uint64 uptime_ms = 1;
Tej Singh4503e102018-01-04 14:35:01 -08001342}