blob: d9e140e8cfc4336fc189c74367e6cbe8c29e660d [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
Tor Norbyed9273d62013-05-30 15:59:53 -070019import android.annotation.IntDef;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020import android.content.Context;
Tor Norbyed9273d62013-05-30 15:59:53 -070021import android.content.pm.ActivityInfo;
Dianne Hackborn2f0b1752011-05-31 17:59:49 -070022import android.content.res.CompatibilityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.content.res.Configuration;
24import android.graphics.Rect;
Dianne Hackbornd040edb2011-08-31 12:47:58 -070025import android.graphics.RectF;
Adam Cohenf7522022012-10-03 20:03:18 -070026import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.os.IBinder;
Dianne Hackborndf89e652011-10-06 22:35:11 -070028import android.os.Looper;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.view.animation.Animation;
30
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080031import java.io.PrintWriter;
Tor Norbyed9273d62013-05-30 15:59:53 -070032import java.lang.annotation.Retention;
33import java.lang.annotation.RetentionPolicy;
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080034
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035/**
36 * This interface supplies all UI-specific behavior of the window manager. An
37 * instance of it is created by the window manager when it starts up, and allows
38 * customization of window layering, special window types, key dispatching, and
39 * layout.
40 *
41 * <p>Because this provides deep interaction with the system window manager,
42 * specific methods on this interface can be called from a variety of contexts
43 * with various restrictions on what they can do. These are encoded through
44 * a suffixes at the end of a method encoding the thread the method is called
45 * from and any locks that are held when it is being called; if no suffix
46 * is attached to a method, then it is not called with any locks and may be
47 * called from the main window manager thread or another thread calling into
48 * the window manager.
49 *
50 * <p>The current suffixes are:
51 *
52 * <dl>
53 * <dt> Ti <dd> Called from the input thread. This is the thread that
54 * collects pending input events and dispatches them to the appropriate window.
55 * It may block waiting for events to be processed, so that the input stream is
56 * properly serialized.
57 * <dt> Tq <dd> Called from the low-level input queue thread. This is the
58 * thread that reads events out of the raw input devices and places them
59 * into the global input queue that is read by the <var>Ti</var> thread.
60 * This thread should not block for a long period of time on anything but the
61 * key driver.
62 * <dt> Lw <dd> Called with the main window manager lock held. Because the
63 * window manager is a very low-level system service, there are few other
64 * system services you can call with this lock held. It is explicitly okay to
65 * make calls into the package manager and power manager; it is explicitly not
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070066 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067 * {@link android.content.Context#checkPermission(String, int, int)} and
68 * variations require calling into the activity manager.
69 * <dt> Li <dd> Called with the input thread lock held. This lock can be
70 * acquired by the window manager while it holds the window lock, so this is
71 * even more restrictive than <var>Lw</var>.
72 * </dl>
73 *
74 * @hide
75 */
76public interface WindowManagerPolicy {
Jeff Brownb6997262010-10-08 22:31:17 -070077 // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080078 public final static int FLAG_WAKE = 0x00000001;
79 public final static int FLAG_WAKE_DROPPED = 0x00000002;
80 public final static int FLAG_SHIFT = 0x00000004;
81 public final static int FLAG_CAPS_LOCK = 0x00000008;
82 public final static int FLAG_ALT = 0x00000010;
83 public final static int FLAG_ALT_GR = 0x00000020;
84 public final static int FLAG_MENU = 0x00000040;
85 public final static int FLAG_LAUNCHER = 0x00000080;
Jeff Brown0eaf3932010-10-01 14:55:30 -070086 public final static int FLAG_VIRTUAL = 0x00000100;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080087
Jeff Brown85a31762010-09-01 17:01:00 -070088 public final static int FLAG_INJECTED = 0x01000000;
Jeff Browne20c9e02010-10-11 14:20:19 -070089 public final static int FLAG_TRUSTED = 0x02000000;
Jeff Brown0029c662011-03-30 02:25:18 -070090 public final static int FLAG_FILTERED = 0x04000000;
91 public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
Jeff Brown85a31762010-09-01 17:01:00 -070092
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 public final static int FLAG_WOKE_HERE = 0x10000000;
94 public final static int FLAG_BRIGHT_HERE = 0x20000000;
Jeff Brownb6997262010-10-08 22:31:17 -070095 public final static int FLAG_PASS_TO_USER = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096
Jeff Browndaa37532012-05-01 15:54:03 -070097 // Flags used for indicating whether the internal and/or external input devices
98 // of some type are available.
99 public final static int PRESENCE_INTERNAL = 1 << 0;
100 public final static int PRESENCE_EXTERNAL = 1 << 1;
101
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 public final static boolean WATCH_POINTER = false;
103
Dianne Hackbornad7fa7f2011-01-07 14:06:50 -0800104 /**
105 * Sticky broadcast of the current HDMI plugged state.
106 */
107 public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
108
109 /**
110 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
111 * plugged in to HDMI, false if not.
112 */
113 public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
114
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 /**
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700116 * Pass this event to the user / app. To be returned from
117 * {@link #interceptKeyBeforeQueueing}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 */
119 public final static int ACTION_PASS_TO_USER = 0x00000001;
120
121 /**
Jeff Brown96307042012-07-27 15:51:34 -0700122 * This key event should wake the device.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700123 * To be returned from {@link #interceptKeyBeforeQueueing}.
124 * 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 -0800125 */
Jeff Brown96307042012-07-27 15:51:34 -0700126 public final static int ACTION_WAKE_UP = 0x00000002;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127
128 /**
129 * This key event should put the device to sleep (and engage keyguard if necessary)
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700130 * To be returned from {@link #interceptKeyBeforeQueueing}.
Craig Mautner69b08182012-09-05 13:07:13 -0700131 * 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 -0800132 */
133 public final static int ACTION_GO_TO_SLEEP = 0x00000004;
134
135 /**
136 * Interface to the Window Manager state associated with a particular
137 * window. You can hold on to an instance of this interface from the call
138 * to prepareAddWindow() until removeWindow().
139 */
140 public interface WindowState {
141 /**
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800142 * Return the uid of the app that owns this window.
143 */
144 int getOwningUid();
145
146 /**
147 * Return the package name of the app that owns this window.
148 */
149 String getOwningPackage();
150
151 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800152 * Perform standard frame computation. The result can be obtained with
153 * getFrame() if so desired. Must be called with the window manager
154 * lock held.
155 *
156 * @param parentFrame The frame of the parent container this window
157 * is in, used for computing its basic position.
158 * @param displayFrame The frame of the overall display in which this
159 * window can appear, used for constraining the overall dimensions
160 * of the window.
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800161 * @param overlayFrame The frame within the display that is inside
162 * of the overlay region.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163 * @param contentFrame The frame within the display in which we would
164 * like active content to appear. This will cause windows behind to
165 * be resized to match the given content frame.
166 * @param visibleFrame The frame within the display that the window
167 * is actually visible, used for computing its visible insets to be
168 * given to windows behind.
169 * This can be used as a hint for scrolling (avoiding resizing)
170 * the window to make certain that parts of its content
171 * are visible.
John Spurlock46646232013-09-30 22:32:42 -0400172 * @param decorFrame The decor frame specified by policy specific to this window,
173 * to use for proper cropping during animation.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800174 */
175 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
John Spurlock46646232013-09-30 22:32:42 -0400176 Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800177
178 /**
179 * Retrieve the current frame of the window that has been assigned by
180 * the window manager. Must be called with the window manager lock held.
181 *
182 * @return Rect The rectangle holding the window frame.
183 */
184 public Rect getFrameLw();
185
186 /**
187 * Retrieve the current frame of the window that is actually shown.
188 * Must be called with the window manager lock held.
189 *
190 * @return Rect The rectangle holding the shown window frame.
191 */
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700192 public RectF getShownFrameLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193
194 /**
195 * Retrieve the frame of the display that this window was last
196 * laid out in. Must be called with the
197 * window manager lock held.
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700198 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199 * @return Rect The rectangle holding the display frame.
200 */
201 public Rect getDisplayFrameLw();
202
203 /**
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800204 * Retrieve the frame of the area inside the overscan region of the
205 * display that this window was last laid out in. Must be called with the
206 * window manager lock held.
207 *
208 * @return Rect The rectangle holding the display overscan frame.
209 */
210 public Rect getOverscanFrameLw();
211
212 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800213 * Retrieve the frame of the content area that this window was last
214 * laid out in. This is the area in which the content of the window
215 * should be placed. It will be smaller than the display frame to
216 * account for screen decorations such as a status bar or soft
217 * keyboard. Must be called with the
218 * window manager lock held.
219 *
220 * @return Rect The rectangle holding the content frame.
221 */
222 public Rect getContentFrameLw();
223
224 /**
225 * Retrieve the frame of the visible area that this window was last
226 * laid out in. This is the area of the screen in which the window
227 * will actually be fully visible. It will be smaller than the
228 * content frame to account for transient UI elements blocking it
229 * such as an input method's candidates UI. Must be called with the
230 * window manager lock held.
231 *
232 * @return Rect The rectangle holding the visible frame.
233 */
234 public Rect getVisibleFrameLw();
235
236 /**
237 * Returns true if this window is waiting to receive its given
238 * internal insets from the client app, and so should not impact the
239 * layout of other windows.
240 */
241 public boolean getGivenInsetsPendingLw();
242
243 /**
244 * Retrieve the insets given by this window's client for the content
245 * area of windows behind it. Must be called with the
246 * window manager lock held.
247 *
248 * @return Rect The left, top, right, and bottom insets, relative
249 * to the window's frame, of the actual contents.
250 */
251 public Rect getGivenContentInsetsLw();
252
253 /**
254 * Retrieve the insets given by this window's client for the visible
255 * area of windows behind it. Must be called with the
256 * window manager lock held.
257 *
258 * @return Rect The left, top, right, and bottom insets, relative
259 * to the window's frame, of the actual visible area.
260 */
261 public Rect getGivenVisibleInsetsLw();
262
263 /**
264 * Retrieve the current LayoutParams of the window.
265 *
266 * @return WindowManager.LayoutParams The window's internal LayoutParams
267 * instance.
268 */
269 public WindowManager.LayoutParams getAttrs();
270
271 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800272 * Return whether this window needs the menu key shown. Must be called
273 * with window lock held, because it may need to traverse down through
274 * window list to determine the result.
275 * @param bottom The bottom-most window to consider when determining this.
276 */
277 public boolean getNeedsMenuLw(WindowState bottom);
278
279 /**
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700280 * Retrieve the current system UI visibility flags associated with
281 * this window.
282 */
283 public int getSystemUiVisibility();
284
285 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800286 * Get the layer at which this window's surface will be Z-ordered.
287 */
288 public int getSurfaceLayer();
289
290 /**
291 * Return the token for the application (actually activity) that owns
292 * this window. May return null for system windows.
293 *
294 * @return An IApplicationToken identifying the owning activity.
295 */
296 public IApplicationToken getAppToken();
297
298 /**
299 * Return true if, at any point, the application token associated with
300 * this window has actually displayed any windows. This is most useful
301 * with the "starting up" window to determine if any windows were
302 * displayed when it is closed.
303 *
304 * @return Returns true if one or more windows have been displayed,
305 * else false.
306 */
307 public boolean hasAppShownWindows();
308
309 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800310 * Is this window visible? It is not visible if there is no
311 * surface, or we are in the process of running an exit animation
312 * that will remove the surface.
313 */
314 boolean isVisibleLw();
315
316 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700317 * Like {@link #isVisibleLw}, but also counts a window that is currently
318 * "hidden" behind the keyguard as visible. This allows us to apply
319 * things like window flags that impact the keyguard.
320 */
321 boolean isVisibleOrBehindKeyguardLw();
322
323 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324 * Is this window currently visible to the user on-screen? It is
325 * displayed either if it is visible or it is currently running an
326 * animation before no longer being visible. Must be called with the
327 * window manager lock held.
328 */
329 boolean isDisplayedLw();
330
331 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700332 * Return true if this window (or a window it is attached to, but not
333 * considering its app token) is currently animating.
334 */
335 public boolean isAnimatingLw();
336
337 /**
Dianne Hackborn01b02a72012-01-12 14:05:03 -0800338 * Is this window considered to be gone for purposes of layout?
339 */
340 boolean isGoneForLayoutLw();
341
342 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800343 * Returns true if this window has been shown on screen at some time in
344 * the past. Must be called with the window manager lock held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800345 */
346 public boolean hasDrawnLw();
347
348 /**
349 * Can be called by the policy to force a window to be hidden,
350 * regardless of whether the client or window manager would like
351 * it shown. Must be called with the window manager lock held.
352 * Returns true if {@link #showLw} was last called for the window.
353 */
354 public boolean hideLw(boolean doAnimation);
355
356 /**
357 * Can be called to undo the effect of {@link #hideLw}, allowing a
358 * window to be shown as long as the window manager and client would
359 * also like it to be shown. Must be called with the window manager
360 * lock held.
361 * Returns true if {@link #hideLw} was last called for the window.
362 */
363 public boolean showLw(boolean doAnimation);
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700364
365 /**
366 * Check whether the process hosting this window is currently alive.
367 */
368 public boolean isAlive();
Craig Mautner69b08182012-09-05 13:07:13 -0700369
370 /**
371 * Check if window is on {@link Display#DEFAULT_DISPLAY}.
372 * @return true if window is on default display.
373 */
374 public boolean isDefaultDisplay();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800375 }
376
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700377 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700378 * Representation of a "fake window" that the policy has added to the
379 * window manager to consume events.
380 */
381 public interface FakeWindow {
382 /**
383 * Remove the fake window from the window manager.
384 */
385 void dismiss();
386 }
387
388 /**
389 * Interface for calling back in to the window manager that is private
390 * between it and the policy.
391 */
392 public interface WindowManagerFuncs {
Jeff Brownac143512012-04-05 18:57:33 -0700393 public static final int LID_ABSENT = -1;
394 public static final int LID_CLOSED = 0;
395 public static final int LID_OPEN = 1;
396
Dianne Hackborndf89e652011-10-06 22:35:11 -0700397 /**
398 * Ask the window manager to re-evaluate the system UI flags.
399 */
400 public void reevaluateStatusBarVisibility();
401
402 /**
403 * Add a fake window to the window manager. This window sits
404 * at the top of the other windows and consumes events.
405 */
Jeff Brown32cbc38552011-12-01 14:01:49 -0800406 public FakeWindow addFakeWindow(Looper looper,
407 InputEventReceiver.Factory inputEventReceiverFactory,
Adam Lesinski95c42972013-10-02 10:13:27 -0700408 String name, int windowType, int layoutParamsFlags, int layoutParamsPrivateFlags,
409 boolean canReceiveKeys, boolean hasFocus, boolean touchFullscreen);
Jeff Brownac143512012-04-05 18:57:33 -0700410
411 /**
412 * Returns a code that describes the current state of the lid switch.
413 */
414 public int getLidState();
415
416 /**
Jeff Browncf39bdf2012-05-18 14:41:19 -0700417 * Switch the keyboard layout for the given device.
418 * Direction should be +1 or -1 to go to the next or previous keyboard layout.
419 */
420 public void switchKeyboardLayout(int deviceId, int direction);
421
Jeff Brown9a538ee2012-08-20 14:56:57 -0700422 public void shutdown(boolean confirm);
423 public void rebootSafeMode(boolean confirm);
John Spurlock04db1762013-05-13 12:46:41 -0400424
425 /**
426 * Return the window manager lock needed to correctly call "Lw" methods.
427 */
428 public Object getWindowManagerLock();
Craig Mautner037aa8d2013-06-07 10:35:44 -0700429
430 /** Register a system listener for touch events */
431 void registerPointerEventListener(PointerEventListener listener);
432
433 /** Unregister a system listener for touch events */
434 void unregisterPointerEventListener(PointerEventListener listener);
435 }
436
437 public interface PointerEventListener {
438 /**
439 * 1. onPointerEvent will be called on the service.UiThread.
440 * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
441 * copy() must be made and the copy must be recycled.
442 **/
443 public void onPointerEvent(MotionEvent motionEvent);
Dianne Hackborndf89e652011-10-06 22:35:11 -0700444 }
445
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 /** Window has been added to the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800447 public static final int TRANSIT_ENTER = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800448 /** Window has been removed from the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800449 public static final int TRANSIT_EXIT = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800450 /** Window has been made visible. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800451 public static final int TRANSIT_SHOW = 3;
452 /** Window has been made invisible.
453 * TODO: Consider removal as this is unused. */
454 public static final int TRANSIT_HIDE = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 /** The "application starting" preview window is no longer needed, and will
456 * animate away to show the real window. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800457 public static final int TRANSIT_PREVIEW_DONE = 5;
458
Dianne Hackborn254cb442010-01-27 19:23:59 -0800459 // NOTE: screen off reasons are in order of significance, with more
460 // important ones lower than less important ones.
461
462 /** Screen turned off because of a device admin */
463 public final int OFF_BECAUSE_OF_ADMIN = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800464 /** Screen turned off because of power button */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800465 public final int OFF_BECAUSE_OF_USER = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800466 /** Screen turned off because of timeout */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800467 public final int OFF_BECAUSE_OF_TIMEOUT = 3;
Mike Lockwood435eb642009-12-03 08:40:18 -0500468 /** Screen turned off because of proximity sensor */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800469 public final int OFF_BECAUSE_OF_PROX_SENSOR = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800470
Tor Norbyed9273d62013-05-30 15:59:53 -0700471 /** @hide */
472 @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED})
473 @Retention(RetentionPolicy.SOURCE)
474 public @interface UserRotationMode {}
475
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400476 /** When not otherwise specified by the activity's screenOrientation, rotation should be
477 * determined by the system (that is, using sensors). */
478 public final int USER_ROTATION_FREE = 0;
479 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
480 * the user. */
481 public final int USER_ROTATION_LOCKED = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800482
483 /**
484 * Perform initialization of the policy.
485 *
486 * @param context The system context we are running in.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800487 */
488 public void init(Context context, IWindowManager windowManager,
Jeff Brown96307042012-07-27 15:51:34 -0700489 WindowManagerFuncs windowManagerFuncs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800490
491 /**
Craig Mautner46ac6fa2013-08-01 10:06:34 -0700492 * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true.
493 */
494 public boolean isDefaultOrientationForced();
495
496 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700497 * Called by window manager once it has the initial, default native
498 * display dimensions.
499 */
Dianne Hackborndde331c2012-08-03 14:01:57 -0700500 public void setInitialDisplaySize(Display display, int width, int height, int density);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700501
Dianne Hackborn9d132642011-04-21 17:26:39 -0700502 /**
Dianne Hackbornc652de82013-02-15 16:32:56 -0800503 * Called by window manager to set the overscan region that should be used for the
504 * given display.
505 */
506 public void setDisplayOverscan(Display display, int left, int top, int right, int bottom);
507
508 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 * Check permissions when adding a window.
510 *
Dianne Hackbornc2293022013-02-06 23:14:49 -0800511 * @param attrs The window's LayoutParams.
512 * @param outAppOp First element will be filled with the app op corresponding to
513 * this window, or OP_NONE.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 *
Jeff Brown98365d72012-08-19 20:30:52 -0700515 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800516 * else an error code, usually
Jeff Brown98365d72012-08-19 20:30:52 -0700517 * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800518 */
Dianne Hackbornc2293022013-02-06 23:14:49 -0800519 public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800520
521 /**
Craig Mautner88400d32012-09-30 12:35:45 -0700522 * Check permissions when adding a window.
523 *
524 * @param attrs The window's LayoutParams.
525 *
526 * @return True if the window may only be shown to the current user, false if the window can
527 * be shown on all users' windows.
528 */
529 public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
530
531 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800532 * Sanitize the layout parameters coming from a client. Allows the policy
533 * to do things like ensure that windows of a specific type can't take
534 * input focus.
535 *
536 * @param attrs The window layout parameters to be modified. These values
537 * are modified in-place.
538 */
539 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
540
541 /**
542 * After the window manager has computed the current configuration based
543 * on its knowledge of the display and input devices, it gives the policy
544 * a chance to adjust the information contained in it. If you want to
545 * leave it as-is, simply do nothing.
546 *
547 * <p>This method may be called by any thread in the window manager, but
548 * no internal locks in the window manager will be held.
549 *
550 * @param config The Configuration being computed, for you to change as
551 * desired.
Jeff Browndaa37532012-05-01 15:54:03 -0700552 * @param keyboardPresence Flags that indicate whether internal or external
553 * keyboards are present.
554 * @param navigationPresence Flags that indicate whether internal or external
555 * navigation devices are present.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800556 */
Jeff Browndaa37532012-05-01 15:54:03 -0700557 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
558 int navigationPresence);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800559
560 /**
561 * Assign a window type to a layer. Allows you to control how different
562 * kinds of windows are ordered on-screen.
563 *
564 * @param type The type of window being assigned.
565 *
566 * @return int An arbitrary integer used to order windows, with lower
567 * numbers below higher ones.
568 */
569 public int windowTypeToLayerLw(int type);
570
571 /**
572 * Return how to Z-order sub-windows in relation to the window they are
573 * attached to. Return positive to have them ordered in front, negative for
574 * behind.
575 *
576 * @param type The sub-window type code.
577 *
578 * @return int Layer in relation to the attached window, where positive is
579 * above and negative is below.
580 */
581 public int subWindowTypeToLayerLw(int type);
582
583 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700584 * Get the highest layer (actually one more than) that the wallpaper is
585 * allowed to be in.
586 */
587 public int getMaxWallpaperLayer();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700588
589 /**
590 * Return the window layer at which windows appear above the normal
591 * universe (that is no longer impacted by the universe background
592 * transform).
593 */
594 public int getAboveUniverseLayer();
595
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700596 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700597 * Return the display width available after excluding any screen
598 * decorations that can never be removed. That is, system bar or
599 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400600 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700601 public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400602
603 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700604 * Return the display height available after excluding any screen
605 * decorations that can never be removed. That is, system bar or
606 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400607 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700608 public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700609
610 /**
611 * Return the available screen width that we should report for the
612 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800613 * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700614 * that to account for more transient decoration like a status bar.
615 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700616 public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700617
618 /**
619 * Return the available screen height that we should report for the
620 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800621 * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700622 * that to account for more transient decoration like a status bar.
623 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700624 public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400625
626 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700627 * Return whether the given window should forcibly hide everything
628 * behind it. Typically returns true for the keyguard.
629 */
630 public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
631
632 /**
633 * Determine if a window that is behind one that is force hiding
634 * (as determined by {@link #doesForceHide}) should actually be hidden.
635 * For example, typically returns false for the status bar. Be careful
636 * to return false for any window that you may hide yourself, since this
637 * will conflict with what you set.
638 */
639 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
640
641 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800642 * Called when the system would like to show a UI to indicate that an
643 * application is starting. You can use this to add a
644 * APPLICATION_STARTING_TYPE window with the given appToken to the window
645 * manager (using the normal window manager APIs) that will be shown until
646 * the application displays its own window. This is called without the
647 * window manager locked so that you can call back into it.
648 *
649 * @param appToken Token of the application being started.
650 * @param packageName The name of the application package being started.
651 * @param theme Resource defining the application's overall visual theme.
652 * @param nonLocalizedLabel The default title label of the application if
653 * no data is found in the resource.
654 * @param labelRes The resource ID the application would like to use as its name.
655 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800656 * @param windowFlags Window layout flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800657 *
658 * @return Optionally you can return the View that was used to create the
659 * window, for easy removal in removeStartingWindow.
660 *
661 * @see #removeStartingWindow
662 */
663 public View addStartingWindow(IBinder appToken, String packageName,
Dianne Hackborn2f0b1752011-05-31 17:59:49 -0700664 int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
Adam Powell04fe6eb2013-05-31 14:39:48 -0700665 int labelRes, int icon, int logo, int windowFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800666
667 /**
668 * Called when the first window of an application has been displayed, while
669 * {@link #addStartingWindow} has created a temporary initial window for
670 * that application. You should at this point remove the window from the
671 * window manager. This is called without the window manager locked so
672 * that you can call back into it.
673 *
674 * <p>Note: due to the nature of these functions not being called with the
675 * window manager locked, you must be prepared for this function to be
676 * called multiple times and/or an initial time with a null View window
677 * even if you previously returned one.
678 *
679 * @param appToken Token of the application that has started.
680 * @param window Window View that was returned by createStartingWindow.
681 *
682 * @see #addStartingWindow
683 */
684 public void removeStartingWindow(IBinder appToken, View window);
685
686 /**
687 * Prepare for a window being added to the window manager. You can throw an
688 * exception here to prevent the window being added, or do whatever setup
689 * you need to keep track of the window.
690 *
691 * @param win The window being added.
692 * @param attrs The window's LayoutParams.
693 *
Jeff Brown98365d72012-08-19 20:30:52 -0700694 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800695 * error code to abort the add.
696 */
697 public int prepareAddWindowLw(WindowState win,
698 WindowManager.LayoutParams attrs);
699
700 /**
701 * Called when a window is being removed from a window manager. Must not
702 * throw an exception -- clean up as much as possible.
703 *
704 * @param win The window being removed.
705 */
706 public void removeWindowLw(WindowState win);
707
708 /**
709 * Control the animation to run when a window's state changes. Return a
710 * non-0 number to force the animation to a specific resource ID, or 0
711 * to use the default animation.
712 *
713 * @param win The window that is changing.
714 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
715 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
716 * {@link #TRANSIT_HIDE}.
717 *
718 * @return Resource ID of the actual animation to use, or 0 for none.
719 */
720 public int selectAnimationLw(WindowState win, int transit);
721
722 /**
Craig Mautner3c174372013-02-21 17:54:37 -0800723 * Determine the animation to run for a rotation transition based on the
724 * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
725 * and whether it is currently fullscreen and frontmost.
726 *
727 * @param anim The exiting animation resource id is stored in anim[0], the
728 * entering animation resource id is stored in anim[1].
729 */
730 public void selectRotationAnimationLw(int anim[]);
731
732 /**
733 * Validate whether the current top fullscreen has specified the same
734 * {@link WindowManager.LayoutParams#rotationAnimation} value as that
735 * being passed in from the previous top fullscreen window.
736 *
737 * @param exitAnimId exiting resource id from the previous window.
738 * @param enterAnimId entering resource id from the previous window.
739 * @param forceDefault For rotation animations only, if true ignore the
740 * animation values and just return false.
741 * @return true if the previous values are still valid, false if they
742 * should be replaced with the default.
743 */
744 public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId,
745 boolean forceDefault);
746
747 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700748 * Create and return an animation to re-display a force hidden window.
749 */
Dianne Hackborn0c2acff2012-04-12 15:17:07 -0700750 public Animation createForceHideEnterAnimation(boolean onWallpaper);
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700751
752 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700753 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800754 *
755 * <p>There are some actions that need to be handled here because they
756 * affect the power state of the device, for example, the power keys.
757 * Generally, it's best to keep as little as possible in the queue thread
758 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -0800759 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700760 * @param policyFlags The policy flags associated with the key.
761 * @param isScreenOn True if the screen is already on
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800762 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800763 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
Craig Mautner69b08182012-09-05 13:07:13 -0700764 * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800765 */
Jeff Brown1f245102010-11-18 20:53:46 -0800766 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
Jeff Brown56194eb2011-03-02 19:23:13 -0800767
768 /**
769 * Called from the input reader thread before a motion is enqueued when the screen is off.
770 *
771 * <p>There are some actions that need to be handled here because they
772 * affect the power state of the device, for example, waking on motions.
773 * Generally, it's best to keep as little as possible in the queue thread
774 * because it's the most fragile.
775 * @param policyFlags The policy flags associated with the motion.
776 *
777 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
Craig Mautner69b08182012-09-05 13:07:13 -0700778 * {@link #ACTION_WAKE_UP} and {@link #ACTION_GO_TO_SLEEP} flags.
Jeff Brown56194eb2011-03-02 19:23:13 -0800779 */
780 public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags);
781
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800782 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700783 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800784 *
785 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -0700786 * behavior for keys that can not be overridden by applications.
787 * This method is called from the input thread, with no locks held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800788 *
789 * @param win The window that currently has focus. This is where the key
790 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800791 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700792 * @param policyFlags The policy flags associated with the key.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700793 * @return 0 if the key should be dispatched immediately, -1 if the key should
794 * not be dispatched ever, or a positive value indicating the number of
795 * milliseconds by which the key dispatch should be delayed before trying
796 * again.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800797 */
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700798 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800799
800 /**
Jeff Brown3915bb82010-11-05 15:02:16 -0700801 * Called from the input dispatcher thread when an application did not handle
802 * a key that was dispatched to it.
803 *
804 * <p>Allows you to define default global behavior for keys that were not handled
805 * by applications. This method is called from the input thread, with no locks held.
806 *
807 * @param win The window that currently has focus. This is where the key
808 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800809 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700810 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -0800811 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
812 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700813 */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800814 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -0700815
816 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800817 * Called when layout of the windows is about to start.
818 *
Craig Mautner69b08182012-09-05 13:07:13 -0700819 * @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800820 * @param displayWidth The current full width of the screen.
821 * @param displayHeight The current full height of the screen.
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700822 * @param displayRotation The current rotation being applied to the base
823 * window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800824 */
Craig Mautner69b08182012-09-05 13:07:13 -0700825 public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
826 int displayRotation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800827
828 /**
John Spurlock46646232013-09-30 22:32:42 -0400829 * Returns the bottom-most layer of the system decor, above which no policy decor should
830 * be applied.
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700831 */
John Spurlock46646232013-09-30 22:32:42 -0400832 public int getSystemDecorLayerLw();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700833
834 /**
Craig Mautner967212c2013-04-13 21:10:58 -0700835 * Return the rectangle of the screen that is available for applications to run in.
836 * This will be called immediately after {@link #beginLayoutLw}.
837 *
838 * @param r The rectangle to be filled with the boundaries available to applications.
839 */
840 public void getContentRectLw(Rect r);
841
842 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800843 * Called for each window attached to the window manager as layout is
844 * proceeding. The implementation of this function must take care of
845 * setting the window's frame, either here or in finishLayout().
846 *
847 * @param win The window being positioned.
848 * @param attrs The LayoutParams of the window.
849 * @param attached For sub-windows, the window it is attached to; this
850 * window will already have had layoutWindow() called on it
851 * so you can use its Rect. Otherwise null.
852 */
853 public void layoutWindowLw(WindowState win,
854 WindowManager.LayoutParams attrs, WindowState attached);
855
856
857 /**
858 * Return the insets for the areas covered by system windows. These values
859 * are computed on the most recent layout, so they are not guaranteed to
860 * be correct.
861 *
862 * @param attrs The LayoutParams of the window.
863 * @param contentInset The areas covered by system windows, expressed as positive insets
864 *
865 */
866 public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700867
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800868 /**
869 * Called when layout of the windows is finished. After this function has
870 * returned, all windows given to layoutWindow() <em>must</em> have had a
871 * frame assigned.
872 */
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800873 public void finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800874
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700875 /** Layout state may have changed (so another layout will be performed) */
876 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
877 /** Configuration state may have changed */
878 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
879 /** Wallpaper may need to move */
880 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800881 /** Need to recompute animations */
882 static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700883
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800884 /**
Craig Mautner39834192012-09-02 07:47:24 -0700885 * Called following layout of all windows before each window has policy applied.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800886 *
887 * @param displayWidth The current full width of the screen.
888 * @param displayHeight The current full height of the screen.
889 */
Craig Mautner39834192012-09-02 07:47:24 -0700890 public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800891
892 /**
Craig Mautner39834192012-09-02 07:47:24 -0700893 * Called following layout of all window to apply policy to each window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800894 *
895 * @param win The window being positioned.
896 * @param attrs The LayoutParams of the window.
897 */
Craig Mautner39834192012-09-02 07:47:24 -0700898 public void applyPostLayoutPolicyLw(WindowState win,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800899 WindowManager.LayoutParams attrs);
900
901 /**
Craig Mautner39834192012-09-02 07:47:24 -0700902 * Called following layout of all windows and after policy has been applied
903 * to each window. If in this function you do
904 * something that may have modified the animation state of another window,
905 * be sure to return non-zero in order to perform another pass through layout.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800906 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800907 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
908 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
909 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800910 */
Craig Mautner39834192012-09-02 07:47:24 -0700911 public int finishPostLayoutPolicyLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800912
913 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800914 * Return true if it is okay to perform animations for an app transition
915 * that is about to occur. You may return false for this if, for example,
916 * the lock screen is currently displayed so the switch should happen
917 * immediately.
918 */
919 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -0800920
921
922 /**
923 * A new window has been focused.
924 */
Dianne Hackborndf89e652011-10-06 22:35:11 -0700925 public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800926
927 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800928 * Called after the screen turns off.
929 *
930 * @param why {@link #OFF_BECAUSE_OF_USER} or
931 * {@link #OFF_BECAUSE_OF_TIMEOUT}.
932 */
933 public void screenTurnedOff(int why);
934
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700935 public interface ScreenOnListener {
936 void onScreenOn();
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800937 }
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700938
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800939 /**
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700940 * Called when the power manager would like to turn the screen on.
941 * Must call back on the listener to tell it when the higher-level system
942 * 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 -0800943 */
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700944 public void screenTurningOn(ScreenOnListener screenOnListener);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800945
946 /**
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700947 * Return whether the screen is about to turn on or is currently on.
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800948 */
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700949 public boolean isScreenOnEarly();
950
951 /**
952 * Return whether the screen is fully turned on.
953 */
954 public boolean isScreenOnFully();
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700955
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800956 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700957 * Tell the policy that the lid switch has changed state.
958 * @param whenNanos The time when the change occurred in uptime nanoseconds.
959 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800960 */
Jeff Brown46b9ac02010-04-22 18:58:52 -0700961 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
962
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800963 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800964 * Tell the policy if anyone is requesting that keyguard not come on.
965 *
966 * @param enabled Whether keyguard can be on or not. does not actually
967 * turn it on, unless it was previously disabled with this function.
968 *
969 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
970 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
971 */
Craig Mautner3c174372013-02-21 17:54:37 -0800972 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800973 public void enableKeyguard(boolean enabled);
974
975 /**
976 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
977 */
978 interface OnKeyguardExitResult {
979 void onKeyguardExitResult(boolean success);
980 }
981
982 /**
983 * Tell the policy if anyone is requesting the keyguard to exit securely
984 * (this would be called after the keyguard was disabled)
985 * @param callback Callback to send the result back.
986 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
987 */
Craig Mautner3c174372013-02-21 17:54:37 -0800988 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800989 void exitKeyguardSecurely(OnKeyguardExitResult callback);
990
991 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -0500992 * isKeyguardLocked
993 *
994 * Return whether the keyguard is currently locked.
995 *
996 * @return true if in keyguard is locked.
997 */
998 public boolean isKeyguardLocked();
999
1000 /**
1001 * isKeyguardSecure
1002 *
1003 * Return whether the keyguard requires a password to unlock.
1004 *
1005 * @return true if in keyguard is secure.
1006 */
1007 public boolean isKeyguardSecure();
1008
1009 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001010 * inKeyguardRestrictedKeyInputMode
1011 *
1012 * if keyguard screen is showing or in restricted key input mode (i.e. in
1013 * keyguard password emergency screen). When in such mode, certain keys,
1014 * such as the Home key and the right soft keys, don't work.
1015 *
1016 * @return true if in keyguard restricted input mode.
1017 */
1018 public boolean inKeyguardRestrictedKeyInputMode();
1019
1020 /**
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001021 * Ask the policy to dismiss the keyguard, if it is currently shown.
1022 */
1023 public void dismissKeyguardLw();
1024
1025 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001026 * Given an orientation constant, returns the appropriate surface rotation,
1027 * taking into account sensors, docking mode, rotation lock, and other factors.
1028 *
1029 * @param orientation An orientation constant, such as
1030 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1031 * @param lastRotation The most recently used rotation.
1032 * @return The surface rotation to use.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001033 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001034 public int rotationForOrientationLw(@ActivityInfo.ScreenOrientation int orientation,
1035 int lastRotation);
Jeff Brown01a98dd2011-09-20 15:08:29 -07001036
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001037 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001038 * Given an orientation constant and a rotation, returns true if the rotation
1039 * has compatible metrics to the requested orientation. For example, if
1040 * the application requested landscape and got seascape, then the rotation
1041 * has compatible metrics; if the application requested portrait and got landscape,
1042 * then the rotation has incompatible metrics; if the application did not specify
1043 * a preference, then anything goes.
1044 *
1045 * @param orientation An orientation constant, such as
1046 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1047 * @param rotation The rotation to check.
1048 * @return True if the rotation is compatible with the requested orientation.
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001049 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001050 public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation int orientation,
1051 int rotation);
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001052
1053 /**
Jeff Brownc0347aa2011-09-23 17:26:09 -07001054 * Called by the window manager when the rotation changes.
1055 *
1056 * @param rotation The new rotation.
1057 */
1058 public void setRotationLw(int rotation);
1059
1060 /**
Jeff Brownac143512012-04-05 18:57:33 -07001061 * Called when the system is mostly done booting to set whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001062 * the system should go into safe mode.
1063 */
Jeff Brownac143512012-04-05 18:57:33 -07001064 public void setSafeMode(boolean safeMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001065
1066 /**
1067 * Called when the system is mostly done booting.
1068 */
1069 public void systemReady();
1070
1071 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -07001072 * Called when the system is done booting to the point where the
1073 * user can start interacting with it.
1074 */
1075 public void systemBooted();
1076
1077 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001078 * Show boot time message to the user.
1079 */
1080 public void showBootMessage(final CharSequence msg, final boolean always);
1081
1082 /**
1083 * Hide the UI for showing boot messages, never to be displayed again.
1084 */
1085 public void hideBootMessages();
1086
1087 /**
Mike Lockwoodef731622010-01-27 17:51:34 -05001088 * Called when userActivity is signalled in the power manager.
1089 * This is safe to call from any thread, with any window manager locks held or not.
1090 */
1091 public void userActivity();
1092
1093 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001094 * Called when we have finished booting and can now display the home
Jeff Brownc042ee22012-05-08 13:03:42 -07001095 * screen to the user. This will happen after systemReady(), and at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001096 * this point the display is active.
1097 */
1098 public void enableScreenAfterBoot();
1099
Tor Norbyed9273d62013-05-30 15:59:53 -07001100 public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001101
1102 /**
1103 * Call from application to perform haptic feedback on its window.
1104 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001105 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001106
1107 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -04001108 * Called when we have started keeping the screen on because a window
1109 * requesting this has become visible.
1110 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001111 public void keepScreenOnStartedLw();
Daniel Sandler0601eb72011-04-13 01:01:32 -04001112
1113 /**
1114 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001115 * requesting this is no longer visible.
1116 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001117 public void keepScreenOnStoppedLw();
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001118
1119 /**
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001120 * Gets the current user rotation mode.
1121 *
1122 * @return The rotation mode.
1123 *
1124 * @see WindowManagerPolicy#USER_ROTATION_LOCKED
1125 * @see WindowManagerPolicy#USER_ROTATION_FREE
1126 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001127 @UserRotationMode
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001128 public int getUserRotationMode();
1129
1130 /**
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001131 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
1132 *
1133 * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
Craig Mautner69b08182012-09-05 13:07:13 -07001134 * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001135 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
Craig Mautner69b08182012-09-05 13:07:13 -07001136 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001137 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001138 public void setUserRotationMode(@UserRotationMode int mode, @Surface.Rotation int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001139
1140 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -07001141 * Called when a new system UI visibility is being reported, allowing
1142 * the policy to adjust what is actually reported.
Tor Norbyed9273d62013-05-30 15:59:53 -07001143 * @param visibility The raw visibility reported by the status bar.
Dianne Hackborndf89e652011-10-06 22:35:11 -07001144 * @return The new desired visibility.
1145 */
1146 public int adjustSystemUiVisibilityLw(int visibility);
1147
1148 /**
Daniel Sandler0c4ccff2011-10-19 16:39:14 -04001149 * Specifies whether there is an on-screen navigation bar separate from the status bar.
1150 */
1151 public boolean hasNavigationBar();
1152
1153 /**
Jim Miller93c518e2012-01-17 15:55:31 -08001154 * Lock the device now.
1155 */
Adam Cohenf7522022012-10-03 20:03:18 -07001156 public void lockNow(Bundle options);
Jim Miller93c518e2012-01-17 15:55:31 -08001157
1158 /**
satok1bc0a492012-04-25 22:47:12 +09001159 * Set the last used input method window state. This state is used to make IME transition
1160 * smooth.
1161 * @hide
1162 */
1163 public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1164
1165 /**
Satoshi Kataoka658c7b82013-10-10 17:03:51 +09001166 * @return The current height of the input method window.
1167 */
1168 public int getInputMethodWindowVisibleHeightLw();
1169
1170 /**
Craig Mautnerf1b67412012-09-19 13:18:29 -07001171 * Called when the current user changes. Guaranteed to be called before the broadcast
1172 * of the new user id is made to all listeners.
1173 *
1174 * @param newUserId The id of the incoming user.
1175 */
1176 public void setCurrentUserLw(int newUserId);
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -07001177
1178 /**
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001179 * Print the WindowManagerPolicy's state into the given stream.
1180 *
1181 * @param prefix Text to print at the front of each line.
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001182 * @param writer The PrintWriter to which you should dump your state. This will be
1183 * closed for you after you return.
1184 * @param args additional arguments to the dump request.
1185 */
Jeff Brownd7a04de2012-06-17 14:17:52 -07001186 public void dump(String prefix, PrintWriter writer, String[] args);
Jim Miller4eeb4f62012-11-08 00:04:29 -08001187
1188 /**
Svetoslav Ganov545252f2012-12-10 18:29:24 -08001189 * Returns whether a given window type can be magnified.
1190 *
1191 * @param windowType The window type.
1192 * @return True if the window can be magnified.
1193 */
1194 public boolean canMagnifyWindow(int windowType);
1195
1196 /**
1197 * Returns whether a given window type is considered a top level one.
1198 * A top level window does not have a container, i.e. attached window,
1199 * or if it has a container it is laid out as a top-level window, not
1200 * as a child of its container.
1201 *
1202 * @param windowType The window type.
1203 * @return True if the window is a top level one.
1204 */
1205 public boolean isTopLevelWindow(int windowType);
Alan Viverette5a0f4ec2013-10-07 15:10:29 -07001206
1207 /**
1208 * Sets the current touch exploration state.
1209 *
1210 * @param enabled Whether touch exploration is enabled.
1211 */
1212 public void setTouchExplorationEnabled(boolean enabled);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001213}