blob: b059afc3fc5518381fba59ce981dabeab067127c [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;
Dianne Hackborndf89e652011-10-06 22:35:11 -070025import android.os.Looper;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.view.animation.Animation;
27
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080028import java.io.PrintWriter;
29
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030/**
31 * This interface supplies all UI-specific behavior of the window manager. An
32 * instance of it is created by the window manager when it starts up, and allows
33 * customization of window layering, special window types, key dispatching, and
34 * layout.
35 *
36 * <p>Because this provides deep interaction with the system window manager,
37 * specific methods on this interface can be called from a variety of contexts
38 * with various restrictions on what they can do. These are encoded through
39 * a suffixes at the end of a method encoding the thread the method is called
40 * from and any locks that are held when it is being called; if no suffix
41 * is attached to a method, then it is not called with any locks and may be
42 * called from the main window manager thread or another thread calling into
43 * the window manager.
44 *
45 * <p>The current suffixes are:
46 *
47 * <dl>
48 * <dt> Ti <dd> Called from the input thread. This is the thread that
49 * collects pending input events and dispatches them to the appropriate window.
50 * It may block waiting for events to be processed, so that the input stream is
51 * properly serialized.
52 * <dt> Tq <dd> Called from the low-level input queue thread. This is the
53 * thread that reads events out of the raw input devices and places them
54 * into the global input queue that is read by the <var>Ti</var> thread.
55 * This thread should not block for a long period of time on anything but the
56 * key driver.
57 * <dt> Lw <dd> Called with the main window manager lock held. Because the
58 * window manager is a very low-level system service, there are few other
59 * system services you can call with this lock held. It is explicitly okay to
60 * make calls into the package manager and power manager; it is explicitly not
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070061 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080062 * {@link android.content.Context#checkPermission(String, int, int)} and
63 * variations require calling into the activity manager.
64 * <dt> Li <dd> Called with the input thread lock held. This lock can be
65 * acquired by the window manager while it holds the window lock, so this is
66 * even more restrictive than <var>Lw</var>.
67 * </dl>
68 *
69 * @hide
70 */
71public interface WindowManagerPolicy {
Jeff Brownb6997262010-10-08 22:31:17 -070072 // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073 public final static int FLAG_WAKE = 0x00000001;
74 public final static int FLAG_WAKE_DROPPED = 0x00000002;
75 public final static int FLAG_SHIFT = 0x00000004;
76 public final static int FLAG_CAPS_LOCK = 0x00000008;
77 public final static int FLAG_ALT = 0x00000010;
78 public final static int FLAG_ALT_GR = 0x00000020;
79 public final static int FLAG_MENU = 0x00000040;
80 public final static int FLAG_LAUNCHER = 0x00000080;
Jeff Brown0eaf3932010-10-01 14:55:30 -070081 public final static int FLAG_VIRTUAL = 0x00000100;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080082
Jeff Brown85a31762010-09-01 17:01:00 -070083 public final static int FLAG_INJECTED = 0x01000000;
Jeff Browne20c9e02010-10-11 14:20:19 -070084 public final static int FLAG_TRUSTED = 0x02000000;
Jeff Brown0029c662011-03-30 02:25:18 -070085 public final static int FLAG_FILTERED = 0x04000000;
86 public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
Jeff Brown85a31762010-09-01 17:01:00 -070087
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 public final static int FLAG_WOKE_HERE = 0x10000000;
89 public final static int FLAG_BRIGHT_HERE = 0x20000000;
Jeff Brownb6997262010-10-08 22:31:17 -070090 public final static int FLAG_PASS_TO_USER = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091
Jeff Browndaa37532012-05-01 15:54:03 -070092 // Flags used for indicating whether the internal and/or external input devices
93 // of some type are available.
94 public final static int PRESENCE_INTERNAL = 1 << 0;
95 public final static int PRESENCE_EXTERNAL = 1 << 1;
96
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 public final static boolean WATCH_POINTER = false;
98
Dianne Hackbornad7fa7f2011-01-07 14:06:50 -080099 /**
100 * Sticky broadcast of the current HDMI plugged state.
101 */
102 public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
103
104 /**
105 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
106 * plugged in to HDMI, false if not.
107 */
108 public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
109
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800110 /**
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700111 * Pass this event to the user / app. To be returned from
112 * {@link #interceptKeyBeforeQueueing}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800113 */
114 public final static int ACTION_PASS_TO_USER = 0x00000001;
115
116 /**
Jeff Brown96307042012-07-27 15:51:34 -0700117 * This key event should wake the device.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700118 * To be returned from {@link #interceptKeyBeforeQueueing}.
119 * Do not return this and {@link #ACTION_GO_TO_SLEEP} or {@link #ACTION_PASS_TO_USER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120 */
Jeff Brown96307042012-07-27 15:51:34 -0700121 public final static int ACTION_WAKE_UP = 0x00000002;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800122
123 /**
124 * This key event should put the device to sleep (and engage keyguard if necessary)
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700125 * To be returned from {@link #interceptKeyBeforeQueueing}.
Craig Mautner69b08182012-09-05 13:07:13 -0700126 * Do not return this and {@link #ACTION_WAKE_UP} or {@link #ACTION_PASS_TO_USER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127 */
128 public final static int ACTION_GO_TO_SLEEP = 0x00000004;
129
130 /**
131 * Interface to the Window Manager state associated with a particular
132 * window. You can hold on to an instance of this interface from the call
133 * to prepareAddWindow() until removeWindow().
134 */
135 public interface WindowState {
136 /**
137 * Perform standard frame computation. The result can be obtained with
138 * getFrame() if so desired. Must be called with the window manager
139 * lock held.
140 *
141 * @param parentFrame The frame of the parent container this window
142 * is in, used for computing its basic position.
143 * @param displayFrame The frame of the overall display in which this
144 * window can appear, used for constraining the overall dimensions
145 * of the window.
146 * @param contentFrame The frame within the display in which we would
147 * like active content to appear. This will cause windows behind to
148 * be resized to match the given content frame.
149 * @param visibleFrame The frame within the display that the window
150 * is actually visible, used for computing its visible insets to be
151 * given to windows behind.
152 * This can be used as a hint for scrolling (avoiding resizing)
153 * the window to make certain that parts of its content
154 * are visible.
155 */
156 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700157 Rect contentFrame, Rect visibleFrame);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800158
159 /**
160 * Retrieve the current frame of the window that has been assigned by
161 * the window manager. Must be called with the window manager lock held.
162 *
163 * @return Rect The rectangle holding the window frame.
164 */
165 public Rect getFrameLw();
166
167 /**
168 * Retrieve the current frame of the window that is actually shown.
169 * Must be called with the window manager lock held.
170 *
171 * @return Rect The rectangle holding the shown window frame.
172 */
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700173 public RectF getShownFrameLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800174
175 /**
176 * Retrieve the frame of the display that this window was last
177 * laid out in. Must be called with the
178 * window manager lock held.
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700179 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800180 * @return Rect The rectangle holding the display frame.
181 */
182 public Rect getDisplayFrameLw();
183
184 /**
185 * Retrieve the frame of the content area that this window was last
186 * laid out in. This is the area in which the content of the window
187 * should be placed. It will be smaller than the display frame to
188 * account for screen decorations such as a status bar or soft
189 * keyboard. Must be called with the
190 * window manager lock held.
191 *
192 * @return Rect The rectangle holding the content frame.
193 */
194 public Rect getContentFrameLw();
195
196 /**
197 * Retrieve the frame of the visible area that this window was last
198 * laid out in. This is the area of the screen in which the window
199 * will actually be fully visible. It will be smaller than the
200 * content frame to account for transient UI elements blocking it
201 * such as an input method's candidates UI. Must be called with the
202 * window manager lock held.
203 *
204 * @return Rect The rectangle holding the visible frame.
205 */
206 public Rect getVisibleFrameLw();
207
208 /**
209 * Returns true if this window is waiting to receive its given
210 * internal insets from the client app, and so should not impact the
211 * layout of other windows.
212 */
213 public boolean getGivenInsetsPendingLw();
214
215 /**
216 * Retrieve the insets given by this window's client for the content
217 * area of windows behind it. Must be called with the
218 * window manager lock held.
219 *
220 * @return Rect The left, top, right, and bottom insets, relative
221 * to the window's frame, of the actual contents.
222 */
223 public Rect getGivenContentInsetsLw();
224
225 /**
226 * Retrieve the insets given by this window's client for the visible
227 * area of windows behind it. Must be called with the
228 * window manager lock held.
229 *
230 * @return Rect The left, top, right, and bottom insets, relative
231 * to the window's frame, of the actual visible area.
232 */
233 public Rect getGivenVisibleInsetsLw();
234
235 /**
236 * Retrieve the current LayoutParams of the window.
237 *
238 * @return WindowManager.LayoutParams The window's internal LayoutParams
239 * instance.
240 */
241 public WindowManager.LayoutParams getAttrs();
242
243 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800244 * Return whether this window needs the menu key shown. Must be called
245 * with window lock held, because it may need to traverse down through
246 * window list to determine the result.
247 * @param bottom The bottom-most window to consider when determining this.
248 */
249 public boolean getNeedsMenuLw(WindowState bottom);
250
251 /**
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700252 * Retrieve the current system UI visibility flags associated with
253 * this window.
254 */
255 public int getSystemUiVisibility();
256
257 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 * Get the layer at which this window's surface will be Z-ordered.
259 */
260 public int getSurfaceLayer();
261
262 /**
263 * Return the token for the application (actually activity) that owns
264 * this window. May return null for system windows.
265 *
266 * @return An IApplicationToken identifying the owning activity.
267 */
268 public IApplicationToken getAppToken();
269
270 /**
271 * Return true if, at any point, the application token associated with
272 * this window has actually displayed any windows. This is most useful
273 * with the "starting up" window to determine if any windows were
274 * displayed when it is closed.
275 *
276 * @return Returns true if one or more windows have been displayed,
277 * else false.
278 */
279 public boolean hasAppShownWindows();
280
281 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282 * Is this window visible? It is not visible if there is no
283 * surface, or we are in the process of running an exit animation
284 * that will remove the surface.
285 */
286 boolean isVisibleLw();
287
288 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700289 * Like {@link #isVisibleLw}, but also counts a window that is currently
290 * "hidden" behind the keyguard as visible. This allows us to apply
291 * things like window flags that impact the keyguard.
292 */
293 boolean isVisibleOrBehindKeyguardLw();
294
295 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800296 * Is this window currently visible to the user on-screen? It is
297 * displayed either if it is visible or it is currently running an
298 * animation before no longer being visible. Must be called with the
299 * window manager lock held.
300 */
301 boolean isDisplayedLw();
302
303 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700304 * Return true if this window (or a window it is attached to, but not
305 * considering its app token) is currently animating.
306 */
307 public boolean isAnimatingLw();
308
309 /**
Dianne Hackborn01b02a72012-01-12 14:05:03 -0800310 * Is this window considered to be gone for purposes of layout?
311 */
312 boolean isGoneForLayoutLw();
313
314 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 * Returns true if this window has been shown on screen at some time in
316 * the past. Must be called with the window manager lock held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800317 */
318 public boolean hasDrawnLw();
319
320 /**
321 * Can be called by the policy to force a window to be hidden,
322 * regardless of whether the client or window manager would like
323 * it shown. Must be called with the window manager lock held.
324 * Returns true if {@link #showLw} was last called for the window.
325 */
326 public boolean hideLw(boolean doAnimation);
327
328 /**
329 * Can be called to undo the effect of {@link #hideLw}, allowing a
330 * window to be shown as long as the window manager and client would
331 * also like it to be shown. Must be called with the window manager
332 * lock held.
333 * Returns true if {@link #hideLw} was last called for the window.
334 */
335 public boolean showLw(boolean doAnimation);
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700336
337 /**
338 * Check whether the process hosting this window is currently alive.
339 */
340 public boolean isAlive();
Craig Mautner69b08182012-09-05 13:07:13 -0700341
342 /**
343 * Check if window is on {@link Display#DEFAULT_DISPLAY}.
344 * @return true if window is on default display.
345 */
346 public boolean isDefaultDisplay();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800347 }
348
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700349 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700350 * Representation of a "fake window" that the policy has added to the
351 * window manager to consume events.
352 */
353 public interface FakeWindow {
354 /**
355 * Remove the fake window from the window manager.
356 */
357 void dismiss();
358 }
359
360 /**
361 * Interface for calling back in to the window manager that is private
362 * between it and the policy.
363 */
364 public interface WindowManagerFuncs {
Jeff Brownac143512012-04-05 18:57:33 -0700365 public static final int LID_ABSENT = -1;
366 public static final int LID_CLOSED = 0;
367 public static final int LID_OPEN = 1;
368
Dianne Hackborndf89e652011-10-06 22:35:11 -0700369 /**
370 * Ask the window manager to re-evaluate the system UI flags.
371 */
372 public void reevaluateStatusBarVisibility();
373
374 /**
375 * Add a fake window to the window manager. This window sits
376 * at the top of the other windows and consumes events.
377 */
Jeff Brown32cbc38552011-12-01 14:01:49 -0800378 public FakeWindow addFakeWindow(Looper looper,
379 InputEventReceiver.Factory inputEventReceiverFactory,
Dianne Hackborndf89e652011-10-06 22:35:11 -0700380 String name, int windowType, int layoutParamsFlags, boolean canReceiveKeys,
381 boolean hasFocus, boolean touchFullscreen);
Jeff Brownac143512012-04-05 18:57:33 -0700382
383 /**
384 * Returns a code that describes the current state of the lid switch.
385 */
386 public int getLidState();
387
388 /**
389 * Creates an input channel that will receive all input from the input dispatcher.
390 */
391 public InputChannel monitorInput(String name);
Jeff Brown7304c342012-05-11 18:42:42 -0700392
Jeff Browncf39bdf2012-05-18 14:41:19 -0700393 /**
394 * Switch the keyboard layout for the given device.
395 * Direction should be +1 or -1 to go to the next or previous keyboard layout.
396 */
397 public void switchKeyboardLayout(int deviceId, int direction);
398
Jeff Brown9a538ee2012-08-20 14:56:57 -0700399 public void shutdown(boolean confirm);
400 public void rebootSafeMode(boolean confirm);
Dianne Hackborndf89e652011-10-06 22:35:11 -0700401 }
402
403 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700404 * Bit mask that is set for all enter transition.
405 */
406 public final int TRANSIT_ENTER_MASK = 0x1000;
407
408 /**
409 * Bit mask that is set for all exit transitions.
410 */
411 public final int TRANSIT_EXIT_MASK = 0x2000;
412
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700413 /** Not set up for a transition. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700414 public final int TRANSIT_UNSET = -1;
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700415 /** No animation for transition. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800416 public final int TRANSIT_NONE = 0;
417 /** Window has been added to the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700418 public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800419 /** Window has been removed from the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700420 public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800421 /** Window has been made visible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700422 public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 /** Window has been made invisible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700424 public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425 /** The "application starting" preview window is no longer needed, and will
426 * animate away to show the real window. */
427 public final int TRANSIT_PREVIEW_DONE = 5;
428 /** A window in a new activity is being opened on top of an existing one
429 * in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700430 public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800431 /** The window in the top-most activity is being closed to reveal the
432 * previous activity in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700433 public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800434 /** A window in a new task is being opened on top of an existing one
435 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700436 public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800437 /** A window in the top-most activity is being closed to reveal the
438 * previous activity in a different task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700439 public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 /** A window in an existing task is being displayed on top of an existing one
441 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700442 public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443 /** A window in an existing task is being put below all other tasks. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700444 public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700445 /** A window in a new activity that doesn't have a wallpaper is being
446 * opened on top of one that does, effectively closing the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700447 public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700448 /** A window in a new activity that does have a wallpaper is being
449 * opened on one that didn't, effectively opening the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700450 public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700451 /** A window in a new activity is being opened on top of an existing one,
452 * and both are on top of the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700453 public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700454 /** The window in the top-most activity is being closed to reveal the
455 * previous activity, and both are on top of he wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700456 public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457
Dianne Hackborn254cb442010-01-27 19:23:59 -0800458 // NOTE: screen off reasons are in order of significance, with more
459 // important ones lower than less important ones.
460
461 /** Screen turned off because of a device admin */
462 public final int OFF_BECAUSE_OF_ADMIN = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800463 /** Screen turned off because of power button */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800464 public final int OFF_BECAUSE_OF_USER = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800465 /** Screen turned off because of timeout */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800466 public final int OFF_BECAUSE_OF_TIMEOUT = 3;
Mike Lockwood435eb642009-12-03 08:40:18 -0500467 /** Screen turned off because of proximity sensor */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800468 public final int OFF_BECAUSE_OF_PROX_SENSOR = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800469
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400470 /** When not otherwise specified by the activity's screenOrientation, rotation should be
471 * determined by the system (that is, using sensors). */
472 public final int USER_ROTATION_FREE = 0;
473 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
474 * the user. */
475 public final int USER_ROTATION_LOCKED = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800476
477 /**
478 * Perform initialization of the policy.
479 *
480 * @param context The system context we are running in.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800481 */
482 public void init(Context context, IWindowManager windowManager,
Jeff Brown96307042012-07-27 15:51:34 -0700483 WindowManagerFuncs windowManagerFuncs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800484
485 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700486 * Called by window manager once it has the initial, default native
487 * display dimensions.
488 */
Dianne Hackborndde331c2012-08-03 14:01:57 -0700489 public void setInitialDisplaySize(Display display, int width, int height, int density);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700490
Dianne Hackborn9d132642011-04-21 17:26:39 -0700491 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800492 * Check permissions when adding a window.
493 *
494 * @param attrs The window's LayoutParams.
495 *
Jeff Brown98365d72012-08-19 20:30:52 -0700496 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800497 * else an error code, usually
Jeff Brown98365d72012-08-19 20:30:52 -0700498 * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800499 */
500 public int checkAddPermission(WindowManager.LayoutParams attrs);
501
502 /**
503 * Sanitize the layout parameters coming from a client. Allows the policy
504 * to do things like ensure that windows of a specific type can't take
505 * input focus.
506 *
507 * @param attrs The window layout parameters to be modified. These values
508 * are modified in-place.
509 */
510 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
511
512 /**
513 * After the window manager has computed the current configuration based
514 * on its knowledge of the display and input devices, it gives the policy
515 * a chance to adjust the information contained in it. If you want to
516 * leave it as-is, simply do nothing.
517 *
518 * <p>This method may be called by any thread in the window manager, but
519 * no internal locks in the window manager will be held.
520 *
521 * @param config The Configuration being computed, for you to change as
522 * desired.
Jeff Browndaa37532012-05-01 15:54:03 -0700523 * @param keyboardPresence Flags that indicate whether internal or external
524 * keyboards are present.
525 * @param navigationPresence Flags that indicate whether internal or external
526 * navigation devices are present.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800527 */
Jeff Browndaa37532012-05-01 15:54:03 -0700528 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
529 int navigationPresence);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530
531 /**
532 * Assign a window type to a layer. Allows you to control how different
533 * kinds of windows are ordered on-screen.
534 *
535 * @param type The type of window being assigned.
536 *
537 * @return int An arbitrary integer used to order windows, with lower
538 * numbers below higher ones.
539 */
540 public int windowTypeToLayerLw(int type);
541
542 /**
543 * Return how to Z-order sub-windows in relation to the window they are
544 * attached to. Return positive to have them ordered in front, negative for
545 * behind.
546 *
547 * @param type The sub-window type code.
548 *
549 * @return int Layer in relation to the attached window, where positive is
550 * above and negative is below.
551 */
552 public int subWindowTypeToLayerLw(int type);
553
554 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700555 * Get the highest layer (actually one more than) that the wallpaper is
556 * allowed to be in.
557 */
558 public int getMaxWallpaperLayer();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700559
560 /**
561 * Return the window layer at which windows appear above the normal
562 * universe (that is no longer impacted by the universe background
563 * transform).
564 */
565 public int getAboveUniverseLayer();
566
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700567 /**
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700568 * Return true if the policy desires a full unified system nav bar. Otherwise,
569 * it is a phone-style status bar with optional nav bar.
Dianne Hackborn81e56d52011-05-26 00:55:58 -0700570 */
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700571 public boolean hasSystemNavBar();
Dianne Hackborn81e56d52011-05-26 00:55:58 -0700572
573 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700574 * Return the display width available after excluding any screen
575 * decorations that can never be removed. That is, system bar or
576 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400577 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700578 public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400579
580 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700581 * Return the display height available after excluding any screen
582 * decorations that can never be removed. That is, system bar or
583 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400584 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700585 public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700586
587 /**
588 * Return the available screen width that we should report for the
589 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800590 * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700591 * that to account for more transient decoration like a status bar.
592 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700593 public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700594
595 /**
596 * Return the available screen height that we should report for the
597 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800598 * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700599 * that to account for more transient decoration like a status bar.
600 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700601 public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400602
603 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700604 * Return whether the given window should forcibly hide everything
605 * behind it. Typically returns true for the keyguard.
606 */
607 public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
608
609 /**
610 * Determine if a window that is behind one that is force hiding
611 * (as determined by {@link #doesForceHide}) should actually be hidden.
612 * For example, typically returns false for the status bar. Be careful
613 * to return false for any window that you may hide yourself, since this
614 * will conflict with what you set.
615 */
616 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
617
618 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800619 * Called when the system would like to show a UI to indicate that an
620 * application is starting. You can use this to add a
621 * APPLICATION_STARTING_TYPE window with the given appToken to the window
622 * manager (using the normal window manager APIs) that will be shown until
623 * the application displays its own window. This is called without the
624 * window manager locked so that you can call back into it.
625 *
626 * @param appToken Token of the application being started.
627 * @param packageName The name of the application package being started.
628 * @param theme Resource defining the application's overall visual theme.
629 * @param nonLocalizedLabel The default title label of the application if
630 * no data is found in the resource.
631 * @param labelRes The resource ID the application would like to use as its name.
632 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800633 * @param windowFlags Window layout flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800634 *
635 * @return Optionally you can return the View that was used to create the
636 * window, for easy removal in removeStartingWindow.
637 *
638 * @see #removeStartingWindow
639 */
640 public View addStartingWindow(IBinder appToken, String packageName,
Dianne Hackborn2f0b1752011-05-31 17:59:49 -0700641 int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800642 int labelRes, int icon, int windowFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800643
644 /**
645 * Called when the first window of an application has been displayed, while
646 * {@link #addStartingWindow} has created a temporary initial window for
647 * that application. You should at this point remove the window from the
648 * window manager. This is called without the window manager locked so
649 * that you can call back into it.
650 *
651 * <p>Note: due to the nature of these functions not being called with the
652 * window manager locked, you must be prepared for this function to be
653 * called multiple times and/or an initial time with a null View window
654 * even if you previously returned one.
655 *
656 * @param appToken Token of the application that has started.
657 * @param window Window View that was returned by createStartingWindow.
658 *
659 * @see #addStartingWindow
660 */
661 public void removeStartingWindow(IBinder appToken, View window);
662
663 /**
664 * Prepare for a window being added to the window manager. You can throw an
665 * exception here to prevent the window being added, or do whatever setup
666 * you need to keep track of the window.
667 *
668 * @param win The window being added.
669 * @param attrs The window's LayoutParams.
670 *
Jeff Brown98365d72012-08-19 20:30:52 -0700671 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800672 * error code to abort the add.
673 */
674 public int prepareAddWindowLw(WindowState win,
675 WindowManager.LayoutParams attrs);
676
677 /**
678 * Called when a window is being removed from a window manager. Must not
679 * throw an exception -- clean up as much as possible.
680 *
681 * @param win The window being removed.
682 */
683 public void removeWindowLw(WindowState win);
684
685 /**
686 * Control the animation to run when a window's state changes. Return a
687 * non-0 number to force the animation to a specific resource ID, or 0
688 * to use the default animation.
689 *
690 * @param win The window that is changing.
691 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
692 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
693 * {@link #TRANSIT_HIDE}.
694 *
695 * @return Resource ID of the actual animation to use, or 0 for none.
696 */
697 public int selectAnimationLw(WindowState win, int transit);
698
699 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700700 * Create and return an animation to re-display a force hidden window.
701 */
Dianne Hackborn0c2acff2012-04-12 15:17:07 -0700702 public Animation createForceHideEnterAnimation(boolean onWallpaper);
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700703
704 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700705 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800706 *
707 * <p>There are some actions that need to be handled here because they
708 * affect the power state of the device, for example, the power keys.
709 * Generally, it's best to keep as little as possible in the queue thread
710 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -0800711 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700712 * @param policyFlags The policy flags associated with the key.
713 * @param isScreenOn True if the screen is already on
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800714 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800715 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
Craig Mautner69b08182012-09-05 13:07:13 -0700716 * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800717 */
Jeff Brown1f245102010-11-18 20:53:46 -0800718 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
Jeff Brown56194eb2011-03-02 19:23:13 -0800719
720 /**
721 * Called from the input reader thread before a motion is enqueued when the screen is off.
722 *
723 * <p>There are some actions that need to be handled here because they
724 * affect the power state of the device, for example, waking on motions.
725 * Generally, it's best to keep as little as possible in the queue thread
726 * because it's the most fragile.
727 * @param policyFlags The policy flags associated with the motion.
728 *
729 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
Craig Mautner69b08182012-09-05 13:07:13 -0700730 * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
Jeff Brown56194eb2011-03-02 19:23:13 -0800731 */
732 public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags);
733
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800734 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700735 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800736 *
737 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -0700738 * behavior for keys that can not be overridden by applications.
739 * This method is called from the input thread, with no locks held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800740 *
741 * @param win The window that currently has focus. This is where the key
742 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800743 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700744 * @param policyFlags The policy flags associated with the key.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700745 * @return 0 if the key should be dispatched immediately, -1 if the key should
746 * not be dispatched ever, or a positive value indicating the number of
747 * milliseconds by which the key dispatch should be delayed before trying
748 * again.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800749 */
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700750 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800751
752 /**
Jeff Brown3915bb82010-11-05 15:02:16 -0700753 * Called from the input dispatcher thread when an application did not handle
754 * a key that was dispatched to it.
755 *
756 * <p>Allows you to define default global behavior for keys that were not handled
757 * by applications. This method is called from the input thread, with no locks held.
758 *
759 * @param win The window that currently has focus. This is where the key
760 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800761 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700762 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -0800763 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
764 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700765 */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800766 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -0700767
768 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800769 * Called when layout of the windows is about to start.
770 *
Craig Mautner69b08182012-09-05 13:07:13 -0700771 * @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800772 * @param displayWidth The current full width of the screen.
773 * @param displayHeight The current full height of the screen.
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700774 * @param displayRotation The current rotation being applied to the base
775 * window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800776 */
Craig Mautner69b08182012-09-05 13:07:13 -0700777 public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
778 int displayRotation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800779
780 /**
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700781 * Return the rectangle of the screen currently covered by system decorations.
782 * This will be called immediately after {@link #layoutWindowLw}. It can
783 * fill in the rectangle to indicate any part of the screen that it knows
784 * for sure is covered by system decor such as the status bar. The rectangle
785 * is initially set to the actual size of the screen, indicating nothing is
786 * covered.
787 *
788 * @param systemRect The rectangle of the screen that is not covered by
789 * system decoration.
790 * @return Returns the layer above which the system rectangle should
791 * not be applied.
792 */
793 public int getSystemDecorRectLw(Rect systemRect);
794
795 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800796 * Called for each window attached to the window manager as layout is
797 * proceeding. The implementation of this function must take care of
798 * setting the window's frame, either here or in finishLayout().
799 *
800 * @param win The window being positioned.
801 * @param attrs The LayoutParams of the window.
802 * @param attached For sub-windows, the window it is attached to; this
803 * window will already have had layoutWindow() called on it
804 * so you can use its Rect. Otherwise null.
805 */
806 public void layoutWindowLw(WindowState win,
807 WindowManager.LayoutParams attrs, WindowState attached);
808
809
810 /**
811 * Return the insets for the areas covered by system windows. These values
812 * are computed on the most recent layout, so they are not guaranteed to
813 * be correct.
814 *
815 * @param attrs The LayoutParams of the window.
816 * @param contentInset The areas covered by system windows, expressed as positive insets
817 *
818 */
819 public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700820
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800821 /**
822 * Called when layout of the windows is finished. After this function has
823 * returned, all windows given to layoutWindow() <em>must</em> have had a
824 * frame assigned.
825 */
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800826 public void finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800827
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700828 /** Layout state may have changed (so another layout will be performed) */
829 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
830 /** Configuration state may have changed */
831 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
832 /** Wallpaper may need to move */
833 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800834 /** Need to recompute animations */
835 static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700836
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800837 /**
Craig Mautner39834192012-09-02 07:47:24 -0700838 * Called following layout of all windows before each window has policy applied.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800839 *
840 * @param displayWidth The current full width of the screen.
841 * @param displayHeight The current full height of the screen.
842 */
Craig Mautner39834192012-09-02 07:47:24 -0700843 public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800844
845 /**
Craig Mautner39834192012-09-02 07:47:24 -0700846 * Called following layout of all window to apply policy to each window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800847 *
848 * @param win The window being positioned.
849 * @param attrs The LayoutParams of the window.
850 */
Craig Mautner39834192012-09-02 07:47:24 -0700851 public void applyPostLayoutPolicyLw(WindowState win,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800852 WindowManager.LayoutParams attrs);
853
854 /**
Craig Mautner39834192012-09-02 07:47:24 -0700855 * Called following layout of all windows and after policy has been applied
856 * to each window. If in this function you do
857 * something that may have modified the animation state of another window,
858 * be sure to return non-zero in order to perform another pass through layout.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800859 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800860 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
861 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
862 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800863 */
Craig Mautner39834192012-09-02 07:47:24 -0700864 public int finishPostLayoutPolicyLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800865
866 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800867 * Return true if it is okay to perform animations for an app transition
868 * that is about to occur. You may return false for this if, for example,
869 * the lock screen is currently displayed so the switch should happen
870 * immediately.
871 */
872 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -0800873
874
875 /**
876 * A new window has been focused.
877 */
Dianne Hackborndf89e652011-10-06 22:35:11 -0700878 public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800879
880 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800881 * Called after the screen turns off.
882 *
883 * @param why {@link #OFF_BECAUSE_OF_USER} or
884 * {@link #OFF_BECAUSE_OF_TIMEOUT}.
885 */
886 public void screenTurnedOff(int why);
887
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700888 public interface ScreenOnListener {
889 void onScreenOn();
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800890 }
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700891
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800892 /**
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700893 * Called when the power manager would like to turn the screen on.
894 * Must call back on the listener to tell it when the higher-level system
895 * is ready for the screen to go on (i.e. the lock screen is shown).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800896 */
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700897 public void screenTurningOn(ScreenOnListener screenOnListener);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800898
899 /**
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700900 * Return whether the screen is about to turn on or is currently on.
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800901 */
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700902 public boolean isScreenOnEarly();
903
904 /**
905 * Return whether the screen is fully turned on.
906 */
907 public boolean isScreenOnFully();
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700908
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800909 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700910 * Tell the policy that the lid switch has changed state.
911 * @param whenNanos The time when the change occurred in uptime nanoseconds.
912 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800913 */
Jeff Brown46b9ac02010-04-22 18:58:52 -0700914 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
915
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800916 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800917 * Tell the policy if anyone is requesting that keyguard not come on.
918 *
919 * @param enabled Whether keyguard can be on or not. does not actually
920 * turn it on, unless it was previously disabled with this function.
921 *
922 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
923 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
924 */
925 public void enableKeyguard(boolean enabled);
926
927 /**
928 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
929 */
930 interface OnKeyguardExitResult {
931 void onKeyguardExitResult(boolean success);
932 }
933
934 /**
935 * Tell the policy if anyone is requesting the keyguard to exit securely
936 * (this would be called after the keyguard was disabled)
937 * @param callback Callback to send the result back.
938 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
939 */
940 void exitKeyguardSecurely(OnKeyguardExitResult callback);
941
942 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -0500943 * isKeyguardLocked
944 *
945 * Return whether the keyguard is currently locked.
946 *
947 * @return true if in keyguard is locked.
948 */
949 public boolean isKeyguardLocked();
950
951 /**
952 * isKeyguardSecure
953 *
954 * Return whether the keyguard requires a password to unlock.
955 *
956 * @return true if in keyguard is secure.
957 */
958 public boolean isKeyguardSecure();
959
960 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800961 * inKeyguardRestrictedKeyInputMode
962 *
963 * if keyguard screen is showing or in restricted key input mode (i.e. in
964 * keyguard password emergency screen). When in such mode, certain keys,
965 * such as the Home key and the right soft keys, don't work.
966 *
967 * @return true if in keyguard restricted input mode.
968 */
969 public boolean inKeyguardRestrictedKeyInputMode();
970
971 /**
Dianne Hackborn90c52de2011-09-23 12:57:44 -0700972 * Ask the policy to dismiss the keyguard, if it is currently shown.
973 */
974 public void dismissKeyguardLw();
975
976 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -0700977 * Given an orientation constant, returns the appropriate surface rotation,
978 * taking into account sensors, docking mode, rotation lock, and other factors.
979 *
980 * @param orientation An orientation constant, such as
981 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
982 * @param lastRotation The most recently used rotation.
983 * @return The surface rotation to use.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984 */
Jeff Brown01a98dd2011-09-20 15:08:29 -0700985 public int rotationForOrientationLw(int orientation, int lastRotation);
986
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800987 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -0700988 * Given an orientation constant and a rotation, returns true if the rotation
989 * has compatible metrics to the requested orientation. For example, if
990 * the application requested landscape and got seascape, then the rotation
991 * has compatible metrics; if the application requested portrait and got landscape,
992 * then the rotation has incompatible metrics; if the application did not specify
993 * a preference, then anything goes.
994 *
995 * @param orientation An orientation constant, such as
996 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
997 * @param rotation The rotation to check.
998 * @return True if the rotation is compatible with the requested orientation.
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700999 */
Jeff Brown01a98dd2011-09-20 15:08:29 -07001000 public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation);
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001001
1002 /**
Jeff Brownc0347aa2011-09-23 17:26:09 -07001003 * Called by the window manager when the rotation changes.
1004 *
1005 * @param rotation The new rotation.
1006 */
1007 public void setRotationLw(int rotation);
1008
1009 /**
Jeff Brownac143512012-04-05 18:57:33 -07001010 * Called when the system is mostly done booting to set whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001011 * the system should go into safe mode.
1012 */
Jeff Brownac143512012-04-05 18:57:33 -07001013 public void setSafeMode(boolean safeMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001014
1015 /**
1016 * Called when the system is mostly done booting.
1017 */
1018 public void systemReady();
1019
1020 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -07001021 * Called when the system is done booting to the point where the
1022 * user can start interacting with it.
1023 */
1024 public void systemBooted();
1025
1026 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001027 * Show boot time message to the user.
1028 */
1029 public void showBootMessage(final CharSequence msg, final boolean always);
1030
1031 /**
1032 * Hide the UI for showing boot messages, never to be displayed again.
1033 */
1034 public void hideBootMessages();
1035
1036 /**
Mike Lockwoodef731622010-01-27 17:51:34 -05001037 * Called when userActivity is signalled in the power manager.
1038 * This is safe to call from any thread, with any window manager locks held or not.
1039 */
1040 public void userActivity();
1041
1042 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001043 * Called when we have finished booting and can now display the home
Jeff Brownc042ee22012-05-08 13:03:42 -07001044 * screen to the user. This will happen after systemReady(), and at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001045 * this point the display is active.
1046 */
1047 public void enableScreenAfterBoot();
1048
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001049 public void setCurrentOrientationLw(int newOrientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001050
1051 /**
1052 * Call from application to perform haptic feedback on its window.
1053 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001054 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001055
1056 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -04001057 * Called when we have started keeping the screen on because a window
1058 * requesting this has become visible.
1059 */
1060 public void screenOnStartedLw();
1061
1062 /**
1063 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001064 * requesting this is no longer visible.
1065 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001066 public void screenOnStoppedLw();
Mike Lockwood3d0ea722009-10-21 22:58:29 -04001067
1068 /**
1069 * Return false to disable key repeat events from being generated.
1070 */
1071 public boolean allowKeyRepeat();
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001072
1073 /**
1074 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
1075 *
1076 * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
Craig Mautner69b08182012-09-05 13:07:13 -07001077 * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001078 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
Craig Mautner69b08182012-09-05 13:07:13 -07001079 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001080 */
1081 public void setUserRotationMode(int mode, int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001082
1083 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -07001084 * Called when a new system UI visibility is being reported, allowing
1085 * the policy to adjust what is actually reported.
1086 * @param visibility The raw visiblity reported by the status bar.
1087 * @return The new desired visibility.
1088 */
1089 public int adjustSystemUiVisibilityLw(int visibility);
1090
1091 /**
Daniel Sandler0c4ccff2011-10-19 16:39:14 -04001092 * Specifies whether there is an on-screen navigation bar separate from the status bar.
1093 */
1094 public boolean hasNavigationBar();
1095
1096 /**
Jim Miller93c518e2012-01-17 15:55:31 -08001097 * Lock the device now.
1098 */
1099 public void lockNow();
1100
1101 /**
satok1bc0a492012-04-25 22:47:12 +09001102 * Set the last used input method window state. This state is used to make IME transition
1103 * smooth.
1104 * @hide
1105 */
1106 public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1107
1108 /**
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001109 * Print the WindowManagerPolicy's state into the given stream.
1110 *
1111 * @param prefix Text to print at the front of each line.
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001112 * @param writer The PrintWriter to which you should dump your state. This will be
1113 * closed for you after you return.
1114 * @param args additional arguments to the dump request.
1115 */
Jeff Brownd7a04de2012-06-17 14:17:52 -07001116 public void dump(String prefix, PrintWriter writer, String[] args);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001117}