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 | |
| 19 | import android.content.Context; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 20 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.res.Configuration; |
| 22 | import android.graphics.Rect; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 23 | import android.graphics.RectF; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 24 | import android.os.Bundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.os.IBinder; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 26 | import android.os.Looper; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.view.animation.Animation; |
| 28 | |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 29 | import java.io.PrintWriter; |
| 30 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | /** |
| 32 | * This interface supplies all UI-specific behavior of the window manager. An |
| 33 | * instance of it is created by the window manager when it starts up, and allows |
| 34 | * customization of window layering, special window types, key dispatching, and |
| 35 | * layout. |
| 36 | * |
| 37 | * <p>Because this provides deep interaction with the system window manager, |
| 38 | * specific methods on this interface can be called from a variety of contexts |
| 39 | * with various restrictions on what they can do. These are encoded through |
| 40 | * a suffixes at the end of a method encoding the thread the method is called |
| 41 | * from and any locks that are held when it is being called; if no suffix |
| 42 | * is attached to a method, then it is not called with any locks and may be |
| 43 | * called from the main window manager thread or another thread calling into |
| 44 | * the window manager. |
| 45 | * |
| 46 | * <p>The current suffixes are: |
| 47 | * |
| 48 | * <dl> |
| 49 | * <dt> Ti <dd> Called from the input thread. This is the thread that |
| 50 | * collects pending input events and dispatches them to the appropriate window. |
| 51 | * It may block waiting for events to be processed, so that the input stream is |
| 52 | * properly serialized. |
| 53 | * <dt> Tq <dd> Called from the low-level input queue thread. This is the |
| 54 | * thread that reads events out of the raw input devices and places them |
| 55 | * into the global input queue that is read by the <var>Ti</var> thread. |
| 56 | * This thread should not block for a long period of time on anything but the |
| 57 | * key driver. |
| 58 | * <dt> Lw <dd> Called with the main window manager lock held. Because the |
| 59 | * window manager is a very low-level system service, there are few other |
| 60 | * system services you can call with this lock held. It is explicitly okay to |
| 61 | * 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] | 62 | * 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] | 63 | * {@link android.content.Context#checkPermission(String, int, int)} and |
| 64 | * variations require calling into the activity manager. |
| 65 | * <dt> Li <dd> Called with the input thread lock held. This lock can be |
| 66 | * acquired by the window manager while it holds the window lock, so this is |
| 67 | * even more restrictive than <var>Lw</var>. |
| 68 | * </dl> |
| 69 | * |
| 70 | * @hide |
| 71 | */ |
| 72 | public interface WindowManagerPolicy { |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 73 | // 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] | 74 | public final static int FLAG_WAKE = 0x00000001; |
| 75 | public final static int FLAG_WAKE_DROPPED = 0x00000002; |
| 76 | public final static int FLAG_SHIFT = 0x00000004; |
| 77 | public final static int FLAG_CAPS_LOCK = 0x00000008; |
| 78 | public final static int FLAG_ALT = 0x00000010; |
| 79 | public final static int FLAG_ALT_GR = 0x00000020; |
| 80 | public final static int FLAG_MENU = 0x00000040; |
| 81 | public final static int FLAG_LAUNCHER = 0x00000080; |
Jeff Brown | 0eaf393 | 2010-10-01 14:55:30 -0700 | [diff] [blame] | 82 | public final static int FLAG_VIRTUAL = 0x00000100; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 84 | public final static int FLAG_INJECTED = 0x01000000; |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 85 | public final static int FLAG_TRUSTED = 0x02000000; |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 86 | public final static int FLAG_FILTERED = 0x04000000; |
| 87 | public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000; |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 88 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | public final static int FLAG_WOKE_HERE = 0x10000000; |
| 90 | public final static int FLAG_BRIGHT_HERE = 0x20000000; |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 91 | public final static int FLAG_PASS_TO_USER = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 93 | // Flags used for indicating whether the internal and/or external input devices |
| 94 | // of some type are available. |
| 95 | public final static int PRESENCE_INTERNAL = 1 << 0; |
| 96 | public final static int PRESENCE_EXTERNAL = 1 << 1; |
| 97 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | public final static boolean WATCH_POINTER = false; |
| 99 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 100 | /** |
| 101 | * Sticky broadcast of the current HDMI plugged state. |
| 102 | */ |
| 103 | public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED"; |
| 104 | |
| 105 | /** |
| 106 | * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if |
| 107 | * plugged in to HDMI, false if not. |
| 108 | */ |
| 109 | public final static String EXTRA_HDMI_PLUGGED_STATE = "state"; |
| 110 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | /** |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 112 | * Pass this event to the user / app. To be returned from |
| 113 | * {@link #interceptKeyBeforeQueueing}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | */ |
| 115 | public final static int ACTION_PASS_TO_USER = 0x00000001; |
| 116 | |
| 117 | /** |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 118 | * This key event should wake the device. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 119 | * To be returned from {@link #interceptKeyBeforeQueueing}. |
| 120 | * Do not return this and {@link #ACTION_GO_TO_SLEEP} or {@link #ACTION_PASS_TO_USER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | */ |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 122 | public final static int ACTION_WAKE_UP = 0x00000002; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * This key event should put the device to sleep (and engage keyguard if necessary) |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 126 | * To be returned from {@link #interceptKeyBeforeQueueing}. |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 127 | * Do not return this and {@link #ACTION_WAKE_UP} or {@link #ACTION_PASS_TO_USER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 128 | */ |
| 129 | public final static int ACTION_GO_TO_SLEEP = 0x00000004; |
| 130 | |
| 131 | /** |
| 132 | * Interface to the Window Manager state associated with a particular |
| 133 | * window. You can hold on to an instance of this interface from the call |
| 134 | * to prepareAddWindow() until removeWindow(). |
| 135 | */ |
| 136 | public interface WindowState { |
| 137 | /** |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 138 | * Return the uid of the app that owns this window. |
| 139 | */ |
| 140 | int getOwningUid(); |
| 141 | |
| 142 | /** |
| 143 | * Return the package name of the app that owns this window. |
| 144 | */ |
| 145 | String getOwningPackage(); |
| 146 | |
| 147 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | * Perform standard frame computation. The result can be obtained with |
| 149 | * getFrame() if so desired. Must be called with the window manager |
| 150 | * lock held. |
| 151 | * |
| 152 | * @param parentFrame The frame of the parent container this window |
| 153 | * is in, used for computing its basic position. |
| 154 | * @param displayFrame The frame of the overall display in which this |
| 155 | * window can appear, used for constraining the overall dimensions |
| 156 | * of the window. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 157 | * @param overlayFrame The frame within the display that is inside |
| 158 | * of the overlay region. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 159 | * @param contentFrame The frame within the display in which we would |
| 160 | * like active content to appear. This will cause windows behind to |
| 161 | * be resized to match the given content frame. |
| 162 | * @param visibleFrame The frame within the display that the window |
| 163 | * is actually visible, used for computing its visible insets to be |
| 164 | * given to windows behind. |
| 165 | * This can be used as a hint for scrolling (avoiding resizing) |
| 166 | * the window to make certain that parts of its content |
| 167 | * are visible. |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 168 | * @param decorFrame The decor frame specified by policy specific to this window, |
| 169 | * to use for proper cropping during animation. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 170 | */ |
| 171 | public void computeFrameLw(Rect parentFrame, Rect displayFrame, |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 172 | Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * Retrieve the current frame of the window that has been assigned by |
| 176 | * the window manager. Must be called with the window manager lock held. |
| 177 | * |
| 178 | * @return Rect The rectangle holding the window frame. |
| 179 | */ |
| 180 | public Rect getFrameLw(); |
| 181 | |
| 182 | /** |
| 183 | * Retrieve the current frame of the window that is actually shown. |
| 184 | * Must be called with the window manager lock held. |
| 185 | * |
| 186 | * @return Rect The rectangle holding the shown window frame. |
| 187 | */ |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 188 | public RectF getShownFrameLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 189 | |
| 190 | /** |
| 191 | * Retrieve the frame of the display that this window was last |
| 192 | * laid out in. Must be called with the |
| 193 | * window manager lock held. |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 194 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | * @return Rect The rectangle holding the display frame. |
| 196 | */ |
| 197 | public Rect getDisplayFrameLw(); |
| 198 | |
| 199 | /** |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 200 | * Retrieve the frame of the area inside the overscan region of the |
| 201 | * display that this window was last laid out in. Must be called with the |
| 202 | * window manager lock held. |
| 203 | * |
| 204 | * @return Rect The rectangle holding the display overscan frame. |
| 205 | */ |
| 206 | public Rect getOverscanFrameLw(); |
| 207 | |
| 208 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 209 | * Retrieve the frame of the content area that this window was last |
| 210 | * laid out in. This is the area in which the content of the window |
| 211 | * should be placed. It will be smaller than the display frame to |
| 212 | * account for screen decorations such as a status bar or soft |
| 213 | * keyboard. Must be called with the |
| 214 | * window manager lock held. |
| 215 | * |
| 216 | * @return Rect The rectangle holding the content frame. |
| 217 | */ |
| 218 | public Rect getContentFrameLw(); |
| 219 | |
| 220 | /** |
| 221 | * Retrieve the frame of the visible area that this window was last |
| 222 | * laid out in. This is the area of the screen in which the window |
| 223 | * will actually be fully visible. It will be smaller than the |
| 224 | * content frame to account for transient UI elements blocking it |
| 225 | * such as an input method's candidates UI. Must be called with the |
| 226 | * window manager lock held. |
| 227 | * |
| 228 | * @return Rect The rectangle holding the visible frame. |
| 229 | */ |
| 230 | public Rect getVisibleFrameLw(); |
| 231 | |
| 232 | /** |
| 233 | * Returns true if this window is waiting to receive its given |
| 234 | * internal insets from the client app, and so should not impact the |
| 235 | * layout of other windows. |
| 236 | */ |
| 237 | public boolean getGivenInsetsPendingLw(); |
| 238 | |
| 239 | /** |
| 240 | * Retrieve the insets given by this window's client for the content |
| 241 | * area of windows behind it. Must be called with the |
| 242 | * window manager lock held. |
| 243 | * |
| 244 | * @return Rect The left, top, right, and bottom insets, relative |
| 245 | * to the window's frame, of the actual contents. |
| 246 | */ |
| 247 | public Rect getGivenContentInsetsLw(); |
| 248 | |
| 249 | /** |
| 250 | * Retrieve the insets given by this window's client for the visible |
| 251 | * area of windows behind it. Must be called with the |
| 252 | * window manager lock held. |
| 253 | * |
| 254 | * @return Rect The left, top, right, and bottom insets, relative |
| 255 | * to the window's frame, of the actual visible area. |
| 256 | */ |
| 257 | public Rect getGivenVisibleInsetsLw(); |
| 258 | |
| 259 | /** |
| 260 | * Retrieve the current LayoutParams of the window. |
| 261 | * |
| 262 | * @return WindowManager.LayoutParams The window's internal LayoutParams |
| 263 | * instance. |
| 264 | */ |
| 265 | public WindowManager.LayoutParams getAttrs(); |
| 266 | |
| 267 | /** |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 268 | * Return whether this window needs the menu key shown. Must be called |
| 269 | * with window lock held, because it may need to traverse down through |
| 270 | * window list to determine the result. |
| 271 | * @param bottom The bottom-most window to consider when determining this. |
| 272 | */ |
| 273 | public boolean getNeedsMenuLw(WindowState bottom); |
| 274 | |
| 275 | /** |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 276 | * Retrieve the current system UI visibility flags associated with |
| 277 | * this window. |
| 278 | */ |
| 279 | public int getSystemUiVisibility(); |
| 280 | |
| 281 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 282 | * Get the layer at which this window's surface will be Z-ordered. |
| 283 | */ |
| 284 | public int getSurfaceLayer(); |
| 285 | |
| 286 | /** |
| 287 | * Return the token for the application (actually activity) that owns |
| 288 | * this window. May return null for system windows. |
| 289 | * |
| 290 | * @return An IApplicationToken identifying the owning activity. |
| 291 | */ |
| 292 | public IApplicationToken getAppToken(); |
| 293 | |
| 294 | /** |
| 295 | * Return true if, at any point, the application token associated with |
| 296 | * this window has actually displayed any windows. This is most useful |
| 297 | * with the "starting up" window to determine if any windows were |
| 298 | * displayed when it is closed. |
| 299 | * |
| 300 | * @return Returns true if one or more windows have been displayed, |
| 301 | * else false. |
| 302 | */ |
| 303 | public boolean hasAppShownWindows(); |
| 304 | |
| 305 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 306 | * Is this window visible? It is not visible if there is no |
| 307 | * surface, or we are in the process of running an exit animation |
| 308 | * that will remove the surface. |
| 309 | */ |
| 310 | boolean isVisibleLw(); |
| 311 | |
| 312 | /** |
Dianne Hackborn | 3d163f07 | 2009-10-07 21:26:57 -0700 | [diff] [blame] | 313 | * Like {@link #isVisibleLw}, but also counts a window that is currently |
| 314 | * "hidden" behind the keyguard as visible. This allows us to apply |
| 315 | * things like window flags that impact the keyguard. |
| 316 | */ |
| 317 | boolean isVisibleOrBehindKeyguardLw(); |
| 318 | |
| 319 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 320 | * Is this window currently visible to the user on-screen? It is |
| 321 | * displayed either if it is visible or it is currently running an |
| 322 | * animation before no longer being visible. Must be called with the |
| 323 | * window manager lock held. |
| 324 | */ |
| 325 | boolean isDisplayedLw(); |
| 326 | |
| 327 | /** |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 328 | * Return true if this window (or a window it is attached to, but not |
| 329 | * considering its app token) is currently animating. |
| 330 | */ |
| 331 | public boolean isAnimatingLw(); |
| 332 | |
| 333 | /** |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 334 | * Is this window considered to be gone for purposes of layout? |
| 335 | */ |
| 336 | boolean isGoneForLayoutLw(); |
| 337 | |
| 338 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 339 | * Returns true if this window has been shown on screen at some time in |
| 340 | * 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] | 341 | */ |
| 342 | public boolean hasDrawnLw(); |
| 343 | |
| 344 | /** |
| 345 | * Can be called by the policy to force a window to be hidden, |
| 346 | * regardless of whether the client or window manager would like |
| 347 | * it shown. Must be called with the window manager lock held. |
| 348 | * Returns true if {@link #showLw} was last called for the window. |
| 349 | */ |
| 350 | public boolean hideLw(boolean doAnimation); |
| 351 | |
| 352 | /** |
| 353 | * Can be called to undo the effect of {@link #hideLw}, allowing a |
| 354 | * window to be shown as long as the window manager and client would |
| 355 | * also like it to be shown. Must be called with the window manager |
| 356 | * lock held. |
| 357 | * Returns true if {@link #hideLw} was last called for the window. |
| 358 | */ |
| 359 | public boolean showLw(boolean doAnimation); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 360 | |
| 361 | /** |
| 362 | * Check whether the process hosting this window is currently alive. |
| 363 | */ |
| 364 | public boolean isAlive(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 365 | |
| 366 | /** |
| 367 | * Check if window is on {@link Display#DEFAULT_DISPLAY}. |
| 368 | * @return true if window is on default display. |
| 369 | */ |
| 370 | public boolean isDefaultDisplay(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 371 | } |
| 372 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 373 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 374 | * Representation of a "fake window" that the policy has added to the |
| 375 | * window manager to consume events. |
| 376 | */ |
| 377 | public interface FakeWindow { |
| 378 | /** |
| 379 | * Remove the fake window from the window manager. |
| 380 | */ |
| 381 | void dismiss(); |
| 382 | } |
| 383 | |
| 384 | /** |
| 385 | * Interface for calling back in to the window manager that is private |
| 386 | * between it and the policy. |
| 387 | */ |
| 388 | public interface WindowManagerFuncs { |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 389 | public static final int LID_ABSENT = -1; |
| 390 | public static final int LID_CLOSED = 0; |
| 391 | public static final int LID_OPEN = 1; |
| 392 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 393 | /** |
| 394 | * Ask the window manager to re-evaluate the system UI flags. |
| 395 | */ |
| 396 | public void reevaluateStatusBarVisibility(); |
| 397 | |
| 398 | /** |
| 399 | * Add a fake window to the window manager. This window sits |
| 400 | * at the top of the other windows and consumes events. |
| 401 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 402 | public FakeWindow addFakeWindow(Looper looper, |
| 403 | InputEventReceiver.Factory inputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 404 | String name, int windowType, int layoutParamsFlags, int layoutParamsPrivateFlags, |
| 405 | boolean canReceiveKeys, boolean hasFocus, boolean touchFullscreen); |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 406 | |
| 407 | /** |
| 408 | * Returns a code that describes the current state of the lid switch. |
| 409 | */ |
| 410 | public int getLidState(); |
| 411 | |
| 412 | /** |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 413 | * Switch the keyboard layout for the given device. |
| 414 | * Direction should be +1 or -1 to go to the next or previous keyboard layout. |
| 415 | */ |
| 416 | public void switchKeyboardLayout(int deviceId, int direction); |
| 417 | |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 418 | public void shutdown(boolean confirm); |
| 419 | public void rebootSafeMode(boolean confirm); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 420 | |
| 421 | /** |
| 422 | * Return the window manager lock needed to correctly call "Lw" methods. |
| 423 | */ |
| 424 | public Object getWindowManagerLock(); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 425 | |
| 426 | /** Register a system listener for touch events */ |
| 427 | void registerPointerEventListener(PointerEventListener listener); |
| 428 | |
| 429 | /** Unregister a system listener for touch events */ |
| 430 | void unregisterPointerEventListener(PointerEventListener listener); |
| 431 | } |
| 432 | |
| 433 | public interface PointerEventListener { |
| 434 | /** |
| 435 | * 1. onPointerEvent will be called on the service.UiThread. |
| 436 | * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a |
| 437 | * copy() must be made and the copy must be recycled. |
| 438 | **/ |
| 439 | public void onPointerEvent(MotionEvent motionEvent); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 440 | } |
| 441 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 442 | /** Window has been added to the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 443 | public static final int TRANSIT_ENTER = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 444 | /** Window has been removed from the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 445 | public static final int TRANSIT_EXIT = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 446 | /** Window has been made visible. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 447 | public static final int TRANSIT_SHOW = 3; |
| 448 | /** Window has been made invisible. |
| 449 | * TODO: Consider removal as this is unused. */ |
| 450 | public static final int TRANSIT_HIDE = 4; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 451 | /** The "application starting" preview window is no longer needed, and will |
| 452 | * animate away to show the real window. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 453 | public static final int TRANSIT_PREVIEW_DONE = 5; |
| 454 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 455 | // NOTE: screen off reasons are in order of significance, with more |
| 456 | // important ones lower than less important ones. |
| 457 | |
| 458 | /** Screen turned off because of a device admin */ |
| 459 | public final int OFF_BECAUSE_OF_ADMIN = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 460 | /** Screen turned off because of power button */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 461 | public final int OFF_BECAUSE_OF_USER = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 462 | /** Screen turned off because of timeout */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 463 | public final int OFF_BECAUSE_OF_TIMEOUT = 3; |
Mike Lockwood | 435eb64 | 2009-12-03 08:40:18 -0500 | [diff] [blame] | 464 | /** Screen turned off because of proximity sensor */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 465 | public final int OFF_BECAUSE_OF_PROX_SENSOR = 4; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 466 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 467 | /** When not otherwise specified by the activity's screenOrientation, rotation should be |
| 468 | * determined by the system (that is, using sensors). */ |
| 469 | public final int USER_ROTATION_FREE = 0; |
| 470 | /** When not otherwise specified by the activity's screenOrientation, rotation is set by |
| 471 | * the user. */ |
| 472 | public final int USER_ROTATION_LOCKED = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 473 | |
| 474 | /** |
| 475 | * Perform initialization of the policy. |
| 476 | * |
| 477 | * @param context The system context we are running in. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 478 | */ |
| 479 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 480 | WindowManagerFuncs windowManagerFuncs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | |
| 482 | /** |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 483 | * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true. |
| 484 | */ |
| 485 | public boolean isDefaultOrientationForced(); |
| 486 | |
| 487 | /** |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 488 | * Called by window manager once it has the initial, default native |
| 489 | * display dimensions. |
| 490 | */ |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 491 | public void setInitialDisplaySize(Display display, int width, int height, int density); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 492 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 493 | /** |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 494 | * Called by window manager to set the overscan region that should be used for the |
| 495 | * given display. |
| 496 | */ |
| 497 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom); |
| 498 | |
| 499 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | * Check permissions when adding a window. |
| 501 | * |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 502 | * @param attrs The window's LayoutParams. |
| 503 | * @param outAppOp First element will be filled with the app op corresponding to |
| 504 | * this window, or OP_NONE. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 505 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 506 | * @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] | 507 | * else an error code, usually |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 508 | * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 509 | */ |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 510 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 511 | |
| 512 | /** |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 513 | * Check permissions when adding a window. |
| 514 | * |
| 515 | * @param attrs The window's LayoutParams. |
| 516 | * |
| 517 | * @return True if the window may only be shown to the current user, false if the window can |
| 518 | * be shown on all users' windows. |
| 519 | */ |
| 520 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs); |
| 521 | |
| 522 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 523 | * Sanitize the layout parameters coming from a client. Allows the policy |
| 524 | * to do things like ensure that windows of a specific type can't take |
| 525 | * input focus. |
| 526 | * |
| 527 | * @param attrs The window layout parameters to be modified. These values |
| 528 | * are modified in-place. |
| 529 | */ |
| 530 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs); |
| 531 | |
| 532 | /** |
| 533 | * After the window manager has computed the current configuration based |
| 534 | * on its knowledge of the display and input devices, it gives the policy |
| 535 | * a chance to adjust the information contained in it. If you want to |
| 536 | * leave it as-is, simply do nothing. |
| 537 | * |
| 538 | * <p>This method may be called by any thread in the window manager, but |
| 539 | * no internal locks in the window manager will be held. |
| 540 | * |
| 541 | * @param config The Configuration being computed, for you to change as |
| 542 | * desired. |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 543 | * @param keyboardPresence Flags that indicate whether internal or external |
| 544 | * keyboards are present. |
| 545 | * @param navigationPresence Flags that indicate whether internal or external |
| 546 | * navigation devices are present. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 547 | */ |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 548 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 549 | int navigationPresence); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | |
| 551 | /** |
| 552 | * Assign a window type to a layer. Allows you to control how different |
| 553 | * kinds of windows are ordered on-screen. |
| 554 | * |
| 555 | * @param type The type of window being assigned. |
| 556 | * |
| 557 | * @return int An arbitrary integer used to order windows, with lower |
| 558 | * numbers below higher ones. |
| 559 | */ |
| 560 | public int windowTypeToLayerLw(int type); |
| 561 | |
| 562 | /** |
| 563 | * Return how to Z-order sub-windows in relation to the window they are |
| 564 | * attached to. Return positive to have them ordered in front, negative for |
| 565 | * behind. |
| 566 | * |
| 567 | * @param type The sub-window type code. |
| 568 | * |
| 569 | * @return int Layer in relation to the attached window, where positive is |
| 570 | * above and negative is below. |
| 571 | */ |
| 572 | public int subWindowTypeToLayerLw(int type); |
| 573 | |
| 574 | /** |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 575 | * Get the highest layer (actually one more than) that the wallpaper is |
| 576 | * allowed to be in. |
| 577 | */ |
| 578 | public int getMaxWallpaperLayer(); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 579 | |
| 580 | /** |
| 581 | * Return the window layer at which windows appear above the normal |
| 582 | * universe (that is no longer impacted by the universe background |
| 583 | * transform). |
| 584 | */ |
| 585 | public int getAboveUniverseLayer(); |
| 586 | |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 587 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 588 | * Return the display width available after excluding any screen |
| 589 | * decorations that can never be removed. That is, system bar or |
| 590 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 591 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 592 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 593 | |
| 594 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 595 | * Return the display height available after excluding any screen |
| 596 | * decorations that can never be removed. That is, system bar or |
| 597 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 598 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 599 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 600 | |
| 601 | /** |
| 602 | * Return the available screen width that we should report for the |
| 603 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 604 | * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 605 | * that to account for more transient decoration like a status bar. |
| 606 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 607 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 608 | |
| 609 | /** |
| 610 | * Return the available screen height that we should report for the |
| 611 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 612 | * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 613 | * that to account for more transient decoration like a status bar. |
| 614 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 615 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 616 | |
| 617 | /** |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 618 | * Return whether the given window should forcibly hide everything |
| 619 | * behind it. Typically returns true for the keyguard. |
| 620 | */ |
| 621 | public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs); |
| 622 | |
| 623 | /** |
| 624 | * Determine if a window that is behind one that is force hiding |
| 625 | * (as determined by {@link #doesForceHide}) should actually be hidden. |
| 626 | * For example, typically returns false for the status bar. Be careful |
| 627 | * to return false for any window that you may hide yourself, since this |
| 628 | * will conflict with what you set. |
| 629 | */ |
| 630 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs); |
| 631 | |
| 632 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 633 | * Called when the system would like to show a UI to indicate that an |
| 634 | * application is starting. You can use this to add a |
| 635 | * APPLICATION_STARTING_TYPE window with the given appToken to the window |
| 636 | * manager (using the normal window manager APIs) that will be shown until |
| 637 | * the application displays its own window. This is called without the |
| 638 | * window manager locked so that you can call back into it. |
| 639 | * |
| 640 | * @param appToken Token of the application being started. |
| 641 | * @param packageName The name of the application package being started. |
| 642 | * @param theme Resource defining the application's overall visual theme. |
| 643 | * @param nonLocalizedLabel The default title label of the application if |
| 644 | * no data is found in the resource. |
| 645 | * @param labelRes The resource ID the application would like to use as its name. |
| 646 | * @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] | 647 | * @param windowFlags Window layout flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 648 | * |
| 649 | * @return Optionally you can return the View that was used to create the |
| 650 | * window, for easy removal in removeStartingWindow. |
| 651 | * |
| 652 | * @see #removeStartingWindow |
| 653 | */ |
| 654 | public View addStartingWindow(IBinder appToken, String packageName, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 655 | int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 656 | int labelRes, int icon, int logo, int windowFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 657 | |
| 658 | /** |
| 659 | * Called when the first window of an application has been displayed, while |
| 660 | * {@link #addStartingWindow} has created a temporary initial window for |
| 661 | * that application. You should at this point remove the window from the |
| 662 | * window manager. This is called without the window manager locked so |
| 663 | * that you can call back into it. |
| 664 | * |
| 665 | * <p>Note: due to the nature of these functions not being called with the |
| 666 | * window manager locked, you must be prepared for this function to be |
| 667 | * called multiple times and/or an initial time with a null View window |
| 668 | * even if you previously returned one. |
| 669 | * |
| 670 | * @param appToken Token of the application that has started. |
| 671 | * @param window Window View that was returned by createStartingWindow. |
| 672 | * |
| 673 | * @see #addStartingWindow |
| 674 | */ |
| 675 | public void removeStartingWindow(IBinder appToken, View window); |
| 676 | |
| 677 | /** |
| 678 | * Prepare for a window being added to the window manager. You can throw an |
| 679 | * exception here to prevent the window being added, or do whatever setup |
| 680 | * you need to keep track of the window. |
| 681 | * |
| 682 | * @param win The window being added. |
| 683 | * @param attrs The window's LayoutParams. |
| 684 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 685 | * @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] | 686 | * error code to abort the add. |
| 687 | */ |
| 688 | public int prepareAddWindowLw(WindowState win, |
| 689 | WindowManager.LayoutParams attrs); |
| 690 | |
| 691 | /** |
| 692 | * Called when a window is being removed from a window manager. Must not |
| 693 | * throw an exception -- clean up as much as possible. |
| 694 | * |
| 695 | * @param win The window being removed. |
| 696 | */ |
| 697 | public void removeWindowLw(WindowState win); |
| 698 | |
| 699 | /** |
| 700 | * Control the animation to run when a window's state changes. Return a |
| 701 | * non-0 number to force the animation to a specific resource ID, or 0 |
| 702 | * to use the default animation. |
| 703 | * |
| 704 | * @param win The window that is changing. |
| 705 | * @param transit What is happening to the window: {@link #TRANSIT_ENTER}, |
| 706 | * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or |
| 707 | * {@link #TRANSIT_HIDE}. |
| 708 | * |
| 709 | * @return Resource ID of the actual animation to use, or 0 for none. |
| 710 | */ |
| 711 | public int selectAnimationLw(WindowState win, int transit); |
| 712 | |
| 713 | /** |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 714 | * Determine the animation to run for a rotation transition based on the |
| 715 | * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation} |
| 716 | * and whether it is currently fullscreen and frontmost. |
| 717 | * |
| 718 | * @param anim The exiting animation resource id is stored in anim[0], the |
| 719 | * entering animation resource id is stored in anim[1]. |
| 720 | */ |
| 721 | public void selectRotationAnimationLw(int anim[]); |
| 722 | |
| 723 | /** |
| 724 | * Validate whether the current top fullscreen has specified the same |
| 725 | * {@link WindowManager.LayoutParams#rotationAnimation} value as that |
| 726 | * being passed in from the previous top fullscreen window. |
| 727 | * |
| 728 | * @param exitAnimId exiting resource id from the previous window. |
| 729 | * @param enterAnimId entering resource id from the previous window. |
| 730 | * @param forceDefault For rotation animations only, if true ignore the |
| 731 | * animation values and just return false. |
| 732 | * @return true if the previous values are still valid, false if they |
| 733 | * should be replaced with the default. |
| 734 | */ |
| 735 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 736 | boolean forceDefault); |
| 737 | |
| 738 | /** |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 739 | * Create and return an animation to re-display a force hidden window. |
| 740 | */ |
Dianne Hackborn | 0c2acff | 2012-04-12 15:17:07 -0700 | [diff] [blame] | 741 | public Animation createForceHideEnterAnimation(boolean onWallpaper); |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 742 | |
| 743 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 744 | * 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] | 745 | * |
| 746 | * <p>There are some actions that need to be handled here because they |
| 747 | * affect the power state of the device, for example, the power keys. |
| 748 | * Generally, it's best to keep as little as possible in the queue thread |
| 749 | * because it's the most fragile. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 750 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 751 | * @param policyFlags The policy flags associated with the key. |
| 752 | * @param isScreenOn True if the screen is already on |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 753 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 754 | * @return The bitwise or of the {@link #ACTION_PASS_TO_USER}, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 755 | * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 756 | */ |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 757 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 758 | |
| 759 | /** |
| 760 | * Called from the input reader thread before a motion is enqueued when the screen is off. |
| 761 | * |
| 762 | * <p>There are some actions that need to be handled here because they |
| 763 | * affect the power state of the device, for example, waking on motions. |
| 764 | * Generally, it's best to keep as little as possible in the queue thread |
| 765 | * because it's the most fragile. |
| 766 | * @param policyFlags The policy flags associated with the motion. |
| 767 | * |
| 768 | * @return The bitwise or of the {@link #ACTION_PASS_TO_USER}, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 769 | * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 770 | */ |
| 771 | public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags); |
| 772 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 773 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 774 | * 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] | 775 | * |
| 776 | * <p>Allows you to define |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 777 | * behavior for keys that can not be overridden by applications. |
| 778 | * This method is called from the input thread, with no locks held. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 779 | * |
| 780 | * @param win The window that currently has focus. This is where the key |
| 781 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 782 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 783 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 784 | * @return 0 if the key should be dispatched immediately, -1 if the key should |
| 785 | * not be dispatched ever, or a positive value indicating the number of |
| 786 | * milliseconds by which the key dispatch should be delayed before trying |
| 787 | * again. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | */ |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 789 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 790 | |
| 791 | /** |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 792 | * Called from the input dispatcher thread when an application did not handle |
| 793 | * a key that was dispatched to it. |
| 794 | * |
| 795 | * <p>Allows you to define default global behavior for keys that were not handled |
| 796 | * by applications. This method is called from the input thread, with no locks held. |
| 797 | * |
| 798 | * @param win The window that currently has focus. This is where the key |
| 799 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 800 | * @param event The key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 801 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 802 | * @return Returns an alternate key event to redispatch as a fallback, or null to give up. |
| 803 | * The caller is responsible for recycling the key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 804 | */ |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 805 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 806 | |
| 807 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 808 | * Called when layout of the windows is about to start. |
| 809 | * |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 810 | * @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] | 811 | * @param displayWidth The current full width of the screen. |
| 812 | * @param displayHeight The current full height of the screen. |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 813 | * @param displayRotation The current rotation being applied to the base |
| 814 | * window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 815 | */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 816 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 817 | int displayRotation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 818 | |
| 819 | /** |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 820 | * Returns the bottom-most layer of the system decor, above which no policy decor should |
| 821 | * be applied. |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 822 | */ |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 823 | public int getSystemDecorLayerLw(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 824 | |
| 825 | /** |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 826 | * Return the rectangle of the screen that is available for applications to run in. |
| 827 | * This will be called immediately after {@link #beginLayoutLw}. |
| 828 | * |
| 829 | * @param r The rectangle to be filled with the boundaries available to applications. |
| 830 | */ |
| 831 | public void getContentRectLw(Rect r); |
| 832 | |
| 833 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 834 | * Called for each window attached to the window manager as layout is |
| 835 | * proceeding. The implementation of this function must take care of |
| 836 | * setting the window's frame, either here or in finishLayout(). |
| 837 | * |
| 838 | * @param win The window being positioned. |
| 839 | * @param attrs The LayoutParams of the window. |
| 840 | * @param attached For sub-windows, the window it is attached to; this |
| 841 | * window will already have had layoutWindow() called on it |
| 842 | * so you can use its Rect. Otherwise null. |
| 843 | */ |
| 844 | public void layoutWindowLw(WindowState win, |
| 845 | WindowManager.LayoutParams attrs, WindowState attached); |
| 846 | |
| 847 | |
| 848 | /** |
| 849 | * Return the insets for the areas covered by system windows. These values |
| 850 | * are computed on the most recent layout, so they are not guaranteed to |
| 851 | * be correct. |
| 852 | * |
| 853 | * @param attrs The LayoutParams of the window. |
| 854 | * @param contentInset The areas covered by system windows, expressed as positive insets |
| 855 | * |
| 856 | */ |
| 857 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 858 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 859 | /** |
| 860 | * Called when layout of the windows is finished. After this function has |
| 861 | * returned, all windows given to layoutWindow() <em>must</em> have had a |
| 862 | * frame assigned. |
| 863 | */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 864 | public void finishLayoutLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 866 | /** Layout state may have changed (so another layout will be performed) */ |
| 867 | static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001; |
| 868 | /** Configuration state may have changed */ |
| 869 | static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002; |
| 870 | /** Wallpaper may need to move */ |
| 871 | static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 872 | /** Need to recompute animations */ |
| 873 | static final int FINISH_LAYOUT_REDO_ANIM = 0x0008; |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 874 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 875 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 876 | * Called following layout of all windows before each window has policy applied. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 877 | * |
| 878 | * @param displayWidth The current full width of the screen. |
| 879 | * @param displayHeight The current full height of the screen. |
| 880 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 881 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 882 | |
| 883 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 884 | * Called following layout of all window to apply policy to each window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 885 | * |
| 886 | * @param win The window being positioned. |
| 887 | * @param attrs The LayoutParams of the window. |
| 888 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 889 | public void applyPostLayoutPolicyLw(WindowState win, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 890 | WindowManager.LayoutParams attrs); |
| 891 | |
| 892 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 893 | * Called following layout of all windows and after policy has been applied |
| 894 | * to each window. If in this function you do |
| 895 | * something that may have modified the animation state of another window, |
| 896 | * be sure to return non-zero in order to perform another pass through layout. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 897 | * |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 898 | * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT}, |
| 899 | * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER}, |
| 900 | * or {@link #FINISH_LAYOUT_REDO_ANIM}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 901 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 902 | public int finishPostLayoutPolicyLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 903 | |
| 904 | /** |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 905 | * Return true if it is okay to perform animations for an app transition |
| 906 | * that is about to occur. You may return false for this if, for example, |
| 907 | * the lock screen is currently displayed so the switch should happen |
| 908 | * immediately. |
| 909 | */ |
| 910 | public boolean allowAppAnimationsLw(); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 911 | |
| 912 | |
| 913 | /** |
| 914 | * A new window has been focused. |
| 915 | */ |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 916 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus); |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 917 | |
| 918 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 919 | * Called after the screen turns off. |
| 920 | * |
| 921 | * @param why {@link #OFF_BECAUSE_OF_USER} or |
| 922 | * {@link #OFF_BECAUSE_OF_TIMEOUT}. |
| 923 | */ |
| 924 | public void screenTurnedOff(int why); |
| 925 | |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 926 | public interface ScreenOnListener { |
| 927 | void onScreenOn(); |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 928 | } |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 929 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 930 | /** |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 931 | * Called when the power manager would like to turn the screen on. |
| 932 | * Must call back on the listener to tell it when the higher-level system |
| 933 | * is ready for the screen to go on (i.e. the lock screen is shown). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 934 | */ |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 935 | public void screenTurningOn(ScreenOnListener screenOnListener); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 936 | |
| 937 | /** |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 938 | * Return whether the screen is about to turn on or is currently on. |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 939 | */ |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 940 | public boolean isScreenOnEarly(); |
| 941 | |
| 942 | /** |
| 943 | * Return whether the screen is fully turned on. |
| 944 | */ |
| 945 | public boolean isScreenOnFully(); |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 946 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 947 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 948 | * Tell the policy that the lid switch has changed state. |
| 949 | * @param whenNanos The time when the change occurred in uptime nanoseconds. |
| 950 | * @param lidOpen True if the lid is now open. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 951 | */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 952 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); |
| 953 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 954 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 955 | * Tell the policy if anyone is requesting that keyguard not come on. |
| 956 | * |
| 957 | * @param enabled Whether keyguard can be on or not. does not actually |
| 958 | * turn it on, unless it was previously disabled with this function. |
| 959 | * |
| 960 | * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard() |
| 961 | * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard() |
| 962 | */ |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 963 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 964 | public void enableKeyguard(boolean enabled); |
| 965 | |
| 966 | /** |
| 967 | * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely} |
| 968 | */ |
| 969 | interface OnKeyguardExitResult { |
| 970 | void onKeyguardExitResult(boolean success); |
| 971 | } |
| 972 | |
| 973 | /** |
| 974 | * Tell the policy if anyone is requesting the keyguard to exit securely |
| 975 | * (this would be called after the keyguard was disabled) |
| 976 | * @param callback Callback to send the result back. |
| 977 | * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult) |
| 978 | */ |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 979 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 980 | void exitKeyguardSecurely(OnKeyguardExitResult callback); |
| 981 | |
| 982 | /** |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 983 | * isKeyguardLocked |
| 984 | * |
| 985 | * Return whether the keyguard is currently locked. |
| 986 | * |
| 987 | * @return true if in keyguard is locked. |
| 988 | */ |
| 989 | public boolean isKeyguardLocked(); |
| 990 | |
| 991 | /** |
| 992 | * isKeyguardSecure |
| 993 | * |
| 994 | * Return whether the keyguard requires a password to unlock. |
| 995 | * |
| 996 | * @return true if in keyguard is secure. |
| 997 | */ |
| 998 | public boolean isKeyguardSecure(); |
| 999 | |
| 1000 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1001 | * inKeyguardRestrictedKeyInputMode |
| 1002 | * |
| 1003 | * if keyguard screen is showing or in restricted key input mode (i.e. in |
| 1004 | * keyguard password emergency screen). When in such mode, certain keys, |
| 1005 | * such as the Home key and the right soft keys, don't work. |
| 1006 | * |
| 1007 | * @return true if in keyguard restricted input mode. |
| 1008 | */ |
| 1009 | public boolean inKeyguardRestrictedKeyInputMode(); |
| 1010 | |
| 1011 | /** |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1012 | * Ask the policy to dismiss the keyguard, if it is currently shown. |
| 1013 | */ |
| 1014 | public void dismissKeyguardLw(); |
| 1015 | |
| 1016 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1017 | * Given an orientation constant, returns the appropriate surface rotation, |
| 1018 | * taking into account sensors, docking mode, rotation lock, and other factors. |
| 1019 | * |
| 1020 | * @param orientation An orientation constant, such as |
| 1021 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 1022 | * @param lastRotation The most recently used rotation. |
| 1023 | * @return The surface rotation to use. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1024 | */ |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1025 | public int rotationForOrientationLw(int orientation, int lastRotation); |
| 1026 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1027 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1028 | * Given an orientation constant and a rotation, returns true if the rotation |
| 1029 | * has compatible metrics to the requested orientation. For example, if |
| 1030 | * the application requested landscape and got seascape, then the rotation |
| 1031 | * has compatible metrics; if the application requested portrait and got landscape, |
| 1032 | * then the rotation has incompatible metrics; if the application did not specify |
| 1033 | * a preference, then anything goes. |
| 1034 | * |
| 1035 | * @param orientation An orientation constant, such as |
| 1036 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 1037 | * @param rotation The rotation to check. |
| 1038 | * @return True if the rotation is compatible with the requested orientation. |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1039 | */ |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1040 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1041 | |
| 1042 | /** |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 1043 | * Called by the window manager when the rotation changes. |
| 1044 | * |
| 1045 | * @param rotation The new rotation. |
| 1046 | */ |
| 1047 | public void setRotationLw(int rotation); |
| 1048 | |
| 1049 | /** |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1050 | * 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] | 1051 | * the system should go into safe mode. |
| 1052 | */ |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1053 | public void setSafeMode(boolean safeMode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1054 | |
| 1055 | /** |
| 1056 | * Called when the system is mostly done booting. |
| 1057 | */ |
| 1058 | public void systemReady(); |
| 1059 | |
| 1060 | /** |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 1061 | * Called when the system is done booting to the point where the |
| 1062 | * user can start interacting with it. |
| 1063 | */ |
| 1064 | public void systemBooted(); |
| 1065 | |
| 1066 | /** |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1067 | * Show boot time message to the user. |
| 1068 | */ |
| 1069 | public void showBootMessage(final CharSequence msg, final boolean always); |
| 1070 | |
| 1071 | /** |
| 1072 | * Hide the UI for showing boot messages, never to be displayed again. |
| 1073 | */ |
| 1074 | public void hideBootMessages(); |
| 1075 | |
| 1076 | /** |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 1077 | * Called when userActivity is signalled in the power manager. |
| 1078 | * This is safe to call from any thread, with any window manager locks held or not. |
| 1079 | */ |
| 1080 | public void userActivity(); |
| 1081 | |
| 1082 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1083 | * Called when we have finished booting and can now display the home |
Jeff Brown | c042ee2 | 2012-05-08 13:03:42 -0700 | [diff] [blame] | 1084 | * 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] | 1085 | * this point the display is active. |
| 1086 | */ |
| 1087 | public void enableScreenAfterBoot(); |
| 1088 | |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 1089 | public void setCurrentOrientationLw(int newOrientation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1090 | |
| 1091 | /** |
| 1092 | * Call from application to perform haptic feedback on its window. |
| 1093 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 1094 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1095 | |
| 1096 | /** |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1097 | * Called when we have started keeping the screen on because a window |
| 1098 | * requesting this has become visible. |
| 1099 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1100 | public void keepScreenOnStartedLw(); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1101 | |
| 1102 | /** |
| 1103 | * 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] | 1104 | * requesting this is no longer visible. |
| 1105 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1106 | public void keepScreenOnStoppedLw(); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1107 | |
| 1108 | /** |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 1109 | * Gets the current user rotation mode. |
| 1110 | * |
| 1111 | * @return The rotation mode. |
| 1112 | * |
| 1113 | * @see WindowManagerPolicy#USER_ROTATION_LOCKED |
| 1114 | * @see WindowManagerPolicy#USER_ROTATION_FREE |
| 1115 | */ |
| 1116 | public int getUserRotationMode(); |
| 1117 | |
| 1118 | /** |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1119 | * Inform the policy that the user has chosen a preferred orientation ("rotation lock"). |
| 1120 | * |
| 1121 | * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1122 | * {@link WindowManagerPolicy#USER_ROTATION_FREE}. |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1123 | * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90}, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1124 | * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}. |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1125 | */ |
| 1126 | public void setUserRotationMode(int mode, int rotation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1127 | |
| 1128 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1129 | * Called when a new system UI visibility is being reported, allowing |
| 1130 | * the policy to adjust what is actually reported. |
| 1131 | * @param visibility The raw visiblity reported by the status bar. |
| 1132 | * @return The new desired visibility. |
| 1133 | */ |
| 1134 | public int adjustSystemUiVisibilityLw(int visibility); |
| 1135 | |
| 1136 | /** |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1137 | * Specifies whether there is an on-screen navigation bar separate from the status bar. |
| 1138 | */ |
| 1139 | public boolean hasNavigationBar(); |
| 1140 | |
| 1141 | /** |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1142 | * Lock the device now. |
| 1143 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1144 | public void lockNow(Bundle options); |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1145 | |
| 1146 | /** |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 1147 | * Set the last used input method window state. This state is used to make IME transition |
| 1148 | * smooth. |
| 1149 | * @hide |
| 1150 | */ |
| 1151 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target); |
| 1152 | |
| 1153 | /** |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1154 | * Called when the current user changes. Guaranteed to be called before the broadcast |
| 1155 | * of the new user id is made to all listeners. |
| 1156 | * |
| 1157 | * @param newUserId The id of the incoming user. |
| 1158 | */ |
| 1159 | public void setCurrentUserLw(int newUserId); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1160 | |
| 1161 | /** |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1162 | * Print the WindowManagerPolicy's state into the given stream. |
| 1163 | * |
| 1164 | * @param prefix Text to print at the front of each line. |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1165 | * @param writer The PrintWriter to which you should dump your state. This will be |
| 1166 | * closed for you after you return. |
| 1167 | * @param args additional arguments to the dump request. |
| 1168 | */ |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 1169 | public void dump(String prefix, PrintWriter writer, String[] args); |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 1170 | |
| 1171 | /** |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 1172 | * Returns whether a given window type can be magnified. |
| 1173 | * |
| 1174 | * @param windowType The window type. |
| 1175 | * @return True if the window can be magnified. |
| 1176 | */ |
| 1177 | public boolean canMagnifyWindow(int windowType); |
| 1178 | |
| 1179 | /** |
| 1180 | * Returns whether a given window type is considered a top level one. |
| 1181 | * A top level window does not have a container, i.e. attached window, |
| 1182 | * or if it has a container it is laid out as a top-level window, not |
| 1183 | * as a child of its container. |
| 1184 | * |
| 1185 | * @param windowType The window type. |
| 1186 | * @return True if the window is a top level one. |
| 1187 | */ |
| 1188 | public boolean isTopLevelWindow(int windowType); |
Alan Viverette | 5a0f4ec | 2013-10-07 15:10:29 -0700 | [diff] [blame] | 1189 | |
| 1190 | /** |
| 1191 | * Sets the current touch exploration state. |
| 1192 | * |
| 1193 | * @param enabled Whether touch exploration is enabled. |
| 1194 | */ |
| 1195 | public void setTouchExplorationEnabled(boolean enabled); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1196 | } |