blob: 5a418f3edecd53c4426cbbeaad75db111c5fbc86 [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
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080026import java.io.FileDescriptor;
27import java.io.PrintWriter;
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029/**
30 * This interface supplies all UI-specific behavior of the window manager. An
31 * instance of it is created by the window manager when it starts up, and allows
32 * customization of window layering, special window types, key dispatching, and
33 * layout.
34 *
35 * <p>Because this provides deep interaction with the system window manager,
36 * specific methods on this interface can be called from a variety of contexts
37 * with various restrictions on what they can do. These are encoded through
38 * a suffixes at the end of a method encoding the thread the method is called
39 * from and any locks that are held when it is being called; if no suffix
40 * is attached to a method, then it is not called with any locks and may be
41 * called from the main window manager thread or another thread calling into
42 * the window manager.
43 *
44 * <p>The current suffixes are:
45 *
46 * <dl>
47 * <dt> Ti <dd> Called from the input thread. This is the thread that
48 * collects pending input events and dispatches them to the appropriate window.
49 * It may block waiting for events to be processed, so that the input stream is
50 * properly serialized.
51 * <dt> Tq <dd> Called from the low-level input queue thread. This is the
52 * thread that reads events out of the raw input devices and places them
53 * into the global input queue that is read by the <var>Ti</var> thread.
54 * This thread should not block for a long period of time on anything but the
55 * key driver.
56 * <dt> Lw <dd> Called with the main window manager lock held. Because the
57 * window manager is a very low-level system service, there are few other
58 * system services you can call with this lock held. It is explicitly okay to
59 * make calls into the package manager and power manager; it is explicitly not
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070060 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061 * {@link android.content.Context#checkPermission(String, int, int)} and
62 * variations require calling into the activity manager.
63 * <dt> Li <dd> Called with the input thread lock held. This lock can be
64 * acquired by the window manager while it holds the window lock, so this is
65 * even more restrictive than <var>Lw</var>.
66 * </dl>
67 *
68 * @hide
69 */
70public interface WindowManagerPolicy {
Jeff Brownb6997262010-10-08 22:31:17 -070071 // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 public final static int FLAG_WAKE = 0x00000001;
73 public final static int FLAG_WAKE_DROPPED = 0x00000002;
74 public final static int FLAG_SHIFT = 0x00000004;
75 public final static int FLAG_CAPS_LOCK = 0x00000008;
76 public final static int FLAG_ALT = 0x00000010;
77 public final static int FLAG_ALT_GR = 0x00000020;
78 public final static int FLAG_MENU = 0x00000040;
79 public final static int FLAG_LAUNCHER = 0x00000080;
Jeff Brown0eaf3932010-10-01 14:55:30 -070080 public final static int FLAG_VIRTUAL = 0x00000100;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081
Jeff Brown85a31762010-09-01 17:01:00 -070082 public final static int FLAG_INJECTED = 0x01000000;
Jeff Browne20c9e02010-10-11 14:20:19 -070083 public final static int FLAG_TRUSTED = 0x02000000;
Jeff Brown0029c662011-03-30 02:25:18 -070084 public final static int FLAG_FILTERED = 0x04000000;
85 public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
Jeff Brown85a31762010-09-01 17:01:00 -070086
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080087 public final static int FLAG_WOKE_HERE = 0x10000000;
88 public final static int FLAG_BRIGHT_HERE = 0x20000000;
Jeff Brownb6997262010-10-08 22:31:17 -070089 public final static int FLAG_PASS_TO_USER = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080090
91 public final static boolean WATCH_POINTER = false;
92
Dianne Hackbornad7fa7f2011-01-07 14:06:50 -080093 /**
94 * Sticky broadcast of the current HDMI plugged state.
95 */
96 public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
97
98 /**
99 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
100 * plugged in to HDMI, false if not.
101 */
102 public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
103
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104 // flags for interceptKeyTq
105 /**
106 * Pass this event to the user / app. To be returned from {@link #interceptKeyTq}.
107 */
108 public final static int ACTION_PASS_TO_USER = 0x00000001;
109
110 /**
111 * This key event should extend the user activity timeout and turn the lights on.
112 * To be returned from {@link #interceptKeyTq}. Do not return this and
113 * {@link #ACTION_GO_TO_SLEEP} or {@link #ACTION_PASS_TO_USER}.
114 */
115 public final static int ACTION_POKE_USER_ACTIVITY = 0x00000002;
116
117 /**
118 * This key event should put the device to sleep (and engage keyguard if necessary)
119 * To be returned from {@link #interceptKeyTq}. Do not return this and
120 * {@link #ACTION_POKE_USER_ACTIVITY} or {@link #ACTION_PASS_TO_USER}.
121 */
122 public final static int ACTION_GO_TO_SLEEP = 0x00000004;
123
124 /**
125 * Interface to the Window Manager state associated with a particular
126 * window. You can hold on to an instance of this interface from the call
127 * to prepareAddWindow() until removeWindow().
128 */
129 public interface WindowState {
130 /**
131 * Perform standard frame computation. The result can be obtained with
132 * getFrame() if so desired. Must be called with the window manager
133 * lock held.
134 *
135 * @param parentFrame The frame of the parent container this window
136 * is in, used for computing its basic position.
137 * @param displayFrame The frame of the overall display in which this
138 * window can appear, used for constraining the overall dimensions
139 * of the window.
140 * @param contentFrame The frame within the display in which we would
141 * like active content to appear. This will cause windows behind to
142 * be resized to match the given content frame.
143 * @param visibleFrame The frame within the display that the window
144 * is actually visible, used for computing its visible insets to be
145 * given to windows behind.
146 * This can be used as a hint for scrolling (avoiding resizing)
147 * the window to make certain that parts of its content
148 * are visible.
149 */
150 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
151 Rect contentFrame, Rect visibleFrame);
152
153 /**
154 * Retrieve the current frame of the window that has been assigned by
155 * the window manager. Must be called with the window manager lock held.
156 *
157 * @return Rect The rectangle holding the window frame.
158 */
159 public Rect getFrameLw();
160
161 /**
162 * Retrieve the current frame of the window that is actually shown.
163 * Must be called with the window manager lock held.
164 *
165 * @return Rect The rectangle holding the shown window frame.
166 */
167 public Rect getShownFrameLw();
168
169 /**
170 * Retrieve the frame of the display that this window was last
171 * laid out in. Must be called with the
172 * window manager lock held.
173 *
174 * @return Rect The rectangle holding the display frame.
175 */
176 public Rect getDisplayFrameLw();
177
178 /**
179 * Retrieve the frame of the content area that this window was last
180 * laid out in. This is the area in which the content of the window
181 * should be placed. It will be smaller than the display frame to
182 * account for screen decorations such as a status bar or soft
183 * keyboard. Must be called with the
184 * window manager lock held.
185 *
186 * @return Rect The rectangle holding the content frame.
187 */
188 public Rect getContentFrameLw();
189
190 /**
191 * Retrieve the frame of the visible area that this window was last
192 * laid out in. This is the area of the screen in which the window
193 * will actually be fully visible. It will be smaller than the
194 * content frame to account for transient UI elements blocking it
195 * such as an input method's candidates UI. Must be called with the
196 * window manager lock held.
197 *
198 * @return Rect The rectangle holding the visible frame.
199 */
200 public Rect getVisibleFrameLw();
201
202 /**
203 * Returns true if this window is waiting to receive its given
204 * internal insets from the client app, and so should not impact the
205 * layout of other windows.
206 */
207 public boolean getGivenInsetsPendingLw();
208
209 /**
210 * Retrieve the insets given by this window's client for the content
211 * area of windows behind it. Must be called with the
212 * window manager lock held.
213 *
214 * @return Rect The left, top, right, and bottom insets, relative
215 * to the window's frame, of the actual contents.
216 */
217 public Rect getGivenContentInsetsLw();
218
219 /**
220 * Retrieve the insets given by this window's client for the visible
221 * area of windows behind it. Must be called with the
222 * window manager lock held.
223 *
224 * @return Rect The left, top, right, and bottom insets, relative
225 * to the window's frame, of the actual visible area.
226 */
227 public Rect getGivenVisibleInsetsLw();
228
229 /**
230 * Retrieve the current LayoutParams of the window.
231 *
232 * @return WindowManager.LayoutParams The window's internal LayoutParams
233 * instance.
234 */
235 public WindowManager.LayoutParams getAttrs();
236
237 /**
238 * Get the layer at which this window's surface will be Z-ordered.
239 */
240 public int getSurfaceLayer();
241
242 /**
243 * Return the token for the application (actually activity) that owns
244 * this window. May return null for system windows.
245 *
246 * @return An IApplicationToken identifying the owning activity.
247 */
248 public IApplicationToken getAppToken();
249
250 /**
251 * Return true if, at any point, the application token associated with
252 * this window has actually displayed any windows. This is most useful
253 * with the "starting up" window to determine if any windows were
254 * displayed when it is closed.
255 *
256 * @return Returns true if one or more windows have been displayed,
257 * else false.
258 */
259 public boolean hasAppShownWindows();
260
261 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800262 * Is this window visible? It is not visible if there is no
263 * surface, or we are in the process of running an exit animation
264 * that will remove the surface.
265 */
266 boolean isVisibleLw();
267
268 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700269 * Like {@link #isVisibleLw}, but also counts a window that is currently
270 * "hidden" behind the keyguard as visible. This allows us to apply
271 * things like window flags that impact the keyguard.
272 */
273 boolean isVisibleOrBehindKeyguardLw();
274
275 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800276 * Is this window currently visible to the user on-screen? It is
277 * displayed either if it is visible or it is currently running an
278 * animation before no longer being visible. Must be called with the
279 * window manager lock held.
280 */
281 boolean isDisplayedLw();
282
283 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800284 * Returns true if this window has been shown on screen at some time in
285 * the past. Must be called with the window manager lock held.
286 *
287 * @return boolean
288 */
289 public boolean hasDrawnLw();
290
291 /**
292 * Can be called by the policy to force a window to be hidden,
293 * regardless of whether the client or window manager would like
294 * it shown. Must be called with the window manager lock held.
295 * Returns true if {@link #showLw} was last called for the window.
296 */
297 public boolean hideLw(boolean doAnimation);
298
299 /**
300 * Can be called to undo the effect of {@link #hideLw}, allowing a
301 * window to be shown as long as the window manager and client would
302 * also like it to be shown. Must be called with the window manager
303 * lock held.
304 * Returns true if {@link #hideLw} was last called for the window.
305 */
306 public boolean showLw(boolean doAnimation);
307 }
308
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700309 /**
310 * Bit mask that is set for all enter transition.
311 */
312 public final int TRANSIT_ENTER_MASK = 0x1000;
313
314 /**
315 * Bit mask that is set for all exit transitions.
316 */
317 public final int TRANSIT_EXIT_MASK = 0x2000;
318
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700319 /** Not set up for a transition. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700320 public final int TRANSIT_UNSET = -1;
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700321 /** No animation for transition. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800322 public final int TRANSIT_NONE = 0;
323 /** Window has been added to the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700324 public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325 /** Window has been removed from the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700326 public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 /** Window has been made visible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700328 public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 /** Window has been made invisible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700330 public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 /** The "application starting" preview window is no longer needed, and will
332 * animate away to show the real window. */
333 public final int TRANSIT_PREVIEW_DONE = 5;
334 /** A window in a new activity is being opened on top of an existing one
335 * in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700336 public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800337 /** The window in the top-most activity is being closed to reveal the
338 * previous activity in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700339 public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800340 /** A window in a new task is being opened on top of an existing one
341 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700342 public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800343 /** A window in the top-most activity is being closed to reveal the
344 * previous activity in a different task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700345 public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 /** A window in an existing task is being displayed on top of an existing one
347 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700348 public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800349 /** A window in an existing task is being put below all other tasks. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700350 public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700351 /** A window in a new activity that doesn't have a wallpaper is being
352 * opened on top of one that does, effectively closing the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700353 public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700354 /** A window in a new activity that does have a wallpaper is being
355 * opened on one that didn't, effectively opening the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700356 public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700357 /** A window in a new activity is being opened on top of an existing one,
358 * and both are on top of the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700359 public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700360 /** The window in the top-most activity is being closed to reveal the
361 * previous activity, and both are on top of he wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700362 public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800363
Dianne Hackborn254cb442010-01-27 19:23:59 -0800364 // NOTE: screen off reasons are in order of significance, with more
365 // important ones lower than less important ones.
366
367 /** Screen turned off because of a device admin */
368 public final int OFF_BECAUSE_OF_ADMIN = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369 /** Screen turned off because of power button */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800370 public final int OFF_BECAUSE_OF_USER = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800371 /** Screen turned off because of timeout */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800372 public final int OFF_BECAUSE_OF_TIMEOUT = 3;
Mike Lockwood435eb642009-12-03 08:40:18 -0500373 /** Screen turned off because of proximity sensor */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800374 public final int OFF_BECAUSE_OF_PROX_SENSOR = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800375
376 /**
377 * Magic constant to {@link IWindowManager#setRotation} to not actually
378 * modify the rotation.
379 */
380 public final int USE_LAST_ROTATION = -1000;
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400381
382 /** When not otherwise specified by the activity's screenOrientation, rotation should be
383 * determined by the system (that is, using sensors). */
384 public final int USER_ROTATION_FREE = 0;
385 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
386 * the user. */
387 public final int USER_ROTATION_LOCKED = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800388
389 /**
390 * Perform initialization of the policy.
391 *
392 * @param context The system context we are running in.
393 * @param powerManager
394 */
395 public void init(Context context, IWindowManager windowManager,
396 LocalPowerManager powerManager);
397
398 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700399 * Called by window manager once it has the initial, default native
400 * display dimensions.
401 */
402 public void setInitialDisplaySize(int width, int height);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700403
Dianne Hackborn9d132642011-04-21 17:26:39 -0700404 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405 * Check permissions when adding a window.
406 *
407 * @param attrs The window's LayoutParams.
408 *
409 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed;
410 * else an error code, usually
411 * {@link WindowManagerImpl#ADD_PERMISSION_DENIED}, to abort the add.
412 */
413 public int checkAddPermission(WindowManager.LayoutParams attrs);
414
415 /**
416 * Sanitize the layout parameters coming from a client. Allows the policy
417 * to do things like ensure that windows of a specific type can't take
418 * input focus.
419 *
420 * @param attrs The window layout parameters to be modified. These values
421 * are modified in-place.
422 */
423 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
424
425 /**
426 * After the window manager has computed the current configuration based
427 * on its knowledge of the display and input devices, it gives the policy
428 * a chance to adjust the information contained in it. If you want to
429 * leave it as-is, simply do nothing.
430 *
431 * <p>This method may be called by any thread in the window manager, but
432 * no internal locks in the window manager will be held.
433 *
434 * @param config The Configuration being computed, for you to change as
435 * desired.
436 */
437 public void adjustConfigurationLw(Configuration config);
438
439 /**
440 * Assign a window type to a layer. Allows you to control how different
441 * kinds of windows are ordered on-screen.
442 *
443 * @param type The type of window being assigned.
444 *
445 * @return int An arbitrary integer used to order windows, with lower
446 * numbers below higher ones.
447 */
448 public int windowTypeToLayerLw(int type);
449
450 /**
451 * Return how to Z-order sub-windows in relation to the window they are
452 * attached to. Return positive to have them ordered in front, negative for
453 * behind.
454 *
455 * @param type The sub-window type code.
456 *
457 * @return int Layer in relation to the attached window, where positive is
458 * above and negative is below.
459 */
460 public int subWindowTypeToLayerLw(int type);
461
462 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700463 * Get the highest layer (actually one more than) that the wallpaper is
464 * allowed to be in.
465 */
466 public int getMaxWallpaperLayer();
467
468 /**
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400469 * Return the display width available after excluding the window
470 * decor.
471 */
472 public int getNonDecorDisplayWidth(int fullWidth);
473
474 /**
475 * Return the display height available after excluding the screen
476 * decor.
477 */
478 public int getNonDecorDisplayHeight(int fullHeight);
479
480 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700481 * Return whether the given window should forcibly hide everything
482 * behind it. Typically returns true for the keyguard.
483 */
484 public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
485
486 /**
487 * Determine if a window that is behind one that is force hiding
488 * (as determined by {@link #doesForceHide}) should actually be hidden.
489 * For example, typically returns false for the status bar. Be careful
490 * to return false for any window that you may hide yourself, since this
491 * will conflict with what you set.
492 */
493 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
494
495 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800496 * Called when the system would like to show a UI to indicate that an
497 * application is starting. You can use this to add a
498 * APPLICATION_STARTING_TYPE window with the given appToken to the window
499 * manager (using the normal window manager APIs) that will be shown until
500 * the application displays its own window. This is called without the
501 * window manager locked so that you can call back into it.
502 *
503 * @param appToken Token of the application being started.
504 * @param packageName The name of the application package being started.
505 * @param theme Resource defining the application's overall visual theme.
506 * @param nonLocalizedLabel The default title label of the application if
507 * no data is found in the resource.
508 * @param labelRes The resource ID the application would like to use as its name.
509 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800510 * @param windowFlags Window layout flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800511 *
512 * @return Optionally you can return the View that was used to create the
513 * window, for easy removal in removeStartingWindow.
514 *
515 * @see #removeStartingWindow
516 */
517 public View addStartingWindow(IBinder appToken, String packageName,
518 int theme, CharSequence nonLocalizedLabel,
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800519 int labelRes, int icon, int windowFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800520
521 /**
522 * Called when the first window of an application has been displayed, while
523 * {@link #addStartingWindow} has created a temporary initial window for
524 * that application. You should at this point remove the window from the
525 * window manager. This is called without the window manager locked so
526 * that you can call back into it.
527 *
528 * <p>Note: due to the nature of these functions not being called with the
529 * window manager locked, you must be prepared for this function to be
530 * called multiple times and/or an initial time with a null View window
531 * even if you previously returned one.
532 *
533 * @param appToken Token of the application that has started.
534 * @param window Window View that was returned by createStartingWindow.
535 *
536 * @see #addStartingWindow
537 */
538 public void removeStartingWindow(IBinder appToken, View window);
539
540 /**
541 * Prepare for a window being added to the window manager. You can throw an
542 * exception here to prevent the window being added, or do whatever setup
543 * you need to keep track of the window.
544 *
545 * @param win The window being added.
546 * @param attrs The window's LayoutParams.
547 *
548 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed, else an
549 * error code to abort the add.
550 */
551 public int prepareAddWindowLw(WindowState win,
552 WindowManager.LayoutParams attrs);
553
554 /**
555 * Called when a window is being removed from a window manager. Must not
556 * throw an exception -- clean up as much as possible.
557 *
558 * @param win The window being removed.
559 */
560 public void removeWindowLw(WindowState win);
561
562 /**
563 * Control the animation to run when a window's state changes. Return a
564 * non-0 number to force the animation to a specific resource ID, or 0
565 * to use the default animation.
566 *
567 * @param win The window that is changing.
568 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
569 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
570 * {@link #TRANSIT_HIDE}.
571 *
572 * @return Resource ID of the actual animation to use, or 0 for none.
573 */
574 public int selectAnimationLw(WindowState win, int transit);
575
576 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700577 * Create and return an animation to re-display a force hidden window.
578 */
579 public Animation createForceHideEnterAnimation();
580
581 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700582 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800583 *
584 * <p>There are some actions that need to be handled here because they
585 * affect the power state of the device, for example, the power keys.
586 * Generally, it's best to keep as little as possible in the queue thread
587 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -0800588 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700589 * @param policyFlags The policy flags associated with the key.
590 * @param isScreenOn True if the screen is already on
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800591 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800592 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
593 * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
594 */
Jeff Brown1f245102010-11-18 20:53:46 -0800595 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
Jeff Brown56194eb2011-03-02 19:23:13 -0800596
597 /**
598 * Called from the input reader thread before a motion is enqueued when the screen is off.
599 *
600 * <p>There are some actions that need to be handled here because they
601 * affect the power state of the device, for example, waking on motions.
602 * Generally, it's best to keep as little as possible in the queue thread
603 * because it's the most fragile.
604 * @param policyFlags The policy flags associated with the motion.
605 *
606 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
607 * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
608 */
609 public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags);
610
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800611 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700612 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800613 *
614 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -0700615 * behavior for keys that can not be overridden by applications.
616 * This method is called from the input thread, with no locks held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800617 *
618 * @param win The window that currently has focus. This is where the key
619 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800620 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700621 * @param policyFlags The policy flags associated with the key.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800622 * @return Returns true if the policy consumed the event and it should
623 * not be further dispatched.
624 */
Jeff Brown1f245102010-11-18 20:53:46 -0800625 public boolean interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800626
627 /**
Jeff Brown3915bb82010-11-05 15:02:16 -0700628 * Called from the input dispatcher thread when an application did not handle
629 * a key that was dispatched to it.
630 *
631 * <p>Allows you to define default global behavior for keys that were not handled
632 * by applications. This method is called from the input thread, with no locks held.
633 *
634 * @param win The window that currently has focus. This is where the key
635 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800636 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700637 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -0800638 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
639 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700640 */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800641 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -0700642
643 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800644 * Called when layout of the windows is about to start.
645 *
646 * @param displayWidth The current full width of the screen.
647 * @param displayHeight The current full height of the screen.
648 */
649 public void beginLayoutLw(int displayWidth, int displayHeight);
650
651 /**
652 * Called for each window attached to the window manager as layout is
653 * proceeding. The implementation of this function must take care of
654 * setting the window's frame, either here or in finishLayout().
655 *
656 * @param win The window being positioned.
657 * @param attrs The LayoutParams of the window.
658 * @param attached For sub-windows, the window it is attached to; this
659 * window will already have had layoutWindow() called on it
660 * so you can use its Rect. Otherwise null.
661 */
662 public void layoutWindowLw(WindowState win,
663 WindowManager.LayoutParams attrs, WindowState attached);
664
665
666 /**
667 * Return the insets for the areas covered by system windows. These values
668 * are computed on the most recent layout, so they are not guaranteed to
669 * be correct.
670 *
671 * @param attrs The LayoutParams of the window.
672 * @param contentInset The areas covered by system windows, expressed as positive insets
673 *
674 */
675 public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
676
677 /**
678 * Called when layout of the windows is finished. After this function has
679 * returned, all windows given to layoutWindow() <em>must</em> have had a
680 * frame assigned.
Dianne Hackborn7ac3f672009-03-31 18:00:53 -0700681 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800682 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
683 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
684 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800685 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700686 public int finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800687
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700688 /** Layout state may have changed (so another layout will be performed) */
689 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
690 /** Configuration state may have changed */
691 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
692 /** Wallpaper may need to move */
693 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800694 /** Need to recompute animations */
695 static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700696
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800697 /**
698 * Called when animation of the windows is about to start.
699 *
700 * @param displayWidth The current full width of the screen.
701 * @param displayHeight The current full height of the screen.
702 */
703 public void beginAnimationLw(int displayWidth, int displayHeight);
704
705 /**
706 * Called each time a window is animating.
707 *
708 * @param win The window being positioned.
709 * @param attrs The LayoutParams of the window.
710 */
711 public void animatingWindowLw(WindowState win,
712 WindowManager.LayoutParams attrs);
713
714 /**
715 * Called when animation of the windows is finished. If in this function you do
716 * something that may have modified the animation state of another window,
717 * be sure to return true in order to perform another animation frame.
718 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800719 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
720 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
721 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800722 */
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800723 public int finishAnimationLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800724
725 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800726 * Return true if it is okay to perform animations for an app transition
727 * that is about to occur. You may return false for this if, for example,
728 * the lock screen is currently displayed so the switch should happen
729 * immediately.
730 */
731 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -0800732
733
734 /**
735 * A new window has been focused.
736 */
737 public void focusChanged(WindowState lastFocus, WindowState newFocus);
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800738
739 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800740 * Called after the screen turns off.
741 *
742 * @param why {@link #OFF_BECAUSE_OF_USER} or
743 * {@link #OFF_BECAUSE_OF_TIMEOUT}.
744 */
745 public void screenTurnedOff(int why);
746
747 /**
748 * Called after the screen turns on.
749 */
750 public void screenTurnedOn();
751
752 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800753 * Return whether the screen is currently on.
754 */
755 public boolean isScreenOn();
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700756
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800757 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700758 * Tell the policy that the lid switch has changed state.
759 * @param whenNanos The time when the change occurred in uptime nanoseconds.
760 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800761 */
Jeff Brown46b9ac02010-04-22 18:58:52 -0700762 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
763
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800764 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800765 * Tell the policy if anyone is requesting that keyguard not come on.
766 *
767 * @param enabled Whether keyguard can be on or not. does not actually
768 * turn it on, unless it was previously disabled with this function.
769 *
770 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
771 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
772 */
773 public void enableKeyguard(boolean enabled);
774
775 /**
776 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
777 */
778 interface OnKeyguardExitResult {
779 void onKeyguardExitResult(boolean success);
780 }
781
782 /**
783 * Tell the policy if anyone is requesting the keyguard to exit securely
784 * (this would be called after the keyguard was disabled)
785 * @param callback Callback to send the result back.
786 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
787 */
788 void exitKeyguardSecurely(OnKeyguardExitResult callback);
789
790 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -0500791 * isKeyguardLocked
792 *
793 * Return whether the keyguard is currently locked.
794 *
795 * @return true if in keyguard is locked.
796 */
797 public boolean isKeyguardLocked();
798
799 /**
800 * isKeyguardSecure
801 *
802 * Return whether the keyguard requires a password to unlock.
803 *
804 * @return true if in keyguard is secure.
805 */
806 public boolean isKeyguardSecure();
807
808 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800809 * inKeyguardRestrictedKeyInputMode
810 *
811 * if keyguard screen is showing or in restricted key input mode (i.e. in
812 * keyguard password emergency screen). When in such mode, certain keys,
813 * such as the Home key and the right soft keys, don't work.
814 *
815 * @return true if in keyguard restricted input mode.
816 */
817 public boolean inKeyguardRestrictedKeyInputMode();
818
819 /**
820 * Given an orientation constant
821 * ({@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE
822 * ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE} or
823 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_PORTRAIT
824 * ActivityInfo.SCREEN_ORIENTATION_PORTRAIT}), return a surface
825 * rotation.
826 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700827 public int rotationForOrientationLw(int orientation, int lastRotation,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800828 boolean displayEnabled);
829
830 /**
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700831 * Return the currently locked screen rotation, if any. Return
832 * Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, or
833 * Surface.ROTATION_270 if locked; return -1 if not locked.
834 */
835 public int getLockedRotationLw();
836
837 /**
Dianne Hackborn6af0d502009-09-28 13:25:46 -0700838 * Called when the system is mostly done booting to determine whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800839 * the system should go into safe mode.
840 */
841 public boolean detectSafeMode();
842
843 /**
844 * Called when the system is mostly done booting.
845 */
846 public void systemReady();
847
848 /**
Mike Lockwoodef731622010-01-27 17:51:34 -0500849 * Called when userActivity is signalled in the power manager.
850 * This is safe to call from any thread, with any window manager locks held or not.
851 */
852 public void userActivity();
853
854 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800855 * Called when we have finished booting and can now display the home
856 * screen to the user. This wilWl happen after systemReady(), and at
857 * this point the display is active.
858 */
859 public void enableScreenAfterBoot();
860
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700861 public void setCurrentOrientationLw(int newOrientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800862
863 /**
864 * Call from application to perform haptic feedback on its window.
865 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700866 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800867
868 /**
869 * Called when we have stopped keeping the screen on because a window
870 * requesting this is no longer visible.
871 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700872 public void screenOnStoppedLw();
Mike Lockwood3d0ea722009-10-21 22:58:29 -0400873
874 /**
875 * Return false to disable key repeat events from being generated.
876 */
877 public boolean allowKeyRepeat();
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400878
879 /**
880 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
881 *
882 * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
883 * {@link * WindowManagerPolicy#USER_ROTATION_FREE}.
884 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
885 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
886 */
887 public void setUserRotationMode(int mode, int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -0800888
889 /**
890 * Print the WindowManagerPolicy's state into the given stream.
891 *
892 * @param prefix Text to print at the front of each line.
893 * @param fd The raw file descriptor that the dump is being sent to.
894 * @param writer The PrintWriter to which you should dump your state. This will be
895 * closed for you after you return.
896 * @param args additional arguments to the dump request.
897 */
898 public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800899}