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