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