Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | package android.os; |
| 18 | |
Jeff Brown | 970d413 | 2014-07-19 11:33:47 -0700 | [diff] [blame] | 19 | import android.view.Display; |
| 20 | |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 21 | /** |
| 22 | * Power manager local system service interface. |
| 23 | * |
| 24 | * @hide Only for use within the system server. |
| 25 | */ |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 26 | public abstract class PowerManagerInternal { |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 27 | /** |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 28 | * Wakefulness: The device is asleep. It can only be awoken by a call to wakeUp(). |
| 29 | * The screen should be off or in the process of being turned off by the display controller. |
| 30 | * The device typically passes through the dozing state first. |
| 31 | */ |
| 32 | public static final int WAKEFULNESS_ASLEEP = 0; |
| 33 | |
| 34 | /** |
| 35 | * Wakefulness: The device is fully awake. It can be put to sleep by a call to goToSleep(). |
| 36 | * When the user activity timeout expires, the device may start dreaming or go to sleep. |
| 37 | */ |
| 38 | public static final int WAKEFULNESS_AWAKE = 1; |
| 39 | |
| 40 | /** |
| 41 | * Wakefulness: The device is dreaming. It can be awoken by a call to wakeUp(), |
| 42 | * which ends the dream. The device goes to sleep when goToSleep() is called, when |
| 43 | * the dream ends or when unplugged. |
| 44 | * User activity may brighten the screen but does not end the dream. |
| 45 | */ |
| 46 | public static final int WAKEFULNESS_DREAMING = 2; |
| 47 | |
| 48 | /** |
| 49 | * Wakefulness: The device is dozing. It is almost asleep but is allowing a special |
| 50 | * low-power "doze" dream to run which keeps the display on but lets the application |
| 51 | * processor be suspended. It can be awoken by a call to wakeUp() which ends the dream. |
| 52 | * The device fully goes to sleep if the dream cannot be started or ends on its own. |
| 53 | */ |
| 54 | public static final int WAKEFULNESS_DOZING = 3; |
| 55 | |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 56 | |
| 57 | /** |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 58 | * Power hint: |
| 59 | * Interaction: The user is interacting with the device. The corresponding data field must be |
Wei Wang | 98f03f9 | 2016-05-18 11:32:52 -0700 | [diff] [blame] | 60 | * the expected duration of the interaction, or 0 if unknown. |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 61 | * |
Wei Wang | 98f03f9 | 2016-05-18 11:32:52 -0700 | [diff] [blame] | 62 | * Sustained Performance Mode: The corresponding data field must be Enable/Disable |
| 63 | * Sustained Performance Mode. |
| 64 | * |
| 65 | * Launch: This is specific for activity launching. The corresponding data field must be |
| 66 | * the expected duration of the required boost, or 0 if unknown. |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 67 | * |
| 68 | * These must be kept in sync with the values in hardware/libhardware/include/hardware/power.h |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 69 | */ |
| 70 | public static final int POWER_HINT_INTERACTION = 2; |
Ruchi Kandoi | 43e38de | 2016-04-14 19:34:53 -0700 | [diff] [blame] | 71 | public static final int POWER_HINT_SUSTAINED_PERFORMANCE_MODE = 6; |
Wei Wang | 98f03f9 | 2016-05-18 11:32:52 -0700 | [diff] [blame] | 72 | public static final int POWER_HINT_LAUNCH = 8; |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 73 | |
Jeff Brown | fbe9670 | 2014-11-19 18:30:58 -0800 | [diff] [blame] | 74 | public static String wakefulnessToString(int wakefulness) { |
| 75 | switch (wakefulness) { |
| 76 | case WAKEFULNESS_ASLEEP: |
| 77 | return "Asleep"; |
| 78 | case WAKEFULNESS_AWAKE: |
| 79 | return "Awake"; |
| 80 | case WAKEFULNESS_DREAMING: |
| 81 | return "Dreaming"; |
| 82 | case WAKEFULNESS_DOZING: |
| 83 | return "Dozing"; |
| 84 | default: |
| 85 | return Integer.toString(wakefulness); |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Returns true if the wakefulness state represents an interactive state |
| 91 | * as defined by {@link android.os.PowerManager#isInteractive}. |
| 92 | */ |
| 93 | public static boolean isInteractive(int wakefulness) { |
| 94 | return wakefulness == WAKEFULNESS_AWAKE || wakefulness == WAKEFULNESS_DREAMING; |
| 95 | } |
| 96 | |
| 97 | /** |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 98 | * Used by the window manager to override the screen brightness based on the |
| 99 | * current foreground activity. |
| 100 | * |
| 101 | * This method must only be called by the window manager. |
| 102 | * |
| 103 | * @param brightness The overridden brightness, or -1 to disable the override. |
| 104 | */ |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 105 | public abstract void setScreenBrightnessOverrideFromWindowManager(int brightness); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Used by the window manager to override the button brightness based on the |
| 109 | * current foreground activity. |
| 110 | * |
| 111 | * This method must only be called by the window manager. |
| 112 | * |
| 113 | * @param brightness The overridden brightness, or -1 to disable the override. |
| 114 | */ |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 115 | public abstract void setButtonBrightnessOverrideFromWindowManager(int brightness); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * Used by the window manager to override the user activity timeout based on the |
| 119 | * current foreground activity. It can only be used to make the timeout shorter |
| 120 | * than usual, not longer. |
| 121 | * |
| 122 | * This method must only be called by the window manager. |
| 123 | * |
| 124 | * @param timeoutMillis The overridden timeout, or -1 to disable the override. |
| 125 | */ |
Jeff Brown | 4ccb823 | 2014-01-16 22:16:42 -0800 | [diff] [blame] | 126 | public abstract void setUserActivityTimeoutOverrideFromWindowManager(long timeoutMillis); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 127 | |
Jeff Brown | 970d413 | 2014-07-19 11:33:47 -0700 | [diff] [blame] | 128 | /** |
Nick Armstrong-Crews | 56ecfcc | 2015-09-07 21:46:50 -0700 | [diff] [blame] | 129 | * Used by the window manager to tell the power manager that the user is no longer actively |
| 130 | * using the device. |
| 131 | */ |
| 132 | public abstract void setUserInactiveOverrideFromWindowManager(); |
| 133 | |
| 134 | /** |
Jeff Brown | 5ce1cb2 | 2014-11-06 19:05:33 -0800 | [diff] [blame] | 135 | * Used by device administration to set the maximum screen off timeout. |
| 136 | * |
| 137 | * This method must only be called by the device administration policy manager. |
| 138 | */ |
| 139 | public abstract void setMaximumScreenOffTimeoutFromDeviceAdmin(int timeMs); |
| 140 | |
| 141 | /** |
Jeff Brown | 970d413 | 2014-07-19 11:33:47 -0700 | [diff] [blame] | 142 | * Used by the dream manager to override certain properties while dozing. |
| 143 | * |
Dianne Hackborn | 88e98df | 2015-03-23 13:29:14 -0700 | [diff] [blame] | 144 | * @param screenState The overridden screen state, or {@link Display#STATE_UNKNOWN} |
Jeff Brown | 970d413 | 2014-07-19 11:33:47 -0700 | [diff] [blame] | 145 | * to disable the override. |
| 146 | * @param screenBrightness The overridden screen brightness, or |
| 147 | * {@link PowerManager#BRIGHTNESS_DEFAULT} to disable the override. |
| 148 | */ |
| 149 | public abstract void setDozeOverrideFromDreamManager( |
| 150 | int screenState, int screenBrightness); |
| 151 | |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 152 | public abstract boolean getLowPowerModeEnabled(); |
| 153 | |
Jeff Brown | 2c43c33 | 2014-06-12 22:38:59 -0700 | [diff] [blame] | 154 | public abstract void registerLowPowerModeObserver(LowPowerModeListener listener); |
| 155 | |
Dianne Hackborn | cbefd8d | 2014-05-14 11:42:00 -0700 | [diff] [blame] | 156 | public interface LowPowerModeListener { |
| 157 | public void onLowPowerModeChanged(boolean enabled); |
| 158 | } |
Dianne Hackborn | 88e98df | 2015-03-23 13:29:14 -0700 | [diff] [blame] | 159 | |
Dianne Hackborn | 08c47a5 | 2015-10-15 12:38:14 -0700 | [diff] [blame] | 160 | public abstract boolean setDeviceIdleMode(boolean enabled); |
| 161 | |
| 162 | public abstract boolean setLightDeviceIdleMode(boolean enabled); |
Dianne Hackborn | 8d66b3f | 2015-05-08 17:21:48 -0700 | [diff] [blame] | 163 | |
| 164 | public abstract void setDeviceIdleWhitelist(int[] appids); |
Dianne Hackborn | d23e0d6 | 2015-05-15 16:36:12 -0700 | [diff] [blame] | 165 | |
Amith Yamasani | af575b9 | 2015-05-29 15:35:26 -0700 | [diff] [blame] | 166 | public abstract void setDeviceIdleTempWhitelist(int[] appids); |
| 167 | |
Dianne Hackborn | d23e0d6 | 2015-05-15 16:36:12 -0700 | [diff] [blame] | 168 | public abstract void updateUidProcState(int uid, int procState); |
| 169 | |
| 170 | public abstract void uidGone(int uid); |
Michael Wright | a4d22d7 | 2015-09-16 23:19:26 +0100 | [diff] [blame] | 171 | |
| 172 | public abstract void powerHint(int hintId, int data); |
Jeff Brown | 6f357d3 | 2014-01-15 20:40:55 -0800 | [diff] [blame] | 173 | } |