1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18option java_multiple_files = true;
19
20package android.os;
21
22import "frameworks/base/core/proto/android/app/job/enums.proto";
23import "frameworks/base/core/proto/android/os/powermanager.proto";
24import "frameworks/base/core/proto/android/telephony/enums.proto";
25import "frameworks/base/libs/incident/proto/android/privacy.proto";
26
27message BatteryStatsProto {
28    option (android.msg_privacy).dest = DEST_AUTOMATIC;
29
30    optional int32 report_version = 1;
31    optional int64 parcel_version = 2;
32    optional string start_platform_version = 3;
33    optional string end_platform_version = 4;
34    repeated UidProto uids = 5;
35    optional SystemProto system = 6;
36}
37
38message ControllerActivityProto {
39    option (android.msg_privacy).dest = DEST_AUTOMATIC;
40
41    // Time (milliseconds) spent in the idle state.
42    optional int64 idle_duration_ms = 1;
43    // Time (milliseconds) spent in the receive state.
44    optional int64 rx_duration_ms = 2;
45    // Total power (mAh) consumed by the controller in all states. The value may
46    // always be 0 if the device doesn't support power calculations.
47    optional int64 power_mah = 3;
48
49    // Represents a transmit level, where each level may draw a different amount
50    // of power. The levels themselves are controller-specific (and may possibly
51    // be device specific...yet to be confirmed).
52    message TxLevel {
53        option (android.msg_privacy).dest = DEST_AUTOMATIC;
54
55        // Transmit level. Higher levels draw more power.
56        optional int32 level = 1;
57        // Time spent in this specific transmit level state.
58        optional int64 duration_ms = 2;
59    }
60    repeated TxLevel tx = 4;
61}
62
63message SystemProto {
64    option (android.msg_privacy).dest = DEST_AUTOMATIC;
65
66    message Battery {
67        option (android.msg_privacy).dest = DEST_AUTOMATIC;
68
69        // Wall clock time when the data collection started.
70        // In case of device time manually reset by users:
71        //     start_clock_time_ms keeps the same value in the current collection
72        //     period and changes for later collection periods.
73        optional int64 start_clock_time_ms = 1;
74        // #times the device has been started since start_clock_time_millis.
75        optional int64 start_count = 2;
76        // Total realtime duration (= SINCE_UNPLUGGED battery_realtime_millis.)
77        optional int64 total_realtime_ms = 3;
78        optional int64 total_uptime_ms = 4;
79        // Realtime duration on battery.
80        optional int64 battery_realtime_ms = 5;
81        // Uptime duration (i.e., not suspend).
82        // Uptime is anytime the CPUs were on. The radio and Wifi chip
83        // can be running while the CPUs are off.
84        optional int64 battery_uptime_ms = 6;
85        // Total realtime duration measured with screen off or dozing.
86        optional int64 screen_off_realtime_ms = 7;
87        // Total uptime duration measured with screen off or dozing.
88        optional int64 screen_off_uptime_ms = 8;
89        // Total time the screen was dozing while the device was running on battery.
90        // For historical reasons, screen_doze_duration_msec is a subset of
91        // screen_off_realtime_msec.
92        optional int64 screen_doze_duration_ms = 9;
93        // The estimated real battery capacity, which may be less than the declared
94        // battery capacity (for example, because of battery aging). This field is
95        // less reliable than min(max)_learned_battery_capacity_uah, use those two
96        // fields whenever possible.
97        optional int64 estimated_battery_capacity_mah = 10;
98        // The minimum learned battery capacity in uAh.
99        optional int64 min_learned_battery_capacity_uah = 11;
100        // The maximum learned battery capacity in uAh.
101        optional int64 max_learned_battery_capacity_uah = 12;
102    };
103    optional Battery battery = 1;
104
105    message BatteryDischarge {
106        option (android.msg_privacy).dest = DEST_AUTOMATIC;
107
108        // Discharged battery percentage points since the stats were last reset
109        // after charging (lower bound approximation).
110        optional int32 lower_bound_since_charge = 1;
111        // Upper bound approximation.
112        optional int32 upper_bound_since_charge = 2;
113        // Discharged points while screen is on.
114        optional int32 screen_on_since_charge = 3;
115        // Discharged points while screen is off.
116        optional int32 screen_off_since_charge = 4;
117        // Discharged points while screen was dozing. For historical reasons,
118        // screen_doze_since_charge is a subset of screen_off_since_charge.
119        optional int32 screen_doze_since_charge = 5;
120        // Total amount of battery discharged in mAh. This will only be non-zero for
121        // devices that report battery discharge via a coulomb counter.
122        optional int64 total_mah = 6;
123        // Total amount of battery discharged while the screen was off in mAh.
124        // This will only be non-zero for devices that report battery discharge
125        // via a coulomb counter.
126        optional int64 total_mah_screen_off = 7;
127        // Total amount of battery discharged while the screen was dozing in mAh.
128        // This will only be non-zero for devices that report battery discharge
129        // via a coulomb counter. For historical reasons, total_mah_screen_doze is
130        // a subset of total_mah_screen_off.
131        optional int64 total_mah_screen_doze = 8;
132        // Total amount of battery discharged in mAh while the device was in light doze mode.
133        // This will only be non-zero for devices that report battery discharge
134        // via a coulomb counter.
135        optional int64 total_mah_light_doze = 9;
136        // Total amount of battery discharged in mAh while the device was in deep doze mode.
137        // This will only be non-zero for devices that report battery discharge
138        // via a coulomb counter.
139        optional int64 total_mah_deep_doze = 10;
140    };
141    optional BatteryDischarge battery_discharge = 2;
142
143    oneof time_remaining {
144        // Approximation for how much time remains until the battery is fully
145        // charged. The device will print -1 if there wasn't enough data to
146        // calculate an estimate, or if the battery is currently discharging.
147        int64 charge_time_remaining_ms = 3;
148        // Approximation for how much time remains until the battery is fully
149        // discharged. The device will print -1 if there wasn't enough data to
150        // calculate an estimate, or if the battery is currently charging.
151        int64 discharge_time_remaining_ms = 4;
152    }
153
154    // BatteryLevelStep tracks data for which conditions were continuously held for
155    // the entire duration. Field for which the conditions were not consistent
156    // for the entire duration should be marked MIXED.
157    message BatteryLevelStep {
158        option (android.msg_privacy).dest = DEST_AUTOMATIC;
159
160        // How long the battery was at the current level.
161        optional int64 duration_ms = 1;
162        // Battery level
163        optional int32 level = 2;
164
165        // State of the display. A special enum is used rather than
166        // DisplayProto.State because a MIXED value needs to be in the enum, and
167        // batterystats doesn't care about all of the different display states.
168        enum DisplayState {
169            DS_MIXED = 0;
170            DS_ON = 1;
171            DS_OFF = 2;
172            DS_DOZE = 3;
173            DS_DOZE_SUSPEND = 4;
174            // Any display state error that comes through should be sent to hackbod@.
175            DS_ERROR = 5;
176        }
177        // The state of the display for the entire battery level step. MIXED is used
178        // if there were multiple states for this step.
179        optional DisplayState display_state = 3;
180
181        // Indicates status in power save mode.
182        enum PowerSaveMode {
183            PSM_MIXED = 0;
184            PSM_ON = 1;
185            PSM_OFF = 2;
186        }
187        // Battery Saver mode for the entire battery level step. MIXED is used
188        // if there were multiple states for this step.
189        optional PowerSaveMode power_save_mode = 4;
190
191        // Indicates status in idle mode.
192        enum IdleMode {
193            IM_MIXED = 0;
194            IM_ON = 2;
195            IM_OFF = 3;
196        }
197        // Doze mode for the entire battery level step. MIXED is used if there were
198        // multiple states for this step.
199        optional IdleMode idle_mode = 5;
200    };
201    // Battery level steps when the device was charging.
202    repeated BatteryLevelStep charge_step = 5;
203    // Battery level steps when the device was discharging.
204    repeated BatteryLevelStep discharge_step = 6;
205
206    // All CPU frequencies of the device.
207    repeated int64 cpu_frequency = 7;
208
209    message DataConnection {
210        option (android.msg_privacy).dest = DEST_AUTOMATIC;
211        oneof type {
212            android.telephony.NetworkTypeEnum name = 1;
213            // If is_none is not set, then the name is a valid network type.
214            bool is_none = 2;
215        }
216        optional TimerProto total = 3;
217    };
218    repeated DataConnection data_connection = 8;
219
220    optional ControllerActivityProto global_bluetooth_controller = 9;
221    optional ControllerActivityProto global_modem_controller = 10;
222    optional ControllerActivityProto global_wifi_controller = 11;
223
224    message GlobalNetwork {
225        option (android.msg_privacy).dest = DEST_AUTOMATIC;
226
227        // Total Bytes received on mobile connections.
228        optional int64 mobile_bytes_rx = 1;
229        // Total Bytes transmitted on mobile connections.
230        optional int64 mobile_bytes_tx = 2;
231        // Total Bytes received on wifi connections.
232        optional int64 wifi_bytes_rx = 3;
233        // Total Bytes transmitted on wifi connections.
234        optional int64 wifi_bytes_tx = 4;
235        // Total Packets received on mobile connections.
236        optional int64 mobile_packets_rx = 5;
237        // Total Packets transmitted on mobile connections.
238        optional int64 mobile_packets_tx = 6;
239        // Total Packets received on wifi connections.
240        optional int64 wifi_packets_rx = 7;
241        // Total Packets transmitted on wifi connections.
242        optional int64 wifi_packets_tx = 8;
243        // Total Bytes received on bluetooth connections.
244        optional int64 bt_bytes_rx = 9;
245        // Total Bytes transmitted on bluetooth connections.
246        optional int64 bt_bytes_tx = 10;
247    };
248    optional GlobalNetwork global_network = 12;
249
250    message GlobalWifi {
251        option (android.msg_privacy).dest = DEST_AUTOMATIC;
252
253        // The amount of time that wifi has been on while the device was running on
254        // battery.
255        optional int64 on_duration_ms = 1;
256        // The amount of time that wifi has been on and the driver has been in the
257        // running state while the device was running on battery.
258        optional int64 running_duration_ms = 2;
259    }
260    optional GlobalWifi global_wifi = 13;
261
262    // Kernel wakelock metrics are only recorded when the device is unplugged
263    // *and* the screen is off.
264    message KernelWakelock {
265        option (android.msg_privacy).dest = DEST_AUTOMATIC;
266
267        optional string name = 1;
268        // Kernel wakelock stats aren't apportioned across all kernel wakelocks (as
269        // app wakelocks stats are).
270        optional TimerProto total = 2;
271        // The kernel doesn't have the data to enable printing out current and max
272        // durations.
273    };
274    repeated KernelWakelock kernel_wakelock = 14;
275
276    message Misc {
277        option (android.msg_privacy).dest = DEST_AUTOMATIC;
278
279        optional int64 screen_on_duration_ms = 1;
280        optional int64 phone_on_duration_ms = 2;
281        optional int64 full_wakelock_total_duration_ms = 3;
282        // The total elapsed time that a partial wakelock was held. This duration
283        // does not double count wakelocks held at the same time.
284        optional int64 partial_wakelock_total_duration_ms = 4;
285        optional int64 mobile_radio_active_duration_ms = 5;
286        // The time that is the difference between the mobile radio time we saw
287        // based on the elapsed timestamp when going down vs. the given time stamp
288        // from the radio.
289        optional int64 mobile_radio_active_adjusted_time_ms = 6;
290        optional int32 mobile_radio_active_count = 7;
291        // The amount of time that the mobile network has been active (in a high
292        // power state) but not being able to blame on an app.
293        optional int32 mobile_radio_active_unknown_duration_ms = 8;
294        // Total amount of time the device was in the interactive state.
295        optional int64 interactive_duration_ms = 9;
296        optional int64 battery_saver_mode_enabled_duration_ms = 10;
297        optional int32 num_connectivity_changes = 11;
298        // Amount of time the device was in deep Doze.
299        optional int64 deep_doze_enabled_duration_ms = 12;
300        // How many times the device went into deep Doze mode.
301        optional int32 deep_doze_count = 13;
302        // Amount of time the device was idling in deep Doze. Idling time
303        // encompasses "doze" time and the maintenance windows that allow apps to
304        // operate.
305        optional int64 deep_doze_idling_duration_ms = 14;
306        // How many times the device idling for deep Doze mode.
307        optional int32 deep_doze_idling_count = 15;
308        optional int64 longest_deep_doze_duration_ms = 16;
309        // Amount of time the device was in Doze Light.
310        optional int64 light_doze_enabled_duration_ms = 17;
311        // How many times the device went into Doze Light mode.
312        optional int32 light_doze_count = 18;
313        // Amount of time the device was idling in Doze Light. Idling time
314        // encompasses "doze" time and the maintenance windows that allow apps to
315        // operate.
316        optional int64 light_doze_idling_duration_ms = 19;
317        // How many times the device idling for Doze Light mode.
318        optional int32 light_doze_idling_count = 20;
319        optional int64 longest_light_doze_duration_ms = 21;
320    }
321    optional Misc misc = 15;
322
323    message PhoneSignalStrength {
324        option (android.msg_privacy).dest = DEST_AUTOMATIC;
325
326        optional android.telephony.SignalStrengthEnum name = 1;
327        optional TimerProto total = 2;
328    };
329    repeated PhoneSignalStrength phone_signal_strength = 16;
330
331    message PowerUseItem {
332        option (android.msg_privacy).dest = DEST_AUTOMATIC;
333
334        enum Sipper {
335            UNKNOWN_SIPPER = 0;
336            IDLE = 1;
337            CELL = 2;
338            PHONE = 3;
339            WIFI = 4;
340            BLUETOOTH = 5;
341            FLASHLIGHT = 6;
342            SCREEN = 7;
343            USER = 8;
344            UNACCOUNTED = 9;
345            OVERCOUNTED = 10;
346            CAMERA = 11;
347            MEMORY = 12;
348            AMBIENT_DISPLAY = 13;
349        };
350        optional Sipper name = 1;
351        // UID, only valid for the USER sipper.
352        optional int32 uid = 2;
353        // Estimated power use in mAh.
354        optional double computed_power_mah = 3;
355        // Starting in Oreo, Battery Settings has two modes to display the battery
356        // info. The first is "app usage list". In this mode, items with should_hide
357        // enabled are hidden.
358        optional bool should_hide = 4;
359        // Smeared power from screen usage. Screen usage power is split and smeared
360        // among apps, based on activity time.
361        optional double screen_power_mah = 5;
362        // Smeared power using proportional method. Power usage from hidden sippers
363        // is smeared to all apps proportionally (except for screen usage).
364        optional double proportional_smear_mah = 6;
365    };
366    repeated PowerUseItem power_use_item = 17;
367
368    message PowerUseSummary {
369        option (android.msg_privacy).dest = DEST_AUTOMATIC;
370
371        optional double battery_capacity_mah = 1;
372        optional double computed_power_mah = 2;
373        // Lower bound of actual power drained.
374        optional double min_drained_power_mah = 3;
375        // Upper bound of actual power drained.
376        optional double max_drained_power_mah = 4;
377    };
378    optional PowerUseSummary power_use_summary = 18;
379
380    message ResourcePowerManager {
381        option (android.msg_privacy).dest = DEST_AUTOMATIC;
382
383        // Either StateName or StateName.VoterName.
384        optional string name = 1;
385        optional TimerProto total = 2;
386        optional TimerProto screen_off = 3;
387    }
388    repeated ResourcePowerManager resource_power_manager = 19;
389
390    message ScreenBrightness {
391        option (android.msg_privacy).dest = DEST_AUTOMATIC;
392
393        enum Name {
394            DARK = 0; // Not screen-off.
395            DIM = 1;
396            MEDIUM = 2;
397            LIGHT = 3;
398            BRIGHT = 4;
399        };
400        optional Name name = 1;
401        optional TimerProto total = 2;
402    };
403    repeated ScreenBrightness screen_brightness = 20;
404
405    // Duration and number of times trying to acquire a signal
406    optional TimerProto signal_scanning = 21;
407
408    message WakeupReason {
409        option (android.msg_privacy).dest = DEST_AUTOMATIC;
410
411        optional string name = 1;
412        optional TimerProto total = 2;
413    };
414    repeated WakeupReason wakeup_reason = 22;
415
416    message WifiMulticastWakelockTotal {
417        option (android.msg_privacy).dest = DEST_AUTOMATIC;
418
419        optional int64 duration_ms = 1;
420        optional int32 count = 2;
421    }
422    optional WifiMulticastWakelockTotal wifi_multicast_wakelock_total = 23;
423
424    message WifiSignalStrength {
425        option (android.msg_privacy).dest = DEST_AUTOMATIC;
426
427        enum Name {
428            NONE = 0;
429            POOR = 1;
430            MODERATE = 2;
431            GOOD = 3;
432            GREAT = 4;
433        };
434        optional Name name = 1;
435        optional TimerProto total = 2;
436    };
437    repeated WifiSignalStrength wifi_signal_strength = 24;
438
439    message WifiState {
440        option (android.msg_privacy).dest = DEST_AUTOMATIC;
441
442        enum Name {
443            OFF = 0;
444            OFF_SCANNING = 1;
445            ON_NO_NETWORKS = 2;
446            ON_DISCONNECTED = 3;
447            ON_CONNECTED_STA = 4;
448            ON_CONNECTED_P2P = 5;
449            ON_CONNECTED_STA_P2P = 6;
450            SOFT_AP = 7;
451        };
452        optional Name name = 1;
453        optional TimerProto total = 2;
454    };
455    repeated WifiState wifi_state = 25;
456
457    message WifiSupplicantState {
458        option (android.msg_privacy).dest = DEST_AUTOMATIC;
459
460        enum Name {
461            INVALID = 0;
462            DISCONNECTED = 1;
463            INTERFACE_DISABLED = 2;
464            INACTIVE = 3;
465            SCANNING = 4;
466            AUTHENTICATING = 5;
467            ASSOCIATING = 6;
468            ASSOCIATED = 7;
469            FOUR_WAY_HANDSHAKE = 8;
470            GROUP_HANDSHAKE = 9;
471            COMPLETED = 10;
472            DORMANT = 11;
473            UNINITIALIZED = 12;
474        };
475        optional Name name = 1;
476        optional TimerProto total = 2;
477    };
478    repeated WifiSupplicantState wifi_supplicant_state = 26;
479}
480
481message TimerProto {
482    option (android.msg_privacy).dest = DEST_AUTOMATIC;
483
484    // This may be an apportioned time.
485    optional int64 duration_ms = 1;
486    optional int64 count = 2;
487    // The max duration if it is being tracked. Not all Timer subclasses
488    // track the max duration.
489    optional int64 max_duration_ms = 3;
490    // The current time the timer has been active, if it is being tracked.
491    // Not all Timer subclasses track the current duration.
492    optional int64 current_duration_ms = 4;
493    // The total cumulative duration (i.e. sum of past durations) that this timer
494    // has been on since reset. This may differ from duration_ms since, depending
495    // on the Timer, getTotalTimeLocked may represent the total 'blamed' or
496    // 'pooled' time, rather than the actual time. By contrast, total_duration_ms
497    // always gives the actual total time. Not all Timer subclasses track the
498    // total duration.
499    optional int64 total_duration_ms = 5;
500}
501
502message UidProto {
503    option (android.msg_privacy).dest = DEST_AUTOMATIC;
504
505    // Combination of app ID and user ID.
506    optional int32 uid = 1;
507
508    // The statistics associated with a particular package.
509    message Package {
510        option (android.msg_privacy).dest = DEST_AUTOMATIC;
511
512        optional string name = 1;
513
514        message Service {
515            option (android.msg_privacy).dest = DEST_AUTOMATIC;
516
517            optional string name = 1;
518            // Time spent started.
519            optional int64 start_duration_ms = 2;
520            optional int32 start_count = 3;
521            optional int32 launch_count = 4;
522        }
523        repeated Service services = 2;
524    }
525    repeated Package packages = 2;
526
527    optional ControllerActivityProto bluetooth_controller = 3;
528    optional ControllerActivityProto modem_controller = 4;
529    optional ControllerActivityProto wifi_controller = 5;
530
531    // Bluetooth misc data.
532    message BluetoothMisc {
533        option (android.msg_privacy).dest = DEST_AUTOMATIC;
534
535        // Duration spent BLE scanning blamed on this App (i.e. apportioned to this
536        // app amongst all apps doing BLE scanning; see explanation of 'apportioned'
537        // in App's comment).
538        optional TimerProto apportioned_ble_scan = 1;
539        // Background times aren't apportioned.
540        optional TimerProto background_ble_scan = 2;
541        // Running unoptimized BLE scanning, as defined by Bluetooth's
542        // AppScanStats.recordScanStart. As of May 2017, these are unfiltered,
543        // non-opportunistic, non-first-match scans. Durations are not
544        // pooled/apportioned.
545        optional TimerProto unoptimized_ble_scan = 3;
546        // Running unoptimized BLE scanning when app is in background. Durations are
547        // not pooled/apportioned.
548        optional TimerProto background_unoptimized_ble_scan = 4;
549        // Count of results returned by BLE scanning.
550        optional int32 ble_scan_result_count = 5;
551        // Count of results returned by BLE scans when app is in background.
552        // (Included in ble_scan_result_count.)
553        optional int32 background_ble_scan_result_count = 6;
554    }
555    optional BluetoothMisc bluetooth_misc = 6;
556
557    message Cpu {
558        option (android.msg_privacy).dest = DEST_AUTOMATIC;
559
560        // Total CPU time with processes executing in userspace. Summed up across
561        // multiple cores.
562        optional int64 user_duration_ms = 1;
563        // Total CPU time with processes executing kernel syscalls. Summed up across
564        // multiple cores.
565        optional int64 system_duration_ms = 2;
566
567        // CPU time broken down by CPU frequency (go/cpu-battery-metrics).
568        //
569        // These are real CPU time measurement from the kernel, so their sum can
570        // be different from the sum of user_duration_millis and
571        // system_duration_millis, which are just approximations. Data is not
572        // tracked when device is charging.
573        message ByFrequency {
574            option (android.msg_privacy).dest = DEST_AUTOMATIC;
575
576            // Index of the frequency in system.cpu_frequency. It starts from 1, to
577            // make it easier to analyze.
578            optional int32 frequency_index = 1;
579            // CPU time in milliseconds.
580            optional int64 total_duration_ms = 2;
581            // Screen-off CPU time in milliseconds.
582            optional int64 screen_off_duration_ms = 3;
583        }
584        // CPU times accumulated across all process states.
585        repeated ByFrequency by_frequency = 3;
586
587        enum ProcessState {
588            TOP = 0;
589            FOREGROUND_SERVICE = 1;
590            FOREGROUND = 2;
591            BACKGROUND = 3;
592            TOP_SLEEPING = 4;
593            HEAVY_WEIGHT = 5;
594            CACHED = 6;
595        }
596        // CPU times at different process states.
597        message ByProcessState {
598            option (android.msg_privacy).dest = DEST_AUTOMATIC;
599
600            optional ProcessState process_state = 1;
601            repeated ByFrequency by_frequency = 2;
602        }
603        repeated ByProcessState by_process_state = 4;
604    }
605    optional Cpu cpu = 7;
606
607    // Duration is pooled/apportioned.
608    optional TimerProto audio = 8;
609    // Duration is pooled/apportioned.
610    optional TimerProto camera = 9;
611    // Duration is pooled/apportioned.
612    optional TimerProto flashlight = 10;
613    // Duration is not pooled/apportioned.
614    optional TimerProto foreground_activity = 11;
615    // Duration is not pooled/apportioned.
616    optional TimerProto foreground_service = 12;
617    // Duration is not pooled/apportioned.
618    optional TimerProto vibrator = 13;
619    // Duration is pooled/apportioned.
620    optional TimerProto video = 14;
621
622    message Job {
623        option (android.msg_privacy).dest = DEST_AUTOMATIC;
624
625        optional string name = 1;
626        // Job times aren't apportioned.
627        optional TimerProto total = 2;
628        optional TimerProto background = 3;
629    }
630    repeated Job jobs = 15;
631
632    message JobCompletion {
633        option (android.msg_privacy).dest = DEST_AUTOMATIC;
634
635        // Job name.
636        optional string name = 1;
637
638        message ReasonCount {
639            option (android.msg_privacy).dest = DEST_AUTOMATIC;
640
641            optional android.app.job.StopReasonEnum name = 1;
642            optional int32 count = 2;
643        }
644        repeated ReasonCount reason_count = 2;
645    };
646    repeated JobCompletion job_completion = 16;
647
648    message Network {
649        option (android.msg_privacy).dest = DEST_AUTOMATIC;
650
651        // Mobile data traffic (total, background + foreground).
652        optional int64 mobile_bytes_rx = 1;
653        optional int64 mobile_bytes_tx = 2;
654        // Wifi data traffic (total, background + foreground).
655        optional int64 wifi_bytes_rx = 3;
656        optional int64 wifi_bytes_tx = 4;
657        // Bluetooth data traffic (total, background + foreground).
658        optional int64 bt_bytes_rx = 5;
659        optional int64 bt_bytes_tx = 6;
660        // In packets (total, background + foreground).
661        optional int64 mobile_packets_rx = 7;
662        optional int64 mobile_packets_tx = 8;
663        optional int64 wifi_packets_rx = 9;
664        optional int64 wifi_packets_tx = 10;
665        // Radio active duration.
666        optional int64 mobile_active_duration_ms = 11;
667        optional int32 mobile_active_count = 12;
668        // Number of times the app woke up the mobile radio.
669        optional int32 mobile_wakeup_count = 13;
670        // Number of times the app woke up the wifi radio.
671        optional int32 wifi_wakeup_count = 14;
672        // Mobile data traffic in the background only, included in total above.
673        optional int64 mobile_bytes_bg_rx = 15;
674        optional int64 mobile_bytes_bg_tx = 16;
675        // Wifi data traffic in the background only, included in total above.
676        optional int64 wifi_bytes_bg_rx = 17;
677        optional int64 wifi_bytes_bg_tx = 18;
678        // In packets (background only, included in total packets above).
679        optional int64 mobile_packets_bg_rx = 19;
680        optional int64 mobile_packets_bg_tx = 20;
681        optional int64 wifi_packets_bg_rx = 21;
682        optional int64 wifi_packets_bg_tx = 22;
683    };
684    optional Network network = 17;
685
686    // TODO: combine System and App messages?
687    message PowerUseItem {
688        option (android.msg_privacy).dest = DEST_AUTOMATIC;
689
690        // Estimated power use in mAh.
691        optional double computed_power_mah = 1;
692        // Starting in Oreo, Battery Settings has two modes to display the battery
693        // info. The first is "app usage list". In this mode, items with should_hide
694        // enabled are hidden.
695        optional bool should_hide = 2;
696        // Smeared power from screen usage. Screen usage power is split and smeared
697        // among apps, based on activity time.
698        optional double screen_power_mah = 3;
699        // Smeared power using proportional method. Power usage from hidden sippers
700        // is smeared to all apps proportionally (except for screen usage).
701        optional double proportional_smear_mah = 4;
702    };
703    optional PowerUseItem power_use_item = 18;
704
705    // Durations are not pooled/apportioned.
706    message Process {
707        option (android.msg_privacy).dest = DEST_AUTOMATIC;
708
709        optional string name = 1;
710        // Time spent executing in user code.
711        optional int64 user_duration_ms = 2;
712        // Time spent executing in kernel code.
713        optional int64 system_duration_ms = 3;
714        // Time the process was running in the foreground.
715        optional int64 foreground_duration_ms = 4;
716        // Number of times the process has been started.
717        optional int32 start_count = 5;
718        // Number of times the process has had an ANR.
719        optional int32 anr_count = 6;
720        // Number of times the process has crashed.
721        optional int32 crash_count = 7;
722    };
723    repeated Process process = 19;
724
725    message StateTime {
726        option (android.msg_privacy).dest = DEST_AUTOMATIC;
727
728        // All of these (non-deprecated) states are mutually exclusive and can be
729        // added together to find the total time a uid has had any processes running
730        // at all.
731
732        // In approximate order or priority (top being what the framework considers
733        // most important and is thus least likely to kill when resources are
734        // needed:
735        // top > foreground service > foreground > background > top sleeping > heavy weight > cache
736        enum State {
737            // Time this uid has any processes in the top state.
738            PROCESS_STATE_TOP = 0;
739            // Time this uid has any process with a started foreground service, but
740            // none in the "top" state.
741            PROCESS_STATE_FOREGROUND_SERVICE = 1;
742            // Time this uid has any process in an active foreground state, but none in the
743            // "foreground service" or better state. Persistent and other foreground states go here.
744            PROCESS_STATE_FOREGROUND = 2;
745            // Time this uid has any process in an active background state, but none
746            // in the "foreground" or better state.
747            PROCESS_STATE_BACKGROUND = 3;
748            // Time this uid has any process that is top while the device is sleeping,
749            // but not active for any other reason. We consider is a kind of cached
750            // process for execution restrictions. Sleeping is mostly screen off, but
751            // also includes the time when the screen is on but the device has not yet
752            // been unlocked.
753            PROCESS_STATE_TOP_SLEEPING = 4;
754            // Time this uid has any process that is in the background but it has an
755            // activity marked as "can't save state". This is essentially a cached
756            // process, though the system will try much harder than normal to avoid
757            // killing it.
758            PROCESS_STATE_HEAVY_WEIGHT = 5;
759            // Time this uid has any processes that are sitting around cached, not in
760            // one of the other active states.
761            PROCESS_STATE_CACHED = 6;
762        }
763        optional State state = 1;
764        optional int64 duration_ms = 2;
765    }
766    repeated StateTime states = 20;
767
768    message Sensor {
769        option (android.msg_privacy).dest = DEST_AUTOMATIC;
770
771        optional int32 id = 1;
772        optional TimerProto apportioned = 2;
773        // Background times aren't apportioned.
774        optional TimerProto background = 3;
775    }
776    repeated Sensor sensors = 21;
777
778    message Sync {
779        option (android.msg_privacy).dest = DEST_AUTOMATIC;
780
781        optional string name = 1;
782        // Sync times aren't apportioned.
783        optional TimerProto total = 2;
784        optional TimerProto background = 3;
785    }
786    repeated Sync syncs = 22;
787
788    message UserActivity {
789        option (android.msg_privacy).dest = DEST_AUTOMATIC;
790
791        optional android.os.PowerManagerProto.UserActivityEvent name = 1;
792        optional int32 count = 2;
793    };
794    repeated UserActivity user_activity = 23;
795
796    // Aggregated wakelock data for an app overall, across all of its wakelocks.
797    // The Wakelock message holds data about each *individual* wakelock, but it
798    // cannot be used to ascertain the aggregated time the app spent holding
799    // wakelocks, since merely summing Wakelock data will either underestimate (in
800    // the case of wakelock.partial.duration_ms) or overestimate (in the case of
801    // wakelock.partial.total_duration_ms) the total time, due to overlapping
802    // wakelocks. AggregatedWakelock, on the other hand, holds overall per-app
803    // wakelock data.
804    message AggregatedWakelock {
805        option (android.msg_privacy).dest = DEST_AUTOMATIC;
806
807        // The total duration that the app spent holding partial wakelocks.
808        // It includes both foreground + background use.
809        optional int64 partial_duration_ms = 1;
810        // The total duration that the app spent holding partial wakelocks while the
811        // app was in the background. Subtracting from partial_duration_ms will
812        // yield foreground usage.
813        optional int64 background_partial_duration_ms = 2;
814    };
815    optional AggregatedWakelock aggregated_wakelock = 24;
816
817    message Wakelock {
818        option (android.msg_privacy).dest = DEST_AUTOMATIC;
819
820        optional string name = 1;
821
822        // Full wakelocks keep the screen on. Based on
823        // PowerManager.SCREEN_BRIGHT_WAKE_LOCK (deprecated in API 13) and
824        // PowerManager.SCREEN_DIM_WAKE_LOCK (deprecated in API 17). Current, max,
825        // and total durations are not tracked for full wakelocks.
826        optional TimerProto full = 2;
827
828        // Partial wakelocks ensure the CPU is running while allowing the screen
829        // to turn off. Based on PowerManager.PARTIAL_WAKE_LOCK.
830        // Partial wakelock metrics are only recorded when the device is unplugged
831        // *and* the screen is off. Current, max, and total durations are tracked
832        // for partial wakelocks.
833        optional TimerProto partial = 3;
834
835        // These fields are for tracking partial wakelocks (see above), but only
836        // the time the wakelock was held while the app was in a background state.
837        // Since all background tracking is 'actual', not 'apportioned',
838        // background_partial.duration_ms is identical to
839        // background_partial.total_duration_ms.
840        optional TimerProto background_partial = 4;
841
842        // Window wakelocks keep the screen on. Current, max, and total durations
843        // are not tracked for window wakelocks.
844        optional TimerProto window = 5;
845    };
846    repeated Wakelock wakelocks = 25;
847
848    message WakeupAlarm {
849        option (android.msg_privacy).dest = DEST_AUTOMATIC;
850
851        // Wakeup alarm name.
852        optional string name = 1;
853        // Only includes counts when screen-off (& on battery).
854        optional int32 count = 2;
855    }
856    repeated WakeupAlarm wakeup_alarm = 26;
857
858    message Wifi {
859        option (android.msg_privacy).dest = DEST_AUTOMATIC;
860
861        // Duration holding Wifi-lock. This time is apportioned.
862        optional int64 full_wifi_lock_duration_ms = 1;
863        // Duration running Wifi. This time is apportioned.
864        optional int64 running_duration_ms = 2;
865        // Duration performing Wifi-scan blamed on this App (i.e. apportioned to
866        // this app amongst all apps doing Wifi-scanning; see explanation of
867        // 'apportioned' in App's comment).
868        optional TimerProto apportioned_scan = 3;
869        // Scans performed when app is in background. (Included in
870        // apportioned_scan). This value is not apportioned. Subtracting
871        // background_scan.total_duration_ms from apportioned_scan.total_duration_ms
872        // will yield foreground usage.
873        optional TimerProto background_scan = 4;
874    };
875    optional Wifi wifi = 27;
876
877    // WiFi Multicast Wakelock
878    // This timer tracks the duration and count for the app to request the
879    // wakelock for wifi multicast traffic.
880    // This wakelock disables the filtering of multicast packets to reach the host
881    // processor, and results in a power penalty.
882    // It is useful to monitor the applications resulting in that
883    optional TimerProto wifi_multicast_wakelock = 28;
884}
885