Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | syntax = "proto2"; |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 18 | |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 19 | // TODO: Not the right package and class name |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 20 | package android.os.statsd; |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 21 | option java_package = "com.android.os"; |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 22 | option java_outer_classname = "AtomsProto"; |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 23 | |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 24 | /** |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 25 | * The master atom class. This message defines all of the available |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 26 | * raw stats log events from the Android system, also known as "atoms." |
| 27 | * |
| 28 | * This field contains a single oneof with all of the available messages. |
| 29 | * The stats-log-api-gen tool runs as part of the Android build and |
| 30 | * generates the android.util.StatsLog class, which contains the constants |
| 31 | * and methods that Android uses to log. |
| 32 | * |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 33 | * This Atom class is not actually built into the Android system. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 34 | * Instead, statsd on Android constructs these messages synthetically, |
| 35 | * in the format defined here and in stats_log.proto. |
| 36 | */ |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 37 | message Atom { |
| 38 | // Pushed atoms start at 2. |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 39 | oneof pushed { |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 40 | // For StatsLog reasons, 1 is illegal and will not work. Must start at 2. |
| 41 | BleScanStateChanged ble_scan_state_changed = 2; |
| 42 | BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3; |
| 43 | BleScanResultReceived ble_scan_result_received = 4; |
| 44 | SensorStateChanged sensor_state_changed = 5; |
| 45 | GpsScanStateChanged gps_scan_state_changed = 6; // TODO: untested |
| 46 | SyncStateChanged sync_state_changed = 7; |
| 47 | ScheduledJobStateChanged scheduled_job_state_changed = 8; |
| 48 | ScreenBrightnessChanged screen_brightness_changed = 9; |
| 49 | // 10-20 are temporarily reserved for wakelocks etc. |
Bookatz | d674624 | 2017-10-24 18:39:35 -0700 | [diff] [blame] | 50 | WakelockStateChanged wakelock_state_changed = 10; |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 51 | UidWakelockStateChanged uid_wakelock_state_changed = 11; |
| 52 | LongPartialWakelockStateChanged long_partial_wakelock_state_changed = 12; |
| 53 | BatterySaverModeStateChanged battery_saver_mode_state_changed = 21; |
| 54 | DeviceIdleModeStateChanged device_idle_mode_state_changed = 22; |
| 55 | AudioStateChanged audio_state_changed = 23; |
| 56 | MediaCodecActivityChanged media_codec_activity_changed = 24; |
| 57 | CameraStateChanged camera_state_changed = 25; |
| 58 | FlashlightStateChanged flashlight_state_changed = 26; |
| 59 | UidProcessStateChanged uid_process_state_changed = 27; |
| 60 | ProcessLifeCycleStateChanged process_life_cycle_state_changed = 28; |
| 61 | ScreenStateChanged screen_state_changed = 29; |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 62 | BatteryLevelChanged battery_level_changed = 30; |
| 63 | ChargingStateChanged charging_state_changed = 31; |
| 64 | PluggedStateChanged plugged_state_changed = 32; |
| 65 | DeviceTemperatureReported device_temperature_reported = 33; |
| 66 | DeviceOnStatusChanged device_on_status_changed = 34; |
| 67 | WakeupAlarmOccurred wakeup_alarm_occurred = 35; |
| 68 | KernelWakeupReported kernel_wakeup_reported = 36; |
Bookatz | e588524 | 2017-10-24 20:10:31 -0700 | [diff] [blame] | 69 | WifiLockStateChanged wifi_lock_state_changed = 37; |
| 70 | WifiSignalStrengthChanged wifi_signal_strength_changed = 38; |
| 71 | WifiScanStateChanged wifi_scan_state_changed = 39; |
| 72 | PhoneSignalStrengthChanged phone_signal_strength_changed = 40; |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 73 | SettingChanged setting_changed = 41; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 74 | ActivityForegroundStateChanged activity_foreground_state_changed = 42; |
David Chen | 2158296 | 2017-11-01 17:32:46 -0700 | [diff] [blame] | 75 | IsolatedUidChanged isolated_uid_changed = 43; |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 76 | // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 77 | } |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 78 | |
| 79 | // Pulled events will start at field 1000. |
| 80 | oneof pulled { |
| 81 | WifiBytesTransferred wifi_bytes_transferred = 1000; |
| 82 | WifiBytesTransferredByFgBg wifi_bytes_transferred_by_fg_bg = 1001; |
| 83 | MobileBytesTransferred mobile_bytes_transferred = 1002; |
| 84 | MobileBytesTransferredByFgBg mobile_bytes_transferred_by_fg_bg = 1003; |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 85 | KernelWakelockPulled kernel_wakelock_pulled = 1004; |
| 86 | PowerStatePlatformSleepStatePulled power_state_platform_sleep_state_pulled = 1005; |
| 87 | PowerStateVoterPulled power_state_voter_pulled = 1006; |
| 88 | PowerStateSubsystemSleepStatePulled power_state_subsystem_sleep_state_pulled = 1007; |
Chenjie Yu | 7f8def9 | 2017-11-03 09:33:15 -0700 | [diff] [blame] | 89 | CpuTimePerFreqPulled cpu_time_per_freq_pulled = 1008; |
Chenjie Yu | e33bc3b | 2017-11-06 17:56:44 -0800 | [diff] [blame] | 90 | CpuTimePerUidPulled cpu_time_per_uid_pulled = 1009; |
| 91 | CpuTimePerUidFreqPulled cpu_time_per_uid_freq_pulled = 1010; |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 92 | } |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 95 | /** |
| 96 | * A WorkSource represents the chained attribution of applications that |
| 97 | * resulted in a particular bit of work being done. |
| 98 | */ |
| 99 | message WorkSource { |
| 100 | // TODO |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 103 | /* |
| 104 | * ***************************************************************************** |
yro | de4ca10 | 2017-11-15 22:57:24 -0800 | [diff] [blame^] | 105 | * Below are all of the individual atoms that are logged by Android via statsd. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 106 | * |
| 107 | * RULES: |
| 108 | * - The field ids for each atom must start at 1, and count upwards by 1. |
| 109 | * Skipping field ids is not allowed. |
| 110 | * - These form an API, so renaming, renumbering or removing fields is |
| 111 | * not allowed between android releases. (This is not currently enforced, |
| 112 | * but there will be a tool to enforce this restriction). |
| 113 | * - The types must be built-in protocol buffer types, namely, no sub-messages |
| 114 | * are allowed (yet). The bytes type is also not allowed. |
| 115 | * - The CamelCase name of the message type should match the |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 116 | * underscore_separated name as defined in Atom. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 117 | * - If an atom represents work that can be attributed to an app, there can |
| 118 | * be exactly one WorkSource field. It must be field number 1. |
| 119 | * - A field that is a uid should be a string field, tagged with the [xxx] |
| 120 | * annotation. The generated code on android will be represented by UIDs, |
| 121 | * and those UIDs will be translated in xxx to those strings. |
| 122 | * |
| 123 | * CONVENTIONS: |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 124 | * - Events are past tense. e.g. ScreenStateChanged, not ScreenStateChange. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 125 | * - If there is a UID, it goes first. Think in an object-oriented fashion. |
| 126 | * ***************************************************************************** |
| 127 | */ |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 128 | |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 129 | /** |
| 130 | * Logs when the screen state changes. |
| 131 | * |
| 132 | * Logged from: |
| 133 | * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java |
| 134 | */ |
| 135 | message ScreenStateChanged { |
| 136 | // TODO: Use the real screen state. |
| 137 | enum State { |
| 138 | STATE_UNKNOWN = 0; |
| 139 | STATE_OFF = 1; |
| 140 | STATE_ON = 2; |
| 141 | STATE_DOZE = 3; |
| 142 | STATE_DOZE_SUSPEND = 4; |
| 143 | STATE_VR = 5; |
| 144 | } |
| 145 | // New screen state. |
| 146 | optional State display_state = 1; |
Stefan Lafon | cdb1a0e | 2017-09-27 20:24:15 -0700 | [diff] [blame] | 147 | } |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 148 | |
| 149 | /** |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 150 | * Logs that the state of a process state, as per the activity manager, has changed. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 151 | * |
| 152 | * Logged from: |
| 153 | * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java |
| 154 | */ |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 155 | message UidProcessStateChanged { |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 156 | optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation |
| 157 | |
| 158 | // The state. |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 159 | // TODO: Use the real (mapped) process states. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 160 | optional int32 state = 2; |
| 161 | } |
| 162 | |
| 163 | /** |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 164 | * Logs that a process started, finished, crashed, or ANRed. |
| 165 | * |
| 166 | * Logged from: |
| 167 | * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java |
| 168 | */ |
| 169 | message ProcessLifeCycleStateChanged { |
| 170 | // TODO: Use the real (mapped) process states. |
| 171 | optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation |
| 172 | |
| 173 | // TODO: What is this? |
| 174 | optional string name = 2; |
| 175 | |
| 176 | // The state. |
| 177 | // TODO: Use an enum. |
| 178 | optional int32 event = 3; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | |
| 183 | /** |
| 184 | * Logs when the ble scan state changes. |
| 185 | * |
| 186 | * Logged from: |
| 187 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 188 | */ |
| 189 | message BleScanStateChanged { |
| 190 | // TODO: Add attribution instead of uid. |
| 191 | optional int32 uid = 1; |
| 192 | |
| 193 | enum State { |
| 194 | OFF = 0; |
| 195 | ON = 1; |
| 196 | } |
| 197 | optional State state = 2; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Logs when an unoptimized ble scan state changes. |
| 202 | * |
| 203 | * Logged from: |
| 204 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 205 | */ |
| 206 | // TODO: Consider changing to tracking per-scanner-id (log from AppScanStats). |
| 207 | message BleUnoptimizedScanStateChanged { |
| 208 | // TODO: Add attribution instead of uid. |
| 209 | optional int32 uid = 1; |
| 210 | |
| 211 | enum State { |
| 212 | OFF = 0; |
| 213 | ON = 1; |
| 214 | } |
| 215 | optional State state = 2; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * Logs reporting of a ble scan finding results. |
| 220 | * |
| 221 | * Logged from: |
| 222 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 223 | */ |
| 224 | // TODO: Consider changing to tracking per-scanner-id (log from AppScanStats). |
| 225 | message BleScanResultReceived { |
| 226 | // TODO: Add attribution instead of uid. |
| 227 | optional int32 uid = 1; |
| 228 | |
| 229 | // Number of ble scan results returned. |
| 230 | optional int32 num_of_results = 2; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * Logs when a sensor state changes. |
| 235 | * |
| 236 | * Logged from: |
| 237 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 238 | */ |
| 239 | message SensorStateChanged { |
| 240 | // TODO: Add attribution instead of uid. |
| 241 | optional int32 uid = 1; |
| 242 | |
| 243 | // TODO: Is there a way to get the actual name of the sensor? |
| 244 | // The id (int) of the sensor. |
| 245 | optional int32 sensor_id = 2; |
| 246 | |
| 247 | enum State { |
| 248 | OFF = 0; |
| 249 | ON = 1; |
| 250 | } |
| 251 | optional State state = 3; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | /** |
| 256 | * Logs when GPS state changes. |
| 257 | * |
| 258 | * Logged from: |
| 259 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 260 | */ |
| 261 | message GpsScanStateChanged { |
| 262 | // TODO: Add attribution instead of uid. |
| 263 | optional int32 uid = 1; |
| 264 | |
| 265 | enum State { |
| 266 | OFF = 0; |
| 267 | ON = 1; |
| 268 | } |
| 269 | optional State state = 2; |
| 270 | } |
| 271 | |
| 272 | |
| 273 | /** |
| 274 | * Logs when a sync manager sync state changes. |
| 275 | * |
| 276 | * Logged from: |
| 277 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 278 | */ |
| 279 | message SyncStateChanged { |
| 280 | // TODO: Add attribution instead of uid. |
| 281 | optional int32 uid = 1; |
| 282 | |
| 283 | // Name of the sync (as named in the app) |
| 284 | optional string name = 2; |
| 285 | |
| 286 | enum State { |
| 287 | OFF = 0; |
| 288 | ON = 1; |
| 289 | } |
| 290 | optional State state = 3; |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * Logs when a job scheduler job state changes. |
| 295 | * |
| 296 | * Logged from: |
| 297 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 298 | */ |
| 299 | message ScheduledJobStateChanged { |
| 300 | // TODO: Add attribution instead of uid. |
| 301 | optional int32 uid = 1; |
| 302 | |
| 303 | // Name of the job (as named in the app) |
| 304 | optional string name = 2; |
| 305 | |
| 306 | enum State { |
| 307 | OFF = 0; |
| 308 | ON = 1; |
| 309 | } |
| 310 | optional State state = 3; |
| 311 | |
| 312 | // TODO: Consider adding the stopReason (int) |
| 313 | } |
| 314 | |
| 315 | /** |
| 316 | * Logs when the audio state changes. |
| 317 | * |
| 318 | * Logged from: |
| 319 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 320 | */ |
| 321 | message AudioStateChanged { |
| 322 | // TODO: Add attribution instead of uid. |
| 323 | optional int32 uid = 1; |
| 324 | |
| 325 | enum State { |
| 326 | OFF = 0; |
| 327 | ON = 1; |
| 328 | } |
| 329 | optional State state = 2; |
| 330 | } |
| 331 | |
| 332 | /** |
| 333 | * Logs when the video codec state changes. |
| 334 | * |
| 335 | * Logged from: |
| 336 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 337 | */ |
| 338 | message MediaCodecActivityChanged { |
| 339 | // TODO: Add attribution instead of uid. |
| 340 | optional int32 uid = 1; |
| 341 | |
| 342 | enum State { |
| 343 | OFF = 0; |
| 344 | ON = 1; |
| 345 | } |
| 346 | optional State state = 2; |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Logs when the flashlight state changes. |
| 351 | * |
| 352 | * Logged from: |
| 353 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 354 | */ |
| 355 | message FlashlightStateChanged { |
| 356 | // TODO: Add attribution instead of uid. |
| 357 | optional int32 uid = 1; |
| 358 | |
| 359 | enum State { |
| 360 | OFF = 0; |
| 361 | ON = 1; |
| 362 | } |
| 363 | optional State state = 2; |
| 364 | } |
| 365 | |
| 366 | /** |
| 367 | * Logs when the camera state changes. |
| 368 | * |
| 369 | * Logged from: |
| 370 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 371 | */ |
| 372 | message CameraStateChanged { |
| 373 | // TODO: Add attribution instead of uid. |
| 374 | optional int32 uid = 1; |
| 375 | |
| 376 | enum State { |
| 377 | OFF = 0; |
| 378 | ON = 1; |
| 379 | } |
| 380 | optional State state = 2; |
| 381 | } |
| 382 | |
| 383 | /** |
| 384 | * Logs that the state of a wakelock (per app and per wakelock name) has changed. |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 385 | * |
| 386 | * Logged from: |
| 387 | * TODO |
| 388 | */ |
Bookatz | d674624 | 2017-10-24 18:39:35 -0700 | [diff] [blame] | 389 | message WakelockStateChanged { |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 390 | // TODO: Add attribution instead of uid. |
| 391 | optional int32 uid = 1; |
| 392 | |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 393 | // Type of wakelock. |
| 394 | enum Type { |
| 395 | PARTIAL = 0; |
| 396 | FULL = 1; |
| 397 | WINDOW = 2; |
| 398 | } |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 399 | optional Type type = 2; |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 400 | |
| 401 | // The wakelock tag (Called tag in the Java API, sometimes name elsewhere). |
| 402 | optional string tag = 3; |
| 403 | |
| 404 | enum State { |
| 405 | OFF = 0; |
| 406 | ON = 1; |
| 407 | } |
| 408 | optional State state = 4; |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * Logs when an app is holding a wakelock, regardless of the wakelock's name. |
| 413 | * |
| 414 | * Logged from: |
| 415 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 416 | */ |
| 417 | message UidWakelockStateChanged { |
| 418 | // TODO: Add attribution instead of uid. |
| 419 | optional int32 uid = 1; |
| 420 | |
| 421 | // Type of wakelock. |
| 422 | enum Type { |
| 423 | PARTIAL = 0; |
| 424 | FULL = 1; |
| 425 | WINDOW = 2; |
| 426 | } |
Stefan Lafon | ae2df01 | 2017-11-14 09:17:21 -0800 | [diff] [blame] | 427 | optional Type type = 2; |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 428 | |
| 429 | enum State { |
| 430 | OFF = 0; |
| 431 | ON = 1; |
| 432 | } |
| 433 | optional State state = 3; |
| 434 | } |
| 435 | |
| 436 | /** |
| 437 | * 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 | */ |
| 442 | message LongPartialWakelockStateChanged { |
| 443 | // TODO: Add attribution instead of uid? |
| 444 | optional int32 uid = 1; |
| 445 | |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 446 | // The wakelock tag (Called tag in the Java API, sometimes name elsewhere). |
| 447 | optional string tag = 2; |
| 448 | |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 449 | // TODO: I have no idea what this is. |
| 450 | optional string history_tag = 3; |
| 451 | |
| 452 | enum State { |
| 453 | OFF = 0; |
| 454 | ON = 1; |
| 455 | } |
| 456 | optional State state = 4; |
Yao Chen | d54f9dd | 2017-10-17 17:37:48 +0000 | [diff] [blame] | 457 | } |
| 458 | |
Bookatz | c1a050a | 2017-10-10 15:49:28 -0700 | [diff] [blame] | 459 | /** |
| 460 | * Logs Battery Saver state change. |
| 461 | * |
| 462 | * Logged from: |
| 463 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 464 | */ |
| 465 | message BatterySaverModeStateChanged { |
| 466 | enum State { |
| 467 | OFF = 0; |
| 468 | ON = 1; |
| 469 | } |
| 470 | optional State state = 1; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Logs Doze mode state change. |
| 475 | * |
| 476 | * Logged from: |
| 477 | * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java |
| 478 | */ |
| 479 | message DeviceIdleModeStateChanged { |
| 480 | // TODO: Use the enum matching BatteryStats.DEVICE_IDLE_MODE_. |
| 481 | optional int32 state = 1; |
| 482 | } |
| 483 | |
| 484 | /** |
| 485 | * Logs screen brightness level. |
| 486 | * |
| 487 | * Logged from: |
| 488 | * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java |
| 489 | */ |
| 490 | message ScreenBrightnessChanged { |
| 491 | // Screen brightness level. Should be in [-1, 255] according to PowerManager.java. |
| 492 | optional int32 level = 1; |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 493 | } |
| 494 | |
| 495 | /** |
| 496 | * Logs battery level (percent full, from 0 to 100). |
| 497 | * |
| 498 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 499 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 500 | */ |
| 501 | message BatteryLevelChanged { |
| 502 | // Battery level. Should be in [0, 100]. |
| 503 | optional int32 battery_level = 1; |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * Logs change in charging status of the device. |
| 508 | * |
| 509 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 510 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 511 | */ |
| 512 | message ChargingStateChanged { |
| 513 | // TODO: Link directly to BatteryManager.java's constants (via a proto). |
| 514 | enum State { |
| 515 | BATTERY_STATUS_UNKNOWN = 1; |
| 516 | BATTERY_STATUS_CHARGING = 2; |
| 517 | BATTERY_STATUS_DISCHARGING = 3; |
| 518 | BATTERY_STATUS_NOT_CHARGING = 4; |
| 519 | BATTERY_STATUS_FULL = 5; |
| 520 | } |
| 521 | optional State charging_state = 1; |
| 522 | } |
| 523 | |
| 524 | /** |
| 525 | * Logs whether the device is plugged in, and what power source it is using. |
| 526 | * |
| 527 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 528 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 529 | */ |
| 530 | message PluggedStateChanged { |
| 531 | // TODO: Link directly to BatteryManager.java's constants (via a proto). |
| 532 | enum State { |
| 533 | // Note that NONE is not in BatteryManager.java's constants. |
| 534 | BATTERY_PLUGGED_NONE = 0; |
| 535 | // Power source is an AC charger. |
| 536 | BATTERY_PLUGGED_AC = 1; |
| 537 | // Power source is a USB port. |
| 538 | BATTERY_PLUGGED_USB = 2; |
| 539 | // Power source is wireless. |
| 540 | BATTERY_PLUGGED_WIRELESS = 4; |
| 541 | } |
| 542 | optional State plugged_state = 1; |
| 543 | } |
| 544 | |
| 545 | /** |
| 546 | * Logs the temperature of the device, in tenths of a degree Celsius. |
| 547 | * |
| 548 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 549 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 550 | */ |
| 551 | message DeviceTemperatureReported { |
| 552 | // Temperature in tenths of a degree C. |
| 553 | optional int32 temperature = 1; |
| 554 | } |
| 555 | |
| 556 | // TODO: Define this more precisely. |
| 557 | // TODO: Log the ON state somewhere. It isn't currently logged anywhere. |
| 558 | /** |
| 559 | * Logs when the device turns off or on. |
| 560 | * |
| 561 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 562 | * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 563 | */ |
| 564 | message DeviceOnStatusChanged { |
| 565 | enum State { |
| 566 | OFF = 0; |
| 567 | ON = 1; |
| 568 | } |
| 569 | optional State state = 1; |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * Logs when an app's wakeup alarm fires. |
| 574 | * |
| 575 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 576 | * frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java |
Bookatz | 8c6571b | 2017-10-24 15:04:41 -0700 | [diff] [blame] | 577 | */ |
| 578 | message WakeupAlarmOccurred { |
| 579 | // TODO: Add attribution instead of uid? |
| 580 | optional int32 uid = 1; |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * Logs kernel wakeup reasons and aborts. |
| 585 | * |
| 586 | * Logged from: |
| 587 | * frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java |
| 588 | */ |
| 589 | message KernelWakeupReported { |
| 590 | // Name of the kernel wakeup reason (or abort). |
| 591 | optional string wakeup_reason_name = 1; |
| 592 | |
| 593 | // Duration (in microseconds) for the wake-up interrupt to be serviced. |
| 594 | optional int64 duration_usec = 2; |
Bookatz | e588524 | 2017-10-24 20:10:31 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | /** |
| 598 | * Logs wifi locks held by an app. |
| 599 | * |
| 600 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 601 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | e588524 | 2017-10-24 20:10:31 -0700 | [diff] [blame] | 602 | */ |
| 603 | message WifiLockStateChanged { |
| 604 | // TODO: Add attribution instead of uid. |
| 605 | optional int32 uid = 1; |
| 606 | |
| 607 | enum State { |
| 608 | OFF = 0; |
| 609 | ON = 1; |
| 610 | } |
| 611 | optional State state = 2; |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * Logs wifi signal strength changes. |
| 616 | * |
| 617 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 618 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | e588524 | 2017-10-24 20:10:31 -0700 | [diff] [blame] | 619 | */ |
| 620 | message WifiSignalStrengthChanged { |
| 621 | // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states. |
| 622 | enum SignalStrength { |
| 623 | SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; |
| 624 | SIGNAL_STRENGTH_POOR = 1; |
| 625 | SIGNAL_STRENGTH_MODERATE = 2; |
| 626 | SIGNAL_STRENGTH_GOOD = 3; |
| 627 | SIGNAL_STRENGTH_GREAT = 4; |
| 628 | } |
| 629 | optional SignalStrength signal_strength = 1; |
| 630 | } |
| 631 | |
| 632 | /** |
| 633 | * Logs wifi scans performed by an app. |
| 634 | * |
| 635 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 636 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | e588524 | 2017-10-24 20:10:31 -0700 | [diff] [blame] | 637 | */ |
| 638 | message WifiScanStateChanged { |
| 639 | // TODO: Add attribution instead of uid. |
| 640 | optional int32 uid = 1; |
| 641 | |
| 642 | enum State { |
| 643 | OFF = 0; |
| 644 | ON = 1; |
| 645 | } |
| 646 | optional State state = 2; |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * Logs phone signal strength changes. |
| 651 | * |
| 652 | * Logged from: |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 653 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
Bookatz | e588524 | 2017-10-24 20:10:31 -0700 | [diff] [blame] | 654 | */ |
| 655 | message PhoneSignalStrengthChanged { |
| 656 | // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states. |
| 657 | enum SignalStrength { |
| 658 | SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0; |
| 659 | SIGNAL_STRENGTH_POOR = 1; |
| 660 | SIGNAL_STRENGTH_MODERATE = 2; |
| 661 | SIGNAL_STRENGTH_GOOD = 3; |
| 662 | SIGNAL_STRENGTH_GREAT = 4; |
| 663 | } |
| 664 | optional SignalStrength signal_strength = 1; |
David Chen | c28b2bb | 2017-10-24 12:52:52 -0700 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | /** |
| 668 | * Logs that a setting was updated. |
| 669 | * Logged from: |
| 670 | * frameworks/base/core/java/android/provider/Settings.java |
| 671 | * The tag and is_default allow resetting of settings to default values based on the specified |
| 672 | * tag. See Settings#putString(ContentResolver, String, String, String, boolean) for more details. |
| 673 | */ |
| 674 | message SettingChanged { |
| 675 | // The name of the setting. |
| 676 | optional string setting = 1; |
| 677 | |
| 678 | // The change being imposed on this setting. May represent a number, eg "3". |
| 679 | optional string value = 2; |
| 680 | |
| 681 | // The new value of this setting. For most settings, this is same as value. For some settings, |
| 682 | // value is +X or -X where X represents an element in a set. For example, if the previous value |
| 683 | // is A,B,C and value is -B, then new_value is A,C and prev_value is A,B,C. |
| 684 | // The +/- feature is currently only used for location_providers_allowed. |
| 685 | optional string new_value = 3; |
| 686 | |
| 687 | // The previous value of this setting. |
| 688 | optional string prev_value = 4; |
| 689 | |
| 690 | // The tag used with the is_default for resetting sets of settings. This is generally null. |
| 691 | optional string tag = 5; |
| 692 | |
| 693 | // 1 indicates that this setting with tag should be resettable. |
| 694 | optional int32 is_default = 6; |
| 695 | |
| 696 | // The user ID associated. Defined in android/os/UserHandle.java |
| 697 | optional int32 user = 7; |
| 698 | } |
Chenjie Yu | b3dda41 | 2017-10-24 13:41:59 -0700 | [diff] [blame] | 699 | |
Chenjie Yu | 3d4f604 | 2017-10-27 15:39:34 -0700 | [diff] [blame] | 700 | /* |
| 701 | * Logs activity going to foreground or background |
| 702 | * |
| 703 | * Logged from: |
| 704 | * frameworks/base/services/core/java/com/android/server/am/ActivityRecord.java |
| 705 | */ |
| 706 | message ActivityForegroundStateChanged { |
| 707 | enum Activity { |
| 708 | MOVE_TO_BACKGROUND = 0; |
| 709 | MOVE_TO_FOREGROUND = 1; |
| 710 | } |
| 711 | optional int32 uid = 1; |
| 712 | optional string pkg_name = 2; |
| 713 | optional string class_name = 3; |
| 714 | optional Activity activity = 4; |
| 715 | } |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 716 | |
| 717 | /** |
| 718 | * Pulls bytes transferred via wifi (Sum of foreground and background usage). |
| 719 | * |
| 720 | * Pulled from: |
| 721 | * StatsCompanionService (using BatteryStats to get which interfaces are wifi) |
| 722 | */ |
| 723 | message WifiBytesTransferred { |
| 724 | optional int32 uid = 1; |
| 725 | |
| 726 | optional int64 rx_bytes = 2; |
| 727 | |
| 728 | optional int64 rx_packets = 3; |
| 729 | |
| 730 | optional int64 tx_bytes = 4; |
| 731 | |
| 732 | optional int64 tx_packets = 5; |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * Pulls bytes transferred via wifi (separated by foreground and background usage). |
| 737 | * |
| 738 | * Pulled from: |
| 739 | * StatsCompanionService (using BatteryStats to get which interfaces are wifi) |
| 740 | */ |
| 741 | message WifiBytesTransferredByFgBg { |
| 742 | optional int32 uid = 1; |
| 743 | |
| 744 | // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats. |
| 745 | optional int32 is_foreground = 2; |
| 746 | |
| 747 | optional int64 rx_bytes = 3; |
| 748 | |
| 749 | optional int64 rx_packets = 4; |
| 750 | |
| 751 | optional int64 tx_bytes = 5; |
| 752 | |
| 753 | optional int64 tx_packets = 6; |
| 754 | } |
| 755 | |
| 756 | /** |
| 757 | * Pulls bytes transferred via mobile networks (Sum of foreground and background usage). |
| 758 | * |
| 759 | * Pulled from: |
| 760 | * StatsCompanionService (using BatteryStats to get which interfaces are mobile data) |
| 761 | */ |
| 762 | message MobileBytesTransferred { |
| 763 | optional int32 uid = 1; |
| 764 | |
| 765 | optional int64 rx_bytes = 2; |
| 766 | |
| 767 | optional int64 rx_packets = 3; |
| 768 | |
| 769 | optional int64 tx_bytes = 4; |
| 770 | |
| 771 | optional int64 tx_packets = 5; |
| 772 | } |
| 773 | |
| 774 | /** |
| 775 | * Pulls bytes transferred via mobile networks (separated by foreground and background usage). |
| 776 | * |
| 777 | * Pulled from: |
| 778 | * StatsCompanionService (using BatteryStats to get which interfaces are mobile data) |
| 779 | */ |
| 780 | message MobileBytesTransferredByFgBg { |
| 781 | optional int32 uid = 1; |
| 782 | |
| 783 | // 1 denotes foreground and 0 denotes background. This is called Set in NetworkStats. |
| 784 | optional int32 is_foreground = 2; |
| 785 | |
| 786 | optional int64 rx_bytes = 3; |
| 787 | |
| 788 | optional int64 rx_packets = 4; |
| 789 | |
| 790 | optional int64 tx_bytes = 5; |
| 791 | |
| 792 | optional int64 tx_packets = 6; |
| 793 | } |
| 794 | |
| 795 | /** |
| 796 | * Pulls the kernel wakelock durations. This atom is adapted from |
| 797 | * android/internal/os/KernelWakelockStats.java |
| 798 | * |
| 799 | * Pulled from: |
| 800 | * StatsCompanionService using KernelWakelockReader. |
| 801 | */ |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 802 | message KernelWakelockPulled { |
David Chen | c8a4324 | 2017-10-17 16:23:28 -0700 | [diff] [blame] | 803 | optional string name = 1; |
| 804 | |
| 805 | optional int32 count = 2; |
| 806 | |
| 807 | optional int32 version = 3; |
| 808 | |
| 809 | optional int64 time = 4; |
| 810 | } |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 811 | |
| 812 | /* |
| 813 | * Pulls PowerStatePlatformSleepState. |
| 814 | * |
| 815 | * Definition here: |
| 816 | * hardware/interfaces/power/1.0/types.hal |
| 817 | */ |
| 818 | message PowerStatePlatformSleepStatePulled { |
| 819 | optional string name = 1; |
| 820 | optional uint64 residency_in_msec_since_boot = 2; |
| 821 | optional uint64 total_transitions = 3; |
| 822 | optional bool supported_only_in_suspend = 4; |
| 823 | } |
| 824 | |
| 825 | /** |
| 826 | * Pulls PowerStateVoter. |
| 827 | * |
| 828 | * Definition here: |
| 829 | * hardware/interfaces/power/1.0/types.hal |
| 830 | */ |
| 831 | message PowerStateVoterPulled { |
| 832 | optional string power_state_platform_sleep_state_name = 1; |
| 833 | optional string power_state_voter_name = 2; |
| 834 | optional uint64 total_time_in_msec_voted_for_since_boot = 3; |
| 835 | optional uint64 total_number_of_times_voted_since_boot = 4; |
| 836 | } |
| 837 | |
| 838 | /** |
| 839 | * Pulls PowerStateSubsystemSleepState. |
| 840 | * |
| 841 | * Definition here: |
| 842 | * hardware/interfaces/power/1.1/types.hal |
| 843 | */ |
| 844 | message PowerStateSubsystemSleepStatePulled { |
| 845 | optional string power_state_subsystem_name = 1; |
| 846 | optional string power_state_subsystem_sleep_state_name = 2; |
| 847 | optional uint64 residency_in_msec_since_boot = 3; |
| 848 | optional uint64 total_transitions = 4; |
| 849 | optional uint64 last_entry_timestamp_ms = 5; |
| 850 | optional bool supported_only_in_suspend = 6; |
| 851 | } |
David Chen | 2158296 | 2017-11-01 17:32:46 -0700 | [diff] [blame] | 852 | |
| 853 | /** |
| 854 | * Logs creation or removal of an isolated uid. Isolated uid's are temporary uid's to sandbox risky |
| 855 | * behavior in its own uid. However, the metrics of these isolated uid's almost always should be |
| 856 | * attributed back to the parent (host) uid. One example is Chrome. |
| 857 | * |
| 858 | * Logged from: |
| 859 | * frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java |
| 860 | */ |
| 861 | message IsolatedUidChanged { |
| 862 | // The host UID. Generally, we should attribute metrics from the isolated uid to the host uid. |
| 863 | optional int32 parent_uid = 1; |
| 864 | |
| 865 | optional int32 isolated_uid = 2; |
| 866 | |
| 867 | // 1 denotes we're creating an isolated uid and 0 denotes removal. We expect an isolated uid to |
| 868 | // be removed before if it's used for another parent uid. |
| 869 | optional int32 is_create = 3; |
| 870 | } |
Chenjie Yu | 7f8def9 | 2017-11-03 09:33:15 -0700 | [diff] [blame] | 871 | |
| 872 | /* |
| 873 | * Pulls Cpu time per frequency. |
| 874 | * Note: this should be pulled for gauge metric only, without condition. |
| 875 | * The puller keeps internal state of last values. It should not be pulled by |
| 876 | * different metrics. |
| 877 | * The pulled data is delta of cpu time from last pull, calculated as |
| 878 | * following: |
| 879 | * if current time is larger than last value, take delta between the two. |
| 880 | * if current time is smaller than last value, there must be a cpu |
| 881 | * hotplug event, and the current time is taken as delta. |
| 882 | */ |
| 883 | message CpuTimePerFreqPulled { |
| 884 | optional uint32 cluster = 1; |
| 885 | optional uint32 freq_index = 2; |
| 886 | optional uint64 time = 3; |
| 887 | } |
Chenjie Yu | e33bc3b | 2017-11-06 17:56:44 -0800 | [diff] [blame] | 888 | |
| 889 | /* |
| 890 | * Pulls Cpu Time Per Uid. |
| 891 | * Note that isolated process uid time should be attributed to host uids. |
| 892 | */ |
| 893 | message CpuTimePerUidPulled { |
| 894 | optional uint64 uid = 1; |
| 895 | optional uint64 user_time_ms = 2; |
| 896 | optional uint64 sys_time_ms = 3; |
| 897 | } |
| 898 | |
| 899 | /** |
| 900 | * Pulls Cpu Time Per Uid per frequency. |
| 901 | * Note that isolated process uid time should be attributed to host uids. |
| 902 | * For each uid, we order the time by descending frequencies. |
| 903 | */ |
| 904 | message CpuTimePerUidFreqPulled { |
| 905 | optional uint64 uid = 1; |
| 906 | optional uint64 freq_idx = 2; |
| 907 | optional uint64 time_ms = 3; |
| 908 | } |