The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 2 | * Copyright (C) 2017 The Android Open Source Project |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 17 | package com.android.server.policy; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 18 | |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 19 | import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; |
| 20 | import static android.view.WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; |
| 21 | import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY; |
| 22 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL; |
| 23 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; |
| 24 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA; |
| 25 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY; |
| 26 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; |
| 27 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; |
| 28 | import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_SUB_PANEL; |
| 29 | import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; |
| 30 | import static android.view.WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY; |
| 31 | import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; |
| 32 | import static android.view.WindowManager.LayoutParams.TYPE_DRAG; |
| 33 | import static android.view.WindowManager.LayoutParams.TYPE_DREAM; |
| 34 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_CONSUMER; |
| 35 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; |
| 36 | import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; |
| 37 | import static android.view.WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG; |
| 38 | import static android.view.WindowManager.LayoutParams.TYPE_MAGNIFICATION_OVERLAY; |
| 39 | import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR; |
| 40 | import static android.view.WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL; |
| 41 | import static android.view.WindowManager.LayoutParams.TYPE_PHONE; |
| 42 | import static android.view.WindowManager.LayoutParams.TYPE_POINTER; |
| 43 | import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION; |
| 44 | import static android.view.WindowManager.LayoutParams.TYPE_PRIORITY_PHONE; |
| 45 | import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION; |
| 46 | import static android.view.WindowManager.LayoutParams.TYPE_QS_DIALOG; |
| 47 | import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT; |
| 48 | import static android.view.WindowManager.LayoutParams.TYPE_SEARCH_BAR; |
| 49 | import static android.view.WindowManager.LayoutParams.TYPE_SECURE_SYSTEM_OVERLAY; |
| 50 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR; |
| 51 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL; |
| 52 | import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL; |
| 53 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; |
| 54 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG; |
| 55 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; |
| 56 | import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; |
| 57 | import static android.view.WindowManager.LayoutParams.TYPE_TOAST; |
| 58 | import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION; |
| 59 | import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION_STARTING; |
| 60 | import static android.view.WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY; |
| 61 | import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER; |
| 62 | import static android.view.WindowManager.LayoutParams.isSystemAlertWindowType; |
| 63 | |
Yohei Yukawa | d0a66b2 | 2018-01-10 13:19:54 -0800 | [diff] [blame] | 64 | import static java.lang.annotation.RetentionPolicy.SOURCE; |
| 65 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 66 | import android.annotation.IntDef; |
Chilun | 70a9ab9 | 2019-02-12 10:57:49 +0800 | [diff] [blame] | 67 | import android.annotation.NonNull; |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 68 | import android.annotation.Nullable; |
Matthew Ng | 605ea47 | 2018-08-30 21:30:06 -0700 | [diff] [blame] | 69 | import android.app.WindowConfiguration; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | import android.content.Context; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 71 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | import android.content.res.Configuration; |
| 73 | import android.graphics.Rect; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 74 | import android.os.Bundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | import android.os.IBinder; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 76 | import android.os.Looper; |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 77 | import android.os.RemoteException; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 78 | import android.util.Slog; |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 79 | import android.util.proto.ProtoOutputStream; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 80 | import android.view.Display; |
| 81 | import android.view.IApplicationToken; |
Adrian Roos | 962017e | 2018-11-27 15:11:46 +0100 | [diff] [blame] | 82 | import android.view.IDisplayFoldListener; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 83 | import android.view.IWindowManager; |
| 84 | import android.view.InputEventReceiver; |
| 85 | import android.view.KeyEvent; |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 86 | import android.view.WindowManager; |
| 87 | import android.view.WindowManagerGlobal; |
| 88 | import android.view.WindowManagerPolicyConstants; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | import android.view.animation.Animation; |
Aurimas Liutikas | 67e2ae8 | 2016-10-11 18:17:42 -0700 | [diff] [blame] | 90 | |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 91 | import com.android.internal.policy.IKeyguardDismissCallback; |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 92 | import com.android.internal.policy.IShortcutService; |
Riddle Hsu | ad256a1 | 2018-07-18 16:11:30 +0800 | [diff] [blame] | 93 | import com.android.server.wm.DisplayRotation; |
chaviw | 553b021 | 2018-07-12 13:37:01 -0700 | [diff] [blame] | 94 | import com.android.server.wm.WindowFrames; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 96 | import java.io.PrintWriter; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 97 | import java.lang.annotation.Retention; |
| 98 | import java.lang.annotation.RetentionPolicy; |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 99 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | /** |
| 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 105 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 106 | * <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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 114 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | * <p>The current suffixes are: |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 116 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | * <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 Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 131 | * okay to make calls into the activity manager or most other services. Note that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 132 | * {@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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 138 | */ |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 139 | public interface WindowManagerPolicy extends WindowManagerPolicyConstants { |
Yohei Yukawa | d0a66b2 | 2018-01-10 13:19:54 -0800 | [diff] [blame] | 140 | @Retention(SOURCE) |
| 141 | @IntDef({NAV_BAR_LEFT, NAV_BAR_RIGHT, NAV_BAR_BOTTOM}) |
| 142 | @interface NavigationBarPosition {} |
| 143 | |
Bryce Lee | 01b0c5f | 2015-02-05 18:24:04 -0800 | [diff] [blame] | 144 | /** |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 145 | * Pass this event to the user / app. To be returned from |
| 146 | * {@link #interceptKeyBeforeQueueing}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 147 | */ |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 148 | 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 Nair | 83537a7 | 2018-07-19 21:27:48 -0700 | [diff] [blame] | 157 | /** Layer for the screen off animation */ |
| 158 | int COLOR_FADE_LAYER = 0x40000001; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 159 | |
| 160 | /** |
Muyuan Li | 94ce94e | 2016-02-24 16:20:54 -0800 | [diff] [blame] | 161 | * 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 Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 169 | * Called when the Keyguard occluded state changed. |
| 170 | * @param occluded Whether Keyguard is currently occluded or not. |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 171 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 172 | void onKeyguardOccludedChangedLw(boolean occluded); |
Adrian Roos | d88eb26 | 2016-08-04 14:50:48 -0700 | [diff] [blame] | 173 | |
| 174 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | * Interface to the Window Manager state associated with a particular |
Vishnu Nair | 539334a | 2019-09-20 10:46:21 -0700 | [diff] [blame] | 176 | * window. You can hold on to an instance of this interface from the call |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 177 | * to prepareAddWindow() until removeWindow(). |
| 178 | */ |
| 179 | public interface WindowState { |
| 180 | /** |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 181 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | * 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 194 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | */ |
chaviw | 1454b39 | 2018-08-06 09:54:04 -0700 | [diff] [blame] | 196 | public void computeFrameLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 197 | |
| 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 201 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 202 | * @return Rect The rectangle holding the window frame. |
| 203 | */ |
| 204 | public Rect getFrameLw(); |
| 205 | |
| 206 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 207 | * 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 Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 210 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 211 | * @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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 222 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | * @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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 234 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 235 | * @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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 245 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 246 | /** |
| 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 250 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 251 | * @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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 260 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | * @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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 268 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 269 | * @return WindowManager.LayoutParams The window's internal LayoutParams |
| 270 | * instance. |
| 271 | */ |
| 272 | public WindowManager.LayoutParams getAttrs(); |
| 273 | |
| 274 | /** |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 275 | * 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 Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 283 | * Retrieve the current system UI visibility flags associated with |
| 284 | * this window. |
| 285 | */ |
| 286 | public int getSystemUiVisibility(); |
| 287 | |
| 288 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 289 | * Get the layer at which this window's surface will be Z-ordered. |
| 290 | */ |
| 291 | public int getSurfaceLayer(); |
Selim Cinek | d662361 | 2015-05-22 18:56:22 -0700 | [diff] [blame] | 292 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 293 | /** |
Selim Cinek | d662361 | 2015-05-22 18:56:22 -0700 | [diff] [blame] | 294 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 304 | * @return An IApplicationToken identifying the owning activity. |
| 305 | */ |
| 306 | public IApplicationToken getAppToken(); |
| 307 | |
| 308 | /** |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 309 | * Return true if this window is participating in voice interaction. |
| 310 | */ |
| 311 | public boolean isVoiceInteraction(); |
| 312 | |
| 313 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 314 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 320 | * else false. |
| 321 | */ |
| 322 | public boolean hasAppShownWindows(); |
| 323 | |
| 324 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 325 | * 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 330 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 331 | /** |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 332 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 334 | * animation before no longer being visible. Must be called with the |
| 335 | * window manager lock held. |
| 336 | */ |
| 337 | boolean isDisplayedLw(); |
| 338 | |
| 339 | /** |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 340 | * Return true if this window (or a window it is attached to, but not |
| 341 | * considering its app token) is currently animating. |
| 342 | */ |
Filip Gruszczynski | 14b4e57 | 2015-11-03 15:53:55 -0800 | [diff] [blame] | 343 | boolean isAnimatingLw(); |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 344 | |
| 345 | /** |
Jorim Jaggi | 23cc9aa | 2017-05-23 16:05:35 +0200 | [diff] [blame] | 346 | * @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 Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 353 | * Is this window considered to be gone for purposes of layout? |
| 354 | */ |
| 355 | boolean isGoneForLayoutLw(); |
| 356 | |
| 357 | /** |
Adrian Roos | 76d2fe4 | 2015-07-09 14:54:08 -0700 | [diff] [blame] | 358 | * 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 366 | * Returns true if this window has been shown on screen at some time in |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 367 | * the past. Must be called with the window manager lock held. |
Jorim Jaggi | a32da38 | 2018-03-28 18:01:22 +0200 | [diff] [blame] | 368 | * |
| 369 | * @deprecated Use {@link #isDrawnLw} or any of the other drawn/visibility methods. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | */ |
Jorim Jaggi | a32da38 | 2018-03-28 18:01:22 +0200 | [diff] [blame] | 371 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 372 | 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 381 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 382 | /** |
| 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 Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 390 | |
| 391 | /** |
| 392 | * Check whether the process hosting this window is currently alive. |
| 393 | */ |
| 394 | public boolean isAlive(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 395 | |
| 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 Roos | cd3884d | 2015-02-18 17:25:23 +0100 | [diff] [blame] | 401 | |
| 402 | /** |
| 403 | * Check whether the window is currently dimming. |
| 404 | */ |
| 405 | public boolean isDimming(); |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 406 | |
Adrian Roos | 865c70f | 2018-01-10 17:32:27 +0100 | [diff] [blame] | 407 | /** |
| 408 | * Returns true if the window is letterboxed for the display cutout. |
| 409 | */ |
| 410 | default boolean isLetterboxedForDisplayCutoutLw() { |
| 411 | return false; |
| 412 | } |
| 413 | |
Adrian Roos | 23df3a3 | 2018-03-15 15:41:13 +0100 | [diff] [blame] | 414 | /** |
| 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 Ogunwale | 44f036f | 2017-09-29 05:09:09 -0700 | [diff] [blame] | 422 | /** @return the current windowing mode of this window. */ |
| 423 | int getWindowingMode(); |
Wale Ogunwale | 9185fb0 | 2016-03-11 18:06:14 -0800 | [diff] [blame] | 424 | |
| 425 | /** |
Matthew Ng | 605ea47 | 2018-08-30 21:30:06 -0700 | [diff] [blame] | 426 | * 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 Ogunwale | 9185fb0 | 2016-03-11 18:06:14 -0800 | [diff] [blame] | 434 | * Returns true if the window is current in multi-windowing mode. i.e. it shares the |
| 435 | * screen with other application windows. |
| 436 | */ |
Evan Rosky | 4fb1e91 | 2019-03-06 13:54:43 -0800 | [diff] [blame] | 437 | boolean inMultiWindowMode(); |
Robert Carr | fd10cd1 | 2016-06-29 16:41:50 -0700 | [diff] [blame] | 438 | |
| 439 | public int getRotationAnimationHint(); |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 440 | |
| 441 | public boolean isInputMethodWindow(); |
| 442 | |
Robert Carr | 825581a | 2018-03-30 14:00:53 -0700 | [diff] [blame] | 443 | public boolean isInputMethodTarget(); |
| 444 | |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 445 | public int getDisplayId(); |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 446 | |
| 447 | /** |
| 448 | * Returns true if the window owner can add internal system windows. |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 449 | * That is, they have {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}. |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 450 | */ |
| 451 | default boolean canAddInternalSystemWindow() { |
| 452 | return false; |
| 453 | } |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 454 | |
| 455 | /** |
| 456 | * Returns true if the window owner has the permission to acquire a sleep token when it's |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 457 | * visible. That is, they have the permission {@link Manifest.permission#DEVICE_POWER}. |
Jorim Jaggi | f12ec0f | 2017-08-23 16:14:10 +0200 | [diff] [blame] | 458 | */ |
| 459 | boolean canAcquireSleepToken(); |
Vishnu Nair | 9a3e406 | 2018-01-11 08:42:54 -0800 | [diff] [blame] | 460 | |
Tiger Huang | 513d5e1 | 2018-07-16 21:49:50 +0800 | [diff] [blame] | 461 | /** @return true if this window desires key events. */ |
| 462 | boolean canReceiveKeys(); |
| 463 | |
lumark | 31e4f8e | 2019-01-10 20:48:18 +0800 | [diff] [blame] | 464 | /** @return true if the window can show over keyguard. */ |
| 465 | boolean canShowWhenLocked(); |
| 466 | |
Vishnu Nair | 9a3e406 | 2018-01-11 08:42:54 -0800 | [diff] [blame] | 467 | /** |
Yi Jin | 6c6e9ca | 2018-03-20 16:53:35 -0700 | [diff] [blame] | 468 | * Writes {@link com.android.server.wm.IdentifierProto} to stream. |
Vishnu Nair | 9a3e406 | 2018-01-11 08:42:54 -0800 | [diff] [blame] | 469 | */ |
| 470 | void writeIdentifierToProto(ProtoOutputStream proto, long fieldId); |
chaviw | 1454b39 | 2018-08-06 09:54:04 -0700 | [diff] [blame] | 471 | |
| 472 | /** |
| 473 | * @return The {@link WindowFrames} associated with this {@link WindowState} |
| 474 | */ |
| 475 | WindowFrames getWindowFrames(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 476 | } |
| 477 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 478 | /** |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 479 | * 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 Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 481 | */ |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 482 | public interface InputConsumer { |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 483 | /** |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 484 | * Remove the input consumer from the window manager. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 485 | */ |
| 486 | void dismiss(); |
| 487 | } |
| 488 | |
| 489 | /** |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 490 | * 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 Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 492 | * held by WM and released with {@link #remove} when no longer needed. |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 493 | */ |
| 494 | interface StartingSurface { |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 495 | |
| 496 | /** |
| 497 | * Removes the starting window surface. Do not hold the window manager lock when calling |
| 498 | * this method! |
| 499 | */ |
| 500 | void remove(); |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 504 | * Interface for calling back in to the window manager that is private |
| 505 | * between it and the policy. |
| 506 | */ |
| 507 | public interface WindowManagerFuncs { |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 508 | 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-Jones | ce7a01f | 2015-12-09 21:16:50 +0100 | [diff] [blame] | 512 | 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 Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 516 | 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 Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 520 | /** |
Selim Cinek | f83e824 | 2015-05-19 18:08:14 -0700 | [diff] [blame] | 521 | * Add a input consumer which will consume all input events going to any window below it. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 522 | */ |
Winson | 4127548 | 2016-10-10 15:17:45 -0700 | [diff] [blame] | 523 | public InputConsumer createInputConsumer(Looper looper, String name, |
Arthur Hung | 95b38a9 | 2018-07-20 18:56:12 +0800 | [diff] [blame] | 524 | InputEventReceiver.Factory inputEventReceiverFactory, int displayId); |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 525 | |
| 526 | /** |
| 527 | * Returns a code that describes the current state of the lid switch. |
| 528 | */ |
| 529 | public int getLidState(); |
| 530 | |
| 531 | /** |
Edward Savage-Jones | 7def60d | 2015-11-13 13:27:03 +0100 | [diff] [blame] | 532 | * Lock the device now. |
| 533 | */ |
| 534 | public void lockDeviceNow(); |
| 535 | |
| 536 | /** |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 537 | * Returns a code that descripbes whether the camera lens is covered or not. |
| 538 | */ |
| 539 | public int getCameraLensCoverState(); |
| 540 | |
| 541 | /** |
Yohei Yukawa | 2d9accb | 2018-03-07 19:15:15 -0800 | [diff] [blame] | 542 | * 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 Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 547 | public void shutdown(boolean confirm); |
Alison Cichowlas | f8eca40 | 2016-08-05 14:50:27 -0400 | [diff] [blame] | 548 | public void reboot(boolean confirm); |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 549 | public void rebootSafeMode(boolean confirm); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 550 | |
| 551 | /** |
| 552 | * Return the window manager lock needed to correctly call "Lw" methods. |
| 553 | */ |
| 554 | public Object getWindowManagerLock(); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 555 | |
| 556 | /** Register a system listener for touch events */ |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 557 | void registerPointerEventListener(PointerEventListener listener, int displayId); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 558 | |
| 559 | /** Unregister a system listener for touch events */ |
Arthur Hung | be5ce21 | 2018-09-13 18:41:56 +0800 | [diff] [blame] | 560 | void unregisterPointerEventListener(PointerEventListener listener, int displayId); |
Jorim Jaggi | 81ba11e | 2016-02-03 22:04:22 -0800 | [diff] [blame] | 561 | |
| 562 | /** |
Wale Ogunwale | 6827856 | 2017-09-23 17:13:55 -0700 | [diff] [blame] | 563 | * Retrieves the {@param outBounds} from the stack matching the {@param windowingMode} and |
| 564 | * {@param activityType}. |
Jorim Jaggi | 8690558 | 2016-02-09 21:36:09 -0800 | [diff] [blame] | 565 | */ |
Wale Ogunwale | 6827856 | 2017-09-23 17:13:55 -0700 | [diff] [blame] | 566 | void getStackBounds(int windowingMode, int activityType, Rect outBounds); |
Jorim Jaggi | 77e1043 | 2016-10-26 17:43:56 -0700 | [diff] [blame] | 567 | |
| 568 | /** |
Jorim Jaggi | 40db029 | 2016-06-27 17:58:03 -0700 | [diff] [blame] | 569 | * @return The currently active input method window. |
| 570 | */ |
| 571 | WindowState getInputMethodWindowLw(); |
| 572 | |
| 573 | /** |
Jorim Jaggi | e69c931 | 2016-10-31 18:24:38 -0700 | [diff] [blame] | 574 | * Notifies window manager that {@link #isKeyguardTrustedLw} has changed. |
| 575 | */ |
| 576 | void notifyKeyguardTrustedChanged(); |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 577 | |
| 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 Wright | 1985976 | 2017-09-18 20:57:58 +0100 | [diff] [blame] | 584 | |
| 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 Roos | 842e788 | 2018-03-26 17:34:06 +0200 | [diff] [blame] | 616 | |
| 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 Roos | 4163d62 | 2018-05-22 16:56:35 +0200 | [diff] [blame] | 622 | |
| 623 | /** |
| 624 | * The keyguard showing state has changed |
| 625 | */ |
| 626 | void onKeyguardShowingAndNotOccludedChanged(); |
Riddle Hsu | ad256a1 | 2018-07-18 16:11:30 +0800 | [diff] [blame] | 627 | |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 628 | /** |
| 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 Huang | dda14a7 | 2019-01-10 17:20:27 +0800 | [diff] [blame] | 637 | |
| 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 Hsu | ad256a1 | 2018-07-18 16:11:30 +0800 | [diff] [blame] | 643 | } |
| 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 Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 662 | } |
| 663 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 664 | /** Window has been added to the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 665 | public static final int TRANSIT_ENTER = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 666 | /** Window has been removed from the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 667 | public static final int TRANSIT_EXIT = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 668 | /** Window has been made visible. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 669 | 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 673 | /** The "application starting" preview window is no longer needed, and will |
| 674 | * animate away to show the real window. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 675 | public static final int TRANSIT_PREVIEW_DONE = 5; |
| 676 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 677 | // NOTE: screen off reasons are in order of significance, with more |
| 678 | // important ones lower than less important ones. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 679 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 680 | /** @hide */ |
| 681 | @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED}) |
| 682 | @Retention(RetentionPolicy.SOURCE) |
| 683 | public @interface UserRotationMode {} |
| 684 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 685 | /** 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 691 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 692 | /** |
Riddle Hsu | 5ce4bb3 | 2018-07-18 16:11:30 +0800 | [diff] [blame] | 693 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 698 | * Perform initialization of the policy. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 699 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 700 | * @param context The system context we are running in. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 701 | */ |
| 702 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 703 | WindowManagerFuncs windowManagerFuncs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 704 | |
| 705 | /** |
| 706 | * Check permissions when adding a window. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 707 | * |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 708 | * @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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 711 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 712 | * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 713 | * else an error code, usually |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 714 | * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 715 | */ |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 716 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 717 | |
| 718 | /** |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 719 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 729 | * 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 733 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 734 | * <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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 736 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 737 | * @param config The Configuration being computed, for you to change as |
| 738 | * desired. |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 739 | * @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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 743 | */ |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 744 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 745 | int navigationPresence); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 746 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 747 | /** |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 748 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 760 | * kinds of windows are ordered on-screen. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 761 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 762 | * @param type The type of window being assigned. |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 763 | * @return int An arbitrary integer used to order windows, with lower numbers below higher ones. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 764 | */ |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 765 | 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 772 | |
| 773 | /** |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 774 | * 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 Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 780 | * {@link Manifest.permission#INTERNAL_SYSTEM_WINDOW}. If true, alert window |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 781 | * 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 Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 821 | case TYPE_SYSTEM_ALERT: |
| 822 | // like the ANR / app crashed dialogs |
Vishnu Nair | 90f97fe | 2019-03-20 10:09:43 -0700 | [diff] [blame] | 823 | // 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 Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 826 | case TYPE_APPLICATION_OVERLAY: |
Vishnu Nair | 9ccb1d2 | 2019-03-20 16:32:44 +0000 | [diff] [blame] | 827 | return 12; |
Wale Ogunwale | d993a57 | 2017-02-05 13:52:09 -0800 | [diff] [blame] | 828 | case TYPE_DREAM: |
| 829 | // used for Dreams (screensavers with TYPE_DREAM windows) |
Vishnu Nair | 90f97fe | 2019-03-20 10:09:43 -0700 | [diff] [blame] | 830 | return 14; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 831 | case TYPE_INPUT_METHOD: |
| 832 | // on-screen keyboards and other such input method user interfaces go here. |
Vishnu Nair | 90f97fe | 2019-03-20 10:09:43 -0700 | [diff] [blame] | 833 | return 15; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 834 | case TYPE_INPUT_METHOD_DIALOG: |
| 835 | // on-screen keyboards and other such input method user interfaces go here. |
Vishnu Nair | 90f97fe | 2019-03-20 10:09:43 -0700 | [diff] [blame] | 836 | return 16; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 837 | case TYPE_STATUS_BAR: |
Robert Carr | 8360a78 | 2017-11-22 12:47:58 -0800 | [diff] [blame] | 838 | return 17; |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 839 | case TYPE_STATUS_BAR_PANEL: |
Robert Carr | 8360a78 | 2017-11-22 12:47:58 -0800 | [diff] [blame] | 840 | return 18; |
| 841 | case TYPE_STATUS_BAR_SUB_PANEL: |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 842 | 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 Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 892 | /** |
| 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 895 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 896 | * @param type The sub-window type code. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 897 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 898 | * @return int Layer in relation to the attached window, where positive is |
| 899 | * above and negative is below. |
| 900 | */ |
Wale Ogunwale | 5cd907d | 2017-01-26 14:14:08 -0800 | [diff] [blame] | 901 | 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 918 | |
| 919 | /** |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 920 | * Get the highest layer (actually one more than) that the wallpaper is |
| 921 | * allowed to be in. |
| 922 | */ |
| 923 | public int getMaxWallpaperLayer(); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 924 | |
| 925 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 926 | * Return whether the given window can become the Keyguard window. Typically returns true for |
| 927 | * the StatusBar. |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 928 | */ |
| 929 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs); |
| 930 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 931 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 932 | * @return whether {@param win} can be hidden by Keyguard |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 933 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 934 | public boolean canBeHiddenByKeyguardLw(WindowState win); |
Craig Mautner | 7d7808f | 2014-09-11 18:02:38 -0700 | [diff] [blame] | 935 | |
| 936 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 937 | * 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 943 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 944 | * @param appToken Token of the application being started. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 945 | * @param packageName The name of the application package being started. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 946 | * @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 Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 951 | * @param windowFlags Window layout flags. |
Wale Ogunwale | dfc1862 | 2016-04-16 15:08:48 -0700 | [diff] [blame] | 952 | * @param overrideConfig override configuration to consider when generating |
| 953 | * context to for resources. |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 954 | * @param displayId Id of the display to show the splash screen at. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 955 | * |
Jorim Jaggi | 02886a8 | 2016-12-06 09:10:06 -0800 | [diff] [blame] | 956 | * @return The starting surface. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 957 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 958 | */ |
Jorim Jaggi | ba41f4b | 2016-12-14 17:43:07 -0800 | [diff] [blame] | 959 | public StartingSurface addSplashScreen(IBinder appToken, String packageName, int theme, |
| 960 | CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon, |
Andrii Kulian | fb1bf69 | 2017-01-17 11:17:34 -0800 | [diff] [blame] | 961 | int logo, int windowFlags, Configuration overrideConfig, int displayId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 962 | |
| 963 | /** |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 964 | * Set or clear a window which can behave as the keyguard. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 965 | * |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 966 | * @param win The window which can behave as the keyguard. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 967 | */ |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 968 | void setKeyguardCandidateLw(@Nullable WindowState win); |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 969 | |
| 970 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 971 | * Create and return an animation to re-display a window that was force hidden by Keyguard. |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 972 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 973 | public Animation createHiddenByKeyguardExit(boolean onWallpaper, |
Issei Suzuki | 5609ccb | 2019-06-13 15:04:08 +0200 | [diff] [blame] | 974 | boolean goingToNotificationShade, boolean subtleAnimation); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 975 | |
| 976 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 977 | * Create and return an animation to let the wallpaper disappear after being shown behind |
| 978 | * Keyguard. |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 979 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 980 | public Animation createKeyguardWallpaperExit(boolean goingToNotificationShade); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 981 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 982 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 983 | * Called from the input reader thread before a key is enqueued. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 984 | * |
| 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 Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 989 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 990 | * @param policyFlags The policy flags associated with the key. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 991 | * |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 992 | * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 993 | */ |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 994 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 995 | |
| 996 | /** |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 997 | * Called from the input reader thread before a motion is enqueued when the device is in a |
| 998 | * non-interactive state. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 999 | * |
| 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 Chen | 4cc014e1 | 2019-01-28 16:17:16 +0800 | [diff] [blame] | 1004 | * @param displayId The display ID of the motion event. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1005 | * @param policyFlags The policy flags associated with the motion. |
| 1006 | * |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 1007 | * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1008 | */ |
Charles Chen | 4cc014e1 | 2019-01-28 16:17:16 +0800 | [diff] [blame] | 1009 | int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos, |
| 1010 | int policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 1011 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1012 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1013 | * Called from the input dispatcher thread before a key is dispatched to a window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1014 | * |
| 1015 | * <p>Allows you to define |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1016 | * behavior for keys that can not be overridden by applications. |
| 1017 | * This method is called from the input thread, with no locks held. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1018 | * |
Vishnu Nair | 539334a | 2019-09-20 10:46:21 -0700 | [diff] [blame] | 1019 | * @param focusedToken Client window token that currently has focus. This is where the key |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1020 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1021 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1022 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 1023 | * @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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1027 | */ |
Vishnu Nair | 539334a | 2019-09-20 10:46:21 -0700 | [diff] [blame] | 1028 | long interceptKeyBeforeDispatching(IBinder focusedToken, KeyEvent event, int policyFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1029 | |
| 1030 | /** |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1031 | * 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1036 | * |
Vishnu Nair | 539334a | 2019-09-20 10:46:21 -0700 | [diff] [blame] | 1037 | * @param focusedToken Client window token that currently has focus. This is where the key |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1038 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 1039 | * @param event The key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1040 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 1041 | * @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 Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1043 | */ |
Vishnu Nair | 539334a | 2019-09-20 10:46:21 -0700 | [diff] [blame] | 1044 | KeyEvent dispatchUnhandledKey(IBinder focusedToken, KeyEvent event, int policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 1045 | |
| 1046 | /** |
Tiger Huang | 51c5a1d | 2018-12-11 20:24:51 +0800 | [diff] [blame] | 1047 | * 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 Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1054 | * Apply the keyguard policy to a specific window. |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1055 | * |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1056 | * @param win The window to apply the keyguard policy. |
| 1057 | * @param imeTarget The current IME target window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1058 | */ |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1059 | void applyKeyguardPolicyLw(WindowState win, WindowState imeTarget); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1060 | |
| 1061 | /** |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1062 | * 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 Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1064 | * |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1065 | * @param displayId The ID of the display. |
| 1066 | * @param allow Whether the display allows showing lockscreen when it is on. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1067 | */ |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1068 | void setAllowLockscreenWhenOn(int displayId, boolean allow); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1069 | |
| 1070 | /** |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1071 | * Called when the device has started waking up. |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1072 | */ |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 1073 | void startedWakingUp(@OnReason int reason); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1074 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 1075 | /** |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1076 | * Called when the device has finished waking up. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1077 | */ |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 1078 | void finishedWakingUp(@OnReason int reason); |
Jeff Brown | 416c49c | 2015-05-26 19:50:18 -0700 | [diff] [blame] | 1079 | |
| 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1095 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 1096 | /** |
| 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 Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1107 | /** |
Jorim Jaggi | 0d210f6 | 2015-07-10 14:24:44 -0700 | [diff] [blame] | 1108 | * 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 Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 1114 | * 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 Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1123 | * Called when the device has turned the screen off. |
| 1124 | */ |
| 1125 | public void screenTurnedOff(); |
| 1126 | |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 1127 | public interface ScreenOnListener { |
| 1128 | void onScreenOn(); |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 1129 | } |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 1130 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1131 | /** |
Jorim Jaggi | 51304d7 | 2017-05-17 17:25:32 +0200 | [diff] [blame] | 1132 | * See {@link #screenTurnedOff} |
| 1133 | */ |
| 1134 | public interface ScreenOffListener { |
| 1135 | void onScreenOff(); |
| 1136 | } |
| 1137 | |
| 1138 | /** |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1139 | * Return whether the default display is on and not blocked by a black surface. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1140 | */ |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 1141 | public boolean isScreenOn(); |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1142 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 1143 | /** |
Adrian Roos | 7c89480 | 2017-07-19 12:25:34 +0200 | [diff] [blame] | 1144 | * @return whether the device is currently allowed to animate. |
Adrian Roos | e94c15c | 2017-05-09 13:17:54 -0700 | [diff] [blame] | 1145 | * |
Adrian Roos | 7c89480 | 2017-07-19 12:25:34 +0200 | [diff] [blame] | 1146 | * 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 Roos | e94c15c | 2017-05-09 13:17:54 -0700 | [diff] [blame] | 1148 | */ |
Adrian Roos | 7c89480 | 2017-07-19 12:25:34 +0200 | [diff] [blame] | 1149 | boolean okToAnimate(); |
Adrian Roos | e94c15c | 2017-05-09 13:17:54 -0700 | [diff] [blame] | 1150 | |
| 1151 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 1152 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1155 | */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 1156 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 1157 | |
| 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1165 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1166 | * 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 Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1174 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1175 | public void enableKeyguard(boolean enabled); |
| 1176 | |
| 1177 | /** |
Adrian Roos | e99bc05 | 2017-11-20 17:55:31 +0100 | [diff] [blame] | 1178 | * Callback used by {@link #exitKeyguardSecurely} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1179 | */ |
| 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 Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1190 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1191 | void exitKeyguardSecurely(OnKeyguardExitResult callback); |
| 1192 | |
| 1193 | /** |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 1194 | * 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 Miller | e4044bb | 2016-05-10 18:38:25 -0700 | [diff] [blame] | 1206 | * @param userId |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 1207 | * |
| 1208 | * @return true if in keyguard is secure. |
| 1209 | */ |
Jim Miller | e4044bb | 2016-05-10 18:38:25 -0700 | [diff] [blame] | 1210 | public boolean isKeyguardSecure(int userId); |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 1211 | |
| 1212 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1213 | * Return whether the keyguard is currently occluded. |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 1214 | * |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1215 | * @return true if in keyguard is occluded, false otherwise |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 1216 | */ |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1217 | public boolean isKeyguardOccluded(); |
Adrian Roos | 461829d | 2015-06-03 14:41:18 -0700 | [diff] [blame] | 1218 | |
| 1219 | /** |
Tony Mak | 2c0d6dc | 2016-04-29 16:16:54 +0100 | [diff] [blame] | 1220 | * @return true if in keyguard is on and not occluded. |
| 1221 | */ |
| 1222 | public boolean isKeyguardShowingAndNotOccluded(); |
| 1223 | |
| 1224 | /** |
Jorim Jaggi | fe76234 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 1225 | * @return whether Keyguard is in trusted state and can be dismissed without credentials |
| 1226 | */ |
| 1227 | public boolean isKeyguardTrustedLw(); |
| 1228 | |
| 1229 | /** |
Siarhei Vishniakou | 35fbb31 | 2017-12-13 13:48:50 -0800 | [diff] [blame] | 1230 | * 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 Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1241 | * Ask the policy to dismiss the keyguard, if it is currently shown. |
Jorim Jaggi | 241ae10 | 2016-11-02 21:57:33 -0700 | [diff] [blame] | 1242 | * |
| 1243 | * @param callback Callback to be informed about the result. |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 1244 | * @param message A message that should be displayed in the keyguard. |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1245 | */ |
Lucas Dupin | c80c67e | 2017-12-04 14:29:10 -0800 | [diff] [blame] | 1246 | public void dismissKeyguardLw(@Nullable IKeyguardDismissCallback callback, |
| 1247 | CharSequence message); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1248 | |
| 1249 | /** |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 1250 | * 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 Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1258 | * Called when the system is mostly done booting to set whether |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1259 | * the system should go into safe mode. |
| 1260 | */ |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1261 | public void setSafeMode(boolean safeMode); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1262 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1263 | /** |
| 1264 | * Called when the system is mostly done booting. |
| 1265 | */ |
| 1266 | public void systemReady(); |
| 1267 | |
| 1268 | /** |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 1269 | * 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 Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1275 | * 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 Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 1285 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1291 | * Called when we have finished booting and can now display the home |
Jeff Brown | c042ee2 | 2012-05-08 13:03:42 -0700 | [diff] [blame] | 1292 | * screen to the user. This will happen after systemReady(), and at |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1293 | * this point the display is active. |
| 1294 | */ |
| 1295 | public void enableScreenAfterBoot(); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1296 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1297 | /** |
| 1298 | * Call from application to perform haptic feedback on its window. |
| 1299 | */ |
Arthur Hung | a4c5206 | 2019-02-19 11:31:44 +0800 | [diff] [blame] | 1300 | public boolean performHapticFeedback(int uid, String packageName, int effectId, |
| 1301 | boolean always, String reason); |
Filip Gruszczynski | 2a6a2c2 | 2015-10-14 12:00:53 -0700 | [diff] [blame] | 1302 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1303 | /** |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1304 | * Called when we have started keeping the screen on because a window |
| 1305 | * requesting this has become visible. |
| 1306 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1307 | public void keepScreenOnStartedLw(); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1308 | |
| 1309 | /** |
| 1310 | * Called when we have stopped keeping the screen on because the last window |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1311 | * requesting this is no longer visible. |
| 1312 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1313 | public void keepScreenOnStoppedLw(); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1314 | |
| 1315 | /** |
Winson | ab21660 | 2016-08-09 14:05:20 -0700 | [diff] [blame] | 1316 | * 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 Chung | ac52f28 | 2017-03-30 14:44:52 -0700 | [diff] [blame] | 1323 | void setPipVisibilityLw(boolean visible); |
Winson | ab21660 | 2016-08-09 14:05:20 -0700 | [diff] [blame] | 1324 | |
| 1325 | /** |
Matthew Ng | 64543e6 | 2018-02-28 17:35:10 -0800 | [diff] [blame] | 1326 | * Called by System UI to enable or disable haptic feedback on the navigation bar buttons. |
| 1327 | */ |
| 1328 | void setNavBarVirtualKeyHapticFeedbackEnabledLw(boolean enabled); |
| 1329 | |
| 1330 | /** |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1331 | * Specifies whether there is an on-screen navigation bar separate from the status bar. |
| 1332 | */ |
| 1333 | public boolean hasNavigationBar(); |
| 1334 | |
| 1335 | /** |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1336 | * Lock the device now. |
| 1337 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1338 | public void lockNow(Bundle options); |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1339 | |
| 1340 | /** |
Yohei Yukawa | d6475a6 | 2017-04-17 10:35:27 -0700 | [diff] [blame] | 1341 | * 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 Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 1353 | * Show the recents task list app. |
| 1354 | * @hide |
| 1355 | */ |
Winson Chung | dff7a73 | 2017-12-11 12:17:06 -0800 | [diff] [blame] | 1356 | public void showRecentApps(); |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 1357 | |
| 1358 | /** |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 1359 | * Show the global actions dialog. |
| 1360 | * @hide |
| 1361 | */ |
| 1362 | public void showGlobalActions(); |
| 1363 | |
| 1364 | /** |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1365 | * 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 Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1375 | * 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 Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1381 | |
| 1382 | /** |
Evan Rosky | 1839645 | 2016-07-27 15:19:37 -0700 | [diff] [blame] | 1383 | * 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 Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1392 | * Print the WindowManagerPolicy's state into the given stream. |
| 1393 | * |
| 1394 | * @param prefix Text to print at the front of each line. |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1395 | * @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 Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 1399 | public void dump(String prefix, PrintWriter writer, String[] args); |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 1400 | |
| 1401 | /** |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 1402 | * Write the WindowManagerPolicy's state into the protocol buffer. |
Yi Jin | 6c6e9ca | 2018-03-20 16:53:35 -0700 | [diff] [blame] | 1403 | * The message is described in {@link com.android.server.wm.WindowManagerPolicyProto} |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 1404 | * |
| 1405 | * @param proto The protocol buffer output stream to write to. |
| 1406 | */ |
Jeffrey Huang | cb78285 | 2019-12-05 11:28:11 -0800 | [diff] [blame] | 1407 | void dumpDebug(ProtoOutputStream proto, long fieldId); |
Steven Timotius | af03df6 | 2017-07-18 16:56:43 -0700 | [diff] [blame] | 1408 | |
| 1409 | /** |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 1410 | * 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 Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1419 | |
| 1420 | /** |
| 1421 | * Notifies the keyguard to start fading out. |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1422 | * |
| 1423 | * @param startTime the start time of the animation in uptime milliseconds |
| 1424 | * @param fadeoutDuration the duration of the exit animation, in milliseconds |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1425 | */ |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1426 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration); |
Jorim Jaggi | 737af72 | 2015-12-31 10:42:27 +0100 | [diff] [blame] | 1427 | |
| 1428 | /** |
Keun-young Park | 4136d2d | 2017-05-08 14:51:59 -0700 | [diff] [blame] | 1429 | * 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 Wright | 1985976 | 2017-09-18 20:57:58 +0100 | [diff] [blame] | 1439 | |
| 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 Naka | e1bdfc82 | 2017-09-15 15:24:34 +0900 | [diff] [blame] | 1453 | |
| 1454 | /** |
Jordan Liu | c022876 | 2018-07-13 11:39:42 -0700 | [diff] [blame] | 1455 | * Requests that the WindowManager sends |
| 1456 | * WindowManagerPolicyConstants#ACTION_USER_ACTIVITY_NOTIFICATION on the next user activity. |
Yoshiaki Naka | e1bdfc82 | 2017-09-15 15:24:34 +0900 | [diff] [blame] | 1457 | */ |
| 1458 | public void requestUserActivityNotification(); |
Benjamin Franz | 3662b15 | 2018-01-16 17:23:44 +0000 | [diff] [blame] | 1459 | |
| 1460 | /** |
Adrian Roos | 962017e | 2018-11-27 15:11:46 +0100 | [diff] [blame] | 1461 | * 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 | /** |
Chilun | 70a9ab9 | 2019-02-12 10:57:49 +0800 | [diff] [blame] | 1471 | * 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 Suzuki | 9f840c7 | 2018-12-07 15:09:30 -0800 | [diff] [blame] | 1485 | * A new window on default display has been focused. |
| 1486 | */ |
| 1487 | default void onDefaultDisplayFocusChangedLw(WindowState newFocus) {} |
| 1488 | |
| 1489 | /** |
chaviw | 0e9fb13 | 2018-06-05 16:29:13 -0700 | [diff] [blame] | 1490 | * 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 Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1495 | } |