blob: b011414bc5561b447acbb5df0222ab54dc274866 [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;
Bryce Lee01b0c5f2015-02-05 18:24:04 -080020import android.annotation.SystemApi;
Jorim Jaggi86905582016-02-09 21:36:09 -080021import android.app.ActivityManager.StackId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.content.Context;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.content.pm.ActivityInfo;
Dianne Hackborn2f0b1752011-05-31 17:59:49 -070024import android.content.res.CompatibilityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.content.res.Configuration;
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -070026import android.graphics.Point;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.graphics.Rect;
Dianne Hackbornd040edb2011-08-31 12:47:58 -070028import android.graphics.RectF;
Adam Cohenf7522022012-10-03 20:03:18 -070029import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.os.IBinder;
Dianne Hackborndf89e652011-10-06 22:35:11 -070031import android.os.Looper;
Muyuan Li94ce94e2016-02-24 16:20:54 -080032import android.os.RemoteException;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.view.animation.Animation;
Muyuan Li94ce94e2016-02-24 16:20:54 -080034import com.android.internal.policy.IShortcutService;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080036import java.io.PrintWriter;
Tor Norbyed9273d62013-05-30 15:59:53 -070037import java.lang.annotation.Retention;
38import java.lang.annotation.RetentionPolicy;
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080039
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040/**
41 * This interface supplies all UI-specific behavior of the window manager. An
42 * instance of it is created by the window manager when it starts up, and allows
43 * customization of window layering, special window types, key dispatching, and
44 * layout.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -070045 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046 * <p>Because this provides deep interaction with the system window manager,
47 * specific methods on this interface can be called from a variety of contexts
48 * with various restrictions on what they can do. These are encoded through
49 * a suffixes at the end of a method encoding the thread the method is called
50 * from and any locks that are held when it is being called; if no suffix
51 * is attached to a method, then it is not called with any locks and may be
52 * called from the main window manager thread or another thread calling into
53 * the window manager.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -070054 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 * <p>The current suffixes are:
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -070056 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 * <dl>
58 * <dt> Ti <dd> Called from the input thread. This is the thread that
59 * collects pending input events and dispatches them to the appropriate window.
60 * It may block waiting for events to be processed, so that the input stream is
61 * properly serialized.
62 * <dt> Tq <dd> Called from the low-level input queue thread. This is the
63 * thread that reads events out of the raw input devices and places them
64 * into the global input queue that is read by the <var>Ti</var> thread.
65 * This thread should not block for a long period of time on anything but the
66 * key driver.
67 * <dt> Lw <dd> Called with the main window manager lock held. Because the
68 * window manager is a very low-level system service, there are few other
69 * system services you can call with this lock held. It is explicitly okay to
70 * make calls into the package manager and power manager; it is explicitly not
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -070071 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 * {@link android.content.Context#checkPermission(String, int, int)} and
73 * variations require calling into the activity manager.
74 * <dt> Li <dd> Called with the input thread lock held. This lock can be
75 * acquired by the window manager while it holds the window lock, so this is
76 * even more restrictive than <var>Lw</var>.
77 * </dl>
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -070078 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080079 * @hide
80 */
81public interface WindowManagerPolicy {
Jeff Brownb6997262010-10-08 22:31:17 -070082 // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080083 public final static int FLAG_WAKE = 0x00000001;
Michael Wright337d9d22014-04-22 15:03:48 -070084 public final static int FLAG_VIRTUAL = 0x00000002;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080085
Jeff Brown85a31762010-09-01 17:01:00 -070086 public final static int FLAG_INJECTED = 0x01000000;
Jeff Browne20c9e02010-10-11 14:20:19 -070087 public final static int FLAG_TRUSTED = 0x02000000;
Jeff Brown0029c662011-03-30 02:25:18 -070088 public final static int FLAG_FILTERED = 0x04000000;
89 public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000;
Jeff Brown85a31762010-09-01 17:01:00 -070090
Jeff Brown037c33e2014-04-09 00:31:55 -070091 public final static int FLAG_INTERACTIVE = 0x20000000;
Jeff Brownb6997262010-10-08 22:31:17 -070092 public final static int FLAG_PASS_TO_USER = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093
Jeff Browndaa37532012-05-01 15:54:03 -070094 // Flags used for indicating whether the internal and/or external input devices
95 // of some type are available.
96 public final static int PRESENCE_INTERNAL = 1 << 0;
97 public final static int PRESENCE_EXTERNAL = 1 << 1;
98
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 public final static boolean WATCH_POINTER = false;
100
Dianne Hackbornad7fa7f2011-01-07 14:06:50 -0800101 /**
102 * Sticky broadcast of the current HDMI plugged state.
103 */
104 public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED";
105
106 /**
107 * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if
108 * plugged in to HDMI, false if not.
109 */
110 public final static String EXTRA_HDMI_PLUGGED_STATE = "state";
111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800112 /**
Bryce Lee01b0c5f2015-02-05 18:24:04 -0800113 * Set to {@code true} when intent was invoked from pressing the home key.
114 * @hide
115 */
116 @SystemApi
117 public static final String EXTRA_FROM_HOME_KEY = "android.intent.extra.FROM_HOME_KEY";
118
119 /**
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700120 * Pass this event to the user / app. To be returned from
121 * {@link #interceptKeyBeforeQueueing}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800122 */
123 public final static int ACTION_PASS_TO_USER = 0x00000001;
124
125 /**
Muyuan Li94ce94e2016-02-24 16:20:54 -0800126 * Register shortcuts for window manager to dispatch.
127 * Shortcut code is packed as (metaState << Integer.SIZE) | keyCode
128 * @hide
129 */
130 void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
131 throws RemoteException;
132
133 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 * Interface to the Window Manager state associated with a particular
135 * window. You can hold on to an instance of this interface from the call
136 * to prepareAddWindow() until removeWindow().
137 */
138 public interface WindowState {
139 /**
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800140 * Return the uid of the app that owns this window.
141 */
142 int getOwningUid();
143
144 /**
145 * Return the package name of the app that owns this window.
146 */
147 String getOwningPackage();
148
149 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150 * Perform standard frame computation. The result can be obtained with
151 * getFrame() if so desired. Must be called with the window manager
152 * lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700153 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154 * @param parentFrame The frame of the parent container this window
155 * is in, used for computing its basic position.
156 * @param displayFrame The frame of the overall display in which this
157 * window can appear, used for constraining the overall dimensions
158 * of the window.
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800159 * @param overlayFrame The frame within the display that is inside
160 * of the overlay region.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800161 * @param contentFrame The frame within the display in which we would
162 * like active content to appear. This will cause windows behind to
163 * be resized to match the given content frame.
164 * @param visibleFrame The frame within the display that the window
165 * is actually visible, used for computing its visible insets to be
166 * given to windows behind.
167 * This can be used as a hint for scrolling (avoiding resizing)
168 * the window to make certain that parts of its content
169 * are visible.
John Spurlock46646232013-09-30 22:32:42 -0400170 * @param decorFrame The decor frame specified by policy specific to this window,
171 * to use for proper cropping during animation.
Adrian Roosfa104232014-06-20 16:10:14 -0700172 * @param stableFrame The frame around which stable system decoration is positioned.
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700173 * @param outsetFrame The frame that includes areas that aren't part of the surface but we
174 * want to treat them as such.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175 */
176 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
Adrian Roosfa104232014-06-20 16:10:14 -0700177 Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame,
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700178 Rect stableFrame, Rect outsetFrame);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179
180 /**
181 * Retrieve the current frame of the window that has been assigned by
182 * the window manager. Must be called with the window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700183 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800184 * @return Rect The rectangle holding the window frame.
185 */
186 public Rect getFrameLw();
187
188 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700189 * Retrieve the current position of the window that is actually shown.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190 * Must be called with the window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700191 *
192 * @return Point The point holding the shown window position.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193 */
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700194 public Point getShownPositionLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800195
196 /**
197 * Retrieve the frame of the display that this window was last
198 * laid out in. Must be called with the
199 * window manager lock held.
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700200 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201 * @return Rect The rectangle holding the display frame.
202 */
203 public Rect getDisplayFrameLw();
204
205 /**
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800206 * Retrieve the frame of the area inside the overscan region of the
207 * display that this window was last laid out in. Must be called with the
208 * window manager lock held.
209 *
210 * @return Rect The rectangle holding the display overscan frame.
211 */
212 public Rect getOverscanFrameLw();
213
214 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215 * Retrieve the frame of the content area that this window was last
216 * laid out in. This is the area in which the content of the window
217 * should be placed. It will be smaller than the display frame to
218 * account for screen decorations such as a status bar or soft
219 * keyboard. Must be called with the
220 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700221 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222 * @return Rect The rectangle holding the content frame.
223 */
224 public Rect getContentFrameLw();
225
226 /**
227 * Retrieve the frame of the visible area that this window was last
228 * laid out in. This is the area of the screen in which the window
229 * will actually be fully visible. It will be smaller than the
230 * content frame to account for transient UI elements blocking it
231 * such as an input method's candidates UI. Must be called with the
232 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700233 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800234 * @return Rect The rectangle holding the visible frame.
235 */
236 public Rect getVisibleFrameLw();
237
238 /**
239 * Returns true if this window is waiting to receive its given
240 * internal insets from the client app, and so should not impact the
241 * layout of other windows.
242 */
243 public boolean getGivenInsetsPendingLw();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700244
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245 /**
246 * Retrieve the insets given by this window's client for the content
247 * area of windows behind it. Must be called with the
248 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700249 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800250 * @return Rect The left, top, right, and bottom insets, relative
251 * to the window's frame, of the actual contents.
252 */
253 public Rect getGivenContentInsetsLw();
254
255 /**
256 * Retrieve the insets given by this window's client for the visible
257 * area of windows behind it. Must be called with the
258 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700259 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 * @return Rect The left, top, right, and bottom insets, relative
261 * to the window's frame, of the actual visible area.
262 */
263 public Rect getGivenVisibleInsetsLw();
264
265 /**
266 * Retrieve the current LayoutParams of the window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700267 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800268 * @return WindowManager.LayoutParams The window's internal LayoutParams
269 * instance.
270 */
271 public WindowManager.LayoutParams getAttrs();
272
273 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800274 * Return whether this window needs the menu key shown. Must be called
275 * with window lock held, because it may need to traverse down through
276 * window list to determine the result.
277 * @param bottom The bottom-most window to consider when determining this.
278 */
279 public boolean getNeedsMenuLw(WindowState bottom);
280
281 /**
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700282 * Retrieve the current system UI visibility flags associated with
283 * this window.
284 */
285 public int getSystemUiVisibility();
286
287 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800288 * Get the layer at which this window's surface will be Z-ordered.
289 */
290 public int getSurfaceLayer();
Selim Cinekd6623612015-05-22 18:56:22 -0700291
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800292 /**
Selim Cinekd6623612015-05-22 18:56:22 -0700293 * Retrieve the type of the top-level window.
294 *
295 * @return the base type of the parent window if attached or its own type otherwise
296 */
297 public int getBaseType();
298
299 /**
300 * Return the token for the application (actually activity) that owns
301 * this window. May return null for system windows.
302 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800303 * @return An IApplicationToken identifying the owning activity.
304 */
305 public IApplicationToken getAppToken();
306
307 /**
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700308 * Return true if this window is participating in voice interaction.
309 */
310 public boolean isVoiceInteraction();
311
312 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700313 * Return true if, at any point, the application token associated with
314 * this window has actually displayed any windows. This is most useful
315 * with the "starting up" window to determine if any windows were
316 * displayed when it is closed.
317 *
318 * @return Returns true if one or more windows have been displayed,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319 * else false.
320 */
321 public boolean hasAppShownWindows();
322
323 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800324 * Is this window visible? It is not visible if there is no
325 * surface, or we are in the process of running an exit animation
326 * that will remove the surface.
327 */
328 boolean isVisibleLw();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700329
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330 /**
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700331 * Like {@link #isVisibleLw}, but also counts a window that is currently
332 * "hidden" behind the keyguard as visible. This allows us to apply
333 * things like window flags that impact the keyguard.
334 */
335 boolean isVisibleOrBehindKeyguardLw();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700336
Dianne Hackborn3d163f072009-10-07 21:26:57 -0700337 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700338 * Is this window currently visible to the user on-screen? It is
339 * displayed either if it is visible or it is currently running an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800340 * animation before no longer being visible. Must be called with the
341 * window manager lock held.
342 */
343 boolean isDisplayedLw();
344
345 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700346 * Return true if this window (or a window it is attached to, but not
347 * considering its app token) is currently animating.
348 */
Filip Gruszczynski14b4e572015-11-03 15:53:55 -0800349 boolean isAnimatingLw();
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700350
351 /**
Dianne Hackborn01b02a72012-01-12 14:05:03 -0800352 * Is this window considered to be gone for purposes of layout?
353 */
354 boolean isGoneForLayoutLw();
355
356 /**
Adrian Roos76d2fe42015-07-09 14:54:08 -0700357 * Returns true if the window has a surface that it has drawn a
358 * complete UI in to. Note that this is different from {@link #hasDrawnLw()}
359 * in that it also returns true if the window is READY_TO_SHOW, but was not yet
360 * promoted to HAS_DRAWN.
361 */
362 boolean isDrawnLw();
363
364 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700365 * Returns true if this window has been shown on screen at some time in
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800366 * the past. Must be called with the window manager lock held.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800367 */
368 public boolean hasDrawnLw();
369
370 /**
371 * Can be called by the policy to force a window to be hidden,
372 * regardless of whether the client or window manager would like
373 * it shown. Must be called with the window manager lock held.
374 * Returns true if {@link #showLw} was last called for the window.
375 */
376 public boolean hideLw(boolean doAnimation);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700377
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800378 /**
379 * Can be called to undo the effect of {@link #hideLw}, allowing a
380 * window to be shown as long as the window manager and client would
381 * also like it to be shown. Must be called with the window manager
382 * lock held.
383 * Returns true if {@link #hideLw} was last called for the window.
384 */
385 public boolean showLw(boolean doAnimation);
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700386
387 /**
388 * Check whether the process hosting this window is currently alive.
389 */
390 public boolean isAlive();
Craig Mautner69b08182012-09-05 13:07:13 -0700391
392 /**
393 * Check if window is on {@link Display#DEFAULT_DISPLAY}.
394 * @return true if window is on default display.
395 */
396 public boolean isDefaultDisplay();
Adrian Rooscd3884d2015-02-18 17:25:23 +0100397
398 /**
399 * Check whether the window is currently dimming.
400 */
401 public boolean isDimming();
Jorim Jaggi86905582016-02-09 21:36:09 -0800402
403 /**
404 * @return the stack id this windows belongs to, or {@link StackId#INVALID_STACK_ID} if
405 * not attached to any stack.
406 */
407 int getStackId();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800408 }
409
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700410 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700411 * Representation of a input consumer that the policy has added to the
412 * window manager to consume input events going to windows below it.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700413 */
Selim Cinekf83e8242015-05-19 18:08:14 -0700414 public interface InputConsumer {
Dianne Hackborndf89e652011-10-06 22:35:11 -0700415 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700416 * Remove the input consumer from the window manager.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700417 */
418 void dismiss();
419 }
420
421 /**
422 * Interface for calling back in to the window manager that is private
423 * between it and the policy.
424 */
425 public interface WindowManagerFuncs {
Jeff Brownac143512012-04-05 18:57:33 -0700426 public static final int LID_ABSENT = -1;
427 public static final int LID_CLOSED = 0;
428 public static final int LID_OPEN = 1;
429
Michael Wright3818c922014-09-02 13:59:07 -0700430 public static final int CAMERA_LENS_COVER_ABSENT = -1;
431 public static final int CAMERA_LENS_UNCOVERED = 0;
432 public static final int CAMERA_LENS_COVERED = 1;
433
Dianne Hackborndf89e652011-10-06 22:35:11 -0700434 /**
435 * Ask the window manager to re-evaluate the system UI flags.
436 */
437 public void reevaluateStatusBarVisibility();
438
439 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700440 * Add a input consumer which will consume all input events going to any window below it.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700441 */
Selim Cinekf83e8242015-05-19 18:08:14 -0700442 public InputConsumer addInputConsumer(Looper looper,
443 InputEventReceiver.Factory inputEventReceiverFactory);
Jeff Brownac143512012-04-05 18:57:33 -0700444
445 /**
446 * Returns a code that describes the current state of the lid switch.
447 */
448 public int getLidState();
449
450 /**
Edward Savage-Jones7def60d2015-11-13 13:27:03 +0100451 * Lock the device now.
452 */
453 public void lockDeviceNow();
454
455 /**
Michael Wright3818c922014-09-02 13:59:07 -0700456 * Returns a code that descripbes whether the camera lens is covered or not.
457 */
458 public int getCameraLensCoverState();
459
460 /**
Yohei Yukawaae61f712015-12-09 13:00:10 -0800461 * Switch the input method, to be precise, input method subtype.
462 *
463 * @param forwardDirection {@code true} to rotate in a forward direction.
464 */
465 public void switchInputMethod(boolean forwardDirection);
466
Jeff Brown9a538ee2012-08-20 14:56:57 -0700467 public void shutdown(boolean confirm);
468 public void rebootSafeMode(boolean confirm);
John Spurlock04db1762013-05-13 12:46:41 -0400469
470 /**
471 * Return the window manager lock needed to correctly call "Lw" methods.
472 */
473 public Object getWindowManagerLock();
Craig Mautner037aa8d2013-06-07 10:35:44 -0700474
475 /** Register a system listener for touch events */
476 void registerPointerEventListener(PointerEventListener listener);
477
478 /** Unregister a system listener for touch events */
479 void unregisterPointerEventListener(PointerEventListener listener);
Jorim Jaggi81ba11e2016-02-03 22:04:22 -0800480
481 /**
482 * @return The content insets of the docked divider window.
483 */
484 int getDockedDividerInsetsLw();
Jorim Jaggi86905582016-02-09 21:36:09 -0800485
486 /**
487 * Retrieves the {@param outBounds} from the stack with id {@param stackId}.
488 */
489 void getStackBounds(int stackId, Rect outBounds);
Craig Mautner037aa8d2013-06-07 10:35:44 -0700490 }
491
492 public interface PointerEventListener {
493 /**
494 * 1. onPointerEvent will be called on the service.UiThread.
495 * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a
496 * copy() must be made and the copy must be recycled.
497 **/
498 public void onPointerEvent(MotionEvent motionEvent);
Dianne Hackborndf89e652011-10-06 22:35:11 -0700499 }
500
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800501 /** Window has been added to the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800502 public static final int TRANSIT_ENTER = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 /** Window has been removed from the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800504 public static final int TRANSIT_EXIT = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800505 /** Window has been made visible. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800506 public static final int TRANSIT_SHOW = 3;
507 /** Window has been made invisible.
508 * TODO: Consider removal as this is unused. */
509 public static final int TRANSIT_HIDE = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800510 /** The "application starting" preview window is no longer needed, and will
511 * animate away to show the real window. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800512 public static final int TRANSIT_PREVIEW_DONE = 5;
513
Dianne Hackborn254cb442010-01-27 19:23:59 -0800514 // NOTE: screen off reasons are in order of significance, with more
515 // important ones lower than less important ones.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700516
Dianne Hackborn254cb442010-01-27 19:23:59 -0800517 /** Screen turned off because of a device admin */
518 public final int OFF_BECAUSE_OF_ADMIN = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 /** Screen turned off because of power button */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800520 public final int OFF_BECAUSE_OF_USER = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800521 /** Screen turned off because of timeout */
Dianne Hackborn254cb442010-01-27 19:23:59 -0800522 public final int OFF_BECAUSE_OF_TIMEOUT = 3;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800523
Tor Norbyed9273d62013-05-30 15:59:53 -0700524 /** @hide */
525 @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED})
526 @Retention(RetentionPolicy.SOURCE)
527 public @interface UserRotationMode {}
528
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400529 /** When not otherwise specified by the activity's screenOrientation, rotation should be
530 * determined by the system (that is, using sensors). */
531 public final int USER_ROTATION_FREE = 0;
532 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
533 * the user. */
534 public final int USER_ROTATION_LOCKED = 1;
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700535
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800536 /**
537 * Perform initialization of the policy.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700538 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 * @param context The system context we are running in.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 */
541 public void init(Context context, IWindowManager windowManager,
Jeff Brown96307042012-07-27 15:51:34 -0700542 WindowManagerFuncs windowManagerFuncs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543
544 /**
Craig Mautner46ac6fa2013-08-01 10:06:34 -0700545 * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true.
546 */
547 public boolean isDefaultOrientationForced();
548
549 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700550 * Called by window manager once it has the initial, default native
551 * display dimensions.
552 */
Dianne Hackborndde331c2012-08-03 14:01:57 -0700553 public void setInitialDisplaySize(Display display, int width, int height, int density);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700554
Dianne Hackborn9d132642011-04-21 17:26:39 -0700555 /**
Dianne Hackbornc652de82013-02-15 16:32:56 -0800556 * Called by window manager to set the overscan region that should be used for the
557 * given display.
558 */
559 public void setDisplayOverscan(Display display, int left, int top, int right, int bottom);
560
561 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800562 * Check permissions when adding a window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700563 *
Dianne Hackbornc2293022013-02-06 23:14:49 -0800564 * @param attrs The window's LayoutParams.
565 * @param outAppOp First element will be filled with the app op corresponding to
566 * this window, or OP_NONE.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700567 *
Jeff Brown98365d72012-08-19 20:30:52 -0700568 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800569 * else an error code, usually
Jeff Brown98365d72012-08-19 20:30:52 -0700570 * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800571 */
Dianne Hackbornc2293022013-02-06 23:14:49 -0800572 public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573
574 /**
Craig Mautner88400d32012-09-30 12:35:45 -0700575 * Check permissions when adding a window.
576 *
577 * @param attrs The window's LayoutParams.
578 *
579 * @return True if the window may only be shown to the current user, false if the window can
580 * be shown on all users' windows.
581 */
582 public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
583
584 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 * Sanitize the layout parameters coming from a client. Allows the policy
586 * to do things like ensure that windows of a specific type can't take
587 * input focus.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700588 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800589 * @param attrs The window layout parameters to be modified. These values
590 * are modified in-place.
591 */
592 public void adjustWindowParamsLw(WindowManager.LayoutParams attrs);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700593
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800594 /**
595 * After the window manager has computed the current configuration based
596 * on its knowledge of the display and input devices, it gives the policy
597 * a chance to adjust the information contained in it. If you want to
598 * leave it as-is, simply do nothing.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700599 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800600 * <p>This method may be called by any thread in the window manager, but
601 * no internal locks in the window manager will be held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700602 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800603 * @param config The Configuration being computed, for you to change as
604 * desired.
Jeff Browndaa37532012-05-01 15:54:03 -0700605 * @param keyboardPresence Flags that indicate whether internal or external
606 * keyboards are present.
607 * @param navigationPresence Flags that indicate whether internal or external
608 * navigation devices are present.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800609 */
Jeff Browndaa37532012-05-01 15:54:03 -0700610 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
611 int navigationPresence);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700612
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800613 /**
614 * Assign a window type to a layer. Allows you to control how different
615 * kinds of windows are ordered on-screen.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700616 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800617 * @param type The type of window being assigned.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700618 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800619 * @return int An arbitrary integer used to order windows, with lower
620 * numbers below higher ones.
621 */
622 public int windowTypeToLayerLw(int type);
623
624 /**
625 * Return how to Z-order sub-windows in relation to the window they are
626 * attached to. Return positive to have them ordered in front, negative for
627 * behind.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700628 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800629 * @param type The sub-window type code.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700630 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800631 * @return int Layer in relation to the attached window, where positive is
632 * above and negative is below.
633 */
634 public int subWindowTypeToLayerLw(int type);
635
636 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700637 * Get the highest layer (actually one more than) that the wallpaper is
638 * allowed to be in.
639 */
640 public int getMaxWallpaperLayer();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700641
642 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700643 * Return the display width available after excluding any screen
Jorim Jaggi82c9dc92016-02-05 15:10:33 -0800644 * decorations that could never be removed in Honeycomb. That is, system bar or
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700645 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400646 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800647 public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
648 int uiMode);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400649
650 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700651 * Return the display height available after excluding any screen
Jorim Jaggi82c9dc92016-02-05 15:10:33 -0800652 * decorations that could never be removed in Honeycomb. That is, system bar or
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700653 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400654 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800655 public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
656 int uiMode);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700657
658 /**
659 * Return the available screen width that we should report for the
660 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800661 * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700662 * that to account for more transient decoration like a status bar.
663 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800664 public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation,
665 int uiMode);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700666
667 /**
668 * Return the available screen height that we should report for the
669 * configuration. This must be no larger than
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800670 * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700671 * that to account for more transient decoration like a status bar.
672 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800673 public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation,
674 int uiMode);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400675
676 /**
Craig Mautnerc9457fa2014-06-06 14:27:48 -0700677 * Return whether the given window is forcibly hiding all windows except windows with
678 * FLAG_SHOW_WHEN_LOCKED set. Typically returns true for the keyguard.
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700679 */
Craig Mautnerc9457fa2014-06-06 14:27:48 -0700680 public boolean isForceHiding(WindowManager.LayoutParams attrs);
Jorim Jaggi0d674622014-05-21 01:34:15 +0200681
682
683 /**
Craig Mautnerc9457fa2014-06-06 14:27:48 -0700684 * Return whether the given window can become one that passes isForceHiding() test.
Jorim Jaggi0d674622014-05-21 01:34:15 +0200685 * Typically returns true for the StatusBar.
686 */
687 public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs);
688
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700689 /**
690 * Determine if a window that is behind one that is force hiding
Craig Mautnerc9457fa2014-06-06 14:27:48 -0700691 * (as determined by {@link #isForceHiding}) should actually be hidden.
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700692 * For example, typically returns false for the status bar. Be careful
693 * to return false for any window that you may hide yourself, since this
694 * will conflict with what you set.
695 */
696 public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs);
Jorim Jaggi0d674622014-05-21 01:34:15 +0200697
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700698 /**
Craig Mautner7d7808f2014-09-11 18:02:38 -0700699 * Return the window that is hiding the keyguard, if such a thing exists.
700 */
701 public WindowState getWinShowWhenLockedLw();
702
703 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800704 * Called when the system would like to show a UI to indicate that an
705 * application is starting. You can use this to add a
706 * APPLICATION_STARTING_TYPE window with the given appToken to the window
707 * manager (using the normal window manager APIs) that will be shown until
708 * the application displays its own window. This is called without the
709 * window manager locked so that you can call back into it.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700710 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800711 * @param appToken Token of the application being started.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700712 * @param packageName The name of the application package being started.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800713 * @param theme Resource defining the application's overall visual theme.
714 * @param nonLocalizedLabel The default title label of the application if
715 * no data is found in the resource.
716 * @param labelRes The resource ID the application would like to use as its name.
717 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800718 * @param windowFlags Window layout flags.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700719 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800720 * @return Optionally you can return the View that was used to create the
721 * window, for easy removal in removeStartingWindow.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700722 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800723 * @see #removeStartingWindow
724 */
725 public View addStartingWindow(IBinder appToken, String packageName,
Dianne Hackborn2f0b1752011-05-31 17:59:49 -0700726 int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel,
Adam Powell04fe6eb2013-05-31 14:39:48 -0700727 int labelRes, int icon, int logo, int windowFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800728
729 /**
730 * Called when the first window of an application has been displayed, while
731 * {@link #addStartingWindow} has created a temporary initial window for
732 * that application. You should at this point remove the window from the
733 * window manager. This is called without the window manager locked so
734 * that you can call back into it.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700735 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800736 * <p>Note: due to the nature of these functions not being called with the
737 * window manager locked, you must be prepared for this function to be
738 * called multiple times and/or an initial time with a null View window
739 * even if you previously returned one.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700740 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800741 * @param appToken Token of the application that has started.
742 * @param window Window View that was returned by createStartingWindow.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700743 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800744 * @see #addStartingWindow
745 */
746 public void removeStartingWindow(IBinder appToken, View window);
747
748 /**
749 * Prepare for a window being added to the window manager. You can throw an
750 * exception here to prevent the window being added, or do whatever setup
751 * you need to keep track of the window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700752 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800753 * @param win The window being added.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700754 * @param attrs The window's LayoutParams.
755 *
Jeff Brown98365d72012-08-19 20:30:52 -0700756 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800757 * error code to abort the add.
758 */
759 public int prepareAddWindowLw(WindowState win,
760 WindowManager.LayoutParams attrs);
761
762 /**
763 * Called when a window is being removed from a window manager. Must not
764 * throw an exception -- clean up as much as possible.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700765 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800766 * @param win The window being removed.
767 */
768 public void removeWindowLw(WindowState win);
769
770 /**
771 * Control the animation to run when a window's state changes. Return a
772 * non-0 number to force the animation to a specific resource ID, or 0
773 * to use the default animation.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700774 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800775 * @param win The window that is changing.
776 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
777 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
778 * {@link #TRANSIT_HIDE}.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700779 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800780 * @return Resource ID of the actual animation to use, or 0 for none.
781 */
782 public int selectAnimationLw(WindowState win, int transit);
783
784 /**
Craig Mautner3c174372013-02-21 17:54:37 -0800785 * Determine the animation to run for a rotation transition based on the
786 * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
787 * and whether it is currently fullscreen and frontmost.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700788 *
789 * @param anim The exiting animation resource id is stored in anim[0], the
Craig Mautner3c174372013-02-21 17:54:37 -0800790 * entering animation resource id is stored in anim[1].
791 */
792 public void selectRotationAnimationLw(int anim[]);
793
794 /**
795 * Validate whether the current top fullscreen has specified the same
796 * {@link WindowManager.LayoutParams#rotationAnimation} value as that
797 * being passed in from the previous top fullscreen window.
798 *
799 * @param exitAnimId exiting resource id from the previous window.
800 * @param enterAnimId entering resource id from the previous window.
801 * @param forceDefault For rotation animations only, if true ignore the
802 * animation values and just return false.
803 * @return true if the previous values are still valid, false if they
804 * should be replaced with the default.
805 */
806 public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId,
807 boolean forceDefault);
808
809 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700810 * Create and return an animation to re-display a force hidden window.
811 */
Jorim Jaggi84a3e7a2014-08-13 17:58:58 +0200812 public Animation createForceHideEnterAnimation(boolean onWallpaper,
813 boolean goingToNotificationShade);
Jorim Jaggi76a16232014-08-08 17:00:47 +0200814
815 /**
816 * Create and return an animation to let the wallpaper disappear after being shown on a force
817 * hiding window.
818 */
Jorim Jaggi84a3e7a2014-08-13 17:58:58 +0200819 public Animation createForceHideWallpaperExitAnimation(boolean goingToNotificationShade);
Jorim Jaggi76a16232014-08-08 17:00:47 +0200820
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700821 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700822 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800823 *
824 * <p>There are some actions that need to be handled here because they
825 * affect the power state of the device, for example, the power keys.
826 * Generally, it's best to keep as little as possible in the queue thread
827 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -0800828 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700829 * @param policyFlags The policy flags associated with the key.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800830 *
Jeff Brown26875502014-01-30 21:47:47 -0800831 * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800832 */
Jeff Brown037c33e2014-04-09 00:31:55 -0700833 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -0800834
835 /**
Michael Wright70af00a2014-09-03 19:30:20 -0700836 * Called from the input reader thread before a motion is enqueued when the device is in a
837 * non-interactive state.
Jeff Brown56194eb2011-03-02 19:23:13 -0800838 *
839 * <p>There are some actions that need to be handled here because they
840 * affect the power state of the device, for example, waking on motions.
841 * Generally, it's best to keep as little as possible in the queue thread
842 * because it's the most fragile.
843 * @param policyFlags The policy flags associated with the motion.
844 *
Jeff Brown26875502014-01-30 21:47:47 -0800845 * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
Jeff Brown56194eb2011-03-02 19:23:13 -0800846 */
Michael Wright70af00a2014-09-03 19:30:20 -0700847 public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -0800848
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800849 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700850 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800851 *
852 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -0700853 * behavior for keys that can not be overridden by applications.
854 * This method is called from the input thread, with no locks held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700855 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800856 * @param win The window that currently has focus. This is where the key
857 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800858 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700859 * @param policyFlags The policy flags associated with the key.
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700860 * @return 0 if the key should be dispatched immediately, -1 if the key should
861 * not be dispatched ever, or a positive value indicating the number of
862 * milliseconds by which the key dispatch should be delayed before trying
863 * again.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800864 */
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700865 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800866
867 /**
Jeff Brown3915bb82010-11-05 15:02:16 -0700868 * Called from the input dispatcher thread when an application did not handle
869 * a key that was dispatched to it.
870 *
871 * <p>Allows you to define default global behavior for keys that were not handled
872 * by applications. This method is called from the input thread, with no locks held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700873 *
Jeff Brown3915bb82010-11-05 15:02:16 -0700874 * @param win The window that currently has focus. This is where the key
875 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -0800876 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700877 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -0800878 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
879 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -0700880 */
Jeff Brown49ed71d2010-12-06 17:13:33 -0800881 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -0700882
883 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800884 * Called when layout of the windows is about to start.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700885 *
Craig Mautner69b08182012-09-05 13:07:13 -0700886 * @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800887 * @param displayWidth The current full width of the screen.
888 * @param displayHeight The current full height of the screen.
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800889 * @param displayRotation The current rotation being applied to the base window.
890 * @param uiMode The current uiMode in configuration.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800891 */
Craig Mautner69b08182012-09-05 13:07:13 -0700892 public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800893 int displayRotation, int uiMode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800894
895 /**
John Spurlock46646232013-09-30 22:32:42 -0400896 * Returns the bottom-most layer of the system decor, above which no policy decor should
897 * be applied.
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700898 */
John Spurlock46646232013-09-30 22:32:42 -0400899 public int getSystemDecorLayerLw();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700900
901 /**
Craig Mautner967212c2013-04-13 21:10:58 -0700902 * Return the rectangle of the screen that is available for applications to run in.
903 * This will be called immediately after {@link #beginLayoutLw}.
904 *
905 * @param r The rectangle to be filled with the boundaries available to applications.
906 */
907 public void getContentRectLw(Rect r);
908
909 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800910 * Called for each window attached to the window manager as layout is
911 * proceeding. The implementation of this function must take care of
912 * setting the window's frame, either here or in finishLayout().
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700913 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800914 * @param win The window being positioned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800915 * @param attached For sub-windows, the window it is attached to; this
916 * window will already have had layoutWindow() called on it
917 * so you can use its Rect. Otherwise null.
918 */
Craig Mautnerc9457fa2014-06-06 14:27:48 -0700919 public void layoutWindowLw(WindowState win, WindowState attached);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800920
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700921
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800922 /**
923 * Return the insets for the areas covered by system windows. These values
924 * are computed on the most recent layout, so they are not guaranteed to
925 * be correct.
Adrian Roos37d7a682014-11-06 18:15:16 +0100926 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800927 * @param attrs The LayoutParams of the window.
Filip Gruszczynski0ec13282015-06-25 11:26:01 -0700928 * @param rotation Rotation of the display.
Adrian Roos37d7a682014-11-06 18:15:16 +0100929 * @param outContentInsets The areas covered by system windows, expressed as positive insets.
930 * @param outStableInsets The areas covered by stable system windows irrespective of their
931 * current visibility. Expressed as positive insets.
Filip Gruszczynski0ec13282015-06-25 11:26:01 -0700932 * @param outOutsets The areas that are not real display, but we would like to treat as such.
Jorim Jaggi0ffd49c2016-02-12 15:04:21 -0800933 * @return Whether to always consume the navigation bar.
934 * See {@link #isNavBarForcedShownLw(WindowState)}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800935 */
Jorim Jaggi0ffd49c2016-02-12 15:04:21 -0800936 public boolean getInsetHintLw(WindowManager.LayoutParams attrs, int rotation,
Filip Gruszczynski0ec13282015-06-25 11:26:01 -0700937 Rect outContentInsets, Rect outStableInsets, Rect outOutsets);
Dianne Hackborn85afd1b2012-05-13 13:31:06 -0700938
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800939 /**
940 * Called when layout of the windows is finished. After this function has
941 * returned, all windows given to layoutWindow() <em>must</em> have had a
942 * frame assigned.
943 */
Craig Mautner61ac6bb2012-02-02 17:29:33 -0800944 public void finishLayoutLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800945
Dianne Hackborn9bfb7072009-09-22 11:37:40 -0700946 /** Layout state may have changed (so another layout will be performed) */
947 static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
948 /** Configuration state may have changed */
949 static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
950 /** Wallpaper may need to move */
951 static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800952 /** Need to recompute animations */
953 static final int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700954
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800955 /**
Craig Mautner39834192012-09-02 07:47:24 -0700956 * Called following layout of all windows before each window has policy applied.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700957 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800958 * @param displayWidth The current full width of the screen.
959 * @param displayHeight The current full height of the screen.
960 */
Craig Mautner39834192012-09-02 07:47:24 -0700961 public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962
963 /**
Craig Mautner39834192012-09-02 07:47:24 -0700964 * Called following layout of all window to apply policy to each window.
Yohei Yukawad1a09222015-06-30 16:22:05 -0700965 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800966 * @param win The window being positioned.
Yohei Yukawad1a09222015-06-30 16:22:05 -0700967 * @param attrs The LayoutParams of the window.
968 * @param attached For sub-windows, the window it is attached to. Otherwise null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800969 */
Craig Mautner39834192012-09-02 07:47:24 -0700970 public void applyPostLayoutPolicyLw(WindowState win,
Yohei Yukawad1a09222015-06-30 16:22:05 -0700971 WindowManager.LayoutParams attrs, WindowState attached);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800972
973 /**
Craig Mautner39834192012-09-02 07:47:24 -0700974 * Called following layout of all windows and after policy has been applied
975 * to each window. If in this function you do
976 * something that may have modified the animation state of another window,
977 * be sure to return non-zero in order to perform another pass through layout.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700978 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -0800979 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
980 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
981 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800982 */
Craig Mautner39834192012-09-02 07:47:24 -0700983 public int finishPostLayoutPolicyLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984
985 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -0800986 * Return true if it is okay to perform animations for an app transition
987 * that is about to occur. You may return false for this if, for example,
988 * the lock screen is currently displayed so the switch should happen
989 * immediately.
990 */
991 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -0800992
993
994 /**
995 * A new window has been focused.
996 */
Dianne Hackborndf89e652011-10-06 22:35:11 -0700997 public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
Jeff Brown36c4db82014-09-19 12:05:31 -0700998
999 /**
Jeff Brown416c49c2015-05-26 19:50:18 -07001000 * Called when the device has started waking up.
Jeff Brown36c4db82014-09-19 12:05:31 -07001001 */
Jeff Brown416c49c2015-05-26 19:50:18 -07001002 public void startedWakingUp();
Jeff Brown36c4db82014-09-19 12:05:31 -07001003
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001004 /**
Jeff Brown416c49c2015-05-26 19:50:18 -07001005 * Called when the device has finished waking up.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001006 */
Jeff Brown416c49c2015-05-26 19:50:18 -07001007 public void finishedWakingUp();
1008
1009 /**
1010 * Called when the device has started going to sleep.
1011 *
1012 * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1013 * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1014 */
1015 public void startedGoingToSleep(int why);
1016
1017 /**
1018 * Called when the device has finished going to sleep.
1019 *
1020 * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1021 * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1022 */
1023 public void finishedGoingToSleep(int why);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001024
Jeff Brown36c4db82014-09-19 12:05:31 -07001025 /**
1026 * Called when the device is about to turn on the screen to show content.
1027 * When waking up, this method will be called once after the call to wakingUp().
1028 * When dozing, the method will be called sometime after the call to goingToSleep() and
1029 * may be called repeatedly in the case where the screen is pulsing on and off.
1030 *
1031 * Must call back on the listener to tell it when the higher-level system
1032 * is ready for the screen to go on (i.e. the lock screen is shown).
1033 */
1034 public void screenTurningOn(ScreenOnListener screenOnListener);
1035
Jeff Brown3ee549c2014-09-22 20:14:39 -07001036 /**
Jorim Jaggi0d210f62015-07-10 14:24:44 -07001037 * Called when the device has actually turned on the screen, i.e. the display power state has
1038 * been set to ON and the screen is unblocked.
1039 */
1040 public void screenTurnedOn();
1041
1042 /**
Jeff Brown3ee549c2014-09-22 20:14:39 -07001043 * Called when the device has turned the screen off.
1044 */
1045 public void screenTurnedOff();
1046
Dianne Hackborn38e29a62011-09-18 14:43:08 -07001047 public interface ScreenOnListener {
1048 void onScreenOn();
Craig Mautner61ac6bb2012-02-02 17:29:33 -08001049 }
Dianne Hackborn38e29a62011-09-18 14:43:08 -07001050
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001051 /**
Jeff Brown3ee549c2014-09-22 20:14:39 -07001052 * Return whether the default display is on and not blocked by a black surface.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001053 */
Jeff Brown3ee549c2014-09-22 20:14:39 -07001054 public boolean isScreenOn();
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001055
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001056 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001057 * Tell the policy that the lid switch has changed state.
1058 * @param whenNanos The time when the change occurred in uptime nanoseconds.
1059 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001060 */
Jeff Brown46b9ac02010-04-22 18:58:52 -07001061 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
Michael Wright3818c922014-09-02 13:59:07 -07001062
1063 /**
1064 * Tell the policy that the camera lens has been covered or uncovered.
1065 * @param whenNanos The time when the change occurred in uptime nanoseconds.
1066 * @param lensCovered True if the lens is covered.
1067 */
1068 public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered);
1069
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001070 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001071 * Tell the policy if anyone is requesting that keyguard not come on.
1072 *
1073 * @param enabled Whether keyguard can be on or not. does not actually
1074 * turn it on, unless it was previously disabled with this function.
1075 *
1076 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
1077 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
1078 */
Craig Mautner3c174372013-02-21 17:54:37 -08001079 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001080 public void enableKeyguard(boolean enabled);
1081
1082 /**
1083 * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely}
1084 */
1085 interface OnKeyguardExitResult {
1086 void onKeyguardExitResult(boolean success);
1087 }
1088
1089 /**
1090 * Tell the policy if anyone is requesting the keyguard to exit securely
1091 * (this would be called after the keyguard was disabled)
1092 * @param callback Callback to send the result back.
1093 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
1094 */
Craig Mautner3c174372013-02-21 17:54:37 -08001095 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001096 void exitKeyguardSecurely(OnKeyguardExitResult callback);
1097
1098 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -05001099 * isKeyguardLocked
1100 *
1101 * Return whether the keyguard is currently locked.
1102 *
1103 * @return true if in keyguard is locked.
1104 */
1105 public boolean isKeyguardLocked();
1106
1107 /**
1108 * isKeyguardSecure
1109 *
1110 * Return whether the keyguard requires a password to unlock.
1111 *
1112 * @return true if in keyguard is secure.
1113 */
1114 public boolean isKeyguardSecure();
1115
1116 /**
Adrian Roos461829d2015-06-03 14:41:18 -07001117 * Return whether the keyguard is on.
1118 *
1119 * @return true if in keyguard is on.
1120 */
1121 public boolean isKeyguardShowingOrOccluded();
1122
1123 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001124 * inKeyguardRestrictedKeyInputMode
1125 *
1126 * if keyguard screen is showing or in restricted key input mode (i.e. in
1127 * keyguard password emergency screen). When in such mode, certain keys,
1128 * such as the Home key and the right soft keys, don't work.
1129 *
1130 * @return true if in keyguard restricted input mode.
1131 */
1132 public boolean inKeyguardRestrictedKeyInputMode();
1133
1134 /**
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001135 * Ask the policy to dismiss the keyguard, if it is currently shown.
1136 */
1137 public void dismissKeyguardLw();
1138
1139 /**
Jorim Jaggi8de4311c2014-08-11 22:36:20 +02001140 * Notifies the keyguard that the activity has drawn it was waiting for.
1141 */
1142 public void notifyActivityDrawnForKeyguardLw();
1143
1144 /**
Jorim Jaggicff0acb2014-03-31 16:35:15 +02001145 * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
1146 * returns true as soon as we know that Keyguard is disabled.
1147 *
1148 * @return true if the keyguard has drawn.
1149 */
1150 public boolean isKeyguardDrawnLw();
1151
1152 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001153 * Given an orientation constant, returns the appropriate surface rotation,
1154 * taking into account sensors, docking mode, rotation lock, and other factors.
1155 *
1156 * @param orientation An orientation constant, such as
1157 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1158 * @param lastRotation The most recently used rotation.
1159 * @return The surface rotation to use.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001160 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001161 public int rotationForOrientationLw(@ActivityInfo.ScreenOrientation int orientation,
1162 int lastRotation);
Jeff Brown01a98dd2011-09-20 15:08:29 -07001163
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001164 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001165 * Given an orientation constant and a rotation, returns true if the rotation
1166 * has compatible metrics to the requested orientation. For example, if
1167 * the application requested landscape and got seascape, then the rotation
1168 * has compatible metrics; if the application requested portrait and got landscape,
1169 * then the rotation has incompatible metrics; if the application did not specify
1170 * a preference, then anything goes.
1171 *
1172 * @param orientation An orientation constant, such as
1173 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1174 * @param rotation The rotation to check.
1175 * @return True if the rotation is compatible with the requested orientation.
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001176 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001177 public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation int orientation,
1178 int rotation);
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001179
1180 /**
Jeff Brownc0347aa2011-09-23 17:26:09 -07001181 * Called by the window manager when the rotation changes.
1182 *
1183 * @param rotation The new rotation.
1184 */
1185 public void setRotationLw(int rotation);
1186
1187 /**
Jeff Brownac143512012-04-05 18:57:33 -07001188 * Called when the system is mostly done booting to set whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 * the system should go into safe mode.
1190 */
Jeff Brownac143512012-04-05 18:57:33 -07001191 public void setSafeMode(boolean safeMode);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001192
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001193 /**
1194 * Called when the system is mostly done booting.
1195 */
1196 public void systemReady();
1197
1198 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -07001199 * Called when the system is done booting to the point where the
1200 * user can start interacting with it.
1201 */
1202 public void systemBooted();
1203
1204 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001205 * Show boot time message to the user.
1206 */
1207 public void showBootMessage(final CharSequence msg, final boolean always);
1208
1209 /**
1210 * Hide the UI for showing boot messages, never to be displayed again.
1211 */
1212 public void hideBootMessages();
1213
1214 /**
Mike Lockwoodef731622010-01-27 17:51:34 -05001215 * Called when userActivity is signalled in the power manager.
1216 * This is safe to call from any thread, with any window manager locks held or not.
1217 */
1218 public void userActivity();
1219
1220 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001221 * Called when we have finished booting and can now display the home
Jeff Brownc042ee22012-05-08 13:03:42 -07001222 * screen to the user. This will happen after systemReady(), and at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001223 * this point the display is active.
1224 */
1225 public void enableScreenAfterBoot();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001226
Tor Norbyed9273d62013-05-30 15:59:53 -07001227 public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001228
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001229 /**
1230 * Call from application to perform haptic feedback on its window.
1231 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001232 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001233
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001234 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -04001235 * Called when we have started keeping the screen on because a window
1236 * requesting this has become visible.
1237 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001238 public void keepScreenOnStartedLw();
Daniel Sandler0601eb72011-04-13 01:01:32 -04001239
1240 /**
1241 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001242 * requesting this is no longer visible.
1243 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001244 public void keepScreenOnStoppedLw();
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001245
1246 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001247 * Gets the current user rotation mode.
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001248 *
1249 * @return The rotation mode.
1250 *
1251 * @see WindowManagerPolicy#USER_ROTATION_LOCKED
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001252 * @see WindowManagerPolicy#USER_ROTATION_FREE
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001253 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001254 @UserRotationMode
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001255 public int getUserRotationMode();
1256
1257 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001258 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001259 *
1260 * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001261 * {@link WindowManagerPolicy#USER_ROTATION_FREE}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001262 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
Craig Mautner69b08182012-09-05 13:07:13 -07001263 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001264 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001265 public void setUserRotationMode(@UserRotationMode int mode, @Surface.Rotation int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001266
1267 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -07001268 * Called when a new system UI visibility is being reported, allowing
1269 * the policy to adjust what is actually reported.
Tor Norbyed9273d62013-05-30 15:59:53 -07001270 * @param visibility The raw visibility reported by the status bar.
Dianne Hackborndf89e652011-10-06 22:35:11 -07001271 * @return The new desired visibility.
1272 */
1273 public int adjustSystemUiVisibilityLw(int visibility);
1274
1275 /**
Daniel Sandler0c4ccff2011-10-19 16:39:14 -04001276 * Specifies whether there is an on-screen navigation bar separate from the status bar.
1277 */
1278 public boolean hasNavigationBar();
1279
1280 /**
Jim Miller93c518e2012-01-17 15:55:31 -08001281 * Lock the device now.
1282 */
Adam Cohenf7522022012-10-03 20:03:18 -07001283 public void lockNow(Bundle options);
Jim Miller93c518e2012-01-17 15:55:31 -08001284
1285 /**
satok1bc0a492012-04-25 22:47:12 +09001286 * Set the last used input method window state. This state is used to make IME transition
1287 * smooth.
1288 * @hide
1289 */
1290 public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1291
1292 /**
Craig Mautner84984fa2014-06-19 11:19:20 -07001293 * Show the recents task list app.
1294 * @hide
1295 */
1296 public void showRecentApps();
1297
1298 /**
Alan Viverettee34560b22014-07-10 14:50:06 -07001299 * Show the global actions dialog.
1300 * @hide
1301 */
1302 public void showGlobalActions();
1303
1304 /**
Satoshi Kataoka658c7b82013-10-10 17:03:51 +09001305 * @return The current height of the input method window.
1306 */
1307 public int getInputMethodWindowVisibleHeightLw();
1308
1309 /**
Craig Mautnerf1b67412012-09-19 13:18:29 -07001310 * Called when the current user changes. Guaranteed to be called before the broadcast
1311 * of the new user id is made to all listeners.
1312 *
1313 * @param newUserId The id of the incoming user.
1314 */
1315 public void setCurrentUserLw(int newUserId);
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -07001316
1317 /**
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001318 * Print the WindowManagerPolicy's state into the given stream.
1319 *
1320 * @param prefix Text to print at the front of each line.
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001321 * @param writer The PrintWriter to which you should dump your state. This will be
1322 * closed for you after you return.
1323 * @param args additional arguments to the dump request.
1324 */
Jeff Brownd7a04de2012-06-17 14:17:52 -07001325 public void dump(String prefix, PrintWriter writer, String[] args);
Jim Miller4eeb4f62012-11-08 00:04:29 -08001326
1327 /**
Svetoslav Ganov545252f2012-12-10 18:29:24 -08001328 * Returns whether a given window type can be magnified.
1329 *
1330 * @param windowType The window type.
1331 * @return True if the window can be magnified.
1332 */
1333 public boolean canMagnifyWindow(int windowType);
1334
1335 /**
1336 * Returns whether a given window type is considered a top level one.
1337 * A top level window does not have a container, i.e. attached window,
1338 * or if it has a container it is laid out as a top-level window, not
1339 * as a child of its container.
1340 *
1341 * @param windowType The window type.
1342 * @return True if the window is a top level one.
1343 */
1344 public boolean isTopLevelWindow(int windowType);
Jorim Jaggi0d674622014-05-21 01:34:15 +02001345
1346 /**
1347 * Notifies the keyguard to start fading out.
Jorim Jaggie29b2db2014-05-30 23:17:03 +02001348 *
1349 * @param startTime the start time of the animation in uptime milliseconds
1350 * @param fadeoutDuration the duration of the exit animation, in milliseconds
Jorim Jaggi0d674622014-05-21 01:34:15 +02001351 */
Jorim Jaggie29b2db2014-05-30 23:17:03 +02001352 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
Jorim Jaggi737af722015-12-31 10:42:27 +01001353
1354 /**
1355 * Calculates the stable insets without running a layout.
1356 *
1357 * @param displayRotation the current display rotation
Jorim Jaggi737af722015-12-31 10:42:27 +01001358 * @param displayWidth the current display width
1359 * @param displayHeight the current display height
Winson3e874742016-01-07 10:08:17 -08001360 * @param outInsets the insets to return
Jorim Jaggi737af722015-12-31 10:42:27 +01001361 */
1362 public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
1363 Rect outInsets);
Jorim Jaggi82c9dc92016-02-05 15:10:33 -08001364
Jorim Jaggi0ffd49c2016-02-12 15:04:21 -08001365
1366 /**
1367 * @return true if the navigation bar is forced to stay visible
1368 */
1369 public boolean isNavBarForcedShownLw(WindowState win);
1370
Jorim Jaggi82c9dc92016-02-05 15:10:33 -08001371 /**
1372 * Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system
1373 * bar or button bar. See {@link #getNonDecorDisplayWidth}.
1374 *
1375 * @param displayRotation the current display rotation
1376 * @param displayWidth the current display width
1377 * @param displayHeight the current display height
1378 * @param outInsets the insets to return
1379 */
1380 public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight,
1381 Rect outInsets);
Jorim Jaggi5060bd82016-02-19 17:12:19 -08001382
1383 /**
1384 * @return True if a specified {@param dockSide} is allowed on the current device, or false
1385 * otherwise. It is guaranteed that at least one dock side for a particular orientation
1386 * is allowed, so for example, if DOCKED_RIGHT is not allowed, DOCKED_LEFT is allowed.
1387 */
1388 public boolean isDockSideAllowed(int dockSide);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001389}