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; |
| 20 | import android.content.res.Configuration; |
| 21 | import android.graphics.Rect; |
| 22 | import android.os.IBinder; |
| 23 | import android.os.LocalPowerManager; |
| 24 | import android.view.animation.Animation; |
| 25 | |
| 26 | /** |
| 27 | * This interface supplies all UI-specific behavior of the window manager. An |
| 28 | * instance of it is created by the window manager when it starts up, and allows |
| 29 | * customization of window layering, special window types, key dispatching, and |
| 30 | * layout. |
| 31 | * |
| 32 | * <p>Because this provides deep interaction with the system window manager, |
| 33 | * specific methods on this interface can be called from a variety of contexts |
| 34 | * with various restrictions on what they can do. These are encoded through |
| 35 | * a suffixes at the end of a method encoding the thread the method is called |
| 36 | * from and any locks that are held when it is being called; if no suffix |
| 37 | * is attached to a method, then it is not called with any locks and may be |
| 38 | * called from the main window manager thread or another thread calling into |
| 39 | * the window manager. |
| 40 | * |
| 41 | * <p>The current suffixes are: |
| 42 | * |
| 43 | * <dl> |
| 44 | * <dt> Ti <dd> Called from the input thread. This is the thread that |
| 45 | * collects pending input events and dispatches them to the appropriate window. |
| 46 | * It may block waiting for events to be processed, so that the input stream is |
| 47 | * properly serialized. |
| 48 | * <dt> Tq <dd> Called from the low-level input queue thread. This is the |
| 49 | * thread that reads events out of the raw input devices and places them |
| 50 | * into the global input queue that is read by the <var>Ti</var> thread. |
| 51 | * This thread should not block for a long period of time on anything but the |
| 52 | * key driver. |
| 53 | * <dt> Lw <dd> Called with the main window manager lock held. Because the |
| 54 | * window manager is a very low-level system service, there are few other |
| 55 | * system services you can call with this lock held. It is explicitly okay to |
| 56 | * 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] | 57 | * 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] | 58 | * {@link android.content.Context#checkPermission(String, int, int)} and |
| 59 | * variations require calling into the activity manager. |
| 60 | * <dt> Li <dd> Called with the input thread lock held. This lock can be |
| 61 | * acquired by the window manager while it holds the window lock, so this is |
| 62 | * even more restrictive than <var>Lw</var>. |
| 63 | * </dl> |
| 64 | * |
| 65 | * @hide |
| 66 | */ |
| 67 | public interface WindowManagerPolicy { |
| 68 | public final static int FLAG_WAKE = 0x00000001; |
| 69 | public final static int FLAG_WAKE_DROPPED = 0x00000002; |
| 70 | public final static int FLAG_SHIFT = 0x00000004; |
| 71 | public final static int FLAG_CAPS_LOCK = 0x00000008; |
| 72 | public final static int FLAG_ALT = 0x00000010; |
| 73 | public final static int FLAG_ALT_GR = 0x00000020; |
| 74 | public final static int FLAG_MENU = 0x00000040; |
| 75 | public final static int FLAG_LAUNCHER = 0x00000080; |
| 76 | |
| 77 | public final static int FLAG_WOKE_HERE = 0x10000000; |
| 78 | public final static int FLAG_BRIGHT_HERE = 0x20000000; |
| 79 | |
| 80 | public final static boolean WATCH_POINTER = false; |
| 81 | |
| 82 | // flags for interceptKeyTq |
| 83 | /** |
| 84 | * Pass this event to the user / app. To be returned from {@link #interceptKeyTq}. |
| 85 | */ |
| 86 | public final static int ACTION_PASS_TO_USER = 0x00000001; |
| 87 | |
| 88 | /** |
| 89 | * This key event should extend the user activity timeout and turn the lights on. |
| 90 | * To be returned from {@link #interceptKeyTq}. Do not return this and |
| 91 | * {@link #ACTION_GO_TO_SLEEP} or {@link #ACTION_PASS_TO_USER}. |
| 92 | */ |
| 93 | public final static int ACTION_POKE_USER_ACTIVITY = 0x00000002; |
| 94 | |
| 95 | /** |
| 96 | * This key event should put the device to sleep (and engage keyguard if necessary) |
| 97 | * To be returned from {@link #interceptKeyTq}. Do not return this and |
| 98 | * {@link #ACTION_POKE_USER_ACTIVITY} or {@link #ACTION_PASS_TO_USER}. |
| 99 | */ |
| 100 | public final static int ACTION_GO_TO_SLEEP = 0x00000004; |
| 101 | |
| 102 | /** |
| 103 | * Interface to the Window Manager state associated with a particular |
| 104 | * window. You can hold on to an instance of this interface from the call |
| 105 | * to prepareAddWindow() until removeWindow(). |
| 106 | */ |
| 107 | public interface WindowState { |
| 108 | /** |
| 109 | * Perform standard frame computation. The result can be obtained with |
| 110 | * getFrame() if so desired. Must be called with the window manager |
| 111 | * lock held. |
| 112 | * |
| 113 | * @param parentFrame The frame of the parent container this window |
| 114 | * is in, used for computing its basic position. |
| 115 | * @param displayFrame The frame of the overall display in which this |
| 116 | * window can appear, used for constraining the overall dimensions |
| 117 | * of the window. |
| 118 | * @param contentFrame The frame within the display in which we would |
| 119 | * like active content to appear. This will cause windows behind to |
| 120 | * be resized to match the given content frame. |
| 121 | * @param visibleFrame The frame within the display that the window |
| 122 | * is actually visible, used for computing its visible insets to be |
| 123 | * given to windows behind. |
| 124 | * This can be used as a hint for scrolling (avoiding resizing) |
| 125 | * the window to make certain that parts of its content |
| 126 | * are visible. |
| 127 | */ |
| 128 | public void computeFrameLw(Rect parentFrame, Rect displayFrame, |
| 129 | Rect contentFrame, Rect visibleFrame); |
| 130 | |
| 131 | /** |
| 132 | * Retrieve the current frame of the window that has been assigned by |
| 133 | * the window manager. Must be called with the window manager lock held. |
| 134 | * |
| 135 | * @return Rect The rectangle holding the window frame. |
| 136 | */ |
| 137 | public Rect getFrameLw(); |
| 138 | |
| 139 | /** |
| 140 | * Retrieve the current frame of the window that is actually shown. |
| 141 | * Must be called with the window manager lock held. |
| 142 | * |
| 143 | * @return Rect The rectangle holding the shown window frame. |
| 144 | */ |
| 145 | public Rect getShownFrameLw(); |
| 146 | |
| 147 | /** |
| 148 | * Retrieve the frame of the display that this window was last |
| 149 | * laid out in. Must be called with the |
| 150 | * window manager lock held. |
| 151 | * |
| 152 | * @return Rect The rectangle holding the display frame. |
| 153 | */ |
| 154 | public Rect getDisplayFrameLw(); |
| 155 | |
| 156 | /** |
| 157 | * Retrieve the frame of the content area that this window was last |
| 158 | * laid out in. This is the area in which the content of the window |
| 159 | * should be placed. It will be smaller than the display frame to |
| 160 | * account for screen decorations such as a status bar or soft |
| 161 | * keyboard. Must be called with the |
| 162 | * window manager lock held. |
| 163 | * |
| 164 | * @return Rect The rectangle holding the content frame. |
| 165 | */ |
| 166 | public Rect getContentFrameLw(); |
| 167 | |
| 168 | /** |
| 169 | * Retrieve the frame of the visible area that this window was last |
| 170 | * laid out in. This is the area of the screen in which the window |
| 171 | * will actually be fully visible. It will be smaller than the |
| 172 | * content frame to account for transient UI elements blocking it |
| 173 | * such as an input method's candidates UI. Must be called with the |
| 174 | * window manager lock held. |
| 175 | * |
| 176 | * @return Rect The rectangle holding the visible frame. |
| 177 | */ |
| 178 | public Rect getVisibleFrameLw(); |
| 179 | |
| 180 | /** |
| 181 | * Returns true if this window is waiting to receive its given |
| 182 | * internal insets from the client app, and so should not impact the |
| 183 | * layout of other windows. |
| 184 | */ |
| 185 | public boolean getGivenInsetsPendingLw(); |
| 186 | |
| 187 | /** |
| 188 | * Retrieve the insets given by this window's client for the content |
| 189 | * area of windows behind it. Must be called with the |
| 190 | * window manager lock held. |
| 191 | * |
| 192 | * @return Rect The left, top, right, and bottom insets, relative |
| 193 | * to the window's frame, of the actual contents. |
| 194 | */ |
| 195 | public Rect getGivenContentInsetsLw(); |
| 196 | |
| 197 | /** |
| 198 | * Retrieve the insets given by this window's client for the visible |
| 199 | * area of windows behind it. Must be called with the |
| 200 | * window manager lock held. |
| 201 | * |
| 202 | * @return Rect The left, top, right, and bottom insets, relative |
| 203 | * to the window's frame, of the actual visible area. |
| 204 | */ |
| 205 | public Rect getGivenVisibleInsetsLw(); |
| 206 | |
| 207 | /** |
| 208 | * Retrieve the current LayoutParams of the window. |
| 209 | * |
| 210 | * @return WindowManager.LayoutParams The window's internal LayoutParams |
| 211 | * instance. |
| 212 | */ |
| 213 | public WindowManager.LayoutParams getAttrs(); |
| 214 | |
| 215 | /** |
| 216 | * Get the layer at which this window's surface will be Z-ordered. |
| 217 | */ |
| 218 | public int getSurfaceLayer(); |
| 219 | |
| 220 | /** |
| 221 | * Return the token for the application (actually activity) that owns |
| 222 | * this window. May return null for system windows. |
| 223 | * |
| 224 | * @return An IApplicationToken identifying the owning activity. |
| 225 | */ |
| 226 | public IApplicationToken getAppToken(); |
| 227 | |
| 228 | /** |
| 229 | * Return true if, at any point, the application token associated with |
| 230 | * this window has actually displayed any windows. This is most useful |
| 231 | * with the "starting up" window to determine if any windows were |
| 232 | * displayed when it is closed. |
| 233 | * |
| 234 | * @return Returns true if one or more windows have been displayed, |
| 235 | * else false. |
| 236 | */ |
| 237 | public boolean hasAppShownWindows(); |
| 238 | |
| 239 | /** |
| 240 | * Return true if the application token has been asked to display an |
| 241 | * app starting icon as the application is starting up. |
| 242 | * |
| 243 | * @return Returns true if setAppStartingIcon() was called for this |
| 244 | * window's token. |
| 245 | */ |
| 246 | public boolean hasAppStartingIcon(); |
| 247 | |
| 248 | /** |
| 249 | * Return the Window that is being displayed as this window's |
| 250 | * application token is being started. |
| 251 | * |
| 252 | * @return Returns the currently displayed starting window, or null if |
| 253 | * it was not requested, has not yet been displayed, or has |
| 254 | * been removed. |
| 255 | */ |
| 256 | public WindowState getAppStartingWindow(); |
| 257 | |
| 258 | /** |
| 259 | * Is this window visible? It is not visible if there is no |
| 260 | * surface, or we are in the process of running an exit animation |
| 261 | * that will remove the surface. |
| 262 | */ |
| 263 | boolean isVisibleLw(); |
| 264 | |
| 265 | /** |
| 266 | * Is this window currently visible to the user on-screen? It is |
| 267 | * displayed either if it is visible or it is currently running an |
| 268 | * animation before no longer being visible. Must be called with the |
| 269 | * window manager lock held. |
| 270 | */ |
| 271 | boolean isDisplayedLw(); |
| 272 | |
| 273 | /** |
| 274 | * Returns true if the window is both full screen and opaque. Must be |
| 275 | * called with the window manager lock held. |
| 276 | * |
| 277 | * @param width The width of the screen |
| 278 | * @param height The height of the screen |
| 279 | * @param shownFrame If true, this is based on the actual shown frame of |
| 280 | * the window (taking into account animations); if |
| 281 | * false, this is based on the currently requested |
| 282 | * frame, which any current animation will be moving |
| 283 | * towards. |
| 284 | * @param onlyOpaque If true, this will only pass if the window is |
| 285 | * also opaque. |
| 286 | * @return Returns true if the window is both full screen and opaque |
| 287 | */ |
| 288 | public boolean fillsScreenLw(int width, int height, boolean shownFrame, |
| 289 | boolean onlyOpaque); |
| 290 | |
| 291 | /** |
| 292 | * Returns true if this window has been shown on screen at some time in |
| 293 | * the past. Must be called with the window manager lock held. |
| 294 | * |
| 295 | * @return boolean |
| 296 | */ |
| 297 | public boolean hasDrawnLw(); |
| 298 | |
| 299 | /** |
| 300 | * Can be called by the policy to force a window to be hidden, |
| 301 | * regardless of whether the client or window manager would like |
| 302 | * it shown. Must be called with the window manager lock held. |
| 303 | * Returns true if {@link #showLw} was last called for the window. |
| 304 | */ |
| 305 | public boolean hideLw(boolean doAnimation); |
| 306 | |
| 307 | /** |
| 308 | * Can be called to undo the effect of {@link #hideLw}, allowing a |
| 309 | * window to be shown as long as the window manager and client would |
| 310 | * also like it to be shown. Must be called with the window manager |
| 311 | * lock held. |
| 312 | * Returns true if {@link #hideLw} was last called for the window. |
| 313 | */ |
| 314 | public boolean showLw(boolean doAnimation); |
| 315 | } |
| 316 | |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 317 | /** Not set up for a transition. */ |
| 318 | public final int TRANSIT_UNSET = 0; |
| 319 | /** No animation for transition. */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 320 | public final int TRANSIT_NONE = 0; |
| 321 | /** Window has been added to the screen. */ |
| 322 | public final int TRANSIT_ENTER = 1; |
| 323 | /** Window has been removed from the screen. */ |
| 324 | public final int TRANSIT_EXIT = 2; |
| 325 | /** Window has been made visible. */ |
| 326 | public final int TRANSIT_SHOW = 3; |
| 327 | /** Window has been made invisible. */ |
| 328 | public final int TRANSIT_HIDE = 4; |
| 329 | /** The "application starting" preview window is no longer needed, and will |
| 330 | * animate away to show the real window. */ |
| 331 | public final int TRANSIT_PREVIEW_DONE = 5; |
| 332 | /** A window in a new activity is being opened on top of an existing one |
| 333 | * in the same task. */ |
| 334 | public final int TRANSIT_ACTIVITY_OPEN = 6; |
| 335 | /** The window in the top-most activity is being closed to reveal the |
| 336 | * previous activity in the same task. */ |
| 337 | public final int TRANSIT_ACTIVITY_CLOSE = 7; |
| 338 | /** A window in a new task is being opened on top of an existing one |
| 339 | * in another activity's task. */ |
| 340 | public final int TRANSIT_TASK_OPEN = 8; |
| 341 | /** A window in the top-most activity is being closed to reveal the |
| 342 | * previous activity in a different task. */ |
| 343 | public final int TRANSIT_TASK_CLOSE = 9; |
| 344 | /** A window in an existing task is being displayed on top of an existing one |
| 345 | * in another activity's task. */ |
| 346 | public final int TRANSIT_TASK_TO_FRONT = 10; |
| 347 | /** A window in an existing task is being put below all other tasks. */ |
| 348 | public final int TRANSIT_TASK_TO_BACK = 11; |
Dianne Hackborn | 25994b4 | 2009-09-04 14:21:19 -0700 | [diff] [blame] | 349 | /** A window in a new activity that doesn't have a wallpaper is being |
| 350 | * opened on top of one that does, effectively closing the wallpaper. */ |
| 351 | public final int TRANSIT_WALLPAPER_CLOSE = 12; |
| 352 | /** A window in a new activity that does have a wallpaper is being |
| 353 | * opened on one that didn't, effectively opening the wallpaper. */ |
| 354 | public final int TRANSIT_WALLPAPER_OPEN = 13; |
Dianne Hackborn | f8fbdb6 | 2009-08-19 12:39:43 -0700 | [diff] [blame] | 355 | /** A window in a new activity is being opened on top of an existing one, |
| 356 | * and both are on top of the wallpaper. */ |
Dianne Hackborn | 25994b4 | 2009-09-04 14:21:19 -0700 | [diff] [blame] | 357 | public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14; |
Dianne Hackborn | f8fbdb6 | 2009-08-19 12:39:43 -0700 | [diff] [blame] | 358 | /** The window in the top-most activity is being closed to reveal the |
| 359 | * previous activity, and both are on top of he wallpaper. */ |
Dianne Hackborn | 25994b4 | 2009-09-04 14:21:19 -0700 | [diff] [blame] | 360 | public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 361 | |
| 362 | /** Screen turned off because of power button */ |
| 363 | public final int OFF_BECAUSE_OF_USER = 1; |
| 364 | /** Screen turned off because of timeout */ |
| 365 | public final int OFF_BECAUSE_OF_TIMEOUT = 2; |
| 366 | |
| 367 | /** |
| 368 | * Magic constant to {@link IWindowManager#setRotation} to not actually |
| 369 | * modify the rotation. |
| 370 | */ |
| 371 | public final int USE_LAST_ROTATION = -1000; |
| 372 | |
| 373 | /** |
| 374 | * Perform initialization of the policy. |
| 375 | * |
| 376 | * @param context The system context we are running in. |
| 377 | * @param powerManager |
| 378 | */ |
| 379 | public void init(Context context, IWindowManager windowManager, |
| 380 | LocalPowerManager powerManager); |
| 381 | |
| 382 | /** |
| 383 | * Check permissions when adding a window. |
| 384 | * |
| 385 | * @param attrs The window's LayoutParams. |
| 386 | * |
| 387 | * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed; |
| 388 | * else an error code, usually |
| 389 | * {@link WindowManagerImpl#ADD_PERMISSION_DENIED}, to abort the add. |
| 390 | */ |
| 391 | public int checkAddPermission(WindowManager.LayoutParams attrs); |
| 392 | |
| 393 | /** |
| 394 | * Sanitize the layout parameters coming from a client. Allows the policy |
| 395 | * to do things like ensure that windows of a specific type can't take |
| 396 | * input focus. |
| 397 | * |
| 398 | * @param attrs The window layout parameters to be modified. These values |
| 399 | * are modified in-place. |
| 400 | */ |
| 401 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs); |
| 402 | |
| 403 | /** |
| 404 | * After the window manager has computed the current configuration based |
| 405 | * on its knowledge of the display and input devices, it gives the policy |
| 406 | * a chance to adjust the information contained in it. If you want to |
| 407 | * leave it as-is, simply do nothing. |
| 408 | * |
| 409 | * <p>This method may be called by any thread in the window manager, but |
| 410 | * no internal locks in the window manager will be held. |
| 411 | * |
| 412 | * @param config The Configuration being computed, for you to change as |
| 413 | * desired. |
| 414 | */ |
| 415 | public void adjustConfigurationLw(Configuration config); |
| 416 | |
| 417 | /** |
| 418 | * Assign a window type to a layer. Allows you to control how different |
| 419 | * kinds of windows are ordered on-screen. |
| 420 | * |
| 421 | * @param type The type of window being assigned. |
| 422 | * |
| 423 | * @return int An arbitrary integer used to order windows, with lower |
| 424 | * numbers below higher ones. |
| 425 | */ |
| 426 | public int windowTypeToLayerLw(int type); |
| 427 | |
| 428 | /** |
| 429 | * Return how to Z-order sub-windows in relation to the window they are |
| 430 | * attached to. Return positive to have them ordered in front, negative for |
| 431 | * behind. |
| 432 | * |
| 433 | * @param type The sub-window type code. |
| 434 | * |
| 435 | * @return int Layer in relation to the attached window, where positive is |
| 436 | * above and negative is below. |
| 437 | */ |
| 438 | public int subWindowTypeToLayerLw(int type); |
| 439 | |
| 440 | /** |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 441 | * Get the highest layer (actually one more than) that the wallpaper is |
| 442 | * allowed to be in. |
| 443 | */ |
| 444 | public int getMaxWallpaperLayer(); |
| 445 | |
| 446 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 447 | * Called when the system would like to show a UI to indicate that an |
| 448 | * application is starting. You can use this to add a |
| 449 | * APPLICATION_STARTING_TYPE window with the given appToken to the window |
| 450 | * manager (using the normal window manager APIs) that will be shown until |
| 451 | * the application displays its own window. This is called without the |
| 452 | * window manager locked so that you can call back into it. |
| 453 | * |
| 454 | * @param appToken Token of the application being started. |
| 455 | * @param packageName The name of the application package being started. |
| 456 | * @param theme Resource defining the application's overall visual theme. |
| 457 | * @param nonLocalizedLabel The default title label of the application if |
| 458 | * no data is found in the resource. |
| 459 | * @param labelRes The resource ID the application would like to use as its name. |
| 460 | * @param icon The resource ID the application would like to use as its icon. |
| 461 | * |
| 462 | * @return Optionally you can return the View that was used to create the |
| 463 | * window, for easy removal in removeStartingWindow. |
| 464 | * |
| 465 | * @see #removeStartingWindow |
| 466 | */ |
| 467 | public View addStartingWindow(IBinder appToken, String packageName, |
| 468 | int theme, CharSequence nonLocalizedLabel, |
| 469 | int labelRes, int icon); |
| 470 | |
| 471 | /** |
| 472 | * Called when the first window of an application has been displayed, while |
| 473 | * {@link #addStartingWindow} has created a temporary initial window for |
| 474 | * that application. You should at this point remove the window from the |
| 475 | * window manager. This is called without the window manager locked so |
| 476 | * that you can call back into it. |
| 477 | * |
| 478 | * <p>Note: due to the nature of these functions not being called with the |
| 479 | * window manager locked, you must be prepared for this function to be |
| 480 | * called multiple times and/or an initial time with a null View window |
| 481 | * even if you previously returned one. |
| 482 | * |
| 483 | * @param appToken Token of the application that has started. |
| 484 | * @param window Window View that was returned by createStartingWindow. |
| 485 | * |
| 486 | * @see #addStartingWindow |
| 487 | */ |
| 488 | public void removeStartingWindow(IBinder appToken, View window); |
| 489 | |
| 490 | /** |
| 491 | * Prepare for a window being added to the window manager. You can throw an |
| 492 | * exception here to prevent the window being added, or do whatever setup |
| 493 | * you need to keep track of the window. |
| 494 | * |
| 495 | * @param win The window being added. |
| 496 | * @param attrs The window's LayoutParams. |
| 497 | * |
| 498 | * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed, else an |
| 499 | * error code to abort the add. |
| 500 | */ |
| 501 | public int prepareAddWindowLw(WindowState win, |
| 502 | WindowManager.LayoutParams attrs); |
| 503 | |
| 504 | /** |
| 505 | * Called when a window is being removed from a window manager. Must not |
| 506 | * throw an exception -- clean up as much as possible. |
| 507 | * |
| 508 | * @param win The window being removed. |
| 509 | */ |
| 510 | public void removeWindowLw(WindowState win); |
| 511 | |
| 512 | /** |
| 513 | * Control the animation to run when a window's state changes. Return a |
| 514 | * non-0 number to force the animation to a specific resource ID, or 0 |
| 515 | * to use the default animation. |
| 516 | * |
| 517 | * @param win The window that is changing. |
| 518 | * @param transit What is happening to the window: {@link #TRANSIT_ENTER}, |
| 519 | * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or |
| 520 | * {@link #TRANSIT_HIDE}. |
| 521 | * |
| 522 | * @return Resource ID of the actual animation to use, or 0 for none. |
| 523 | */ |
| 524 | public int selectAnimationLw(WindowState win, int transit); |
| 525 | |
| 526 | /** |
| 527 | * Called from the key queue thread before a key is dispatched to the |
| 528 | * input thread. |
| 529 | * |
| 530 | * <p>There are some actions that need to be handled here because they |
| 531 | * affect the power state of the device, for example, the power keys. |
| 532 | * Generally, it's best to keep as little as possible in the queue thread |
| 533 | * because it's the most fragile. |
| 534 | * |
| 535 | * @param event the raw input event as read from the driver |
| 536 | * @param screenIsOn true if the screen is already on |
| 537 | * @return The bitwise or of the {@link #ACTION_PASS_TO_USER}, |
| 538 | * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags. |
| 539 | */ |
| 540 | public int interceptKeyTq(RawInputEvent event, boolean screenIsOn); |
| 541 | |
| 542 | /** |
| 543 | * Called from the input thread before a key is dispatched to a window. |
| 544 | * |
| 545 | * <p>Allows you to define |
| 546 | * behavior for keys that can not be overridden by applications or redirect |
| 547 | * key events to a different window. This method is called from the |
| 548 | * input thread, with no locks held. |
| 549 | * |
| 550 | * <p>Note that if you change the window a key is dispatched to, the new |
| 551 | * target window will receive the key event without having input focus. |
| 552 | * |
| 553 | * @param win The window that currently has focus. This is where the key |
| 554 | * event will normally go. |
| 555 | * @param code Key code. |
Dianne Hackborn | ddca3ee | 2009-07-23 19:01:31 -0700 | [diff] [blame] | 556 | * @param metaKeys bit mask of meta keys that are held. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 557 | * @param down Is this a key press (true) or release (false)? |
| 558 | * @param repeatCount Number of times a key down has repeated. |
Dianne Hackborn | ddca3ee | 2009-07-23 19:01:31 -0700 | [diff] [blame] | 559 | * @param flags event's flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 560 | * @return Returns true if the policy consumed the event and it should |
| 561 | * not be further dispatched. |
| 562 | */ |
| 563 | public boolean interceptKeyTi(WindowState win, int code, |
Dianne Hackborn | ddca3ee | 2009-07-23 19:01:31 -0700 | [diff] [blame] | 564 | int metaKeys, boolean down, int repeatCount, int flags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 565 | |
| 566 | /** |
| 567 | * Called when layout of the windows is about to start. |
| 568 | * |
| 569 | * @param displayWidth The current full width of the screen. |
| 570 | * @param displayHeight The current full height of the screen. |
| 571 | */ |
| 572 | public void beginLayoutLw(int displayWidth, int displayHeight); |
| 573 | |
| 574 | /** |
| 575 | * Called for each window attached to the window manager as layout is |
| 576 | * proceeding. The implementation of this function must take care of |
| 577 | * setting the window's frame, either here or in finishLayout(). |
| 578 | * |
| 579 | * @param win The window being positioned. |
| 580 | * @param attrs The LayoutParams of the window. |
| 581 | * @param attached For sub-windows, the window it is attached to; this |
| 582 | * window will already have had layoutWindow() called on it |
| 583 | * so you can use its Rect. Otherwise null. |
| 584 | */ |
| 585 | public void layoutWindowLw(WindowState win, |
| 586 | WindowManager.LayoutParams attrs, WindowState attached); |
| 587 | |
| 588 | |
| 589 | /** |
| 590 | * Return the insets for the areas covered by system windows. These values |
| 591 | * are computed on the most recent layout, so they are not guaranteed to |
| 592 | * be correct. |
| 593 | * |
| 594 | * @param attrs The LayoutParams of the window. |
| 595 | * @param contentInset The areas covered by system windows, expressed as positive insets |
| 596 | * |
| 597 | */ |
| 598 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset); |
| 599 | |
| 600 | /** |
| 601 | * Called when layout of the windows is finished. After this function has |
| 602 | * returned, all windows given to layoutWindow() <em>must</em> have had a |
| 603 | * frame assigned. |
Dianne Hackborn | 7ac3f67 | 2009-03-31 18:00:53 -0700 | [diff] [blame] | 604 | * |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame^] | 605 | * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT} |
| 606 | * and {@link #FINISH_LAYOUT_REDO_CONFIG}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 607 | */ |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame^] | 608 | public int finishLayoutLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 609 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame^] | 610 | /** Layout state may have changed (so another layout will be performed) */ |
| 611 | static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001; |
| 612 | /** Configuration state may have changed */ |
| 613 | static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002; |
| 614 | /** Wallpaper may need to move */ |
| 615 | static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004; |
| 616 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 617 | /** |
| 618 | * Called when animation of the windows is about to start. |
| 619 | * |
| 620 | * @param displayWidth The current full width of the screen. |
| 621 | * @param displayHeight The current full height of the screen. |
| 622 | */ |
| 623 | public void beginAnimationLw(int displayWidth, int displayHeight); |
| 624 | |
| 625 | /** |
| 626 | * Called each time a window is animating. |
| 627 | * |
| 628 | * @param win The window being positioned. |
| 629 | * @param attrs The LayoutParams of the window. |
| 630 | */ |
| 631 | public void animatingWindowLw(WindowState win, |
| 632 | WindowManager.LayoutParams attrs); |
| 633 | |
| 634 | /** |
| 635 | * Called when animation of the windows is finished. If in this function you do |
| 636 | * something that may have modified the animation state of another window, |
| 637 | * be sure to return true in order to perform another animation frame. |
| 638 | * |
| 639 | * @return Return true if animation state may have changed (so that another |
| 640 | * frame of animation will be run). |
| 641 | */ |
| 642 | public boolean finishAnimationLw(); |
| 643 | |
| 644 | /** |
| 645 | * Called after the screen turns off. |
| 646 | * |
| 647 | * @param why {@link #OFF_BECAUSE_OF_USER} or |
| 648 | * {@link #OFF_BECAUSE_OF_TIMEOUT}. |
| 649 | */ |
| 650 | public void screenTurnedOff(int why); |
| 651 | |
| 652 | /** |
| 653 | * Called after the screen turns on. |
| 654 | */ |
| 655 | public void screenTurnedOn(); |
| 656 | |
| 657 | /** |
| 658 | * Perform any initial processing of a low-level input event before the |
| 659 | * window manager handles special keys and generates a high-level event |
| 660 | * that is dispatched to the application. |
| 661 | * |
| 662 | * @param event The input event that has occurred. |
| 663 | * |
| 664 | * @return Return true if you have consumed the event and do not want |
| 665 | * further processing to occur; return false for normal processing. |
| 666 | */ |
| 667 | public boolean preprocessInputEventTq(RawInputEvent event); |
| 668 | |
| 669 | /** |
| 670 | * Determine whether a given key code is used to cause an app switch |
| 671 | * to occur (most often the HOME key, also often ENDCALL). If you return |
| 672 | * true, then the system will go into a special key processing state |
| 673 | * where it drops any pending events that it cans and adjusts timeouts to |
| 674 | * try to get to this key as quickly as possible. |
| 675 | * |
| 676 | * <p>Note that this function is called from the low-level input queue |
| 677 | * thread, with either/or the window or input lock held; be very careful |
| 678 | * about what you do here. You absolutely should never acquire a lock |
| 679 | * that you would ever hold elsewhere while calling out into the window |
| 680 | * manager or view hierarchy. |
| 681 | * |
| 682 | * @param keycode The key that should be checked for performing an |
| 683 | * app switch before delivering to the application. |
| 684 | * |
| 685 | * @return Return true if this is an app switch key and special processing |
| 686 | * should happen; return false for normal processing. |
| 687 | */ |
| 688 | public boolean isAppSwitchKeyTqTiLwLi(int keycode); |
| 689 | |
| 690 | /** |
| 691 | * Determine whether a given key code is used for movement within a UI, |
| 692 | * and does not generally cause actions to be performed (normally the DPAD |
| 693 | * movement keys, NOT the DPAD center press key). This is called |
| 694 | * when {@link #isAppSwitchKeyTiLi} returns true to remove any pending events |
| 695 | * in the key queue that are not needed to switch applications. |
| 696 | * |
| 697 | * <p>Note that this function is called from the low-level input queue |
| 698 | * thread; be very careful about what you do here. |
| 699 | * |
| 700 | * @param keycode The key that is waiting to be delivered to the |
| 701 | * application. |
| 702 | * |
| 703 | * @return Return true if this is a purely navigation key and can be |
| 704 | * dropped without negative consequences; return false to keep it. |
| 705 | */ |
| 706 | public boolean isMovementKeyTi(int keycode); |
| 707 | |
| 708 | /** |
| 709 | * Given the current state of the world, should this relative movement |
| 710 | * wake up the device? |
| 711 | * |
| 712 | * @param device The device the movement came from. |
| 713 | * @param classes The input classes associated with the device. |
| 714 | * @param event The input event that occurred. |
| 715 | * @return |
| 716 | */ |
| 717 | public boolean isWakeRelMovementTq(int device, int classes, |
| 718 | RawInputEvent event); |
| 719 | |
| 720 | /** |
| 721 | * Given the current state of the world, should this absolute movement |
| 722 | * wake up the device? |
| 723 | * |
| 724 | * @param device The device the movement came from. |
| 725 | * @param classes The input classes associated with the device. |
| 726 | * @param event The input event that occurred. |
| 727 | * @return |
| 728 | */ |
| 729 | public boolean isWakeAbsMovementTq(int device, int classes, |
| 730 | RawInputEvent event); |
| 731 | |
| 732 | /** |
| 733 | * Tell the policy if anyone is requesting that keyguard not come on. |
| 734 | * |
| 735 | * @param enabled Whether keyguard can be on or not. does not actually |
| 736 | * turn it on, unless it was previously disabled with this function. |
| 737 | * |
| 738 | * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard() |
| 739 | * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard() |
| 740 | */ |
| 741 | public void enableKeyguard(boolean enabled); |
| 742 | |
| 743 | /** |
| 744 | * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely} |
| 745 | */ |
| 746 | interface OnKeyguardExitResult { |
| 747 | void onKeyguardExitResult(boolean success); |
| 748 | } |
| 749 | |
| 750 | /** |
| 751 | * Tell the policy if anyone is requesting the keyguard to exit securely |
| 752 | * (this would be called after the keyguard was disabled) |
| 753 | * @param callback Callback to send the result back. |
| 754 | * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult) |
| 755 | */ |
| 756 | void exitKeyguardSecurely(OnKeyguardExitResult callback); |
| 757 | |
| 758 | /** |
| 759 | * Return if keyguard is currently showing. |
| 760 | */ |
| 761 | public boolean keyguardIsShowingTq(); |
| 762 | |
| 763 | /** |
| 764 | * inKeyguardRestrictedKeyInputMode |
| 765 | * |
| 766 | * if keyguard screen is showing or in restricted key input mode (i.e. in |
| 767 | * keyguard password emergency screen). When in such mode, certain keys, |
| 768 | * such as the Home key and the right soft keys, don't work. |
| 769 | * |
| 770 | * @return true if in keyguard restricted input mode. |
| 771 | */ |
| 772 | public boolean inKeyguardRestrictedKeyInputMode(); |
| 773 | |
| 774 | /** |
| 775 | * Given an orientation constant |
| 776 | * ({@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE |
| 777 | * ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE} or |
| 778 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_PORTRAIT |
| 779 | * ActivityInfo.SCREEN_ORIENTATION_PORTRAIT}), return a surface |
| 780 | * rotation. |
| 781 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 782 | public int rotationForOrientationLw(int orientation, int lastRotation, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 783 | boolean displayEnabled); |
| 784 | |
| 785 | /** |
| 786 | * Called when the system is mostly done booting to dentermine whether |
| 787 | * the system should go into safe mode. |
| 788 | */ |
| 789 | public boolean detectSafeMode(); |
| 790 | |
| 791 | /** |
| 792 | * Called when the system is mostly done booting. |
| 793 | */ |
| 794 | public void systemReady(); |
| 795 | |
| 796 | /** |
| 797 | * Called when we have finished booting and can now display the home |
| 798 | * screen to the user. This wilWl happen after systemReady(), and at |
| 799 | * this point the display is active. |
| 800 | */ |
| 801 | public void enableScreenAfterBoot(); |
| 802 | |
| 803 | /** |
| 804 | * Returns true if the user's cheek has been pressed against the phone. This is |
| 805 | * determined by comparing the event's size attribute with a threshold value. |
| 806 | * For example for a motion event like down or up or move, if the size exceeds |
| 807 | * the threshold, it is considered as cheek press. |
| 808 | * @param ev the motion event generated when the cheek is pressed |
| 809 | * against the phone |
| 810 | * @return Returns true if the user's cheek has been pressed against the phone |
| 811 | * screen resulting in an invalid motion event |
| 812 | */ |
| 813 | public boolean isCheekPressedAgainstScreen(MotionEvent ev); |
| 814 | |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 815 | public void setCurrentOrientationLw(int newOrientation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 816 | |
| 817 | /** |
| 818 | * Call from application to perform haptic feedback on its window. |
| 819 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 820 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 821 | |
| 822 | /** |
Dianne Hackborn | ddca3ee | 2009-07-23 19:01:31 -0700 | [diff] [blame] | 823 | * A special function that is called from the very low-level input queue |
| 824 | * to provide feedback to the user. Currently only called for virtual |
| 825 | * keys. |
| 826 | */ |
| 827 | public void keyFeedbackFromInput(KeyEvent event); |
| 828 | |
| 829 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 830 | * Called when we have stopped keeping the screen on because a window |
| 831 | * requesting this is no longer visible. |
| 832 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 833 | public void screenOnStoppedLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 834 | } |