blob: 95a5f52e5efb75195d7968ca959677a1c8b4e61b [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
Tor Norbyed9273d62013-05-30 15:59:53 -070066import android.annotation.IntDef;
Chilun70a9ab92019-02-12 10:57:49 +080067import android.annotation.NonNull;
Jorim Jaggi241ae102016-11-02 21:57:33 -070068import android.annotation.Nullable;
Matthew Ng605ea472018-08-30 21:30:06 -070069import android.app.WindowConfiguration;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070import android.content.Context;
Dianne Hackborn2f0b1752011-05-31 17:59:49 -070071import android.content.res.CompatibilityInfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072import android.content.res.Configuration;
73import android.graphics.Rect;
Adam Cohenf7522022012-10-03 20:03:18 -070074import android.os.Bundle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075import android.os.IBinder;
Dianne Hackborndf89e652011-10-06 22:35:11 -070076import android.os.Looper;
Muyuan Li94ce94e2016-02-24 16:20:54 -080077import android.os.RemoteException;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -080078import android.util.Slog;
Steven Timotiusaf03df62017-07-18 16:56:43 -070079import android.util.proto.ProtoOutputStream;
Adrian Roose99bc052017-11-20 17:55:31 +010080import android.view.Display;
81import android.view.IApplicationToken;
Adrian Roos962017e2018-11-27 15:11:46 +010082import android.view.IDisplayFoldListener;
Adrian Roose99bc052017-11-20 17:55:31 +010083import android.view.IWindowManager;
84import android.view.InputEventReceiver;
85import android.view.KeyEvent;
Adrian Roose99bc052017-11-20 17:55:31 +010086import android.view.WindowManager;
87import android.view.WindowManagerGlobal;
88import android.view.WindowManagerPolicyConstants;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089import android.view.animation.Animation;
Aurimas Liutikas67e2ae82016-10-11 18:17:42 -070090
Jorim Jaggi241ae102016-11-02 21:57:33 -070091import com.android.internal.policy.IKeyguardDismissCallback;
Muyuan Li94ce94e2016-02-24 16:20:54 -080092import com.android.internal.policy.IShortcutService;
Riddle Hsuad256a12018-07-18 16:11:30 +080093import com.android.server.wm.DisplayRotation;
chaviw553b0212018-07-12 13:37:01 -070094import com.android.server.wm.WindowFrames;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080096import java.io.PrintWriter;
Tor Norbyed9273d62013-05-30 15:59:53 -070097import java.lang.annotation.Retention;
98import java.lang.annotation.RetentionPolicy;
Dianne Hackbornf99f9c52011-01-12 15:49:25 -080099
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100/**
101 * This interface supplies all UI-specific behavior of the window manager. An
102 * instance of it is created by the window manager when it starts up, and allows
103 * customization of window layering, special window types, key dispatching, and
104 * layout.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700105 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 * <p>Because this provides deep interaction with the system window manager,
107 * specific methods on this interface can be called from a variety of contexts
108 * with various restrictions on what they can do. These are encoded through
109 * a suffixes at the end of a method encoding the thread the method is called
110 * from and any locks that are held when it is being called; if no suffix
111 * is attached to a method, then it is not called with any locks and may be
112 * called from the main window manager thread or another thread calling into
113 * the window manager.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700114 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 * <p>The current suffixes are:
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700116 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 * <dl>
118 * <dt> Ti <dd> Called from the input thread. This is the thread that
119 * collects pending input events and dispatches them to the appropriate window.
120 * It may block waiting for events to be processed, so that the input stream is
121 * properly serialized.
122 * <dt> Tq <dd> Called from the low-level input queue thread. This is the
123 * thread that reads events out of the raw input devices and places them
124 * into the global input queue that is read by the <var>Ti</var> thread.
125 * This thread should not block for a long period of time on anything but the
126 * key driver.
127 * <dt> Lw <dd> Called with the main window manager lock held. Because the
128 * window manager is a very low-level system service, there are few other
129 * system services you can call with this lock held. It is explicitly okay to
130 * make calls into the package manager and power manager; it is explicitly not
The Android Open Source Projectc39a6e02009-03-11 12:11:56 -0700131 * okay to make calls into the activity manager or most other services. Note that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800132 * {@link android.content.Context#checkPermission(String, int, int)} and
133 * variations require calling into the activity manager.
134 * <dt> Li <dd> Called with the input thread lock held. This lock can be
135 * acquired by the window manager while it holds the window lock, so this is
136 * even more restrictive than <var>Lw</var>.
137 * </dl>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800138 */
Adrian Roose99bc052017-11-20 17:55:31 +0100139public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
Yohei Yukawad0a66b22018-01-10 13:19:54 -0800140 @Retention(SOURCE)
141 @IntDef({NAV_BAR_LEFT, NAV_BAR_RIGHT, NAV_BAR_BOTTOM})
142 @interface NavigationBarPosition {}
143
Bryce Lee01b0c5f2015-02-05 18:24:04 -0800144 /**
Jeff Brownd5bb82d2011-10-12 13:57:59 -0700145 * Pass this event to the user / app. To be returned from
146 * {@link #interceptKeyBeforeQueueing}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 */
Adrian Roose99bc052017-11-20 17:55:31 +0100148 int ACTION_PASS_TO_USER = 0x00000001;
149 /** Layout state may have changed (so another layout will be performed) */
150 int FINISH_LAYOUT_REDO_LAYOUT = 0x0001;
151 /** Configuration state may have changed */
152 int FINISH_LAYOUT_REDO_CONFIG = 0x0002;
153 /** Wallpaper may need to move */
154 int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004;
155 /** Need to recompute animations */
156 int FINISH_LAYOUT_REDO_ANIM = 0x0008;
Vishnu Nair83537a72018-07-19 21:27:48 -0700157 /** Layer for the screen off animation */
158 int COLOR_FADE_LAYER = 0x40000001;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159
160 /**
Muyuan Li94ce94e2016-02-24 16:20:54 -0800161 * Register shortcuts for window manager to dispatch.
162 * Shortcut code is packed as (metaState << Integer.SIZE) | keyCode
163 * @hide
164 */
165 void registerShortcutKey(long shortcutCode, IShortcutService shortcutKeyReceiver)
166 throws RemoteException;
167
168 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200169 * Called when the Keyguard occluded state changed.
170 * @param occluded Whether Keyguard is currently occluded or not.
Adrian Roosd88eb262016-08-04 14:50:48 -0700171 */
Jorim Jaggife762342016-10-13 14:33:27 +0200172 void onKeyguardOccludedChangedLw(boolean occluded);
Adrian Roosd88eb262016-08-04 14:50:48 -0700173
174 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175 * Interface to the Window Manager state associated with a particular
Vishnu Nair539334a2019-09-20 10:46:21 -0700176 * window. You can hold on to an instance of this interface from the call
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800177 * to prepareAddWindow() until removeWindow().
178 */
179 public interface WindowState {
180 /**
Dianne Hackbornf265ea92013-01-31 15:00:51 -0800181 * Return the uid of the app that owns this window.
182 */
183 int getOwningUid();
184
185 /**
186 * Return the package name of the app that owns this window.
187 */
188 String getOwningPackage();
189
190 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800191 * Perform standard frame computation. The result can be obtained with
192 * getFrame() if so desired. Must be called with the window manager
193 * lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700194 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800195 */
chaviw1454b392018-08-06 09:54:04 -0700196 public void computeFrameLw();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800197
198 /**
199 * Retrieve the current frame of the window that has been assigned by
200 * the window manager. Must be called with the window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700201 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800202 * @return Rect The rectangle holding the window frame.
203 */
204 public Rect getFrameLw();
205
206 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800207 * Retrieve the frame of the display that this window was last
208 * laid out in. Must be called with the
209 * window manager lock held.
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700210 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 * @return Rect The rectangle holding the display frame.
212 */
213 public Rect getDisplayFrameLw();
214
215 /**
216 * Retrieve the frame of the content area that this window was last
217 * laid out in. This is the area in which the content of the window
218 * should be placed. It will be smaller than the display frame to
219 * account for screen decorations such as a status bar or soft
220 * keyboard. Must be called with the
221 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700222 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800223 * @return Rect The rectangle holding the content frame.
224 */
225 public Rect getContentFrameLw();
226
227 /**
228 * Retrieve the frame of the visible area that this window was last
229 * laid out in. This is the area of the screen in which the window
230 * will actually be fully visible. It will be smaller than the
231 * content frame to account for transient UI elements blocking it
232 * such as an input method's candidates UI. Must be called with the
233 * 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 visible frame.
236 */
237 public Rect getVisibleFrameLw();
238
239 /**
240 * Returns true if this window is waiting to receive its given
241 * internal insets from the client app, and so should not impact the
242 * layout of other windows.
243 */
244 public boolean getGivenInsetsPendingLw();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700245
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800246 /**
247 * Retrieve the insets given by this window's client for the content
248 * area of windows behind it. Must be called with the
249 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700250 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800251 * @return Rect The left, top, right, and bottom insets, relative
252 * to the window's frame, of the actual contents.
253 */
254 public Rect getGivenContentInsetsLw();
255
256 /**
257 * Retrieve the insets given by this window's client for the visible
258 * area of windows behind it. Must be called with the
259 * window manager lock held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700260 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800261 * @return Rect The left, top, right, and bottom insets, relative
262 * to the window's frame, of the actual visible area.
263 */
264 public Rect getGivenVisibleInsetsLw();
265
266 /**
267 * Retrieve the current LayoutParams of the window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700268 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800269 * @return WindowManager.LayoutParams The window's internal LayoutParams
270 * instance.
271 */
272 public WindowManager.LayoutParams getAttrs();
273
274 /**
Dianne Hackborn73ab6a42011-12-13 11:16:23 -0800275 * Return whether this window needs the menu key shown. Must be called
276 * with window lock held, because it may need to traverse down through
277 * window list to determine the result.
278 * @param bottom The bottom-most window to consider when determining this.
279 */
280 public boolean getNeedsMenuLw(WindowState bottom);
281
282 /**
Dianne Hackborn9a230e02011-10-06 11:51:27 -0700283 * Retrieve the current system UI visibility flags associated with
284 * this window.
285 */
286 public int getSystemUiVisibility();
287
288 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289 * Get the layer at which this window's surface will be Z-ordered.
290 */
291 public int getSurfaceLayer();
Selim Cinekd6623612015-05-22 18:56:22 -0700292
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800293 /**
Selim Cinekd6623612015-05-22 18:56:22 -0700294 * Retrieve the type of the top-level window.
295 *
296 * @return the base type of the parent window if attached or its own type otherwise
297 */
298 public int getBaseType();
299
300 /**
301 * Return the token for the application (actually activity) that owns
302 * this window. May return null for system windows.
303 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800304 * @return An IApplicationToken identifying the owning activity.
305 */
306 public IApplicationToken getAppToken();
307
308 /**
Dianne Hackborne30e02f2014-05-27 18:24:45 -0700309 * Return true if this window is participating in voice interaction.
310 */
311 public boolean isVoiceInteraction();
312
313 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700314 * Return true if, at any point, the application token associated with
315 * this window has actually displayed any windows. This is most useful
316 * with the "starting up" window to determine if any windows were
317 * displayed when it is closed.
318 *
319 * @return Returns true if one or more windows have been displayed,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800320 * else false.
321 */
322 public boolean hasAppShownWindows();
323
324 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800325 * Is this window visible? It is not visible if there is no
326 * surface, or we are in the process of running an exit animation
327 * that will remove the surface.
328 */
329 boolean isVisibleLw();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700330
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800331 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700332 * Is this window currently visible to the user on-screen? It is
333 * displayed either if it is visible or it is currently running an
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800334 * animation before no longer being visible. Must be called with the
335 * window manager lock held.
336 */
337 boolean isDisplayedLw();
338
339 /**
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700340 * Return true if this window (or a window it is attached to, but not
341 * considering its app token) is currently animating.
342 */
Filip Gruszczynski14b4e572015-11-03 15:53:55 -0800343 boolean isAnimatingLw();
Dianne Hackborn5c58de32012-04-28 19:52:37 -0700344
345 /**
Jorim Jaggi23cc9aa2017-05-23 16:05:35 +0200346 * @return Whether the window can affect SystemUI flags, meaning that SystemUI (system bars,
347 * for example) will be affected by the flags specified in this window. This is the
348 * case when the surface is on screen but not exiting.
349 */
350 boolean canAffectSystemUiFlags();
351
352 /**
Dianne Hackborn01b02a72012-01-12 14:05:03 -0800353 * Is this window considered to be gone for purposes of layout?
354 */
355 boolean isGoneForLayoutLw();
356
357 /**
Adrian Roos76d2fe42015-07-09 14:54:08 -0700358 * Returns true if the window has a surface that it has drawn a
359 * complete UI in to. Note that this is different from {@link #hasDrawnLw()}
360 * in that it also returns true if the window is READY_TO_SHOW, but was not yet
361 * promoted to HAS_DRAWN.
362 */
363 boolean isDrawnLw();
364
365 /**
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700366 * Returns true if this window has been shown on screen at some time in
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800367 * the past. Must be called with the window manager lock held.
Jorim Jaggia32da382018-03-28 18:01:22 +0200368 *
369 * @deprecated Use {@link #isDrawnLw} or any of the other drawn/visibility methods.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800370 */
Jorim Jaggia32da382018-03-28 18:01:22 +0200371 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800372 public boolean hasDrawnLw();
373
374 /**
375 * Can be called by the policy to force a window to be hidden,
376 * regardless of whether the client or window manager would like
377 * it shown. Must be called with the window manager lock held.
378 * Returns true if {@link #showLw} was last called for the window.
379 */
380 public boolean hideLw(boolean doAnimation);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700381
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800382 /**
383 * Can be called to undo the effect of {@link #hideLw}, allowing a
384 * window to be shown as long as the window manager and client would
385 * also like it to be shown. Must be called with the window manager
386 * lock held.
387 * Returns true if {@link #hideLw} was last called for the window.
388 */
389 public boolean showLw(boolean doAnimation);
Dianne Hackbornf87d1962012-04-04 12:48:24 -0700390
391 /**
392 * Check whether the process hosting this window is currently alive.
393 */
394 public boolean isAlive();
Craig Mautner69b08182012-09-05 13:07:13 -0700395
396 /**
397 * Check if window is on {@link Display#DEFAULT_DISPLAY}.
398 * @return true if window is on default display.
399 */
400 public boolean isDefaultDisplay();
Adrian Rooscd3884d2015-02-18 17:25:23 +0100401
402 /**
403 * Check whether the window is currently dimming.
404 */
405 public boolean isDimming();
Jorim Jaggi86905582016-02-09 21:36:09 -0800406
Adrian Roos865c70f2018-01-10 17:32:27 +0100407 /**
408 * Returns true if the window is letterboxed for the display cutout.
409 */
410 default boolean isLetterboxedForDisplayCutoutLw() {
411 return false;
412 }
413
Adrian Roos23df3a32018-03-15 15:41:13 +0100414 /**
415 * Returns true if the window has a letterbox and any part of that letterbox overlaps with
416 * the given {@code rect}.
417 */
418 default boolean isLetterboxedOverlappingWith(Rect rect) {
419 return false;
420 }
421
Wale Ogunwale44f036f2017-09-29 05:09:09 -0700422 /** @return the current windowing mode of this window. */
423 int getWindowingMode();
Wale Ogunwale9185fb02016-03-11 18:06:14 -0800424
425 /**
Matthew Ng605ea472018-08-30 21:30:06 -0700426 * Returns the {@link WindowConfiguration.ActivityType} associated with the configuration
427 * of this window.
428 */
429 default int getActivityType() {
430 return WindowConfiguration.WINDOWING_MODE_UNDEFINED;
431 }
432
433 /**
Wale Ogunwale9185fb02016-03-11 18:06:14 -0800434 * Returns true if the window is current in multi-windowing mode. i.e. it shares the
435 * screen with other application windows.
436 */
Evan Rosky4fb1e912019-03-06 13:54:43 -0800437 boolean inMultiWindowMode();
Robert Carrfd10cd12016-06-29 16:41:50 -0700438
439 public int getRotationAnimationHint();
Jorim Jaggife762342016-10-13 14:33:27 +0200440
441 public boolean isInputMethodWindow();
442
Robert Carr825581a2018-03-30 14:00:53 -0700443 public boolean isInputMethodTarget();
444
Jorim Jaggife762342016-10-13 14:33:27 +0200445 public int getDisplayId();
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800446
447 /**
448 * Returns true if the window owner can add internal system windows.
Adrian Roose99bc052017-11-20 17:55:31 +0100449 * That is, they have {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}.
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800450 */
451 default boolean canAddInternalSystemWindow() {
452 return false;
453 }
Jorim Jaggif12ec0f2017-08-23 16:14:10 +0200454
455 /**
456 * Returns true if the window owner has the permission to acquire a sleep token when it's
Adrian Roose99bc052017-11-20 17:55:31 +0100457 * visible. That is, they have the permission {@link Manifest.permission#DEVICE_POWER}.
Jorim Jaggif12ec0f2017-08-23 16:14:10 +0200458 */
459 boolean canAcquireSleepToken();
Vishnu Nair9a3e4062018-01-11 08:42:54 -0800460
Tiger Huang513d5e12018-07-16 21:49:50 +0800461 /** @return true if this window desires key events. */
462 boolean canReceiveKeys();
463
lumark31e4f8e2019-01-10 20:48:18 +0800464 /** @return true if the window can show over keyguard. */
465 boolean canShowWhenLocked();
466
Vishnu Nair9a3e4062018-01-11 08:42:54 -0800467 /**
Yi Jin6c6e9ca2018-03-20 16:53:35 -0700468 * Writes {@link com.android.server.wm.IdentifierProto} to stream.
Vishnu Nair9a3e4062018-01-11 08:42:54 -0800469 */
470 void writeIdentifierToProto(ProtoOutputStream proto, long fieldId);
chaviw1454b392018-08-06 09:54:04 -0700471
472 /**
473 * @return The {@link WindowFrames} associated with this {@link WindowState}
474 */
475 WindowFrames getWindowFrames();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800476 }
477
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700478 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700479 * Representation of a input consumer that the policy has added to the
480 * window manager to consume input events going to windows below it.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700481 */
Selim Cinekf83e8242015-05-19 18:08:14 -0700482 public interface InputConsumer {
Dianne Hackborndf89e652011-10-06 22:35:11 -0700483 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700484 * Remove the input consumer from the window manager.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700485 */
486 void dismiss();
487 }
488
489 /**
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800490 * Holds the contents of a starting window. {@link #addSplashScreen} needs to wrap the
491 * contents of the starting window into an class implementing this interface, which then will be
Jorim Jaggi02886a82016-12-06 09:10:06 -0800492 * held by WM and released with {@link #remove} when no longer needed.
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800493 */
494 interface StartingSurface {
Jorim Jaggi02886a82016-12-06 09:10:06 -0800495
496 /**
497 * Removes the starting window surface. Do not hold the window manager lock when calling
498 * this method!
499 */
500 void remove();
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800501 }
502
503 /**
Dianne Hackborndf89e652011-10-06 22:35:11 -0700504 * Interface for calling back in to the window manager that is private
505 * between it and the policy.
506 */
507 public interface WindowManagerFuncs {
Jeff Brownac143512012-04-05 18:57:33 -0700508 public static final int LID_ABSENT = -1;
509 public static final int LID_CLOSED = 0;
510 public static final int LID_OPEN = 1;
511
Edward Savage-Jonesce7a01f2015-12-09 21:16:50 +0100512 public static final int LID_BEHAVIOR_NONE = 0;
513 public static final int LID_BEHAVIOR_SLEEP = 1;
514 public static final int LID_BEHAVIOR_LOCK = 2;
515
Michael Wright3818c922014-09-02 13:59:07 -0700516 public static final int CAMERA_LENS_COVER_ABSENT = -1;
517 public static final int CAMERA_LENS_UNCOVERED = 0;
518 public static final int CAMERA_LENS_COVERED = 1;
519
Dianne Hackborndf89e652011-10-06 22:35:11 -0700520 /**
Selim Cinekf83e8242015-05-19 18:08:14 -0700521 * Add a input consumer which will consume all input events going to any window below it.
Dianne Hackborndf89e652011-10-06 22:35:11 -0700522 */
Winson41275482016-10-10 15:17:45 -0700523 public InputConsumer createInputConsumer(Looper looper, String name,
Arthur Hung95b38a92018-07-20 18:56:12 +0800524 InputEventReceiver.Factory inputEventReceiverFactory, int displayId);
Jeff Brownac143512012-04-05 18:57:33 -0700525
526 /**
527 * Returns a code that describes the current state of the lid switch.
528 */
529 public int getLidState();
530
531 /**
Edward Savage-Jones7def60d2015-11-13 13:27:03 +0100532 * Lock the device now.
533 */
534 public void lockDeviceNow();
535
536 /**
Michael Wright3818c922014-09-02 13:59:07 -0700537 * Returns a code that descripbes whether the camera lens is covered or not.
538 */
539 public int getCameraLensCoverState();
540
541 /**
Yohei Yukawa2d9accb2018-03-07 19:15:15 -0800542 * Switch the keyboard layout for the given device.
543 * Direction should be +1 or -1 to go to the next or previous keyboard layout.
544 */
545 public void switchKeyboardLayout(int deviceId, int direction);
546
Jeff Brown9a538ee2012-08-20 14:56:57 -0700547 public void shutdown(boolean confirm);
Alison Cichowlasf8eca402016-08-05 14:50:27 -0400548 public void reboot(boolean confirm);
Jeff Brown9a538ee2012-08-20 14:56:57 -0700549 public void rebootSafeMode(boolean confirm);
John Spurlock04db1762013-05-13 12:46:41 -0400550
551 /**
552 * Return the window manager lock needed to correctly call "Lw" methods.
553 */
554 public Object getWindowManagerLock();
Craig Mautner037aa8d2013-06-07 10:35:44 -0700555
556 /** Register a system listener for touch events */
Arthur Hungbe5ce212018-09-13 18:41:56 +0800557 void registerPointerEventListener(PointerEventListener listener, int displayId);
Craig Mautner037aa8d2013-06-07 10:35:44 -0700558
559 /** Unregister a system listener for touch events */
Arthur Hungbe5ce212018-09-13 18:41:56 +0800560 void unregisterPointerEventListener(PointerEventListener listener, int displayId);
Jorim Jaggi81ba11e2016-02-03 22:04:22 -0800561
562 /**
Wale Ogunwale68278562017-09-23 17:13:55 -0700563 * Retrieves the {@param outBounds} from the stack matching the {@param windowingMode} and
564 * {@param activityType}.
Jorim Jaggi86905582016-02-09 21:36:09 -0800565 */
Wale Ogunwale68278562017-09-23 17:13:55 -0700566 void getStackBounds(int windowingMode, int activityType, Rect outBounds);
Jorim Jaggi77e10432016-10-26 17:43:56 -0700567
568 /**
Jorim Jaggi40db0292016-06-27 17:58:03 -0700569 * @return The currently active input method window.
570 */
571 WindowState getInputMethodWindowLw();
572
573 /**
Jorim Jaggie69c9312016-10-31 18:24:38 -0700574 * Notifies window manager that {@link #isKeyguardTrustedLw} has changed.
575 */
576 void notifyKeyguardTrustedChanged();
Jorim Jaggi51304d72017-05-17 17:25:32 +0200577
578 /**
579 * Notifies the window manager that screen is being turned off.
580 *
581 * @param listener callback to call when display can be turned off
582 */
583 void screenTurningOff(ScreenOffListener listener);
Michael Wright19859762017-09-18 20:57:58 +0100584
585 /**
586 * Convert the lid state to a human readable format.
587 */
588 static String lidStateToString(int lid) {
589 switch (lid) {
590 case LID_ABSENT:
591 return "LID_ABSENT";
592 case LID_CLOSED:
593 return "LID_CLOSED";
594 case LID_OPEN:
595 return "LID_OPEN";
596 default:
597 return Integer.toString(lid);
598 }
599 }
600
601 /**
602 * Convert the camera lens state to a human readable format.
603 */
604 static String cameraLensStateToString(int lens) {
605 switch (lens) {
606 case CAMERA_LENS_COVER_ABSENT:
607 return "CAMERA_LENS_COVER_ABSENT";
608 case CAMERA_LENS_UNCOVERED:
609 return "CAMERA_LENS_UNCOVERED";
610 case CAMERA_LENS_COVERED:
611 return "CAMERA_LENS_COVERED";
612 default:
613 return Integer.toString(lens);
614 }
615 }
Adrian Roos842e7882018-03-26 17:34:06 +0200616
617 /**
618 * Hint to window manager that the user has started a navigation action that should
619 * abort animations that have no timeout, in case they got stuck.
620 */
621 void triggerAnimationFailsafe();
Adrian Roos4163d622018-05-22 16:56:35 +0200622
623 /**
624 * The keyguard showing state has changed
625 */
626 void onKeyguardShowingAndNotOccludedChanged();
Riddle Hsuad256a12018-07-18 16:11:30 +0800627
Tiger Huang7c610aa2018-10-27 00:01:01 +0800628 /**
629 * Notifies window manager that power key is being pressed.
630 */
631 void onPowerKeyDown(boolean isScreenOn);
632
633 /**
634 * Notifies window manager that user is switched.
635 */
636 void onUserSwitched();
Tiger Huangdda14a72019-01-10 17:20:27 +0800637
638 /**
639 * Hint to window manager that the user is interacting with a display that should be treated
640 * as the top display.
641 */
642 void moveDisplayToTop(int displayId);
Riddle Hsuad256a12018-07-18 16:11:30 +0800643 }
644
645 /**
646 * Provides the rotation of a device.
647 *
648 * @see com.android.server.policy.WindowOrientationListener
649 */
650 public interface RotationSource {
651 int getProposedRotation();
652
653 void setCurrentRotation(int rotation);
654 }
655
656 /**
657 * Interface to get public information of a display content.
658 */
659 public interface DisplayContentInfo {
660 DisplayRotation getDisplayRotation();
661 Display getDisplay();
Craig Mautner037aa8d2013-06-07 10:35:44 -0700662 }
663
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800664 /** Window has been added to the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800665 public static final int TRANSIT_ENTER = 1;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800666 /** Window has been removed from the screen. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800667 public static final int TRANSIT_EXIT = 2;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800668 /** Window has been made visible. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800669 public static final int TRANSIT_SHOW = 3;
670 /** Window has been made invisible.
671 * TODO: Consider removal as this is unused. */
672 public static final int TRANSIT_HIDE = 4;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800673 /** The "application starting" preview window is no longer needed, and will
674 * animate away to show the real window. */
Craig Mautner4b71aa12012-12-27 17:20:01 -0800675 public static final int TRANSIT_PREVIEW_DONE = 5;
676
Dianne Hackborn254cb442010-01-27 19:23:59 -0800677 // NOTE: screen off reasons are in order of significance, with more
678 // important ones lower than less important ones.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700679
Tor Norbyed9273d62013-05-30 15:59:53 -0700680 /** @hide */
681 @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED})
682 @Retention(RetentionPolicy.SOURCE)
683 public @interface UserRotationMode {}
684
Daniel Sandlerb73617d2010-08-17 00:41:00 -0400685 /** When not otherwise specified by the activity's screenOrientation, rotation should be
686 * determined by the system (that is, using sensors). */
687 public final int USER_ROTATION_FREE = 0;
688 /** When not otherwise specified by the activity's screenOrientation, rotation is set by
689 * the user. */
690 public final int USER_ROTATION_LOCKED = 1;
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700691
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800692 /**
Riddle Hsu5ce4bb32018-07-18 16:11:30 +0800693 * Set the default display content to provide basic functions for the policy.
694 */
695 public void setDefaultDisplay(DisplayContentInfo displayContentInfo);
696
697 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800698 * Perform initialization of the policy.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700699 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800700 * @param context The system context we are running in.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800701 */
702 public void init(Context context, IWindowManager windowManager,
Jeff Brown96307042012-07-27 15:51:34 -0700703 WindowManagerFuncs windowManagerFuncs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800704
705 /**
706 * Check permissions when adding a window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700707 *
Dianne Hackbornc2293022013-02-06 23:14:49 -0800708 * @param attrs The window's LayoutParams.
709 * @param outAppOp First element will be filled with the app op corresponding to
710 * this window, or OP_NONE.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700711 *
Jeff Brown98365d72012-08-19 20:30:52 -0700712 * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800713 * else an error code, usually
Jeff Brown98365d72012-08-19 20:30:52 -0700714 * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800715 */
Dianne Hackbornc2293022013-02-06 23:14:49 -0800716 public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800717
718 /**
Craig Mautner88400d32012-09-30 12:35:45 -0700719 * Check permissions when adding a window.
720 *
721 * @param attrs The window's LayoutParams.
722 *
723 * @return True if the window may only be shown to the current user, false if the window can
724 * be shown on all users' windows.
725 */
726 public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs);
727
728 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800729 * After the window manager has computed the current configuration based
730 * on its knowledge of the display and input devices, it gives the policy
731 * a chance to adjust the information contained in it. If you want to
732 * leave it as-is, simply do nothing.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700733 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800734 * <p>This method may be called by any thread in the window manager, but
735 * no internal locks in the window manager will be held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700736 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800737 * @param config The Configuration being computed, for you to change as
738 * desired.
Jeff Browndaa37532012-05-01 15:54:03 -0700739 * @param keyboardPresence Flags that indicate whether internal or external
740 * keyboards are present.
741 * @param navigationPresence Flags that indicate whether internal or external
742 * navigation devices are present.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800743 */
Jeff Browndaa37532012-05-01 15:54:03 -0700744 public void adjustConfigurationLw(Configuration config, int keyboardPresence,
745 int navigationPresence);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700746
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800747 /**
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800748 * Returns the layer assignment for the window state. Allows you to control how different
749 * kinds of windows are ordered on-screen.
750 *
751 * @param win The window state
752 * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
753 */
754 default int getWindowLayerLw(WindowState win) {
755 return getWindowLayerFromTypeLw(win.getBaseType(), win.canAddInternalSystemWindow());
756 }
757
758 /**
759 * Returns the layer assignment for the window type. Allows you to control how different
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 * kinds of windows are ordered on-screen.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700761 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800762 * @param type The type of window being assigned.
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800763 * @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 -0800764 */
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800765 default int getWindowLayerFromTypeLw(int type) {
766 if (isSystemAlertWindowType(type)) {
767 throw new IllegalArgumentException("Use getWindowLayerFromTypeLw() or"
768 + " getWindowLayerLw() for alert window types");
769 }
770 return getWindowLayerFromTypeLw(type, false /* canAddInternalSystemWindow */);
771 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800772
773 /**
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800774 * Returns the layer assignment for the window type. Allows you to control how different
775 * kinds of windows are ordered on-screen.
776 *
777 * @param type The type of window being assigned.
778 * @param canAddInternalSystemWindow If the owner window associated with the type we are
779 * evaluating can add internal system windows. I.e they have
Adrian Roose99bc052017-11-20 17:55:31 +0100780 * {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}. If true, alert window
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800781 * types {@link android.view.WindowManager.LayoutParams#isSystemAlertWindowType(int)}
782 * can be assigned layers greater than the layer for
783 * {@link android.view.WindowManager.LayoutParams#TYPE_APPLICATION_OVERLAY} Else, their
784 * layers would be lesser.
785 * @return int An arbitrary integer used to order windows, with lower numbers below higher ones.
786 */
787 default int getWindowLayerFromTypeLw(int type, boolean canAddInternalSystemWindow) {
788 if (type >= FIRST_APPLICATION_WINDOW && type <= LAST_APPLICATION_WINDOW) {
789 return APPLICATION_LAYER;
790 }
791
792 switch (type) {
793 case TYPE_WALLPAPER:
794 // wallpaper is at the bottom, though the window manager may move it.
795 return 1;
796 case TYPE_PRESENTATION:
797 case TYPE_PRIVATE_PRESENTATION:
798 return APPLICATION_LAYER;
799 case TYPE_DOCK_DIVIDER:
800 return APPLICATION_LAYER;
801 case TYPE_QS_DIALOG:
802 return APPLICATION_LAYER;
803 case TYPE_PHONE:
804 return 3;
805 case TYPE_SEARCH_BAR:
806 case TYPE_VOICE_INTERACTION_STARTING:
807 return 4;
808 case TYPE_VOICE_INTERACTION:
809 // voice interaction layer is almost immediately above apps.
810 return 5;
811 case TYPE_INPUT_CONSUMER:
812 return 6;
813 case TYPE_SYSTEM_DIALOG:
814 return 7;
815 case TYPE_TOAST:
816 // toasts and the plugged-in battery thing
817 return 8;
818 case TYPE_PRIORITY_PHONE:
819 // SIM errors and unlock. Not sure if this really should be in a high layer.
820 return 9;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800821 case TYPE_SYSTEM_ALERT:
822 // like the ANR / app crashed dialogs
Vishnu Nair90f97fe2019-03-20 10:09:43 -0700823 // Type is deprecated for non-system apps. For system apps, this type should be
824 // in a higher layer than TYPE_APPLICATION_OVERLAY.
825 return canAddInternalSystemWindow ? 13 : 10;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800826 case TYPE_APPLICATION_OVERLAY:
Vishnu Nair9ccb1d22019-03-20 16:32:44 +0000827 return 12;
Wale Ogunwaled993a572017-02-05 13:52:09 -0800828 case TYPE_DREAM:
829 // used for Dreams (screensavers with TYPE_DREAM windows)
Vishnu Nair90f97fe2019-03-20 10:09:43 -0700830 return 14;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800831 case TYPE_INPUT_METHOD:
832 // on-screen keyboards and other such input method user interfaces go here.
Vishnu Nair90f97fe2019-03-20 10:09:43 -0700833 return 15;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800834 case TYPE_INPUT_METHOD_DIALOG:
835 // on-screen keyboards and other such input method user interfaces go here.
Vishnu Nair90f97fe2019-03-20 10:09:43 -0700836 return 16;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800837 case TYPE_STATUS_BAR:
Robert Carr8360a782017-11-22 12:47:58 -0800838 return 17;
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800839 case TYPE_STATUS_BAR_PANEL:
Robert Carr8360a782017-11-22 12:47:58 -0800840 return 18;
841 case TYPE_STATUS_BAR_SUB_PANEL:
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800842 return 19;
843 case TYPE_KEYGUARD_DIALOG:
844 return 20;
845 case TYPE_VOLUME_OVERLAY:
846 // the on-screen volume indicator and controller shown when the user
847 // changes the device volume
848 return 21;
849 case TYPE_SYSTEM_OVERLAY:
850 // the on-screen volume indicator and controller shown when the user
851 // changes the device volume
852 return canAddInternalSystemWindow ? 22 : 11;
853 case TYPE_NAVIGATION_BAR:
854 // the navigation bar, if available, shows atop most things
855 return 23;
856 case TYPE_NAVIGATION_BAR_PANEL:
857 // some panels (e.g. search) need to show on top of the navigation bar
858 return 24;
859 case TYPE_SCREENSHOT:
860 // screenshot selection layer shouldn't go above system error, but it should cover
861 // navigation bars at the very least.
862 return 25;
863 case TYPE_SYSTEM_ERROR:
864 // system-level error dialogs
865 return canAddInternalSystemWindow ? 26 : 10;
866 case TYPE_MAGNIFICATION_OVERLAY:
867 // used to highlight the magnified portion of a display
868 return 27;
869 case TYPE_DISPLAY_OVERLAY:
870 // used to simulate secondary display devices
871 return 28;
872 case TYPE_DRAG:
873 // the drag layer: input for drag-and-drop is associated with this window,
874 // which sits above all other focusable windows
875 return 29;
876 case TYPE_ACCESSIBILITY_OVERLAY:
877 // overlay put by accessibility services to intercept user interaction
878 return 30;
879 case TYPE_SECURE_SYSTEM_OVERLAY:
880 return 31;
881 case TYPE_BOOT_PROGRESS:
882 return 32;
883 case TYPE_POINTER:
884 // the (mouse) pointer layer
885 return 33;
886 default:
887 Slog.e("WindowManager", "Unknown window type: " + type);
888 return APPLICATION_LAYER;
889 }
890 }
891
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800892 /**
893 * Return how to Z-order sub-windows in relation to the window they are attached to.
894 * Return positive to have them ordered in front, negative for behind.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700895 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800896 * @param type The sub-window type code.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700897 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800898 * @return int Layer in relation to the attached window, where positive is
899 * above and negative is below.
900 */
Wale Ogunwale5cd907d2017-01-26 14:14:08 -0800901 default int getSubWindowLayerFromTypeLw(int type) {
902 switch (type) {
903 case TYPE_APPLICATION_PANEL:
904 case TYPE_APPLICATION_ATTACHED_DIALOG:
905 return APPLICATION_PANEL_SUBLAYER;
906 case TYPE_APPLICATION_MEDIA:
907 return APPLICATION_MEDIA_SUBLAYER;
908 case TYPE_APPLICATION_MEDIA_OVERLAY:
909 return APPLICATION_MEDIA_OVERLAY_SUBLAYER;
910 case TYPE_APPLICATION_SUB_PANEL:
911 return APPLICATION_SUB_PANEL_SUBLAYER;
912 case TYPE_APPLICATION_ABOVE_SUB_PANEL:
913 return APPLICATION_ABOVE_SUB_PANEL_SUBLAYER;
914 }
915 Slog.e("WindowManager", "Unknown sub-window type: " + type);
916 return 0;
917 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800918
919 /**
Dianne Hackborn6136b7e2009-09-18 01:53:49 -0700920 * Get the highest layer (actually one more than) that the wallpaper is
921 * allowed to be in.
922 */
923 public int getMaxWallpaperLayer();
Dianne Hackborna4b7f2f2012-05-21 11:28:41 -0700924
925 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200926 * Return whether the given window can become the Keyguard window. Typically returns true for
927 * the StatusBar.
Jorim Jaggi0d674622014-05-21 01:34:15 +0200928 */
929 public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs);
930
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700931 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200932 * @return whether {@param win} can be hidden by Keyguard
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700933 */
Jorim Jaggife762342016-10-13 14:33:27 +0200934 public boolean canBeHiddenByKeyguardLw(WindowState win);
Craig Mautner7d7808f2014-09-11 18:02:38 -0700935
936 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800937 * Called when the system would like to show a UI to indicate that an
938 * application is starting. You can use this to add a
939 * APPLICATION_STARTING_TYPE window with the given appToken to the window
940 * manager (using the normal window manager APIs) that will be shown until
941 * the application displays its own window. This is called without the
942 * window manager locked so that you can call back into it.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700943 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800944 * @param appToken Token of the application being started.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700945 * @param packageName The name of the application package being started.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800946 * @param theme Resource defining the application's overall visual theme.
947 * @param nonLocalizedLabel The default title label of the application if
948 * no data is found in the resource.
949 * @param labelRes The resource ID the application would like to use as its name.
950 * @param icon The resource ID the application would like to use as its icon.
Dianne Hackborn7eec10e2010-11-12 18:03:47 -0800951 * @param windowFlags Window layout flags.
Wale Ogunwaledfc18622016-04-16 15:08:48 -0700952 * @param overrideConfig override configuration to consider when generating
953 * context to for resources.
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800954 * @param displayId Id of the display to show the splash screen at.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700955 *
Jorim Jaggi02886a82016-12-06 09:10:06 -0800956 * @return The starting surface.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700957 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800958 */
Jorim Jaggiba41f4b2016-12-14 17:43:07 -0800959 public StartingSurface addSplashScreen(IBinder appToken, String packageName, int theme,
960 CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon,
Andrii Kulianfb1bf692017-01-17 11:17:34 -0800961 int logo, int windowFlags, Configuration overrideConfig, int displayId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962
963 /**
Tiger Huang7c610aa2018-10-27 00:01:01 +0800964 * Set or clear a window which can behave as the keyguard.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -0700965 *
Tiger Huang7c610aa2018-10-27 00:01:01 +0800966 * @param win The window which can behave as the keyguard.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800967 */
Tiger Huang7c610aa2018-10-27 00:01:01 +0800968 void setKeyguardCandidateLw(@Nullable WindowState win);
Craig Mautner3c174372013-02-21 17:54:37 -0800969
970 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200971 * Create and return an animation to re-display a window that was force hidden by Keyguard.
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700972 */
Jorim Jaggife762342016-10-13 14:33:27 +0200973 public Animation createHiddenByKeyguardExit(boolean onWallpaper,
Issei Suzuki5609ccb2019-06-13 15:04:08 +0200974 boolean goingToNotificationShade, boolean subtleAnimation);
Jorim Jaggi76a16232014-08-08 17:00:47 +0200975
976 /**
Jorim Jaggife762342016-10-13 14:33:27 +0200977 * Create and return an animation to let the wallpaper disappear after being shown behind
978 * Keyguard.
Jorim Jaggi76a16232014-08-08 17:00:47 +0200979 */
Jorim Jaggife762342016-10-13 14:33:27 +0200980 public Animation createKeyguardWallpaperExit(boolean goingToNotificationShade);
Jorim Jaggi76a16232014-08-08 17:00:47 +0200981
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700982 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700983 * Called from the input reader thread before a key is enqueued.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984 *
985 * <p>There are some actions that need to be handled here because they
986 * affect the power state of the device, for example, the power keys.
987 * Generally, it's best to keep as little as possible in the queue thread
988 * because it's the most fragile.
Jeff Brown1f245102010-11-18 20:53:46 -0800989 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -0700990 * @param policyFlags The policy flags associated with the key.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800991 *
Jeff Brown26875502014-01-30 21:47:47 -0800992 * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800993 */
Jeff Brown037c33e2014-04-09 00:31:55 -0700994 public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -0800995
996 /**
Michael Wright70af00a2014-09-03 19:30:20 -0700997 * Called from the input reader thread before a motion is enqueued when the device is in a
998 * non-interactive state.
Jeff Brown56194eb2011-03-02 19:23:13 -0800999 *
1000 * <p>There are some actions that need to be handled here because they
1001 * affect the power state of the device, for example, waking on motions.
1002 * Generally, it's best to keep as little as possible in the queue thread
1003 * because it's the most fragile.
Charles Chen4cc014e12019-01-28 16:17:16 +08001004 * @param displayId The display ID of the motion event.
Jeff Brown56194eb2011-03-02 19:23:13 -08001005 * @param policyFlags The policy flags associated with the motion.
1006 *
Jeff Brown26875502014-01-30 21:47:47 -08001007 * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
Jeff Brown56194eb2011-03-02 19:23:13 -08001008 */
Charles Chen4cc014e12019-01-28 16:17:16 +08001009 int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos,
1010 int policyFlags);
Jeff Brown56194eb2011-03-02 19:23:13 -08001011
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001012 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001013 * Called from the input dispatcher thread before a key is dispatched to a window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001014 *
1015 * <p>Allows you to define
Jeff Brown3915bb82010-11-05 15:02:16 -07001016 * behavior for keys that can not be overridden by applications.
1017 * This method is called from the input thread, with no locks held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001018 *
Vishnu Nair539334a2019-09-20 10:46:21 -07001019 * @param focusedToken Client window token that currently has focus. This is where the key
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001020 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -08001021 * @param event The key event.
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001022 * @param policyFlags The policy flags associated with the key.
Jeff Brownd5bb82d2011-10-12 13:57:59 -07001023 * @return 0 if the key should be dispatched immediately, -1 if the key should
1024 * not be dispatched ever, or a positive value indicating the number of
1025 * milliseconds by which the key dispatch should be delayed before trying
1026 * again.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001027 */
Vishnu Nair539334a2019-09-20 10:46:21 -07001028 long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event, int policyFlags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001029
1030 /**
Jeff Brown3915bb82010-11-05 15:02:16 -07001031 * Called from the input dispatcher thread when an application did not handle
1032 * a key that was dispatched to it.
1033 *
1034 * <p>Allows you to define default global behavior for keys that were not handled
1035 * by applications. This method is called from the input thread, with no locks held.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001036 *
Vishnu Nair539334a2019-09-20 10:46:21 -07001037 * @param focusedToken Client window token that currently has focus. This is where the key
Jeff Brown3915bb82010-11-05 15:02:16 -07001038 * event will normally go.
Jeff Brown1f245102010-11-18 20:53:46 -08001039 * @param event The key event.
Jeff Brown3915bb82010-11-05 15:02:16 -07001040 * @param policyFlags The policy flags associated with the key.
Jeff Brown49ed71d2010-12-06 17:13:33 -08001041 * @return Returns an alternate key event to redispatch as a fallback, or null to give up.
1042 * The caller is responsible for recycling the key event.
Jeff Brown3915bb82010-11-05 15:02:16 -07001043 */
Vishnu Nair539334a2019-09-20 10:46:21 -07001044 KeyEvent dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags);
Jeff Brown3915bb82010-11-05 15:02:16 -07001045
1046 /**
Tiger Huang51c5a1d2018-12-11 20:24:51 +08001047 * Called when the top focused display is changed.
1048 *
1049 * @param displayId The ID of the top focused display.
1050 */
1051 void setTopFocusedDisplay(int displayId);
1052
1053 /**
Tiger Huang7c610aa2018-10-27 00:01:01 +08001054 * Apply the keyguard policy to a specific window.
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001055 *
Tiger Huang7c610aa2018-10-27 00:01:01 +08001056 * @param win The window to apply the keyguard policy.
1057 * @param imeTarget The current IME target window.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001058 */
Tiger Huang7c610aa2018-10-27 00:01:01 +08001059 void applyKeyguardPolicyLw(WindowState win, WindowState imeTarget);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001060
1061 /**
Tiger Huang7c610aa2018-10-27 00:01:01 +08001062 * Called when the state of allow-lockscreen-when-on of the display is changed. See
1063 * {@link WindowManager.LayoutParams#FLAG_ALLOW_LOCK_WHILE_SCREEN_ON}
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001064 *
Tiger Huang7c610aa2018-10-27 00:01:01 +08001065 * @param displayId The ID of the display.
1066 * @param allow Whether the display allows showing lockscreen when it is on.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001067 */
Tiger Huang7c610aa2018-10-27 00:01:01 +08001068 void setAllowLockscreenWhenOn(int displayId, boolean allow);
Jeff Brown36c4db82014-09-19 12:05:31 -07001069
1070 /**
Jeff Brown416c49c2015-05-26 19:50:18 -07001071 * Called when the device has started waking up.
Jeff Brown36c4db82014-09-19 12:05:31 -07001072 */
Michael Wrighte3001042019-02-05 00:13:14 +00001073 void startedWakingUp(@OnReason int reason);
Jeff Brown36c4db82014-09-19 12:05:31 -07001074
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001075 /**
Jeff Brown416c49c2015-05-26 19:50:18 -07001076 * Called when the device has finished waking up.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001077 */
Michael Wrighte3001042019-02-05 00:13:14 +00001078 void finishedWakingUp(@OnReason int reason);
Jeff Brown416c49c2015-05-26 19:50:18 -07001079
1080 /**
1081 * Called when the device has started going to sleep.
1082 *
1083 * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1084 * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1085 */
1086 public void startedGoingToSleep(int why);
1087
1088 /**
1089 * Called when the device has finished going to sleep.
1090 *
1091 * @param why {@link #OFF_BECAUSE_OF_USER}, {@link #OFF_BECAUSE_OF_ADMIN},
1092 * or {@link #OFF_BECAUSE_OF_TIMEOUT}.
1093 */
1094 public void finishedGoingToSleep(int why);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001095
Jeff Brown36c4db82014-09-19 12:05:31 -07001096 /**
1097 * Called when the device is about to turn on the screen to show content.
1098 * When waking up, this method will be called once after the call to wakingUp().
1099 * When dozing, the method will be called sometime after the call to goingToSleep() and
1100 * may be called repeatedly in the case where the screen is pulsing on and off.
1101 *
1102 * Must call back on the listener to tell it when the higher-level system
1103 * is ready for the screen to go on (i.e. the lock screen is shown).
1104 */
1105 public void screenTurningOn(ScreenOnListener screenOnListener);
1106
Jeff Brown3ee549c2014-09-22 20:14:39 -07001107 /**
Jorim Jaggi0d210f62015-07-10 14:24:44 -07001108 * Called when the device has actually turned on the screen, i.e. the display power state has
1109 * been set to ON and the screen is unblocked.
1110 */
1111 public void screenTurnedOn();
1112
1113 /**
Jorim Jaggi51304d72017-05-17 17:25:32 +02001114 * Called when the display would like to be turned off. This gives policy a chance to do some
1115 * things before the display power state is actually changed to off.
1116 *
1117 * @param screenOffListener Must be called to tell that the display power state can actually be
1118 * changed now after policy has done its work.
1119 */
1120 public void screenTurningOff(ScreenOffListener screenOffListener);
1121
1122 /**
Jeff Brown3ee549c2014-09-22 20:14:39 -07001123 * Called when the device has turned the screen off.
1124 */
1125 public void screenTurnedOff();
1126
Dianne Hackborn38e29a62011-09-18 14:43:08 -07001127 public interface ScreenOnListener {
1128 void onScreenOn();
Craig Mautner61ac6bb2012-02-02 17:29:33 -08001129 }
Dianne Hackborn38e29a62011-09-18 14:43:08 -07001130
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001131 /**
Jorim Jaggi51304d72017-05-17 17:25:32 +02001132 * See {@link #screenTurnedOff}
1133 */
1134 public interface ScreenOffListener {
1135 void onScreenOff();
1136 }
1137
1138 /**
Jeff Brown3ee549c2014-09-22 20:14:39 -07001139 * Return whether the default display is on and not blocked by a black surface.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001140 */
Jeff Brown3ee549c2014-09-22 20:14:39 -07001141 public boolean isScreenOn();
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001142
Dianne Hackbornde2606d2009-12-18 16:53:55 -08001143 /**
Adrian Roos7c894802017-07-19 12:25:34 +02001144 * @return whether the device is currently allowed to animate.
Adrian Roose94c15c2017-05-09 13:17:54 -07001145 *
Adrian Roos7c894802017-07-19 12:25:34 +02001146 * Note: this can be true even if it is not appropriate to animate for reasons that are outside
1147 * of the policy's authority.
Adrian Roose94c15c2017-05-09 13:17:54 -07001148 */
Adrian Roos7c894802017-07-19 12:25:34 +02001149 boolean okToAnimate();
Adrian Roose94c15c2017-05-09 13:17:54 -07001150
1151 /**
Jeff Brown00fa7bd2010-07-02 15:37:36 -07001152 * Tell the policy that the lid switch has changed state.
1153 * @param whenNanos The time when the change occurred in uptime nanoseconds.
1154 * @param lidOpen True if the lid is now open.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001155 */
Jeff Brown46b9ac02010-04-22 18:58:52 -07001156 public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen);
Michael Wright3818c922014-09-02 13:59:07 -07001157
1158 /**
1159 * Tell the policy that the camera lens has been covered or uncovered.
1160 * @param whenNanos The time when the change occurred in uptime nanoseconds.
1161 * @param lensCovered True if the lens is covered.
1162 */
1163 public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered);
1164
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001165 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001166 * Tell the policy if anyone is requesting that keyguard not come on.
1167 *
1168 * @param enabled Whether keyguard can be on or not. does not actually
1169 * turn it on, unless it was previously disabled with this function.
1170 *
1171 * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard()
1172 * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard()
1173 */
Craig Mautner3c174372013-02-21 17:54:37 -08001174 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001175 public void enableKeyguard(boolean enabled);
1176
1177 /**
Adrian Roose99bc052017-11-20 17:55:31 +01001178 * Callback used by {@link #exitKeyguardSecurely}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001179 */
1180 interface OnKeyguardExitResult {
1181 void onKeyguardExitResult(boolean success);
1182 }
1183
1184 /**
1185 * Tell the policy if anyone is requesting the keyguard to exit securely
1186 * (this would be called after the keyguard was disabled)
1187 * @param callback Callback to send the result back.
1188 * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult)
1189 */
Craig Mautner3c174372013-02-21 17:54:37 -08001190 @SuppressWarnings("javadoc")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001191 void exitKeyguardSecurely(OnKeyguardExitResult callback);
1192
1193 /**
Mike Lockwood520d8bc2011-02-18 13:23:13 -05001194 * isKeyguardLocked
1195 *
1196 * Return whether the keyguard is currently locked.
1197 *
1198 * @return true if in keyguard is locked.
1199 */
1200 public boolean isKeyguardLocked();
1201
1202 /**
1203 * isKeyguardSecure
1204 *
1205 * Return whether the keyguard requires a password to unlock.
Jim Millere4044bb2016-05-10 18:38:25 -07001206 * @param userId
Mike Lockwood520d8bc2011-02-18 13:23:13 -05001207 *
1208 * @return true if in keyguard is secure.
1209 */
Jim Millere4044bb2016-05-10 18:38:25 -07001210 public boolean isKeyguardSecure(int userId);
Mike Lockwood520d8bc2011-02-18 13:23:13 -05001211
1212 /**
Jorim Jaggife762342016-10-13 14:33:27 +02001213 * Return whether the keyguard is currently occluded.
Adrian Roos461829d2015-06-03 14:41:18 -07001214 *
Jorim Jaggife762342016-10-13 14:33:27 +02001215 * @return true if in keyguard is occluded, false otherwise
Adrian Roos461829d2015-06-03 14:41:18 -07001216 */
Jorim Jaggife762342016-10-13 14:33:27 +02001217 public boolean isKeyguardOccluded();
Adrian Roos461829d2015-06-03 14:41:18 -07001218
1219 /**
Tony Mak2c0d6dc2016-04-29 16:16:54 +01001220 * @return true if in keyguard is on and not occluded.
1221 */
1222 public boolean isKeyguardShowingAndNotOccluded();
1223
1224 /**
Jorim Jaggife762342016-10-13 14:33:27 +02001225 * @return whether Keyguard is in trusted state and can be dismissed without credentials
1226 */
1227 public boolean isKeyguardTrustedLw();
1228
1229 /**
Siarhei Vishniakou35fbb312017-12-13 13:48:50 -08001230 * inKeyguardRestrictedKeyInputMode
1231 *
1232 * If keyguard screen is showing or in restricted key input mode (i.e. in
1233 * keyguard password emergency screen). When in such mode, certain keys,
1234 * such as the Home key and the right soft keys, don't work.
1235 *
1236 * @return true if in keyguard restricted input mode.
1237 */
1238 public boolean inKeyguardRestrictedKeyInputMode();
1239
1240 /**
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001241 * Ask the policy to dismiss the keyguard, if it is currently shown.
Jorim Jaggi241ae102016-11-02 21:57:33 -07001242 *
1243 * @param callback Callback to be informed about the result.
Lucas Dupinc80c67e2017-12-04 14:29:10 -08001244 * @param message A message that should be displayed in the keyguard.
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001245 */
Lucas Dupinc80c67e2017-12-04 14:29:10 -08001246 public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback,
1247 CharSequence message);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07001248
1249 /**
Jorim Jaggicff0acb2014-03-31 16:35:15 +02001250 * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method
1251 * returns true as soon as we know that Keyguard is disabled.
1252 *
1253 * @return true if the keyguard has drawn.
1254 */
1255 public boolean isKeyguardDrawnLw();
1256
1257 /**
Jeff Brownac143512012-04-05 18:57:33 -07001258 * Called when the system is mostly done booting to set whether
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001259 * the system should go into safe mode.
1260 */
Jeff Brownac143512012-04-05 18:57:33 -07001261 public void setSafeMode(boolean safeMode);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001262
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001263 /**
1264 * Called when the system is mostly done booting.
1265 */
1266 public void systemReady();
1267
1268 /**
Dianne Hackbornba24e4d2011-09-01 11:17:06 -07001269 * Called when the system is done booting to the point where the
1270 * user can start interacting with it.
1271 */
1272 public void systemBooted();
1273
1274 /**
Dianne Hackborn661cd522011-08-22 00:26:20 -07001275 * Show boot time message to the user.
1276 */
1277 public void showBootMessage(final CharSequence msg, final boolean always);
1278
1279 /**
1280 * Hide the UI for showing boot messages, never to be displayed again.
1281 */
1282 public void hideBootMessages();
1283
1284 /**
Mike Lockwoodef731622010-01-27 17:51:34 -05001285 * Called when userActivity is signalled in the power manager.
1286 * This is safe to call from any thread, with any window manager locks held or not.
1287 */
1288 public void userActivity();
1289
1290 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001291 * Called when we have finished booting and can now display the home
Jeff Brownc042ee22012-05-08 13:03:42 -07001292 * screen to the user. This will happen after systemReady(), and at
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001293 * this point the display is active.
1294 */
1295 public void enableScreenAfterBoot();
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001296
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001297 /**
1298 * Call from application to perform haptic feedback on its window.
1299 */
Arthur Hunga4c52062019-02-19 11:31:44 +08001300 public boolean performHapticFeedback(int uid, String packageName, int effectId,
1301 boolean always, String reason);
Filip Gruszczynski2a6a2c22015-10-14 12:00:53 -07001302
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001303 /**
Daniel Sandler0601eb72011-04-13 01:01:32 -04001304 * Called when we have started keeping the screen on because a window
1305 * requesting this has become visible.
1306 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001307 public void keepScreenOnStartedLw();
Daniel Sandler0601eb72011-04-13 01:01:32 -04001308
1309 /**
1310 * Called when we have stopped keeping the screen on because the last window
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001311 * requesting this is no longer visible.
1312 */
Jeff Brownc38c9be2012-10-04 13:16:19 -07001313 public void keepScreenOnStoppedLw();
Daniel Sandlerb73617d2010-08-17 00:41:00 -04001314
1315 /**
Winsonab216602016-08-09 14:05:20 -07001316 * Called by System UI to notify of changes to the visibility of Recents.
1317 */
1318 public void setRecentsVisibilityLw(boolean visible);
1319
1320 /**
1321 * Called by System UI to notify of changes to the visibility of PIP.
1322 */
Winson Chungac52f282017-03-30 14:44:52 -07001323 void setPipVisibilityLw(boolean visible);
Winsonab216602016-08-09 14:05:20 -07001324
1325 /**
Matthew Ng64543e62018-02-28 17:35:10 -08001326 * Called by System UI to enable or disable haptic feedback on the navigation bar buttons.
1327 */
1328 void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled);
1329
1330 /**
Daniel Sandler0c4ccff2011-10-19 16:39:14 -04001331 * Specifies whether there is an on-screen navigation bar separate from the status bar.
1332 */
1333 public boolean hasNavigationBar();
1334
1335 /**
Jim Miller93c518e2012-01-17 15:55:31 -08001336 * Lock the device now.
1337 */
Adam Cohenf7522022012-10-03 20:03:18 -07001338 public void lockNow(Bundle options);
Jim Miller93c518e2012-01-17 15:55:31 -08001339
1340 /**
Yohei Yukawad6475a62017-04-17 10:35:27 -07001341 * An internal callback (from InputMethodManagerService) to notify a state change regarding
1342 * whether the back key should dismiss the software keyboard (IME) or not.
1343 *
1344 * @param newValue {@code true} if the software keyboard is shown and the back key is expected
1345 * to dismiss the software keyboard.
1346 * @hide
1347 */
1348 default void setDismissImeOnBackKeyPressed(boolean newValue) {
1349 // Default implementation does nothing.
1350 }
1351
1352 /**
Craig Mautner84984fa2014-06-19 11:19:20 -07001353 * Show the recents task list app.
1354 * @hide
1355 */
Winson Chungdff7a732017-12-11 12:17:06 -08001356 public void showRecentApps();
Craig Mautner84984fa2014-06-19 11:19:20 -07001357
1358 /**
Alan Viverettee34560b22014-07-10 14:50:06 -07001359 * Show the global actions dialog.
1360 * @hide
1361 */
1362 public void showGlobalActions();
1363
1364 /**
Tiger Huang7c610aa2018-10-27 00:01:01 +08001365 * Returns whether the user setup is complete.
1366 */
1367 boolean isUserSetupComplete();
1368
1369 /**
1370 * Returns the current UI mode.
1371 */
1372 int getUiMode();
1373
1374 /**
Craig Mautnerf1b67412012-09-19 13:18:29 -07001375 * Called when the current user changes. Guaranteed to be called before the broadcast
1376 * of the new user id is made to all listeners.
1377 *
1378 * @param newUserId The id of the incoming user.
1379 */
1380 public void setCurrentUserLw(int newUserId);
Svetoslav Ganov1cf70bb2012-08-06 10:53:34 -07001381
1382 /**
Evan Rosky18396452016-07-27 15:19:37 -07001383 * For a given user-switch operation, this will be called once with switching=true before the
1384 * user-switch and once with switching=false afterwards (or if the user-switch was cancelled).
1385 * This gives the policy a chance to alter its behavior for the duration of a user-switch.
1386 *
1387 * @param switching true if a user-switch is in progress
1388 */
1389 void setSwitchingUser(boolean switching);
1390
1391 /**
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001392 * Print the WindowManagerPolicy's state into the given stream.
1393 *
1394 * @param prefix Text to print at the front of each line.
Dianne Hackbornf99f9c52011-01-12 15:49:25 -08001395 * @param writer The PrintWriter to which you should dump your state. This will be
1396 * closed for you after you return.
1397 * @param args additional arguments to the dump request.
1398 */
Jeff Brownd7a04de2012-06-17 14:17:52 -07001399 public void dump(String prefix, PrintWriter writer, String[] args);
Jim Miller4eeb4f62012-11-08 00:04:29 -08001400
1401 /**
Steven Timotiusaf03df62017-07-18 16:56:43 -07001402 * Write the WindowManagerPolicy's state into the protocol buffer.
Yi Jin6c6e9ca2018-03-20 16:53:35 -07001403 * The message is described in {@link com.android.server.wm.WindowManagerPolicyProto}
Steven Timotiusaf03df62017-07-18 16:56:43 -07001404 *
1405 * @param proto The protocol buffer output stream to write to.
1406 */
Jeffrey Huangcb782852019-12-05 11:28:11 -08001407 void dumpDebug(ProtoOutputStream proto, long fieldId);
Steven Timotiusaf03df62017-07-18 16:56:43 -07001408
1409 /**
Svetoslav Ganov545252f2012-12-10 18:29:24 -08001410 * Returns whether a given window type is considered a top level one.
1411 * A top level window does not have a container, i.e. attached window,
1412 * or if it has a container it is laid out as a top-level window, not
1413 * as a child of its container.
1414 *
1415 * @param windowType The window type.
1416 * @return True if the window is a top level one.
1417 */
1418 public boolean isTopLevelWindow(int windowType);
Jorim Jaggi0d674622014-05-21 01:34:15 +02001419
1420 /**
1421 * Notifies the keyguard to start fading out.
Jorim Jaggie29b2db2014-05-30 23:17:03 +02001422 *
1423 * @param startTime the start time of the animation in uptime milliseconds
1424 * @param fadeoutDuration the duration of the exit animation, in milliseconds
Jorim Jaggi0d674622014-05-21 01:34:15 +02001425 */
Jorim Jaggie29b2db2014-05-30 23:17:03 +02001426 public void startKeyguardExitAnimation(long startTime, long fadeoutDuration);
Jorim Jaggi737af722015-12-31 10:42:27 +01001427
1428 /**
Keun-young Park4136d2d2017-05-08 14:51:59 -07001429 * Called when System UI has been started.
1430 */
1431 void onSystemUiStarted();
1432
1433 /**
1434 * Checks whether the policy is ready for dismissing the boot animation and completing the boot.
1435 *
1436 * @return true if ready; false otherwise.
1437 */
1438 boolean canDismissBootAnimation();
Michael Wright19859762017-09-18 20:57:58 +01001439
1440 /**
1441 * Convert the user rotation mode to a human readable format.
1442 */
1443 static String userRotationModeToString(int mode) {
1444 switch(mode) {
1445 case USER_ROTATION_FREE:
1446 return "USER_ROTATION_FREE";
1447 case USER_ROTATION_LOCKED:
1448 return "USER_ROTATION_LOCKED";
1449 default:
1450 return Integer.toString(mode);
1451 }
1452 }
Yoshiaki Nakae1bdfc822017-09-15 15:24:34 +09001453
1454 /**
Jordan Liuc0228762018-07-13 11:39:42 -07001455 * Requests that the WindowManager sends
1456 * WindowManagerPolicyConstants#ACTION_USER_ACTIVITY_NOTIFICATION on the next user activity.
Yoshiaki Nakae1bdfc822017-09-15 15:24:34 +09001457 */
1458 public void requestUserActivityNotification();
Benjamin Franz3662b152018-01-16 17:23:44 +00001459
1460 /**
Adrian Roos962017e2018-11-27 15:11:46 +01001461 * Registers an IDisplayFoldListener.
1462 */
1463 default void registerDisplayFoldListener(IDisplayFoldListener listener) {}
1464
1465 /**
1466 * Unregisters an IDisplayFoldListener.
1467 */
1468 default void unregisterDisplayFoldListener(IDisplayFoldListener listener) {}
1469
1470 /**
Chilun70a9ab92019-02-12 10:57:49 +08001471 * Overrides the folded area.
1472 *
1473 * @param area the overriding folded area or an empty {@code Rect} to clear the override.
1474 */
1475 default void setOverrideFoldedArea(@NonNull Rect area) {}
1476
1477 /**
1478 * Get the display folded area.
1479 */
1480 default @NonNull Rect getFoldedArea() {
1481 return new Rect();
1482 }
1483
1484 /**
Issei Suzuki9f840c72018-12-07 15:09:30 -08001485 * A new window on default display has been focused.
1486 */
1487 default void onDefaultDisplayFocusChangedLw(WindowState newFocus) {}
1488
1489 /**
chaviw0e9fb132018-06-05 16:29:13 -07001490 * Updates the flag about whether AOD is showing.
1491 *
1492 * @return whether the value was changed.
1493 */
1494 boolean setAodShowing(boolean aodShowing);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001495}