blob: 9522a1bd564263587e5d488e8860ffafd6663f8d [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.view;
18
19import android.content.Context;
Dianne Hackborn2f0b1752011-05-31 17:59:49 -070020import android.content.res.CompatibilityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.res.Configuration;
22import android.graphics.Rect;
Dianne Hackbornd040edb2011-08-31 12:47:58 -070023import android.graphics.RectF;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.os.IBinder;
25import android.os.LocalPowerManager;
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 /**
118 * This key event should extend the user activity timeout and turn the lights on.
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 */
122 public final static int ACTION_POKE_USER_ACTIVITY = 0x00000002;
123
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}.
127 * Do not return this and {@link #ACTION_POKE_USER_ACTIVITY} 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 /**
138 * Perform standard frame computation. The result can be obtained with
139 * getFrame() if so desired. Must be called with the window manager
140 * lock held.
141 *
142 * @param parentFrame The frame of the parent container this window
143 * is in, used for computing its basic position.
144 * @param displayFrame The frame of the overall display in which this
145 * window can appear, used for constraining the overall dimensions
146 * of the window.
147 * @param contentFrame The frame within the display in which we would
148 * like active content to appear. This will cause windows behind to
149 * be resized to match the given content frame.
150 * @param visibleFrame The frame within the display that the window
151 * is actually visible, used for computing its visible insets to be
152 * given to windows behind.
153 * This can be used as a hint for scrolling (avoiding resizing)
154 * the window to make certain that parts of its content
155 * are visible.
156 */
157 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700158 Rect contentFrame, Rect visibleFrame);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159
160 /**
161 * Retrieve the current frame of the window that has been assigned by
162 * the window manager. Must be called with the window manager lock held.
163 *
164 * @return Rect The rectangle holding the window frame.
165 */
166 public Rect getFrameLw();
167
168 /**
169 * Retrieve the current frame of the window that is actually shown.
170 * Must be called with the window manager lock held.
171 *
172 * @return Rect The rectangle holding the shown window frame.
173 */
Dianne Hackbornd040edb2011-08-31 12:47:58 -0700174 public RectF getShownFrameLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175
176 /**
177 * Retrieve the frame of the display that this window was last
178 * laid out in. Must be called with the
179 * window manager lock held.
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700180 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800181 * @return Rect The rectangle holding the display frame.
182 */
183 public Rect getDisplayFrameLw();
184
185 /**
186 * Retrieve the frame of the content area that this window was last
187 * laid out in. This is the area in which the content of the window
188 * should be placed. It will be smaller than the display frame to
189 * account for screen decorations such as a status bar or soft
190 * keyboard. Must be called with the
191 * window manager lock held.
192 *
193 * @return Rect The rectangle holding the content frame.
194 */
195 public Rect getContentFrameLw();
196
197 /**
198 * Retrieve the frame of the visible area that this window was last
199 * laid out in. This is the area of the screen in which the window
200 * will actually be fully visible. It will be smaller than the
201 * content frame to account for transient UI elements blocking it
202 * such as an input method's candidates UI. Must be called with the
203 * window manager lock held.
204 *
205 * @return Rect The rectangle holding the visible frame.
206 */
207 public Rect getVisibleFrameLw();
208
209 /**
210 * Returns true if this window is waiting to receive its given
211 * internal insets from the client app, and so should not impact the
212 * layout of other windows.
213 */
214 public boolean getGivenInsetsPendingLw();
215
216 /**
217 * Retrieve the insets given by this window's client for the content
218 * area of windows behind it. Must be called with the
219 * window manager lock held.
220 *
221 * @return Rect The left, top, right, and bottom insets, relative
222 * to the window's frame, of the actual contents.
223 */
224 public Rect getGivenContentInsetsLw();
225
226 /**
227 * Retrieve the insets given by this window's client for the visible
228 * area of windows behind it. Must be called with the
229 * window manager lock held.
230 *
231 * @return Rect The left, top, right, and bottom insets, relative
232 * to the window's frame, of the actual visible area.
233 */
234 public Rect getGivenVisibleInsetsLw();
235
236 /**
237 * Retrieve the current LayoutParams of the window.
238 *
239 * @return WindowManager.LayoutParams The window's internal LayoutParams
240 * instance.
241 */
242 public WindowManager.LayoutParams getAttrs();
243
244 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800245 * Return whether this window needs the menu key shown. Must be called
246 * with window lock held, because it may need to traverse down through
247 * window list to determine the result.
248 * @param bottom The bottom-most window to consider when determining this.
249 */
250 public boolean getNeedsMenuLw(WindowState bottom);
251
252 /**
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700253 * Retrieve the current system UI visibility flags associated with
254 * this window.
255 */
256 public int getSystemUiVisibility();
257
258 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 * Get the layer at which this window's surface will be Z-ordered.
260 */
261 public int getSurfaceLayer();
262
263 /**
264 * Return the token for the application (actually activity) that owns
265 * this window. May return null for system windows.
266 *
267 * @return An IApplicationToken identifying the owning activity.
268 */
269 public IApplicationToken getAppToken();
270
271 /**
272 * Return true if, at any point, the application token associated with
273 * this window has actually displayed any windows. This is most useful
274 * with the "starting up" window to determine if any windows were
275 * displayed when it is closed.
276 *
277 * @return Returns true if one or more windows have been displayed,
278 * else false.
279 */
280 public boolean hasAppShownWindows();
281
282 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800283 * Is this window visible? It is not visible if there is no
284 * surface, or we are in the process of running an exit animation
285 * that will remove the surface.
286 */
287 boolean isVisibleLw();
288
289 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700290 * Like {@link #isVisibleLw}, but also counts a window that is currently
291 * "hidden" behind the keyguard as visible. This allows us to apply
292 * things like window flags that impact the keyguard.
293 */
294 boolean isVisibleOrBehindKeyguardLw();
295
296 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800297 * Is this window currently visible to the user on-screen? It is
298 * displayed either if it is visible or it is currently running an
299 * animation before no longer being visible. Must be called with the
300 * window manager lock held.
301 */
302 boolean isDisplayedLw();
303
304 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700305 * Return true if this window (or a window it is attached to, but not
306 * considering its app token) is currently animating.
307 */
308 public boolean isAnimatingLw();
309
310 /**
Dianne Hackborn01b02a72012-01-12 14:05:03 -0800311 * Is this window considered to be gone for purposes of layout?
312 */
313 boolean isGoneForLayoutLw();
314
315 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800316 * Returns true if this window has been shown on screen at some time in
317 * the past. Must be called with the window manager lock held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800318 */
319 public boolean hasDrawnLw();
320
321 /**
322 * Can be called by the policy to force a window to be hidden,
323 * regardless of whether the client or window manager would like
324 * it shown. Must be called with the window manager lock held.
325 * Returns true if {@link #showLw} was last called for the window.
326 */
327 public boolean hideLw(boolean doAnimation);
328
329 /**
330 * Can be called to undo the effect of {@link #hideLw}, allowing a
331 * window to be shown as long as the window manager and client would
332 * also like it to be shown. Must be called with the window manager
333 * lock held.
334 * Returns true if {@link #hideLw} was last called for the window.
335 */
336 public boolean showLw(boolean doAnimation);
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700337
338 /**
339 * Check whether the process hosting this window is currently alive.
340 */
341 public boolean isAlive();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 }
343
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700344 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700345 * Representation of a "fake window" that the policy has added to the
346 * window manager to consume events.
347 */
348 public interface FakeWindow {
349 /**
350 * Remove the fake window from the window manager.
351 */
352 void dismiss();
353 }
354
355 /**
356 * Interface for calling back in to the window manager that is private
357 * between it and the policy.
358 */
359 public interface WindowManagerFuncs {
Jeff Brownac143512012-04-05 18:57:33 -0700360 public static final int LID_ABSENT = -1;
361 public static final int LID_CLOSED = 0;
362 public static final int LID_OPEN = 1;
363
Dianne Hackborndf89e652011-10-06 22:35:11 -0700364 /**
365 * Ask the window manager to re-evaluate the system UI flags.
366 */
367 public void reevaluateStatusBarVisibility();
368
369 /**
370 * Add a fake window to the window manager. This window sits
371 * at the top of the other windows and consumes events.
372 */
Jeff Brown32cbc38552011-12-01 14:01:49 -0800373 public FakeWindow addFakeWindow(Looper looper,
374 InputEventReceiver.Factory inputEventReceiverFactory,
Dianne Hackborndf89e652011-10-06 22:35:11 -0700375 String name, int windowType, int layoutParamsFlags, boolean canReceiveKeys,
376 boolean hasFocus, boolean touchFullscreen);
Jeff Brownac143512012-04-05 18:57:33 -0700377
378 /**
379 * Returns a code that describes the current state of the lid switch.
380 */
381 public int getLidState();
382
383 /**
384 * Creates an input channel that will receive all input from the input dispatcher.
385 */
386 public InputChannel monitorInput(String name);
Jeff Brown7304c342012-05-11 18:42:42 -0700387
Jeff Browncf39bdf2012-05-18 14:41:19 -0700388 /**
389 * Switch the keyboard layout for the given device.
390 * Direction should be +1 or -1 to go to the next or previous keyboard layout.
391 */
392 public void switchKeyboardLayout(int deviceId, int direction);
393
Jeff Brown7304c342012-05-11 18:42:42 -0700394 public void shutdown();
395 public void rebootSafeMode();
Dianne Hackborndf89e652011-10-06 22:35:11 -0700396 }
397
398 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700399 * Bit mask that is set for all enter transition.
400 */
401 public final int TRANSIT_ENTER_MASK = 0x1000;
402
403 /**
404 * Bit mask that is set for all exit transitions.
405 */
406 public final int TRANSIT_EXIT_MASK = 0x2000;
407
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700408 /** Not set up for a transition. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700409 public final int TRANSIT_UNSET = -1;
Dianne Hackbornbfe319e2009-09-21 00:34:05 -0700410 /** No animation for transition. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800411 public final int TRANSIT_NONE = 0;
412 /** Window has been added to the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700413 public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414 /** Window has been removed from the screen. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700415 public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800416 /** Window has been made visible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700417 public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800418 /** Window has been made invisible. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700419 public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800420 /** The "application starting" preview window is no longer needed, and will
421 * animate away to show the real window. */
422 public final int TRANSIT_PREVIEW_DONE = 5;
423 /** A window in a new activity is being opened on top of an existing one
424 * in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700425 public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800426 /** The window in the top-most activity is being closed to reveal the
427 * previous activity in the same task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700428 public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800429 /** A window in a new task is being opened on top of an existing one
430 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700431 public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800432 /** A window in the top-most activity is being closed to reveal the
433 * previous activity in a different task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700434 public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800435 /** A window in an existing task is being displayed on top of an existing one
436 * in another activity's task. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700437 public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 /** A window in an existing task is being put below all other tasks. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700439 public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700440 /** A window in a new activity that doesn't have a wallpaper is being
441 * opened on top of one that does, effectively closing the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700442 public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK;
Dianne Hackborn25994b42009-09-04 14:21:19 -0700443 /** A window in a new activity that does have a wallpaper is being
444 * opened on one that didn't, effectively opening the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700445 public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700446 /** A window in a new activity is being opened on top of an existing one,
447 * and both are on top of the wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700448 public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK;
Dianne Hackbornf8fbdb62009-08-19 12:39:43 -0700449 /** The window in the top-most activity is being closed to reveal the
450 * previous activity, and both are on top of he wallpaper. */
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700451 public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800452
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.
476 * @param powerManager
477 */
478 public void init(Context context, IWindowManager windowManager,
Dianne Hackborndf89e652011-10-06 22:35:11 -0700479 WindowManagerFuncs windowManagerFuncs,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800480 LocalPowerManager powerManager);
481
482 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700483 * Called by window manager once it has the initial, default native
484 * display dimensions.
485 */
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700486 public void setInitialDisplaySize(Display display, int width, int height);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700487
Dianne Hackborn9d132642011-04-21 17:26:39 -0700488 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800489 * Check permissions when adding a window.
490 *
491 * @param attrs The window's LayoutParams.
492 *
493 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed;
494 * else an error code, usually
495 * {@link WindowManagerImpl#ADD_PERMISSION_DENIED}, to abort the add.
496 */
497 public int checkAddPermission(WindowManager.LayoutParams attrs);
498
499 /**
500 * Sanitize the layout parameters coming from a client. Allows the policy
501 * to do things like ensure that windows of a specific type can't take
502 * input focus.
503 *
504 * @param attrs The window layout parameters to be modified. These values
505 * are modified in-place.
506 */
507 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
508
509 /**
510 * After the window manager has computed the current configuration based
511 * on its knowledge of the display and input devices, it gives the policy
512 * a chance to adjust the information contained in it. If you want to
513 * leave it as-is, simply do nothing.
514 *
515 * <p>This method may be called by any thread in the window manager, but
516 * no internal locks in the window manager will be held.
517 *
518 * @param config The Configuration being computed, for you to change as
519 * desired.
Jeff Browndaa37532012-05-01 15:54:03 -0700520 * @param keyboardPresence Flags that indicate whether internal or external
521 * keyboards are present.
522 * @param navigationPresence Flags that indicate whether internal or external
523 * navigation devices are present.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800524 */
Jeff Browndaa37532012-05-01 15:54:03 -0700525 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
526 int navigationPresence);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800527
528 /**
529 * Assign a window type to a layer. Allows you to control how different
530 * kinds of windows are ordered on-screen.
531 *
532 * @param type The type of window being assigned.
533 *
534 * @return int An arbitrary integer used to order windows, with lower
535 * numbers below higher ones.
536 */
537 public int windowTypeToLayerLw(int type);
538
539 /**
540 * Return how to Z-order sub-windows in relation to the window they are
541 * attached to. Return positive to have them ordered in front, negative for
542 * behind.
543 *
544 * @param type The sub-window type code.
545 *
546 * @return int Layer in relation to the attached window, where positive is
547 * above and negative is below.
548 */
549 public int subWindowTypeToLayerLw(int type);
550
551 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700552 * Get the highest layer (actually one more than) that the wallpaper is
553 * allowed to be in.
554 */
555 public int getMaxWallpaperLayer();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700556
557 /**
558 * Return the window layer at which windows appear above the normal
559 * universe (that is no longer impacted by the universe background
560 * transform).
561 */
562 public int getAboveUniverseLayer();
563
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700564 /**
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700565 * Return true if the policy desires a full unified system nav bar. Otherwise,
566 * it is a phone-style status bar with optional nav bar.
Dianne Hackborn81e56d52011-05-26 00:55:58 -0700567 */
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700568 public boolean hasSystemNavBar();
Dianne Hackborn81e56d52011-05-26 00:55:58 -0700569
570 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700571 * Return the display width available after excluding any screen
572 * decorations that can never be removed. That is, system bar or
573 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400574 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700575 public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400576
577 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700578 * Return the display height available after excluding any screen
579 * decorations that can never be removed. That is, system bar or
580 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400581 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700582 public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700583
584 /**
585 * Return the available screen width that we should report for the
586 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800587 * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700588 * that to account for more transient decoration like a status bar.
589 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700590 public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700591
592 /**
593 * Return the available screen height that we should report for the
594 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800595 * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700596 * that to account for more transient decoration like a status bar.
597 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700598 public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400599
600 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700601 * Return whether the given window should forcibly hide everything
602 * behind it. Typically returns true for the keyguard.
603 */
604 public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs);
605
606 /**
607 * Determine if a window that is behind one that is force hiding
608 * (as determined by {@link #doesForceHide}) should actually be hidden.
609 * For example, typically returns false for the status bar. Be careful
610 * to return false for any window that you may hide yourself, since this
611 * will conflict with what you set.
612 */
613 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
614
615 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616 * Called when the system would like to show a UI to indicate that an
617 * application is starting. You can use this to add a
618 * APPLICATION_STARTING_TYPE window with the given appToken to the window
619 * manager (using the normal window manager APIs) that will be shown until
620 * the application displays its own window. This is called without the
621 * window manager locked so that you can call back into it.
622 *
623 * @param appToken Token of the application being started.
624 * @param packageName The name of the application package being started.
625 * @param theme Resource defining the application's overall visual theme.
626 * @param nonLocalizedLabel The default title label of the application if
627 * no data is found in the resource.
628 * @param labelRes The resource ID the application would like to use as its name.
629 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800630 * @param windowFlags Window layout flags.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800631 *
632 * @return Optionally you can return the View that was used to create the
633 * window, for easy removal in removeStartingWindow.
634 *
635 * @see #removeStartingWindow
636 */
637 public View addStartingWindow(IBinder appToken, String packageName,
Dianne Hackborn2f0b1752011-05-31 17:59:49 -0700638 int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800639 int labelRes, int icon, int windowFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800640
641 /**
642 * Called when the first window of an application has been displayed, while
643 * {@link #addStartingWindow} has created a temporary initial window for
644 * that application. You should at this point remove the window from the
645 * window manager. This is called without the window manager locked so
646 * that you can call back into it.
647 *
648 * <p>Note: due to the nature of these functions not being called with the
649 * window manager locked, you must be prepared for this function to be
650 * called multiple times and/or an initial time with a null View window
651 * even if you previously returned one.
652 *
653 * @param appToken Token of the application that has started.
654 * @param window Window View that was returned by createStartingWindow.
655 *
656 * @see #addStartingWindow
657 */
658 public void removeStartingWindow(IBinder appToken, View window);
659
660 /**
661 * Prepare for a window being added to the window manager. You can throw an
662 * exception here to prevent the window being added, or do whatever setup
663 * you need to keep track of the window.
664 *
665 * @param win The window being added.
666 * @param attrs The window's LayoutParams.
667 *
668 * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed, else an
669 * error code to abort the add.
670 */
671 public int prepareAddWindowLw(WindowState win,
672 WindowManager.LayoutParams attrs);
673
674 /**
675 * Called when a window is being removed from a window manager. Must not
676 * throw an exception -- clean up as much as possible.
677 *
678 * @param win The window being removed.
679 */
680 public void removeWindowLw(WindowState win);
681
682 /**
683 * Control the animation to run when a window's state changes. Return a
684 * non-0 number to force the animation to a specific resource ID, or 0
685 * to use the default animation.
686 *
687 * @param win The window that is changing.
688 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
689 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
690 * {@link #TRANSIT_HIDE}.
691 *
692 * @return Resource ID of the actual animation to use, or 0 for none.
693 */
694 public int selectAnimationLw(WindowState win, int transit);
695
696 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700697 * Create and return an animation to re-display a force hidden window.
698 */
Dianne Hackborn0c2acff2012-04-12 15:17:07 -0700699 public Animation createForceHideEnterAnimation(boolean onWallpaper);
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700700
701 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700702 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800703 *
704 * <p>There are some actions that need to be handled here because they
705 * affect the power state of the device, for example, the power keys.
706 * Generally, it's best to keep as little as possible in the queue thread
707 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -0800708 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700709 * @param policyFlags The policy flags associated with the key.
710 * @param isScreenOn True if the screen is already on
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800711 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800712 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
713 * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
714 */
Jeff Brown1f245102010-11-18 20:53:46 -0800715 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn);
Jeff Brown56194eb2011-03-02 19:23:13 -0800716
717 /**
718 * Called from the input reader thread before a motion is enqueued when the screen is off.
719 *
720 * <p>There are some actions that need to be handled here because they
721 * affect the power state of the device, for example, waking on motions.
722 * Generally, it's best to keep as little as possible in the queue thread
723 * because it's the most fragile.
724 * @param policyFlags The policy flags associated with the motion.
725 *
726 * @return The bitwise or of the {@link #ACTION_PASS_TO_USER},
727 * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags.
728 */
729 public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags);
730
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800731 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700732 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800733 *
734 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -0700735 * behavior for keys that can not be overridden by applications.
736 * This method is called from the input thread, with no locks held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800737 *
738 * @param win The window that currently has focus. This is where the key
739 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800740 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700741 * @param policyFlags The policy flags associated with the key.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700742 * @return 0 if the key should be dispatched immediately, -1 if the key should
743 * not be dispatched ever, or a positive value indicating the number of
744 * milliseconds by which the key dispatch should be delayed before trying
745 * again.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800746 */
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700747 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800748
749 /**
Jeff Brown3915bb82010-11-05 15:02:16 -0700750 * Called from the input dispatcher thread when an application did not handle
751 * a key that was dispatched to it.
752 *
753 * <p>Allows you to define default global behavior for keys that were not handled
754 * by applications. This method is called from the input thread, with no locks held.
755 *
756 * @param win The window that currently has focus. This is where the key
757 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800758 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700759 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -0800760 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
761 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700762 */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800763 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -0700764
765 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800766 * Called when layout of the windows is about to start.
767 *
768 * @param displayWidth The current full width of the screen.
769 * @param displayHeight The current full height of the screen.
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700770 * @param displayRotation The current rotation being applied to the base
771 * window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800772 */
Dianne Hackborn1f903c32011-09-13 19:18:06 -0700773 public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800774
775 /**
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700776 * Return the rectangle of the screen currently covered by system decorations.
777 * This will be called immediately after {@link #layoutWindowLw}. It can
778 * fill in the rectangle to indicate any part of the screen that it knows
779 * for sure is covered by system decor such as the status bar. The rectangle
780 * is initially set to the actual size of the screen, indicating nothing is
781 * covered.
782 *
783 * @param systemRect The rectangle of the screen that is not covered by
784 * system decoration.
785 * @return Returns the layer above which the system rectangle should
786 * not be applied.
787 */
788 public int getSystemDecorRectLw(Rect systemRect);
789
790 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800791 * Called for each window attached to the window manager as layout is
792 * proceeding. The implementation of this function must take care of
793 * setting the window's frame, either here or in finishLayout().
794 *
795 * @param win The window being positioned.
796 * @param attrs The LayoutParams of the window.
797 * @param attached For sub-windows, the window it is attached to; this
798 * window will already have had layoutWindow() called on it
799 * so you can use its Rect. Otherwise null.
800 */
801 public void layoutWindowLw(WindowState win,
802 WindowManager.LayoutParams attrs, WindowState attached);
803
804
805 /**
806 * Return the insets for the areas covered by system windows. These values
807 * are computed on the most recent layout, so they are not guaranteed to
808 * be correct.
809 *
810 * @param attrs The LayoutParams of the window.
811 * @param contentInset The areas covered by system windows, expressed as positive insets
812 *
813 */
814 public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset);
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700815
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800816 /**
817 * Called when layout of the windows is finished. After this function has
818 * returned, all windows given to layoutWindow() <em>must</em> have had a
819 * frame assigned.
820 */
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800821 public void finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800822
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700823 /** Layout state may have changed (so another layout will be performed) */
824 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
825 /** Configuration state may have changed */
826 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
827 /** Wallpaper may need to move */
828 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800829 /** Need to recompute animations */
830 static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700831
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800832 /**
833 * Called when animation of the windows is about to start.
834 *
835 * @param displayWidth The current full width of the screen.
836 * @param displayHeight The current full height of the screen.
837 */
838 public void beginAnimationLw(int displayWidth, int displayHeight);
839
840 /**
841 * Called each time a window is animating.
842 *
843 * @param win The window being positioned.
844 * @param attrs The LayoutParams of the window.
845 */
846 public void animatingWindowLw(WindowState win,
847 WindowManager.LayoutParams attrs);
848
849 /**
850 * Called when animation of the windows is finished. If in this function you do
851 * something that may have modified the animation state of another window,
852 * be sure to return true in order to perform another animation frame.
853 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800854 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
855 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
856 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800857 */
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800858 public int finishAnimationLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800859
860 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800861 * Return true if it is okay to perform animations for an app transition
862 * that is about to occur. You may return false for this if, for example,
863 * the lock screen is currently displayed so the switch should happen
864 * immediately.
865 */
866 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -0800867
868
869 /**
870 * A new window has been focused.
871 */
Dianne Hackborndf89e652011-10-06 22:35:11 -0700872 public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800873
874 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800875 * Called after the screen turns off.
876 *
877 * @param why {@link #OFF_BECAUSE_OF_USER} or
878 * {@link #OFF_BECAUSE_OF_TIMEOUT}.
879 */
880 public void screenTurnedOff(int why);
881
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700882 public interface ScreenOnListener {
883 void onScreenOn();
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800884 }
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700885
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800886 /**
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700887 * Called when the power manager would like to turn the screen on.
888 * Must call back on the listener to tell it when the higher-level system
889 * 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 -0800890 */
Dianne Hackborn38e29a62011-09-18 14:43:08 -0700891 public void screenTurningOn(ScreenOnListener screenOnListener);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800892
893 /**
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700894 * Return whether the screen is about to turn on or is currently on.
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800895 */
Dianne Hackbornbc1aa7b2011-09-20 11:20:31 -0700896 public boolean isScreenOnEarly();
897
898 /**
899 * Return whether the screen is fully turned on.
900 */
901 public boolean isScreenOnFully();
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700902
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800903 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700904 * Tell the policy that the lid switch has changed state.
905 * @param whenNanos The time when the change occurred in uptime nanoseconds.
906 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800907 */
Jeff Brown46b9ac02010-04-22 18:58:52 -0700908 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
909
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800910 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800911 * Tell the policy if anyone is requesting that keyguard not come on.
912 *
913 * @param enabled Whether keyguard can be on or not. does not actually
914 * turn it on, unless it was previously disabled with this function.
915 *
916 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
917 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
918 */
919 public void enableKeyguard(boolean enabled);
920
921 /**
922 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
923 */
924 interface OnKeyguardExitResult {
925 void onKeyguardExitResult(boolean success);
926 }
927
928 /**
929 * Tell the policy if anyone is requesting the keyguard to exit securely
930 * (this would be called after the keyguard was disabled)
931 * @param callback Callback to send the result back.
932 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
933 */
934 void exitKeyguardSecurely(OnKeyguardExitResult callback);
935
936 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -0500937 * isKeyguardLocked
938 *
939 * Return whether the keyguard is currently locked.
940 *
941 * @return true if in keyguard is locked.
942 */
943 public boolean isKeyguardLocked();
944
945 /**
946 * isKeyguardSecure
947 *
948 * Return whether the keyguard requires a password to unlock.
949 *
950 * @return true if in keyguard is secure.
951 */
952 public boolean isKeyguardSecure();
953
954 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800955 * inKeyguardRestrictedKeyInputMode
956 *
957 * if keyguard screen is showing or in restricted key input mode (i.e. in
958 * keyguard password emergency screen). When in such mode, certain keys,
959 * such as the Home key and the right soft keys, don't work.
960 *
961 * @return true if in keyguard restricted input mode.
962 */
963 public boolean inKeyguardRestrictedKeyInputMode();
964
965 /**
Dianne Hackborn90c52de2011-09-23 12:57:44 -0700966 * Ask the policy to dismiss the keyguard, if it is currently shown.
967 */
968 public void dismissKeyguardLw();
969
970 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -0700971 * Given an orientation constant, returns the appropriate surface rotation,
972 * taking into account sensors, docking mode, rotation lock, and other factors.
973 *
974 * @param orientation An orientation constant, such as
975 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
976 * @param lastRotation The most recently used rotation.
977 * @return The surface rotation to use.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800978 */
Jeff Brown01a98dd2011-09-20 15:08:29 -0700979 public int rotationForOrientationLw(int orientation, int lastRotation);
980
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800981 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -0700982 * Given an orientation constant and a rotation, returns true if the rotation
983 * has compatible metrics to the requested orientation. For example, if
984 * the application requested landscape and got seascape, then the rotation
985 * has compatible metrics; if the application requested portrait and got landscape,
986 * then the rotation has incompatible metrics; if the application did not specify
987 * a preference, then anything goes.
988 *
989 * @param orientation An orientation constant, such as
990 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
991 * @param rotation The rotation to check.
992 * @return True if the rotation is compatible with the requested orientation.
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700993 */
Jeff Brown01a98dd2011-09-20 15:08:29 -0700994 public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700995
996 /**
Jeff Brownc0347aa2011-09-23 17:26:09 -0700997 * Called by the window manager when the rotation changes.
998 *
999 * @param rotation The new rotation.
1000 */
1001 public void setRotationLw(int rotation);
1002
1003 /**
Jeff Brownac143512012-04-05 18:57:33 -07001004 * Called when the system is mostly done booting to set whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001005 * the system should go into safe mode.
1006 */
Jeff Brownac143512012-04-05 18:57:33 -07001007 public void setSafeMode(boolean safeMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001008
1009 /**
1010 * Called when the system is mostly done booting.
1011 */
1012 public void systemReady();
1013
1014 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -07001015 * Called when the system is done booting to the point where the
1016 * user can start interacting with it.
1017 */
1018 public void systemBooted();
1019
1020 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001021 * Show boot time message to the user.
1022 */
1023 public void showBootMessage(final CharSequence msg, final boolean always);
1024
1025 /**
1026 * Hide the UI for showing boot messages, never to be displayed again.
1027 */
1028 public void hideBootMessages();
1029
1030 /**
Mike Lockwoodef731622010-01-27 17:51:34 -05001031 * Called when userActivity is signalled in the power manager.
1032 * This is safe to call from any thread, with any window manager locks held or not.
1033 */
1034 public void userActivity();
1035
1036 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001037 * Called when we have finished booting and can now display the home
Jeff Brownc042ee22012-05-08 13:03:42 -07001038 * screen to the user. This will happen after systemReady(), and at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001039 * this point the display is active.
1040 */
1041 public void enableScreenAfterBoot();
1042
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001043 public void setCurrentOrientationLw(int newOrientation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001044
1045 /**
1046 * Call from application to perform haptic feedback on its window.
1047 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001048 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001049
1050 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -04001051 * Called when we have started keeping the screen on because a window
1052 * requesting this has become visible.
1053 */
1054 public void screenOnStartedLw();
1055
1056 /**
1057 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001058 * requesting this is no longer visible.
1059 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001060 public void screenOnStoppedLw();
Mike Lockwood3d0ea722009-10-21 22:58:29 -04001061
1062 /**
1063 * Return false to disable key repeat events from being generated.
1064 */
1065 public boolean allowKeyRepeat();
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001066
1067 /**
1068 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
1069 *
1070 * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
1071 * {@link * WindowManagerPolicy#USER_ROTATION_FREE}.
1072 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
1073 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
1074 */
1075 public void setUserRotationMode(int mode, int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001076
1077 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -07001078 * Called when a new system UI visibility is being reported, allowing
1079 * the policy to adjust what is actually reported.
1080 * @param visibility The raw visiblity reported by the status bar.
1081 * @return The new desired visibility.
1082 */
1083 public int adjustSystemUiVisibilityLw(int visibility);
1084
1085 /**
Daniel Sandler0c4ccff2011-10-19 16:39:14 -04001086 * Specifies whether there is an on-screen navigation bar separate from the status bar.
1087 */
1088 public boolean hasNavigationBar();
1089
1090 /**
Jim Miller93c518e2012-01-17 15:55:31 -08001091 * Lock the device now.
1092 */
1093 public void lockNow();
1094
1095 /**
Daniel Sandler7d276c32012-01-30 14:33:52 -05001096 * Check to see if a screensaver should be run instead of powering off the screen on timeout.
1097 *
1098 * @return true if the screensaver should run, false if the screen should turn off.
1099 *
1100 * @hide
1101 */
1102 public boolean isScreenSaverEnabled();
1103
1104 /**
1105 * Start the screensaver (if it is enabled and not yet running).
1106 *
1107 * @return Whether the screensaver was successfully started.
1108 *
1109 * @hide
1110 */
1111 public boolean startScreenSaver();
1112
1113 /**
1114 * Stop the screensaver if it is running.
1115 *
1116 * @hide
1117 */
1118 public void stopScreenSaver();
1119
1120 /**
satok1bc0a492012-04-25 22:47:12 +09001121 * Set the last used input method window state. This state is used to make IME transition
1122 * smooth.
1123 * @hide
1124 */
1125 public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1126
1127 /**
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001128 * Print the WindowManagerPolicy's state into the given stream.
1129 *
1130 * @param prefix Text to print at the front of each line.
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001131 * @param writer The PrintWriter to which you should dump your state. This will be
1132 * closed for you after you return.
1133 * @param args additional arguments to the dump request.
1134 */
Jeff Brownd7a04de2012-06-17 14:17:52 -07001135 public void dump(String prefix, PrintWriter writer, String[] args);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001136}