blob: 69012b24071d7bdf4f53f9a570601a12be1f83e2 [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;
Bookatzc1a050a2017-10-10 15:49:28 -070089 // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
Yao Chend54f9dd2017-10-17 17:37:48 +000090 }
David Chenc8a43242017-10-17 16:23:28 -070091
David Chen6e3e6cb2018-01-03 16:14:06 -080092 // Pulled events will start at field 10000.
David Chenc8a43242017-10-17 16:23:28 -070093 oneof pulled {
David Chen6e3e6cb2018-01-03 16:14:06 -080094 WifiBytesTransfer wifi_bytes_transfer = 10000;
95 WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
96 MobileBytesTransfer mobile_bytes_transfer = 10002;
97 MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 10003;
98 KernelWakelock kernel_wakelock = 10004;
Chenjie Yuc8b7f222018-01-11 23:25:57 -080099 SubsystemSleepState subsystem_sleep_state = 10005;
100 // 10006 and 10007 are free to use.
David Chen6e3e6cb2018-01-03 16:14:06 -0800101 CpuTimePerFreq cpu_time_per_freq = 10008;
102 CpuTimePerUid cpu_time_per_uid = 10009;
103 CpuTimePerUidFreq cpu_time_per_uid_freq = 10010;
104 WifiActivityEnergyInfo wifi_activity_energy_info = 10011;
105 ModemActivityInfo modem_activity_info = 10012;
Rajeev Kumar508a9bf2018-01-18 15:49:11 -0800106 MemoryStat memory_stat = 10013;
Chenjie Yu9da105b2018-01-13 12:41:08 -0800107 CpuSuspendTime cpu_suspend_time = 10014;
108 CpuIdleTime cpu_idle_time = 10015;
109 CpuActiveTime cpu_active_time = 10016;
110 CpuClusterTime cpu_cluster_time = 10017;
David Chenc8a43242017-10-17 16:23:28 -0700111 }
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700112}
113
Yao Chend54f9dd2017-10-17 17:37:48 +0000114/**
Yangster-mac20877162017-12-22 17:19:39 -0800115 * This proto represents a node of an attribution chain.
116 * Note: All attribution chains are represented as a repeated field of type
117 * AttributionNode. It is understood that in such arrays, the order is that
118 * of calls, that is [A, B, C] if A calls B that calls C.
Yao Chend54f9dd2017-10-17 17:37:48 +0000119 */
Yangster-mac20877162017-12-22 17:19:39 -0800120message AttributionNode {
121 // The uid for a given element in the attribution chain.
Yangster-mac7604aea2017-12-11 22:55:49 -0800122 optional int32 uid = 1;
Yangster-mac7604aea2017-12-11 22:55:49 -0800123
Yangster-mac20877162017-12-22 17:19:39 -0800124 // The (optional) string tag for an element in the attribution chain. If the
125 // element has no tag, it is encoded as an empty string.
126 optional string tag = 2;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700127}
128
Yao Chend54f9dd2017-10-17 17:37:48 +0000129/*
130 * *****************************************************************************
yrode4ca102017-11-15 22:57:24 -0800131 * Below are all of the individual atoms that are logged by Android via statsd.
Yao Chend54f9dd2017-10-17 17:37:48 +0000132 *
133 * RULES:
134 * - The field ids for each atom must start at 1, and count upwards by 1.
135 * Skipping field ids is not allowed.
136 * - These form an API, so renaming, renumbering or removing fields is
137 * not allowed between android releases. (This is not currently enforced,
138 * but there will be a tool to enforce this restriction).
139 * - The types must be built-in protocol buffer types, namely, no sub-messages
140 * are allowed (yet). The bytes type is also not allowed.
141 * - The CamelCase name of the message type should match the
Stefan Lafonae2df012017-11-14 09:17:21 -0800142 * underscore_separated name as defined in Atom.
Yao Chend54f9dd2017-10-17 17:37:48 +0000143 * - If an atom represents work that can be attributed to an app, there can
Yangster-mac7604aea2017-12-11 22:55:49 -0800144 * be exactly one AttributionChain field. It must be field number 1.
Yao Chend54f9dd2017-10-17 17:37:48 +0000145 * - A field that is a uid should be a string field, tagged with the [xxx]
146 * annotation. The generated code on android will be represented by UIDs,
147 * and those UIDs will be translated in xxx to those strings.
148 *
149 * CONVENTIONS:
Bookatzc1a050a2017-10-10 15:49:28 -0700150 * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange.
Yao Chend54f9dd2017-10-17 17:37:48 +0000151 * - If there is a UID, it goes first. Think in an object-oriented fashion.
152 * *****************************************************************************
153 */
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700154
Yao Chend54f9dd2017-10-17 17:37:48 +0000155/**
156 * Logs when the screen state changes.
157 *
158 * Logged from:
159 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
160 */
161message ScreenStateChanged {
162 // TODO: Use the real screen state.
163 enum State {
164 STATE_UNKNOWN = 0;
165 STATE_OFF = 1;
166 STATE_ON = 2;
167 STATE_DOZE = 3;
168 STATE_DOZE_SUSPEND = 4;
169 STATE_VR = 5;
Bookatzddccf0a2017-11-28 16:48:14 -0800170 STATE_ON_SUSPEND = 6;
Yao Chend54f9dd2017-10-17 17:37:48 +0000171 }
172 // New screen state.
173 optional State display_state = 1;
Stefan Lafoncdb1a0e2017-09-27 20:24:15 -0700174}
Yao Chend54f9dd2017-10-17 17:37:48 +0000175
176/**
Bookatzc1a050a2017-10-10 15:49:28 -0700177 * Logs that the state of a process state, as per the activity manager, has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000178 *
179 * Logged from:
180 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
181 */
Bookatzc1a050a2017-10-10 15:49:28 -0700182message UidProcessStateChanged {
Yao Chend54f9dd2017-10-17 17:37:48 +0000183 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
184
185 // The state.
Bookatzc1a050a2017-10-10 15:49:28 -0700186 // TODO: Use the real (mapped) process states.
Joe Onorato62c220b2017-11-18 20:32:56 -0800187 optional android.app.ProcessState state = 2;
Yao Chend54f9dd2017-10-17 17:37:48 +0000188}
189
190/**
Bookatzc1a050a2017-10-10 15:49:28 -0700191 * Logs that a process started, finished, crashed, or ANRed.
192 *
193 * Logged from:
194 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
195 */
196message ProcessLifeCycleStateChanged {
197 // TODO: Use the real (mapped) process states.
198 optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
199
200 // TODO: What is this?
201 optional string name = 2;
202
Bookatzddccf0a2017-11-28 16:48:14 -0800203 // What lifecycle state the process changed to.
204 // This enum is specific to atoms.proto.
205 enum Event {
206 PROCESS_FINISHED = 0;
207 PROCESS_STARTED = 1;
208 PROCESS_CRASHED = 2;
209 PROCESS_ANRED = 3;
210 }
211 optional Event event = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700212}
213
Bookatzc1a050a2017-10-10 15:49:28 -0700214/**
215 * Logs when the ble scan state changes.
216 *
217 * Logged from:
218 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
219 */
220message BleScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800221 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700222
223 enum State {
224 OFF = 0;
225 ON = 1;
226 }
227 optional State state = 2;
228}
229
230/**
231 * Logs when an unoptimized ble scan state changes.
232 *
233 * Logged from:
234 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
235 */
236// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
237message BleUnoptimizedScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800238 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700239
240 enum State {
241 OFF = 0;
242 ON = 1;
243 }
244 optional State state = 2;
245}
246
247/**
248 * Logs reporting of a ble scan finding results.
249 *
250 * Logged from:
251 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
252 */
253// TODO: Consider changing to tracking per-scanner-id (log from AppScanStats).
254message BleScanResultReceived {
Yangster-macafad8c62018-01-05 22:30:49 -0800255 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700256
257 // Number of ble scan results returned.
258 optional int32 num_of_results = 2;
259}
260
261/**
262 * Logs when a sensor state changes.
263 *
264 * Logged from:
265 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
266 */
267message SensorStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800268 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700269
270 // TODO: Is there a way to get the actual name of the sensor?
271 // The id (int) of the sensor.
272 optional int32 sensor_id = 2;
273
274 enum State {
275 OFF = 0;
276 ON = 1;
277 }
278 optional State state = 3;
279}
280
281
282/**
283 * Logs when GPS state changes.
284 *
285 * Logged from:
286 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
287 */
288message GpsScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800289 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700290
291 enum State {
292 OFF = 0;
293 ON = 1;
294 }
295 optional State state = 2;
296}
297
298
299/**
300 * Logs when a sync manager sync state changes.
301 *
302 * Logged from:
303 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
304 */
305message SyncStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800306 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700307
308 // Name of the sync (as named in the app)
309 optional string name = 2;
310
311 enum State {
312 OFF = 0;
313 ON = 1;
314 }
315 optional State state = 3;
316}
317
318/**
319 * Logs when a job scheduler job state changes.
320 *
321 * Logged from:
322 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
323 */
324message ScheduledJobStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800325 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700326
327 // Name of the job (as named in the app)
328 optional string name = 2;
329
330 enum State {
331 OFF = 0;
332 ON = 1;
333 }
334 optional State state = 3;
335
336 // TODO: Consider adding the stopReason (int)
337}
338
339/**
340 * Logs when the audio state changes.
341 *
342 * Logged from:
343 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
344 */
345message AudioStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800346 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700347
348 enum State {
349 OFF = 0;
350 ON = 1;
351 }
352 optional State state = 2;
353}
354
355/**
356 * Logs when the video codec state changes.
357 *
358 * Logged from:
359 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
360 */
361message MediaCodecActivityChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800362 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700363
364 enum State {
365 OFF = 0;
366 ON = 1;
367 }
368 optional State state = 2;
369}
370
371/**
372 * Logs when the flashlight state changes.
373 *
374 * Logged from:
375 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
376 */
377message FlashlightStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800378 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700379
380 enum State {
381 OFF = 0;
382 ON = 1;
383 }
384 optional State state = 2;
385}
386
387/**
388 * Logs when the camera state changes.
389 *
390 * Logged from:
391 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
392 */
393message CameraStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800394 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700395
396 enum State {
397 OFF = 0;
398 ON = 1;
399 }
400 optional State state = 2;
401}
402
403/**
404 * Logs that the state of a wakelock (per app and per wakelock name) has changed.
Yao Chend54f9dd2017-10-17 17:37:48 +0000405 *
406 * Logged from:
407 * TODO
408 */
Bookatzd6746242017-10-24 18:39:35 -0700409message WakelockStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800410 repeated AttributionNode attribution_node = 1;
Yao Chend54f9dd2017-10-17 17:37:48 +0000411
Bookatzc1a050a2017-10-10 15:49:28 -0700412 // Type of wakelock.
413 enum Type {
414 PARTIAL = 0;
415 FULL = 1;
416 WINDOW = 2;
417 }
Stefan Lafonae2df012017-11-14 09:17:21 -0800418 optional Type type = 2;
Bookatzc1a050a2017-10-10 15:49:28 -0700419
420 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
421 optional string tag = 3;
422
423 enum State {
Yangster-maccfdf3a42017-12-06 13:42:38 -0800424 RELEASE = 0;
425 ACQUIRE = 1;
426 CHANGE_RELEASE = 2;
427 CHANGE_ACQUIRE = 3;
Bookatzc1a050a2017-10-10 15:49:28 -0700428 }
429 optional State state = 4;
430}
431
432/**
Bookatzc1a050a2017-10-10 15:49:28 -0700433 * Logs when a partial wakelock is considered 'long' (over 1 min).
434 *
435 * Logged from:
436 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
437 */
438message LongPartialWakelockStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800439 repeated AttributionNode attribution_node = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700440
Yao Chend54f9dd2017-10-17 17:37:48 +0000441 // The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
442 optional string tag = 2;
443
Bookatzc1a050a2017-10-10 15:49:28 -0700444 // TODO: I have no idea what this is.
445 optional string history_tag = 3;
446
447 enum State {
448 OFF = 0;
449 ON = 1;
450 }
451 optional State state = 4;
Yao Chend54f9dd2017-10-17 17:37:48 +0000452}
453
Bookatzc1a050a2017-10-10 15:49:28 -0700454/**
455 * Logs Battery Saver state change.
456 *
457 * Logged from:
458 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
459 */
460message BatterySaverModeStateChanged {
461 enum State {
462 OFF = 0;
463 ON = 1;
464 }
465 optional State state = 1;
466}
467
468/**
469 * Logs Doze mode state change.
470 *
471 * Logged from:
Bookatzddccf0a2017-11-28 16:48:14 -0800472 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatzc1a050a2017-10-10 15:49:28 -0700473 */
474message DeviceIdleModeStateChanged {
475 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
Bookatzddccf0a2017-11-28 16:48:14 -0800476 enum State {
477 DEVICE_IDLE_MODE_OFF = 0;
478 DEVICE_IDLE_MODE_LIGHT = 1;
479 DEVICE_IDLE_MODE_DEEP = 2;
480 }
481 optional State state = 1;
482}
483
484
485/**
486 * Logs state change of Doze mode including maintenance windows.
487 *
488 * Logged from:
489 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
490 */
491message DeviceIdlingModeStateChanged {
492 // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_.
493 enum State {
494 DEVICE_IDLE_MODE_OFF = 0;
495 DEVICE_IDLE_MODE_LIGHT = 1;
496 DEVICE_IDLE_MODE_DEEP = 2;
497 }
498 optional State state = 1;
Bookatzc1a050a2017-10-10 15:49:28 -0700499}
500
501/**
502 * Logs screen brightness level.
503 *
504 * Logged from:
505 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
506 */
507message ScreenBrightnessChanged {
508 // Screen brightness level. Should be in [-1, 255] according to PowerManager.java.
509 optional int32 level = 1;
Bookatz8c6571b2017-10-24 15:04:41 -0700510}
511
512/**
513 * Logs battery level (percent full, from 0 to 100).
514 *
515 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700516 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700517 */
518message BatteryLevelChanged {
519 // Battery level. Should be in [0, 100].
520 optional int32 battery_level = 1;
521}
522
523/**
524 * Logs change in charging status of the device.
525 *
526 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700527 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700528 */
529message ChargingStateChanged {
530 // TODO: Link directly to BatteryManager.java's constants (via a proto).
531 enum State {
532 BATTERY_STATUS_UNKNOWN = 1;
533 BATTERY_STATUS_CHARGING = 2;
534 BATTERY_STATUS_DISCHARGING = 3;
535 BATTERY_STATUS_NOT_CHARGING = 4;
536 BATTERY_STATUS_FULL = 5;
537 }
538 optional State charging_state = 1;
539}
540
541/**
542 * Logs whether the device is plugged in, and what power source it is using.
543 *
544 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700545 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700546 */
547message PluggedStateChanged {
548 // TODO: Link directly to BatteryManager.java's constants (via a proto).
549 enum State {
550 // Note that NONE is not in BatteryManager.java's constants.
551 BATTERY_PLUGGED_NONE = 0;
552 // Power source is an AC charger.
553 BATTERY_PLUGGED_AC = 1;
554 // Power source is a USB port.
555 BATTERY_PLUGGED_USB = 2;
556 // Power source is wireless.
557 BATTERY_PLUGGED_WIRELESS = 4;
558 }
559 optional State plugged_state = 1;
560}
561
562/**
563 * Logs the temperature of the device, in tenths of a degree Celsius.
564 *
565 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700566 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatz8c6571b2017-10-24 15:04:41 -0700567 */
568message DeviceTemperatureReported {
569 // Temperature in tenths of a degree C.
570 optional int32 temperature = 1;
571}
572
573// TODO: Define this more precisely.
574// TODO: Log the ON state somewhere. It isn't currently logged anywhere.
575/**
576 * Logs when the device turns off or on.
577 *
578 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700579 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700580 */
581message DeviceOnStatusChanged {
582 enum State {
583 OFF = 0;
584 ON = 1;
585 }
586 optional State state = 1;
587}
588
589/**
590 * Logs when an app's wakeup alarm fires.
591 *
592 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700593 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Bookatz8c6571b2017-10-24 15:04:41 -0700594 */
595message WakeupAlarmOccurred {
Yangster-macafad8c62018-01-05 22:30:49 -0800596 repeated AttributionNode attribution_node = 1;
Bookatzddccf0a2017-11-28 16:48:14 -0800597
598 // Name of the wakeup alarm.
599 optional string tag = 2;
600}
601
602/**
603 * Logs when an an app causes the mobile radio to change state.
604 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the mobile radio.
605 *
606 * Logged from:
607 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
608 */
609message MobileRadioPowerStateChanged {
610 // TODO: Add attribution instead of uid?
611 optional int32 uid = 1;
612
613 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
614 enum PowerState {
615 DC_POWER_STATE_LOW = 1;
616 DC_POWER_STATE_MEDIUM = 2;
617 DC_POWER_STATE_HIGH = 3;
618 }
619 optional PowerState power_state = 2;
620}
621
622/**
623 * Logs when an an app causes the wifi radio to change state.
624 * Changing from LOW to MEDIUM or HIGH can be considered the app waking the wifi radio.
625 *
626 * Logged from:
627 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
628 */
629message WifiRadioPowerStateChanged {
630 // TODO: Add attribution instead of uid?
631 optional int32 uid = 1;
632
633 // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
634 enum PowerState {
635 DC_POWER_STATE_LOW = 1;
636 DC_POWER_STATE_MEDIUM = 2;
637 DC_POWER_STATE_HIGH = 3;
638 }
639 optional PowerState power_state = 2;
Bookatz8c6571b2017-10-24 15:04:41 -0700640}
641
642/**
643 * Logs kernel wakeup reasons and aborts.
644 *
645 * Logged from:
646 * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
647 */
648message KernelWakeupReported {
649 // Name of the kernel wakeup reason (or abort).
650 optional string wakeup_reason_name = 1;
651
652 // Duration (in microseconds) for the wake-up interrupt to be serviced.
653 optional int64 duration_usec = 2;
Bookatze5885242017-10-24 20:10:31 -0700654}
655
656/**
657 * Logs wifi locks held by an app.
658 *
659 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700660 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700661 */
662message WifiLockStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800663 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700664
665 enum State {
666 OFF = 0;
667 ON = 1;
668 }
669 optional State state = 2;
670}
671
672/**
673 * Logs wifi signal strength changes.
674 *
675 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700676 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700677 */
678message WifiSignalStrengthChanged {
679 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
680 enum SignalStrength {
681 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
682 SIGNAL_STRENGTH_POOR = 1;
683 SIGNAL_STRENGTH_MODERATE = 2;
684 SIGNAL_STRENGTH_GOOD = 3;
685 SIGNAL_STRENGTH_GREAT = 4;
686 }
687 optional SignalStrength signal_strength = 1;
688}
689
690/**
691 * Logs wifi scans performed by an app.
692 *
693 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700694 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700695 */
696message WifiScanStateChanged {
Yangster-macafad8c62018-01-05 22:30:49 -0800697 repeated AttributionNode attribution_node = 1;
Bookatze5885242017-10-24 20:10:31 -0700698
699 enum State {
700 OFF = 0;
701 ON = 1;
702 }
703 optional State state = 2;
704}
705
706/**
707 * Logs phone signal strength changes.
708 *
709 * Logged from:
David Chenc28b2bb2017-10-24 12:52:52 -0700710 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
Bookatze5885242017-10-24 20:10:31 -0700711 */
712message PhoneSignalStrengthChanged {
713 // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
714 enum SignalStrength {
715 SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
716 SIGNAL_STRENGTH_POOR = 1;
717 SIGNAL_STRENGTH_MODERATE = 2;
718 SIGNAL_STRENGTH_GOOD = 3;
719 SIGNAL_STRENGTH_GREAT = 4;
720 }
721 optional SignalStrength signal_strength = 1;
David Chenc28b2bb2017-10-24 12:52:52 -0700722}
723
724/**
725 * Logs that a setting was updated.
726 * Logged from:
727 * frameworks/base/core/java/android/provider/Settings.java
728 * The tag and is_default allow resetting of settings to default values based on the specified
729 * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details.
730 */
731message SettingChanged {
732 // The name of the setting.
733 optional string setting = 1;
734
735 // The change being imposed on this setting. May represent a number, eg "3".
736 optional string value = 2;
737
738 // The new value of this setting. For most settings, this is same as value. For some settings,
739 // value is +X or -X where X represents an element in a set. For example, if the previous value
740 // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C.
741 // The +/- feature is currently only used for location_providers_allowed.
742 optional string new_value = 3;
743
744 // The previous value of this setting.
745 optional string prev_value = 4;
746
747 // The tag used with the is_default for resetting sets of settings. This is generally null.
748 optional string tag = 5;
749
750 // 1 indicates that this setting with tag should be resettable.
751 optional int32 is_default = 6;
752
753 // The user ID associated. Defined in android/os/UserHandle.java
754 optional int32 user = 7;
755}
Chenjie Yub3dda412017-10-24 13:41:59 -0700756
Chenjie Yu05013b32017-11-21 10:21:41 -0800757/**
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700758 * Logs activity going to foreground or background
759 *
760 * Logged from:
761 * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java
762 */
763message ActivityForegroundStateChanged {
Yangster-mac20877162017-12-22 17:19:39 -0800764 optional int32 uid = 1;
765 optional string pkg_name = 2;
766 optional string class_name = 3;
767
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700768 enum Activity {
769 MOVE_TO_BACKGROUND = 0;
770 MOVE_TO_FOREGROUND = 1;
771 }
Chenjie Yu3d4f6042017-10-27 15:39:34 -0700772 optional Activity activity = 4;
773}
David Chenc8a43242017-10-17 16:23:28 -0700774
775/**
David Chen9e3808c2017-11-20 17:25:34 -0800776 * Logs when an error is written to dropbox.
777 * Logged from:
778 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
779 */
780message DropboxErrorChanged {
781 // The uid if available. -1 means not available.
782 optional int32 uid = 1;
783
784 // Tag used when recording this error to dropbox. Contains data_ or system_ prefix.
785 optional string tag = 2;
786
787 // The name of the process.
788 optional string process_name = 3;
789
790 // The pid if available. -1 means not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800791 optional sint32 pid = 4;
David Chen9e3808c2017-11-20 17:25:34 -0800792
793 // 1 indicates is instant app. -1 indicates Not applicable.
David Chen6e3e6cb2018-01-03 16:14:06 -0800794 optional sint32 is_instant_app = 5;
David Chen9e3808c2017-11-20 17:25:34 -0800795
796 // The activity name if available.
797 optional string activity_name = 6;
798
David Chen6e3e6cb2018-01-03 16:14:06 -0800799 // The package name if available.
800 optional string package_name = 7;
801
David Chen9e3808c2017-11-20 17:25:34 -0800802 // 1 indicates in foreground. -1 indicates not available.
David Chen6e3e6cb2018-01-03 16:14:06 -0800803 optional sint32 is_foreground = 8;
David Chen9e3808c2017-11-20 17:25:34 -0800804}
805
David Chen0a368b22017-12-06 16:28:16 -0800806/*
807 * Allows other apps to push events into statsd.
808 * Logged from:
809 * frameworks/base/core/java/android/util/StatsLog.java
810 */
811message AppHook {
812 // The uid of the application that sent this custom atom.
813 optional int32 uid = 1;
814
815 // An arbitrary label chosen by the developer. For Android P, the label should be in [0, 16).
816 optional int32 label = 2;
817
818 // Allows applications to easily use a custom event as start/stop boundaries (ie, define custom
819 // predicates for the metrics).
820 enum State {
821 UNKNOWN = 0;
822 UNSPECIFIED = 1; // For events that are known to not represent START/STOP.
823 STOP = 2;
824 START = 3;
825 }
826 optional State state = 3;
827}
828
David Chen9e3808c2017-11-20 17:25:34 -0800829/**
Bookatz8fcd09a2017-12-18 13:01:10 -0800830 * Logs when statsd detects an anomaly.
831 *
832 * Logged from:
833 * frameworks/base/cmds/statsd/src/anomaly/AnomalyTracker.cpp
834 */
835message AnomalyDetected {
836 // Uid that owns the config whose anomaly detection alert fired.
837 optional int32 config_uid = 1;
838
Yangster-mac94e197c2018-01-02 16:03:03 -0800839 // Id of the config whose anomaly detection alert fired.
840 optional int64 config_id = 2;
Bookatz8fcd09a2017-12-18 13:01:10 -0800841
Yangster-mac94e197c2018-01-02 16:03:03 -0800842 // Id of the alert (i.e. name of the anomaly that was detected).
843 optional int64 alert_id = 3;
Bookatz8fcd09a2017-12-18 13:01:10 -0800844}
845
Olivier Gaillardaed7f122017-12-12 14:26:22 +0000846message AppStartChanged {
847 // The uid if available. -1 means not available.
848 optional int32 uid = 1;
849
850 // The app package name.
851 optional string pkg_name = 2;
852
853 enum TransitionType {
854 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
855 WARM = 1;
856 HOT = 2;
857 COLD = 3;
858 }
859 // The transition type.
860 optional TransitionType type = 3;
861
862 // The activity name.
863 optional string activity_name = 4;
864
865 // The name of the calling app. Empty if not set.
866 optional string calling_pkg_name = 5;
867
868 // Whether the app is an instant app.
869 optional bool is_instant_app = 6;
870
871 // Device uptime when activity started.
872 optional int64 activity_start_msec = 7;
873
874 // TODO: Update android/app/ActivityManagerInternal.java constants to depend on our proto enum.
875 enum TransitionReason {
876 APP_START_TRANSITION_REASON_UNKNOWN = 0;
877 SPLASH_SCREEN = 1;
878 WINDOWS_DRAWN = 2;
879 TIMEOUT = 3;
880 SNAPSHOT = 4;
881 }
882 optional TransitionReason reason = 8;
883
884 optional int32 transition_delay_msec = 9;
885 // -1 if not set.
886 optional int32 starting_window_delay_msec = 10;
887 // -1 if not set.
888 optional int32 bind_application_delay_msec = 11;
889 optional int32 windows_drawn_delay_msec = 12;
890
891 // Empty if not set.
892 optional string launch_token = 13;
893
894}
895
896message AppStartCancelChanged {
897 // The uid if available. -1 means not available.
898 optional int32 uid = 1;
899
900 // The app package name.
901 optional string pkg_name = 2;
902
903 enum TransitionType {
904 APP_START_TRANSITION_TYPE_UNKNOWN = 0;
905 WARM = 1;
906 HOT = 2;
907 COLD = 3;
908 }
909 // The transition type.
910 optional TransitionType type = 3;
911
912 // The activity name.
913 optional string activity_name = 4;
914}
915
916message AppStartFullyDrawnChanged {
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 WITH_BUNDLE = 1;
926 WITHOUT_BUNDLE = 2;
927 }
928 // The transition type.
929 optional TransitionType type = 3;
930
931 // The activity name.
932 optional string activity_name = 4;
933
934 optional bool transition_process_running = 5;
935
936 // App startup time (until call to Activity#reportFullyDrawn()).
937 optional int64 app_startup_time_ms = 6;
938}
939
Bookatz8fcd09a2017-12-18 13:01:10 -0800940/**
Chenjie Yu52cacc62017-12-08 18:11:45 -0800941 * Logs a picture-in-picture action
942 * Logged from:
943 * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
944 * frameworks/base/services/core/java/com/android/server/am/ActivityStackSupervisor.java
945 * frameworks/base/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
946 */
947message PictureInPictureStateChanged {
948 optional int32 uid = 1;
949
950 optional string package_name = 2;
951
952 optional string class_name = 3;
953
954 // Picture-in-Picture action occurred, similar to
955 // frameworks/base/proto/src/metrics_constants.proto
956 enum State {
957 ENTERED = 1;
958 EXPANDED_TO_FULL_SCREEN = 2;
959 MINIMIZED = 3;
960 DISMISSED = 4;
961 }
962 optional State state = 4;
963}
964
965/**
David Chenc8a43242017-10-17 16:23:28 -0700966 * Pulls bytes transferred via wifi (Sum of foreground and background usage).
967 *
968 * Pulled from:
969 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
970 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800971message WifiBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -0700972 optional int32 uid = 1;
973
974 optional int64 rx_bytes = 2;
975
976 optional int64 rx_packets = 3;
977
978 optional int64 tx_bytes = 4;
979
980 optional int64 tx_packets = 5;
981}
982
983/**
984 * Pulls bytes transferred via wifi (separated by foreground and background usage).
985 *
986 * Pulled from:
987 * StatsCompanionService (using BatteryStats to get which interfaces are wifi)
988 */
Chenjie Yu31d14d72017-12-12 17:54:33 -0800989message WifiBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -0700990 optional int32 uid = 1;
991
992 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
993 optional int32 is_foreground = 2;
994
995 optional int64 rx_bytes = 3;
996
997 optional int64 rx_packets = 4;
998
999 optional int64 tx_bytes = 5;
1000
1001 optional int64 tx_packets = 6;
1002}
1003
1004/**
1005 * Pulls bytes transferred via mobile networks (Sum of foreground and background usage).
1006 *
1007 * Pulled from:
1008 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1009 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001010message MobileBytesTransfer {
David Chenc8a43242017-10-17 16:23:28 -07001011 optional int32 uid = 1;
1012
1013 optional int64 rx_bytes = 2;
1014
1015 optional int64 rx_packets = 3;
1016
1017 optional int64 tx_bytes = 4;
1018
1019 optional int64 tx_packets = 5;
1020}
1021
1022/**
1023 * Pulls bytes transferred via mobile networks (separated by foreground and background usage).
1024 *
1025 * Pulled from:
1026 * StatsCompanionService (using BatteryStats to get which interfaces are mobile data)
1027 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001028message MobileBytesTransferByFgBg {
David Chenc8a43242017-10-17 16:23:28 -07001029 optional int32 uid = 1;
1030
1031 // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats.
1032 optional int32 is_foreground = 2;
1033
1034 optional int64 rx_bytes = 3;
1035
1036 optional int64 rx_packets = 4;
1037
1038 optional int64 tx_bytes = 5;
1039
1040 optional int64 tx_packets = 6;
1041}
1042
1043/**
1044 * Pulls the kernel wakelock durations. This atom is adapted from
1045 * android/internal/os/KernelWakelockStats.java
1046 *
1047 * Pulled from:
1048 * StatsCompanionService using KernelWakelockReader.
1049 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001050message KernelWakelock {
David Chenc8a43242017-10-17 16:23:28 -07001051 optional string name = 1;
1052
1053 optional int32 count = 2;
1054
1055 optional int32 version = 3;
1056
1057 optional int64 time = 4;
1058}
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001059
Chenjie Yu05013b32017-11-21 10:21:41 -08001060/**
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001061 * Pulls low power state information. This includes platform and subsystem sleep state information,
1062 * PowerStatePlatformSleepState, PowerStateVoter or PowerStateSubsystemSleepState as defined in
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001063 * hardware/interfaces/power/1.0/types.hal
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001064 * hardware/interfaces/power/1.1/types.hal
1065 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001066message SubsystemSleepState {
Chenjie Yuc8b7f222018-01-11 23:25:57 -08001067 // Name should be in the format of XXX.YYY where XXX is subsystem name,
1068 // YYY is corresponding voter name.
1069 // If there are no voters, the format should just be XXX (with no dot).
1070 // XXX and YYY should not contain a "." in it.
1071 optional string name = 1;
1072 // The number of times it entered, or voted for entering the sleep state
1073 optional uint64 count = 2;
1074 // The length of time spent in, or spent voting for, the sleep state
1075 optional uint64 timeMs = 3;
Chenjie Yu5305e1d2017-10-31 13:49:36 -07001076}
David Chen21582962017-11-01 17:32:46 -07001077
1078/**
1079 * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky
1080 * behavior in its own uid. However, the metrics of these isolated uid's almost always should be
1081 * attributed back to the parent (host) uid. One example is Chrome.
1082 *
1083 * Logged from:
1084 * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
1085 */
1086message IsolatedUidChanged {
1087 // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid.
1088 optional int32 parent_uid = 1;
1089
1090 optional int32 isolated_uid = 2;
1091
1092 // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to
1093 // be removed before if it's used for another parent uid.
1094 optional int32 is_create = 3;
1095}
Chenjie Yu7f8def92017-11-03 09:33:15 -07001096
Chenjie Yu05013b32017-11-21 10:21:41 -08001097/**
Chenjie Yu7f8def92017-11-03 09:33:15 -07001098 * Pulls Cpu time per frequency.
Chenjie Yu1ee9b742018-01-10 16:02:57 -08001099 * Pulls the time the cpu spend on the frequency index. Frequency index
1100 * starts from highest to lowest. The value should be monotonically
1101 * increasing since boot. However, if there is a cpu
1102 * hotplug event, the value would be reset as well.
Chenjie Yu7f8def92017-11-03 09:33:15 -07001103 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001104message CpuTimePerFreq {
Chenjie Yu7f8def92017-11-03 09:33:15 -07001105 optional uint32 cluster = 1;
1106 optional uint32 freq_index = 2;
Chenjie Yu31d14d72017-12-12 17:54:33 -08001107 optional uint64 time_ms = 3;
Chenjie Yu7f8def92017-11-03 09:33:15 -07001108}
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001109
Chenjie Yu05013b32017-11-21 10:21:41 -08001110/**
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001111 * Pulls Cpu Time Per Uid.
1112 * Note that isolated process uid time should be attributed to host uids.
1113 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001114message CpuTimePerUid {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001115 optional uint64 uid = 1;
1116 optional uint64 user_time_ms = 2;
1117 optional uint64 sys_time_ms = 3;
1118}
1119
1120/**
1121 * Pulls Cpu Time Per Uid per frequency.
1122 * Note that isolated process uid time should be attributed to host uids.
1123 * For each uid, we order the time by descending frequencies.
1124 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001125message CpuTimePerUidFreq {
Chenjie Yue33bc3b2017-11-06 17:56:44 -08001126 optional uint64 uid = 1;
1127 optional uint64 freq_idx = 2;
1128 optional uint64 time_ms = 3;
1129}
Hugo Benichi884970e2017-11-14 22:42:46 +09001130
1131/*
1132 * Logs the reception of an incoming network packet causing the main system to wake up for
1133 * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd
1134 * and processed by WakeupController.cpp.
1135 */
1136message PacketWakeupOccurred {
1137 // The uid owning the socket into which the packet was delivered, or -1 if the packet was
1138 // delivered nowhere.
1139 optional int32 uid = 1;
1140 // The interface name on which the packet was received.
1141 optional string iface = 2;
1142 // The ethertype value of the packet.
1143 optional int32 ethertype = 3;
1144 // String representation of the destination MAC address of the packet.
1145 optional string destination_hardware_address = 4;
1146 // String representation of the source address of the packet if this was an IP packet.
1147 optional string source_ip = 5;
1148 // String representation of the destination address of the packet if this was an IP packet.
1149 optional string destination_ip = 6;
1150 // The value of the protocol field if this was an IPv4 packet or the value of the Next Header
1151 // field if this was an IPv6 packet. The range of possible values is the same for both IP
1152 // families.
1153 optional int32 ip_next_header = 7;
1154 // The source port if this was a TCP or UDP packet.
1155 optional int32 source_port = 8;
1156 // The destination port if this was a TCP or UDP packet.
1157 optional int32 destination_port = 9;
1158}
Chenjie Yu05013b32017-11-21 10:21:41 -08001159
1160/**
1161 * Pulls Wifi Controller Activity Energy Info
1162 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001163message WifiActivityEnergyInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001164 // timestamp(wall clock) of record creation
1165 optional uint64 timestamp_ms = 1;
1166 // stack reported state
1167 // TODO: replace this with proto enum
1168 optional int32 stack_state = 2;
1169 // tx time in ms
1170 optional uint64 controller_tx_time_ms = 3;
1171 // rx time in ms
1172 optional uint64 controller_rx_time_ms = 4;
1173 // idle time in ms
1174 optional uint64 controller_idle_time_ms = 5;
1175 // product of current(mA), voltage(V) and time(ms)
1176 optional uint64 controller_energy_used = 6;
1177}
1178
1179/**
1180 * Pulls Modem Activity Energy Info
1181 */
Chenjie Yu31d14d72017-12-12 17:54:33 -08001182message ModemActivityInfo {
Chenjie Yu05013b32017-11-21 10:21:41 -08001183 // timestamp(wall clock) of record creation
1184 optional uint64 timestamp_ms = 1;
1185 // sleep time in ms.
1186 optional uint64 sleep_time_ms = 2;
1187 // idle time in ms
1188 optional uint64 controller_idle_time_ms = 3;
1189 /**
1190 * Tx power index
1191 * index 0 = tx_power < 0dBm
1192 * index 1 = 0dBm < tx_power < 5dBm
1193 * index 2 = 5dBm < tx_power < 15dBm
1194 * index 3 = 15dBm < tx_power < 20dBm
1195 * index 4 = tx_power > 20dBm
1196 */
1197 // tx time in ms at power level 0
1198 optional uint64 controller_tx_time_pl0_ms = 4;
1199 // tx time in ms at power level 1
1200 optional uint64 controller_tx_time_pl1_ms = 5;
1201 // tx time in ms at power level 2
1202 optional uint64 controller_tx_time_pl2_ms = 6;
1203 // tx time in ms at power level 3
1204 optional uint64 controller_tx_time_pl3_ms = 7;
1205 // tx time in ms at power level 4
1206 optional uint64 controller_tx_time_pl4_ms = 8;
1207 // rx time in ms at power level 5
1208 optional uint64 controller_rx_time_ms = 9;
1209 // product of current(mA), voltage(V) and time(ms)
1210 optional uint64 energy_used = 10;
Joe Onorato62c220b2017-11-18 20:32:56 -08001211}
Rajeev Kumar508a9bf2018-01-18 15:49:11 -08001212
1213/*
1214 * Logs the memory stats for a process
1215 */
1216message MemoryStat {
1217 // The uid if available. -1 means not available.
1218 optional int32 uid = 1;
1219
1220 // The app package name.
1221 optional string pkg_name = 2;
1222
1223 // # of page-faults
1224 optional int64 pgfault = 3;
1225
1226 // # of major page-faults
1227 optional int64 pgmajfault = 4;
1228
1229 // RSS+CACHE(+SWAP)
1230 optional int64 usage_in_bytes = 5;
1231}
1232
1233/*
1234 * Logs the event when LMKD kills a process to reduce memory pressure
1235 * Logged from:
1236 * system/core/lmkd/lmkd.c
1237 */
1238message LmkEventOccurred {
1239 // The uid if available. -1 means not available.
1240 optional int32 uid = 1;
1241
1242 // The app package name.
1243 optional string pkg_name = 2;
1244
1245 // oom adj score.
1246 optional int32 oom_score = 3;
1247
1248 // Used as start/stop boundaries for the event
1249 enum State {
1250 UNKNOWN = 0;
1251 START = 1;
1252 END = 2;
1253 }
1254 optional State state = 4;
1255}
Chenjie Yu9da105b2018-01-13 12:41:08 -08001256
1257/*
1258 * Cpu syspend time for cpu power calculation.
1259 */
1260message CpuSuspendTime {
1261 optional uint64 time = 1;
1262}
1263
1264/*
1265 * Cpu idle time for cpu power calculation.
1266 */
1267message CpuIdleTime {
1268 optional uint64 time = 1;
1269}
1270
1271/*
1272 * Reads from /proc/uid_concurrent_active_time which has the format:
1273 * active: X (X is # cores)
1274 * [uid0]: [time-0] [time-1] [time-2] ... (# entries = # cores)
1275 * [uid1]: [time-0] [time-1] [time-2] ... ...
1276 * ...
1277 * Time-N means the CPU time a UID spent running concurrently with N other processes.
1278 * The file contains a monotonically increasing count of time for a single boot.
1279 */
1280message CpuActiveTime {
1281 optional uint64 uid = 1;
1282 optional uint64 idx = 2;
1283 optional uint64 time_ms = 3;
1284}
1285
1286/**
1287 * Reads from /proc/uid_concurrent_policy_time which has the format:
1288 * policy0: X policy4: Y (there are X cores on policy0, Y cores on policy4)
1289 * [uid0]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1290 * [uid1]: [time-0-0] [time-0-1] ... [time-1-0] [time-1-1] ...
1291 * ...
1292 * Time-X-Y means the time a UID spent on clusterX running concurrently with Y other processes.
1293 * The file contains a monotonically increasing count of time for a single boot.
1294 */
1295message CpuClusterTime {
1296 optional uint64 uid = 1;
1297 optional uint64 idx = 2;
1298 optional uint64 time_ms = 3;
1299}