blob: c26482b33ff5fb31885031177b93179b7cdfe97f [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;
Adam Cohenf7522022012-10-03 20:03:18 -070024import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.os.IBinder;
Dianne Hackborndf89e652011-10-06 22:35:11 -070026import android.os.Looper;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.view.animation.Animation;
28
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080029import 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
Jeff Browndaa37532012-05-01 15:54:03 -070093 // Flags used for indicating whether the internal and/or external input devices
94 // of some type are available.
95 public final static int PRESENCE_INTERNAL = 1 << 0;
96 public final static int PRESENCE_EXTERNAL = 1 << 1;
97
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 public final static boolean WATCH_POINTER = false;
99
Dianne Hackbornad7fa7f2011-01-07 14:06:50 -0800100 /**
101 * Sticky broadcast of the current HDMI plugged state.
102 */
103 public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
104
105 /**
106 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
107 * plugged in to HDMI, false if not.
108 */
109 public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
110
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800111 /**
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700112 * Pass this event to the user / app. To be returned from
113 * {@link #interceptKeyBeforeQueueing}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800114 */
115 public final static int ACTION_PASS_TO_USER = 0x00000001;
116
117 /**
Jeff Brown96307042012-07-27 15:51:34 -0700118 * This key event should wake the device.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700119 * To be returned from {@link #interceptKeyBeforeQueueing}.
120 * 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 -0800121 */
Jeff Brown96307042012-07-27 15:51:34 -0700122 public final static int ACTION_WAKE_UP = 0x00000002;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800123
124 /**
125 * This key event should put the device to sleep (and engage keyguard if necessary)
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700126 * To be returned from {@link #interceptKeyBeforeQueueing}.
Craig Mautner69b08182012-09-05 13:07:13 -0700127 * 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 -0800128 */
129 public final static int ACTION_GO_TO_SLEEP = 0x00000004;
130
131 /**
132 * Interface to the Window Manager state associated with a particular
133 * window. You can hold on to an instance of this interface from the call
134 * to prepareAddWindow() until removeWindow().
135 */
136 public interface WindowState {
137 /**
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800138 * Return the uid of the app that owns this window.
139 */
140 int getOwningUid();
141
142 /**
143 * Return the package name of the app that owns this window.
144 */
145 String getOwningPackage();
146
147 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800148 * Perform standard frame computation. The result can be obtained with
149 * getFrame() if so desired. Must be called with the window manager
150 * lock held.
151 *
152 * @param parentFrame The frame of the parent container this window
153 * is in, used for computing its basic position.
154 * @param displayFrame The frame of the overall display in which this
155 * window can appear, used for constraining the overall dimensions
156 * of the window.
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800157 * @param overlayFrame The frame within the display that is inside
158 * of the overlay region.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159 * @param contentFrame The frame within the display in which we would
160 * like active content to appear. This will cause windows behind to
161 * be resized to match the given content frame.
162 * @param visibleFrame The frame within the display that the window
163 * is actually visible, used for computing its visible insets to be
164 * given to windows behind.
165 * This can be used as a hint for scrolling (avoiding resizing)
166 * the window to make certain that parts of its content
167 * are visible.
168 */
169 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800170 Rect overlayFrame, Rect contentFrame, Rect visibleFrame);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800171
172 /**
173 * Retrieve the current frame of the window that has been assigned by
174 * the window manager. Must be called with the window manager lock held.
175 *
176 * @return Rect The rectangle holding the window frame.
177 */
178 public Rect getFrameLw();
179
180 /**
181 * Retrieve the current frame of the window that is actually shown.
182 * Must be called with the window manager lock held.
183 *
184 * @return Rect The rectangle holding the shown window frame.
185 */
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700186 public RectF getShownFrameLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187
188 /**
189 * Retrieve the frame of the display that this window was last
190 * laid out in. Must be called with the
191 * window manager lock held.
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700192 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 * @return Rect The rectangle holding the display frame.
194 */
195 public Rect getDisplayFrameLw();
196
197 /**
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800198 * Retrieve the frame of the area inside the overscan region of the
199 * display that this window was last laid out in. Must be called with the
200 * window manager lock held.
201 *
202 * @return Rect The rectangle holding the display overscan frame.
203 */
204 public Rect getOverscanFrameLw();
205
206 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800207 * Retrieve the frame of the content area that this window was last
208 * laid out in. This is the area in which the content of the window
209 * should be placed. It will be smaller than the display frame to
210 * account for screen decorations such as a status bar or soft
211 * keyboard. Must be called with the
212 * window manager lock held.
213 *
214 * @return Rect The rectangle holding the content frame.
215 */
216 public Rect getContentFrameLw();
217
218 /**
219 * Retrieve the frame of the visible area that this window was last
220 * laid out in. This is the area of the screen in which the window
221 * will actually be fully visible. It will be smaller than the
222 * content frame to account for transient UI elements blocking it
223 * such as an input method's candidates UI. Must be called with the
224 * window manager lock held.
225 *
226 * @return Rect The rectangle holding the visible frame.
227 */
228 public Rect getVisibleFrameLw();
229
230 /**
231 * Returns true if this window is waiting to receive its given
232 * internal insets from the client app, and so should not impact the
233 * layout of other windows.
234 */
235 public boolean getGivenInsetsPendingLw();
236
237 /**
238 * Retrieve the insets given by this window's client for the content
239 * area of windows behind it. Must be called with the
240 * window manager lock held.
241 *
242 * @return Rect The left, top, right, and bottom insets, relative
243 * to the window's frame, of the actual contents.
244 */
245 public Rect getGivenContentInsetsLw();
246
247 /**
248 * Retrieve the insets given by this window's client for the visible
249 * area of windows behind it. Must be called with the
250 * window manager lock held.
251 *
252 * @return Rect The left, top, right, and bottom insets, relative
253 * to the window's frame, of the actual visible area.
254 */
255 public Rect getGivenVisibleInsetsLw();
256
257 /**
258 * Retrieve the current LayoutParams of the window.
259 *
260 * @return WindowManager.LayoutParams The window's internal LayoutParams
261 * instance.
262 */
263 public WindowManager.LayoutParams getAttrs();
264
265 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800266 * Return whether this window needs the menu key shown. Must be called
267 * with window lock held, because it may need to traverse down through
268 * window list to determine the result.
269 * @param bottom The bottom-most window to consider when determining this.
270 */
271 public boolean getNeedsMenuLw(WindowState bottom);
272
273 /**
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700274 * Retrieve the current system UI visibility flags associated with
275 * this window.
276 */
277 public int getSystemUiVisibility();
278
279 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 * Get the layer at which this window's surface will be Z-ordered.
281 */
282 public int getSurfaceLayer();
283
284 /**
285 * Return the token for the application (actually activity) that owns
286 * this window. May return null for system windows.
287 *
288 * @return An IApplicationToken identifying the owning activity.
289 */
290 public IApplicationToken getAppToken();
291
292 /**
293 * Return true if, at any point, the application token associated with
294 * this window has actually displayed any windows. This is most useful
295 * with the "starting up" window to determine if any windows were
296 * displayed when it is closed.
297 *
298 * @return Returns true if one or more windows have been displayed,
299 * else false.
300 */
301 public boolean hasAppShownWindows();
302
303 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800304 * Is this window visible? It is not visible if there is no
305 * surface, or we are in the process of running an exit animation
306 * that will remove the surface.
307 */
308 boolean isVisibleLw();
309
310 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700311 * Like {@link #isVisibleLw}, but also counts a window that is currently
312 * "hidden" behind the keyguard as visible. This allows us to apply
313 * things like window flags that impact the keyguard.
314 */
315 boolean isVisibleOrBehindKeyguardLw();
316
317 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318 * Is this window currently visible to the user on-screen? It is
319 * displayed either if it is visible or it is currently running an
320 * animation before no longer being visible. Must be called with the
321 * window manager lock held.
322 */
323 boolean isDisplayedLw();
324
325 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700326 * Return true if this window (or a window it is attached to, but not
327 * considering its app token) is currently animating.
328 */
329 public boolean isAnimatingLw();
330
331 /**
Dianne Hackborn01b02a72012-01-12 14:05:03 -0800332 * Is this window considered to be gone for purposes of layout?
333 */
334 boolean isGoneForLayoutLw();
335
336 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800337 * Returns true if this window has been shown on screen at some time in
338 * the past. Must be called with the window manager lock held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339 */
340 public boolean hasDrawnLw();
341
342 /**
343 * Can be called by the policy to force a window to be hidden,
344 * regardless of whether the client or window manager would like
345 * it shown. Must be called with the window manager lock held.
346 * Returns true if {@link #showLw} was last called for the window.
347 */
348 public boolean hideLw(boolean doAnimation);
349
350 /**
351 * Can be called to undo the effect of {@link #hideLw}, allowing a
352 * window to be shown as long as the window manager and client would
353 * also like it to be shown. Must be called with the window manager
354 * lock held.
355 * Returns true if {@link #hideLw} was last called for the window.
356 */
357 public boolean showLw(boolean doAnimation);
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700358
359 /**
360 * Check whether the process hosting this window is currently alive.
361 */
362 public boolean isAlive();
Craig Mautner69b08182012-09-05 13:07:13 -0700363
364 /**
365 * Check if window is on {@link Display#DEFAULT_DISPLAY}.
366 * @return true if window is on default display.
367 */
368 public boolean isDefaultDisplay();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369 }
370
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700371 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700372 * Representation of a "fake window" that the policy has added to the
373 * window manager to consume events.
374 */
375 public interface FakeWindow {
376 /**
377 * Remove the fake window from the window manager.
378 */
379 void dismiss();
380 }
381
382 /**
383 * Interface for calling back in to the window manager that is private
384 * between it and the policy.
385 */
386 public interface WindowManagerFuncs {
Jeff Brownac143512012-04-05 18:57:33 -0700387 public static final int LID_ABSENT = -1;
388 public static final int LID_CLOSED = 0;
389 public static final int LID_OPEN = 1;
390
Dianne Hackborndf89e652011-10-06 22:35:11 -0700391 /**
392 * Ask the window manager to re-evaluate the system UI flags.
393 */
394 public void reevaluateStatusBarVisibility();
395
396 /**
397 * Add a fake window to the window manager. This window sits
398 * at the top of the other windows and consumes events.
399 */
Jeff Brown32cbc38552011-12-01 14:01:49 -0800400 public FakeWindow addFakeWindow(Looper looper,
401 InputEventReceiver.Factory inputEventReceiverFactory,
Dianne Hackborndf89e652011-10-06 22:35:11 -0700402 String name, int windowType, int layoutParamsFlags, boolean canReceiveKeys,
403 boolean hasFocus, boolean touchFullscreen);
Jeff Brownac143512012-04-05 18:57:33 -0700404
405 /**
406 * Returns a code that describes the current state of the lid switch.
407 */
408 public int getLidState();
409
410 /**
Jeff Browncf39bdf2012-05-18 14:41:19 -0700411 * Switch the keyboard layout for the given device.
412 * Direction should be +1 or -1 to go to the next or previous keyboard layout.
413 */
414 public void switchKeyboardLayout(int deviceId, int direction);
415
Jeff Brown9a538ee2012-08-20 14:56:57 -0700416 public void shutdown(boolean confirm);
417 public void rebootSafeMode(boolean confirm);
John Spurlock04db1762013-05-13 12:46:41 -0400418
419 /**
420 * Return the window manager lock needed to correctly call "Lw" methods.
421 */
422 public Object getWindowManagerLock();
Craig Mautner037aa8d2013-06-07 10:35:44 -0700423
424 /** Register a system listener for touch events */
425 void registerPointerEventListener(PointerEventListener listener);
426
427 /** Unregister a system listener for touch events */
428 void unregisterPointerEventListener(PointerEventListener listener);
429 }
430
431 public interface PointerEventListener {
432 /**
433 * 1. onPointerEvent will be called on the service.UiThread.
434 * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
435 * copy() must be made and the copy must be recycled.
436 **/
437 public void onPointerEvent(MotionEvent motionEvent);
Dianne Hackborndf89e652011-10-06 22:35:11 -0700438 }
439
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 /** Window has been added to the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800441 public static final int TRANSIT_ENTER = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800442 /** Window has been removed from the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800443 public static final int TRANSIT_EXIT = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800444 /** Window has been made visible. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800445 public static final int TRANSIT_SHOW = 3;
446 /** Window has been made invisible.
447 * TODO: Consider removal as this is unused. */
448 public static final int TRANSIT_HIDE = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800449 /** The "application starting" preview window is no longer needed, and will
450 * animate away to show the real window. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800451 public static final int TRANSIT_PREVIEW_DONE = 5;
452
Dianne Hackborn254cb442010-01-27 19:23:59 -0800453 // NOTE: screen off reasons are in order of significance, with more
454 // important ones lower than less important ones.
455
456 /** Screen turned off because of a device admin */
457 public final int OFF_BECAUSE_OF_ADMIN = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800458 /** Screen turned off because of power button */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800459 public final int OFF_BECAUSE_OF_USER = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800460 /** Screen turned off because of timeout */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800461 public final int OFF_BECAUSE_OF_TIMEOUT = 3;
Mike Lockwood435eb642009-12-03 08:40:18 -0500462 /** Screen turned off because of proximity sensor */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800463 public final int OFF_BECAUSE_OF_PROX_SENSOR = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800464
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400465 /** When not otherwise specified by the activity's screenOrientation, rotation should be
466 * determined by the system (that is, using sensors). */
467 public final int USER_ROTATION_FREE = 0;
468 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
469 * the user. */
470 public final int USER_ROTATION_LOCKED = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800471
472 /**
473 * Perform initialization of the policy.
474 *
475 * @param context The system context we are running in.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800476 */
477 public void init(Context context, IWindowManager windowManager,
Jeff Brown96307042012-07-27 15:51:34 -0700478 WindowManagerFuncs windowManagerFuncs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800479
480 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700481 * Called by window manager once it has the initial, default native
482 * display dimensions.
483 */
Dianne Hackborndde331c2012-08-03 14:01:57 -0700484 public void setInitialDisplaySize(Display display, int width, int height, int density);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700485
Dianne Hackborn9d132642011-04-21 17:26:39 -0700486 /**
Dianne Hackbornc652de82013-02-15 16:32:56 -0800487 * Called by window manager to set the overscan region that should be used for the
488 * given display.
489 */
490 public void setDisplayOverscan(Display display, int left, int top, int right, int bottom);
491
492 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800493 * Check permissions when adding a window.
494 *
Dianne Hackbornc2293022013-02-06 23:14:49 -0800495 * @param attrs The window's LayoutParams.
496 * @param outAppOp First element will be filled with the app op corresponding to
497 * this window, or OP_NONE.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800498 *
Jeff Brown98365d72012-08-19 20:30:52 -0700499 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800500 * else an error code, usually
Jeff Brown98365d72012-08-19 20:30:52 -0700501 * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800502 */
Dianne Hackbornc2293022013-02-06 23:14:49 -0800503 public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800504
505 /**
Craig Mautner88400d32012-09-30 12:35:45 -0700506 * Check permissions when adding a window.
507 *
508 * @param attrs The window's LayoutParams.
509 *
510 * @return True if the window may only be shown to the current user, false if the window can
511 * be shown on all users' windows.
512 */
513 public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
514
515 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800516 * Sanitize the layout parameters coming from a client. Allows the policy
517 * to do things like ensure that windows of a specific type can't take
518 * input focus.
519 *
520 * @param attrs The window layout parameters to be modified. These values
521 * are modified in-place.
522 */
523 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
524
525 /**
526 * After the window manager has computed the current configuration based
527 * on its knowledge of the display and input devices, it gives the policy
528 * a chance to adjust the information contained in it. If you want to
529 * leave it as-is, simply do nothing.
530 *
531 * <p>This method may be called by any thread in the window manager, but
532 * no internal locks in the window manager will be held.
533 *
534 * @param config The Configuration being computed, for you to change as
535 * desired.
Jeff Browndaa37532012-05-01 15:54:03 -0700536 * @param keyboardPresence Flags that indicate whether internal or external
537 * keyboards are present.
538 * @param navigationPresence Flags that indicate whether internal or external
539 * navigation devices are present.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 */
Jeff Browndaa37532012-05-01 15:54:03 -0700541 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
542 int navigationPresence);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543
544 /**
545 * Assign a window type to a layer. Allows you to control how different
546 * kinds of windows are ordered on-screen.
547 *
548 * @param type The type of window being assigned.
549 *
550 * @return int An arbitrary integer used to order windows, with lower
551 * numbers below higher ones.
552 */
553 public int windowTypeToLayerLw(int type);
554
555 /**
556 * Return how to Z-order sub-windows in relation to the window they are
557 * attached to. Return positive to have them ordered in front, negative for
558 * behind.
559 *
560 * @param type The sub-window type code.
561 *
562 * @return int Layer in relation to the attached window, where positive is
563 * above and negative is below.
564 */
565 public int subWindowTypeToLayerLw(int type);
566
567 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700568 * Get the highest layer (actually one more than) that the wallpaper is
569 * allowed to be in.
570 */
571 public int getMaxWallpaperLayer();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700572
573 /**
574 * Return the window layer at which windows appear above the normal
575 * universe (that is no longer impacted by the universe background
576 * transform).
577 */
578 public int getAboveUniverseLayer();
579
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700580 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700581 * Return the display width 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 getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400586
587 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700588 * Return the display height available after excluding any screen
589 * decorations that can never be removed. That is, system bar or
590 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400591 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700592 public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700593
594 /**
595 * Return the available screen width that we should report for the
596 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800597 * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700598 * that to account for more transient decoration like a status bar.
599 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700600 public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700601
602 /**
603 * Return the available screen height that we should report for the
604 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800605 * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700606 * that to account for more transient decoration like a status bar.
607 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700608 public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400609
610 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700611 * Return whether the given window should forcibly hide everything
612 * behind it. Typically returns true for the keyguard.
613 */
614 public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
615
616 /**
617 * Determine if a window that is behind one that is force hiding
618 * (as determined by {@link #doesForceHide}) should actually be hidden.
619 * For example, typically returns false for the status bar. Be careful
620 * to return false for any window that you may hide yourself, since this
621 * will conflict with what you set.
622 */
623 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
624
625 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800626 * Called when the system would like to show a UI to indicate that an
627 * application is starting. You can use this to add a
628 * APPLICATION_STARTING_TYPE window with the given appToken to the window
629 * manager (using the normal window manager APIs) that will be shown until
630 * the application displays its own window. This is called without the
631 * window manager locked so that you can call back into it.
632 *
633 * @param appToken Token of the application being started.
634 * @param packageName The name of the application package being started.
635 * @param theme Resource defining the application's overall visual theme.
636 * @param nonLocalizedLabel The default title label of the application if
637 * no data is found in the resource.
638 * @param labelRes The resource ID the application would like to use as its name.
639 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800640 * @param windowFlags Window layout flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800641 *
642 * @return Optionally you can return the View that was used to create the
643 * window, for easy removal in removeStartingWindow.
644 *
645 * @see #removeStartingWindow
646 */
647 public View addStartingWindow(IBinder appToken, String packageName,
Dianne Hackborn2f0b1752011-05-31 17:59:49 -0700648 int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
Adam Powell04fe6eb2013-05-31 14:39:48 -0700649 int labelRes, int icon, int logo, int windowFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800650
651 /**
652 * Called when the first window of an application has been displayed, while
653 * {@link #addStartingWindow} has created a temporary initial window for
654 * that application. You should at this point remove the window from the
655 * window manager. This is called without the window manager locked so
656 * that you can call back into it.
657 *
658 * <p>Note: due to the nature of these functions not being called with the
659 * window manager locked, you must be prepared for this function to be
660 * called multiple times and/or an initial time with a null View window
661 * even if you previously returned one.
662 *
663 * @param appToken Token of the application that has started.
664 * @param window Window View that was returned by createStartingWindow.
665 *
666 * @see #addStartingWindow
667 */
668 public void removeStartingWindow(IBinder appToken, View window);
669
670 /**
671 * Prepare for a window being added to the window manager. You can throw an
672 * exception here to prevent the window being added, or do whatever setup
673 * you need to keep track of the window.
674 *
675 * @param win The window being added.
676 * @param attrs The window's LayoutParams.
677 *
Jeff Brown98365d72012-08-19 20:30:52 -0700678 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800679 * error code to abort the add.
680 */
681 public int prepareAddWindowLw(WindowState win,
682 WindowManager.LayoutParams attrs);
683
684 /**
685 * Called when a window is being removed from a window manager. Must not
686 * throw an exception -- clean up as much as possible.
687 *
688 * @param win The window being removed.
689 */
690 public void removeWindowLw(WindowState win);
691
692 /**
693 * Control the animation to run when a window's state changes. Return a
694 * non-0 number to force the animation to a specific resource ID, or 0
695 * to use the default animation.
696 *
697 * @param win The window that is changing.
698 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
699 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
700 * {@link #TRANSIT_HIDE}.
701 *
702 * @return Resource ID of the actual animation to use, or 0 for none.
703 */
704 public int selectAnimationLw(WindowState win, int transit);
705
706 /**
Craig Mautner3c174372013-02-21 17:54:37 -0800707 * Determine the animation to run for a rotation transition based on the
708 * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
709 * and whether it is currently fullscreen and frontmost.
710 *
711 * @param anim The exiting animation resource id is stored in anim[0], the
712 * entering animation resource id is stored in anim[1].
713 */
714 public void selectRotationAnimationLw(int anim[]);
715
716 /**
717 * Validate whether the current top fullscreen has specified the same
718 * {@link WindowManager.LayoutParams#rotationAnimation} value as that
719 * being passed in from the previous top fullscreen window.
720 *
721 * @param exitAnimId exiting resource id from the previous window.
722 * @param enterAnimId entering resource id from the previous window.
723 * @param forceDefault For rotation animations only, if true ignore the
724 * animation values and just return false.
725 * @return true if the previous values are still valid, false if they
726 * should be replaced with the default.
727 */
728 public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId,
729 boolean forceDefault);
730
731 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700732 * Create and return an animation to re-display a force hidden window.
733 */
Dianne Hackborn0c2acff2012-04-12 15:17:07 -0700734 public Animation createForceHideEnterAnimation(boolean onWallpaper);
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700735
736 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700737 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800738 *
739 * <p>There are some actions that need to be handled here because they
740 * affect the power state of the device, for example, the power keys.
741 * Generally, it's best to keep as little as possible in the queue thread
742 * because it's the most fragile.
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.
745 * @param isScreenOn True if the screen is already on
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800746 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800747 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
Craig Mautner69b08182012-09-05 13:07:13 -0700748 * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800749 */
Jeff Brown1f245102010-11-18 20:53:46 -0800750 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
Jeff Brown56194eb2011-03-02 19:23:13 -0800751
752 /**
753 * Called from the input reader thread before a motion is enqueued when the screen is off.
754 *
755 * <p>There are some actions that need to be handled here because they
756 * affect the power state of the device, for example, waking on motions.
757 * Generally, it's best to keep as little as possible in the queue thread
758 * because it's the most fragile.
759 * @param policyFlags The policy flags associated with the motion.
760 *
761 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
Craig Mautner69b08182012-09-05 13:07:13 -0700762 * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
Jeff Brown56194eb2011-03-02 19:23:13 -0800763 */
764 public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags);
765
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800766 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700767 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800768 *
769 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -0700770 * behavior for keys that can not be overridden by applications.
771 * This method is called from the input thread, with no locks held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800772 *
773 * @param win The window that currently has focus. This is where the key
774 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800775 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700776 * @param policyFlags The policy flags associated with the key.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700777 * @return 0 if the key should be dispatched immediately, -1 if the key should
778 * not be dispatched ever, or a positive value indicating the number of
779 * milliseconds by which the key dispatch should be delayed before trying
780 * again.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800781 */
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700782 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800783
784 /**
Jeff Brown3915bb82010-11-05 15:02:16 -0700785 * Called from the input dispatcher thread when an application did not handle
786 * a key that was dispatched to it.
787 *
788 * <p>Allows you to define default global behavior for keys that were not handled
789 * by applications. This method is called from the input thread, with no locks held.
790 *
791 * @param win The window that currently has focus. This is where the key
792 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800793 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700794 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -0800795 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
796 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700797 */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800798 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -0700799
800 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800801 * Called when layout of the windows is about to start.
802 *
Craig Mautner69b08182012-09-05 13:07:13 -0700803 * @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800804 * @param displayWidth The current full width of the screen.
805 * @param displayHeight The current full height of the screen.
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700806 * @param displayRotation The current rotation being applied to the base
807 * window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800808 */
Craig Mautner69b08182012-09-05 13:07:13 -0700809 public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
810 int displayRotation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800811
812 /**
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700813 * Return the rectangle of the screen currently covered by system decorations.
814 * This will be called immediately after {@link #layoutWindowLw}. It can
815 * fill in the rectangle to indicate any part of the screen that it knows
816 * for sure is covered by system decor such as the status bar. The rectangle
817 * is initially set to the actual size of the screen, indicating nothing is
818 * covered.
819 *
820 * @param systemRect The rectangle of the screen that is not covered by
821 * system decoration.
822 * @return Returns the layer above which the system rectangle should
823 * not be applied.
824 */
825 public int getSystemDecorRectLw(Rect systemRect);
826
827 /**
Craig Mautner967212c2013-04-13 21:10:58 -0700828 * Return the rectangle of the screen that is available for applications to run in.
829 * This will be called immediately after {@link #beginLayoutLw}.
830 *
831 * @param r The rectangle to be filled with the boundaries available to applications.
832 */
833 public void getContentRectLw(Rect r);
834
835 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800836 * Called for each window attached to the window manager as layout is
837 * proceeding. The implementation of this function must take care of
838 * setting the window's frame, either here or in finishLayout().
839 *
840 * @param win The window being positioned.
841 * @param attrs The LayoutParams of the window.
842 * @param attached For sub-windows, the window it is attached to; this
843 * window will already have had layoutWindow() called on it
844 * so you can use its Rect. Otherwise null.
845 */
846 public void layoutWindowLw(WindowState win,
847 WindowManager.LayoutParams attrs, WindowState attached);
848
849
850 /**
851 * Return the insets for the areas covered by system windows. These values
852 * are computed on the most recent layout, so they are not guaranteed to
853 * be correct.
854 *
855 * @param attrs The LayoutParams of the window.
856 * @param contentInset The areas covered by system windows, expressed as positive insets
857 *
858 */
859 public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700860
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800861 /**
862 * Called when layout of the windows is finished. After this function has
863 * returned, all windows given to layoutWindow() <em>must</em> have had a
864 * frame assigned.
865 */
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800866 public void finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800867
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700868 /** Layout state may have changed (so another layout will be performed) */
869 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
870 /** Configuration state may have changed */
871 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
872 /** Wallpaper may need to move */
873 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800874 /** Need to recompute animations */
875 static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700876
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800877 /**
Craig Mautner39834192012-09-02 07:47:24 -0700878 * Called following layout of all windows before each window has policy applied.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800879 *
880 * @param displayWidth The current full width of the screen.
881 * @param displayHeight The current full height of the screen.
882 */
Craig Mautner39834192012-09-02 07:47:24 -0700883 public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800884
885 /**
Craig Mautner39834192012-09-02 07:47:24 -0700886 * Called following layout of all window to apply policy to each window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800887 *
888 * @param win The window being positioned.
889 * @param attrs The LayoutParams of the window.
890 */
Craig Mautner39834192012-09-02 07:47:24 -0700891 public void applyPostLayoutPolicyLw(WindowState win,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800892 WindowManager.LayoutParams attrs);
893
894 /**
Craig Mautner39834192012-09-02 07:47:24 -0700895 * Called following layout of all windows and after policy has been applied
896 * to each window. If in this function you do
897 * something that may have modified the animation state of another window,
898 * be sure to return non-zero in order to perform another pass through layout.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800899 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800900 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
901 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
902 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800903 */
Craig Mautner39834192012-09-02 07:47:24 -0700904 public int finishPostLayoutPolicyLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800905
906 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800907 * Return true if it is okay to perform animations for an app transition
908 * that is about to occur. You may return false for this if, for example,
909 * the lock screen is currently displayed so the switch should happen
910 * immediately.
911 */
912 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -0800913
914
915 /**
916 * A new window has been focused.
917 */
Dianne Hackborndf89e652011-10-06 22:35:11 -0700918 public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800919
920 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800921 * Called after the screen turns off.
922 *
923 * @param why {@link #OFF_BECAUSE_OF_USER} or
924 * {@link #OFF_BECAUSE_OF_TIMEOUT}.
925 */
926 public void screenTurnedOff(int why);
927
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700928 public interface ScreenOnListener {
929 void onScreenOn();
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800930 }
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700931
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800932 /**
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700933 * Called when the power manager would like to turn the screen on.
934 * Must call back on the listener to tell it when the higher-level system
935 * 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 -0800936 */
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700937 public void screenTurningOn(ScreenOnListener screenOnListener);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800938
939 /**
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700940 * Return whether the screen is about to turn on or is currently on.
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800941 */
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700942 public boolean isScreenOnEarly();
943
944 /**
945 * Return whether the screen is fully turned on.
946 */
947 public boolean isScreenOnFully();
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700948
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800949 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700950 * Tell the policy that the lid switch has changed state.
951 * @param whenNanos The time when the change occurred in uptime nanoseconds.
952 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800953 */
Jeff Brown46b9ac02010-04-22 18:58:52 -0700954 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
955
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800956 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800957 * Tell the policy if anyone is requesting that keyguard not come on.
958 *
959 * @param enabled Whether keyguard can be on or not. does not actually
960 * turn it on, unless it was previously disabled with this function.
961 *
962 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
963 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
964 */
Craig Mautner3c174372013-02-21 17:54:37 -0800965 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800966 public void enableKeyguard(boolean enabled);
967
968 /**
969 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
970 */
971 interface OnKeyguardExitResult {
972 void onKeyguardExitResult(boolean success);
973 }
974
975 /**
976 * Tell the policy if anyone is requesting the keyguard to exit securely
977 * (this would be called after the keyguard was disabled)
978 * @param callback Callback to send the result back.
979 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
980 */
Craig Mautner3c174372013-02-21 17:54:37 -0800981 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800982 void exitKeyguardSecurely(OnKeyguardExitResult callback);
983
984 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -0500985 * isKeyguardLocked
986 *
987 * Return whether the keyguard is currently locked.
988 *
989 * @return true if in keyguard is locked.
990 */
991 public boolean isKeyguardLocked();
992
993 /**
994 * isKeyguardSecure
995 *
996 * Return whether the keyguard requires a password to unlock.
997 *
998 * @return true if in keyguard is secure.
999 */
1000 public boolean isKeyguardSecure();
1001
1002 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001003 * inKeyguardRestrictedKeyInputMode
1004 *
1005 * if keyguard screen is showing or in restricted key input mode (i.e. in
1006 * keyguard password emergency screen). When in such mode, certain keys,
1007 * such as the Home key and the right soft keys, don't work.
1008 *
1009 * @return true if in keyguard restricted input mode.
1010 */
1011 public boolean inKeyguardRestrictedKeyInputMode();
1012
1013 /**
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001014 * Ask the policy to dismiss the keyguard, if it is currently shown.
1015 */
1016 public void dismissKeyguardLw();
1017
1018 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001019 * Given an orientation constant, returns the appropriate surface rotation,
1020 * taking into account sensors, docking mode, rotation lock, and other factors.
1021 *
1022 * @param orientation An orientation constant, such as
1023 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1024 * @param lastRotation The most recently used rotation.
1025 * @return The surface rotation to use.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001026 */
Jeff Brown01a98dd2011-09-20 15:08:29 -07001027 public int rotationForOrientationLw(int orientation, int lastRotation);
1028
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001029 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001030 * Given an orientation constant and a rotation, returns true if the rotation
1031 * has compatible metrics to the requested orientation. For example, if
1032 * the application requested landscape and got seascape, then the rotation
1033 * has compatible metrics; if the application requested portrait and got landscape,
1034 * then the rotation has incompatible metrics; if the application did not specify
1035 * a preference, then anything goes.
1036 *
1037 * @param orientation An orientation constant, such as
1038 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1039 * @param rotation The rotation to check.
1040 * @return True if the rotation is compatible with the requested orientation.
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001041 */
Jeff Brown01a98dd2011-09-20 15:08:29 -07001042 public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation);
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001043
1044 /**
Jeff Brownc0347aa2011-09-23 17:26:09 -07001045 * Called by the window manager when the rotation changes.
1046 *
1047 * @param rotation The new rotation.
1048 */
1049 public void setRotationLw(int rotation);
1050
1051 /**
Jeff Brownac143512012-04-05 18:57:33 -07001052 * Called when the system is mostly done booting to set whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001053 * the system should go into safe mode.
1054 */
Jeff Brownac143512012-04-05 18:57:33 -07001055 public void setSafeMode(boolean safeMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001056
1057 /**
1058 * Called when the system is mostly done booting.
1059 */
1060 public void systemReady();
1061
1062 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -07001063 * Called when the system is done booting to the point where the
1064 * user can start interacting with it.
1065 */
1066 public void systemBooted();
1067
1068 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001069 * Show boot time message to the user.
1070 */
1071 public void showBootMessage(final CharSequence msg, final boolean always);
1072
1073 /**
1074 * Hide the UI for showing boot messages, never to be displayed again.
1075 */
1076 public void hideBootMessages();
1077
1078 /**
Mike Lockwoodef731622010-01-27 17:51:34 -05001079 * Called when userActivity is signalled in the power manager.
1080 * This is safe to call from any thread, with any window manager locks held or not.
1081 */
1082 public void userActivity();
1083
1084 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001085 * Called when we have finished booting and can now display the home
Jeff Brownc042ee22012-05-08 13:03:42 -07001086 * screen to the user. This will happen after systemReady(), and at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001087 * this point the display is active.
1088 */
1089 public void enableScreenAfterBoot();
1090
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001091 public void setCurrentOrientationLw(int newOrientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001092
1093 /**
1094 * Call from application to perform haptic feedback on its window.
1095 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001096 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001097
1098 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -04001099 * Called when we have started keeping the screen on because a window
1100 * requesting this has become visible.
1101 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001102 public void keepScreenOnStartedLw();
Daniel Sandler0601eb72011-04-13 01:01:32 -04001103
1104 /**
1105 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001106 * requesting this is no longer visible.
1107 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001108 public void keepScreenOnStoppedLw();
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001109
1110 /**
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001111 * Gets the current user rotation mode.
1112 *
1113 * @return The rotation mode.
1114 *
1115 * @see WindowManagerPolicy#USER_ROTATION_LOCKED
1116 * @see WindowManagerPolicy#USER_ROTATION_FREE
1117 */
1118 public int getUserRotationMode();
1119
1120 /**
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001121 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
1122 *
1123 * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
Craig Mautner69b08182012-09-05 13:07:13 -07001124 * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001125 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
Craig Mautner69b08182012-09-05 13:07:13 -07001126 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001127 */
1128 public void setUserRotationMode(int mode, int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001129
1130 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -07001131 * Called when a new system UI visibility is being reported, allowing
1132 * the policy to adjust what is actually reported.
1133 * @param visibility The raw visiblity reported by the status bar.
1134 * @return The new desired visibility.
1135 */
1136 public int adjustSystemUiVisibilityLw(int visibility);
1137
1138 /**
Daniel Sandler0c4ccff2011-10-19 16:39:14 -04001139 * Specifies whether there is an on-screen navigation bar separate from the status bar.
1140 */
1141 public boolean hasNavigationBar();
1142
1143 /**
Jim Miller93c518e2012-01-17 15:55:31 -08001144 * Lock the device now.
1145 */
Adam Cohenf7522022012-10-03 20:03:18 -07001146 public void lockNow(Bundle options);
Jim Miller93c518e2012-01-17 15:55:31 -08001147
1148 /**
satok1bc0a492012-04-25 22:47:12 +09001149 * Set the last used input method window state. This state is used to make IME transition
1150 * smooth.
1151 * @hide
1152 */
1153 public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1154
1155 /**
Craig Mautnerf1b67412012-09-19 13:18:29 -07001156 * Called when the current user changes. Guaranteed to be called before the broadcast
1157 * of the new user id is made to all listeners.
1158 *
1159 * @param newUserId The id of the incoming user.
1160 */
1161 public void setCurrentUserLw(int newUserId);
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -07001162
1163 /**
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001164 * Print the WindowManagerPolicy's state into the given stream.
1165 *
1166 * @param prefix Text to print at the front of each line.
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001167 * @param writer The PrintWriter to which you should dump your state. This will be
1168 * closed for you after you return.
1169 * @param args additional arguments to the dump request.
1170 */
Jeff Brownd7a04de2012-06-17 14:17:52 -07001171 public void dump(String prefix, PrintWriter writer, String[] args);
Jim Miller4eeb4f62012-11-08 00:04:29 -08001172
1173 /**
1174 * Ask keyguard to invoke the assist intent after dismissing keyguard
1175 * {@link android.content.Intent#ACTION_ASSIST}
1176 */
1177 public void showAssistant();
Svetoslav Ganov545252f2012-12-10 18:29:24 -08001178
1179 /**
1180 * Returns whether a given window type can be magnified.
1181 *
1182 * @param windowType The window type.
1183 * @return True if the window can be magnified.
1184 */
1185 public boolean canMagnifyWindow(int windowType);
1186
1187 /**
1188 * Returns whether a given window type is considered a top level one.
1189 * A top level window does not have a container, i.e. attached window,
1190 * or if it has a container it is laid out as a top-level window, not
1191 * as a child of its container.
1192 *
1193 * @param windowType The window type.
1194 * @return True if the window is a top level one.
1195 */
1196 public boolean isTopLevelWindow(int windowType);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001197}