The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | import android.content.Context; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 21 | import android.content.pm.ActivityInfo; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 22 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.content.res.Configuration; |
| 24 | import android.graphics.Rect; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 25 | import android.graphics.RectF; |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 26 | import android.os.Bundle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.os.IBinder; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 28 | import android.os.Looper; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | import android.view.animation.Animation; |
| 30 | |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 31 | import java.io.PrintWriter; |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 32 | import java.lang.annotation.Retention; |
| 33 | import java.lang.annotation.RetentionPolicy; |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 34 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 35 | /** |
| 36 | * This interface supplies all UI-specific behavior of the window manager. An |
| 37 | * instance of it is created by the window manager when it starts up, and allows |
| 38 | * customization of window layering, special window types, key dispatching, and |
| 39 | * layout. |
| 40 | * |
| 41 | * <p>Because this provides deep interaction with the system window manager, |
| 42 | * specific methods on this interface can be called from a variety of contexts |
| 43 | * with various restrictions on what they can do. These are encoded through |
| 44 | * a suffixes at the end of a method encoding the thread the method is called |
| 45 | * from and any locks that are held when it is being called; if no suffix |
| 46 | * is attached to a method, then it is not called with any locks and may be |
| 47 | * called from the main window manager thread or another thread calling into |
| 48 | * the window manager. |
| 49 | * |
| 50 | * <p>The current suffixes are: |
| 51 | * |
| 52 | * <dl> |
| 53 | * <dt> Ti <dd> Called from the input thread. This is the thread that |
| 54 | * collects pending input events and dispatches them to the appropriate window. |
| 55 | * It may block waiting for events to be processed, so that the input stream is |
| 56 | * properly serialized. |
| 57 | * <dt> Tq <dd> Called from the low-level input queue thread. This is the |
| 58 | * thread that reads events out of the raw input devices and places them |
| 59 | * into the global input queue that is read by the <var>Ti</var> thread. |
| 60 | * This thread should not block for a long period of time on anything but the |
| 61 | * key driver. |
| 62 | * <dt> Lw <dd> Called with the main window manager lock held. Because the |
| 63 | * window manager is a very low-level system service, there are few other |
| 64 | * system services you can call with this lock held. It is explicitly okay to |
| 65 | * 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] | 66 | * 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] | 67 | * {@link android.content.Context#checkPermission(String, int, int)} and |
| 68 | * variations require calling into the activity manager. |
| 69 | * <dt> Li <dd> Called with the input thread lock held. This lock can be |
| 70 | * acquired by the window manager while it holds the window lock, so this is |
| 71 | * even more restrictive than <var>Lw</var>. |
| 72 | * </dl> |
| 73 | * |
| 74 | * @hide |
| 75 | */ |
| 76 | public interface WindowManagerPolicy { |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 77 | // Policy flags. These flags are also defined in frameworks/base/include/ui/Input.h. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | public final static int FLAG_WAKE = 0x00000001; |
Michael Wright | 337d9d2 | 2014-04-22 15:03:48 -0700 | [diff] [blame] | 79 | public final static int FLAG_VIRTUAL = 0x00000002; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 81 | public final static int FLAG_INJECTED = 0x01000000; |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 82 | public final static int FLAG_TRUSTED = 0x02000000; |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 83 | public final static int FLAG_FILTERED = 0x04000000; |
| 84 | public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000; |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 85 | |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 86 | public final static int FLAG_INTERACTIVE = 0x20000000; |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 87 | public final static int FLAG_PASS_TO_USER = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 89 | // Flags used for indicating whether the internal and/or external input devices |
| 90 | // of some type are available. |
| 91 | public final static int PRESENCE_INTERNAL = 1 << 0; |
| 92 | public final static int PRESENCE_EXTERNAL = 1 << 1; |
| 93 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | public final static boolean WATCH_POINTER = false; |
| 95 | |
Dianne Hackborn | ad7fa7f | 2011-01-07 14:06:50 -0800 | [diff] [blame] | 96 | /** |
| 97 | * Sticky broadcast of the current HDMI plugged state. |
| 98 | */ |
| 99 | public final static String ACTION_HDMI_PLUGGED = "android.intent.action.HDMI_PLUGGED"; |
| 100 | |
| 101 | /** |
| 102 | * Extra in {@link #ACTION_HDMI_PLUGGED} indicating the state: true if |
| 103 | * plugged in to HDMI, false if not. |
| 104 | */ |
| 105 | public final static String EXTRA_HDMI_PLUGGED_STATE = "state"; |
| 106 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | /** |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 108 | * Pass this event to the user / app. To be returned from |
| 109 | * {@link #interceptKeyBeforeQueueing}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | */ |
| 111 | public final static int ACTION_PASS_TO_USER = 0x00000001; |
| 112 | |
| 113 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | * Interface to the Window Manager state associated with a particular |
| 115 | * window. You can hold on to an instance of this interface from the call |
| 116 | * to prepareAddWindow() until removeWindow(). |
| 117 | */ |
| 118 | public interface WindowState { |
| 119 | /** |
Dianne Hackborn | f265ea9 | 2013-01-31 15:00:51 -0800 | [diff] [blame] | 120 | * Return the uid of the app that owns this window. |
| 121 | */ |
| 122 | int getOwningUid(); |
| 123 | |
| 124 | /** |
| 125 | * Return the package name of the app that owns this window. |
| 126 | */ |
| 127 | String getOwningPackage(); |
| 128 | |
| 129 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | * Perform standard frame computation. The result can be obtained with |
| 131 | * getFrame() if so desired. Must be called with the window manager |
| 132 | * lock held. |
| 133 | * |
| 134 | * @param parentFrame The frame of the parent container this window |
| 135 | * is in, used for computing its basic position. |
| 136 | * @param displayFrame The frame of the overall display in which this |
| 137 | * window can appear, used for constraining the overall dimensions |
| 138 | * of the window. |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 139 | * @param overlayFrame The frame within the display that is inside |
| 140 | * of the overlay region. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | * @param contentFrame The frame within the display in which we would |
| 142 | * like active content to appear. This will cause windows behind to |
| 143 | * be resized to match the given content frame. |
| 144 | * @param visibleFrame The frame within the display that the window |
| 145 | * is actually visible, used for computing its visible insets to be |
| 146 | * given to windows behind. |
| 147 | * This can be used as a hint for scrolling (avoiding resizing) |
| 148 | * the window to make certain that parts of its content |
| 149 | * are visible. |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 150 | * @param decorFrame The decor frame specified by policy specific to this window, |
| 151 | * to use for proper cropping during animation. |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 152 | * @param stableFrame The frame around which stable system decoration is positioned. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | */ |
| 154 | public void computeFrameLw(Rect parentFrame, Rect displayFrame, |
Adrian Roos | fa10423 | 2014-06-20 16:10:14 -0700 | [diff] [blame] | 155 | Rect overlayFrame, Rect contentFrame, Rect visibleFrame, Rect decorFrame, |
| 156 | Rect stableFrame); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * Retrieve the current frame of the window that has been assigned by |
| 160 | * the window manager. Must be called with the window manager lock held. |
| 161 | * |
| 162 | * @return Rect The rectangle holding the window frame. |
| 163 | */ |
| 164 | public Rect getFrameLw(); |
| 165 | |
| 166 | /** |
| 167 | * Retrieve the current frame of the window that is actually shown. |
| 168 | * Must be called with the window manager lock held. |
| 169 | * |
| 170 | * @return Rect The rectangle holding the shown window frame. |
| 171 | */ |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 172 | public RectF getShownFrameLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * Retrieve the frame of the display that this window was last |
| 176 | * laid out in. Must be called with the |
| 177 | * window manager lock held. |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 178 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 179 | * @return Rect The rectangle holding the display frame. |
| 180 | */ |
| 181 | public Rect getDisplayFrameLw(); |
| 182 | |
| 183 | /** |
Dianne Hackborn | c4aad01 | 2013-02-22 15:05:25 -0800 | [diff] [blame] | 184 | * Retrieve the frame of the area inside the overscan region of the |
| 185 | * display that this window was last laid out in. Must be called with the |
| 186 | * window manager lock held. |
| 187 | * |
| 188 | * @return Rect The rectangle holding the display overscan frame. |
| 189 | */ |
| 190 | public Rect getOverscanFrameLw(); |
| 191 | |
| 192 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 193 | * Retrieve the frame of the content area that this window was last |
| 194 | * laid out in. This is the area in which the content of the window |
| 195 | * should be placed. It will be smaller than the display frame to |
| 196 | * account for screen decorations such as a status bar or soft |
| 197 | * keyboard. Must be called with the |
| 198 | * window manager lock held. |
| 199 | * |
| 200 | * @return Rect The rectangle holding the content frame. |
| 201 | */ |
| 202 | public Rect getContentFrameLw(); |
| 203 | |
| 204 | /** |
| 205 | * Retrieve the frame of the visible area that this window was last |
| 206 | * laid out in. This is the area of the screen in which the window |
| 207 | * will actually be fully visible. It will be smaller than the |
| 208 | * content frame to account for transient UI elements blocking it |
| 209 | * such as an input method's candidates UI. Must be called with the |
| 210 | * window manager lock held. |
| 211 | * |
| 212 | * @return Rect The rectangle holding the visible frame. |
| 213 | */ |
| 214 | public Rect getVisibleFrameLw(); |
| 215 | |
| 216 | /** |
| 217 | * Returns true if this window is waiting to receive its given |
| 218 | * internal insets from the client app, and so should not impact the |
| 219 | * layout of other windows. |
| 220 | */ |
| 221 | public boolean getGivenInsetsPendingLw(); |
| 222 | |
| 223 | /** |
| 224 | * Retrieve the insets given by this window's client for the content |
| 225 | * area of windows behind it. Must be called with the |
| 226 | * window manager lock held. |
| 227 | * |
| 228 | * @return Rect The left, top, right, and bottom insets, relative |
| 229 | * to the window's frame, of the actual contents. |
| 230 | */ |
| 231 | public Rect getGivenContentInsetsLw(); |
| 232 | |
| 233 | /** |
| 234 | * Retrieve the insets given by this window's client for the visible |
| 235 | * area of windows behind it. Must be called with the |
| 236 | * window manager lock held. |
| 237 | * |
| 238 | * @return Rect The left, top, right, and bottom insets, relative |
| 239 | * to the window's frame, of the actual visible area. |
| 240 | */ |
| 241 | public Rect getGivenVisibleInsetsLw(); |
| 242 | |
| 243 | /** |
| 244 | * Retrieve the current LayoutParams of the window. |
| 245 | * |
| 246 | * @return WindowManager.LayoutParams The window's internal LayoutParams |
| 247 | * instance. |
| 248 | */ |
| 249 | public WindowManager.LayoutParams getAttrs(); |
| 250 | |
| 251 | /** |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 252 | * Return whether this window needs the menu key shown. Must be called |
| 253 | * with window lock held, because it may need to traverse down through |
| 254 | * window list to determine the result. |
| 255 | * @param bottom The bottom-most window to consider when determining this. |
| 256 | */ |
| 257 | public boolean getNeedsMenuLw(WindowState bottom); |
| 258 | |
| 259 | /** |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 260 | * Retrieve the current system UI visibility flags associated with |
| 261 | * this window. |
| 262 | */ |
| 263 | public int getSystemUiVisibility(); |
| 264 | |
| 265 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 266 | * Get the layer at which this window's surface will be Z-ordered. |
| 267 | */ |
| 268 | public int getSurfaceLayer(); |
Craig Mautner | 9cf34e2 | 2014-03-23 00:10:33 +0000 | [diff] [blame] | 269 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 270 | /** |
| 271 | * Return the token for the application (actually activity) that owns |
| 272 | * this window. May return null for system windows. |
| 273 | * |
| 274 | * @return An IApplicationToken identifying the owning activity. |
| 275 | */ |
| 276 | public IApplicationToken getAppToken(); |
| 277 | |
| 278 | /** |
Dianne Hackborn | e30e02f | 2014-05-27 18:24:45 -0700 | [diff] [blame] | 279 | * Return true if this window is participating in voice interaction. |
| 280 | */ |
| 281 | public boolean isVoiceInteraction(); |
| 282 | |
| 283 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 284 | * Return true if, at any point, the application token associated with |
| 285 | * this window has actually displayed any windows. This is most useful |
| 286 | * with the "starting up" window to determine if any windows were |
| 287 | * displayed when it is closed. |
| 288 | * |
| 289 | * @return Returns true if one or more windows have been displayed, |
| 290 | * else false. |
| 291 | */ |
| 292 | public boolean hasAppShownWindows(); |
| 293 | |
| 294 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 295 | * Is this window visible? It is not visible if there is no |
| 296 | * surface, or we are in the process of running an exit animation |
| 297 | * that will remove the surface. |
| 298 | */ |
| 299 | boolean isVisibleLw(); |
| 300 | |
| 301 | /** |
Dianne Hackborn | 3d163f07 | 2009-10-07 21:26:57 -0700 | [diff] [blame] | 302 | * Like {@link #isVisibleLw}, but also counts a window that is currently |
| 303 | * "hidden" behind the keyguard as visible. This allows us to apply |
| 304 | * things like window flags that impact the keyguard. |
| 305 | */ |
| 306 | boolean isVisibleOrBehindKeyguardLw(); |
| 307 | |
| 308 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 309 | * Is this window currently visible to the user on-screen? It is |
| 310 | * displayed either if it is visible or it is currently running an |
| 311 | * animation before no longer being visible. Must be called with the |
| 312 | * window manager lock held. |
| 313 | */ |
| 314 | boolean isDisplayedLw(); |
| 315 | |
| 316 | /** |
Dianne Hackborn | 5c58de3 | 2012-04-28 19:52:37 -0700 | [diff] [blame] | 317 | * Return true if this window (or a window it is attached to, but not |
| 318 | * considering its app token) is currently animating. |
| 319 | */ |
| 320 | public boolean isAnimatingLw(); |
| 321 | |
| 322 | /** |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 323 | * Is this window considered to be gone for purposes of layout? |
| 324 | */ |
| 325 | boolean isGoneForLayoutLw(); |
| 326 | |
| 327 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 328 | * Returns true if this window has been shown on screen at some time in |
| 329 | * the past. Must be called with the window manager lock held. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 330 | */ |
| 331 | public boolean hasDrawnLw(); |
| 332 | |
| 333 | /** |
| 334 | * Can be called by the policy to force a window to be hidden, |
| 335 | * regardless of whether the client or window manager would like |
| 336 | * it shown. Must be called with the window manager lock held. |
| 337 | * Returns true if {@link #showLw} was last called for the window. |
| 338 | */ |
| 339 | public boolean hideLw(boolean doAnimation); |
| 340 | |
| 341 | /** |
| 342 | * Can be called to undo the effect of {@link #hideLw}, allowing a |
| 343 | * window to be shown as long as the window manager and client would |
| 344 | * also like it to be shown. Must be called with the window manager |
| 345 | * lock held. |
| 346 | * Returns true if {@link #hideLw} was last called for the window. |
| 347 | */ |
| 348 | public boolean showLw(boolean doAnimation); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 349 | |
| 350 | /** |
| 351 | * Check whether the process hosting this window is currently alive. |
| 352 | */ |
| 353 | public boolean isAlive(); |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 354 | |
| 355 | /** |
| 356 | * Check if window is on {@link Display#DEFAULT_DISPLAY}. |
| 357 | * @return true if window is on default display. |
| 358 | */ |
| 359 | public boolean isDefaultDisplay(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 360 | } |
| 361 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 362 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 363 | * Representation of a "fake window" that the policy has added to the |
| 364 | * window manager to consume events. |
| 365 | */ |
| 366 | public interface FakeWindow { |
| 367 | /** |
| 368 | * Remove the fake window from the window manager. |
| 369 | */ |
| 370 | void dismiss(); |
| 371 | } |
| 372 | |
| 373 | /** |
| 374 | * Interface for calling back in to the window manager that is private |
| 375 | * between it and the policy. |
| 376 | */ |
| 377 | public interface WindowManagerFuncs { |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 378 | public static final int LID_ABSENT = -1; |
| 379 | public static final int LID_CLOSED = 0; |
| 380 | public static final int LID_OPEN = 1; |
| 381 | |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 382 | public static final int CAMERA_LENS_COVER_ABSENT = -1; |
| 383 | public static final int CAMERA_LENS_UNCOVERED = 0; |
| 384 | public static final int CAMERA_LENS_COVERED = 1; |
| 385 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 386 | /** |
| 387 | * Ask the window manager to re-evaluate the system UI flags. |
| 388 | */ |
| 389 | public void reevaluateStatusBarVisibility(); |
| 390 | |
| 391 | /** |
| 392 | * Add a fake window to the window manager. This window sits |
| 393 | * at the top of the other windows and consumes events. |
| 394 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 395 | public FakeWindow addFakeWindow(Looper looper, |
| 396 | InputEventReceiver.Factory inputEventReceiverFactory, |
Adam Lesinski | 95c4297 | 2013-10-02 10:13:27 -0700 | [diff] [blame] | 397 | String name, int windowType, int layoutParamsFlags, int layoutParamsPrivateFlags, |
| 398 | boolean canReceiveKeys, boolean hasFocus, boolean touchFullscreen); |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 399 | |
| 400 | /** |
| 401 | * Returns a code that describes the current state of the lid switch. |
| 402 | */ |
| 403 | public int getLidState(); |
| 404 | |
| 405 | /** |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 406 | * Returns a code that descripbes whether the camera lens is covered or not. |
| 407 | */ |
| 408 | public int getCameraLensCoverState(); |
| 409 | |
| 410 | /** |
Jeff Brown | cf39bdf | 2012-05-18 14:41:19 -0700 | [diff] [blame] | 411 | * Switch the keyboard layout for the given device. |
| 412 | * Direction should be +1 or -1 to go to the next or previous keyboard layout. |
| 413 | */ |
| 414 | public void switchKeyboardLayout(int deviceId, int direction); |
| 415 | |
Jeff Brown | 9a538ee | 2012-08-20 14:56:57 -0700 | [diff] [blame] | 416 | public void shutdown(boolean confirm); |
| 417 | public void rebootSafeMode(boolean confirm); |
John Spurlock | 04db176 | 2013-05-13 12:46:41 -0400 | [diff] [blame] | 418 | |
| 419 | /** |
| 420 | * Return the window manager lock needed to correctly call "Lw" methods. |
| 421 | */ |
| 422 | public Object getWindowManagerLock(); |
Craig Mautner | 037aa8d | 2013-06-07 10:35:44 -0700 | [diff] [blame] | 423 | |
| 424 | /** Register a system listener for touch events */ |
| 425 | void registerPointerEventListener(PointerEventListener listener); |
| 426 | |
| 427 | /** Unregister a system listener for touch events */ |
| 428 | void unregisterPointerEventListener(PointerEventListener listener); |
| 429 | } |
| 430 | |
| 431 | public interface PointerEventListener { |
| 432 | /** |
| 433 | * 1. onPointerEvent will be called on the service.UiThread. |
| 434 | * 2. motionEvent will be recycled after onPointerEvent returns so if it is needed later a |
| 435 | * copy() must be made and the copy must be recycled. |
| 436 | **/ |
| 437 | public void onPointerEvent(MotionEvent motionEvent); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 438 | } |
| 439 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 440 | /** Window has been added to the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 441 | public static final int TRANSIT_ENTER = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 442 | /** Window has been removed from the screen. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 443 | public static final int TRANSIT_EXIT = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 444 | /** Window has been made visible. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 445 | public static final int TRANSIT_SHOW = 3; |
| 446 | /** Window has been made invisible. |
| 447 | * TODO: Consider removal as this is unused. */ |
| 448 | public static final int TRANSIT_HIDE = 4; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 449 | /** The "application starting" preview window is no longer needed, and will |
| 450 | * animate away to show the real window. */ |
Craig Mautner | 4b71aa1 | 2012-12-27 17:20:01 -0800 | [diff] [blame] | 451 | public static final int TRANSIT_PREVIEW_DONE = 5; |
| 452 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 453 | // NOTE: screen off reasons are in order of significance, with more |
| 454 | // important ones lower than less important ones. |
| 455 | |
| 456 | /** Screen turned off because of a device admin */ |
| 457 | public final int OFF_BECAUSE_OF_ADMIN = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 458 | /** Screen turned off because of power button */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 459 | public final int OFF_BECAUSE_OF_USER = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 460 | /** Screen turned off because of timeout */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 461 | public final int OFF_BECAUSE_OF_TIMEOUT = 3; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 462 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 463 | /** @hide */ |
| 464 | @IntDef({USER_ROTATION_FREE, USER_ROTATION_LOCKED}) |
| 465 | @Retention(RetentionPolicy.SOURCE) |
| 466 | public @interface UserRotationMode {} |
| 467 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 468 | /** When not otherwise specified by the activity's screenOrientation, rotation should be |
| 469 | * determined by the system (that is, using sensors). */ |
| 470 | public final int USER_ROTATION_FREE = 0; |
| 471 | /** When not otherwise specified by the activity's screenOrientation, rotation is set by |
| 472 | * the user. */ |
| 473 | public final int USER_ROTATION_LOCKED = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 474 | |
| 475 | /** |
| 476 | * Perform initialization of the policy. |
| 477 | * |
| 478 | * @param context The system context we are running in. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 479 | */ |
| 480 | public void init(Context context, IWindowManager windowManager, |
Jeff Brown | 9630704 | 2012-07-27 15:51:34 -0700 | [diff] [blame] | 481 | WindowManagerFuncs windowManagerFuncs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 482 | |
| 483 | /** |
Craig Mautner | 46ac6fa | 2013-08-01 10:06:34 -0700 | [diff] [blame] | 484 | * @return true if com.android.internal.R.bool#config_forceDefaultOrientation is true. |
| 485 | */ |
| 486 | public boolean isDefaultOrientationForced(); |
| 487 | |
| 488 | /** |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 489 | * Called by window manager once it has the initial, default native |
| 490 | * display dimensions. |
| 491 | */ |
Dianne Hackborn | dde331c | 2012-08-03 14:01:57 -0700 | [diff] [blame] | 492 | public void setInitialDisplaySize(Display display, int width, int height, int density); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 493 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 494 | /** |
Dianne Hackborn | c652de8 | 2013-02-15 16:32:56 -0800 | [diff] [blame] | 495 | * Called by window manager to set the overscan region that should be used for the |
| 496 | * given display. |
| 497 | */ |
| 498 | public void setDisplayOverscan(Display display, int left, int top, int right, int bottom); |
| 499 | |
| 500 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 501 | * Check permissions when adding a window. |
| 502 | * |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 503 | * @param attrs The window's LayoutParams. |
| 504 | * @param outAppOp First element will be filled with the app op corresponding to |
| 505 | * this window, or OP_NONE. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 506 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 507 | * @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] | 508 | * else an error code, usually |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 509 | * {@link WindowManagerGlobal#ADD_PERMISSION_DENIED}, to abort the add. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 510 | */ |
Dianne Hackborn | c229302 | 2013-02-06 23:14:49 -0800 | [diff] [blame] | 511 | public int checkAddPermission(WindowManager.LayoutParams attrs, int[] outAppOp); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 512 | |
| 513 | /** |
Craig Mautner | 88400d3 | 2012-09-30 12:35:45 -0700 | [diff] [blame] | 514 | * Check permissions when adding a window. |
| 515 | * |
| 516 | * @param attrs The window's LayoutParams. |
| 517 | * |
| 518 | * @return True if the window may only be shown to the current user, false if the window can |
| 519 | * be shown on all users' windows. |
| 520 | */ |
| 521 | public boolean checkShowToOwnerOnly(WindowManager.LayoutParams attrs); |
| 522 | |
| 523 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 524 | * Sanitize the layout parameters coming from a client. Allows the policy |
| 525 | * to do things like ensure that windows of a specific type can't take |
| 526 | * input focus. |
| 527 | * |
| 528 | * @param attrs The window layout parameters to be modified. These values |
| 529 | * are modified in-place. |
| 530 | */ |
| 531 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs); |
| 532 | |
| 533 | /** |
| 534 | * After the window manager has computed the current configuration based |
| 535 | * on its knowledge of the display and input devices, it gives the policy |
| 536 | * a chance to adjust the information contained in it. If you want to |
| 537 | * leave it as-is, simply do nothing. |
| 538 | * |
| 539 | * <p>This method may be called by any thread in the window manager, but |
| 540 | * no internal locks in the window manager will be held. |
| 541 | * |
| 542 | * @param config The Configuration being computed, for you to change as |
| 543 | * desired. |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 544 | * @param keyboardPresence Flags that indicate whether internal or external |
| 545 | * keyboards are present. |
| 546 | * @param navigationPresence Flags that indicate whether internal or external |
| 547 | * navigation devices are present. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 548 | */ |
Jeff Brown | daa3753 | 2012-05-01 15:54:03 -0700 | [diff] [blame] | 549 | public void adjustConfigurationLw(Configuration config, int keyboardPresence, |
| 550 | int navigationPresence); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 551 | |
| 552 | /** |
| 553 | * Assign a window type to a layer. Allows you to control how different |
| 554 | * kinds of windows are ordered on-screen. |
| 555 | * |
| 556 | * @param type The type of window being assigned. |
| 557 | * |
| 558 | * @return int An arbitrary integer used to order windows, with lower |
| 559 | * numbers below higher ones. |
| 560 | */ |
| 561 | public int windowTypeToLayerLw(int type); |
| 562 | |
| 563 | /** |
| 564 | * Return how to Z-order sub-windows in relation to the window they are |
| 565 | * attached to. Return positive to have them ordered in front, negative for |
| 566 | * behind. |
| 567 | * |
| 568 | * @param type The sub-window type code. |
| 569 | * |
| 570 | * @return int Layer in relation to the attached window, where positive is |
| 571 | * above and negative is below. |
| 572 | */ |
| 573 | public int subWindowTypeToLayerLw(int type); |
| 574 | |
| 575 | /** |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 576 | * Get the highest layer (actually one more than) that the wallpaper is |
| 577 | * allowed to be in. |
| 578 | */ |
| 579 | public int getMaxWallpaperLayer(); |
Dianne Hackborn | a4b7f2f | 2012-05-21 11:28:41 -0700 | [diff] [blame] | 580 | |
| 581 | /** |
| 582 | * Return the window layer at which windows appear above the normal |
| 583 | * universe (that is no longer impacted by the universe background |
| 584 | * transform). |
| 585 | */ |
| 586 | public int getAboveUniverseLayer(); |
| 587 | |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 588 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 589 | * Return the display width available after excluding any screen |
| 590 | * decorations that can never be removed. That is, system bar or |
| 591 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 592 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 593 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 594 | |
| 595 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 596 | * Return the display height available after excluding any screen |
| 597 | * decorations that can never be removed. That is, system bar or |
| 598 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 599 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 600 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 601 | |
| 602 | /** |
| 603 | * Return the available screen width that we should report for the |
| 604 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 605 | * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 606 | * that to account for more transient decoration like a status bar. |
| 607 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 608 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 609 | |
| 610 | /** |
| 611 | * Return the available screen height that we should report for the |
| 612 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 613 | * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 614 | * that to account for more transient decoration like a status bar. |
| 615 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 616 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 617 | |
| 618 | /** |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 619 | * Return whether the given window is forcibly hiding all windows except windows with |
| 620 | * FLAG_SHOW_WHEN_LOCKED set. Typically returns true for the keyguard. |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 621 | */ |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 622 | public boolean isForceHiding(WindowManager.LayoutParams attrs); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 623 | |
| 624 | |
| 625 | /** |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 626 | * Return whether the given window can become one that passes isForceHiding() test. |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 627 | * Typically returns true for the StatusBar. |
| 628 | */ |
| 629 | public boolean isKeyguardHostWindow(WindowManager.LayoutParams attrs); |
| 630 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 631 | /** |
| 632 | * Determine if a window that is behind one that is force hiding |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 633 | * (as determined by {@link #isForceHiding}) should actually be hidden. |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 634 | * For example, typically returns false for the status bar. Be careful |
| 635 | * to return false for any window that you may hide yourself, since this |
| 636 | * will conflict with what you set. |
| 637 | */ |
| 638 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 639 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 640 | /** |
Craig Mautner | 7d7808f | 2014-09-11 18:02:38 -0700 | [diff] [blame] | 641 | * Return the window that is hiding the keyguard, if such a thing exists. |
| 642 | */ |
| 643 | public WindowState getWinShowWhenLockedLw(); |
| 644 | |
| 645 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 646 | * Called when the system would like to show a UI to indicate that an |
| 647 | * application is starting. You can use this to add a |
| 648 | * APPLICATION_STARTING_TYPE window with the given appToken to the window |
| 649 | * manager (using the normal window manager APIs) that will be shown until |
| 650 | * the application displays its own window. This is called without the |
| 651 | * window manager locked so that you can call back into it. |
| 652 | * |
| 653 | * @param appToken Token of the application being started. |
| 654 | * @param packageName The name of the application package being started. |
| 655 | * @param theme Resource defining the application's overall visual theme. |
| 656 | * @param nonLocalizedLabel The default title label of the application if |
| 657 | * no data is found in the resource. |
| 658 | * @param labelRes The resource ID the application would like to use as its name. |
| 659 | * @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] | 660 | * @param windowFlags Window layout flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 661 | * |
| 662 | * @return Optionally you can return the View that was used to create the |
| 663 | * window, for easy removal in removeStartingWindow. |
| 664 | * |
| 665 | * @see #removeStartingWindow |
| 666 | */ |
| 667 | public View addStartingWindow(IBinder appToken, String packageName, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 668 | int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, |
Adam Powell | 04fe6eb | 2013-05-31 14:39:48 -0700 | [diff] [blame] | 669 | int labelRes, int icon, int logo, int windowFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | |
| 671 | /** |
| 672 | * Called when the first window of an application has been displayed, while |
| 673 | * {@link #addStartingWindow} has created a temporary initial window for |
| 674 | * that application. You should at this point remove the window from the |
| 675 | * window manager. This is called without the window manager locked so |
| 676 | * that you can call back into it. |
| 677 | * |
| 678 | * <p>Note: due to the nature of these functions not being called with the |
| 679 | * window manager locked, you must be prepared for this function to be |
| 680 | * called multiple times and/or an initial time with a null View window |
| 681 | * even if you previously returned one. |
| 682 | * |
| 683 | * @param appToken Token of the application that has started. |
| 684 | * @param window Window View that was returned by createStartingWindow. |
| 685 | * |
| 686 | * @see #addStartingWindow |
| 687 | */ |
| 688 | public void removeStartingWindow(IBinder appToken, View window); |
| 689 | |
| 690 | /** |
| 691 | * Prepare for a window being added to the window manager. You can throw an |
| 692 | * exception here to prevent the window being added, or do whatever setup |
| 693 | * you need to keep track of the window. |
| 694 | * |
| 695 | * @param win The window being added. |
| 696 | * @param attrs The window's LayoutParams. |
| 697 | * |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 698 | * @return {@link WindowManagerGlobal#ADD_OKAY} if the add can proceed, else an |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 699 | * error code to abort the add. |
| 700 | */ |
| 701 | public int prepareAddWindowLw(WindowState win, |
| 702 | WindowManager.LayoutParams attrs); |
| 703 | |
| 704 | /** |
| 705 | * Called when a window is being removed from a window manager. Must not |
| 706 | * throw an exception -- clean up as much as possible. |
| 707 | * |
| 708 | * @param win The window being removed. |
| 709 | */ |
| 710 | public void removeWindowLw(WindowState win); |
| 711 | |
| 712 | /** |
| 713 | * Control the animation to run when a window's state changes. Return a |
| 714 | * non-0 number to force the animation to a specific resource ID, or 0 |
| 715 | * to use the default animation. |
| 716 | * |
| 717 | * @param win The window that is changing. |
| 718 | * @param transit What is happening to the window: {@link #TRANSIT_ENTER}, |
| 719 | * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or |
| 720 | * {@link #TRANSIT_HIDE}. |
| 721 | * |
| 722 | * @return Resource ID of the actual animation to use, or 0 for none. |
| 723 | */ |
| 724 | public int selectAnimationLw(WindowState win, int transit); |
| 725 | |
| 726 | /** |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 727 | * Determine the animation to run for a rotation transition based on the |
| 728 | * top fullscreen windows {@link WindowManager.LayoutParams#rotationAnimation} |
| 729 | * and whether it is currently fullscreen and frontmost. |
| 730 | * |
| 731 | * @param anim The exiting animation resource id is stored in anim[0], the |
| 732 | * entering animation resource id is stored in anim[1]. |
| 733 | */ |
| 734 | public void selectRotationAnimationLw(int anim[]); |
| 735 | |
| 736 | /** |
| 737 | * Validate whether the current top fullscreen has specified the same |
| 738 | * {@link WindowManager.LayoutParams#rotationAnimation} value as that |
| 739 | * being passed in from the previous top fullscreen window. |
| 740 | * |
| 741 | * @param exitAnimId exiting resource id from the previous window. |
| 742 | * @param enterAnimId entering resource id from the previous window. |
| 743 | * @param forceDefault For rotation animations only, if true ignore the |
| 744 | * animation values and just return false. |
| 745 | * @return true if the previous values are still valid, false if they |
| 746 | * should be replaced with the default. |
| 747 | */ |
| 748 | public boolean validateRotationAnimationLw(int exitAnimId, int enterAnimId, |
| 749 | boolean forceDefault); |
| 750 | |
| 751 | /** |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 752 | * Create and return an animation to re-display a force hidden window. |
| 753 | */ |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 754 | public Animation createForceHideEnterAnimation(boolean onWallpaper, |
| 755 | boolean goingToNotificationShade); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 756 | |
| 757 | /** |
| 758 | * Create and return an animation to let the wallpaper disappear after being shown on a force |
| 759 | * hiding window. |
| 760 | */ |
Jorim Jaggi | 84a3e7a | 2014-08-13 17:58:58 +0200 | [diff] [blame] | 761 | public Animation createForceHideWallpaperExitAnimation(boolean goingToNotificationShade); |
Jorim Jaggi | 76a1623 | 2014-08-08 17:00:47 +0200 | [diff] [blame] | 762 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 763 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 764 | * 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] | 765 | * |
| 766 | * <p>There are some actions that need to be handled here because they |
| 767 | * affect the power state of the device, for example, the power keys. |
| 768 | * Generally, it's best to keep as little as possible in the queue thread |
| 769 | * because it's the most fragile. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 770 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 771 | * @param policyFlags The policy flags associated with the key. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 772 | * |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 773 | * @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] | 774 | */ |
Jeff Brown | 037c33e | 2014-04-09 00:31:55 -0700 | [diff] [blame] | 775 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 776 | |
| 777 | /** |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 778 | * Called from the input reader thread before a motion is enqueued when the device is in a |
| 779 | * non-interactive state. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 780 | * |
| 781 | * <p>There are some actions that need to be handled here because they |
| 782 | * affect the power state of the device, for example, waking on motions. |
| 783 | * Generally, it's best to keep as little as possible in the queue thread |
| 784 | * because it's the most fragile. |
| 785 | * @param policyFlags The policy flags associated with the motion. |
| 786 | * |
Jeff Brown | 2687550 | 2014-01-30 21:47:47 -0800 | [diff] [blame] | 787 | * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}. |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 788 | */ |
Michael Wright | 70af00a | 2014-09-03 19:30:20 -0700 | [diff] [blame] | 789 | public int interceptMotionBeforeQueueingNonInteractive(long whenNanos, int policyFlags); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 790 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 791 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 792 | * 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] | 793 | * |
| 794 | * <p>Allows you to define |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 795 | * behavior for keys that can not be overridden by applications. |
| 796 | * This method is called from the input thread, with no locks held. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 797 | * |
| 798 | * @param win The window that currently has focus. This is where the key |
| 799 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 800 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 801 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 802 | * @return 0 if the key should be dispatched immediately, -1 if the key should |
| 803 | * not be dispatched ever, or a positive value indicating the number of |
| 804 | * milliseconds by which the key dispatch should be delayed before trying |
| 805 | * again. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 806 | */ |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 807 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 808 | |
| 809 | /** |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 810 | * Called from the input dispatcher thread when an application did not handle |
| 811 | * a key that was dispatched to it. |
| 812 | * |
| 813 | * <p>Allows you to define default global behavior for keys that were not handled |
| 814 | * by applications. This method is called from the input thread, with no locks held. |
| 815 | * |
| 816 | * @param win The window that currently has focus. This is where the key |
| 817 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 818 | * @param event The key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 819 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 820 | * @return Returns an alternate key event to redispatch as a fallback, or null to give up. |
| 821 | * The caller is responsible for recycling the key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 822 | */ |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 823 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 824 | |
| 825 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 826 | * Called when layout of the windows is about to start. |
| 827 | * |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 828 | * @param isDefaultDisplay true if window is on {@link Display#DEFAULT_DISPLAY}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 829 | * @param displayWidth The current full width of the screen. |
| 830 | * @param displayHeight The current full height of the screen. |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 831 | * @param displayRotation The current rotation being applied to the base |
| 832 | * window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 833 | */ |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 834 | public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight, |
| 835 | int displayRotation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 836 | |
| 837 | /** |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 838 | * Returns the bottom-most layer of the system decor, above which no policy decor should |
| 839 | * be applied. |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 840 | */ |
John Spurlock | 4664623 | 2013-09-30 22:32:42 -0400 | [diff] [blame] | 841 | public int getSystemDecorLayerLw(); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 842 | |
| 843 | /** |
Craig Mautner | 967212c | 2013-04-13 21:10:58 -0700 | [diff] [blame] | 844 | * Return the rectangle of the screen that is available for applications to run in. |
| 845 | * This will be called immediately after {@link #beginLayoutLw}. |
| 846 | * |
| 847 | * @param r The rectangle to be filled with the boundaries available to applications. |
| 848 | */ |
| 849 | public void getContentRectLw(Rect r); |
| 850 | |
| 851 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 852 | * Called for each window attached to the window manager as layout is |
| 853 | * proceeding. The implementation of this function must take care of |
| 854 | * setting the window's frame, either here or in finishLayout(). |
| 855 | * |
| 856 | * @param win The window being positioned. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 857 | * @param attached For sub-windows, the window it is attached to; this |
| 858 | * window will already have had layoutWindow() called on it |
| 859 | * so you can use its Rect. Otherwise null. |
| 860 | */ |
Craig Mautner | c9457fa | 2014-06-06 14:27:48 -0700 | [diff] [blame] | 861 | public void layoutWindowLw(WindowState win, WindowState attached); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 862 | |
| 863 | |
| 864 | /** |
| 865 | * Return the insets for the areas covered by system windows. These values |
| 866 | * are computed on the most recent layout, so they are not guaranteed to |
| 867 | * be correct. |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 868 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 869 | * @param attrs The LayoutParams of the window. |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 870 | * @param outContentInsets The areas covered by system windows, expressed as positive insets. |
| 871 | * @param outStableInsets The areas covered by stable system windows irrespective of their |
| 872 | * current visibility. Expressed as positive insets. |
| 873 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 874 | */ |
Adrian Roos | 37d7a68 | 2014-11-06 18:15:16 +0100 | [diff] [blame] | 875 | public void getInsetHintLw(WindowManager.LayoutParams attrs, Rect outContentInsets, |
| 876 | Rect outStableInsets); |
Dianne Hackborn | 85afd1b | 2012-05-13 13:31:06 -0700 | [diff] [blame] | 877 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 878 | /** |
| 879 | * Called when layout of the windows is finished. After this function has |
| 880 | * returned, all windows given to layoutWindow() <em>must</em> have had a |
| 881 | * frame assigned. |
| 882 | */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 883 | public void finishLayoutLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 884 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 885 | /** Layout state may have changed (so another layout will be performed) */ |
| 886 | static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001; |
| 887 | /** Configuration state may have changed */ |
| 888 | static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002; |
| 889 | /** Wallpaper may need to move */ |
| 890 | static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 891 | /** Need to recompute animations */ |
| 892 | static final int FINISH_LAYOUT_REDO_ANIM = 0x0008; |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 893 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 894 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 895 | * Called following layout of all windows before each window has policy applied. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 896 | * |
| 897 | * @param displayWidth The current full width of the screen. |
| 898 | * @param displayHeight The current full height of the screen. |
| 899 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 900 | public void beginPostLayoutPolicyLw(int displayWidth, int displayHeight); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 901 | |
| 902 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 903 | * Called following layout of all window to apply policy to each window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 904 | * |
| 905 | * @param win The window being positioned. |
| 906 | * @param attrs The LayoutParams of the window. |
| 907 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 908 | public void applyPostLayoutPolicyLw(WindowState win, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 909 | WindowManager.LayoutParams attrs); |
| 910 | |
| 911 | /** |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 912 | * Called following layout of all windows and after policy has been applied |
| 913 | * to each window. If in this function you do |
| 914 | * something that may have modified the animation state of another window, |
| 915 | * be sure to return non-zero in order to perform another pass through layout. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 916 | * |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 917 | * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT}, |
| 918 | * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER}, |
| 919 | * or {@link #FINISH_LAYOUT_REDO_ANIM}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 920 | */ |
Craig Mautner | 3983419 | 2012-09-02 07:47:24 -0700 | [diff] [blame] | 921 | public int finishPostLayoutPolicyLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 922 | |
| 923 | /** |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 924 | * Return true if it is okay to perform animations for an app transition |
| 925 | * that is about to occur. You may return false for this if, for example, |
| 926 | * the lock screen is currently displayed so the switch should happen |
| 927 | * immediately. |
| 928 | */ |
| 929 | public boolean allowAppAnimationsLw(); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 930 | |
| 931 | |
| 932 | /** |
| 933 | * A new window has been focused. |
| 934 | */ |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 935 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus); |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 936 | |
| 937 | /** |
| 938 | * Called when the device is waking up. |
| 939 | */ |
| 940 | public void wakingUp(); |
| 941 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 942 | /** |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 943 | * Called when the device is going to sleep. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 944 | * |
| 945 | * @param why {@link #OFF_BECAUSE_OF_USER} or |
| 946 | * {@link #OFF_BECAUSE_OF_TIMEOUT}. |
| 947 | */ |
Jeff Brown | 140ffc7 | 2014-05-01 15:18:00 -0700 | [diff] [blame] | 948 | public void goingToSleep(int why); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 949 | |
Jeff Brown | 36c4db8 | 2014-09-19 12:05:31 -0700 | [diff] [blame] | 950 | /** |
| 951 | * Called when the device is about to turn on the screen to show content. |
| 952 | * When waking up, this method will be called once after the call to wakingUp(). |
| 953 | * When dozing, the method will be called sometime after the call to goingToSleep() and |
| 954 | * may be called repeatedly in the case where the screen is pulsing on and off. |
| 955 | * |
| 956 | * Must call back on the listener to tell it when the higher-level system |
| 957 | * is ready for the screen to go on (i.e. the lock screen is shown). |
| 958 | */ |
| 959 | public void screenTurningOn(ScreenOnListener screenOnListener); |
| 960 | |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 961 | /** |
| 962 | * Called when the device has turned the screen off. |
| 963 | */ |
| 964 | public void screenTurnedOff(); |
| 965 | |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 966 | public interface ScreenOnListener { |
| 967 | void onScreenOn(); |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 968 | } |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 969 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 970 | /** |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 971 | * 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] | 972 | */ |
Jeff Brown | 3ee549c | 2014-09-22 20:14:39 -0700 | [diff] [blame] | 973 | public boolean isScreenOn(); |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 974 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 975 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 976 | * Tell the policy that the lid switch has changed state. |
| 977 | * @param whenNanos The time when the change occurred in uptime nanoseconds. |
| 978 | * @param lidOpen True if the lid is now open. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 979 | */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 980 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); |
Michael Wright | 3818c92 | 2014-09-02 13:59:07 -0700 | [diff] [blame] | 981 | |
| 982 | /** |
| 983 | * Tell the policy that the camera lens has been covered or uncovered. |
| 984 | * @param whenNanos The time when the change occurred in uptime nanoseconds. |
| 985 | * @param lensCovered True if the lens is covered. |
| 986 | */ |
| 987 | public void notifyCameraLensCoverSwitchChanged(long whenNanos, boolean lensCovered); |
| 988 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 989 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 990 | * Tell the policy if anyone is requesting that keyguard not come on. |
| 991 | * |
| 992 | * @param enabled Whether keyguard can be on or not. does not actually |
| 993 | * turn it on, unless it was previously disabled with this function. |
| 994 | * |
| 995 | * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard() |
| 996 | * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard() |
| 997 | */ |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 998 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 999 | public void enableKeyguard(boolean enabled); |
| 1000 | |
| 1001 | /** |
| 1002 | * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely} |
| 1003 | */ |
| 1004 | interface OnKeyguardExitResult { |
| 1005 | void onKeyguardExitResult(boolean success); |
| 1006 | } |
| 1007 | |
| 1008 | /** |
| 1009 | * Tell the policy if anyone is requesting the keyguard to exit securely |
| 1010 | * (this would be called after the keyguard was disabled) |
| 1011 | * @param callback Callback to send the result back. |
| 1012 | * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult) |
| 1013 | */ |
Craig Mautner | 3c17437 | 2013-02-21 17:54:37 -0800 | [diff] [blame] | 1014 | @SuppressWarnings("javadoc") |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1015 | void exitKeyguardSecurely(OnKeyguardExitResult callback); |
| 1016 | |
| 1017 | /** |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 1018 | * isKeyguardLocked |
| 1019 | * |
| 1020 | * Return whether the keyguard is currently locked. |
| 1021 | * |
| 1022 | * @return true if in keyguard is locked. |
| 1023 | */ |
| 1024 | public boolean isKeyguardLocked(); |
| 1025 | |
| 1026 | /** |
| 1027 | * isKeyguardSecure |
| 1028 | * |
| 1029 | * Return whether the keyguard requires a password to unlock. |
| 1030 | * |
| 1031 | * @return true if in keyguard is secure. |
| 1032 | */ |
| 1033 | public boolean isKeyguardSecure(); |
| 1034 | |
| 1035 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1036 | * inKeyguardRestrictedKeyInputMode |
| 1037 | * |
| 1038 | * if keyguard screen is showing or in restricted key input mode (i.e. in |
| 1039 | * keyguard password emergency screen). When in such mode, certain keys, |
| 1040 | * such as the Home key and the right soft keys, don't work. |
| 1041 | * |
| 1042 | * @return true if in keyguard restricted input mode. |
| 1043 | */ |
| 1044 | public boolean inKeyguardRestrictedKeyInputMode(); |
| 1045 | |
| 1046 | /** |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1047 | * Ask the policy to dismiss the keyguard, if it is currently shown. |
| 1048 | */ |
| 1049 | public void dismissKeyguardLw(); |
| 1050 | |
| 1051 | /** |
Jorim Jaggi | 8de4311c | 2014-08-11 22:36:20 +0200 | [diff] [blame] | 1052 | * Notifies the keyguard that the activity has drawn it was waiting for. |
| 1053 | */ |
| 1054 | public void notifyActivityDrawnForKeyguardLw(); |
| 1055 | |
| 1056 | /** |
Jorim Jaggi | cff0acb | 2014-03-31 16:35:15 +0200 | [diff] [blame] | 1057 | * Ask the policy whether the Keyguard has drawn. If the Keyguard is disabled, this method |
| 1058 | * returns true as soon as we know that Keyguard is disabled. |
| 1059 | * |
| 1060 | * @return true if the keyguard has drawn. |
| 1061 | */ |
| 1062 | public boolean isKeyguardDrawnLw(); |
| 1063 | |
| 1064 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1065 | * Given an orientation constant, returns the appropriate surface rotation, |
| 1066 | * taking into account sensors, docking mode, rotation lock, and other factors. |
| 1067 | * |
| 1068 | * @param orientation An orientation constant, such as |
| 1069 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 1070 | * @param lastRotation The most recently used rotation. |
| 1071 | * @return The surface rotation to use. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1072 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1073 | public int rotationForOrientationLw(@ActivityInfo.ScreenOrientation int orientation, |
| 1074 | int lastRotation); |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1075 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1076 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 1077 | * Given an orientation constant and a rotation, returns true if the rotation |
| 1078 | * has compatible metrics to the requested orientation. For example, if |
| 1079 | * the application requested landscape and got seascape, then the rotation |
| 1080 | * has compatible metrics; if the application requested portrait and got landscape, |
| 1081 | * then the rotation has incompatible metrics; if the application did not specify |
| 1082 | * a preference, then anything goes. |
| 1083 | * |
| 1084 | * @param orientation An orientation constant, such as |
| 1085 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 1086 | * @param rotation The rotation to check. |
| 1087 | * @return True if the rotation is compatible with the requested orientation. |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1088 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1089 | public boolean rotationHasCompatibleMetricsLw(@ActivityInfo.ScreenOrientation int orientation, |
| 1090 | int rotation); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 1091 | |
| 1092 | /** |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 1093 | * Called by the window manager when the rotation changes. |
| 1094 | * |
| 1095 | * @param rotation The new rotation. |
| 1096 | */ |
| 1097 | public void setRotationLw(int rotation); |
| 1098 | |
| 1099 | /** |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1100 | * 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] | 1101 | * the system should go into safe mode. |
| 1102 | */ |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 1103 | public void setSafeMode(boolean safeMode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1104 | |
| 1105 | /** |
| 1106 | * Called when the system is mostly done booting. |
| 1107 | */ |
| 1108 | public void systemReady(); |
| 1109 | |
| 1110 | /** |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 1111 | * Called when the system is done booting to the point where the |
| 1112 | * user can start interacting with it. |
| 1113 | */ |
| 1114 | public void systemBooted(); |
| 1115 | |
| 1116 | /** |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 1117 | * Show boot time message to the user. |
| 1118 | */ |
| 1119 | public void showBootMessage(final CharSequence msg, final boolean always); |
| 1120 | |
| 1121 | /** |
| 1122 | * Hide the UI for showing boot messages, never to be displayed again. |
| 1123 | */ |
| 1124 | public void hideBootMessages(); |
| 1125 | |
| 1126 | /** |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 1127 | * Called when userActivity is signalled in the power manager. |
| 1128 | * This is safe to call from any thread, with any window manager locks held or not. |
| 1129 | */ |
| 1130 | public void userActivity(); |
| 1131 | |
| 1132 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1133 | * Called when we have finished booting and can now display the home |
Jeff Brown | c042ee2 | 2012-05-08 13:03:42 -0700 | [diff] [blame] | 1134 | * 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] | 1135 | * this point the display is active. |
| 1136 | */ |
| 1137 | public void enableScreenAfterBoot(); |
| 1138 | |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1139 | public void setCurrentOrientationLw(@ActivityInfo.ScreenOrientation int newOrientation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1140 | |
| 1141 | /** |
| 1142 | * Call from application to perform haptic feedback on its window. |
| 1143 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 1144 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1145 | |
| 1146 | /** |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1147 | * Called when we have started keeping the screen on because a window |
| 1148 | * requesting this has become visible. |
| 1149 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1150 | public void keepScreenOnStartedLw(); |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1151 | |
| 1152 | /** |
| 1153 | * 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] | 1154 | * requesting this is no longer visible. |
| 1155 | */ |
Jeff Brown | c38c9be | 2012-10-04 13:16:19 -0700 | [diff] [blame] | 1156 | public void keepScreenOnStoppedLw(); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1157 | |
| 1158 | /** |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 1159 | * Gets the current user rotation mode. |
| 1160 | * |
| 1161 | * @return The rotation mode. |
| 1162 | * |
| 1163 | * @see WindowManagerPolicy#USER_ROTATION_LOCKED |
| 1164 | * @see WindowManagerPolicy#USER_ROTATION_FREE |
| 1165 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1166 | @UserRotationMode |
Svetoslav Ganov | 80943d8 | 2013-01-02 10:25:37 -0800 | [diff] [blame] | 1167 | public int getUserRotationMode(); |
| 1168 | |
| 1169 | /** |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1170 | * Inform the policy that the user has chosen a preferred orientation ("rotation lock"). |
| 1171 | * |
| 1172 | * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1173 | * {@link WindowManagerPolicy#USER_ROTATION_FREE}. |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1174 | * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90}, |
Craig Mautner | 69b0818 | 2012-09-05 13:07:13 -0700 | [diff] [blame] | 1175 | * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}. |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1176 | */ |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1177 | public void setUserRotationMode(@UserRotationMode int mode, @Surface.Rotation int rotation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1178 | |
| 1179 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1180 | * Called when a new system UI visibility is being reported, allowing |
| 1181 | * the policy to adjust what is actually reported. |
Tor Norbye | d9273d6 | 2013-05-30 15:59:53 -0700 | [diff] [blame] | 1182 | * @param visibility The raw visibility reported by the status bar. |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1183 | * @return The new desired visibility. |
| 1184 | */ |
| 1185 | public int adjustSystemUiVisibilityLw(int visibility); |
| 1186 | |
| 1187 | /** |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1188 | * Specifies whether there is an on-screen navigation bar separate from the status bar. |
| 1189 | */ |
| 1190 | public boolean hasNavigationBar(); |
| 1191 | |
| 1192 | /** |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1193 | * Lock the device now. |
| 1194 | */ |
Adam Cohen | f752202 | 2012-10-03 20:03:18 -0700 | [diff] [blame] | 1195 | public void lockNow(Bundle options); |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1196 | |
| 1197 | /** |
satok | 1bc0a49 | 2012-04-25 22:47:12 +0900 | [diff] [blame] | 1198 | * Set the last used input method window state. This state is used to make IME transition |
| 1199 | * smooth. |
| 1200 | * @hide |
| 1201 | */ |
| 1202 | public void setLastInputMethodWindowLw(WindowState ime, WindowState target); |
| 1203 | |
| 1204 | /** |
Craig Mautner | 84984fa | 2014-06-19 11:19:20 -0700 | [diff] [blame] | 1205 | * Show the recents task list app. |
| 1206 | * @hide |
| 1207 | */ |
| 1208 | public void showRecentApps(); |
| 1209 | |
| 1210 | /** |
Alan Viverette | e34560b2 | 2014-07-10 14:50:06 -0700 | [diff] [blame] | 1211 | * Show the global actions dialog. |
| 1212 | * @hide |
| 1213 | */ |
| 1214 | public void showGlobalActions(); |
| 1215 | |
| 1216 | /** |
Satoshi Kataoka | 658c7b8 | 2013-10-10 17:03:51 +0900 | [diff] [blame] | 1217 | * @return The current height of the input method window. |
| 1218 | */ |
| 1219 | public int getInputMethodWindowVisibleHeightLw(); |
| 1220 | |
| 1221 | /** |
Craig Mautner | f1b6741 | 2012-09-19 13:18:29 -0700 | [diff] [blame] | 1222 | * Called when the current user changes. Guaranteed to be called before the broadcast |
| 1223 | * of the new user id is made to all listeners. |
| 1224 | * |
| 1225 | * @param newUserId The id of the incoming user. |
| 1226 | */ |
| 1227 | public void setCurrentUserLw(int newUserId); |
Svetoslav Ganov | 1cf70bb | 2012-08-06 10:53:34 -0700 | [diff] [blame] | 1228 | |
| 1229 | /** |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1230 | * Print the WindowManagerPolicy's state into the given stream. |
| 1231 | * |
| 1232 | * @param prefix Text to print at the front of each line. |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1233 | * @param writer The PrintWriter to which you should dump your state. This will be |
| 1234 | * closed for you after you return. |
| 1235 | * @param args additional arguments to the dump request. |
| 1236 | */ |
Jeff Brown | d7a04de | 2012-06-17 14:17:52 -0700 | [diff] [blame] | 1237 | public void dump(String prefix, PrintWriter writer, String[] args); |
Jim Miller | 4eeb4f6 | 2012-11-08 00:04:29 -0800 | [diff] [blame] | 1238 | |
| 1239 | /** |
Svetoslav Ganov | 545252f | 2012-12-10 18:29:24 -0800 | [diff] [blame] | 1240 | * Returns whether a given window type can be magnified. |
| 1241 | * |
| 1242 | * @param windowType The window type. |
| 1243 | * @return True if the window can be magnified. |
| 1244 | */ |
| 1245 | public boolean canMagnifyWindow(int windowType); |
| 1246 | |
| 1247 | /** |
| 1248 | * Returns whether a given window type is considered a top level one. |
| 1249 | * A top level window does not have a container, i.e. attached window, |
| 1250 | * or if it has a container it is laid out as a top-level window, not |
| 1251 | * as a child of its container. |
| 1252 | * |
| 1253 | * @param windowType The window type. |
| 1254 | * @return True if the window is a top level one. |
| 1255 | */ |
| 1256 | public boolean isTopLevelWindow(int windowType); |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1257 | |
| 1258 | /** |
| 1259 | * Notifies the keyguard to start fading out. |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1260 | * |
| 1261 | * @param startTime the start time of the animation in uptime milliseconds |
| 1262 | * @param fadeoutDuration the duration of the exit animation, in milliseconds |
Jorim Jaggi | 0d67462 | 2014-05-21 01:34:15 +0200 | [diff] [blame] | 1263 | */ |
Jorim Jaggi | e29b2db | 2014-05-30 23:17:03 +0200 | [diff] [blame] | 1264 | public void startKeyguardExitAnimation(long startTime, long fadeoutDuration); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1265 | } |