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
17syntax = "proto2";
18package com.android.server.power;
19
20option java_multiple_files = true;
21
22import "frameworks/base/core/proto/android/app/enums.proto";
23import "frameworks/base/core/proto/android/content/intent.proto";
24import "frameworks/base/core/proto/android/os/enums.proto";
25import "frameworks/base/core/proto/android/os/looper.proto";
26import "frameworks/base/core/proto/android/os/powermanager.proto";
27import "frameworks/base/core/proto/android/os/worksource.proto";
28import "frameworks/base/core/proto/android/providers/settings.proto";
29import "frameworks/base/core/proto/android/server/wirelesschargerdetector.proto";
30import "frameworks/base/core/proto/android/view/enums.proto";
31import "frameworks/base/core/proto/android/privacy.proto";
32
33message PowerManagerServiceDumpProto {
34    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
35
36    // A com.android.server.power.PowerManagerService.Constants object.
37    message ConstantsProto {
38        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
39
40        optional bool is_no_cached_wake_locks = 1;
41    }
42    message ActiveWakeLocksProto {
43        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
44
45        optional bool is_cpu = 1;
46        optional bool is_screen_bright = 2;
47        optional bool is_screen_dim = 3;
48        optional bool is_button_bright = 4;
49        optional bool is_proximity_screen_off = 5;
50        // only set if already awake
51        optional bool is_stay_awake = 6;
52        optional bool is_doze = 7;
53        optional bool is_draw = 8;
54    }
55    message UserActivityProto {
56        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
57
58        optional bool is_screen_bright = 1;
59        optional bool is_screen_dim = 2;
60        optional bool is_screen_dream = 3;
61    }
62    // A com.android.server.power.PowerManagerService.UidState object.
63    message UidStateProto {
64        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
65
66        optional int32 uid = 1;
67        optional string uid_string = 2;
68        optional bool is_active = 3;
69        optional int32 num_wake_locks = 4;
70        optional .android.app.ProcessStateEnum process_state = 5;
71    }
72
73    optional ConstantsProto constants = 1;
74    // A bitfield that indicates what parts of the power state have
75    // changed and need to be recalculated.
76    optional int32 dirty = 2;
77    // Indicates whether the device is awake or asleep or somewhere in between.
78    optional .android.os.PowerManagerInternalProto.Wakefulness wakefulness = 3;
79    optional bool is_wakefulness_changing = 4;
80    // True if the device is plugged into a power source.
81    optional bool is_powered = 5;
82    // The current plug type
83    optional .android.os.BatteryPluggedStateEnum plug_type = 6;
84    // The current battery level percentage.
85    optional int32 battery_level = 7;
86    // The battery level percentage at the time the dream started.
87    optional int32 battery_level_when_dream_started = 8;
88    // The current dock state.
89    optional .android.content.IntentProto.DockState dock_state = 9;
90    // True if the device should stay on.
91    optional bool is_stay_on = 10;
92    // True if the proximity sensor reads a positive result.
93    optional bool is_proximity_positive = 11;
94    // True if boot completed occurred.  We keep the screen on until this happens.
95    optional bool is_boot_completed = 12;
96    // True if systemReady() has been called.
97    optional bool is_system_ready = 13;
98    // True if auto-suspend mode is enabled.
99    optional bool is_hal_auto_suspend_mode_enabled = 14;
100    // True if interactive mode is enabled.
101    optional bool is_hal_auto_interactive_mode_enabled = 15;
102    // Summarizes the state of all active wakelocks.
103    optional ActiveWakeLocksProto active_wake_locks = 16;
104    // Have we scheduled a message to check for long wake locks?  This is when
105    // we will check. (In milliseconds timestamp)
106    optional int64 notify_long_scheduled_ms = 17;
107    // Last time we checked for long wake locks. (In milliseconds timestamp)
108    optional int64 notify_long_dispatched_ms = 18;
109    // The time we decided to do next long check. (In milliseconds timestamp)
110    optional int64 notify_long_next_check_ms = 19;
111    // Summarizes the effect of the user activity timer.
112    optional UserActivityProto user_activity = 20;
113    // If true, instructs the display controller to wait for the proximity
114    // sensor to go negative before turning the screen on.
115    optional bool is_request_wait_for_negative_proximity = 21;
116    // True if MSG_SANDMAN has been scheduled.
117    optional bool is_sandman_scheduled = 22;
118    // True if the sandman has just been summoned for the first time since entering
119    // the dreaming or dozing state.  Indicates whether a new dream should begin.
120    optional bool is_sandman_summoned = 23;
121    // True if the battery level is currently considered low.
122    optional bool is_battery_level_low = 24;
123    // True if we are currently in light device idle mode.
124    optional bool is_light_device_idle_mode = 25;
125    // True if we are currently in device idle mode.
126    optional bool is_device_idle_mode = 26;
127    // Set of app ids that we will always respect the wake locks for.
128    repeated int32 device_idle_whitelist = 27;
129    // Set of app ids that are temporarily allowed to acquire wakelocks due to
130    // high-pri message
131    repeated int32 device_idle_temp_whitelist = 28;
132    // Timestamp of the last time the device was awoken.
133    optional int64 last_wake_time_ms = 29;
134    // Timestamp of the last time the device was put to sleep.
135    optional int64 last_sleep_time_ms = 30;
136    // Timestamp of the last call to user activity.
137    optional int64 last_user_activity_time_ms = 31;
138    optional int64 last_user_activity_time_no_change_lights_ms = 32;
139    // Timestamp of last interactive power hint.
140    optional int64 last_interactive_power_hint_time_ms = 33;
141    // Timestamp of the last screen brightness boost.
142    optional int64 last_screen_brightness_boost_time_ms = 34;
143    // True if screen brightness boost is in progress.
144    optional bool is_screen_brightness_boost_in_progress = 35;
145    // True if the display power state has been fully applied, which means the
146    // display is actually on or actually off or whatever was requested.
147    optional bool is_display_ready = 36;
148    // True if the wake lock suspend blocker has been acquired.
149    optional bool is_holding_wake_lock_suspend_blocker = 37;
150    // The suspend blocker used to keep the CPU alive when the display is on, the
151    // display is getting ready or there is user activity (in which case the
152    // display must be on).
153    optional bool is_holding_display_suspend_blocker = 38;
154    // Settings and configuration
155    optional PowerServiceSettingsAndConfigurationDumpProto settings_and_configuration = 39;
156    // Sleep timeout in ms. This can be -1.
157    optional sint32 sleep_timeout_ms = 40;
158    // Screen off timeout in ms
159    optional int32 screen_off_timeout_ms = 41;
160    // Screen dim duration in ms
161    optional int32 screen_dim_duration_ms = 42;
162    // We are currently in the middle of a batch change of uids.
163    optional bool are_uids_changing = 43;
164    // Some uids have actually changed while mUidsChanging was true.
165    optional bool are_uids_changed = 44;
166    // List of UIDs and their states
167    repeated UidStateProto uid_states = 45;
168    optional .android.os.LooperProto looper = 46;
169    // List of all wake locks acquired by applications.
170    repeated WakeLockProto wake_locks = 47;
171    // List of all suspend blockers.
172    repeated SuspendBlockerProto suspend_blockers = 48;
173    optional WirelessChargerDetectorProto wireless_charger_detector = 49;
174    optional BatterySaverStateMachineProto battery_saver_state_machine = 50;
175    // Attentive timeout in ms. The timeout is disabled if it is set to -1.
176    optional sint32 attentive_timeout_ms = 51;
177}
178
179// A com.android.server.power.PowerManagerService.SuspendBlockerImpl object.
180message SuspendBlockerProto {
181    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
182
183    optional string name = 1;
184    optional int32 reference_count = 2;
185}
186
187// A com.android.server.power.PowerManagerService.WakeLock object.
188message WakeLockProto {
189    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
190
191    message WakeLockFlagsProto {
192        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
193
194        // Turn the screen on when the wake lock is acquired.
195        optional bool is_acquire_causes_wakeup = 1;
196        // When this wake lock is released, poke the user activity timer
197        // so the screen stays on for a little longer.
198        optional bool is_on_after_release = 2;
199    }
200
201    optional .android.os.WakeLockLevelEnum lock_level = 1;
202    optional string tag = 2;
203    optional WakeLockFlagsProto flags = 3;
204    optional bool is_disabled = 4;
205    // Acquire time in ms
206    optional int64 acq_ms = 5;
207    optional bool is_notified_long = 6;
208    // Owner UID
209    optional int32 uid = 7;
210    // Owner PID
211    optional int32 pid = 8;
212    optional .android.os.WorkSourceProto work_source = 9;
213}
214
215message PowerServiceSettingsAndConfigurationDumpProto {
216    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
217
218    message StayOnWhilePluggedInProto {
219        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
220
221        optional bool is_stay_on_while_plugged_in_ac = 1;
222        optional bool is_stay_on_while_plugged_in_usb = 2;
223        optional bool is_stay_on_while_plugged_in_wireless = 3;
224    }
225    message ScreenBrightnessSettingLimitsProto {
226        option (.android.msg_privacy).dest = DEST_AUTOMATIC;
227
228        reserved 1, 2, 3; // setting_minimum, setting_maximum, setting_default
229        optional float setting_minimum_float = 4;
230        optional float setting_maximum_float = 5;
231        optional float setting_default_float = 6;
232    }
233
234    // True to decouple auto-suspend mode from the display state.
235    optional bool is_decouple_hal_auto_suspend_mode_from_display_config = 1;
236    // True to decouple interactive mode from the display state.
237    optional bool is_decouple_hal_interactive_mode_from_display_config = 2;
238    // True if the device should wake up when plugged or unplugged.
239    optional bool is_wake_up_when_plugged_or_unplugged_config = 3;
240    // True if the device should wake up when plugged or unplugged in theater mode.
241    optional bool is_wake_up_when_plugged_or_unplugged_in_theater_mode_config = 4;
242    // True if theater mode is enabled
243    optional bool is_theater_mode_enabled = 5;
244    // True if the device should suspend when the screen is off due to proximity.
245    optional bool is_suspend_when_screen_off_due_to_proximity_config = 6;
246    // True if dreams are supported on this device.
247    optional bool are_dreams_supported_config = 7;
248    // Default value for dreams enabled
249    optional bool are_dreams_enabled_by_default_config = 8;
250    // Default value for dreams activate-on-sleep
251    optional bool are_dreams_activated_on_sleep_by_default_config = 9;
252    // Default value for dreams activate-on-dock
253    optional bool are_dreams_activated_on_dock_by_default_config = 10;
254    // True if dreams can run while not plugged in.
255    optional bool are_dreams_enabled_on_battery_config = 11;
256    // Minimum battery level to allow dreaming when powered.
257    // Use -1 to disable this safety feature.
258    optional sint32 dreams_battery_level_minimum_when_powered_config = 12;
259    // Minimum battery level to allow dreaming when not powered.
260    // Use -1 to disable this safety feature.
261    optional sint32 dreams_battery_level_minimum_when_not_powered_config = 13;
262    // If the battery level drops by this percentage and the user activity
263    // timeout has expired, then assume the device is receiving insufficient
264    // current to charge effectively and terminate the dream.  Use -1 to disable
265    // this safety feature.
266    optional sint32 dreams_battery_level_drain_cutoff_config = 14;
267    // True if dreams are enabled by the user.
268    optional bool are_dreams_enabled_setting = 15;
269    // True if dreams should be activated on sleep.
270    optional bool are_dreams_activate_on_sleep_setting = 16;
271    // True if dreams should be activated on dock.
272    optional bool are_dreams_activate_on_dock_setting = 17;
273    // True if doze should not be started until after the screen off transition.
274    optional bool is_doze_after_screen_off_config = 18;
275    // The minimum screen off timeout, in milliseconds.
276    optional int32 minimum_screen_off_timeout_config_ms = 19;
277    // The screen dim duration, in milliseconds.
278    optional int32 maximum_screen_dim_duration_config_ms = 20;
279    // The maximum screen dim time expressed as a ratio relative to the screen off timeout.
280    optional float maximum_screen_dim_ratio_config = 21;
281    // The screen off timeout setting value in milliseconds.
282    optional int32 screen_off_timeout_setting_ms = 22;
283    // The sleep timeout setting value in milliseconds. Default value is -1.
284    optional sint32 sleep_timeout_setting_ms = 23;
285    // The maximum allowable screen off timeout according to the device administration policy.
286    optional int32 maximum_screen_off_timeout_from_device_admin_ms = 24;
287    optional bool is_maximum_screen_off_timeout_from_device_admin_enforced_locked = 25;
288    // The stay on while plugged in setting.
289    // A set of battery conditions under which to make the screen stay on.
290    optional StayOnWhilePluggedInProto stay_on_while_plugged_in = 26;
291    // The screen brightness mode.
292    optional .android.providers.settings.SettingsProto.ScreenBrightnessMode screen_brightness_mode_setting = 27;
293    // The screen brightness setting override from the window manager
294    // to allow the current foreground activity to override the brightness.
295    // Use -1 to disable.
296    optional sint32 screen_brightness_override_from_window_manager = 28;
297    // The user activity timeout override from the window manager
298    // to allow the current foreground activity to override the user activity
299    // timeout. Use -1 to disable.
300    optional sint64 user_activity_timeout_override_from_window_manager_ms = 29;
301    // The window manager has determined the user to be inactive via other means.
302    // Set this to false to disable.
303    optional bool is_user_inactive_override_from_window_manager = 30;
304    // The screen state to use while dozing.
305    optional .android.view.DisplayStateEnum doze_screen_state_override_from_dream_manager = 31;
306    // The screen brightness to use while dozing.
307    optional float dozed_screen_brightness_override_from_dream_manager = 32;
308    // Screen brightness settings limits.
309    optional ScreenBrightnessSettingLimitsProto screen_brightness_setting_limits = 33;
310    // True if double tap to wake is enabled
311    optional bool is_double_tap_wake_enabled = 34;
312    // True if we are currently in VR Mode.
313    optional bool is_vr_mode_enabled = 35;
314    // True if Sidekick is controlling the display and we shouldn't change its power mode.
315    optional bool draw_wake_lock_override_from_sidekick = 36;
316    // The attentive timeout setting value in milliseconds. Default value is -1.
317    optional sint32 attentive_timeout_setting_ms = 37;
318    // The attentive timeout config value in milliseconds.
319    optional sint32 attentive_timeout_config_ms = 38;
320    // The attentive warning duration config value in milliseconds.
321    optional sint32 attentive_warning_duration_config_ms = 39;
322}
323
324message BatterySaverStateMachineProto {
325    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
326
327    // Whether battery saver is enabled.
328    optional bool enabled = 1;
329
330    enum StateEnum {
331        STATE_UNKNOWN = 0;
332        STATE_OFF = 1;
333        STATE_MANUAL_ON = 2;
334        STATE_AUTOMATIC_ON = 3;
335        STATE_OFF_AUTOMATIC_SNOOZED = 4;
336        STATE_PENDING_STICKY_ON = 5;
337    }
338    optional StateEnum state = 18;
339
340    // Whether full battery saver is enabled.
341    optional bool is_full_enabled = 14;
342
343    // Whether adaptive battery saver is enabled.
344    optional bool is_adaptive_enabled = 15;
345
346    // Whether the battery saver policy indicates that is_enabled should be
347    // advertised.
348    optional bool should_advertise_is_enabled = 16;
349
350    // Whether system has booted.
351    optional bool boot_completed = 2;
352
353    // Whether settings have been loaded already.
354    optional bool settings_loaded = 3;
355
356    // Whether battery status has been set at least once.
357    optional bool battery_status_set = 4;
358
359    reserved 5; // battery_saver_snoozing
360
361    // Whether the device is connected to any power source.
362    optional bool is_powered = 6;
363
364    // Current battery level in %, 0-100.
365    optional int32 battery_level = 7;
366
367    // Whether battery level is low or not.
368    optional bool is_battery_level_low = 8;
369
370    // Denotes which threshold should be used for automatic Battery Saver triggering.
371    enum AutomaticTriggerEnum {
372        TRIGGER_PERCENTAGE = 0;
373        TRIGGER_DYNAMIC = 1;
374    }
375    // The value of Global.AUTOMATIC_POWER_SAVE_MODE. This is a cached value, so it could
376    // be slightly different from what's in GlobalSettingsProto.DynamicPowerSavings.
377    optional AutomaticTriggerEnum setting_automatic_trigger = 19;
378
379    // The value of Global.LOW_POWER_MODE. This is a cached value, so it could
380    // be slightly different from what's in GlobalSettingsProto.LowPowerMode.
381    optional bool setting_battery_saver_enabled = 9;
382
383    // The value of Global.LOW_POWER_MODE_STICKY. This is a cached value, so it could
384    // be slightly different from what's in GlobalSettingsProto.LowPowerMode.
385    optional bool setting_battery_saver_enabled_sticky = 10;
386
387    // The value of Global.LOW_POWER_MODE_TRIGGER_LEVEL. This is a cached value, so it could
388    // be slightly different from what's in GlobalSettingsProto.LowPowerMode.
389    optional int32 setting_battery_saver_trigger_threshold = 11;
390
391    // The value of Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_ENABLED. This is a cached value, so
392    // it could be slightly different from what's in GlobalSettingsProto.LowPowerMode.
393    optional bool setting_battery_saver_sticky_auto_disable_enabled = 12;
394
395    // The value of Global.LOW_POWER_MODE_STICKY_AUTO_DISABLE_LEVEL. This is a cached value, so it
396    // could be slightly different from what's in GlobalSettingsProto.LowPowerMode.
397    optional int32 setting_battery_saver_sticky_auto_disable_threshold = 13;
398
399    // The last time adaptive battery saver was changed by an external service,
400    // using elapsed realtime as the timebase.
401    optional int64 last_adaptive_battery_saver_changed_externally_elapsed = 17;
402
403    // The default disable threshold for Dynamic Power Savings enabled battery saver.
404    optional int32 default_dynamic_disable_threshold = 20;
405
406    // When to disable battery saver again if it was enabled due to an external suggestion.
407    // Corresponds to Global.DYNAMIC_POWER_SAVINGS_DISABLE_THRESHOLD. This is a cached value,
408    // so it could be slightly different from what's in GlobalSettingsProto.DynamicPowerSavings.
409    optional int32 dynamic_disable_threshold = 21;
410
411    // Whether we've received a suggestion that battery saver should be on from an external app.
412    // Corresponds to Global.DYNAMIC_POWER_SAVINGS_ENABLED. This is a cached value, so it could
413    // be slightly different from what's in GlobalSettingsProto.DynamicPowerSavings.
414    optional bool dynamic_battery_saver_enabled = 22;
415
416    // Next tag: 23
417}
418