blob: a02ee225861dbe4096c1bf34285c0e5c8a27c3af [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
Adrian Roose99bc052017-11-20 17:55:31 +01002 * Copyright (C) 2017 The Android Open Source Project
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003 *
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
Adrian Roose99bc052017-11-20 17:55:31 +010017package com.android.server.policy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018
Wale Ogunwale5cd907d2017-01-26 14:14:08 -080019import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
20import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
21import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY;
22import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL;
23import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
24import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
25import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY;
26import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
27import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
28import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL;
29import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS;
30import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY;
31import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER;
32import static android.view.WindowManager.LayoutParams.TYPE_DRAG;
33import static android.view.WindowManager.LayoutParams.TYPE_DREAM;
34import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
35import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
36import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG;
37import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG;
38import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY;
39import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR;
40import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL;
41import static android.view.WindowManager.LayoutParams.TYPE_PHONE;
42import static android.view.WindowManager.LayoutParams.TYPE_POINTER;
43import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
44import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE;
45import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
46import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG;
47import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;
48import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR;
49import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY;
50import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR;
51import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL;
52import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL;
53import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
54import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
55import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
56import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY;
57import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
58import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
59import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING;
60import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY;
61import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
62import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType;
63
Yohei Yukawad0a66b22018-01-10 13:19:54 -080064import static java.lang.annotation.RetentionPolicy.SOURCE;
65
Adrian Roose99bc052017-11-20 17:55:31 +010066import android.Manifest;
Tor Norbyed9273d62013-05-30 15:59:53 -070067import android.annotation.IntDef;
Jorim Jaggi241ae102016-11-02 21:57:33 -070068import android.annotation.Nullable;
Benjamin Franz3662b152018-01-16 17:23:44 +000069import android.app.ActivityManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070import android.content.Context;
Tor Norbyed9273d62013-05-30 15:59:53 -070071import android.content.pm.ActivityInfo;
Dianne Hackborn2f0b1752011-05-31 17:59:49 -070072import android.content.res.CompatibilityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073import android.content.res.Configuration;
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -070074import android.graphics.Point;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075import android.graphics.Rect;
Adam Cohenf7522022012-10-03 20:03:18 -070076import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077import android.os.IBinder;
Dianne Hackborndf89e652011-10-06 22:35:11 -070078import android.os.Looper;
Muyuan Li94ce94e2016-02-24 16:20:54 -080079import android.os.RemoteException;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -080080import android.util.Slog;
Steven Timotiusaf03df62017-07-18 16:56:43 -070081import android.util.proto.ProtoOutputStream;
Adrian Roose99bc052017-11-20 17:55:31 +010082import android.view.Display;
Adrian Roos5c6b6222017-11-07 17:36:10 +010083import android.view.DisplayCutout;
Adrian Roose99bc052017-11-20 17:55:31 +010084import android.view.IApplicationToken;
85import android.view.IWindowManager;
86import android.view.InputEventReceiver;
87import android.view.KeyEvent;
88import android.view.Surface;
89import android.view.WindowManager;
90import android.view.WindowManagerGlobal;
91import android.view.WindowManagerPolicyConstants;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092import android.view.animation.Animation;
Aurimas Liutikas67e2ae82016-10-11 18:17:42 -070093
Jorim Jaggi241ae102016-11-02 21:57:33 -070094import com.android.internal.policy.IKeyguardDismissCallback;
Muyuan Li94ce94e2016-02-24 16:20:54 -080095import com.android.internal.policy.IShortcutService;
Adrian Roose99bc052017-11-20 17:55:31 +010096import com.android.server.wm.DisplayFrames;
Adrian Roos6a4fa0e2018-03-05 19:50:16 +010097import com.android.server.wm.utils.WmDisplayCutout;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080099import java.io.PrintWriter;
Tor Norbyed9273d62013-05-30 15:59:53 -0700100import java.lang.annotation.Retention;
101import java.lang.annotation.RetentionPolicy;
Dianne Hackbornf99f9c52011-01-12 15:49:25 -0800102
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103/**
104 * This interface supplies all UI-specific behavior of the window manager. An
105 * instance of it is created by the window manager when it starts up, and allows
106 * customization of window layering, special window types, key dispatching, and
107 * layout.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700108 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109 * <p>Because this provides deep interaction with the system window manager,
110 * specific methods on this interface can be called from a variety of contexts
111 * with various restrictions on what they can do. These are encoded through
112 * a suffixes at the end of a method encoding the thread the method is called
113 * from and any locks that are held when it is being called; if no suffix
114 * is attached to a method, then it is not called with any locks and may be
115 * called from the main window manager thread or another thread calling into
116 * the window manager.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700117 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118 * <p>The current suffixes are:
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700119 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800120 * <dl>
121 * <dt> Ti <dd> Called from the input thread. This is the thread that
122 * collects pending input events and dispatches them to the appropriate window.
123 * It may block waiting for events to be processed, so that the input stream is
124 * properly serialized.
125 * <dt> Tq <dd> Called from the low-level input queue thread. This is the
126 * thread that reads events out of the raw input devices and places them
127 * into the global input queue that is read by the <var>Ti</var> thread.
128 * This thread should not block for a long period of time on anything but the
129 * key driver.
130 * <dt> Lw <dd> Called with the main window manager lock held. Because the
131 * window manager is a very low-level system service, there are few other
132 * system services you can call with this lock held. It is explicitly okay to
133 * make calls into the package manager and power manager; it is explicitly not
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700134 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800135 * {@link android.content.Context#checkPermission(String, int, int)} and
136 * variations require calling into the activity manager.
137 * <dt> Li <dd> Called with the input thread lock held. This lock can be
138 * acquired by the window manager while it holds the window lock, so this is
139 * even more restrictive than <var>Lw</var>.
140 * </dl>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800141 */
Adrian Roose99bc052017-11-20 17:55:31 +0100142public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
Yohei Yukawad0a66b22018-01-10 13:19:54 -0800143 @Retention(SOURCE)
144 @IntDef({NAV_BAR_LEFT, NAV_BAR_RIGHT, NAV_BAR_BOTTOM})
145 @interface NavigationBarPosition {}
146
Bryce Lee01b0c5f2015-02-05 18:24:04 -0800147 /**
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700148 * Pass this event to the user / app. To be returned from
149 * {@link #interceptKeyBeforeQueueing}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150 */
Adrian Roose99bc052017-11-20 17:55:31 +0100151 int ACTION_PASS_TO_USER = 0x00000001;
152 /** Layout state may have changed (so another layout will be performed) */
153 int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
154 /** Configuration state may have changed */
155 int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
156 /** Wallpaper may need to move */
157 int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
158 /** Need to recompute animations */
159 int FINISH_LAYOUT_REDO_ANIM = 0x0008;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800160
161 /**
Muyuan Li94ce94e2016-02-24 16:20:54 -0800162 * Register shortcuts for window manager to dispatch.
163 * Shortcut code is packed as (metaState << Integer.SIZE) | keyCode
164 * @hide
165 */
166 void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
167 throws RemoteException;
168
169 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200170 * Called when the Keyguard occluded state changed.
171 * @param occluded Whether Keyguard is currently occluded or not.
Adrian Roosd88eb262016-08-04 14:50:48 -0700172 */
Jorim Jaggife762342016-10-13 14:33:27 +0200173 void onKeyguardOccludedChangedLw(boolean occluded);
Adrian Roosd88eb262016-08-04 14:50:48 -0700174
175 /**
Adrian Roos2f1a90b2018-01-09 17:28:49 +0100176 * Called when the resource overlays change.
177 */
178 default void onOverlayChangedLw() {}
179
180 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800181 * Interface to the Window Manager state associated with a particular
182 * window. You can hold on to an instance of this interface from the call
183 * to prepareAddWindow() until removeWindow().
184 */
185 public interface WindowState {
186 /**
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800187 * Return the uid of the app that owns this window.
188 */
189 int getOwningUid();
190
191 /**
192 * Return the package name of the app that owns this window.
193 */
194 String getOwningPackage();
195
196 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800197 * Perform standard frame computation. The result can be obtained with
198 * getFrame() if so desired. Must be called with the window manager
199 * lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700200 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201 * @param parentFrame The frame of the parent container this window
202 * is in, used for computing its basic position.
203 * @param displayFrame The frame of the overall display in which this
204 * window can appear, used for constraining the overall dimensions
205 * of the window.
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800206 * @param overlayFrame The frame within the display that is inside
207 * of the overlay region.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800208 * @param contentFrame The frame within the display in which we would
209 * like active content to appear. This will cause windows behind to
210 * be resized to match the given content frame.
211 * @param visibleFrame The frame within the display that the window
212 * is actually visible, used for computing its visible insets to be
213 * given to windows behind.
214 * This can be used as a hint for scrolling (avoiding resizing)
215 * the window to make certain that parts of its content
216 * are visible.
John Spurlock46646232013-09-30 22:32:42 -0400217 * @param decorFrame The decor frame specified by policy specific to this window,
218 * to use for proper cropping during animation.
Adrian Roosfa104232014-06-20 16:10:14 -0700219 * @param stableFrame The frame around which stable system decoration is positioned.
Filip Gruszczynski2217f612015-05-26 11:32:08 -0700220 * @param outsetFrame The frame that includes areas that aren't part of the surface but we
221 * want to treat them as such.
Adrian Roos6a4fa0e2018-03-05 19:50:16 +0100222 * @param displayCutout the display cutout
Adrian Roos5ed644f2018-03-19 17:01:05 +0100223 * @param parentFrameWasClippedByDisplayCutout true if the parent frame would have been
224 * different if there was no display cutout.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800225 */
226 public void computeFrameLw(Rect parentFrame, Rect displayFrame,
Adrian Roosfa104232014-06-20 16:10:14 -0700227 Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame,
Adrian Roos5ed644f2018-03-19 17:01:05 +0100228 Rect stableFrame, @Nullable Rect outsetFrame, WmDisplayCutout displayCutout,
229 boolean parentFrameWasClippedByDisplayCutout);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800230
231 /**
232 * Retrieve the current frame of the window that has been assigned by
233 * the window manager. Must be called with the window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700234 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800235 * @return Rect The rectangle holding the window frame.
236 */
237 public Rect getFrameLw();
238
239 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800240 * Retrieve the frame of the display that this window was last
241 * laid out in. Must be called with the
242 * window manager lock held.
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700243 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800244 * @return Rect The rectangle holding the display frame.
245 */
246 public Rect getDisplayFrameLw();
247
248 /**
Dianne Hackbornc4aad012013-02-22 15:05:25 -0800249 * Retrieve the frame of the area inside the overscan region of the
250 * display that this window was last laid out in. Must be called with the
251 * window manager lock held.
252 *
253 * @return Rect The rectangle holding the display overscan frame.
254 */
255 public Rect getOverscanFrameLw();
256
257 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 * Retrieve the frame of the content area that this window was last
259 * laid out in. This is the area in which the content of the window
260 * should be placed. It will be smaller than the display frame to
261 * account for screen decorations such as a status bar or soft
262 * keyboard. Must be called with the
263 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700264 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 * @return Rect The rectangle holding the content frame.
266 */
267 public Rect getContentFrameLw();
268
269 /**
270 * Retrieve the frame of the visible area that this window was last
271 * laid out in. This is the area of the screen in which the window
272 * will actually be fully visible. It will be smaller than the
273 * content frame to account for transient UI elements blocking it
274 * such as an input method's candidates UI. Must be called with the
275 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700276 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800277 * @return Rect The rectangle holding the visible frame.
278 */
279 public Rect getVisibleFrameLw();
280
281 /**
282 * Returns true if this window is waiting to receive its given
283 * internal insets from the client app, and so should not impact the
284 * layout of other windows.
285 */
286 public boolean getGivenInsetsPendingLw();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700287
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800288 /**
289 * Retrieve the insets given by this window's client for the content
290 * area of windows behind it. Must be called with the
291 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700292 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 * @return Rect The left, top, right, and bottom insets, relative
294 * to the window's frame, of the actual contents.
295 */
296 public Rect getGivenContentInsetsLw();
297
298 /**
299 * Retrieve the insets given by this window's client for the visible
300 * area of windows behind it. Must be called with the
301 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700302 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800303 * @return Rect The left, top, right, and bottom insets, relative
304 * to the window's frame, of the actual visible area.
305 */
306 public Rect getGivenVisibleInsetsLw();
307
308 /**
309 * Retrieve the current LayoutParams of the window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700310 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800311 * @return WindowManager.LayoutParams The window's internal LayoutParams
312 * instance.
313 */
314 public WindowManager.LayoutParams getAttrs();
315
316 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800317 * Return whether this window needs the menu key shown. Must be called
318 * with window lock held, because it may need to traverse down through
319 * window list to determine the result.
320 * @param bottom The bottom-most window to consider when determining this.
321 */
322 public boolean getNeedsMenuLw(WindowState bottom);
323
324 /**
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700325 * Retrieve the current system UI visibility flags associated with
326 * this window.
327 */
328 public int getSystemUiVisibility();
329
330 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 * Get the layer at which this window's surface will be Z-ordered.
332 */
333 public int getSurfaceLayer();
Selim Cinekd6623612015-05-22 18:56:22 -0700334
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800335 /**
Selim Cinekd6623612015-05-22 18:56:22 -0700336 * Retrieve the type of the top-level window.
337 *
338 * @return the base type of the parent window if attached or its own type otherwise
339 */
340 public int getBaseType();
341
342 /**
343 * Return the token for the application (actually activity) that owns
344 * this window. May return null for system windows.
345 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800346 * @return An IApplicationToken identifying the owning activity.
347 */
348 public IApplicationToken getAppToken();
349
350 /**
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700351 * Return true if this window is participating in voice interaction.
352 */
353 public boolean isVoiceInteraction();
354
355 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700356 * Return true if, at any point, the application token associated with
357 * this window has actually displayed any windows. This is most useful
358 * with the "starting up" window to determine if any windows were
359 * displayed when it is closed.
360 *
361 * @return Returns true if one or more windows have been displayed,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800362 * else false.
363 */
364 public boolean hasAppShownWindows();
365
366 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800367 * Is this window visible? It is not visible if there is no
368 * surface, or we are in the process of running an exit animation
369 * that will remove the surface.
370 */
371 boolean isVisibleLw();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700372
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800373 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700374 * Is this window currently visible to the user on-screen? It is
375 * displayed either if it is visible or it is currently running an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800376 * animation before no longer being visible. Must be called with the
377 * window manager lock held.
378 */
379 boolean isDisplayedLw();
380
381 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700382 * Return true if this window (or a window it is attached to, but not
383 * considering its app token) is currently animating.
384 */
Filip Gruszczynski14b4e572015-11-03 15:53:55 -0800385 boolean isAnimatingLw();
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700386
387 /**
Jorim Jaggi23cc9aa2017-05-23 16:05:35 +0200388 * @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars,
389 * for example) will be affected by the flags specified in this window. This is the
390 * case when the surface is on screen but not exiting.
391 */
392 boolean canAffectSystemUiFlags();
393
394 /**
Dianne Hackborn01b02a72012-01-12 14:05:03 -0800395 * Is this window considered to be gone for purposes of layout?
396 */
397 boolean isGoneForLayoutLw();
398
399 /**
Adrian Roos76d2fe42015-07-09 14:54:08 -0700400 * Returns true if the window has a surface that it has drawn a
401 * complete UI in to. Note that this is different from {@link #hasDrawnLw()}
402 * in that it also returns true if the window is READY_TO_SHOW, but was not yet
403 * promoted to HAS_DRAWN.
404 */
405 boolean isDrawnLw();
406
407 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700408 * Returns true if this window has been shown on screen at some time in
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800409 * the past. Must be called with the window manager lock held.
Jorim Jaggia32da382018-03-28 18:01:22 +0200410 *
411 * @deprecated Use {@link #isDrawnLw} or any of the other drawn/visibility methods.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 */
Jorim Jaggia32da382018-03-28 18:01:22 +0200413 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414 public boolean hasDrawnLw();
415
416 /**
417 * Can be called by the policy to force a window to be hidden,
418 * regardless of whether the client or window manager would like
419 * it shown. Must be called with the window manager lock held.
420 * Returns true if {@link #showLw} was last called for the window.
421 */
422 public boolean hideLw(boolean doAnimation);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700423
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800424 /**
425 * Can be called to undo the effect of {@link #hideLw}, allowing a
426 * window to be shown as long as the window manager and client would
427 * also like it to be shown. Must be called with the window manager
428 * lock held.
429 * Returns true if {@link #hideLw} was last called for the window.
430 */
431 public boolean showLw(boolean doAnimation);
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700432
433 /**
434 * Check whether the process hosting this window is currently alive.
435 */
436 public boolean isAlive();
Craig Mautner69b08182012-09-05 13:07:13 -0700437
438 /**
439 * Check if window is on {@link Display#DEFAULT_DISPLAY}.
440 * @return true if window is on default display.
441 */
442 public boolean isDefaultDisplay();
Adrian Rooscd3884d2015-02-18 17:25:23 +0100443
444 /**
445 * Check whether the window is currently dimming.
446 */
447 public boolean isDimming();
Jorim Jaggi86905582016-02-09 21:36:09 -0800448
Adrian Roos865c70f2018-01-10 17:32:27 +0100449 /**
450 * Returns true if the window is letterboxed for the display cutout.
451 */
452 default boolean isLetterboxedForDisplayCutoutLw() {
453 return false;
454 }
455
Adrian Roos23df3a32018-03-15 15:41:13 +0100456 /**
457 * Returns true if the window has a letterbox and any part of that letterbox overlaps with
458 * the given {@code rect}.
459 */
460 default boolean isLetterboxedOverlappingWith(Rect rect) {
461 return false;
462 }
463
Wale Ogunwale44f036f2017-09-29 05:09:09 -0700464 /** @return the current windowing mode of this window. */
465 int getWindowingMode();
Wale Ogunwale9185fb02016-03-11 18:06:14 -0800466
467 /**
468 * Returns true if the window is current in multi-windowing mode. i.e. it shares the
469 * screen with other application windows.
470 */
Andrii Kulian933076d2016-03-29 17:04:42 -0700471 public boolean isInMultiWindowMode();
Robert Carrfd10cd12016-06-29 16:41:50 -0700472
473 public int getRotationAnimationHint();
Jorim Jaggife762342016-10-13 14:33:27 +0200474
475 public boolean isInputMethodWindow();
476
Robert Carr825581a2018-03-30 14:00:53 -0700477 public boolean isInputMethodTarget();
478
Jorim Jaggife762342016-10-13 14:33:27 +0200479 public int getDisplayId();
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800480
481 /**
482 * Returns true if the window owner can add internal system windows.
Adrian Roose99bc052017-11-20 17:55:31 +0100483 * That is, they have {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}.
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800484 */
485 default boolean canAddInternalSystemWindow() {
486 return false;
487 }
Jorim Jaggif12ec0f2017-08-23 16:14:10 +0200488
489 /**
490 * Returns true if the window owner has the permission to acquire a sleep token when it's
Adrian Roose99bc052017-11-20 17:55:31 +0100491 * visible. That is, they have the permission {@link Manifest.permission#DEVICE_POWER}.
Jorim Jaggif12ec0f2017-08-23 16:14:10 +0200492 */
493 boolean canAcquireSleepToken();
Vishnu Nair9a3e4062018-01-11 08:42:54 -0800494
495 /**
Yi Jin6c6e9ca2018-03-20 16:53:35 -0700496 * Writes {@link com.android.server.wm.IdentifierProto} to stream.
Vishnu Nair9a3e4062018-01-11 08:42:54 -0800497 */
498 void writeIdentifierToProto(ProtoOutputStream proto, long fieldId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800499 }
500
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700501 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700502 * Representation of a input consumer that the policy has added to the
503 * window manager to consume input events going to windows below it.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700504 */
Selim Cinekf83e8242015-05-19 18:08:14 -0700505 public interface InputConsumer {
Dianne Hackborndf89e652011-10-06 22:35:11 -0700506 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700507 * Remove the input consumer from the window manager.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700508 */
509 void dismiss();
510 }
511
512 /**
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800513 * Holds the contents of a starting window. {@link #addSplashScreen} needs to wrap the
514 * contents of the starting window into an class implementing this interface, which then will be
Jorim Jaggi02886a82016-12-06 09:10:06 -0800515 * held by WM and released with {@link #remove} when no longer needed.
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800516 */
517 interface StartingSurface {
Jorim Jaggi02886a82016-12-06 09:10:06 -0800518
519 /**
520 * Removes the starting window surface. Do not hold the window manager lock when calling
521 * this method!
522 */
523 void remove();
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800524 }
525
526 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700527 * Interface for calling back in to the window manager that is private
528 * between it and the policy.
529 */
530 public interface WindowManagerFuncs {
Jeff Brownac143512012-04-05 18:57:33 -0700531 public static final int LID_ABSENT = -1;
532 public static final int LID_CLOSED = 0;
533 public static final int LID_OPEN = 1;
534
Michael Wright3818c922014-09-02 13:59:07 -0700535 public static final int CAMERA_LENS_COVER_ABSENT = -1;
536 public static final int CAMERA_LENS_UNCOVERED = 0;
537 public static final int CAMERA_LENS_COVERED = 1;
538
Dianne Hackborndf89e652011-10-06 22:35:11 -0700539 /**
540 * Ask the window manager to re-evaluate the system UI flags.
541 */
542 public void reevaluateStatusBarVisibility();
543
544 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700545 * Add a input consumer which will consume all input events going to any window below it.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700546 */
Winson41275482016-10-10 15:17:45 -0700547 public InputConsumer createInputConsumer(Looper looper, String name,
Selim Cinekf83e8242015-05-19 18:08:14 -0700548 InputEventReceiver.Factory inputEventReceiverFactory);
Jeff Brownac143512012-04-05 18:57:33 -0700549
550 /**
551 * Returns a code that describes the current state of the lid switch.
552 */
553 public int getLidState();
554
555 /**
Edward Savage-Jones7def60d2015-11-13 13:27:03 +0100556 * Lock the device now.
557 */
558 public void lockDeviceNow();
559
560 /**
Michael Wright3818c922014-09-02 13:59:07 -0700561 * Returns a code that descripbes whether the camera lens is covered or not.
562 */
563 public int getCameraLensCoverState();
564
565 /**
Yohei Yukawa2d9accb2018-03-07 19:15:15 -0800566 * Switch the keyboard layout for the given device.
567 * Direction should be +1 or -1 to go to the next or previous keyboard layout.
568 */
569 public void switchKeyboardLayout(int deviceId, int direction);
570
571 /**
Yohei Yukawaae61f712015-12-09 13:00:10 -0800572 * Switch the input method, to be precise, input method subtype.
573 *
574 * @param forwardDirection {@code true} to rotate in a forward direction.
575 */
576 public void switchInputMethod(boolean forwardDirection);
577
Jeff Brown9a538ee2012-08-20 14:56:57 -0700578 public void shutdown(boolean confirm);
Alison Cichowlasf8eca402016-08-05 14:50:27 -0400579 public void reboot(boolean confirm);
Jeff Brown9a538ee2012-08-20 14:56:57 -0700580 public void rebootSafeMode(boolean confirm);
John Spurlock04db1762013-05-13 12:46:41 -0400581
582 /**
583 * Return the window manager lock needed to correctly call "Lw" methods.
584 */
585 public Object getWindowManagerLock();
Craig Mautner037aa8d2013-06-07 10:35:44 -0700586
587 /** Register a system listener for touch events */
588 void registerPointerEventListener(PointerEventListener listener);
589
590 /** Unregister a system listener for touch events */
591 void unregisterPointerEventListener(PointerEventListener listener);
Jorim Jaggi81ba11e2016-02-03 22:04:22 -0800592
593 /**
594 * @return The content insets of the docked divider window.
595 */
596 int getDockedDividerInsetsLw();
Jorim Jaggi86905582016-02-09 21:36:09 -0800597
598 /**
Wale Ogunwale68278562017-09-23 17:13:55 -0700599 * Retrieves the {@param outBounds} from the stack matching the {@param windowingMode} and
600 * {@param activityType}.
Jorim Jaggi86905582016-02-09 21:36:09 -0800601 */
Wale Ogunwale68278562017-09-23 17:13:55 -0700602 void getStackBounds(int windowingMode, int activityType, Rect outBounds);
Jorim Jaggi77e10432016-10-26 17:43:56 -0700603
604 /**
605 * Notifies window manager that {@link #isShowingDreamLw} has changed.
606 */
607 void notifyShowingDreamChanged();
Jorim Jaggie69c9312016-10-31 18:24:38 -0700608
609 /**
Jorim Jaggi40db0292016-06-27 17:58:03 -0700610 * @return The currently active input method window.
611 */
612 WindowState getInputMethodWindowLw();
613
614 /**
Jorim Jaggie69c9312016-10-31 18:24:38 -0700615 * Notifies window manager that {@link #isKeyguardTrustedLw} has changed.
616 */
617 void notifyKeyguardTrustedChanged();
Jorim Jaggi51304d72017-05-17 17:25:32 +0200618
619 /**
620 * Notifies the window manager that screen is being turned off.
621 *
622 * @param listener callback to call when display can be turned off
623 */
624 void screenTurningOff(ScreenOffListener listener);
Michael Wright19859762017-09-18 20:57:58 +0100625
626 /**
627 * Convert the lid state to a human readable format.
628 */
629 static String lidStateToString(int lid) {
630 switch (lid) {
631 case LID_ABSENT:
632 return "LID_ABSENT";
633 case LID_CLOSED:
634 return "LID_CLOSED";
635 case LID_OPEN:
636 return "LID_OPEN";
637 default:
638 return Integer.toString(lid);
639 }
640 }
641
642 /**
643 * Convert the camera lens state to a human readable format.
644 */
645 static String cameraLensStateToString(int lens) {
646 switch (lens) {
647 case CAMERA_LENS_COVER_ABSENT:
648 return "CAMERA_LENS_COVER_ABSENT";
649 case CAMERA_LENS_UNCOVERED:
650 return "CAMERA_LENS_UNCOVERED";
651 case CAMERA_LENS_COVERED:
652 return "CAMERA_LENS_COVERED";
653 default:
654 return Integer.toString(lens);
655 }
656 }
Adrian Roos842e7882018-03-26 17:34:06 +0200657
658 /**
659 * Hint to window manager that the user has started a navigation action that should
660 * abort animations that have no timeout, in case they got stuck.
661 */
662 void triggerAnimationFailsafe();
Adrian Roos4163d622018-05-22 16:56:35 +0200663
664 /**
665 * The keyguard showing state has changed
666 */
667 void onKeyguardShowingAndNotOccludedChanged();
Craig Mautner037aa8d2013-06-07 10:35:44 -0700668 }
669
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 /** Window has been added to the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800671 public static final int TRANSIT_ENTER = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800672 /** Window has been removed from the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800673 public static final int TRANSIT_EXIT = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800674 /** Window has been made visible. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800675 public static final int TRANSIT_SHOW = 3;
676 /** Window has been made invisible.
677 * TODO: Consider removal as this is unused. */
678 public static final int TRANSIT_HIDE = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800679 /** The "application starting" preview window is no longer needed, and will
680 * animate away to show the real window. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800681 public static final int TRANSIT_PREVIEW_DONE = 5;
682
Dianne Hackborn254cb442010-01-27 19:23:59 -0800683 // NOTE: screen off reasons are in order of significance, with more
684 // important ones lower than less important ones.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700685
Tor Norbyed9273d62013-05-30 15:59:53 -0700686 /** @hide */
687 @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED})
688 @Retention(RetentionPolicy.SOURCE)
689 public @interface UserRotationMode {}
690
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400691 /** When not otherwise specified by the activity's screenOrientation, rotation should be
692 * determined by the system (that is, using sensors). */
693 public final int USER_ROTATION_FREE = 0;
694 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
695 * the user. */
696 public final int USER_ROTATION_LOCKED = 1;
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700697
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800698 /**
699 * Perform initialization of the policy.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700700 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800701 * @param context The system context we are running in.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800702 */
703 public void init(Context context, IWindowManager windowManager,
Jeff Brown96307042012-07-27 15:51:34 -0700704 WindowManagerFuncs windowManagerFuncs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800705
706 /**
Craig Mautner46ac6fa2013-08-01 10:06:34 -0700707 * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true.
708 */
709 public boolean isDefaultOrientationForced();
710
711 /**
Dianne Hackborn9d132642011-04-21 17:26:39 -0700712 * Called by window manager once it has the initial, default native
713 * display dimensions.
714 */
Dianne Hackborndde331c2012-08-03 14:01:57 -0700715 public void setInitialDisplaySize(Display display, int width, int height, int density);
Dianne Hackborndacea8c2011-04-21 17:26:39 -0700716
Dianne Hackborn9d132642011-04-21 17:26:39 -0700717 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800718 * Check permissions when adding a window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700719 *
Dianne Hackbornc2293022013-02-06 23:14:49 -0800720 * @param attrs The window's LayoutParams.
721 * @param outAppOp First element will be filled with the app op corresponding to
722 * this window, or OP_NONE.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700723 *
Jeff Brown98365d72012-08-19 20:30:52 -0700724 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800725 * else an error code, usually
Jeff Brown98365d72012-08-19 20:30:52 -0700726 * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800727 */
Dianne Hackbornc2293022013-02-06 23:14:49 -0800728 public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800729
730 /**
Craig Mautner88400d32012-09-30 12:35:45 -0700731 * Check permissions when adding a window.
732 *
733 * @param attrs The window's LayoutParams.
734 *
735 * @return True if the window may only be shown to the current user, false if the window can
736 * be shown on all users' windows.
737 */
738 public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
739
740 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800741 * Sanitize the layout parameters coming from a client. Allows the policy
742 * to do things like ensure that windows of a specific type can't take
743 * input focus.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700744 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800745 * @param attrs The window layout parameters to be modified. These values
746 * are modified in-place.
747 */
Wale Ogunwalec0b0f932017-11-01 12:51:43 -0700748 public void adjustWindowParamsLw(WindowState win, WindowManager.LayoutParams attrs,
749 boolean hasStatusBarServicePermission);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700750
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800751 /**
752 * After the window manager has computed the current configuration based
753 * on its knowledge of the display and input devices, it gives the policy
754 * a chance to adjust the information contained in it. If you want to
755 * leave it as-is, simply do nothing.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700756 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800757 * <p>This method may be called by any thread in the window manager, but
758 * no internal locks in the window manager will be held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700759 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 * @param config The Configuration being computed, for you to change as
761 * desired.
Jeff Browndaa37532012-05-01 15:54:03 -0700762 * @param keyboardPresence Flags that indicate whether internal or external
763 * keyboards are present.
764 * @param navigationPresence Flags that indicate whether internal or external
765 * navigation devices are present.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800766 */
Jeff Browndaa37532012-05-01 15:54:03 -0700767 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
768 int navigationPresence);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700769
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800770 /**
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800771 * Returns the layer assignment for the window state. Allows you to control how different
772 * kinds of windows are ordered on-screen.
773 *
774 * @param win The window state
775 * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
776 */
777 default int getWindowLayerLw(WindowState win) {
778 return getWindowLayerFromTypeLw(win.getBaseType(), win.canAddInternalSystemWindow());
779 }
780
781 /**
782 * Returns the layer assignment for the window type. Allows you to control how different
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800783 * kinds of windows are ordered on-screen.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700784 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800785 * @param type The type of window being assigned.
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800786 * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800787 */
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800788 default int getWindowLayerFromTypeLw(int type) {
789 if (isSystemAlertWindowType(type)) {
790 throw new IllegalArgumentException("Use getWindowLayerFromTypeLw() or"
791 + " getWindowLayerLw() for alert window types");
792 }
793 return getWindowLayerFromTypeLw(type, false /* canAddInternalSystemWindow */);
794 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800795
796 /**
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800797 * Returns the layer assignment for the window type. Allows you to control how different
798 * kinds of windows are ordered on-screen.
799 *
800 * @param type The type of window being assigned.
801 * @param canAddInternalSystemWindow If the owner window associated with the type we are
802 * evaluating can add internal system windows. I.e they have
Adrian Roose99bc052017-11-20 17:55:31 +0100803 * {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}. If true, alert window
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800804 * types {@link android.view.WindowManager.LayoutParams#isSystemAlertWindowType(int)}
805 * can be assigned layers greater than the layer for
806 * {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} Else, their
807 * layers would be lesser.
808 * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
809 */
810 default int getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow) {
811 if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
812 return APPLICATION_LAYER;
813 }
814
815 switch (type) {
816 case TYPE_WALLPAPER:
817 // wallpaper is at the bottom, though the window manager may move it.
818 return 1;
819 case TYPE_PRESENTATION:
820 case TYPE_PRIVATE_PRESENTATION:
821 return APPLICATION_LAYER;
822 case TYPE_DOCK_DIVIDER:
823 return APPLICATION_LAYER;
824 case TYPE_QS_DIALOG:
825 return APPLICATION_LAYER;
826 case TYPE_PHONE:
827 return 3;
828 case TYPE_SEARCH_BAR:
829 case TYPE_VOICE_INTERACTION_STARTING:
830 return 4;
831 case TYPE_VOICE_INTERACTION:
832 // voice interaction layer is almost immediately above apps.
833 return 5;
834 case TYPE_INPUT_CONSUMER:
835 return 6;
836 case TYPE_SYSTEM_DIALOG:
837 return 7;
838 case TYPE_TOAST:
839 // toasts and the plugged-in battery thing
840 return 8;
841 case TYPE_PRIORITY_PHONE:
842 // SIM errors and unlock. Not sure if this really should be in a high layer.
843 return 9;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800844 case TYPE_SYSTEM_ALERT:
845 // like the ANR / app crashed dialogs
846 return canAddInternalSystemWindow ? 11 : 10;
847 case TYPE_APPLICATION_OVERLAY:
Wale Ogunwaled993a572017-02-05 13:52:09 -0800848 return 12;
849 case TYPE_DREAM:
850 // used for Dreams (screensavers with TYPE_DREAM windows)
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800851 return 13;
852 case TYPE_INPUT_METHOD:
853 // on-screen keyboards and other such input method user interfaces go here.
854 return 14;
855 case TYPE_INPUT_METHOD_DIALOG:
856 // on-screen keyboards and other such input method user interfaces go here.
857 return 15;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800858 case TYPE_STATUS_BAR:
Robert Carr8360a782017-11-22 12:47:58 -0800859 return 17;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800860 case TYPE_STATUS_BAR_PANEL:
Robert Carr8360a782017-11-22 12:47:58 -0800861 return 18;
862 case TYPE_STATUS_BAR_SUB_PANEL:
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800863 return 19;
864 case TYPE_KEYGUARD_DIALOG:
865 return 20;
866 case TYPE_VOLUME_OVERLAY:
867 // the on-screen volume indicator and controller shown when the user
868 // changes the device volume
869 return 21;
870 case TYPE_SYSTEM_OVERLAY:
871 // the on-screen volume indicator and controller shown when the user
872 // changes the device volume
873 return canAddInternalSystemWindow ? 22 : 11;
874 case TYPE_NAVIGATION_BAR:
875 // the navigation bar, if available, shows atop most things
876 return 23;
877 case TYPE_NAVIGATION_BAR_PANEL:
878 // some panels (e.g. search) need to show on top of the navigation bar
879 return 24;
880 case TYPE_SCREENSHOT:
881 // screenshot selection layer shouldn't go above system error, but it should cover
882 // navigation bars at the very least.
883 return 25;
884 case TYPE_SYSTEM_ERROR:
885 // system-level error dialogs
886 return canAddInternalSystemWindow ? 26 : 10;
887 case TYPE_MAGNIFICATION_OVERLAY:
888 // used to highlight the magnified portion of a display
889 return 27;
890 case TYPE_DISPLAY_OVERLAY:
891 // used to simulate secondary display devices
892 return 28;
893 case TYPE_DRAG:
894 // the drag layer: input for drag-and-drop is associated with this window,
895 // which sits above all other focusable windows
896 return 29;
897 case TYPE_ACCESSIBILITY_OVERLAY:
898 // overlay put by accessibility services to intercept user interaction
899 return 30;
900 case TYPE_SECURE_SYSTEM_OVERLAY:
901 return 31;
902 case TYPE_BOOT_PROGRESS:
903 return 32;
904 case TYPE_POINTER:
905 // the (mouse) pointer layer
906 return 33;
907 default:
908 Slog.e("WindowManager", "Unknown window type: " + type);
909 return APPLICATION_LAYER;
910 }
911 }
912
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800913 /**
914 * Return how to Z-order sub-windows in relation to the window they are attached to.
915 * Return positive to have them ordered in front, negative for behind.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700916 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800917 * @param type The sub-window type code.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700918 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800919 * @return int Layer in relation to the attached window, where positive is
920 * above and negative is below.
921 */
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800922 default int getSubWindowLayerFromTypeLw(int type) {
923 switch (type) {
924 case TYPE_APPLICATION_PANEL:
925 case TYPE_APPLICATION_ATTACHED_DIALOG:
926 return APPLICATION_PANEL_SUBLAYER;
927 case TYPE_APPLICATION_MEDIA:
928 return APPLICATION_MEDIA_SUBLAYER;
929 case TYPE_APPLICATION_MEDIA_OVERLAY:
930 return APPLICATION_MEDIA_OVERLAY_SUBLAYER;
931 case TYPE_APPLICATION_SUB_PANEL:
932 return APPLICATION_SUB_PANEL_SUBLAYER;
933 case TYPE_APPLICATION_ABOVE_SUB_PANEL:
934 return APPLICATION_ABOVE_SUB_PANEL_SUBLAYER;
935 }
936 Slog.e("WindowManager", "Unknown sub-window type: " + type);
937 return 0;
938 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800939
940 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700941 * Get the highest layer (actually one more than) that the wallpaper is
942 * allowed to be in.
943 */
944 public int getMaxWallpaperLayer();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700945
946 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700947 * Return the display width available after excluding any screen
Jorim Jaggi82c9dc92016-02-05 15:10:33 -0800948 * decorations that could never be removed in Honeycomb. That is, system bar or
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700949 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400950 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800951 public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation,
Adrian Roos11c25582018-02-19 18:06:36 +0100952 int uiMode, int displayId, DisplayCutout displayCutout);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400953
954 /**
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700955 * Return the display height available after excluding any screen
Jorim Jaggi82c9dc92016-02-05 15:10:33 -0800956 * decorations that could never be removed in Honeycomb. That is, system bar or
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700957 * button bar.
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400958 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800959 public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation,
Adrian Roos11c25582018-02-19 18:06:36 +0100960 int uiMode, int displayId, DisplayCutout displayCutout);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700961
962 /**
963 * Return the available screen width that we should report for the
964 * configuration. This must be no larger than
Adrian Roos11c25582018-02-19 18:06:36 +0100965 * {@link #getNonDecorDisplayWidth(int, int, int, int, int, DisplayCutout)}; it may be smaller
966 * than that to account for more transient decoration like a status bar.
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700967 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800968 public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation,
Adrian Roos11c25582018-02-19 18:06:36 +0100969 int uiMode, int displayId, DisplayCutout displayCutout);
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700970
971 /**
972 * Return the available screen height that we should report for the
973 * configuration. This must be no larger than
Adrian Roos11c25582018-02-19 18:06:36 +0100974 * {@link #getNonDecorDisplayHeight(int, int, int, int, int, DisplayCutout)}; it may be smaller
975 * than that to account for more transient decoration like a status bar.
Dianne Hackborn69cb8752011-05-19 18:13:32 -0700976 */
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -0800977 public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation,
Adrian Roos11c25582018-02-19 18:06:36 +0100978 int uiMode, int displayId, DisplayCutout displayCutout);
Dianne Hackborne2515ee2011-04-27 18:52:56 -0400979
980 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200981 * Return whether the given window can become the Keyguard window. Typically returns true for
982 * the StatusBar.
Jorim Jaggi0d674622014-05-21 01:34:15 +0200983 */
984 public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs);
985
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700986 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200987 * @return whether {@param win} can be hidden by Keyguard
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700988 */
Jorim Jaggife762342016-10-13 14:33:27 +0200989 public boolean canBeHiddenByKeyguardLw(WindowState win);
Craig Mautner7d7808f2014-09-11 18:02:38 -0700990
991 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800992 * Called when the system would like to show a UI to indicate that an
993 * application is starting. You can use this to add a
994 * APPLICATION_STARTING_TYPE window with the given appToken to the window
995 * manager (using the normal window manager APIs) that will be shown until
996 * the application displays its own window. This is called without the
997 * window manager locked so that you can call back into it.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700998 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800999 * @param appToken Token of the application being started.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001000 * @param packageName The name of the application package being started.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001001 * @param theme Resource defining the application's overall visual theme.
1002 * @param nonLocalizedLabel The default title label of the application if
1003 * no data is found in the resource.
1004 * @param labelRes The resource ID the application would like to use as its name.
1005 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -08001006 * @param windowFlags Window layout flags.
Wale Ogunwaledfc18622016-04-16 15:08:48 -07001007 * @param overrideConfig override configuration to consider when generating
1008 * context to for resources.
Andrii Kulianfb1bf692017-01-17 11:17:34 -08001009 * @param displayId Id of the display to show the splash screen at.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001010 *
Jorim Jaggi02886a82016-12-06 09:10:06 -08001011 * @return The starting surface.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001012 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001013 */
Jorim Jaggiba41f4b2016-12-14 17:43:07 -08001014 public StartingSurface addSplashScreen(IBinder appToken, String packageName, int theme,
1015 CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon,
Andrii Kulianfb1bf692017-01-17 11:17:34 -08001016 int logo, int windowFlags, Configuration overrideConfig, int displayId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001017
1018 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001019 * Prepare for a window being added to the window manager. You can throw an
1020 * exception here to prevent the window being added, or do whatever setup
1021 * you need to keep track of the window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001022 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001023 * @param win The window being added.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001024 * @param attrs The window's LayoutParams.
1025 *
Jeff Brown98365d72012-08-19 20:30:52 -07001026 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001027 * error code to abort the add.
1028 */
1029 public int prepareAddWindowLw(WindowState win,
1030 WindowManager.LayoutParams attrs);
1031
1032 /**
1033 * Called when a window is being removed from a window manager. Must not
1034 * throw an exception -- clean up as much as possible.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001035 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001036 * @param win The window being removed.
1037 */
1038 public void removeWindowLw(WindowState win);
1039
1040 /**
1041 * Control the animation to run when a window's state changes. Return a
1042 * non-0 number to force the animation to a specific resource ID, or 0
1043 * to use the default animation.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001044 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001045 * @param win The window that is changing.
1046 * @param transit What is happening to the window: {@link #TRANSIT_ENTER},
1047 * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or
1048 * {@link #TRANSIT_HIDE}.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001049 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001050 * @return Resource ID of the actual animation to use, or 0 for none.
1051 */
1052 public int selectAnimationLw(WindowState win, int transit);
1053
1054 /**
Craig Mautner3c174372013-02-21 17:54:37 -08001055 * Determine the animation to run for a rotation transition based on the
1056 * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation}
1057 * and whether it is currently fullscreen and frontmost.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001058 *
1059 * @param anim The exiting animation resource id is stored in anim[0], the
Craig Mautner3c174372013-02-21 17:54:37 -08001060 * entering animation resource id is stored in anim[1].
1061 */
1062 public void selectRotationAnimationLw(int anim[]);
1063
1064 /**
1065 * Validate whether the current top fullscreen has specified the same
1066 * {@link WindowManager.LayoutParams#rotationAnimation} value as that
1067 * being passed in from the previous top fullscreen window.
1068 *
1069 * @param exitAnimId exiting resource id from the previous window.
1070 * @param enterAnimId entering resource id from the previous window.
1071 * @param forceDefault For rotation animations only, if true ignore the
1072 * animation values and just return false.
1073 * @return true if the previous values are still valid, false if they
1074 * should be replaced with the default.
1075 */
1076 public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId,
1077 boolean forceDefault);
1078
1079 /**
Jorim Jaggife762342016-10-13 14:33:27 +02001080 * Create and return an animation to re-display a window that was force hidden by Keyguard.
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001081 */
Jorim Jaggife762342016-10-13 14:33:27 +02001082 public Animation createHiddenByKeyguardExit(boolean onWallpaper,
Jorim Jaggi84a3e7a2014-08-13 17:58:58 +02001083 boolean goingToNotificationShade);
Jorim Jaggi76a16232014-08-08 17:00:47 +02001084
1085 /**
Jorim Jaggife762342016-10-13 14:33:27 +02001086 * Create and return an animation to let the wallpaper disappear after being shown behind
1087 * Keyguard.
Jorim Jaggi76a16232014-08-08 17:00:47 +02001088 */
Jorim Jaggife762342016-10-13 14:33:27 +02001089 public Animation createKeyguardWallpaperExit(boolean goingToNotificationShade);
Jorim Jaggi76a16232014-08-08 17:00:47 +02001090
Dianne Hackborn3b3e1452009-09-24 19:22:12 -07001091 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001092 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001093 *
1094 * <p>There are some actions that need to be handled here because they
1095 * affect the power state of the device, for example, the power keys.
1096 * Generally, it's best to keep as little as possible in the queue thread
1097 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -08001098 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001099 * @param policyFlags The policy flags associated with the key.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001100 *
Jeff Brown26875502014-01-30 21:47:47 -08001101 * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001102 */
Jeff Brown037c33e2014-04-09 00:31:55 -07001103 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -08001104
1105 /**
Michael Wright70af00a2014-09-03 19:30:20 -07001106 * Called from the input reader thread before a motion is enqueued when the device is in a
1107 * non-interactive state.
Jeff Brown56194eb2011-03-02 19:23:13 -08001108 *
1109 * <p>There are some actions that need to be handled here because they
1110 * affect the power state of the device, for example, waking on motions.
1111 * Generally, it's best to keep as little as possible in the queue thread
1112 * because it's the most fragile.
1113 * @param policyFlags The policy flags associated with the motion.
1114 *
Jeff Brown26875502014-01-30 21:47:47 -08001115 * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
Jeff Brown56194eb2011-03-02 19:23:13 -08001116 */
Michael Wright70af00a2014-09-03 19:30:20 -07001117 public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -08001118
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001119 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001120 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001121 *
1122 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -07001123 * behavior for keys that can not be overridden by applications.
1124 * This method is called from the input thread, with no locks held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001125 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001126 * @param win The window that currently has focus. This is where the key
1127 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -08001128 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001129 * @param policyFlags The policy flags associated with the key.
Jeff Brownd5bb82d2011-10-12 13:57:59 -07001130 * @return 0 if the key should be dispatched immediately, -1 if the key should
1131 * not be dispatched ever, or a positive value indicating the number of
1132 * milliseconds by which the key dispatch should be delayed before trying
1133 * again.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001134 */
Jeff Brownd5bb82d2011-10-12 13:57:59 -07001135 public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001136
1137 /**
Jeff Brown3915bb82010-11-05 15:02:16 -07001138 * Called from the input dispatcher thread when an application did not handle
1139 * a key that was dispatched to it.
1140 *
1141 * <p>Allows you to define default global behavior for keys that were not handled
1142 * by applications. This method is called from the input thread, with no locks held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001143 *
Jeff Brown3915bb82010-11-05 15:02:16 -07001144 * @param win The window that currently has focus. This is where the key
1145 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -08001146 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -07001147 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -08001148 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
1149 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -07001150 */
Jeff Brown49ed71d2010-12-06 17:13:33 -08001151 public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -07001152
1153 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001154 * Called when layout of the windows is about to start.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001155 *
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001156 * @param displayFrames frames of the display we are doing layout on.
Sriram Viswanathan9ebbe6a2015-11-16 17:59:22 -08001157 * @param uiMode The current uiMode in configuration.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001158 */
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001159 default void beginLayoutLw(DisplayFrames displayFrames, int uiMode) {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001160
1161 /**
John Spurlock46646232013-09-30 22:32:42 -04001162 * Returns the bottom-most layer of the system decor, above which no policy decor should
1163 * be applied.
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001164 */
John Spurlock46646232013-09-30 22:32:42 -04001165 public int getSystemDecorLayerLw();
Dianne Hackborn85afd1b2012-05-13 13:31:06 -07001166
1167 /**
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001168 * Called for each window attached to the window manager as layout is proceeding. The
1169 * implementation of this function must take care of setting the window's frame, either here or
1170 * in finishLayout().
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001171 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001172 * @param win The window being positioned.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001173 * @param attached For sub-windows, the window it is attached to; this
1174 * window will already have had layoutWindow() called on it
1175 * so you can use its Rect. Otherwise null.
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001176 * @param displayFrames The display frames.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001177 */
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001178 default void layoutWindowLw(
1179 WindowState win, WindowState attached, DisplayFrames displayFrames) {}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001180
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001181
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001182 /**
Adrian Roos9e370f22018-03-06 18:19:45 +01001183 * Return the layout hints for a newly added window. These values are computed on the
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001184 * most recent layout, so they are not guaranteed to be correct.
Adrian Roos37d7a682014-11-06 18:15:16 +01001185 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001186 * @param attrs The LayoutParams of the window.
Jorim Jaggi23bf5462016-05-13 15:24:39 -07001187 * @param taskBounds The bounds of the task this window is on or {@code null} if no task is
1188 * associated with the window.
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001189 * @param displayFrames display frames.
Adrian Roos9e370f22018-03-06 18:19:45 +01001190 * @param outFrame The frame of the window.
Adrian Roos37d7a682014-11-06 18:15:16 +01001191 * @param outContentInsets The areas covered by system windows, expressed as positive insets.
1192 * @param outStableInsets The areas covered by stable system windows irrespective of their
1193 * current visibility. Expressed as positive insets.
Filip Gruszczynski0ec13282015-06-25 11:26:01 -07001194 * @param outOutsets The areas that are not real display, but we would like to treat as such.
Adrian Roos5c6b6222017-11-07 17:36:10 +01001195 * @param outDisplayCutout The area that has been cut away from the display.
Jorim Jaggi0ffd49c2016-02-12 15:04:21 -08001196 * @return Whether to always consume the navigation bar.
1197 * See {@link #isNavBarForcedShownLw(WindowState)}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001198 */
Adrian Roos9e370f22018-03-06 18:19:45 +01001199 default boolean getLayoutHintLw(WindowManager.LayoutParams attrs, Rect taskBounds,
1200 DisplayFrames displayFrames, Rect outFrame, Rect outContentInsets,
1201 Rect outStableInsets, Rect outOutsets,
1202 DisplayCutout.ParcelableWrapper outDisplayCutout) {
Wale Ogunwale828ff7e2017-11-14 01:01:29 +00001203 return false;
1204 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001205
1206 /**
Craig Mautner39834192012-09-02 07:47:24 -07001207 * Called following layout of all windows before each window has policy applied.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001208 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001209 * @param displayWidth The current full width of the screen.
1210 * @param displayHeight The current full height of the screen.
1211 */
Craig Mautner39834192012-09-02 07:47:24 -07001212 public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001213
1214 /**
Craig Mautner39834192012-09-02 07:47:24 -07001215 * Called following layout of all window to apply policy to each window.
Yohei Yukawad1a09222015-06-30 16:22:05 -07001216 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001217 * @param win The window being positioned.
Yohei Yukawad1a09222015-06-30 16:22:05 -07001218 * @param attrs The LayoutParams of the window.
1219 * @param attached For sub-windows, the window it is attached to. Otherwise null.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001220 */
Craig Mautner39834192012-09-02 07:47:24 -07001221 public void applyPostLayoutPolicyLw(WindowState win,
Jorim Jaggife762342016-10-13 14:33:27 +02001222 WindowManager.LayoutParams attrs, WindowState attached, WindowState imeTarget);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001223
1224 /**
Craig Mautner39834192012-09-02 07:47:24 -07001225 * Called following layout of all windows and after policy has been applied
1226 * to each window. If in this function you do
1227 * something that may have modified the animation state of another window,
1228 * be sure to return non-zero in order to perform another pass through layout.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001229 *
Dianne Hackbornb8b11a02010-03-10 15:53:11 -08001230 * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT},
1231 * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER},
1232 * or {@link #FINISH_LAYOUT_REDO_ANIM}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001233 */
Craig Mautner39834192012-09-02 07:47:24 -07001234 public int finishPostLayoutPolicyLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001235
1236 /**
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001237 * Return true if it is okay to perform animations for an app transition
Jorim Jaggif84e2f62018-01-16 14:17:59 +01001238 * that is about to occur. You may return false for this if, for example,
1239 * the dream window is currently displayed so the switch should happen
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001240 * immediately.
1241 */
1242 public boolean allowAppAnimationsLw();
Joe Onorato664644d2011-01-23 17:53:23 -08001243
Joe Onorato664644d2011-01-23 17:53:23 -08001244 /**
1245 * A new window has been focused.
1246 */
Dianne Hackborndf89e652011-10-06 22:35:11 -07001247 public int focusChangedLw(WindowState lastFocus, WindowState newFocus);
Jeff Brown36c4db82014-09-19 12:05:31 -07001248
1249 /**
Jeff Brown416c49c2015-05-26 19:50:18 -07001250 * Called when the device has started waking up.
Jeff Brown36c4db82014-09-19 12:05:31 -07001251 */
Jeff Brown416c49c2015-05-26 19:50:18 -07001252 public void startedWakingUp();
Jeff Brown36c4db82014-09-19 12:05:31 -07001253
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001254 /**
Jeff Brown416c49c2015-05-26 19:50:18 -07001255 * Called when the device has finished waking up.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001256 */
Jeff Brown416c49c2015-05-26 19:50:18 -07001257 public void finishedWakingUp();
1258
1259 /**
1260 * Called when the device has started going to sleep.
1261 *
1262 * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1263 * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1264 */
1265 public void startedGoingToSleep(int why);
1266
1267 /**
1268 * Called when the device has finished going to sleep.
1269 *
1270 * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1271 * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1272 */
1273 public void finishedGoingToSleep(int why);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001274
Jeff Brown36c4db82014-09-19 12:05:31 -07001275 /**
1276 * Called when the device is about to turn on the screen to show content.
1277 * When waking up, this method will be called once after the call to wakingUp().
1278 * When dozing, the method will be called sometime after the call to goingToSleep() and
1279 * may be called repeatedly in the case where the screen is pulsing on and off.
1280 *
1281 * Must call back on the listener to tell it when the higher-level system
1282 * is ready for the screen to go on (i.e. the lock screen is shown).
1283 */
1284 public void screenTurningOn(ScreenOnListener screenOnListener);
1285
Jeff Brown3ee549c2014-09-22 20:14:39 -07001286 /**
Jorim Jaggi0d210f62015-07-10 14:24:44 -07001287 * Called when the device has actually turned on the screen, i.e. the display power state has
1288 * been set to ON and the screen is unblocked.
1289 */
1290 public void screenTurnedOn();
1291
1292 /**
Jorim Jaggi51304d72017-05-17 17:25:32 +02001293 * Called when the display would like to be turned off. This gives policy a chance to do some
1294 * things before the display power state is actually changed to off.
1295 *
1296 * @param screenOffListener Must be called to tell that the display power state can actually be
1297 * changed now after policy has done its work.
1298 */
1299 public void screenTurningOff(ScreenOffListener screenOffListener);
1300
1301 /**
Jeff Brown3ee549c2014-09-22 20:14:39 -07001302 * Called when the device has turned the screen off.
1303 */
1304 public void screenTurnedOff();
1305
Dianne Hackborn38e29a62011-09-18 14:43:08 -07001306 public interface ScreenOnListener {
1307 void onScreenOn();
Craig Mautner61ac6bb2012-02-02 17:29:33 -08001308 }
Dianne Hackborn38e29a62011-09-18 14:43:08 -07001309
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001310 /**
Jorim Jaggi51304d72017-05-17 17:25:32 +02001311 * See {@link #screenTurnedOff}
1312 */
1313 public interface ScreenOffListener {
1314 void onScreenOff();
1315 }
1316
1317 /**
Jeff Brown3ee549c2014-09-22 20:14:39 -07001318 * Return whether the default display is on and not blocked by a black surface.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001319 */
Jeff Brown3ee549c2014-09-22 20:14:39 -07001320 public boolean isScreenOn();
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001321
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001322 /**
Adrian Roos7c894802017-07-19 12:25:34 +02001323 * @return whether the device is currently allowed to animate.
Adrian Roose94c15c2017-05-09 13:17:54 -07001324 *
Adrian Roos7c894802017-07-19 12:25:34 +02001325 * Note: this can be true even if it is not appropriate to animate for reasons that are outside
1326 * of the policy's authority.
Adrian Roose94c15c2017-05-09 13:17:54 -07001327 */
Adrian Roos7c894802017-07-19 12:25:34 +02001328 boolean okToAnimate();
Adrian Roose94c15c2017-05-09 13:17:54 -07001329
1330 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001331 * Tell the policy that the lid switch has changed state.
1332 * @param whenNanos The time when the change occurred in uptime nanoseconds.
1333 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001334 */
Jeff Brown46b9ac02010-04-22 18:58:52 -07001335 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
Michael Wright3818c922014-09-02 13:59:07 -07001336
1337 /**
1338 * Tell the policy that the camera lens has been covered or uncovered.
1339 * @param whenNanos The time when the change occurred in uptime nanoseconds.
1340 * @param lensCovered True if the lens is covered.
1341 */
1342 public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered);
1343
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001344 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001345 * Tell the policy if anyone is requesting that keyguard not come on.
1346 *
1347 * @param enabled Whether keyguard can be on or not. does not actually
1348 * turn it on, unless it was previously disabled with this function.
1349 *
1350 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
1351 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
1352 */
Craig Mautner3c174372013-02-21 17:54:37 -08001353 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001354 public void enableKeyguard(boolean enabled);
1355
1356 /**
Adrian Roose99bc052017-11-20 17:55:31 +01001357 * Callback used by {@link #exitKeyguardSecurely}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001358 */
1359 interface OnKeyguardExitResult {
1360 void onKeyguardExitResult(boolean success);
1361 }
1362
1363 /**
1364 * Tell the policy if anyone is requesting the keyguard to exit securely
1365 * (this would be called after the keyguard was disabled)
1366 * @param callback Callback to send the result back.
1367 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
1368 */
Craig Mautner3c174372013-02-21 17:54:37 -08001369 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001370 void exitKeyguardSecurely(OnKeyguardExitResult callback);
1371
1372 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -05001373 * isKeyguardLocked
1374 *
1375 * Return whether the keyguard is currently locked.
1376 *
1377 * @return true if in keyguard is locked.
1378 */
1379 public boolean isKeyguardLocked();
1380
1381 /**
1382 * isKeyguardSecure
1383 *
1384 * Return whether the keyguard requires a password to unlock.
Jim Millere4044bb2016-05-10 18:38:25 -07001385 * @param userId
Mike Lockwood520d8bc2011-02-18 13:23:13 -05001386 *
1387 * @return true if in keyguard is secure.
1388 */
Jim Millere4044bb2016-05-10 18:38:25 -07001389 public boolean isKeyguardSecure(int userId);
Mike Lockwood520d8bc2011-02-18 13:23:13 -05001390
1391 /**
Jorim Jaggife762342016-10-13 14:33:27 +02001392 * Return whether the keyguard is currently occluded.
Adrian Roos461829d2015-06-03 14:41:18 -07001393 *
Jorim Jaggife762342016-10-13 14:33:27 +02001394 * @return true if in keyguard is occluded, false otherwise
Adrian Roos461829d2015-06-03 14:41:18 -07001395 */
Jorim Jaggife762342016-10-13 14:33:27 +02001396 public boolean isKeyguardOccluded();
Adrian Roos461829d2015-06-03 14:41:18 -07001397
1398 /**
Tony Mak2c0d6dc2016-04-29 16:16:54 +01001399 * @return true if in keyguard is on and not occluded.
1400 */
1401 public boolean isKeyguardShowingAndNotOccluded();
1402
1403 /**
Jorim Jaggife762342016-10-13 14:33:27 +02001404 * @return whether Keyguard is in trusted state and can be dismissed without credentials
1405 */
1406 public boolean isKeyguardTrustedLw();
1407
1408 /**
Siarhei Vishniakou35fbb312017-12-13 13:48:50 -08001409 * inKeyguardRestrictedKeyInputMode
1410 *
1411 * If keyguard screen is showing or in restricted key input mode (i.e. in
1412 * keyguard password emergency screen). When in such mode, certain keys,
1413 * such as the Home key and the right soft keys, don't work.
1414 *
1415 * @return true if in keyguard restricted input mode.
1416 */
1417 public boolean inKeyguardRestrictedKeyInputMode();
1418
1419 /**
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001420 * Ask the policy to dismiss the keyguard, if it is currently shown.
Jorim Jaggi241ae102016-11-02 21:57:33 -07001421 *
1422 * @param callback Callback to be informed about the result.
Lucas Dupinc80c67e2017-12-04 14:29:10 -08001423 * @param message A message that should be displayed in the keyguard.
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001424 */
Lucas Dupinc80c67e2017-12-04 14:29:10 -08001425 public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback,
1426 CharSequence message);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001427
1428 /**
Jorim Jaggicff0acb2014-03-31 16:35:15 +02001429 * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
1430 * returns true as soon as we know that Keyguard is disabled.
1431 *
1432 * @return true if the keyguard has drawn.
1433 */
1434 public boolean isKeyguardDrawnLw();
1435
Jorim Jaggi77e10432016-10-26 17:43:56 -07001436 public boolean isShowingDreamLw();
1437
Jorim Jaggicff0acb2014-03-31 16:35:15 +02001438 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001439 * Given an orientation constant, returns the appropriate surface rotation,
1440 * taking into account sensors, docking mode, rotation lock, and other factors.
1441 *
1442 * @param orientation An orientation constant, such as
1443 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1444 * @param lastRotation The most recently used rotation.
Andrii Kulianef5ce1c2018-03-20 19:27:24 -07001445 * @param defaultDisplay Flag indicating whether the rotation is computed for the default
1446 * display. Currently for all non-default displays sensors, docking mode,
1447 * rotation lock and other factors are ignored.
Jeff Brown01a98dd2011-09-20 15:08:29 -07001448 * @return The surface rotation to use.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001449 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001450 public int rotationForOrientationLw(@ActivityInfo.ScreenOrientation int orientation,
Andrii Kulianef5ce1c2018-03-20 19:27:24 -07001451 int lastRotation, boolean defaultDisplay);
Jeff Brown01a98dd2011-09-20 15:08:29 -07001452
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001453 /**
Jeff Brown01a98dd2011-09-20 15:08:29 -07001454 * Given an orientation constant and a rotation, returns true if the rotation
1455 * has compatible metrics to the requested orientation. For example, if
1456 * the application requested landscape and got seascape, then the rotation
1457 * has compatible metrics; if the application requested portrait and got landscape,
1458 * then the rotation has incompatible metrics; if the application did not specify
1459 * a preference, then anything goes.
1460 *
1461 * @param orientation An orientation constant, such as
1462 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}.
1463 * @param rotation The rotation to check.
1464 * @return True if the rotation is compatible with the requested orientation.
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001465 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001466 public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation int orientation,
1467 int rotation);
Dianne Hackborndacea8c2011-04-21 17:26:39 -07001468
1469 /**
Jeff Brownc0347aa2011-09-23 17:26:09 -07001470 * Called by the window manager when the rotation changes.
1471 *
1472 * @param rotation The new rotation.
1473 */
1474 public void setRotationLw(int rotation);
1475
1476 /**
Jeff Brownac143512012-04-05 18:57:33 -07001477 * Called when the system is mostly done booting to set whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001478 * the system should go into safe mode.
1479 */
Jeff Brownac143512012-04-05 18:57:33 -07001480 public void setSafeMode(boolean safeMode);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001481
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001482 /**
1483 * Called when the system is mostly done booting.
1484 */
1485 public void systemReady();
1486
1487 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -07001488 * Called when the system is done booting to the point where the
1489 * user can start interacting with it.
1490 */
1491 public void systemBooted();
1492
1493 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001494 * Show boot time message to the user.
1495 */
1496 public void showBootMessage(final CharSequence msg, final boolean always);
1497
1498 /**
1499 * Hide the UI for showing boot messages, never to be displayed again.
1500 */
1501 public void hideBootMessages();
1502
1503 /**
Mike Lockwoodef731622010-01-27 17:51:34 -05001504 * Called when userActivity is signalled in the power manager.
1505 * This is safe to call from any thread, with any window manager locks held or not.
1506 */
1507 public void userActivity();
1508
1509 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001510 * Called when we have finished booting and can now display the home
Jeff Brownc042ee22012-05-08 13:03:42 -07001511 * screen to the user. This will happen after systemReady(), and at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001512 * this point the display is active.
1513 */
1514 public void enableScreenAfterBoot();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001515
Tor Norbyed9273d62013-05-30 15:59:53 -07001516 public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001517
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001518 /**
1519 * Call from application to perform haptic feedback on its window.
1520 */
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -07001521 public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001522
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001523 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -04001524 * Called when we have started keeping the screen on because a window
1525 * requesting this has become visible.
1526 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001527 public void keepScreenOnStartedLw();
Daniel Sandler0601eb72011-04-13 01:01:32 -04001528
1529 /**
1530 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001531 * requesting this is no longer visible.
1532 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001533 public void keepScreenOnStoppedLw();
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001534
1535 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001536 * Gets the current user rotation mode.
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001537 *
1538 * @return The rotation mode.
1539 *
Adrian Roose99bc052017-11-20 17:55:31 +01001540 * @see #USER_ROTATION_LOCKED
1541 * @see #USER_ROTATION_FREE
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001542 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001543 @UserRotationMode
Svetoslav Ganov80943d82013-01-02 10:25:37 -08001544 public int getUserRotationMode();
1545
1546 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001547 * Inform the policy that the user has chosen a preferred orientation ("rotation lock").
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001548 *
Adrian Roose99bc052017-11-20 17:55:31 +01001549 * @param mode One of {@link #USER_ROTATION_LOCKED} or {@link #USER_ROTATION_FREE}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001550 * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90},
Craig Mautner69b08182012-09-05 13:07:13 -07001551 * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}.
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001552 */
Tor Norbyed9273d62013-05-30 15:59:53 -07001553 public void setUserRotationMode(@UserRotationMode int mode, @Surface.Rotation int rotation);
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001554
1555 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -07001556 * Called when a new system UI visibility is being reported, allowing
1557 * the policy to adjust what is actually reported.
Tor Norbyed9273d62013-05-30 15:59:53 -07001558 * @param visibility The raw visibility reported by the status bar.
Dianne Hackborndf89e652011-10-06 22:35:11 -07001559 * @return The new desired visibility.
1560 */
1561 public int adjustSystemUiVisibilityLw(int visibility);
1562
1563 /**
Winsonab216602016-08-09 14:05:20 -07001564 * Called by System UI to notify of changes to the visibility of Recents.
1565 */
1566 public void setRecentsVisibilityLw(boolean visible);
1567
1568 /**
1569 * Called by System UI to notify of changes to the visibility of PIP.
1570 */
Winson Chungac52f282017-03-30 14:44:52 -07001571 void setPipVisibilityLw(boolean visible);
Winsonab216602016-08-09 14:05:20 -07001572
1573 /**
Matthew Ng64543e62018-02-28 17:35:10 -08001574 * Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
1575 */
1576 void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled);
1577
1578 /**
Daniel Sandler0c4ccff2011-10-19 16:39:14 -04001579 * Specifies whether there is an on-screen navigation bar separate from the status bar.
1580 */
1581 public boolean hasNavigationBar();
1582
1583 /**
Jim Miller93c518e2012-01-17 15:55:31 -08001584 * Lock the device now.
1585 */
Adam Cohenf7522022012-10-03 20:03:18 -07001586 public void lockNow(Bundle options);
Jim Miller93c518e2012-01-17 15:55:31 -08001587
1588 /**
satok1bc0a492012-04-25 22:47:12 +09001589 * Set the last used input method window state. This state is used to make IME transition
1590 * smooth.
1591 * @hide
1592 */
1593 public void setLastInputMethodWindowLw(WindowState ime, WindowState target);
1594
1595 /**
Yohei Yukawad6475a62017-04-17 10:35:27 -07001596 * An internal callback (from InputMethodManagerService) to notify a state change regarding
1597 * whether the back key should dismiss the software keyboard (IME) or not.
1598 *
1599 * @param newValue {@code true} if the software keyboard is shown and the back key is expected
1600 * to dismiss the software keyboard.
1601 * @hide
1602 */
1603 default void setDismissImeOnBackKeyPressed(boolean newValue) {
1604 // Default implementation does nothing.
1605 }
1606
1607 /**
Craig Mautner84984fa2014-06-19 11:19:20 -07001608 * Show the recents task list app.
1609 * @hide
1610 */
Winson Chungdff7a732017-12-11 12:17:06 -08001611 public void showRecentApps();
Craig Mautner84984fa2014-06-19 11:19:20 -07001612
1613 /**
Alan Viverettee34560b22014-07-10 14:50:06 -07001614 * Show the global actions dialog.
1615 * @hide
1616 */
1617 public void showGlobalActions();
1618
1619 /**
Craig Mautnerf1b67412012-09-19 13:18:29 -07001620 * Called when the current user changes. Guaranteed to be called before the broadcast
1621 * of the new user id is made to all listeners.
1622 *
1623 * @param newUserId The id of the incoming user.
1624 */
1625 public void setCurrentUserLw(int newUserId);
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -07001626
1627 /**
Evan Rosky18396452016-07-27 15:19:37 -07001628 * For a given user-switch operation, this will be called once with switching=true before the
1629 * user-switch and once with switching=false afterwards (or if the user-switch was cancelled).
1630 * This gives the policy a chance to alter its behavior for the duration of a user-switch.
1631 *
1632 * @param switching true if a user-switch is in progress
1633 */
1634 void setSwitchingUser(boolean switching);
1635
1636 /**
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001637 * Print the WindowManagerPolicy's state into the given stream.
1638 *
1639 * @param prefix Text to print at the front of each line.
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001640 * @param writer The PrintWriter to which you should dump your state. This will be
1641 * closed for you after you return.
1642 * @param args additional arguments to the dump request.
1643 */
Jeff Brownd7a04de2012-06-17 14:17:52 -07001644 public void dump(String prefix, PrintWriter writer, String[] args);
Jim Miller4eeb4f62012-11-08 00:04:29 -08001645
1646 /**
Steven Timotiusaf03df62017-07-18 16:56:43 -07001647 * Write the WindowManagerPolicy's state into the protocol buffer.
Yi Jin6c6e9ca2018-03-20 16:53:35 -07001648 * The message is described in {@link com.android.server.wm.WindowManagerPolicyProto}
Steven Timotiusaf03df62017-07-18 16:56:43 -07001649 *
1650 * @param proto The protocol buffer output stream to write to.
1651 */
1652 void writeToProto(ProtoOutputStream proto, long fieldId);
1653
1654 /**
Svetoslav Ganov545252f2012-12-10 18:29:24 -08001655 * Returns whether a given window type is considered a top level one.
1656 * A top level window does not have a container, i.e. attached window,
1657 * or if it has a container it is laid out as a top-level window, not
1658 * as a child of its container.
1659 *
1660 * @param windowType The window type.
1661 * @return True if the window is a top level one.
1662 */
1663 public boolean isTopLevelWindow(int windowType);
Jorim Jaggi0d674622014-05-21 01:34:15 +02001664
1665 /**
1666 * Notifies the keyguard to start fading out.
Jorim Jaggie29b2db2014-05-30 23:17:03 +02001667 *
1668 * @param startTime the start time of the animation in uptime milliseconds
1669 * @param fadeoutDuration the duration of the exit animation, in milliseconds
Jorim Jaggi0d674622014-05-21 01:34:15 +02001670 */
Jorim Jaggie29b2db2014-05-30 23:17:03 +02001671 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
Jorim Jaggi737af722015-12-31 10:42:27 +01001672
1673 /**
1674 * Calculates the stable insets without running a layout.
1675 *
1676 * @param displayRotation the current display rotation
Jorim Jaggi737af722015-12-31 10:42:27 +01001677 * @param displayWidth the current display width
1678 * @param displayHeight the current display height
Adrian Roos11c25582018-02-19 18:06:36 +01001679 * @param displayCutout the current display cutout
Winson3e874742016-01-07 10:08:17 -08001680 * @param outInsets the insets to return
Jorim Jaggi737af722015-12-31 10:42:27 +01001681 */
1682 public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight,
Adrian Roos11c25582018-02-19 18:06:36 +01001683 DisplayCutout displayCutout, Rect outInsets);
Jorim Jaggi82c9dc92016-02-05 15:10:33 -08001684
Jorim Jaggi0ffd49c2016-02-12 15:04:21 -08001685
1686 /**
1687 * @return true if the navigation bar is forced to stay visible
1688 */
1689 public boolean isNavBarForcedShownLw(WindowState win);
1690
Jorim Jaggi82c9dc92016-02-05 15:10:33 -08001691 /**
Andrii Kulian3a1619d2017-07-07 14:38:09 -07001692 * @return The side of the screen where navigation bar is positioned.
1693 * @see #NAV_BAR_LEFT
1694 * @see #NAV_BAR_RIGHT
1695 * @see #NAV_BAR_BOTTOM
1696 */
Yohei Yukawad0a66b22018-01-10 13:19:54 -08001697 @NavigationBarPosition
Andrii Kulian3a1619d2017-07-07 14:38:09 -07001698 int getNavBarPosition();
1699
1700 /**
Jorim Jaggi82c9dc92016-02-05 15:10:33 -08001701 * Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system
1702 * bar or button bar. See {@link #getNonDecorDisplayWidth}.
1703 *
1704 * @param displayRotation the current display rotation
1705 * @param displayWidth the current display width
1706 * @param displayHeight the current display height
Adrian Roos11c25582018-02-19 18:06:36 +01001707 * @param displayCutout the current display cutout
Jorim Jaggi82c9dc92016-02-05 15:10:33 -08001708 * @param outInsets the insets to return
1709 */
1710 public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight,
Adrian Roos11c25582018-02-19 18:06:36 +01001711 DisplayCutout displayCutout, Rect outInsets);
Jorim Jaggi5060bd82016-02-19 17:12:19 -08001712
1713 /**
Matthew Ng62c78462018-04-09 14:43:21 -07001714 * @param displayRotation the current display rotation
1715 * @param displayWidth the current display width
1716 * @param displayHeight the current display height
1717 * @param dockSide the dockside asking if allowed
1718 * @param originalDockSide the side that was original docked to in split screen
Jorim Jaggi5060bd82016-02-19 17:12:19 -08001719 * @return True if a specified {@param dockSide} is allowed on the current device, or false
1720 * otherwise. It is guaranteed that at least one dock side for a particular orientation
1721 * is allowed, so for example, if DOCKED_RIGHT is not allowed, DOCKED_LEFT is allowed.
Matthew Ng62c78462018-04-09 14:43:21 -07001722 * If navigation bar is movable then the docked side would bias towards the
1723 * {@param originalDockSide}.
Jorim Jaggi5060bd82016-02-19 17:12:19 -08001724 */
Matthew Ng62c78462018-04-09 14:43:21 -07001725 public boolean isDockSideAllowed(int dockSide, int originalDockSide, int displayWidth,
1726 int displayHeight, int displayRotation);
Jorim Jaggi11c62e12016-04-05 20:41:21 -07001727
1728 /**
1729 * Called when the configuration has changed, and it's safe to load new values from resources.
1730 */
1731 public void onConfigurationChanged();
Robert Carr6da3cc02016-06-16 15:17:07 -07001732
1733 public boolean shouldRotateSeamlessly(int oldRotation, int newRotation);
Keun-young Park4136d2d2017-05-08 14:51:59 -07001734
1735 /**
1736 * Called when System UI has been started.
1737 */
1738 void onSystemUiStarted();
1739
1740 /**
1741 * Checks whether the policy is ready for dismissing the boot animation and completing the boot.
1742 *
1743 * @return true if ready; false otherwise.
1744 */
1745 boolean canDismissBootAnimation();
Michael Wright19859762017-09-18 20:57:58 +01001746
1747 /**
1748 * Convert the user rotation mode to a human readable format.
1749 */
1750 static String userRotationModeToString(int mode) {
1751 switch(mode) {
1752 case USER_ROTATION_FREE:
1753 return "USER_ROTATION_FREE";
1754 case USER_ROTATION_LOCKED:
1755 return "USER_ROTATION_LOCKED";
1756 default:
1757 return Integer.toString(mode);
1758 }
1759 }
Yoshiaki Nakae1bdfc822017-09-15 15:24:34 +09001760
1761 /**
1762 * Requests that the WindowManager sends WindowManagerPolicy#ACTION_USER_ACTIVITY_NOTIFICATION
1763 * on the next user activity.
1764 */
1765 public void requestUserActivityNotification();
Benjamin Franz3662b152018-01-16 17:23:44 +00001766
1767 /**
1768 * Called when the state of lock task mode changes. This should be used to disable immersive
1769 * mode confirmation.
1770 *
1771 * @param lockTaskState the new lock task mode state. One of
1772 * {@link ActivityManager#LOCK_TASK_MODE_NONE},
1773 * {@link ActivityManager#LOCK_TASK_MODE_LOCKED},
1774 * {@link ActivityManager#LOCK_TASK_MODE_PINNED}.
1775 */
1776 void onLockTaskStateChangedLw(int lockTaskState);
chaviw0e9fb132018-06-05 16:29:13 -07001777
1778 /**
1779 * Updates the flag about whether AOD is showing.
1780 *
1781 * @return whether the value was changed.
1782 */
1783 boolean setAodShowing(boolean aodShowing);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001784}