blob: ab3260e13f6cb59d51cc58bb0102e6a5a4d96e98 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.view;
18
19import android.content.Context;
20import android.content.res.Configuration;
21import android.graphics.Rect;
22import android.os.IBinder;
23import android.os.LocalPowerManager;
24import 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 Projectc39a6e02009-03-11 12:11:56 -070057 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080058 * {@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 */
67public 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 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800240 * Is this window visible? It is not visible if there is no
241 * surface, or we are in the process of running an exit animation
242 * that will remove the surface.
243 */
244 boolean isVisibleLw();
245
246 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700247 * Like {@link #isVisibleLw}, but also counts a window that is currently
248 * "hidden" behind the keyguard as visible. This allows us to apply
249 * things like window flags that impact the keyguard.
250 */
251 boolean isVisibleOrBehindKeyguardLw();
252
253 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800254 * Is this window currently visible to the user on-screen? It is
255 * displayed either if it is visible or it is currently running an
256 * animation before no longer being visible. Must be called with the
257 * window manager lock held.
258 */
259 boolean isDisplayedLw();
260
261 /**
262 * Returns true if the window is both full screen and opaque. Must be
263 * called with the window manager lock held.
264 *
265 * @param width The width of the screen
266 * @param height The height of the screen
267 * @param shownFrame If true, this is based on the actual shown frame of
268 * the window (taking into account animations); if
269 * false, this is based on the currently requested
270 * frame, which any current animation will be moving
271 * towards.
272 * @param onlyOpaque If true, this will only pass if the window is
273 * also opaque.
274 * @return Returns true if the window is both full screen and opaque
275 */
276 public boolean fillsScreenLw(int width, int height, boolean shownFrame,
277 boolean onlyOpaque);
278
279 /**
280 * Returns true if this window has been shown on screen at some time in
281 * the past. Must be called with the window manager lock held.
282 *
283 * @return boolean
284 */
285 public boolean hasDrawnLw();
286
287 /**
288 * Can be called by the policy to force a window to be hidden,
289 * regardless of whether the client or window manager would like
290 * it shown. Must be called with the window manager lock held.
291 * Returns true if {@link #showLw} was last called for the window.
292 */
293 public boolean hideLw(boolean doAnimation);
294
295 /**
296 * Can be called to undo the effect of {@link #hideLw}, allowing a
297 * window to be shown as long as the window manager and client would
298 * also like it to be shown. Must be called with the window manager
299 * lock held.
300 * Returns true if {@link #hideLw} was last called for the window.
301 */
302 public boolean showLw(boolean doAnimation);
303 }
304
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700305 /**
306 * Bit mask that is set for all enter transition.
307 */
308 public final int TRANSIT_ENTER_MASK = 0x1000;
309
310 /**
311 * Bit mask that is set for all exit transitions.
312 */
313 public final int TRANSIT_EXIT_MASK = 0x2000;
314
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700315 /** Not set up for a transition. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700316 public final int TRANSIT_UNSET = -1;
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700317 /** No animation for transition. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318 public final int TRANSIT_NONE = 0;
319 /** Window has been added to the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700320 public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800321 /** Window has been removed from the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700322 public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800323 /** Window has been made visible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700324 public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325 /** Window has been made invisible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700326 public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 /** The "application starting" preview window is no longer needed, and will
328 * animate away to show the real window. */
329 public final int TRANSIT_PREVIEW_DONE = 5;
330 /** A window in a new activity is being opened on top of an existing one
331 * in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700332 public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800333 /** The window in the top-most activity is being closed to reveal the
334 * previous activity in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700335 public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800336 /** A window in a new task is being opened on top of an existing one
337 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700338 public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339 /** A window in the top-most activity is being closed to reveal the
340 * previous activity in a different task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700341 public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 /** A window in an existing task is being displayed on top of an existing one
343 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700344 public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800345 /** A window in an existing task is being put below all other tasks. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700346 public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700347 /** A window in a new activity that doesn't have a wallpaper is being
348 * opened on top of one that does, effectively closing the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700349 public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700350 /** A window in a new activity that does have a wallpaper is being
351 * opened on one that didn't, effectively opening the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700352 public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700353 /** A window in a new activity is being opened on top of an existing one,
354 * and both are on top of the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700355 public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700356 /** The window in the top-most activity is being closed to reveal the
357 * previous activity, and both are on top of he wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700358 public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800359
Dianne Hackborn254cb442010-01-27 19:23:59 -0800360 // NOTE: screen off reasons are in order of significance, with more
361 // important ones lower than less important ones.
362
363 /** Screen turned off because of a device admin */
364 public final int OFF_BECAUSE_OF_ADMIN = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800365 /** Screen turned off because of power button */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800366 public final int OFF_BECAUSE_OF_USER = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800367 /** Screen turned off because of timeout */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800368 public final int OFF_BECAUSE_OF_TIMEOUT = 3;
Mike Lockwood435eb642009-12-03 08:40:18 -0500369 /** Screen turned off because of proximity sensor */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800370 public final int OFF_BECAUSE_OF_PROX_SENSOR = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800371
372 /**
373 * Magic constant to {@link IWindowManager#setRotation} to not actually
374 * modify the rotation.
375 */
376 public final int USE_LAST_ROTATION = -1000;
377
378 /**
379 * Perform initialization of the policy.
380 *
381 * @param context The system context we are running in.
382 * @param powerManager
383 */
384 public void init(Context context, IWindowManager windowManager,
385 LocalPowerManager powerManager);
386
387 /**
388 * Check permissions when adding a window.
389 *
390 * @param attrs The window's LayoutParams.
391 *
392 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed;
393 * else an error code, usually
394 * {@link WindowManagerImpl#ADD_PERMISSION_DENIED}, to abort the add.
395 */
396 public int checkAddPermission(WindowManager.LayoutParams attrs);
397
398 /**
399 * Sanitize the layout parameters coming from a client. Allows the policy
400 * to do things like ensure that windows of a specific type can't take
401 * input focus.
402 *
403 * @param attrs The window layout parameters to be modified. These values
404 * are modified in-place.
405 */
406 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
407
408 /**
409 * After the window manager has computed the current configuration based
410 * on its knowledge of the display and input devices, it gives the policy
411 * a chance to adjust the information contained in it. If you want to
412 * leave it as-is, simply do nothing.
413 *
414 * <p>This method may be called by any thread in the window manager, but
415 * no internal locks in the window manager will be held.
416 *
417 * @param config The Configuration being computed, for you to change as
418 * desired.
419 */
420 public void adjustConfigurationLw(Configuration config);
421
422 /**
423 * Assign a window type to a layer. Allows you to control how different
424 * kinds of windows are ordered on-screen.
425 *
426 * @param type The type of window being assigned.
427 *
428 * @return int An arbitrary integer used to order windows, with lower
429 * numbers below higher ones.
430 */
431 public int windowTypeToLayerLw(int type);
432
433 /**
434 * Return how to Z-order sub-windows in relation to the window they are
435 * attached to. Return positive to have them ordered in front, negative for
436 * behind.
437 *
438 * @param type The sub-window type code.
439 *
440 * @return int Layer in relation to the attached window, where positive is
441 * above and negative is below.
442 */
443 public int subWindowTypeToLayerLw(int type);
444
445 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700446 * Get the highest layer (actually one more than) that the wallpaper is
447 * allowed to be in.
448 */
449 public int getMaxWallpaperLayer();
450
451 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700452 * Return whether the given window should forcibly hide everything
453 * behind it. Typically returns true for the keyguard.
454 */
455 public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
456
457 /**
458 * Determine if a window that is behind one that is force hiding
459 * (as determined by {@link #doesForceHide}) should actually be hidden.
460 * For example, typically returns false for the status bar. Be careful
461 * to return false for any window that you may hide yourself, since this
462 * will conflict with what you set.
463 */
464 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
465
466 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800467 * Called when the system would like to show a UI to indicate that an
468 * application is starting. You can use this to add a
469 * APPLICATION_STARTING_TYPE window with the given appToken to the window
470 * manager (using the normal window manager APIs) that will be shown until
471 * the application displays its own window. This is called without the
472 * window manager locked so that you can call back into it.
473 *
474 * @param appToken Token of the application being started.
475 * @param packageName The name of the application package being started.
476 * @param theme Resource defining the application's overall visual theme.
477 * @param nonLocalizedLabel The default title label of the application if
478 * no data is found in the resource.
479 * @param labelRes The resource ID the application would like to use as its name.
480 * @param icon The resource ID the application would like to use as its icon.
481 *
482 * @return Optionally you can return the View that was used to create the
483 * window, for easy removal in removeStartingWindow.
484 *
485 * @see #removeStartingWindow
486 */
487 public View addStartingWindow(IBinder appToken, String packageName,
488 int theme, CharSequence nonLocalizedLabel,
489 int labelRes, int icon);
490
491 /**
492 * Called when the first window of an application has been displayed, while
493 * {@link #addStartingWindow} has created a temporary initial window for
494 * that application. You should at this point remove the window from the
495 * window manager. This is called without the window manager locked so
496 * that you can call back into it.
497 *
498 * <p>Note: due to the nature of these functions not being called with the
499 * window manager locked, you must be prepared for this function to be
500 * called multiple times and/or an initial time with a null View window
501 * even if you previously returned one.
502 *
503 * @param appToken Token of the application that has started.
504 * @param window Window View that was returned by createStartingWindow.
505 *
506 * @see #addStartingWindow
507 */
508 public void removeStartingWindow(IBinder appToken, View window);
509
510 /**
511 * Prepare for a window being added to the window manager. You can throw an
512 * exception here to prevent the window being added, or do whatever setup
513 * you need to keep track of the window.
514 *
515 * @param win The window being added.
516 * @param attrs The window's LayoutParams.
517 *
518 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed, else an
519 * error code to abort the add.
520 */
521 public int prepareAddWindowLw(WindowState win,
522 WindowManager.LayoutParams attrs);
523
524 /**
525 * Called when a window is being removed from a window manager. Must not
526 * throw an exception -- clean up as much as possible.
527 *
528 * @param win The window being removed.
529 */
530 public void removeWindowLw(WindowState win);
531
532 /**
533 * Control the animation to run when a window's state changes. Return a
534 * non-0 number to force the animation to a specific resource ID, or 0
535 * to use the default animation.
536 *
537 * @param win The window that is changing.
538 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
539 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
540 * {@link #TRANSIT_HIDE}.
541 *
542 * @return Resource ID of the actual animation to use, or 0 for none.
543 */
544 public int selectAnimationLw(WindowState win, int transit);
545
546 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700547 * Create and return an animation to re-display a force hidden window.
548 */
549 public Animation createForceHideEnterAnimation();
550
551 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800552 * Called from the key queue thread before a key is dispatched to the
553 * input thread.
554 *
555 * <p>There are some actions that need to be handled here because they
556 * affect the power state of the device, for example, the power keys.
557 * Generally, it's best to keep as little as possible in the queue thread
558 * because it's the most fragile.
559 *
560 * @param event the raw input event as read from the driver
561 * @param screenIsOn true if the screen is already on
562 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
563 * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
564 */
565 public int interceptKeyTq(RawInputEvent event, boolean screenIsOn);
566
567 /**
568 * Called from the input thread before a key is dispatched to a window.
569 *
570 * <p>Allows you to define
571 * behavior for keys that can not be overridden by applications or redirect
572 * key events to a different window. This method is called from the
573 * input thread, with no locks held.
574 *
575 * <p>Note that if you change the window a key is dispatched to, the new
576 * target window will receive the key event without having input focus.
577 *
578 * @param win The window that currently has focus. This is where the key
579 * event will normally go.
580 * @param code Key code.
Dianne Hackbornddca3ee2009-07-23 19:01:31 -0700581 * @param metaKeys bit mask of meta keys that are held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800582 * @param down Is this a key press (true) or release (false)?
583 * @param repeatCount Number of times a key down has repeated.
Dianne Hackbornddca3ee2009-07-23 19:01:31 -0700584 * @param flags event's flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 * @return Returns true if the policy consumed the event and it should
586 * not be further dispatched.
587 */
588 public boolean interceptKeyTi(WindowState win, int code,
Dianne Hackbornddca3ee2009-07-23 19:01:31 -0700589 int metaKeys, boolean down, int repeatCount, int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800590
591 /**
592 * Called when layout of the windows is about to start.
593 *
594 * @param displayWidth The current full width of the screen.
595 * @param displayHeight The current full height of the screen.
596 */
597 public void beginLayoutLw(int displayWidth, int displayHeight);
598
599 /**
600 * Called for each window attached to the window manager as layout is
601 * proceeding. The implementation of this function must take care of
602 * setting the window's frame, either here or in finishLayout().
603 *
604 * @param win The window being positioned.
605 * @param attrs The LayoutParams of the window.
606 * @param attached For sub-windows, the window it is attached to; this
607 * window will already have had layoutWindow() called on it
608 * so you can use its Rect. Otherwise null.
609 */
610 public void layoutWindowLw(WindowState win,
611 WindowManager.LayoutParams attrs, WindowState attached);
612
613
614 /**
615 * Return the insets for the areas covered by system windows. These values
616 * are computed on the most recent layout, so they are not guaranteed to
617 * be correct.
618 *
619 * @param attrs The LayoutParams of the window.
620 * @param contentInset The areas covered by system windows, expressed as positive insets
621 *
622 */
623 public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
624
625 /**
626 * Called when layout of the windows is finished. After this function has
627 * returned, all windows given to layoutWindow() <em>must</em> have had a
628 * frame assigned.
Dianne Hackborn7ac3f672009-03-31 18:00:53 -0700629 *
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700630 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT}
631 * and {@link #FINISH_LAYOUT_REDO_CONFIG}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800632 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700633 public int finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800634
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700635 /** Layout state may have changed (so another layout will be performed) */
636 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
637 /** Configuration state may have changed */
638 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
639 /** Wallpaper may need to move */
640 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
641
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800642 /**
643 * Called when animation of the windows is about to start.
644 *
645 * @param displayWidth The current full width of the screen.
646 * @param displayHeight The current full height of the screen.
647 */
648 public void beginAnimationLw(int displayWidth, int displayHeight);
649
650 /**
651 * Called each time a window is animating.
652 *
653 * @param win The window being positioned.
654 * @param attrs The LayoutParams of the window.
655 */
656 public void animatingWindowLw(WindowState win,
657 WindowManager.LayoutParams attrs);
658
659 /**
660 * Called when animation of the windows is finished. If in this function you do
661 * something that may have modified the animation state of another window,
662 * be sure to return true in order to perform another animation frame.
663 *
664 * @return Return true if animation state may have changed (so that another
665 * frame of animation will be run).
666 */
667 public boolean finishAnimationLw();
668
669 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800670 * Return true if it is okay to perform animations for an app transition
671 * that is about to occur. You may return false for this if, for example,
672 * the lock screen is currently displayed so the switch should happen
673 * immediately.
674 */
675 public boolean allowAppAnimationsLw();
676
677 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800678 * Called after the screen turns off.
679 *
680 * @param why {@link #OFF_BECAUSE_OF_USER} or
681 * {@link #OFF_BECAUSE_OF_TIMEOUT}.
682 */
683 public void screenTurnedOff(int why);
684
685 /**
686 * Called after the screen turns on.
687 */
688 public void screenTurnedOn();
689
690 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800691 * Return whether the screen is currently on.
692 */
693 public boolean isScreenOn();
694
695 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800696 * Perform any initial processing of a low-level input event before the
697 * window manager handles special keys and generates a high-level event
698 * that is dispatched to the application.
699 *
700 * @param event The input event that has occurred.
701 *
702 * @return Return true if you have consumed the event and do not want
703 * further processing to occur; return false for normal processing.
704 */
705 public boolean preprocessInputEventTq(RawInputEvent event);
706
707 /**
708 * Determine whether a given key code is used to cause an app switch
709 * to occur (most often the HOME key, also often ENDCALL). If you return
710 * true, then the system will go into a special key processing state
711 * where it drops any pending events that it cans and adjusts timeouts to
712 * try to get to this key as quickly as possible.
713 *
714 * <p>Note that this function is called from the low-level input queue
715 * thread, with either/or the window or input lock held; be very careful
716 * about what you do here. You absolutely should never acquire a lock
717 * that you would ever hold elsewhere while calling out into the window
718 * manager or view hierarchy.
719 *
720 * @param keycode The key that should be checked for performing an
721 * app switch before delivering to the application.
722 *
723 * @return Return true if this is an app switch key and special processing
724 * should happen; return false for normal processing.
725 */
726 public boolean isAppSwitchKeyTqTiLwLi(int keycode);
727
728 /**
729 * Determine whether a given key code is used for movement within a UI,
730 * and does not generally cause actions to be performed (normally the DPAD
731 * movement keys, NOT the DPAD center press key). This is called
732 * when {@link #isAppSwitchKeyTiLi} returns true to remove any pending events
733 * in the key queue that are not needed to switch applications.
734 *
735 * <p>Note that this function is called from the low-level input queue
736 * thread; be very careful about what you do here.
737 *
738 * @param keycode The key that is waiting to be delivered to the
739 * application.
740 *
741 * @return Return true if this is a purely navigation key and can be
742 * dropped without negative consequences; return false to keep it.
743 */
744 public boolean isMovementKeyTi(int keycode);
745
746 /**
747 * Given the current state of the world, should this relative movement
748 * wake up the device?
749 *
750 * @param device The device the movement came from.
751 * @param classes The input classes associated with the device.
752 * @param event The input event that occurred.
753 * @return
754 */
755 public boolean isWakeRelMovementTq(int device, int classes,
756 RawInputEvent event);
757
758 /**
759 * Given the current state of the world, should this absolute movement
760 * wake up the device?
761 *
762 * @param device The device the movement came from.
763 * @param classes The input classes associated with the device.
764 * @param event The input event that occurred.
765 * @return
766 */
767 public boolean isWakeAbsMovementTq(int device, int classes,
768 RawInputEvent event);
769
770 /**
771 * Tell the policy if anyone is requesting that keyguard not come on.
772 *
773 * @param enabled Whether keyguard can be on or not. does not actually
774 * turn it on, unless it was previously disabled with this function.
775 *
776 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
777 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
778 */
779 public void enableKeyguard(boolean enabled);
780
781 /**
782 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
783 */
784 interface OnKeyguardExitResult {
785 void onKeyguardExitResult(boolean success);
786 }
787
788 /**
789 * Tell the policy if anyone is requesting the keyguard to exit securely
790 * (this would be called after the keyguard was disabled)
791 * @param callback Callback to send the result back.
792 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
793 */
794 void exitKeyguardSecurely(OnKeyguardExitResult callback);
795
796 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800797 * inKeyguardRestrictedKeyInputMode
798 *
799 * if keyguard screen is showing or in restricted key input mode (i.e. in
800 * keyguard password emergency screen). When in such mode, certain keys,
801 * such as the Home key and the right soft keys, don't work.
802 *
803 * @return true if in keyguard restricted input mode.
804 */
805 public boolean inKeyguardRestrictedKeyInputMode();
806
807 /**
808 * Given an orientation constant
809 * ({@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE
810 * ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE} or
811 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_PORTRAIT
812 * ActivityInfo.SCREEN_ORIENTATION_PORTRAIT}), return a surface
813 * rotation.
814 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700815 public int rotationForOrientationLw(int orientation, int lastRotation,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800816 boolean displayEnabled);
817
818 /**
Dianne Hackborn6af0d502009-09-28 13:25:46 -0700819 * Called when the system is mostly done booting to determine whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800820 * the system should go into safe mode.
821 */
822 public boolean detectSafeMode();
823
824 /**
825 * Called when the system is mostly done booting.
826 */
827 public void systemReady();
828
829 /**
Mike Lockwoodef731622010-01-27 17:51:34 -0500830 * Called when userActivity is signalled in the power manager.
831 * This is safe to call from any thread, with any window manager locks held or not.
832 */
833 public void userActivity();
834
835 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800836 * Called when we have finished booting and can now display the home
837 * screen to the user. This wilWl happen after systemReady(), and at
838 * this point the display is active.
839 */
840 public void enableScreenAfterBoot();
841
842 /**
843 * Returns true if the user's cheek has been pressed against the phone. This is
844 * determined by comparing the event's size attribute with a threshold value.
845 * For example for a motion event like down or up or move, if the size exceeds
846 * the threshold, it is considered as cheek press.
847 * @param ev the motion event generated when the cheek is pressed
848 * against the phone
849 * @return Returns true if the user's cheek has been pressed against the phone
850 * screen resulting in an invalid motion event
851 */
852 public boolean isCheekPressedAgainstScreen(MotionEvent ev);
853
Dianne Hackborn90d2db32010-02-11 22:19:06 -0800854 /**
855 * Called every time the window manager is dispatching a pointer event.
856 */
857 public void dispatchedPointerEventLw(MotionEvent ev, int targetX, int targetY);
858
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700859 public void setCurrentOrientationLw(int newOrientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800860
861 /**
862 * Call from application to perform haptic feedback on its window.
863 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700864 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800865
866 /**
Dianne Hackbornddca3ee2009-07-23 19:01:31 -0700867 * A special function that is called from the very low-level input queue
868 * to provide feedback to the user. Currently only called for virtual
869 * keys.
870 */
871 public void keyFeedbackFromInput(KeyEvent event);
872
873 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800874 * Called when we have stopped keeping the screen on because a window
875 * requesting this is no longer visible.
876 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700877 public void screenOnStoppedLw();
Mike Lockwood3d0ea722009-10-21 22:58:29 -0400878
879 /**
880 * Return false to disable key repeat events from being generated.
881 */
882 public boolean allowKeyRepeat();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800883}