The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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.view; |
| 18 | |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 19 | import static android.Manifest.permission; |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 20 | import static android.view.Display.DEFAULT_DISPLAY; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 21 | import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; |
| 22 | import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 23 | import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY; |
| 24 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL; |
| 25 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
| 26 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; |
| 27 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; |
| 28 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; |
| 29 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; |
| 30 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; |
| 31 | import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; |
| 32 | import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY; |
| 33 | import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; |
| 34 | import static android.view.WindowManager.LayoutParams.TYPE_DRAG; |
| 35 | import static android.view.WindowManager.LayoutParams.TYPE_DREAM; |
| 36 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER; |
| 37 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 38 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
| 39 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; |
| 40 | import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; |
| 41 | import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; |
| 42 | import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; |
| 43 | import static android.view.WindowManager.LayoutParams.TYPE_PHONE; |
| 44 | import static android.view.WindowManager.LayoutParams.TYPE_POINTER; |
| 45 | import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION; |
| 46 | import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE; |
| 47 | import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; |
| 48 | import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG; |
| 49 | import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT; |
| 50 | import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR; |
| 51 | import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
| 52 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
| 53 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; |
| 54 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; |
| 55 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; |
| 56 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; |
| 57 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; |
| 58 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; |
| 59 | import static android.view.WindowManager.LayoutParams.TYPE_TOAST; |
| 60 | import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; |
| 61 | import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING; |
| 62 | import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY; |
| 63 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 64 | import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType; |
| 65 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 66 | import android.annotation.IntDef; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 67 | import android.annotation.Nullable; |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 68 | import android.annotation.SystemApi; |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 69 | import android.app.ActivityManager.StackId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | import android.content.Context; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 71 | import android.content.pm.ActivityInfo; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 72 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | import android.content.res.Configuration; |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 74 | import android.graphics.Point; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | import android.graphics.Rect; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 76 | import android.os.Bundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | import android.os.IBinder; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 78 | import android.os.Looper; |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 79 | import android.os.RemoteException; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 80 | import android.util.Slog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 81 | import android.view.animation.Animation; |
Aurimas Liutikas | 67e2ae8 | 2016-10-11 18:17:42 -0700 | [diff] [blame] | 82 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 83 | import com.android.internal.policy.IKeyguardDismissCallback; |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 84 | import com.android.internal.policy.IShortcutService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 85 | |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 86 | import java.io.PrintWriter; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 87 | import java.lang.annotation.Retention; |
| 88 | import java.lang.annotation.RetentionPolicy; |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | /** |
| 91 | * This interface supplies all UI-specific behavior of the window manager. An |
| 92 | * instance of it is created by the window manager when it starts up, and allows |
| 93 | * customization of window layering, special window types, key dispatching, and |
| 94 | * layout. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 95 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | * <p>Because this provides deep interaction with the system window manager, |
| 97 | * specific methods on this interface can be called from a variety of contexts |
| 98 | * with various restrictions on what they can do. These are encoded through |
| 99 | * a suffixes at the end of a method encoding the thread the method is called |
| 100 | * from and any locks that are held when it is being called; if no suffix |
| 101 | * is attached to a method, then it is not called with any locks and may be |
| 102 | * called from the main window manager thread or another thread calling into |
| 103 | * the window manager. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 104 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | * <p>The current suffixes are: |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 106 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | * <dl> |
| 108 | * <dt> Ti <dd> Called from the input thread. This is the thread that |
| 109 | * collects pending input events and dispatches them to the appropriate window. |
| 110 | * It may block waiting for events to be processed, so that the input stream is |
| 111 | * properly serialized. |
| 112 | * <dt> Tq <dd> Called from the low-level input queue thread. This is the |
| 113 | * thread that reads events out of the raw input devices and places them |
| 114 | * into the global input queue that is read by the <var>Ti</var> thread. |
| 115 | * This thread should not block for a long period of time on anything but the |
| 116 | * key driver. |
| 117 | * <dt> Lw <dd> Called with the main window manager lock held. Because the |
| 118 | * window manager is a very low-level system service, there are few other |
| 119 | * system services you can call with this lock held. It is explicitly okay to |
| 120 | * make calls into the package manager and power manager; it is explicitly not |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 121 | * okay to make calls into the activity manager or most other services. Note that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | * {@link android.content.Context#checkPermission(String, int, int)} and |
| 123 | * variations require calling into the activity manager. |
| 124 | * <dt> Li <dd> Called with the input thread lock held. This lock can be |
| 125 | * acquired by the window manager while it holds the window lock, so this is |
| 126 | * even more restrictive than <var>Lw</var>. |
| 127 | * </dl> |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 128 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | * @hide |
| 130 | */ |
| 131 | public interface WindowManagerPolicy { |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 132 | // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | public final static int FLAG_WAKE = 0x00000001; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 134 | public final static int FLAG_VIRTUAL = 0x00000002; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 135 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 136 | public final static int FLAG_INJECTED = 0x01000000; |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 137 | public final static int FLAG_TRUSTED = 0x02000000; |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 138 | public final static int FLAG_FILTERED = 0x04000000; |
| 139 | public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000; |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 140 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 141 | public final static int FLAG_INTERACTIVE = 0x20000000; |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 142 | public final static int FLAG_PASS_TO_USER = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 143 | |
Adrian Roos | d5c2db6 | 2016-03-08 16:11:31 -0800 | [diff] [blame] | 144 | // Flags for IActivityManager.keyguardGoingAway() |
| 145 | public final static int KEYGUARD_GOING_AWAY_FLAG_TO_SHADE = 1 << 0; |
| 146 | public final static int KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS = 1 << 1; |
| 147 | public final static int KEYGUARD_GOING_AWAY_FLAG_WITH_WALLPAPER = 1 << 2; |
| 148 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 149 | // Flags used for indicating whether the internal and/or external input devices |
| 150 | // of some type are available. |
| 151 | public final static int PRESENCE_INTERNAL = 1 << 0; |
| 152 | public final static int PRESENCE_EXTERNAL = 1 << 1; |
| 153 | |
Andrii Kulian | 3a1619d | 2017-07-07 14:38:09 -0700 | [diff] [blame] | 154 | // Navigation bar position values |
| 155 | int NAV_BAR_LEFT = 1 << 0; |
| 156 | int NAV_BAR_RIGHT = 1 << 1; |
| 157 | int NAV_BAR_BOTTOM = 1 << 2; |
| 158 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 159 | public final static boolean WATCH_POINTER = false; |
| 160 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 161 | /** |
| 162 | * Sticky broadcast of the current HDMI plugged state. |
| 163 | */ |
| 164 | public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED"; |
| 165 | |
| 166 | /** |
| 167 | * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if |
| 168 | * plugged in to HDMI, false if not. |
| 169 | */ |
| 170 | public final static String EXTRA_HDMI_PLUGGED_STATE = "state"; |
| 171 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | /** |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 173 | * Set to {@code true} when intent was invoked from pressing the home key. |
| 174 | * @hide |
| 175 | */ |
| 176 | @SystemApi |
| 177 | public static final String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY"; |
| 178 | |
| 179 | /** |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 180 | * Pass this event to the user / app. To be returned from |
| 181 | * {@link #interceptKeyBeforeQueueing}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 182 | */ |
| 183 | public final static int ACTION_PASS_TO_USER = 0x00000001; |
| 184 | |
| 185 | /** |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 186 | * Register shortcuts for window manager to dispatch. |
| 187 | * Shortcut code is packed as (metaState << Integer.SIZE) | keyCode |
| 188 | * @hide |
| 189 | */ |
| 190 | void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver) |
| 191 | throws RemoteException; |
| 192 | |
| 193 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 194 | * Called when the Keyguard occluded state changed. |
| 195 | * @param occluded Whether Keyguard is currently occluded or not. |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 196 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 197 | void onKeyguardOccludedChangedLw(boolean occluded); |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 198 | |
| 199 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 200 | * Interface to the Window Manager state associated with a particular |
| 201 | * window. You can hold on to an instance of this interface from the call |
| 202 | * to prepareAddWindow() until removeWindow(). |
| 203 | */ |
| 204 | public interface WindowState { |
| 205 | /** |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 206 | * Return the uid of the app that owns this window. |
| 207 | */ |
| 208 | int getOwningUid(); |
| 209 | |
| 210 | /** |
| 211 | * Return the package name of the app that owns this window. |
| 212 | */ |
| 213 | String getOwningPackage(); |
| 214 | |
| 215 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 216 | * Perform standard frame computation. The result can be obtained with |
| 217 | * getFrame() if so desired. Must be called with the window manager |
| 218 | * lock held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 219 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 220 | * @param parentFrame The frame of the parent container this window |
| 221 | * is in, used for computing its basic position. |
| 222 | * @param displayFrame The frame of the overall display in which this |
| 223 | * window can appear, used for constraining the overall dimensions |
| 224 | * of the window. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 225 | * @param overlayFrame The frame within the display that is inside |
| 226 | * of the overlay region. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | * @param contentFrame The frame within the display in which we would |
| 228 | * like active content to appear. This will cause windows behind to |
| 229 | * be resized to match the given content frame. |
| 230 | * @param visibleFrame The frame within the display that the window |
| 231 | * is actually visible, used for computing its visible insets to be |
| 232 | * given to windows behind. |
| 233 | * This can be used as a hint for scrolling (avoiding resizing) |
| 234 | * the window to make certain that parts of its content |
| 235 | * are visible. |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 236 | * @param decorFrame The decor frame specified by policy specific to this window, |
| 237 | * to use for proper cropping during animation. |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 238 | * @param stableFrame The frame around which stable system decoration is positioned. |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 239 | * @param outsetFrame The frame that includes areas that aren't part of the surface but we |
| 240 | * want to treat them as such. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 241 | */ |
| 242 | public void computeFrameLw(Rect parentFrame, Rect displayFrame, |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 243 | Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame, |
Filip Gruszczynski | 2217f61 | 2015-05-26 11:32:08 -0700 | [diff] [blame] | 244 | Rect stableFrame, Rect outsetFrame); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 245 | |
| 246 | /** |
| 247 | * Retrieve the current frame of the window that has been assigned by |
| 248 | * the window manager. Must be called with the window manager lock held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 249 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 250 | * @return Rect The rectangle holding the window frame. |
| 251 | */ |
| 252 | public Rect getFrameLw(); |
| 253 | |
| 254 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 255 | * Retrieve the current position of the window that is actually shown. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 256 | * Must be called with the window manager lock held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 257 | * |
| 258 | * @return Point The point holding the shown window position. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | */ |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 260 | public Point getShownPositionLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | |
| 262 | /** |
| 263 | * Retrieve the frame of the display that this window was last |
| 264 | * laid out in. Must be called with the |
| 265 | * window manager lock held. |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 266 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 267 | * @return Rect The rectangle holding the display frame. |
| 268 | */ |
| 269 | public Rect getDisplayFrameLw(); |
| 270 | |
| 271 | /** |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 272 | * Retrieve the frame of the area inside the overscan region of the |
| 273 | * display that this window was last laid out in. Must be called with the |
| 274 | * window manager lock held. |
| 275 | * |
| 276 | * @return Rect The rectangle holding the display overscan frame. |
| 277 | */ |
| 278 | public Rect getOverscanFrameLw(); |
| 279 | |
| 280 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | * Retrieve the frame of the content area that this window was last |
| 282 | * laid out in. This is the area in which the content of the window |
| 283 | * should be placed. It will be smaller than the display frame to |
| 284 | * account for screen decorations such as a status bar or soft |
| 285 | * keyboard. Must be called with the |
| 286 | * window manager lock held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 287 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 288 | * @return Rect The rectangle holding the content frame. |
| 289 | */ |
| 290 | public Rect getContentFrameLw(); |
| 291 | |
| 292 | /** |
| 293 | * Retrieve the frame of the visible area that this window was last |
| 294 | * laid out in. This is the area of the screen in which the window |
| 295 | * will actually be fully visible. It will be smaller than the |
| 296 | * content frame to account for transient UI elements blocking it |
| 297 | * such as an input method's candidates UI. Must be called with the |
| 298 | * window manager lock held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 299 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | * @return Rect The rectangle holding the visible frame. |
| 301 | */ |
| 302 | public Rect getVisibleFrameLw(); |
| 303 | |
| 304 | /** |
| 305 | * Returns true if this window is waiting to receive its given |
| 306 | * internal insets from the client app, and so should not impact the |
| 307 | * layout of other windows. |
| 308 | */ |
| 309 | public boolean getGivenInsetsPendingLw(); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 310 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 311 | /** |
| 312 | * Retrieve the insets given by this window's client for the content |
| 313 | * area of windows behind it. Must be called with the |
| 314 | * window manager lock held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 315 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | * @return Rect The left, top, right, and bottom insets, relative |
| 317 | * to the window's frame, of the actual contents. |
| 318 | */ |
| 319 | public Rect getGivenContentInsetsLw(); |
| 320 | |
| 321 | /** |
| 322 | * Retrieve the insets given by this window's client for the visible |
| 323 | * area of windows behind it. Must be called with the |
| 324 | * window manager lock held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 325 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 326 | * @return Rect The left, top, right, and bottom insets, relative |
| 327 | * to the window's frame, of the actual visible area. |
| 328 | */ |
| 329 | public Rect getGivenVisibleInsetsLw(); |
| 330 | |
| 331 | /** |
| 332 | * Retrieve the current LayoutParams of the window. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 333 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 334 | * @return WindowManager.LayoutParams The window's internal LayoutParams |
| 335 | * instance. |
| 336 | */ |
| 337 | public WindowManager.LayoutParams getAttrs(); |
| 338 | |
| 339 | /** |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 340 | * Return whether this window needs the menu key shown. Must be called |
| 341 | * with window lock held, because it may need to traverse down through |
| 342 | * window list to determine the result. |
| 343 | * @param bottom The bottom-most window to consider when determining this. |
| 344 | */ |
| 345 | public boolean getNeedsMenuLw(WindowState bottom); |
| 346 | |
| 347 | /** |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 348 | * Retrieve the current system UI visibility flags associated with |
| 349 | * this window. |
| 350 | */ |
| 351 | public int getSystemUiVisibility(); |
| 352 | |
| 353 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 354 | * Get the layer at which this window's surface will be Z-ordered. |
| 355 | */ |
| 356 | public int getSurfaceLayer(); |
Selim Cinek | d662361 | 2015-05-22 18:56:22 -0700 | [diff] [blame] | 357 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 358 | /** |
Selim Cinek | d662361 | 2015-05-22 18:56:22 -0700 | [diff] [blame] | 359 | * Retrieve the type of the top-level window. |
| 360 | * |
| 361 | * @return the base type of the parent window if attached or its own type otherwise |
| 362 | */ |
| 363 | public int getBaseType(); |
| 364 | |
| 365 | /** |
| 366 | * Return the token for the application (actually activity) that owns |
| 367 | * this window. May return null for system windows. |
| 368 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 369 | * @return An IApplicationToken identifying the owning activity. |
| 370 | */ |
| 371 | public IApplicationToken getAppToken(); |
| 372 | |
| 373 | /** |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 374 | * Return true if this window is participating in voice interaction. |
| 375 | */ |
| 376 | public boolean isVoiceInteraction(); |
| 377 | |
| 378 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 379 | * Return true if, at any point, the application token associated with |
| 380 | * this window has actually displayed any windows. This is most useful |
| 381 | * with the "starting up" window to determine if any windows were |
| 382 | * displayed when it is closed. |
| 383 | * |
| 384 | * @return Returns true if one or more windows have been displayed, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 385 | * else false. |
| 386 | */ |
| 387 | public boolean hasAppShownWindows(); |
| 388 | |
| 389 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | * Is this window visible? It is not visible if there is no |
| 391 | * surface, or we are in the process of running an exit animation |
| 392 | * that will remove the surface. |
| 393 | */ |
| 394 | boolean isVisibleLw(); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 395 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 396 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 397 | * Is this window currently visible to the user on-screen? It is |
| 398 | * displayed either if it is visible or it is currently running an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | * animation before no longer being visible. Must be called with the |
| 400 | * window manager lock held. |
| 401 | */ |
| 402 | boolean isDisplayedLw(); |
| 403 | |
| 404 | /** |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 405 | * Return true if this window (or a window it is attached to, but not |
| 406 | * considering its app token) is currently animating. |
| 407 | */ |
Filip Gruszczynski | 14b4e57 | 2015-11-03 15:53:55 -0800 | [diff] [blame] | 408 | boolean isAnimatingLw(); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 409 | |
| 410 | /** |
Jorim Jaggi | 23cc9aa | 2017-05-23 16:05:35 +0200 | [diff] [blame] | 411 | * @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars, |
| 412 | * for example) will be affected by the flags specified in this window. This is the |
| 413 | * case when the surface is on screen but not exiting. |
| 414 | */ |
| 415 | boolean canAffectSystemUiFlags(); |
| 416 | |
| 417 | /** |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 418 | * Is this window considered to be gone for purposes of layout? |
| 419 | */ |
| 420 | boolean isGoneForLayoutLw(); |
| 421 | |
| 422 | /** |
Adrian Roos | 76d2fe4 | 2015-07-09 14:54:08 -0700 | [diff] [blame] | 423 | * Returns true if the window has a surface that it has drawn a |
| 424 | * complete UI in to. Note that this is different from {@link #hasDrawnLw()} |
| 425 | * in that it also returns true if the window is READY_TO_SHOW, but was not yet |
| 426 | * promoted to HAS_DRAWN. |
| 427 | */ |
| 428 | boolean isDrawnLw(); |
| 429 | |
| 430 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 431 | * Returns true if this window has been shown on screen at some time in |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 432 | * the past. Must be called with the window manager lock held. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 433 | */ |
| 434 | public boolean hasDrawnLw(); |
| 435 | |
| 436 | /** |
| 437 | * Can be called by the policy to force a window to be hidden, |
| 438 | * regardless of whether the client or window manager would like |
| 439 | * it shown. Must be called with the window manager lock held. |
| 440 | * Returns true if {@link #showLw} was last called for the window. |
| 441 | */ |
| 442 | public boolean hideLw(boolean doAnimation); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 443 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 444 | /** |
| 445 | * Can be called to undo the effect of {@link #hideLw}, allowing a |
| 446 | * window to be shown as long as the window manager and client would |
| 447 | * also like it to be shown. Must be called with the window manager |
| 448 | * lock held. |
| 449 | * Returns true if {@link #hideLw} was last called for the window. |
| 450 | */ |
| 451 | public boolean showLw(boolean doAnimation); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 452 | |
| 453 | /** |
| 454 | * Check whether the process hosting this window is currently alive. |
| 455 | */ |
| 456 | public boolean isAlive(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 457 | |
| 458 | /** |
| 459 | * Check if window is on {@link Display#DEFAULT_DISPLAY}. |
| 460 | * @return true if window is on default display. |
| 461 | */ |
| 462 | public boolean isDefaultDisplay(); |
Adrian Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 463 | |
| 464 | /** |
| 465 | * Check whether the window is currently dimming. |
| 466 | */ |
| 467 | public boolean isDimming(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 468 | |
| 469 | /** |
| 470 | * @return the stack id this windows belongs to, or {@link StackId#INVALID_STACK_ID} if |
| 471 | * not attached to any stack. |
| 472 | */ |
| 473 | int getStackId(); |
Wale Ogunwale | 9185fb0 | 2016-03-11 18:06:14 -0800 | [diff] [blame] | 474 | |
| 475 | /** |
| 476 | * Returns true if the window is current in multi-windowing mode. i.e. it shares the |
| 477 | * screen with other application windows. |
| 478 | */ |
Andrii Kulian | 933076d | 2016-03-29 17:04:42 -0700 | [diff] [blame] | 479 | public boolean isInMultiWindowMode(); |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 480 | |
| 481 | public int getRotationAnimationHint(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 482 | |
| 483 | public boolean isInputMethodWindow(); |
| 484 | |
| 485 | public int getDisplayId(); |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 486 | |
| 487 | /** |
| 488 | * Returns true if the window owner can add internal system windows. |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 489 | * That is, they have {@link permission#INTERNAL_SYSTEM_WINDOW}. |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 490 | */ |
| 491 | default boolean canAddInternalSystemWindow() { |
| 492 | return false; |
| 493 | } |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 494 | |
| 495 | /** |
| 496 | * Returns true if the window owner has the permission to acquire a sleep token when it's |
| 497 | * visible. That is, they have the permission {@link permission#DEVICE_POWER}. |
| 498 | */ |
| 499 | boolean canAcquireSleepToken(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | } |
| 501 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 502 | /** |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 503 | * Representation of a input consumer that the policy has added to the |
| 504 | * window manager to consume input events going to windows below it. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 505 | */ |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 506 | public interface InputConsumer { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 507 | /** |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 508 | * Remove the input consumer from the window manager. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 509 | */ |
| 510 | void dismiss(); |
| 511 | } |
| 512 | |
| 513 | /** |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 514 | * Holds the contents of a starting window. {@link #addSplashScreen} needs to wrap the |
| 515 | * contents of the starting window into an class implementing this interface, which then will be |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 516 | * held by WM and released with {@link #remove} when no longer needed. |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 517 | */ |
| 518 | interface StartingSurface { |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 519 | |
| 520 | /** |
| 521 | * Removes the starting window surface. Do not hold the window manager lock when calling |
| 522 | * this method! |
| 523 | */ |
| 524 | void remove(); |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 528 | * Interface for calling back in to the window manager that is private |
| 529 | * between it and the policy. |
| 530 | */ |
| 531 | public interface WindowManagerFuncs { |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 532 | public static final int LID_ABSENT = -1; |
| 533 | public static final int LID_CLOSED = 0; |
| 534 | public static final int LID_OPEN = 1; |
| 535 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 536 | public static final int CAMERA_LENS_COVER_ABSENT = -1; |
| 537 | public static final int CAMERA_LENS_UNCOVERED = 0; |
| 538 | public static final int CAMERA_LENS_COVERED = 1; |
| 539 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 540 | /** |
| 541 | * Ask the window manager to re-evaluate the system UI flags. |
| 542 | */ |
| 543 | public void reevaluateStatusBarVisibility(); |
| 544 | |
| 545 | /** |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 546 | * Add a input consumer which will consume all input events going to any window below it. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 547 | */ |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 548 | public InputConsumer createInputConsumer(Looper looper, String name, |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 549 | InputEventReceiver.Factory inputEventReceiverFactory); |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 550 | |
| 551 | /** |
| 552 | * Returns a code that describes the current state of the lid switch. |
| 553 | */ |
| 554 | public int getLidState(); |
| 555 | |
| 556 | /** |
Edward Savage-Jones | 7def60d | 2015-11-13 13:27:03 +0100 | [diff] [blame] | 557 | * Lock the device now. |
| 558 | */ |
| 559 | public void lockDeviceNow(); |
| 560 | |
| 561 | /** |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 562 | * Returns a code that descripbes whether the camera lens is covered or not. |
| 563 | */ |
| 564 | public int getCameraLensCoverState(); |
| 565 | |
| 566 | /** |
Yohei Yukawa | ae61f71 | 2015-12-09 13:00:10 -0800 | [diff] [blame] | 567 | * Switch the input method, to be precise, input method subtype. |
| 568 | * |
| 569 | * @param forwardDirection {@code true} to rotate in a forward direction. |
| 570 | */ |
| 571 | public void switchInputMethod(boolean forwardDirection); |
| 572 | |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 573 | public void shutdown(boolean confirm); |
Alison Cichowlas | f8eca40 | 2016-08-05 14:50:27 -0400 | [diff] [blame] | 574 | public void reboot(boolean confirm); |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 575 | public void rebootSafeMode(boolean confirm); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 576 | |
| 577 | /** |
| 578 | * Return the window manager lock needed to correctly call "Lw" methods. |
| 579 | */ |
| 580 | public Object getWindowManagerLock(); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 581 | |
| 582 | /** Register a system listener for touch events */ |
| 583 | void registerPointerEventListener(PointerEventListener listener); |
| 584 | |
| 585 | /** Unregister a system listener for touch events */ |
| 586 | void unregisterPointerEventListener(PointerEventListener listener); |
Jorim Jaggi | 81ba11e | 2016-02-03 22:04:22 -0800 | [diff] [blame] | 587 | |
| 588 | /** |
| 589 | * @return The content insets of the docked divider window. |
| 590 | */ |
| 591 | int getDockedDividerInsetsLw(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 592 | |
| 593 | /** |
| 594 | * Retrieves the {@param outBounds} from the stack with id {@param stackId}. |
| 595 | */ |
| 596 | void getStackBounds(int stackId, Rect outBounds); |
Jorim Jaggi | 77e1043 | 2016-10-26 17:43:56 -0700 | [diff] [blame] | 597 | |
| 598 | /** |
| 599 | * Notifies window manager that {@link #isShowingDreamLw} has changed. |
| 600 | */ |
| 601 | void notifyShowingDreamChanged(); |
Jorim Jaggi | e69c931 | 2016-10-31 18:24:38 -0700 | [diff] [blame] | 602 | |
| 603 | /** |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 604 | * @return The currently active input method window. |
| 605 | */ |
| 606 | WindowState getInputMethodWindowLw(); |
| 607 | |
| 608 | /** |
Jorim Jaggi | e69c931 | 2016-10-31 18:24:38 -0700 | [diff] [blame] | 609 | * Notifies window manager that {@link #isKeyguardTrustedLw} has changed. |
| 610 | */ |
| 611 | void notifyKeyguardTrustedChanged(); |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 612 | |
| 613 | /** |
| 614 | * Notifies the window manager that screen is being turned off. |
| 615 | * |
| 616 | * @param listener callback to call when display can be turned off |
| 617 | */ |
| 618 | void screenTurningOff(ScreenOffListener listener); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | public interface PointerEventListener { |
| 622 | /** |
| 623 | * 1. onPointerEvent will be called on the service.UiThread. |
| 624 | * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a |
| 625 | * copy() must be made and the copy must be recycled. |
| 626 | **/ |
Tarandeep Singh | e1cfcf4 | 2017-07-10 18:50:00 -0700 | [diff] [blame] | 627 | void onPointerEvent(MotionEvent motionEvent); |
| 628 | |
| 629 | /** |
| 630 | * @see #onPointerEvent(MotionEvent) |
| 631 | **/ |
| 632 | default void onPointerEvent(MotionEvent motionEvent, int displayId) { |
| 633 | if (displayId == DEFAULT_DISPLAY) { |
| 634 | onPointerEvent(motionEvent); |
| 635 | } |
| 636 | } |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 637 | } |
| 638 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 639 | /** Window has been added to the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 640 | public static final int TRANSIT_ENTER = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 641 | /** Window has been removed from the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 642 | public static final int TRANSIT_EXIT = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 643 | /** Window has been made visible. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 644 | public static final int TRANSIT_SHOW = 3; |
| 645 | /** Window has been made invisible. |
| 646 | * TODO: Consider removal as this is unused. */ |
| 647 | public static final int TRANSIT_HIDE = 4; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 648 | /** The "application starting" preview window is no longer needed, and will |
| 649 | * animate away to show the real window. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 650 | public static final int TRANSIT_PREVIEW_DONE = 5; |
| 651 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 652 | // NOTE: screen off reasons are in order of significance, with more |
| 653 | // important ones lower than less important ones. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 654 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 655 | /** Screen turned off because of a device admin */ |
| 656 | public final int OFF_BECAUSE_OF_ADMIN = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 657 | /** Screen turned off because of power button */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 658 | public final int OFF_BECAUSE_OF_USER = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 659 | /** Screen turned off because of timeout */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 660 | public final int OFF_BECAUSE_OF_TIMEOUT = 3; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 661 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 662 | /** @hide */ |
| 663 | @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED}) |
| 664 | @Retention(RetentionPolicy.SOURCE) |
| 665 | public @interface UserRotationMode {} |
| 666 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 667 | /** When not otherwise specified by the activity's screenOrientation, rotation should be |
| 668 | * determined by the system (that is, using sensors). */ |
| 669 | public final int USER_ROTATION_FREE = 0; |
| 670 | /** When not otherwise specified by the activity's screenOrientation, rotation is set by |
| 671 | * the user. */ |
| 672 | public final int USER_ROTATION_LOCKED = 1; |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 673 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 674 | /** |
| 675 | * Perform initialization of the policy. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 676 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 677 | * @param context The system context we are running in. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 678 | */ |
| 679 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 680 | WindowManagerFuncs windowManagerFuncs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 681 | |
| 682 | /** |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 683 | * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true. |
| 684 | */ |
| 685 | public boolean isDefaultOrientationForced(); |
| 686 | |
| 687 | /** |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 688 | * Called by window manager once it has the initial, default native |
| 689 | * display dimensions. |
| 690 | */ |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 691 | public void setInitialDisplaySize(Display display, int width, int height, int density); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 692 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 693 | /** |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 694 | * Called by window manager to set the overscan region that should be used for the |
| 695 | * given display. |
| 696 | */ |
| 697 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom); |
| 698 | |
| 699 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 700 | * Check permissions when adding a window. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 701 | * |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 702 | * @param attrs The window's LayoutParams. |
| 703 | * @param outAppOp First element will be filled with the app op corresponding to |
| 704 | * this window, or OP_NONE. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 705 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 706 | * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 707 | * else an error code, usually |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 708 | * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 709 | */ |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 710 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 711 | |
| 712 | /** |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 713 | * Check permissions when adding a window. |
| 714 | * |
| 715 | * @param attrs The window's LayoutParams. |
| 716 | * |
| 717 | * @return True if the window may only be shown to the current user, false if the window can |
| 718 | * be shown on all users' windows. |
| 719 | */ |
| 720 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs); |
| 721 | |
| 722 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 723 | * Sanitize the layout parameters coming from a client. Allows the policy |
| 724 | * to do things like ensure that windows of a specific type can't take |
| 725 | * input focus. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 726 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 727 | * @param attrs The window layout parameters to be modified. These values |
| 728 | * are modified in-place. |
| 729 | */ |
| 730 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 731 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 732 | /** |
| 733 | * After the window manager has computed the current configuration based |
| 734 | * on its knowledge of the display and input devices, it gives the policy |
| 735 | * a chance to adjust the information contained in it. If you want to |
| 736 | * leave it as-is, simply do nothing. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 737 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 738 | * <p>This method may be called by any thread in the window manager, but |
| 739 | * no internal locks in the window manager will be held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 740 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 741 | * @param config The Configuration being computed, for you to change as |
| 742 | * desired. |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 743 | * @param keyboardPresence Flags that indicate whether internal or external |
| 744 | * keyboards are present. |
| 745 | * @param navigationPresence Flags that indicate whether internal or external |
| 746 | * navigation devices are present. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 747 | */ |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 748 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 749 | int navigationPresence); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 750 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 751 | /** |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 752 | * Returns the layer assignment for the window state. Allows you to control how different |
| 753 | * kinds of windows are ordered on-screen. |
| 754 | * |
| 755 | * @param win The window state |
| 756 | * @return int An arbitrary integer used to order windows, with lower numbers below higher ones. |
| 757 | */ |
| 758 | default int getWindowLayerLw(WindowState win) { |
| 759 | return getWindowLayerFromTypeLw(win.getBaseType(), win.canAddInternalSystemWindow()); |
| 760 | } |
| 761 | |
| 762 | /** |
| 763 | * Returns the layer assignment for the window type. Allows you to control how different |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 764 | * kinds of windows are ordered on-screen. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 765 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 766 | * @param type The type of window being assigned. |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 767 | * @return int An arbitrary integer used to order windows, with lower numbers below higher ones. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 768 | */ |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 769 | default int getWindowLayerFromTypeLw(int type) { |
| 770 | if (isSystemAlertWindowType(type)) { |
| 771 | throw new IllegalArgumentException("Use getWindowLayerFromTypeLw() or" |
| 772 | + " getWindowLayerLw() for alert window types"); |
| 773 | } |
| 774 | return getWindowLayerFromTypeLw(type, false /* canAddInternalSystemWindow */); |
| 775 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 776 | |
| 777 | /** |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 778 | * Returns the layer assignment for the window type. Allows you to control how different |
| 779 | * kinds of windows are ordered on-screen. |
| 780 | * |
| 781 | * @param type The type of window being assigned. |
| 782 | * @param canAddInternalSystemWindow If the owner window associated with the type we are |
| 783 | * evaluating can add internal system windows. I.e they have |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 784 | * {@link permission#INTERNAL_SYSTEM_WINDOW}. If true, alert window |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 785 | * types {@link android.view.WindowManager.LayoutParams#isSystemAlertWindowType(int)} |
| 786 | * can be assigned layers greater than the layer for |
| 787 | * {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} Else, their |
| 788 | * layers would be lesser. |
| 789 | * @return int An arbitrary integer used to order windows, with lower numbers below higher ones. |
| 790 | */ |
| 791 | default int getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow) { |
| 792 | if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) { |
| 793 | return APPLICATION_LAYER; |
| 794 | } |
| 795 | |
| 796 | switch (type) { |
| 797 | case TYPE_WALLPAPER: |
| 798 | // wallpaper is at the bottom, though the window manager may move it. |
| 799 | return 1; |
| 800 | case TYPE_PRESENTATION: |
| 801 | case TYPE_PRIVATE_PRESENTATION: |
| 802 | return APPLICATION_LAYER; |
| 803 | case TYPE_DOCK_DIVIDER: |
| 804 | return APPLICATION_LAYER; |
| 805 | case TYPE_QS_DIALOG: |
| 806 | return APPLICATION_LAYER; |
| 807 | case TYPE_PHONE: |
| 808 | return 3; |
| 809 | case TYPE_SEARCH_BAR: |
| 810 | case TYPE_VOICE_INTERACTION_STARTING: |
| 811 | return 4; |
| 812 | case TYPE_VOICE_INTERACTION: |
| 813 | // voice interaction layer is almost immediately above apps. |
| 814 | return 5; |
| 815 | case TYPE_INPUT_CONSUMER: |
| 816 | return 6; |
| 817 | case TYPE_SYSTEM_DIALOG: |
| 818 | return 7; |
| 819 | case TYPE_TOAST: |
| 820 | // toasts and the plugged-in battery thing |
| 821 | return 8; |
| 822 | case TYPE_PRIORITY_PHONE: |
| 823 | // SIM errors and unlock. Not sure if this really should be in a high layer. |
| 824 | return 9; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 825 | case TYPE_SYSTEM_ALERT: |
| 826 | // like the ANR / app crashed dialogs |
| 827 | return canAddInternalSystemWindow ? 11 : 10; |
| 828 | case TYPE_APPLICATION_OVERLAY: |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 829 | return 12; |
| 830 | case TYPE_DREAM: |
| 831 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 832 | return 13; |
| 833 | case TYPE_INPUT_METHOD: |
| 834 | // on-screen keyboards and other such input method user interfaces go here. |
| 835 | return 14; |
| 836 | case TYPE_INPUT_METHOD_DIALOG: |
| 837 | // on-screen keyboards and other such input method user interfaces go here. |
| 838 | return 15; |
| 839 | case TYPE_STATUS_BAR_SUB_PANEL: |
| 840 | return 17; |
| 841 | case TYPE_STATUS_BAR: |
| 842 | return 18; |
| 843 | case TYPE_STATUS_BAR_PANEL: |
| 844 | return 19; |
| 845 | case TYPE_KEYGUARD_DIALOG: |
| 846 | return 20; |
| 847 | case TYPE_VOLUME_OVERLAY: |
| 848 | // the on-screen volume indicator and controller shown when the user |
| 849 | // changes the device volume |
| 850 | return 21; |
| 851 | case TYPE_SYSTEM_OVERLAY: |
| 852 | // the on-screen volume indicator and controller shown when the user |
| 853 | // changes the device volume |
| 854 | return canAddInternalSystemWindow ? 22 : 11; |
| 855 | case TYPE_NAVIGATION_BAR: |
| 856 | // the navigation bar, if available, shows atop most things |
| 857 | return 23; |
| 858 | case TYPE_NAVIGATION_BAR_PANEL: |
| 859 | // some panels (e.g. search) need to show on top of the navigation bar |
| 860 | return 24; |
| 861 | case TYPE_SCREENSHOT: |
| 862 | // screenshot selection layer shouldn't go above system error, but it should cover |
| 863 | // navigation bars at the very least. |
| 864 | return 25; |
| 865 | case TYPE_SYSTEM_ERROR: |
| 866 | // system-level error dialogs |
| 867 | return canAddInternalSystemWindow ? 26 : 10; |
| 868 | case TYPE_MAGNIFICATION_OVERLAY: |
| 869 | // used to highlight the magnified portion of a display |
| 870 | return 27; |
| 871 | case TYPE_DISPLAY_OVERLAY: |
| 872 | // used to simulate secondary display devices |
| 873 | return 28; |
| 874 | case TYPE_DRAG: |
| 875 | // the drag layer: input for drag-and-drop is associated with this window, |
| 876 | // which sits above all other focusable windows |
| 877 | return 29; |
| 878 | case TYPE_ACCESSIBILITY_OVERLAY: |
| 879 | // overlay put by accessibility services to intercept user interaction |
| 880 | return 30; |
| 881 | case TYPE_SECURE_SYSTEM_OVERLAY: |
| 882 | return 31; |
| 883 | case TYPE_BOOT_PROGRESS: |
| 884 | return 32; |
| 885 | case TYPE_POINTER: |
| 886 | // the (mouse) pointer layer |
| 887 | return 33; |
| 888 | default: |
| 889 | Slog.e("WindowManager", "Unknown window type: " + type); |
| 890 | return APPLICATION_LAYER; |
| 891 | } |
| 892 | } |
| 893 | |
| 894 | int APPLICATION_LAYER = 2; |
| 895 | int APPLICATION_MEDIA_SUBLAYER = -2; |
| 896 | int APPLICATION_MEDIA_OVERLAY_SUBLAYER = -1; |
| 897 | int APPLICATION_PANEL_SUBLAYER = 1; |
| 898 | int APPLICATION_SUB_PANEL_SUBLAYER = 2; |
| 899 | int APPLICATION_ABOVE_SUB_PANEL_SUBLAYER = 3; |
| 900 | |
| 901 | /** |
| 902 | * Return how to Z-order sub-windows in relation to the window they are attached to. |
| 903 | * Return positive to have them ordered in front, negative for behind. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 904 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 905 | * @param type The sub-window type code. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 906 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 907 | * @return int Layer in relation to the attached window, where positive is |
| 908 | * above and negative is below. |
| 909 | */ |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 910 | default int getSubWindowLayerFromTypeLw(int type) { |
| 911 | switch (type) { |
| 912 | case TYPE_APPLICATION_PANEL: |
| 913 | case TYPE_APPLICATION_ATTACHED_DIALOG: |
| 914 | return APPLICATION_PANEL_SUBLAYER; |
| 915 | case TYPE_APPLICATION_MEDIA: |
| 916 | return APPLICATION_MEDIA_SUBLAYER; |
| 917 | case TYPE_APPLICATION_MEDIA_OVERLAY: |
| 918 | return APPLICATION_MEDIA_OVERLAY_SUBLAYER; |
| 919 | case TYPE_APPLICATION_SUB_PANEL: |
| 920 | return APPLICATION_SUB_PANEL_SUBLAYER; |
| 921 | case TYPE_APPLICATION_ABOVE_SUB_PANEL: |
| 922 | return APPLICATION_ABOVE_SUB_PANEL_SUBLAYER; |
| 923 | } |
| 924 | Slog.e("WindowManager", "Unknown sub-window type: " + type); |
| 925 | return 0; |
| 926 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 927 | |
| 928 | /** |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 929 | * Get the highest layer (actually one more than) that the wallpaper is |
| 930 | * allowed to be in. |
| 931 | */ |
| 932 | public int getMaxWallpaperLayer(); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 933 | |
| 934 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 935 | * Return the display width available after excluding any screen |
Jorim Jaggi | 82c9dc9 | 2016-02-05 15:10:33 -0800 | [diff] [blame] | 936 | * decorations that could never be removed in Honeycomb. That is, system bar or |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 937 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 938 | */ |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 939 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, |
Andrii Kulian | db8e106 | 2016-11-15 18:30:27 -0800 | [diff] [blame] | 940 | int uiMode, int displayId); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 941 | |
| 942 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 943 | * Return the display height available after excluding any screen |
Jorim Jaggi | 82c9dc9 | 2016-02-05 15:10:33 -0800 | [diff] [blame] | 944 | * decorations that could never be removed in Honeycomb. That is, system bar or |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 945 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 946 | */ |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 947 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, |
Andrii Kulian | db8e106 | 2016-11-15 18:30:27 -0800 | [diff] [blame] | 948 | int uiMode, int displayId); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 949 | |
| 950 | /** |
| 951 | * Return the available screen width that we should report for the |
| 952 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 953 | * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 954 | * that to account for more transient decoration like a status bar. |
| 955 | */ |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 956 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation, |
Andrii Kulian | db8e106 | 2016-11-15 18:30:27 -0800 | [diff] [blame] | 957 | int uiMode, int displayId); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 958 | |
| 959 | /** |
| 960 | * Return the available screen height that we should report for the |
| 961 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 962 | * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 963 | * that to account for more transient decoration like a status bar. |
| 964 | */ |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 965 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation, |
Andrii Kulian | db8e106 | 2016-11-15 18:30:27 -0800 | [diff] [blame] | 966 | int uiMode, int displayId); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 967 | |
| 968 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 969 | * Return whether the given window can become the Keyguard window. Typically returns true for |
| 970 | * the StatusBar. |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 971 | */ |
| 972 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs); |
| 973 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 974 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 975 | * @return whether {@param win} can be hidden by Keyguard |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 976 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 977 | public boolean canBeHiddenByKeyguardLw(WindowState win); |
Craig Mautner | 7d7808f | 2014-09-11 18:02:38 -0700 | [diff] [blame] | 978 | |
| 979 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 980 | * Called when the system would like to show a UI to indicate that an |
| 981 | * application is starting. You can use this to add a |
| 982 | * APPLICATION_STARTING_TYPE window with the given appToken to the window |
| 983 | * manager (using the normal window manager APIs) that will be shown until |
| 984 | * the application displays its own window. This is called without the |
| 985 | * window manager locked so that you can call back into it. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 986 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 987 | * @param appToken Token of the application being started. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 988 | * @param packageName The name of the application package being started. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 989 | * @param theme Resource defining the application's overall visual theme. |
| 990 | * @param nonLocalizedLabel The default title label of the application if |
| 991 | * no data is found in the resource. |
| 992 | * @param labelRes The resource ID the application would like to use as its name. |
| 993 | * @param icon The resource ID the application would like to use as its icon. |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 994 | * @param windowFlags Window layout flags. |
Wale Ogunwale | dfc1862 | 2016-04-16 15:08:48 -0700 | [diff] [blame] | 995 | * @param overrideConfig override configuration to consider when generating |
| 996 | * context to for resources. |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 997 | * @param displayId Id of the display to show the splash screen at. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 998 | * |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 999 | * @return The starting surface. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1000 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1001 | */ |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 1002 | public StartingSurface addSplashScreen(IBinder appToken, String packageName, int theme, |
| 1003 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 1004 | int logo, int windowFlags, Configuration overrideConfig, int displayId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1005 | |
| 1006 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1007 | * Prepare for a window being added to the window manager. You can throw an |
| 1008 | * exception here to prevent the window being added, or do whatever setup |
| 1009 | * you need to keep track of the window. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1010 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1011 | * @param win The window being added. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1012 | * @param attrs The window's LayoutParams. |
| 1013 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1014 | * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1015 | * error code to abort the add. |
| 1016 | */ |
| 1017 | public int prepareAddWindowLw(WindowState win, |
| 1018 | WindowManager.LayoutParams attrs); |
| 1019 | |
| 1020 | /** |
| 1021 | * Called when a window is being removed from a window manager. Must not |
| 1022 | * throw an exception -- clean up as much as possible. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1023 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1024 | * @param win The window being removed. |
| 1025 | */ |
| 1026 | public void removeWindowLw(WindowState win); |
| 1027 | |
| 1028 | /** |
| 1029 | * Control the animation to run when a window's state changes. Return a |
| 1030 | * non-0 number to force the animation to a specific resource ID, or 0 |
| 1031 | * to use the default animation. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1032 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1033 | * @param win The window that is changing. |
| 1034 | * @param transit What is happening to the window: {@link #TRANSIT_ENTER}, |
| 1035 | * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or |
| 1036 | * {@link #TRANSIT_HIDE}. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1037 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1038 | * @return Resource ID of the actual animation to use, or 0 for none. |
| 1039 | */ |
| 1040 | public int selectAnimationLw(WindowState win, int transit); |
| 1041 | |
| 1042 | /** |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1043 | * Determine the animation to run for a rotation transition based on the |
| 1044 | * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation} |
| 1045 | * and whether it is currently fullscreen and frontmost. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1046 | * |
| 1047 | * @param anim The exiting animation resource id is stored in anim[0], the |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1048 | * entering animation resource id is stored in anim[1]. |
| 1049 | */ |
| 1050 | public void selectRotationAnimationLw(int anim[]); |
| 1051 | |
| 1052 | /** |
| 1053 | * Validate whether the current top fullscreen has specified the same |
| 1054 | * {@link WindowManager.LayoutParams#rotationAnimation} value as that |
| 1055 | * being passed in from the previous top fullscreen window. |
| 1056 | * |
| 1057 | * @param exitAnimId exiting resource id from the previous window. |
| 1058 | * @param enterAnimId entering resource id from the previous window. |
| 1059 | * @param forceDefault For rotation animations only, if true ignore the |
| 1060 | * animation values and just return false. |
| 1061 | * @return true if the previous values are still valid, false if they |
| 1062 | * should be replaced with the default. |
| 1063 | */ |
| 1064 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 1065 | boolean forceDefault); |
| 1066 | |
| 1067 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1068 | * Create and return an animation to re-display a window that was force hidden by Keyguard. |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 1069 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1070 | public Animation createHiddenByKeyguardExit(boolean onWallpaper, |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 1071 | boolean goingToNotificationShade); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 1072 | |
| 1073 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1074 | * Create and return an animation to let the wallpaper disappear after being shown behind |
| 1075 | * Keyguard. |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 1076 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1077 | public Animation createKeyguardWallpaperExit(boolean goingToNotificationShade); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 1078 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 1079 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1080 | * Called from the input reader thread before a key is enqueued. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1081 | * |
| 1082 | * <p>There are some actions that need to be handled here because they |
| 1083 | * affect the power state of the device, for example, the power keys. |
| 1084 | * Generally, it's best to keep as little as possible in the queue thread |
| 1085 | * because it's the most fragile. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1086 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1087 | * @param policyFlags The policy flags associated with the key. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1088 | * |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 1089 | * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1090 | */ |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 1091 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1092 | |
| 1093 | /** |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 1094 | * Called from the input reader thread before a motion is enqueued when the device is in a |
| 1095 | * non-interactive state. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1096 | * |
| 1097 | * <p>There are some actions that need to be handled here because they |
| 1098 | * affect the power state of the device, for example, waking on motions. |
| 1099 | * Generally, it's best to keep as little as possible in the queue thread |
| 1100 | * because it's the most fragile. |
| 1101 | * @param policyFlags The policy flags associated with the motion. |
| 1102 | * |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 1103 | * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1104 | */ |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 1105 | public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1106 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1107 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1108 | * Called from the input dispatcher thread before a key is dispatched to a window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1109 | * |
| 1110 | * <p>Allows you to define |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1111 | * behavior for keys that can not be overridden by applications. |
| 1112 | * This method is called from the input thread, with no locks held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1113 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1114 | * @param win The window that currently has focus. This is where the key |
| 1115 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1116 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1117 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1118 | * @return 0 if the key should be dispatched immediately, -1 if the key should |
| 1119 | * not be dispatched ever, or a positive value indicating the number of |
| 1120 | * milliseconds by which the key dispatch should be delayed before trying |
| 1121 | * again. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1122 | */ |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1123 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1124 | |
| 1125 | /** |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1126 | * Called from the input dispatcher thread when an application did not handle |
| 1127 | * a key that was dispatched to it. |
| 1128 | * |
| 1129 | * <p>Allows you to define default global behavior for keys that were not handled |
| 1130 | * by applications. This method is called from the input thread, with no locks held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1131 | * |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1132 | * @param win The window that currently has focus. This is where the key |
| 1133 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1134 | * @param event The key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1135 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1136 | * @return Returns an alternate key event to redispatch as a fallback, or null to give up. |
| 1137 | * The caller is responsible for recycling the key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1138 | */ |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1139 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1140 | |
| 1141 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1142 | * Called when layout of the windows is about to start. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1143 | * |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1144 | * @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1145 | * @param displayWidth The current full width of the screen. |
| 1146 | * @param displayHeight The current full height of the screen. |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1147 | * @param displayRotation The current rotation being applied to the base window. |
| 1148 | * @param uiMode The current uiMode in configuration. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1149 | */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1150 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
Sriram Viswanathan | 9ebbe6a | 2015-11-16 17:59:22 -0800 | [diff] [blame] | 1151 | int displayRotation, int uiMode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1152 | |
| 1153 | /** |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 1154 | * Returns the bottom-most layer of the system decor, above which no policy decor should |
| 1155 | * be applied. |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1156 | */ |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 1157 | public int getSystemDecorLayerLw(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1158 | |
| 1159 | /** |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 1160 | * Return the rectangle of the screen that is available for applications to run in. |
| 1161 | * This will be called immediately after {@link #beginLayoutLw}. |
| 1162 | * |
| 1163 | * @param r The rectangle to be filled with the boundaries available to applications. |
| 1164 | */ |
| 1165 | public void getContentRectLw(Rect r); |
| 1166 | |
| 1167 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1168 | * Called for each window attached to the window manager as layout is |
| 1169 | * proceeding. The implementation of this function must take care of |
| 1170 | * setting the window's frame, either here or in finishLayout(). |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1171 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1172 | * @param win The window being positioned. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1173 | * @param attached For sub-windows, the window it is attached to; this |
| 1174 | * window will already have had layoutWindow() called on it |
| 1175 | * so you can use its Rect. Otherwise null. |
| 1176 | */ |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 1177 | public void layoutWindowLw(WindowState win, WindowState attached); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1178 | |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1179 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1180 | /** |
| 1181 | * Return the insets for the areas covered by system windows. These values |
| 1182 | * are computed on the most recent layout, so they are not guaranteed to |
| 1183 | * be correct. |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 1184 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1185 | * @param attrs The LayoutParams of the window. |
Jorim Jaggi | 23bf546 | 2016-05-13 15:24:39 -0700 | [diff] [blame] | 1186 | * @param taskBounds The bounds of the task this window is on or {@code null} if no task is |
| 1187 | * associated with the window. |
| 1188 | * @param displayRotation Rotation of the display. |
| 1189 | * @param displayWidth The width of the display. |
| 1190 | * @param displayHeight The height of the display. |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 1191 | * @param outContentInsets The areas covered by system windows, expressed as positive insets. |
| 1192 | * @param outStableInsets The areas covered by stable system windows irrespective of their |
| 1193 | * current visibility. Expressed as positive insets. |
Filip Gruszczynski | 0ec1328 | 2015-06-25 11:26:01 -0700 | [diff] [blame] | 1194 | * @param outOutsets The areas that are not real display, but we would like to treat as such. |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 1195 | * @return Whether to always consume the navigation bar. |
| 1196 | * See {@link #isNavBarForcedShownLw(WindowState)}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1197 | */ |
Jorim Jaggi | 23bf546 | 2016-05-13 15:24:39 -0700 | [diff] [blame] | 1198 | public boolean getInsetHintLw(WindowManager.LayoutParams attrs, Rect taskBounds, |
| 1199 | int displayRotation, int displayWidth, int displayHeight, Rect outContentInsets, |
| 1200 | Rect outStableInsets, Rect outOutsets); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 1201 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1202 | /** |
| 1203 | * Called when layout of the windows is finished. After this function has |
| 1204 | * returned, all windows given to layoutWindow() <em>must</em> have had a |
| 1205 | * frame assigned. |
| 1206 | */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 1207 | public void finishLayoutLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1208 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 1209 | /** Layout state may have changed (so another layout will be performed) */ |
| 1210 | static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001; |
| 1211 | /** Configuration state may have changed */ |
| 1212 | static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002; |
| 1213 | /** Wallpaper may need to move */ |
| 1214 | static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 1215 | /** Need to recompute animations */ |
| 1216 | static final int FINISH_LAYOUT_REDO_ANIM = 0x0008; |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1217 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1218 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 1219 | * Called following layout of all windows before each window has policy applied. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1220 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1221 | * @param displayWidth The current full width of the screen. |
| 1222 | * @param displayHeight The current full height of the screen. |
| 1223 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 1224 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1225 | |
| 1226 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 1227 | * Called following layout of all window to apply policy to each window. |
Yohei Yukawa | d1a0922 | 2015-06-30 16:22:05 -0700 | [diff] [blame] | 1228 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1229 | * @param win The window being positioned. |
Yohei Yukawa | d1a0922 | 2015-06-30 16:22:05 -0700 | [diff] [blame] | 1230 | * @param attrs The LayoutParams of the window. |
| 1231 | * @param attached For sub-windows, the window it is attached to. Otherwise null. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1232 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 1233 | public void applyPostLayoutPolicyLw(WindowState win, |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1234 | WindowManager.LayoutParams attrs, WindowState attached, WindowState imeTarget); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1235 | |
| 1236 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 1237 | * Called following layout of all windows and after policy has been applied |
| 1238 | * to each window. If in this function you do |
| 1239 | * something that may have modified the animation state of another window, |
| 1240 | * be sure to return non-zero in order to perform another pass through layout. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1241 | * |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 1242 | * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT}, |
| 1243 | * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER}, |
| 1244 | * or {@link #FINISH_LAYOUT_REDO_ANIM}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1245 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 1246 | public int finishPostLayoutPolicyLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1247 | |
| 1248 | /** |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 1249 | * Return true if it is okay to perform animations for an app transition |
| 1250 | * that is about to occur. You may return false for this if, for example, |
| 1251 | * the lock screen is currently displayed so the switch should happen |
| 1252 | * immediately. |
| 1253 | */ |
| 1254 | public boolean allowAppAnimationsLw(); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 1255 | |
| 1256 | |
| 1257 | /** |
| 1258 | * A new window has been focused. |
| 1259 | */ |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1260 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1261 | |
| 1262 | /** |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1263 | * Called when the device has started waking up. |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1264 | */ |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1265 | public void startedWakingUp(); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1266 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 1267 | /** |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1268 | * Called when the device has finished waking up. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1269 | */ |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1270 | public void finishedWakingUp(); |
| 1271 | |
| 1272 | /** |
| 1273 | * Called when the device has started going to sleep. |
| 1274 | * |
| 1275 | * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN}, |
| 1276 | * or {@link #OFF_BECAUSE_OF_TIMEOUT}. |
| 1277 | */ |
| 1278 | public void startedGoingToSleep(int why); |
| 1279 | |
| 1280 | /** |
| 1281 | * Called when the device has finished going to sleep. |
| 1282 | * |
| 1283 | * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN}, |
| 1284 | * or {@link #OFF_BECAUSE_OF_TIMEOUT}. |
| 1285 | */ |
| 1286 | public void finishedGoingToSleep(int why); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1287 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1288 | /** |
| 1289 | * Called when the device is about to turn on the screen to show content. |
| 1290 | * When waking up, this method will be called once after the call to wakingUp(). |
| 1291 | * When dozing, the method will be called sometime after the call to goingToSleep() and |
| 1292 | * may be called repeatedly in the case where the screen is pulsing on and off. |
| 1293 | * |
| 1294 | * Must call back on the listener to tell it when the higher-level system |
| 1295 | * is ready for the screen to go on (i.e. the lock screen is shown). |
| 1296 | */ |
| 1297 | public void screenTurningOn(ScreenOnListener screenOnListener); |
| 1298 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1299 | /** |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1300 | * Called when the device has actually turned on the screen, i.e. the display power state has |
| 1301 | * been set to ON and the screen is unblocked. |
| 1302 | */ |
| 1303 | public void screenTurnedOn(); |
| 1304 | |
| 1305 | /** |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 1306 | * Called when the display would like to be turned off. This gives policy a chance to do some |
| 1307 | * things before the display power state is actually changed to off. |
| 1308 | * |
| 1309 | * @param screenOffListener Must be called to tell that the display power state can actually be |
| 1310 | * changed now after policy has done its work. |
| 1311 | */ |
| 1312 | public void screenTurningOff(ScreenOffListener screenOffListener); |
| 1313 | |
| 1314 | /** |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1315 | * Called when the device has turned the screen off. |
| 1316 | */ |
| 1317 | public void screenTurnedOff(); |
| 1318 | |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 1319 | public interface ScreenOnListener { |
| 1320 | void onScreenOn(); |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 1321 | } |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 1322 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1323 | /** |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 1324 | * See {@link #screenTurnedOff} |
| 1325 | */ |
| 1326 | public interface ScreenOffListener { |
| 1327 | void onScreenOff(); |
| 1328 | } |
| 1329 | |
| 1330 | /** |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1331 | * Return whether the default display is on and not blocked by a black surface. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1332 | */ |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1333 | public boolean isScreenOn(); |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1334 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 1335 | /** |
Adrian Roos | 7c89480 | 2017-07-19 12:25:34 +0200 | [diff] [blame] | 1336 | * @return whether the device is currently allowed to animate. |
Adrian Roos | e94c15c | 2017-05-09 13:17:54 -0700 | [diff] [blame] | 1337 | * |
Adrian Roos | 7c89480 | 2017-07-19 12:25:34 +0200 | [diff] [blame] | 1338 | * Note: this can be true even if it is not appropriate to animate for reasons that are outside |
| 1339 | * of the policy's authority. |
Adrian Roos | e94c15c | 2017-05-09 13:17:54 -0700 | [diff] [blame] | 1340 | */ |
Adrian Roos | 7c89480 | 2017-07-19 12:25:34 +0200 | [diff] [blame] | 1341 | boolean okToAnimate(); |
Adrian Roos | e94c15c | 2017-05-09 13:17:54 -0700 | [diff] [blame] | 1342 | |
| 1343 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1344 | * Tell the policy that the lid switch has changed state. |
| 1345 | * @param whenNanos The time when the change occurred in uptime nanoseconds. |
| 1346 | * @param lidOpen True if the lid is now open. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1347 | */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1348 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 1349 | |
| 1350 | /** |
| 1351 | * Tell the policy that the camera lens has been covered or uncovered. |
| 1352 | * @param whenNanos The time when the change occurred in uptime nanoseconds. |
| 1353 | * @param lensCovered True if the lens is covered. |
| 1354 | */ |
| 1355 | public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered); |
| 1356 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1357 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1358 | * Tell the policy if anyone is requesting that keyguard not come on. |
| 1359 | * |
| 1360 | * @param enabled Whether keyguard can be on or not. does not actually |
| 1361 | * turn it on, unless it was previously disabled with this function. |
| 1362 | * |
| 1363 | * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard() |
| 1364 | * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard() |
| 1365 | */ |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1366 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1367 | public void enableKeyguard(boolean enabled); |
| 1368 | |
| 1369 | /** |
| 1370 | * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely} |
| 1371 | */ |
| 1372 | interface OnKeyguardExitResult { |
| 1373 | void onKeyguardExitResult(boolean success); |
| 1374 | } |
| 1375 | |
| 1376 | /** |
| 1377 | * Tell the policy if anyone is requesting the keyguard to exit securely |
| 1378 | * (this would be called after the keyguard was disabled) |
| 1379 | * @param callback Callback to send the result back. |
| 1380 | * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult) |
| 1381 | */ |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1382 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1383 | void exitKeyguardSecurely(OnKeyguardExitResult callback); |
| 1384 | |
| 1385 | /** |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 1386 | * isKeyguardLocked |
| 1387 | * |
| 1388 | * Return whether the keyguard is currently locked. |
| 1389 | * |
| 1390 | * @return true if in keyguard is locked. |
| 1391 | */ |
| 1392 | public boolean isKeyguardLocked(); |
| 1393 | |
| 1394 | /** |
| 1395 | * isKeyguardSecure |
| 1396 | * |
| 1397 | * Return whether the keyguard requires a password to unlock. |
Jim Miller | e4044bb | 2016-05-10 18:38:25 -0700 | [diff] [blame] | 1398 | * @param userId |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 1399 | * |
| 1400 | * @return true if in keyguard is secure. |
| 1401 | */ |
Jim Miller | e4044bb | 2016-05-10 18:38:25 -0700 | [diff] [blame] | 1402 | public boolean isKeyguardSecure(int userId); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 1403 | |
| 1404 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1405 | * Return whether the keyguard is currently occluded. |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 1406 | * |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1407 | * @return true if in keyguard is occluded, false otherwise |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 1408 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1409 | public boolean isKeyguardOccluded(); |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 1410 | |
| 1411 | /** |
Tony Mak | 2c0d6dc | 2016-04-29 16:16:54 +0100 | [diff] [blame] | 1412 | * @return true if in keyguard is on and not occluded. |
| 1413 | */ |
| 1414 | public boolean isKeyguardShowingAndNotOccluded(); |
| 1415 | |
| 1416 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1417 | * @return whether Keyguard is in trusted state and can be dismissed without credentials |
| 1418 | */ |
| 1419 | public boolean isKeyguardTrustedLw(); |
| 1420 | |
| 1421 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1422 | * inKeyguardRestrictedKeyInputMode |
| 1423 | * |
| 1424 | * if keyguard screen is showing or in restricted key input mode (i.e. in |
| 1425 | * keyguard password emergency screen). When in such mode, certain keys, |
| 1426 | * such as the Home key and the right soft keys, don't work. |
| 1427 | * |
| 1428 | * @return true if in keyguard restricted input mode. |
| 1429 | */ |
| 1430 | public boolean inKeyguardRestrictedKeyInputMode(); |
| 1431 | |
| 1432 | /** |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1433 | * Ask the policy to dismiss the keyguard, if it is currently shown. |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1434 | * |
| 1435 | * @param callback Callback to be informed about the result. |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1436 | */ |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1437 | public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1438 | |
| 1439 | /** |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 1440 | * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method |
| 1441 | * returns true as soon as we know that Keyguard is disabled. |
| 1442 | * |
| 1443 | * @return true if the keyguard has drawn. |
| 1444 | */ |
| 1445 | public boolean isKeyguardDrawnLw(); |
| 1446 | |
Jorim Jaggi | 77e1043 | 2016-10-26 17:43:56 -0700 | [diff] [blame] | 1447 | public boolean isShowingDreamLw(); |
| 1448 | |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 1449 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1450 | * Given an orientation constant, returns the appropriate surface rotation, |
| 1451 | * taking into account sensors, docking mode, rotation lock, and other factors. |
| 1452 | * |
| 1453 | * @param orientation An orientation constant, such as |
| 1454 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 1455 | * @param lastRotation The most recently used rotation. |
| 1456 | * @return The surface rotation to use. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1457 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1458 | public int rotationForOrientationLw(@ActivityInfo.ScreenOrientation int orientation, |
| 1459 | int lastRotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1460 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1461 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1462 | * Given an orientation constant and a rotation, returns true if the rotation |
| 1463 | * has compatible metrics to the requested orientation. For example, if |
| 1464 | * the application requested landscape and got seascape, then the rotation |
| 1465 | * has compatible metrics; if the application requested portrait and got landscape, |
| 1466 | * then the rotation has incompatible metrics; if the application did not specify |
| 1467 | * a preference, then anything goes. |
| 1468 | * |
| 1469 | * @param orientation An orientation constant, such as |
| 1470 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 1471 | * @param rotation The rotation to check. |
| 1472 | * @return True if the rotation is compatible with the requested orientation. |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1473 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1474 | public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation int orientation, |
| 1475 | int rotation); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1476 | |
| 1477 | /** |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 1478 | * Called by the window manager when the rotation changes. |
| 1479 | * |
| 1480 | * @param rotation The new rotation. |
| 1481 | */ |
| 1482 | public void setRotationLw(int rotation); |
| 1483 | |
| 1484 | /** |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1485 | * Called when the system is mostly done booting to set whether |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1486 | * the system should go into safe mode. |
| 1487 | */ |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1488 | public void setSafeMode(boolean safeMode); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1489 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1490 | /** |
| 1491 | * Called when the system is mostly done booting. |
| 1492 | */ |
| 1493 | public void systemReady(); |
| 1494 | |
| 1495 | /** |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 1496 | * Called when the system is done booting to the point where the |
| 1497 | * user can start interacting with it. |
| 1498 | */ |
| 1499 | public void systemBooted(); |
| 1500 | |
| 1501 | /** |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1502 | * Show boot time message to the user. |
| 1503 | */ |
| 1504 | public void showBootMessage(final CharSequence msg, final boolean always); |
| 1505 | |
| 1506 | /** |
| 1507 | * Hide the UI for showing boot messages, never to be displayed again. |
| 1508 | */ |
| 1509 | public void hideBootMessages(); |
| 1510 | |
| 1511 | /** |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 1512 | * Called when userActivity is signalled in the power manager. |
| 1513 | * This is safe to call from any thread, with any window manager locks held or not. |
| 1514 | */ |
| 1515 | public void userActivity(); |
| 1516 | |
| 1517 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1518 | * Called when we have finished booting and can now display the home |
Jeff Brown | c042ee2 | 2012-05-08 13:03:42 -0700 | [diff] [blame] | 1519 | * screen to the user. This will happen after systemReady(), and at |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1520 | * this point the display is active. |
| 1521 | */ |
| 1522 | public void enableScreenAfterBoot(); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1523 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1524 | public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1525 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1526 | /** |
| 1527 | * Call from application to perform haptic feedback on its window. |
| 1528 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 1529 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1530 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1531 | /** |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1532 | * Called when we have started keeping the screen on because a window |
| 1533 | * requesting this has become visible. |
| 1534 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1535 | public void keepScreenOnStartedLw(); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1536 | |
| 1537 | /** |
| 1538 | * Called when we have stopped keeping the screen on because the last window |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1539 | * requesting this is no longer visible. |
| 1540 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1541 | public void keepScreenOnStoppedLw(); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1542 | |
| 1543 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1544 | * Gets the current user rotation mode. |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 1545 | * |
| 1546 | * @return The rotation mode. |
| 1547 | * |
| 1548 | * @see WindowManagerPolicy#USER_ROTATION_LOCKED |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1549 | * @see WindowManagerPolicy#USER_ROTATION_FREE |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 1550 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1551 | @UserRotationMode |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 1552 | public int getUserRotationMode(); |
| 1553 | |
| 1554 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1555 | * Inform the policy that the user has chosen a preferred orientation ("rotation lock"). |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1556 | * |
| 1557 | * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1558 | * {@link WindowManagerPolicy#USER_ROTATION_FREE}. |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1559 | * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90}, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1560 | * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}. |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1561 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1562 | public void setUserRotationMode(@UserRotationMode int mode, @Surface.Rotation int rotation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1563 | |
| 1564 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1565 | * Called when a new system UI visibility is being reported, allowing |
| 1566 | * the policy to adjust what is actually reported. |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1567 | * @param visibility The raw visibility reported by the status bar. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1568 | * @return The new desired visibility. |
| 1569 | */ |
| 1570 | public int adjustSystemUiVisibilityLw(int visibility); |
| 1571 | |
| 1572 | /** |
Winson | ab21660 | 2016-08-09 14:05:20 -0700 | [diff] [blame] | 1573 | * Called by System UI to notify of changes to the visibility of Recents. |
| 1574 | */ |
| 1575 | public void setRecentsVisibilityLw(boolean visible); |
| 1576 | |
| 1577 | /** |
| 1578 | * Called by System UI to notify of changes to the visibility of PIP. |
| 1579 | */ |
Winson Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 1580 | void setPipVisibilityLw(boolean visible); |
Winson | ab21660 | 2016-08-09 14:05:20 -0700 | [diff] [blame] | 1581 | |
| 1582 | /** |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1583 | * Specifies whether there is an on-screen navigation bar separate from the status bar. |
| 1584 | */ |
| 1585 | public boolean hasNavigationBar(); |
| 1586 | |
| 1587 | /** |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1588 | * Lock the device now. |
| 1589 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1590 | public void lockNow(Bundle options); |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1591 | |
| 1592 | /** |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 1593 | * Set the last used input method window state. This state is used to make IME transition |
| 1594 | * smooth. |
| 1595 | * @hide |
| 1596 | */ |
| 1597 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target); |
| 1598 | |
| 1599 | /** |
Yohei Yukawa | d6475a6 | 2017-04-17 10:35:27 -0700 | [diff] [blame] | 1600 | * An internal callback (from InputMethodManagerService) to notify a state change regarding |
| 1601 | * whether the back key should dismiss the software keyboard (IME) or not. |
| 1602 | * |
| 1603 | * @param newValue {@code true} if the software keyboard is shown and the back key is expected |
| 1604 | * to dismiss the software keyboard. |
| 1605 | * @hide |
| 1606 | */ |
| 1607 | default void setDismissImeOnBackKeyPressed(boolean newValue) { |
| 1608 | // Default implementation does nothing. |
| 1609 | } |
| 1610 | |
| 1611 | /** |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 1612 | * Show the recents task list app. |
| 1613 | * @hide |
| 1614 | */ |
Jorim Jaggi | 681fc7b | 2016-04-14 22:02:39 -0700 | [diff] [blame] | 1615 | public void showRecentApps(boolean fromHome); |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 1616 | |
| 1617 | /** |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 1618 | * Show the global actions dialog. |
| 1619 | * @hide |
| 1620 | */ |
| 1621 | public void showGlobalActions(); |
| 1622 | |
| 1623 | /** |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 1624 | * @return The current height of the input method window. |
| 1625 | */ |
| 1626 | public int getInputMethodWindowVisibleHeightLw(); |
| 1627 | |
| 1628 | /** |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1629 | * Called when the current user changes. Guaranteed to be called before the broadcast |
| 1630 | * of the new user id is made to all listeners. |
| 1631 | * |
| 1632 | * @param newUserId The id of the incoming user. |
| 1633 | */ |
| 1634 | public void setCurrentUserLw(int newUserId); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1635 | |
| 1636 | /** |
Evan Rosky | 1839645 | 2016-07-27 15:19:37 -0700 | [diff] [blame] | 1637 | * For a given user-switch operation, this will be called once with switching=true before the |
| 1638 | * user-switch and once with switching=false afterwards (or if the user-switch was cancelled). |
| 1639 | * This gives the policy a chance to alter its behavior for the duration of a user-switch. |
| 1640 | * |
| 1641 | * @param switching true if a user-switch is in progress |
| 1642 | */ |
| 1643 | void setSwitchingUser(boolean switching); |
| 1644 | |
| 1645 | /** |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1646 | * Print the WindowManagerPolicy's state into the given stream. |
| 1647 | * |
| 1648 | * @param prefix Text to print at the front of each line. |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1649 | * @param writer The PrintWriter to which you should dump your state. This will be |
| 1650 | * closed for you after you return. |
| 1651 | * @param args additional arguments to the dump request. |
| 1652 | */ |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 1653 | public void dump(String prefix, PrintWriter writer, String[] args); |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 1654 | |
| 1655 | /** |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 1656 | * Returns whether a given window type can be magnified. |
| 1657 | * |
| 1658 | * @param windowType The window type. |
| 1659 | * @return True if the window can be magnified. |
| 1660 | */ |
| 1661 | public boolean canMagnifyWindow(int windowType); |
| 1662 | |
| 1663 | /** |
| 1664 | * Returns whether a given window type is considered a top level one. |
| 1665 | * A top level window does not have a container, i.e. attached window, |
| 1666 | * or if it has a container it is laid out as a top-level window, not |
| 1667 | * as a child of its container. |
| 1668 | * |
| 1669 | * @param windowType The window type. |
| 1670 | * @return True if the window is a top level one. |
| 1671 | */ |
| 1672 | public boolean isTopLevelWindow(int windowType); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1673 | |
| 1674 | /** |
| 1675 | * Notifies the keyguard to start fading out. |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1676 | * |
| 1677 | * @param startTime the start time of the animation in uptime milliseconds |
| 1678 | * @param fadeoutDuration the duration of the exit animation, in milliseconds |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1679 | */ |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1680 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 1681 | |
| 1682 | /** |
| 1683 | * Calculates the stable insets without running a layout. |
| 1684 | * |
| 1685 | * @param displayRotation the current display rotation |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 1686 | * @param displayWidth the current display width |
| 1687 | * @param displayHeight the current display height |
Winson | 3e87474 | 2016-01-07 10:08:17 -0800 | [diff] [blame] | 1688 | * @param outInsets the insets to return |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 1689 | */ |
| 1690 | public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, |
| 1691 | Rect outInsets); |
Jorim Jaggi | 82c9dc9 | 2016-02-05 15:10:33 -0800 | [diff] [blame] | 1692 | |
Jorim Jaggi | 0ffd49c | 2016-02-12 15:04:21 -0800 | [diff] [blame] | 1693 | |
| 1694 | /** |
| 1695 | * @return true if the navigation bar is forced to stay visible |
| 1696 | */ |
| 1697 | public boolean isNavBarForcedShownLw(WindowState win); |
| 1698 | |
Jorim Jaggi | 82c9dc9 | 2016-02-05 15:10:33 -0800 | [diff] [blame] | 1699 | /** |
Andrii Kulian | 3a1619d | 2017-07-07 14:38:09 -0700 | [diff] [blame] | 1700 | * @return The side of the screen where navigation bar is positioned. |
| 1701 | * @see #NAV_BAR_LEFT |
| 1702 | * @see #NAV_BAR_RIGHT |
| 1703 | * @see #NAV_BAR_BOTTOM |
| 1704 | */ |
| 1705 | int getNavBarPosition(); |
| 1706 | |
| 1707 | /** |
Jorim Jaggi | 82c9dc9 | 2016-02-05 15:10:33 -0800 | [diff] [blame] | 1708 | * Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system |
| 1709 | * bar or button bar. See {@link #getNonDecorDisplayWidth}. |
| 1710 | * |
| 1711 | * @param displayRotation the current display rotation |
| 1712 | * @param displayWidth the current display width |
| 1713 | * @param displayHeight the current display height |
| 1714 | * @param outInsets the insets to return |
| 1715 | */ |
| 1716 | public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, |
| 1717 | Rect outInsets); |
Jorim Jaggi | 5060bd8 | 2016-02-19 17:12:19 -0800 | [diff] [blame] | 1718 | |
| 1719 | /** |
| 1720 | * @return True if a specified {@param dockSide} is allowed on the current device, or false |
| 1721 | * otherwise. It is guaranteed that at least one dock side for a particular orientation |
| 1722 | * is allowed, so for example, if DOCKED_RIGHT is not allowed, DOCKED_LEFT is allowed. |
| 1723 | */ |
| 1724 | public boolean isDockSideAllowed(int dockSide); |
Jorim Jaggi | 11c62e1 | 2016-04-05 20:41:21 -0700 | [diff] [blame] | 1725 | |
| 1726 | /** |
| 1727 | * Called when the configuration has changed, and it's safe to load new values from resources. |
| 1728 | */ |
| 1729 | public void onConfigurationChanged(); |
Robert Carr | 6da3cc0 | 2016-06-16 15:17:07 -0700 | [diff] [blame] | 1730 | |
| 1731 | public boolean shouldRotateSeamlessly(int oldRotation, int newRotation); |
Keun-young Park | 4136d2d | 2017-05-08 14:51:59 -0700 | [diff] [blame] | 1732 | |
| 1733 | /** |
| 1734 | * Called when System UI has been started. |
| 1735 | */ |
| 1736 | void onSystemUiStarted(); |
| 1737 | |
| 1738 | /** |
| 1739 | * Checks whether the policy is ready for dismissing the boot animation and completing the boot. |
| 1740 | * |
| 1741 | * @return true if ready; false otherwise. |
| 1742 | */ |
| 1743 | boolean canDismissBootAnimation(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1744 | } |