blob: dc1bbd7343b7128b548937ce44a32e5e67128251 [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;
Dianne Hackborn2f0b1752011-05-31 17:59:49 -070020import android.content.res.CompatibilityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.res.Configuration;
22import android.graphics.Rect;
Dianne Hackbornd040edb2011-08-31 12:47:58 -070023import android.graphics.RectF;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.os.IBinder;
25import android.os.LocalPowerManager;
26import android.view.animation.Animation;
27
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080028import java.io.FileDescriptor;
29import java.io.PrintWriter;
30
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031/**
32 * This interface supplies all UI-specific behavior of the window manager. An
33 * instance of it is created by the window manager when it starts up, and allows
34 * customization of window layering, special window types, key dispatching, and
35 * layout.
36 *
37 * <p>Because this provides deep interaction with the system window manager,
38 * specific methods on this interface can be called from a variety of contexts
39 * with various restrictions on what they can do. These are encoded through
40 * a suffixes at the end of a method encoding the thread the method is called
41 * from and any locks that are held when it is being called; if no suffix
42 * is attached to a method, then it is not called with any locks and may be
43 * called from the main window manager thread or another thread calling into
44 * the window manager.
45 *
46 * <p>The current suffixes are:
47 *
48 * <dl>
49 * <dt> Ti <dd> Called from the input thread. This is the thread that
50 * collects pending input events and dispatches them to the appropriate window.
51 * It may block waiting for events to be processed, so that the input stream is
52 * properly serialized.
53 * <dt> Tq <dd> Called from the low-level input queue thread. This is the
54 * thread that reads events out of the raw input devices and places them
55 * into the global input queue that is read by the <var>Ti</var> thread.
56 * This thread should not block for a long period of time on anything but the
57 * key driver.
58 * <dt> Lw <dd> Called with the main window manager lock held. Because the
59 * window manager is a very low-level system service, there are few other
60 * system services you can call with this lock held. It is explicitly okay to
61 * make calls into the package manager and power manager; it is explicitly not
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070062 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 * {@link android.content.Context#checkPermission(String, int, int)} and
64 * variations require calling into the activity manager.
65 * <dt> Li <dd> Called with the input thread lock held. This lock can be
66 * acquired by the window manager while it holds the window lock, so this is
67 * even more restrictive than <var>Lw</var>.
68 * </dl>
69 *
70 * @hide
71 */
72public interface WindowManagerPolicy {
Jeff Brownb6997262010-10-08 22:31:17 -070073 // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 public final static int FLAG_WAKE = 0x00000001;
75 public final static int FLAG_WAKE_DROPPED = 0x00000002;
76 public final static int FLAG_SHIFT = 0x00000004;
77 public final static int FLAG_CAPS_LOCK = 0x00000008;
78 public final static int FLAG_ALT = 0x00000010;
79 public final static int FLAG_ALT_GR = 0x00000020;
80 public final static int FLAG_MENU = 0x00000040;
81 public final static int FLAG_LAUNCHER = 0x00000080;
Jeff Brown0eaf3932010-10-01 14:55:30 -070082 public final static int FLAG_VIRTUAL = 0x00000100;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083
Jeff Brown85a31762010-09-01 17:01:00 -070084 public final static int FLAG_INJECTED = 0x01000000;
Jeff Browne20c9e02010-10-11 14:20:19 -070085 public final static int FLAG_TRUSTED = 0x02000000;
Jeff Brown0029c662011-03-30 02:25:18 -070086 public final static int FLAG_FILTERED = 0x04000000;
87 public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
Jeff Brown85a31762010-09-01 17:01:00 -070088
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 public final static int FLAG_WOKE_HERE = 0x10000000;
90 public final static int FLAG_BRIGHT_HERE = 0x20000000;
Jeff Brownb6997262010-10-08 22:31:17 -070091 public final static int FLAG_PASS_TO_USER = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092
93 public final static boolean WATCH_POINTER = false;
94
Dianne Hackbornad7fa7f2011-01-07 14:06:50 -080095 /**
96 * Sticky broadcast of the current HDMI plugged state.
97 */
98 public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
99
100 /**
101 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
102 * plugged in to HDMI, false if not.
103 */
104 public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
105
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 // flags for interceptKeyTq
107 /**
108 * Pass this event to the user / app. To be returned from {@link #interceptKeyTq}.
109 */
110 public final static int ACTION_PASS_TO_USER = 0x00000001;
111
112 /**
113 * This key event should extend the user activity timeout and turn the lights on.
114 * To be returned from {@link #interceptKeyTq}. Do not return this and
115 * {@link #ACTION_GO_TO_SLEEP} or {@link #ACTION_PASS_TO_USER}.
116 */
117 public final static int ACTION_POKE_USER_ACTIVITY = 0x00000002;
118
119 /**
120 * This key event should put the device to sleep (and engage keyguard if necessary)
121 * To be returned from {@link #interceptKeyTq}. Do not return this and
122 * {@link #ACTION_POKE_USER_ACTIVITY} or {@link #ACTION_PASS_TO_USER}.
123 */
124 public final static int ACTION_GO_TO_SLEEP = 0x00000004;
125
126 /**
127 * Interface to the Window Manager state associated with a particular
128 * window. You can hold on to an instance of this interface from the call
129 * to prepareAddWindow() until removeWindow().
130 */
131 public interface WindowState {
132 /**
133 * Perform standard frame computation. The result can be obtained with
134 * getFrame() if so desired. Must be called with the window manager
135 * lock held.
136 *
137 * @param parentFrame The frame of the parent container this window
138 * is in, used for computing its basic position.
139 * @param displayFrame The frame of the overall display in which this
140 * window can appear, used for constraining the overall dimensions
141 * of the window.
142 * @param contentFrame The frame within the display in which we would
143 * like active content to appear. This will cause windows behind to
144 * be resized to match the given content frame.
145 * @param visibleFrame The frame within the display that the window
146 * is actually visible, used for computing its visible insets to be
147 * given to windows behind.
148 * This can be used as a hint for scrolling (avoiding resizing)
149 * the window to make certain that parts of its content
150 * are visible.
151 */
152 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
153 Rect contentFrame, Rect visibleFrame);
154
155 /**
156 * Retrieve the current frame of the window that has been assigned by
157 * the window manager. Must be called with the window manager lock held.
158 *
159 * @return Rect The rectangle holding the window frame.
160 */
161 public Rect getFrameLw();
162
163 /**
164 * Retrieve the current frame of the window that is actually shown.
165 * Must be called with the window manager lock held.
166 *
167 * @return Rect The rectangle holding the shown window frame.
168 */
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700169 public RectF getShownFrameLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170
171 /**
172 * Retrieve the frame of the display that this window was last
173 * laid out in. Must be called with the
174 * window manager lock held.
175 *
176 * @return Rect The rectangle holding the display frame.
177 */
178 public Rect getDisplayFrameLw();
179
180 /**
181 * Retrieve the frame of the content area that this window was last
182 * laid out in. This is the area in which the content of the window
183 * should be placed. It will be smaller than the display frame to
184 * account for screen decorations such as a status bar or soft
185 * keyboard. Must be called with the
186 * window manager lock held.
187 *
188 * @return Rect The rectangle holding the content frame.
189 */
190 public Rect getContentFrameLw();
191
192 /**
193 * Retrieve the frame of the visible area that this window was last
194 * laid out in. This is the area of the screen in which the window
195 * will actually be fully visible. It will be smaller than the
196 * content frame to account for transient UI elements blocking it
197 * such as an input method's candidates UI. Must be called with the
198 * window manager lock held.
199 *
200 * @return Rect The rectangle holding the visible frame.
201 */
202 public Rect getVisibleFrameLw();
203
204 /**
205 * Returns true if this window is waiting to receive its given
206 * internal insets from the client app, and so should not impact the
207 * layout of other windows.
208 */
209 public boolean getGivenInsetsPendingLw();
210
211 /**
212 * Retrieve the insets given by this window's client for the content
213 * area of windows behind it. Must be called with the
214 * window manager lock held.
215 *
216 * @return Rect The left, top, right, and bottom insets, relative
217 * to the window's frame, of the actual contents.
218 */
219 public Rect getGivenContentInsetsLw();
220
221 /**
222 * Retrieve the insets given by this window's client for the visible
223 * area of windows behind it. Must be called with the
224 * window manager lock held.
225 *
226 * @return Rect The left, top, right, and bottom insets, relative
227 * to the window's frame, of the actual visible area.
228 */
229 public Rect getGivenVisibleInsetsLw();
230
231 /**
232 * Retrieve the current LayoutParams of the window.
233 *
234 * @return WindowManager.LayoutParams The window's internal LayoutParams
235 * instance.
236 */
237 public WindowManager.LayoutParams getAttrs();
238
239 /**
240 * Get the layer at which this window's surface will be Z-ordered.
241 */
242 public int getSurfaceLayer();
243
244 /**
245 * Return the token for the application (actually activity) that owns
246 * this window. May return null for system windows.
247 *
248 * @return An IApplicationToken identifying the owning activity.
249 */
250 public IApplicationToken getAppToken();
251
252 /**
253 * Return true if, at any point, the application token associated with
254 * this window has actually displayed any windows. This is most useful
255 * with the "starting up" window to determine if any windows were
256 * displayed when it is closed.
257 *
258 * @return Returns true if one or more windows have been displayed,
259 * else false.
260 */
261 public boolean hasAppShownWindows();
262
263 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800264 * Is this window visible? It is not visible if there is no
265 * surface, or we are in the process of running an exit animation
266 * that will remove the surface.
267 */
268 boolean isVisibleLw();
269
270 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700271 * Like {@link #isVisibleLw}, but also counts a window that is currently
272 * "hidden" behind the keyguard as visible. This allows us to apply
273 * things like window flags that impact the keyguard.
274 */
275 boolean isVisibleOrBehindKeyguardLw();
276
277 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800278 * Is this window currently visible to the user on-screen? It is
279 * displayed either if it is visible or it is currently running an
280 * animation before no longer being visible. Must be called with the
281 * window manager lock held.
282 */
283 boolean isDisplayedLw();
284
285 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800286 * Returns true if this window has been shown on screen at some time in
287 * the past. Must be called with the window manager lock held.
288 *
289 * @return boolean
290 */
291 public boolean hasDrawnLw();
292
293 /**
294 * Can be called by the policy to force a window to be hidden,
295 * regardless of whether the client or window manager would like
296 * it shown. Must be called with the window manager lock held.
297 * Returns true if {@link #showLw} was last called for the window.
298 */
299 public boolean hideLw(boolean doAnimation);
300
301 /**
302 * Can be called to undo the effect of {@link #hideLw}, allowing a
303 * window to be shown as long as the window manager and client would
304 * also like it to be shown. Must be called with the window manager
305 * lock held.
306 * Returns true if {@link #hideLw} was last called for the window.
307 */
308 public boolean showLw(boolean doAnimation);
309 }
310
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700311 /**
312 * Bit mask that is set for all enter transition.
313 */
314 public final int TRANSIT_ENTER_MASK = 0x1000;
315
316 /**
317 * Bit mask that is set for all exit transitions.
318 */
319 public final int TRANSIT_EXIT_MASK = 0x2000;
320
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700321 /** Not set up for a transition. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700322 public final int TRANSIT_UNSET = -1;
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700323 /** No animation for transition. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324 public final int TRANSIT_NONE = 0;
325 /** Window has been added to the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700326 public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 /** Window has been removed from the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700328 public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 /** Window has been made visible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700330 public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 /** Window has been made invisible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700332 public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800333 /** The "application starting" preview window is no longer needed, and will
334 * animate away to show the real window. */
335 public final int TRANSIT_PREVIEW_DONE = 5;
336 /** A window in a new activity is being opened on top of an existing one
337 * in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700338 public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339 /** The window in the top-most activity is being closed to reveal the
340 * previous activity in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700341 public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 /** A window in a new task is being opened 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_OPEN = 8 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800345 /** A window in the top-most activity is being closed to reveal the
346 * previous activity in a different task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700347 public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800348 /** A window in an existing task is being displayed on top of an existing one
349 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700350 public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800351 /** A window in an existing task is being put below all other tasks. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700352 public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700353 /** A window in a new activity that doesn't have a wallpaper is being
354 * opened on top of one that does, effectively closing the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700355 public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700356 /** A window in a new activity that does have a wallpaper is being
357 * opened on one that didn't, effectively opening the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700358 public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700359 /** A window in a new activity is being opened on top of an existing one,
360 * and both are on top of the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700361 public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700362 /** The window in the top-most activity is being closed to reveal the
363 * previous activity, and both are on top of he wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700364 public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800365
Dianne Hackborn254cb442010-01-27 19:23:59 -0800366 // NOTE: screen off reasons are in order of significance, with more
367 // important ones lower than less important ones.
368
369 /** Screen turned off because of a device admin */
370 public final int OFF_BECAUSE_OF_ADMIN = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800371 /** Screen turned off because of power button */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800372 public final int OFF_BECAUSE_OF_USER = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800373 /** Screen turned off because of timeout */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800374 public final int OFF_BECAUSE_OF_TIMEOUT = 3;
Mike Lockwood435eb642009-12-03 08:40:18 -0500375 /** Screen turned off because of proximity sensor */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800376 public final int OFF_BECAUSE_OF_PROX_SENSOR = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800377
378 /**
379 * Magic constant to {@link IWindowManager#setRotation} to not actually
380 * modify the rotation.
381 */
382 public final int USE_LAST_ROTATION = -1000;
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400383
384 /** When not otherwise specified by the activity's screenOrientation, rotation should be
385 * determined by the system (that is, using sensors). */
386 public final int USER_ROTATION_FREE = 0;
387 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
388 * the user. */
389 public final int USER_ROTATION_LOCKED = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390
391 /**
392 * Perform initialization of the policy.
393 *
394 * @param context The system context we are running in.
395 * @param powerManager
396 */
397 public void init(Context context, IWindowManager windowManager,
398 LocalPowerManager powerManager);
399
400 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700401 * Called by window manager once it has the initial, default native
402 * display dimensions.
403 */
404 public void setInitialDisplaySize(int width, int height);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700405
Dianne Hackborn9d132642011-04-21 17:26:39 -0700406 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800407 * Check permissions when adding a window.
408 *
409 * @param attrs The window's LayoutParams.
410 *
411 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed;
412 * else an error code, usually
413 * {@link WindowManagerImpl#ADD_PERMISSION_DENIED}, to abort the add.
414 */
415 public int checkAddPermission(WindowManager.LayoutParams attrs);
416
417 /**
418 * Sanitize the layout parameters coming from a client. Allows the policy
419 * to do things like ensure that windows of a specific type can't take
420 * input focus.
421 *
422 * @param attrs The window layout parameters to be modified. These values
423 * are modified in-place.
424 */
425 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
426
427 /**
428 * After the window manager has computed the current configuration based
429 * on its knowledge of the display and input devices, it gives the policy
430 * a chance to adjust the information contained in it. If you want to
431 * leave it as-is, simply do nothing.
432 *
433 * <p>This method may be called by any thread in the window manager, but
434 * no internal locks in the window manager will be held.
435 *
436 * @param config The Configuration being computed, for you to change as
437 * desired.
438 */
439 public void adjustConfigurationLw(Configuration config);
440
441 /**
442 * Assign a window type to a layer. Allows you to control how different
443 * kinds of windows are ordered on-screen.
444 *
445 * @param type The type of window being assigned.
446 *
447 * @return int An arbitrary integer used to order windows, with lower
448 * numbers below higher ones.
449 */
450 public int windowTypeToLayerLw(int type);
451
452 /**
453 * Return how to Z-order sub-windows in relation to the window they are
454 * attached to. Return positive to have them ordered in front, negative for
455 * behind.
456 *
457 * @param type The sub-window type code.
458 *
459 * @return int Layer in relation to the attached window, where positive is
460 * above and negative is below.
461 */
462 public int subWindowTypeToLayerLw(int type);
463
464 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700465 * Get the highest layer (actually one more than) that the wallpaper is
466 * allowed to be in.
467 */
468 public int getMaxWallpaperLayer();
469
470 /**
Dianne Hackborn81e56d52011-05-26 00:55:58 -0700471 * Return true if the policy allows the status bar to hide. Otherwise,
472 * it is a tablet-style system bar.
473 */
474 public boolean canStatusBarHide();
475
476 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700477 * Return the display width available after excluding any screen
478 * decorations that can never be removed. That is, system bar or
479 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400480 */
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700481 public int getNonDecorDisplayWidth(int rotation, int fullWidth);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400482
483 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700484 * Return the display height available after excluding any screen
485 * decorations that can never be removed. That is, system bar or
486 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400487 */
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700488 public int getNonDecorDisplayHeight(int rotation, int fullHeight);
489
490 /**
491 * Return the available screen width that we should report for the
492 * configuration. This must be no larger than
493 * {@link #getNonDecorDisplayWidth(int, int)}; it may be smaller than
494 * that to account for more transient decoration like a status bar.
495 */
496 public int getConfigDisplayWidth(int rotation, int fullWidth);
497
498 /**
499 * Return the available screen height that we should report for the
500 * configuration. This must be no larger than
501 * {@link #getNonDecorDisplayHeight(int, int)}; it may be smaller than
502 * that to account for more transient decoration like a status bar.
503 */
504 public int getConfigDisplayHeight(int rotation, int fullHeight);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400505
506 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700507 * Return whether the given window should forcibly hide everything
508 * behind it. Typically returns true for the keyguard.
509 */
510 public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
511
512 /**
513 * Determine if a window that is behind one that is force hiding
514 * (as determined by {@link #doesForceHide}) should actually be hidden.
515 * For example, typically returns false for the status bar. Be careful
516 * to return false for any window that you may hide yourself, since this
517 * will conflict with what you set.
518 */
519 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
520
521 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800522 * Called when the system would like to show a UI to indicate that an
523 * application is starting. You can use this to add a
524 * APPLICATION_STARTING_TYPE window with the given appToken to the window
525 * manager (using the normal window manager APIs) that will be shown until
526 * the application displays its own window. This is called without the
527 * window manager locked so that you can call back into it.
528 *
529 * @param appToken Token of the application being started.
530 * @param packageName The name of the application package being started.
531 * @param theme Resource defining the application's overall visual theme.
532 * @param nonLocalizedLabel The default title label of the application if
533 * no data is found in the resource.
534 * @param labelRes The resource ID the application would like to use as its name.
535 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800536 * @param windowFlags Window layout flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800537 *
538 * @return Optionally you can return the View that was used to create the
539 * window, for easy removal in removeStartingWindow.
540 *
541 * @see #removeStartingWindow
542 */
543 public View addStartingWindow(IBinder appToken, String packageName,
Dianne Hackborn2f0b1752011-05-31 17:59:49 -0700544 int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800545 int labelRes, int icon, int windowFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800546
547 /**
548 * Called when the first window of an application has been displayed, while
549 * {@link #addStartingWindow} has created a temporary initial window for
550 * that application. You should at this point remove the window from the
551 * window manager. This is called without the window manager locked so
552 * that you can call back into it.
553 *
554 * <p>Note: due to the nature of these functions not being called with the
555 * window manager locked, you must be prepared for this function to be
556 * called multiple times and/or an initial time with a null View window
557 * even if you previously returned one.
558 *
559 * @param appToken Token of the application that has started.
560 * @param window Window View that was returned by createStartingWindow.
561 *
562 * @see #addStartingWindow
563 */
564 public void removeStartingWindow(IBinder appToken, View window);
565
566 /**
567 * Prepare for a window being added to the window manager. You can throw an
568 * exception here to prevent the window being added, or do whatever setup
569 * you need to keep track of the window.
570 *
571 * @param win The window being added.
572 * @param attrs The window's LayoutParams.
573 *
574 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed, else an
575 * error code to abort the add.
576 */
577 public int prepareAddWindowLw(WindowState win,
578 WindowManager.LayoutParams attrs);
579
580 /**
581 * Called when a window is being removed from a window manager. Must not
582 * throw an exception -- clean up as much as possible.
583 *
584 * @param win The window being removed.
585 */
586 public void removeWindowLw(WindowState win);
587
588 /**
589 * Control the animation to run when a window's state changes. Return a
590 * non-0 number to force the animation to a specific resource ID, or 0
591 * to use the default animation.
592 *
593 * @param win The window that is changing.
594 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
595 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
596 * {@link #TRANSIT_HIDE}.
597 *
598 * @return Resource ID of the actual animation to use, or 0 for none.
599 */
600 public int selectAnimationLw(WindowState win, int transit);
601
602 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700603 * Create and return an animation to re-display a force hidden window.
604 */
605 public Animation createForceHideEnterAnimation();
606
607 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700608 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800609 *
610 * <p>There are some actions that need to be handled here because they
611 * affect the power state of the device, for example, the power keys.
612 * Generally, it's best to keep as little as possible in the queue thread
613 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -0800614 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700615 * @param policyFlags The policy flags associated with the key.
616 * @param isScreenOn True if the screen is already on
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800617 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800618 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
619 * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
620 */
Jeff Brown1f245102010-11-18 20:53:46 -0800621 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
Jeff Brown56194eb2011-03-02 19:23:13 -0800622
623 /**
624 * Called from the input reader thread before a motion is enqueued when the screen is off.
625 *
626 * <p>There are some actions that need to be handled here because they
627 * affect the power state of the device, for example, waking on motions.
628 * Generally, it's best to keep as little as possible in the queue thread
629 * because it's the most fragile.
630 * @param policyFlags The policy flags associated with the motion.
631 *
632 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
633 * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
634 */
635 public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags);
636
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800637 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700638 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800639 *
640 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -0700641 * behavior for keys that can not be overridden by applications.
642 * This method is called from the input thread, with no locks held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800643 *
644 * @param win The window that currently has focus. This is where the key
645 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800646 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700647 * @param policyFlags The policy flags associated with the key.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800648 * @return Returns true if the policy consumed the event and it should
649 * not be further dispatched.
650 */
Jeff Brown1f245102010-11-18 20:53:46 -0800651 public boolean interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800652
653 /**
Jeff Brown3915bb82010-11-05 15:02:16 -0700654 * Called from the input dispatcher thread when an application did not handle
655 * a key that was dispatched to it.
656 *
657 * <p>Allows you to define default global behavior for keys that were not handled
658 * by applications. This method is called from the input thread, with no locks held.
659 *
660 * @param win The window that currently has focus. This is where the key
661 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800662 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700663 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -0800664 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
665 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700666 */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800667 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -0700668
669 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 * Called when layout of the windows is about to start.
671 *
672 * @param displayWidth The current full width of the screen.
673 * @param displayHeight The current full height of the screen.
674 */
675 public void beginLayoutLw(int displayWidth, int displayHeight);
676
677 /**
678 * Called for each window attached to the window manager as layout is
679 * proceeding. The implementation of this function must take care of
680 * setting the window's frame, either here or in finishLayout().
681 *
682 * @param win The window being positioned.
683 * @param attrs The LayoutParams of the window.
684 * @param attached For sub-windows, the window it is attached to; this
685 * window will already have had layoutWindow() called on it
686 * so you can use its Rect. Otherwise null.
687 */
688 public void layoutWindowLw(WindowState win,
689 WindowManager.LayoutParams attrs, WindowState attached);
690
691
692 /**
693 * Return the insets for the areas covered by system windows. These values
694 * are computed on the most recent layout, so they are not guaranteed to
695 * be correct.
696 *
697 * @param attrs The LayoutParams of the window.
698 * @param contentInset The areas covered by system windows, expressed as positive insets
699 *
700 */
701 public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
702
703 /**
704 * Called when layout of the windows is finished. After this function has
705 * returned, all windows given to layoutWindow() <em>must</em> have had a
706 * frame assigned.
Dianne Hackborn7ac3f672009-03-31 18:00:53 -0700707 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800708 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
709 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
710 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800711 */
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700712 public int finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800713
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700714 /** Layout state may have changed (so another layout will be performed) */
715 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
716 /** Configuration state may have changed */
717 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
718 /** Wallpaper may need to move */
719 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800720 /** Need to recompute animations */
721 static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700722
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800723 /**
724 * Called when animation of the windows is about to start.
725 *
726 * @param displayWidth The current full width of the screen.
727 * @param displayHeight The current full height of the screen.
728 */
729 public void beginAnimationLw(int displayWidth, int displayHeight);
730
731 /**
732 * Called each time a window is animating.
733 *
734 * @param win The window being positioned.
735 * @param attrs The LayoutParams of the window.
736 */
737 public void animatingWindowLw(WindowState win,
738 WindowManager.LayoutParams attrs);
739
740 /**
741 * Called when animation of the windows is finished. If in this function you do
742 * something that may have modified the animation state of another window,
743 * be sure to return true in order to perform another animation frame.
744 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800745 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
746 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
747 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800748 */
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800749 public int finishAnimationLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800750
751 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800752 * Return true if it is okay to perform animations for an app transition
753 * that is about to occur. You may return false for this if, for example,
754 * the lock screen is currently displayed so the switch should happen
755 * immediately.
756 */
757 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -0800758
759
760 /**
761 * A new window has been focused.
762 */
763 public void focusChanged(WindowState lastFocus, WindowState newFocus);
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800764
765 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800766 * Called after the screen turns off.
767 *
768 * @param why {@link #OFF_BECAUSE_OF_USER} or
769 * {@link #OFF_BECAUSE_OF_TIMEOUT}.
770 */
771 public void screenTurnedOff(int why);
772
773 /**
774 * Called after the screen turns on.
775 */
776 public void screenTurnedOn();
777
778 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800779 * Return whether the screen is currently on.
780 */
781 public boolean isScreenOn();
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700782
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800783 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700784 * Tell the policy that the lid switch has changed state.
785 * @param whenNanos The time when the change occurred in uptime nanoseconds.
786 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800787 */
Jeff Brown46b9ac02010-04-22 18:58:52 -0700788 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
789
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800790 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800791 * Tell the policy if anyone is requesting that keyguard not come on.
792 *
793 * @param enabled Whether keyguard can be on or not. does not actually
794 * turn it on, unless it was previously disabled with this function.
795 *
796 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
797 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
798 */
799 public void enableKeyguard(boolean enabled);
800
801 /**
802 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
803 */
804 interface OnKeyguardExitResult {
805 void onKeyguardExitResult(boolean success);
806 }
807
808 /**
809 * Tell the policy if anyone is requesting the keyguard to exit securely
810 * (this would be called after the keyguard was disabled)
811 * @param callback Callback to send the result back.
812 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
813 */
814 void exitKeyguardSecurely(OnKeyguardExitResult callback);
815
816 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -0500817 * isKeyguardLocked
818 *
819 * Return whether the keyguard is currently locked.
820 *
821 * @return true if in keyguard is locked.
822 */
823 public boolean isKeyguardLocked();
824
825 /**
826 * isKeyguardSecure
827 *
828 * Return whether the keyguard requires a password to unlock.
829 *
830 * @return true if in keyguard is secure.
831 */
832 public boolean isKeyguardSecure();
833
834 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800835 * inKeyguardRestrictedKeyInputMode
836 *
837 * if keyguard screen is showing or in restricted key input mode (i.e. in
838 * keyguard password emergency screen). When in such mode, certain keys,
839 * such as the Home key and the right soft keys, don't work.
840 *
841 * @return true if in keyguard restricted input mode.
842 */
843 public boolean inKeyguardRestrictedKeyInputMode();
844
845 /**
846 * Given an orientation constant
847 * ({@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE
848 * ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE} or
849 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_PORTRAIT
850 * ActivityInfo.SCREEN_ORIENTATION_PORTRAIT}), return a surface
851 * rotation.
852 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700853 public int rotationForOrientationLw(int orientation, int lastRotation,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800854 boolean displayEnabled);
855
856 /**
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700857 * Return the currently locked screen rotation, if any. Return
858 * Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, or
859 * Surface.ROTATION_270 if locked; return -1 if not locked.
860 */
861 public int getLockedRotationLw();
862
863 /**
Dianne Hackborn6af0d502009-09-28 13:25:46 -0700864 * Called when the system is mostly done booting to determine whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800865 * the system should go into safe mode.
866 */
867 public boolean detectSafeMode();
868
869 /**
870 * Called when the system is mostly done booting.
871 */
872 public void systemReady();
873
874 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -0700875 * Called when the system is done booting to the point where the
876 * user can start interacting with it.
877 */
878 public void systemBooted();
879
880 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -0700881 * Show boot time message to the user.
882 */
883 public void showBootMessage(final CharSequence msg, final boolean always);
884
885 /**
886 * Hide the UI for showing boot messages, never to be displayed again.
887 */
888 public void hideBootMessages();
889
890 /**
Mike Lockwoodef731622010-01-27 17:51:34 -0500891 * Called when userActivity is signalled in the power manager.
892 * This is safe to call from any thread, with any window manager locks held or not.
893 */
894 public void userActivity();
895
896 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800897 * Called when we have finished booting and can now display the home
898 * screen to the user. This wilWl happen after systemReady(), and at
899 * this point the display is active.
900 */
901 public void enableScreenAfterBoot();
902
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700903 public void setCurrentOrientationLw(int newOrientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800904
905 /**
906 * Call from application to perform haptic feedback on its window.
907 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700908 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800909
910 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -0400911 * Called when we have started keeping the screen on because a window
912 * requesting this has become visible.
913 */
914 public void screenOnStartedLw();
915
916 /**
917 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800918 * requesting this is no longer visible.
919 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700920 public void screenOnStoppedLw();
Mike Lockwood3d0ea722009-10-21 22:58:29 -0400921
922 /**
923 * Return false to disable key repeat events from being generated.
924 */
925 public boolean allowKeyRepeat();
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400926
927 /**
928 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
929 *
930 * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
931 * {@link * WindowManagerPolicy#USER_ROTATION_FREE}.
932 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
933 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
934 */
935 public void setUserRotationMode(int mode, int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -0800936
937 /**
938 * Print the WindowManagerPolicy's state into the given stream.
939 *
940 * @param prefix Text to print at the front of each line.
941 * @param fd The raw file descriptor that the dump is being sent to.
942 * @param writer The PrintWriter to which you should dump your state. This will be
943 * closed for you after you return.
944 * @param args additional arguments to the dump request.
945 */
946 public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800947}