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 | |
| 19 | import android.content.Context; |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 20 | import android.content.res.CompatibilityInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.res.Configuration; |
| 22 | import android.graphics.Rect; |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 23 | import android.graphics.RectF; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.os.IBinder; |
| 25 | import android.os.LocalPowerManager; |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 26 | import android.os.Looper; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.view.animation.Animation; |
| 28 | |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 29 | import java.io.FileDescriptor; |
| 30 | import java.io.PrintWriter; |
| 31 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | /** |
| 33 | * This interface supplies all UI-specific behavior of the window manager. An |
| 34 | * instance of it is created by the window manager when it starts up, and allows |
| 35 | * customization of window layering, special window types, key dispatching, and |
| 36 | * layout. |
| 37 | * |
| 38 | * <p>Because this provides deep interaction with the system window manager, |
| 39 | * specific methods on this interface can be called from a variety of contexts |
| 40 | * with various restrictions on what they can do. These are encoded through |
| 41 | * a suffixes at the end of a method encoding the thread the method is called |
| 42 | * from and any locks that are held when it is being called; if no suffix |
| 43 | * is attached to a method, then it is not called with any locks and may be |
| 44 | * called from the main window manager thread or another thread calling into |
| 45 | * the window manager. |
| 46 | * |
| 47 | * <p>The current suffixes are: |
| 48 | * |
| 49 | * <dl> |
| 50 | * <dt> Ti <dd> Called from the input thread. This is the thread that |
| 51 | * collects pending input events and dispatches them to the appropriate window. |
| 52 | * It may block waiting for events to be processed, so that the input stream is |
| 53 | * properly serialized. |
| 54 | * <dt> Tq <dd> Called from the low-level input queue thread. This is the |
| 55 | * thread that reads events out of the raw input devices and places them |
| 56 | * into the global input queue that is read by the <var>Ti</var> thread. |
| 57 | * This thread should not block for a long period of time on anything but the |
| 58 | * key driver. |
| 59 | * <dt> Lw <dd> Called with the main window manager lock held. Because the |
| 60 | * window manager is a very low-level system service, there are few other |
| 61 | * system services you can call with this lock held. It is explicitly okay to |
| 62 | * 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] | 63 | * 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] | 64 | * {@link android.content.Context#checkPermission(String, int, int)} and |
| 65 | * variations require calling into the activity manager. |
| 66 | * <dt> Li <dd> Called with the input thread lock held. This lock can be |
| 67 | * acquired by the window manager while it holds the window lock, so this is |
| 68 | * even more restrictive than <var>Lw</var>. |
| 69 | * </dl> |
| 70 | * |
| 71 | * @hide |
| 72 | */ |
| 73 | public interface WindowManagerPolicy { |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 74 | // 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] | 75 | public final static int FLAG_WAKE = 0x00000001; |
| 76 | public final static int FLAG_WAKE_DROPPED = 0x00000002; |
| 77 | public final static int FLAG_SHIFT = 0x00000004; |
| 78 | public final static int FLAG_CAPS_LOCK = 0x00000008; |
| 79 | public final static int FLAG_ALT = 0x00000010; |
| 80 | public final static int FLAG_ALT_GR = 0x00000020; |
| 81 | public final static int FLAG_MENU = 0x00000040; |
| 82 | public final static int FLAG_LAUNCHER = 0x00000080; |
Jeff Brown | 0eaf393 | 2010-10-01 14:55:30 -0700 | [diff] [blame] | 83 | public final static int FLAG_VIRTUAL = 0x00000100; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 85 | public final static int FLAG_INJECTED = 0x01000000; |
Jeff Brown | e20c9e0 | 2010-10-11 14:20:19 -0700 | [diff] [blame] | 86 | public final static int FLAG_TRUSTED = 0x02000000; |
Jeff Brown | 0029c66 | 2011-03-30 02:25:18 -0700 | [diff] [blame] | 87 | public final static int FLAG_FILTERED = 0x04000000; |
| 88 | public final static int FLAG_DISABLE_KEY_REPEAT = 0x08000000; |
Jeff Brown | 85a3176 | 2010-09-01 17:01:00 -0700 | [diff] [blame] | 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | public final static int FLAG_WOKE_HERE = 0x10000000; |
| 91 | public final static int FLAG_BRIGHT_HERE = 0x20000000; |
Jeff Brown | b699726 | 2010-10-08 22:31:17 -0700 | [diff] [blame] | 92 | public final static int FLAG_PASS_TO_USER = 0x40000000; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | |
| 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 | /** |
| 114 | * This key event should extend the user activity timeout and turn the lights on. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 115 | * To be returned from {@link #interceptKeyBeforeQueueing}. |
| 116 | * Do not return this and {@link #ACTION_GO_TO_SLEEP} or {@link #ACTION_PASS_TO_USER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | */ |
| 118 | public final static int ACTION_POKE_USER_ACTIVITY = 0x00000002; |
| 119 | |
| 120 | /** |
| 121 | * This key event should put the device to sleep (and engage keyguard if necessary) |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 122 | * To be returned from {@link #interceptKeyBeforeQueueing}. |
| 123 | * Do not return this and {@link #ACTION_POKE_USER_ACTIVITY} or {@link #ACTION_PASS_TO_USER}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 124 | */ |
| 125 | public final static int ACTION_GO_TO_SLEEP = 0x00000004; |
| 126 | |
| 127 | /** |
| 128 | * Interface to the Window Manager state associated with a particular |
| 129 | * window. You can hold on to an instance of this interface from the call |
| 130 | * to prepareAddWindow() until removeWindow(). |
| 131 | */ |
| 132 | public interface WindowState { |
| 133 | /** |
| 134 | * Perform standard frame computation. The result can be obtained with |
| 135 | * getFrame() if so desired. Must be called with the window manager |
| 136 | * lock held. |
| 137 | * |
| 138 | * @param parentFrame The frame of the parent container this window |
| 139 | * is in, used for computing its basic position. |
| 140 | * @param displayFrame The frame of the overall display in which this |
| 141 | * window can appear, used for constraining the overall dimensions |
| 142 | * of the window. |
| 143 | * @param contentFrame The frame within the display in which we would |
| 144 | * like active content to appear. This will cause windows behind to |
| 145 | * be resized to match the given content frame. |
| 146 | * @param visibleFrame The frame within the display that the window |
| 147 | * is actually visible, used for computing its visible insets to be |
| 148 | * given to windows behind. |
| 149 | * This can be used as a hint for scrolling (avoiding resizing) |
| 150 | * the window to make certain that parts of its content |
| 151 | * are visible. |
| 152 | */ |
| 153 | public void computeFrameLw(Rect parentFrame, Rect displayFrame, |
| 154 | Rect contentFrame, Rect visibleFrame); |
| 155 | |
| 156 | /** |
| 157 | * Retrieve the current frame of the window that has been assigned by |
| 158 | * the window manager. Must be called with the window manager lock held. |
| 159 | * |
| 160 | * @return Rect The rectangle holding the window frame. |
| 161 | */ |
| 162 | public Rect getFrameLw(); |
| 163 | |
| 164 | /** |
| 165 | * Retrieve the current frame of the window that is actually shown. |
| 166 | * Must be called with the window manager lock held. |
| 167 | * |
| 168 | * @return Rect The rectangle holding the shown window frame. |
| 169 | */ |
Dianne Hackborn | d040edb | 2011-08-31 12:47:58 -0700 | [diff] [blame] | 170 | public RectF getShownFrameLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 171 | |
| 172 | /** |
| 173 | * Retrieve the frame of the display that this window was last |
| 174 | * laid out in. Must be called with the |
| 175 | * window manager lock held. |
| 176 | * |
| 177 | * @return Rect The rectangle holding the display frame. |
| 178 | */ |
| 179 | public Rect getDisplayFrameLw(); |
| 180 | |
| 181 | /** |
| 182 | * Retrieve the frame of the content area that this window was last |
| 183 | * laid out in. This is the area in which the content of the window |
| 184 | * should be placed. It will be smaller than the display frame to |
| 185 | * account for screen decorations such as a status bar or soft |
| 186 | * keyboard. Must be called with the |
| 187 | * window manager lock held. |
| 188 | * |
| 189 | * @return Rect The rectangle holding the content frame. |
| 190 | */ |
| 191 | public Rect getContentFrameLw(); |
| 192 | |
| 193 | /** |
| 194 | * Retrieve the frame of the visible area that this window was last |
| 195 | * laid out in. This is the area of the screen in which the window |
| 196 | * will actually be fully visible. It will be smaller than the |
| 197 | * content frame to account for transient UI elements blocking it |
| 198 | * such as an input method's candidates UI. Must be called with the |
| 199 | * window manager lock held. |
| 200 | * |
| 201 | * @return Rect The rectangle holding the visible frame. |
| 202 | */ |
| 203 | public Rect getVisibleFrameLw(); |
| 204 | |
| 205 | /** |
| 206 | * Returns true if this window is waiting to receive its given |
| 207 | * internal insets from the client app, and so should not impact the |
| 208 | * layout of other windows. |
| 209 | */ |
| 210 | public boolean getGivenInsetsPendingLw(); |
| 211 | |
| 212 | /** |
| 213 | * Retrieve the insets given by this window's client for the content |
| 214 | * area of windows behind it. Must be called with the |
| 215 | * window manager lock held. |
| 216 | * |
| 217 | * @return Rect The left, top, right, and bottom insets, relative |
| 218 | * to the window's frame, of the actual contents. |
| 219 | */ |
| 220 | public Rect getGivenContentInsetsLw(); |
| 221 | |
| 222 | /** |
| 223 | * Retrieve the insets given by this window's client for the visible |
| 224 | * area of windows behind it. Must be called with the |
| 225 | * window manager lock held. |
| 226 | * |
| 227 | * @return Rect The left, top, right, and bottom insets, relative |
| 228 | * to the window's frame, of the actual visible area. |
| 229 | */ |
| 230 | public Rect getGivenVisibleInsetsLw(); |
| 231 | |
| 232 | /** |
| 233 | * Retrieve the current LayoutParams of the window. |
| 234 | * |
| 235 | * @return WindowManager.LayoutParams The window's internal LayoutParams |
| 236 | * instance. |
| 237 | */ |
| 238 | public WindowManager.LayoutParams getAttrs(); |
| 239 | |
| 240 | /** |
Dianne Hackborn | 73ab6a4 | 2011-12-13 11:16:23 -0800 | [diff] [blame] | 241 | * Return whether this window needs the menu key shown. Must be called |
| 242 | * with window lock held, because it may need to traverse down through |
| 243 | * window list to determine the result. |
| 244 | * @param bottom The bottom-most window to consider when determining this. |
| 245 | */ |
| 246 | public boolean getNeedsMenuLw(WindowState bottom); |
| 247 | |
| 248 | /** |
Dianne Hackborn | 9a230e0 | 2011-10-06 11:51:27 -0700 | [diff] [blame] | 249 | * Retrieve the current system UI visibility flags associated with |
| 250 | * this window. |
| 251 | */ |
| 252 | public int getSystemUiVisibility(); |
| 253 | |
| 254 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 255 | * Get the layer at which this window's surface will be Z-ordered. |
| 256 | */ |
| 257 | public int getSurfaceLayer(); |
| 258 | |
| 259 | /** |
| 260 | * Return the token for the application (actually activity) that owns |
| 261 | * this window. May return null for system windows. |
| 262 | * |
| 263 | * @return An IApplicationToken identifying the owning activity. |
| 264 | */ |
| 265 | public IApplicationToken getAppToken(); |
| 266 | |
| 267 | /** |
| 268 | * Return true if, at any point, the application token associated with |
| 269 | * this window has actually displayed any windows. This is most useful |
| 270 | * with the "starting up" window to determine if any windows were |
| 271 | * displayed when it is closed. |
| 272 | * |
| 273 | * @return Returns true if one or more windows have been displayed, |
| 274 | * else false. |
| 275 | */ |
| 276 | public boolean hasAppShownWindows(); |
| 277 | |
| 278 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 279 | * Is this window visible? It is not visible if there is no |
| 280 | * surface, or we are in the process of running an exit animation |
| 281 | * that will remove the surface. |
| 282 | */ |
| 283 | boolean isVisibleLw(); |
| 284 | |
| 285 | /** |
Dianne Hackborn | 3d163f07 | 2009-10-07 21:26:57 -0700 | [diff] [blame] | 286 | * Like {@link #isVisibleLw}, but also counts a window that is currently |
| 287 | * "hidden" behind the keyguard as visible. This allows us to apply |
| 288 | * things like window flags that impact the keyguard. |
| 289 | */ |
| 290 | boolean isVisibleOrBehindKeyguardLw(); |
| 291 | |
| 292 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 293 | * Is this window currently visible to the user on-screen? It is |
| 294 | * displayed either if it is visible or it is currently running an |
| 295 | * animation before no longer being visible. Must be called with the |
| 296 | * window manager lock held. |
| 297 | */ |
| 298 | boolean isDisplayedLw(); |
| 299 | |
| 300 | /** |
Dianne Hackborn | 01b02a7 | 2012-01-12 14:05:03 -0800 | [diff] [blame] | 301 | * Is this window considered to be gone for purposes of layout? |
| 302 | */ |
| 303 | boolean isGoneForLayoutLw(); |
| 304 | |
| 305 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 306 | * Returns true if this window has been shown on screen at some time in |
| 307 | * the past. Must be called with the window manager lock held. |
| 308 | * |
| 309 | * @return boolean |
| 310 | */ |
| 311 | public boolean hasDrawnLw(); |
| 312 | |
| 313 | /** |
| 314 | * Can be called by the policy to force a window to be hidden, |
| 315 | * regardless of whether the client or window manager would like |
| 316 | * it shown. Must be called with the window manager lock held. |
| 317 | * Returns true if {@link #showLw} was last called for the window. |
| 318 | */ |
| 319 | public boolean hideLw(boolean doAnimation); |
| 320 | |
| 321 | /** |
| 322 | * Can be called to undo the effect of {@link #hideLw}, allowing a |
| 323 | * window to be shown as long as the window manager and client would |
| 324 | * also like it to be shown. Must be called with the window manager |
| 325 | * lock held. |
| 326 | * Returns true if {@link #hideLw} was last called for the window. |
| 327 | */ |
| 328 | public boolean showLw(boolean doAnimation); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 329 | |
| 330 | /** |
| 331 | * Check whether the process hosting this window is currently alive. |
| 332 | */ |
| 333 | public boolean isAlive(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 334 | } |
| 335 | |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 336 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 337 | * Representation of a "fake window" that the policy has added to the |
| 338 | * window manager to consume events. |
| 339 | */ |
| 340 | public interface FakeWindow { |
| 341 | /** |
| 342 | * Remove the fake window from the window manager. |
| 343 | */ |
| 344 | void dismiss(); |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Interface for calling back in to the window manager that is private |
| 349 | * between it and the policy. |
| 350 | */ |
| 351 | public interface WindowManagerFuncs { |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 352 | public static final int LID_ABSENT = -1; |
| 353 | public static final int LID_CLOSED = 0; |
| 354 | public static final int LID_OPEN = 1; |
| 355 | |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 356 | /** |
| 357 | * Ask the window manager to re-evaluate the system UI flags. |
| 358 | */ |
| 359 | public void reevaluateStatusBarVisibility(); |
| 360 | |
| 361 | /** |
| 362 | * Add a fake window to the window manager. This window sits |
| 363 | * at the top of the other windows and consumes events. |
| 364 | */ |
Jeff Brown | 32cbc3855 | 2011-12-01 14:01:49 -0800 | [diff] [blame] | 365 | public FakeWindow addFakeWindow(Looper looper, |
| 366 | InputEventReceiver.Factory inputEventReceiverFactory, |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 367 | String name, int windowType, int layoutParamsFlags, boolean canReceiveKeys, |
| 368 | boolean hasFocus, boolean touchFullscreen); |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 369 | |
| 370 | /** |
| 371 | * Returns a code that describes the current state of the lid switch. |
| 372 | */ |
| 373 | public int getLidState(); |
| 374 | |
| 375 | /** |
| 376 | * Creates an input channel that will receive all input from the input dispatcher. |
| 377 | */ |
| 378 | public InputChannel monitorInput(String name); |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | /** |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 382 | * Bit mask that is set for all enter transition. |
| 383 | */ |
| 384 | public final int TRANSIT_ENTER_MASK = 0x1000; |
| 385 | |
| 386 | /** |
| 387 | * Bit mask that is set for all exit transitions. |
| 388 | */ |
| 389 | public final int TRANSIT_EXIT_MASK = 0x2000; |
| 390 | |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 391 | /** Not set up for a transition. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 392 | public final int TRANSIT_UNSET = -1; |
Dianne Hackborn | bfe319e | 2009-09-21 00:34:05 -0700 | [diff] [blame] | 393 | /** No animation for transition. */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 394 | public final int TRANSIT_NONE = 0; |
| 395 | /** Window has been added to the screen. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 396 | public final int TRANSIT_ENTER = 1 | TRANSIT_ENTER_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 397 | /** Window has been removed from the screen. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 398 | public final int TRANSIT_EXIT = 2 | TRANSIT_EXIT_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | /** Window has been made visible. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 400 | public final int TRANSIT_SHOW = 3 | TRANSIT_ENTER_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 401 | /** Window has been made invisible. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 402 | public final int TRANSIT_HIDE = 4 | TRANSIT_EXIT_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 403 | /** The "application starting" preview window is no longer needed, and will |
| 404 | * animate away to show the real window. */ |
| 405 | public final int TRANSIT_PREVIEW_DONE = 5; |
| 406 | /** A window in a new activity is being opened on top of an existing one |
| 407 | * in the same task. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 408 | public final int TRANSIT_ACTIVITY_OPEN = 6 | TRANSIT_ENTER_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 409 | /** The window in the top-most activity is being closed to reveal the |
| 410 | * previous activity in the same task. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 411 | public final int TRANSIT_ACTIVITY_CLOSE = 7 | TRANSIT_EXIT_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 412 | /** A window in a new task is being opened on top of an existing one |
| 413 | * in another activity's task. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 414 | public final int TRANSIT_TASK_OPEN = 8 | TRANSIT_ENTER_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 415 | /** A window in the top-most activity is being closed to reveal the |
| 416 | * previous activity in a different task. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 417 | public final int TRANSIT_TASK_CLOSE = 9 | TRANSIT_EXIT_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 418 | /** A window in an existing task is being displayed on top of an existing one |
| 419 | * in another activity's task. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 420 | public final int TRANSIT_TASK_TO_FRONT = 10 | TRANSIT_ENTER_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 421 | /** A window in an existing task is being put below all other tasks. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 422 | public final int TRANSIT_TASK_TO_BACK = 11 | TRANSIT_EXIT_MASK; |
Dianne Hackborn | 25994b4 | 2009-09-04 14:21:19 -0700 | [diff] [blame] | 423 | /** A window in a new activity that doesn't have a wallpaper is being |
| 424 | * opened on top of one that does, effectively closing the wallpaper. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 425 | public final int TRANSIT_WALLPAPER_CLOSE = 12 | TRANSIT_EXIT_MASK; |
Dianne Hackborn | 25994b4 | 2009-09-04 14:21:19 -0700 | [diff] [blame] | 426 | /** A window in a new activity that does have a wallpaper is being |
| 427 | * opened on one that didn't, effectively opening the wallpaper. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 428 | public final int TRANSIT_WALLPAPER_OPEN = 13 | TRANSIT_ENTER_MASK; |
Dianne Hackborn | f8fbdb6 | 2009-08-19 12:39:43 -0700 | [diff] [blame] | 429 | /** A window in a new activity is being opened on top of an existing one, |
| 430 | * and both are on top of the wallpaper. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 431 | public final int TRANSIT_WALLPAPER_INTRA_OPEN = 14 | TRANSIT_ENTER_MASK; |
Dianne Hackborn | f8fbdb6 | 2009-08-19 12:39:43 -0700 | [diff] [blame] | 432 | /** The window in the top-most activity is being closed to reveal the |
| 433 | * previous activity, and both are on top of he wallpaper. */ |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 434 | public final int TRANSIT_WALLPAPER_INTRA_CLOSE = 15 | TRANSIT_EXIT_MASK; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 435 | |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 436 | // NOTE: screen off reasons are in order of significance, with more |
| 437 | // important ones lower than less important ones. |
| 438 | |
| 439 | /** Screen turned off because of a device admin */ |
| 440 | public final int OFF_BECAUSE_OF_ADMIN = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 441 | /** Screen turned off because of power button */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 442 | public final int OFF_BECAUSE_OF_USER = 2; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 443 | /** Screen turned off because of timeout */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 444 | public final int OFF_BECAUSE_OF_TIMEOUT = 3; |
Mike Lockwood | 435eb64 | 2009-12-03 08:40:18 -0500 | [diff] [blame] | 445 | /** Screen turned off because of proximity sensor */ |
Dianne Hackborn | 254cb44 | 2010-01-27 19:23:59 -0800 | [diff] [blame] | 446 | public final int OFF_BECAUSE_OF_PROX_SENSOR = 4; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 447 | |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 448 | /** When not otherwise specified by the activity's screenOrientation, rotation should be |
| 449 | * determined by the system (that is, using sensors). */ |
| 450 | public final int USER_ROTATION_FREE = 0; |
| 451 | /** When not otherwise specified by the activity's screenOrientation, rotation is set by |
| 452 | * the user. */ |
| 453 | public final int USER_ROTATION_LOCKED = 1; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 454 | |
| 455 | /** |
| 456 | * Perform initialization of the policy. |
| 457 | * |
| 458 | * @param context The system context we are running in. |
| 459 | * @param powerManager |
| 460 | */ |
| 461 | public void init(Context context, IWindowManager windowManager, |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 462 | WindowManagerFuncs windowManagerFuncs, |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 463 | LocalPowerManager powerManager); |
| 464 | |
| 465 | /** |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 466 | * Called by window manager once it has the initial, default native |
| 467 | * display dimensions. |
| 468 | */ |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 469 | public void setInitialDisplaySize(Display display, int width, int height); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 470 | |
Dianne Hackborn | 9d13264 | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 471 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 472 | * Check permissions when adding a window. |
| 473 | * |
| 474 | * @param attrs The window's LayoutParams. |
| 475 | * |
| 476 | * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed; |
| 477 | * else an error code, usually |
| 478 | * {@link WindowManagerImpl#ADD_PERMISSION_DENIED}, to abort the add. |
| 479 | */ |
| 480 | public int checkAddPermission(WindowManager.LayoutParams attrs); |
| 481 | |
| 482 | /** |
| 483 | * Sanitize the layout parameters coming from a client. Allows the policy |
| 484 | * to do things like ensure that windows of a specific type can't take |
| 485 | * input focus. |
| 486 | * |
| 487 | * @param attrs The window layout parameters to be modified. These values |
| 488 | * are modified in-place. |
| 489 | */ |
| 490 | public void adjustWindowParamsLw(WindowManager.LayoutParams attrs); |
| 491 | |
| 492 | /** |
| 493 | * After the window manager has computed the current configuration based |
| 494 | * on its knowledge of the display and input devices, it gives the policy |
| 495 | * a chance to adjust the information contained in it. If you want to |
| 496 | * leave it as-is, simply do nothing. |
| 497 | * |
| 498 | * <p>This method may be called by any thread in the window manager, but |
| 499 | * no internal locks in the window manager will be held. |
| 500 | * |
| 501 | * @param config The Configuration being computed, for you to change as |
| 502 | * desired. |
| 503 | */ |
| 504 | public void adjustConfigurationLw(Configuration config); |
| 505 | |
| 506 | /** |
| 507 | * Assign a window type to a layer. Allows you to control how different |
| 508 | * kinds of windows are ordered on-screen. |
| 509 | * |
| 510 | * @param type The type of window being assigned. |
| 511 | * |
| 512 | * @return int An arbitrary integer used to order windows, with lower |
| 513 | * numbers below higher ones. |
| 514 | */ |
| 515 | public int windowTypeToLayerLw(int type); |
| 516 | |
| 517 | /** |
| 518 | * Return how to Z-order sub-windows in relation to the window they are |
| 519 | * attached to. Return positive to have them ordered in front, negative for |
| 520 | * behind. |
| 521 | * |
| 522 | * @param type The sub-window type code. |
| 523 | * |
| 524 | * @return int Layer in relation to the attached window, where positive is |
| 525 | * above and negative is below. |
| 526 | */ |
| 527 | public int subWindowTypeToLayerLw(int type); |
| 528 | |
| 529 | /** |
Dianne Hackborn | 6136b7e | 2009-09-18 01:53:49 -0700 | [diff] [blame] | 530 | * Get the highest layer (actually one more than) that the wallpaper is |
| 531 | * allowed to be in. |
| 532 | */ |
| 533 | public int getMaxWallpaperLayer(); |
| 534 | |
| 535 | /** |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 536 | * Return true if the policy desires a full unified system nav bar. Otherwise, |
| 537 | * it is a phone-style status bar with optional nav bar. |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 538 | */ |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 539 | public boolean hasSystemNavBar(); |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 540 | |
| 541 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 542 | * Return the display width available after excluding any screen |
| 543 | * decorations that can never be removed. That is, system bar or |
| 544 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 545 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 546 | public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 547 | |
| 548 | /** |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 549 | * Return the display height available after excluding any screen |
| 550 | * decorations that can never be removed. That is, system bar or |
| 551 | * button bar. |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 552 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 553 | public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 554 | |
| 555 | /** |
| 556 | * Return the available screen width that we should report for the |
| 557 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 558 | * {@link #getNonDecorDisplayWidth(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 559 | * that to account for more transient decoration like a status bar. |
| 560 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 561 | public int getConfigDisplayWidth(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 562 | |
| 563 | /** |
| 564 | * Return the available screen height that we should report for the |
| 565 | * configuration. This must be no larger than |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 566 | * {@link #getNonDecorDisplayHeight(int, int, int)}; it may be smaller than |
Dianne Hackborn | 69cb875 | 2011-05-19 18:13:32 -0700 | [diff] [blame] | 567 | * that to account for more transient decoration like a status bar. |
| 568 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 569 | public int getConfigDisplayHeight(int fullWidth, int fullHeight, int rotation); |
Dianne Hackborn | e2515ee | 2011-04-27 18:52:56 -0400 | [diff] [blame] | 570 | |
| 571 | /** |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 572 | * Return whether the given window should forcibly hide everything |
| 573 | * behind it. Typically returns true for the keyguard. |
| 574 | */ |
| 575 | public boolean doesForceHide(WindowState win, WindowManager.LayoutParams attrs); |
| 576 | |
| 577 | /** |
| 578 | * Determine if a window that is behind one that is force hiding |
| 579 | * (as determined by {@link #doesForceHide}) should actually be hidden. |
| 580 | * For example, typically returns false for the status bar. Be careful |
| 581 | * to return false for any window that you may hide yourself, since this |
| 582 | * will conflict with what you set. |
| 583 | */ |
| 584 | public boolean canBeForceHidden(WindowState win, WindowManager.LayoutParams attrs); |
| 585 | |
| 586 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 587 | * Called when the system would like to show a UI to indicate that an |
| 588 | * application is starting. You can use this to add a |
| 589 | * APPLICATION_STARTING_TYPE window with the given appToken to the window |
| 590 | * manager (using the normal window manager APIs) that will be shown until |
| 591 | * the application displays its own window. This is called without the |
| 592 | * window manager locked so that you can call back into it. |
| 593 | * |
| 594 | * @param appToken Token of the application being started. |
| 595 | * @param packageName The name of the application package being started. |
| 596 | * @param theme Resource defining the application's overall visual theme. |
| 597 | * @param nonLocalizedLabel The default title label of the application if |
| 598 | * no data is found in the resource. |
| 599 | * @param labelRes The resource ID the application would like to use as its name. |
| 600 | * @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] | 601 | * @param windowFlags Window layout flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 602 | * |
| 603 | * @return Optionally you can return the View that was used to create the |
| 604 | * window, for easy removal in removeStartingWindow. |
| 605 | * |
| 606 | * @see #removeStartingWindow |
| 607 | */ |
| 608 | public View addStartingWindow(IBinder appToken, String packageName, |
Dianne Hackborn | 2f0b175 | 2011-05-31 17:59:49 -0700 | [diff] [blame] | 609 | int theme, CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, |
Dianne Hackborn | 7eec10e | 2010-11-12 18:03:47 -0800 | [diff] [blame] | 610 | int labelRes, int icon, int windowFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 611 | |
| 612 | /** |
| 613 | * Called when the first window of an application has been displayed, while |
| 614 | * {@link #addStartingWindow} has created a temporary initial window for |
| 615 | * that application. You should at this point remove the window from the |
| 616 | * window manager. This is called without the window manager locked so |
| 617 | * that you can call back into it. |
| 618 | * |
| 619 | * <p>Note: due to the nature of these functions not being called with the |
| 620 | * window manager locked, you must be prepared for this function to be |
| 621 | * called multiple times and/or an initial time with a null View window |
| 622 | * even if you previously returned one. |
| 623 | * |
| 624 | * @param appToken Token of the application that has started. |
| 625 | * @param window Window View that was returned by createStartingWindow. |
| 626 | * |
| 627 | * @see #addStartingWindow |
| 628 | */ |
| 629 | public void removeStartingWindow(IBinder appToken, View window); |
| 630 | |
| 631 | /** |
| 632 | * Prepare for a window being added to the window manager. You can throw an |
| 633 | * exception here to prevent the window being added, or do whatever setup |
| 634 | * you need to keep track of the window. |
| 635 | * |
| 636 | * @param win The window being added. |
| 637 | * @param attrs The window's LayoutParams. |
| 638 | * |
| 639 | * @return {@link WindowManagerImpl#ADD_OKAY} if the add can proceed, else an |
| 640 | * error code to abort the add. |
| 641 | */ |
| 642 | public int prepareAddWindowLw(WindowState win, |
| 643 | WindowManager.LayoutParams attrs); |
| 644 | |
| 645 | /** |
| 646 | * Called when a window is being removed from a window manager. Must not |
| 647 | * throw an exception -- clean up as much as possible. |
| 648 | * |
| 649 | * @param win The window being removed. |
| 650 | */ |
| 651 | public void removeWindowLw(WindowState win); |
| 652 | |
| 653 | /** |
| 654 | * Control the animation to run when a window's state changes. Return a |
| 655 | * non-0 number to force the animation to a specific resource ID, or 0 |
| 656 | * to use the default animation. |
| 657 | * |
| 658 | * @param win The window that is changing. |
| 659 | * @param transit What is happening to the window: {@link #TRANSIT_ENTER}, |
| 660 | * {@link #TRANSIT_EXIT}, {@link #TRANSIT_SHOW}, or |
| 661 | * {@link #TRANSIT_HIDE}. |
| 662 | * |
| 663 | * @return Resource ID of the actual animation to use, or 0 for none. |
| 664 | */ |
| 665 | public int selectAnimationLw(WindowState win, int transit); |
| 666 | |
| 667 | /** |
Dianne Hackborn | 3b3e145 | 2009-09-24 19:22:12 -0700 | [diff] [blame] | 668 | * Create and return an animation to re-display a force hidden window. |
| 669 | */ |
| 670 | public Animation createForceHideEnterAnimation(); |
| 671 | |
| 672 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 673 | * 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] | 674 | * |
| 675 | * <p>There are some actions that need to be handled here because they |
| 676 | * affect the power state of the device, for example, the power keys. |
| 677 | * Generally, it's best to keep as little as possible in the queue thread |
| 678 | * because it's the most fragile. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 679 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 680 | * @param policyFlags The policy flags associated with the key. |
| 681 | * @param isScreenOn True if the screen is already on |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 682 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 683 | * @return The bitwise or of the {@link #ACTION_PASS_TO_USER}, |
| 684 | * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags. |
| 685 | */ |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 686 | public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags, boolean isScreenOn); |
Jeff Brown | 56194eb | 2011-03-02 19:23:13 -0800 | [diff] [blame] | 687 | |
| 688 | /** |
| 689 | * Called from the input reader thread before a motion is enqueued when the screen is off. |
| 690 | * |
| 691 | * <p>There are some actions that need to be handled here because they |
| 692 | * affect the power state of the device, for example, waking on motions. |
| 693 | * Generally, it's best to keep as little as possible in the queue thread |
| 694 | * because it's the most fragile. |
| 695 | * @param policyFlags The policy flags associated with the motion. |
| 696 | * |
| 697 | * @return The bitwise or of the {@link #ACTION_PASS_TO_USER}, |
| 698 | * {@link #ACTION_POKE_USER_ACTIVITY} and {@link #ACTION_GO_TO_SLEEP} flags. |
| 699 | */ |
| 700 | public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags); |
| 701 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 702 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 703 | * 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] | 704 | * |
| 705 | * <p>Allows you to define |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 706 | * behavior for keys that can not be overridden by applications. |
| 707 | * 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] | 708 | * |
| 709 | * @param win The window that currently has focus. This is where the key |
| 710 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 711 | * @param event The key event. |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 712 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 713 | * @return 0 if the key should be dispatched immediately, -1 if the key should |
| 714 | * not be dispatched ever, or a positive value indicating the number of |
| 715 | * milliseconds by which the key dispatch should be delayed before trying |
| 716 | * again. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 717 | */ |
Jeff Brown | d5bb82d | 2011-10-12 13:57:59 -0700 | [diff] [blame] | 718 | public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 719 | |
| 720 | /** |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 721 | * Called from the input dispatcher thread when an application did not handle |
| 722 | * a key that was dispatched to it. |
| 723 | * |
| 724 | * <p>Allows you to define default global behavior for keys that were not handled |
| 725 | * by applications. This method is called from the input thread, with no locks held. |
| 726 | * |
| 727 | * @param win The window that currently has focus. This is where the key |
| 728 | * event will normally go. |
Jeff Brown | 1f24510 | 2010-11-18 20:53:46 -0800 | [diff] [blame] | 729 | * @param event The key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 730 | * @param policyFlags The policy flags associated with the key. |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 731 | * @return Returns an alternate key event to redispatch as a fallback, or null to give up. |
| 732 | * The caller is responsible for recycling the key event. |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 733 | */ |
Jeff Brown | 49ed71d | 2010-12-06 17:13:33 -0800 | [diff] [blame] | 734 | public KeyEvent dispatchUnhandledKey(WindowState win, KeyEvent event, int policyFlags); |
Jeff Brown | 3915bb8 | 2010-11-05 15:02:16 -0700 | [diff] [blame] | 735 | |
| 736 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 737 | * Called when layout of the windows is about to start. |
| 738 | * |
| 739 | * @param displayWidth The current full width of the screen. |
| 740 | * @param displayHeight The current full height of the screen. |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 741 | * @param displayRotation The current rotation being applied to the base |
| 742 | * window. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 743 | */ |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 744 | public void beginLayoutLw(int displayWidth, int displayHeight, int displayRotation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 745 | |
| 746 | /** |
| 747 | * Called for each window attached to the window manager as layout is |
| 748 | * proceeding. The implementation of this function must take care of |
| 749 | * setting the window's frame, either here or in finishLayout(). |
| 750 | * |
| 751 | * @param win The window being positioned. |
| 752 | * @param attrs The LayoutParams of the window. |
| 753 | * @param attached For sub-windows, the window it is attached to; this |
| 754 | * window will already have had layoutWindow() called on it |
| 755 | * so you can use its Rect. Otherwise null. |
| 756 | */ |
| 757 | public void layoutWindowLw(WindowState win, |
| 758 | WindowManager.LayoutParams attrs, WindowState attached); |
| 759 | |
| 760 | |
| 761 | /** |
| 762 | * Return the insets for the areas covered by system windows. These values |
| 763 | * are computed on the most recent layout, so they are not guaranteed to |
| 764 | * be correct. |
| 765 | * |
| 766 | * @param attrs The LayoutParams of the window. |
| 767 | * @param contentInset The areas covered by system windows, expressed as positive insets |
| 768 | * |
| 769 | */ |
| 770 | public void getContentInsetHintLw(WindowManager.LayoutParams attrs, Rect contentInset); |
| 771 | |
| 772 | /** |
| 773 | * Called when layout of the windows is finished. After this function has |
| 774 | * returned, all windows given to layoutWindow() <em>must</em> have had a |
| 775 | * frame assigned. |
| 776 | */ |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 777 | public void finishLayoutLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 778 | |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 779 | /** Layout state may have changed (so another layout will be performed) */ |
| 780 | static final int FINISH_LAYOUT_REDO_LAYOUT = 0x0001; |
| 781 | /** Configuration state may have changed */ |
| 782 | static final int FINISH_LAYOUT_REDO_CONFIG = 0x0002; |
| 783 | /** Wallpaper may need to move */ |
| 784 | static final int FINISH_LAYOUT_REDO_WALLPAPER = 0x0004; |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 785 | /** Need to recompute animations */ |
| 786 | static final int FINISH_LAYOUT_REDO_ANIM = 0x0008; |
Dianne Hackborn | 9bfb707 | 2009-09-22 11:37:40 -0700 | [diff] [blame] | 787 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | /** |
| 789 | * Called when animation of the windows is about to start. |
| 790 | * |
| 791 | * @param displayWidth The current full width of the screen. |
| 792 | * @param displayHeight The current full height of the screen. |
| 793 | */ |
| 794 | public void beginAnimationLw(int displayWidth, int displayHeight); |
| 795 | |
| 796 | /** |
| 797 | * Called each time a window is animating. |
| 798 | * |
| 799 | * @param win The window being positioned. |
| 800 | * @param attrs The LayoutParams of the window. |
| 801 | */ |
| 802 | public void animatingWindowLw(WindowState win, |
| 803 | WindowManager.LayoutParams attrs); |
| 804 | |
| 805 | /** |
| 806 | * Called when animation of the windows is finished. If in this function you do |
| 807 | * something that may have modified the animation state of another window, |
| 808 | * be sure to return true in order to perform another animation frame. |
| 809 | * |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 810 | * @return Return any bit set of {@link #FINISH_LAYOUT_REDO_LAYOUT}, |
| 811 | * {@link #FINISH_LAYOUT_REDO_CONFIG}, {@link #FINISH_LAYOUT_REDO_WALLPAPER}, |
| 812 | * or {@link #FINISH_LAYOUT_REDO_ANIM}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 813 | */ |
Dianne Hackborn | b8b11a0 | 2010-03-10 15:53:11 -0800 | [diff] [blame] | 814 | public int finishAnimationLw(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 815 | |
| 816 | /** |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 817 | * Return true if it is okay to perform animations for an app transition |
| 818 | * that is about to occur. You may return false for this if, for example, |
| 819 | * the lock screen is currently displayed so the switch should happen |
| 820 | * immediately. |
| 821 | */ |
| 822 | public boolean allowAppAnimationsLw(); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 823 | |
| 824 | |
| 825 | /** |
| 826 | * A new window has been focused. |
| 827 | */ |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 828 | public int focusChangedLw(WindowState lastFocus, WindowState newFocus); |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 829 | |
| 830 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 831 | * Called after the screen turns off. |
| 832 | * |
| 833 | * @param why {@link #OFF_BECAUSE_OF_USER} or |
| 834 | * {@link #OFF_BECAUSE_OF_TIMEOUT}. |
| 835 | */ |
| 836 | public void screenTurnedOff(int why); |
| 837 | |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 838 | public interface ScreenOnListener { |
| 839 | void onScreenOn(); |
Craig Mautner | 61ac6bb | 2012-02-02 17:29:33 -0800 | [diff] [blame] | 840 | } |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 841 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 842 | /** |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 843 | * Called when the power manager would like to turn the screen on. |
| 844 | * Must call back on the listener to tell it when the higher-level system |
| 845 | * is ready for the screen to go on (i.e. the lock screen is shown). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 846 | */ |
Dianne Hackborn | 38e29a6 | 2011-09-18 14:43:08 -0700 | [diff] [blame] | 847 | public void screenTurningOn(ScreenOnListener screenOnListener); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 848 | |
| 849 | /** |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 850 | * Return whether the screen is about to turn on or is currently on. |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 851 | */ |
Dianne Hackborn | bc1aa7b | 2011-09-20 11:20:31 -0700 | [diff] [blame] | 852 | public boolean isScreenOnEarly(); |
| 853 | |
| 854 | /** |
| 855 | * Return whether the screen is fully turned on. |
| 856 | */ |
| 857 | public boolean isScreenOnFully(); |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 858 | |
Dianne Hackborn | de2606d | 2009-12-18 16:53:55 -0800 | [diff] [blame] | 859 | /** |
Jeff Brown | 00fa7bd | 2010-07-02 15:37:36 -0700 | [diff] [blame] | 860 | * Tell the policy that the lid switch has changed state. |
| 861 | * @param whenNanos The time when the change occurred in uptime nanoseconds. |
| 862 | * @param lidOpen True if the lid is now open. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 863 | */ |
Jeff Brown | 46b9ac0 | 2010-04-22 18:58:52 -0700 | [diff] [blame] | 864 | public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen); |
| 865 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 866 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 867 | * Tell the policy if anyone is requesting that keyguard not come on. |
| 868 | * |
| 869 | * @param enabled Whether keyguard can be on or not. does not actually |
| 870 | * turn it on, unless it was previously disabled with this function. |
| 871 | * |
| 872 | * @see android.app.KeyguardManager.KeyguardLock#disableKeyguard() |
| 873 | * @see android.app.KeyguardManager.KeyguardLock#reenableKeyguard() |
| 874 | */ |
| 875 | public void enableKeyguard(boolean enabled); |
| 876 | |
| 877 | /** |
| 878 | * Callback used by {@link WindowManagerPolicy#exitKeyguardSecurely} |
| 879 | */ |
| 880 | interface OnKeyguardExitResult { |
| 881 | void onKeyguardExitResult(boolean success); |
| 882 | } |
| 883 | |
| 884 | /** |
| 885 | * Tell the policy if anyone is requesting the keyguard to exit securely |
| 886 | * (this would be called after the keyguard was disabled) |
| 887 | * @param callback Callback to send the result back. |
| 888 | * @see android.app.KeyguardManager#exitKeyguardSecurely(android.app.KeyguardManager.OnKeyguardExitResult) |
| 889 | */ |
| 890 | void exitKeyguardSecurely(OnKeyguardExitResult callback); |
| 891 | |
| 892 | /** |
Mike Lockwood | 520d8bc | 2011-02-18 13:23:13 -0500 | [diff] [blame] | 893 | * isKeyguardLocked |
| 894 | * |
| 895 | * Return whether the keyguard is currently locked. |
| 896 | * |
| 897 | * @return true if in keyguard is locked. |
| 898 | */ |
| 899 | public boolean isKeyguardLocked(); |
| 900 | |
| 901 | /** |
| 902 | * isKeyguardSecure |
| 903 | * |
| 904 | * Return whether the keyguard requires a password to unlock. |
| 905 | * |
| 906 | * @return true if in keyguard is secure. |
| 907 | */ |
| 908 | public boolean isKeyguardSecure(); |
| 909 | |
| 910 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 911 | * inKeyguardRestrictedKeyInputMode |
| 912 | * |
| 913 | * if keyguard screen is showing or in restricted key input mode (i.e. in |
| 914 | * keyguard password emergency screen). When in such mode, certain keys, |
| 915 | * such as the Home key and the right soft keys, don't work. |
| 916 | * |
| 917 | * @return true if in keyguard restricted input mode. |
| 918 | */ |
| 919 | public boolean inKeyguardRestrictedKeyInputMode(); |
| 920 | |
| 921 | /** |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 922 | * Ask the policy to dismiss the keyguard, if it is currently shown. |
| 923 | */ |
| 924 | public void dismissKeyguardLw(); |
| 925 | |
| 926 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 927 | * Given an orientation constant, returns the appropriate surface rotation, |
| 928 | * taking into account sensors, docking mode, rotation lock, and other factors. |
| 929 | * |
| 930 | * @param orientation An orientation constant, such as |
| 931 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 932 | * @param lastRotation The most recently used rotation. |
| 933 | * @return The surface rotation to use. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 934 | */ |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 935 | public int rotationForOrientationLw(int orientation, int lastRotation); |
| 936 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 937 | /** |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 938 | * Given an orientation constant and a rotation, returns true if the rotation |
| 939 | * has compatible metrics to the requested orientation. For example, if |
| 940 | * the application requested landscape and got seascape, then the rotation |
| 941 | * has compatible metrics; if the application requested portrait and got landscape, |
| 942 | * then the rotation has incompatible metrics; if the application did not specify |
| 943 | * a preference, then anything goes. |
| 944 | * |
| 945 | * @param orientation An orientation constant, such as |
| 946 | * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_LANDSCAPE}. |
| 947 | * @param rotation The rotation to check. |
| 948 | * @return True if the rotation is compatible with the requested orientation. |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 949 | */ |
Jeff Brown | 01a98dd | 2011-09-20 15:08:29 -0700 | [diff] [blame] | 950 | public boolean rotationHasCompatibleMetricsLw(int orientation, int rotation); |
Dianne Hackborn | dacea8c | 2011-04-21 17:26:39 -0700 | [diff] [blame] | 951 | |
| 952 | /** |
Jeff Brown | c0347aa | 2011-09-23 17:26:09 -0700 | [diff] [blame] | 953 | * Called by the window manager when the rotation changes. |
| 954 | * |
| 955 | * @param rotation The new rotation. |
| 956 | */ |
| 957 | public void setRotationLw(int rotation); |
| 958 | |
| 959 | /** |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 960 | * 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] | 961 | * the system should go into safe mode. |
| 962 | */ |
Jeff Brown | ac14351 | 2012-04-05 18:57:33 -0700 | [diff] [blame] | 963 | public void setSafeMode(boolean safeMode); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 964 | |
| 965 | /** |
| 966 | * Called when the system is mostly done booting. |
| 967 | */ |
| 968 | public void systemReady(); |
| 969 | |
| 970 | /** |
Dianne Hackborn | ba24e4d | 2011-09-01 11:17:06 -0700 | [diff] [blame] | 971 | * Called when the system is done booting to the point where the |
| 972 | * user can start interacting with it. |
| 973 | */ |
| 974 | public void systemBooted(); |
| 975 | |
| 976 | /** |
Dianne Hackborn | 661cd52 | 2011-08-22 00:26:20 -0700 | [diff] [blame] | 977 | * Show boot time message to the user. |
| 978 | */ |
| 979 | public void showBootMessage(final CharSequence msg, final boolean always); |
| 980 | |
| 981 | /** |
| 982 | * Hide the UI for showing boot messages, never to be displayed again. |
| 983 | */ |
| 984 | public void hideBootMessages(); |
| 985 | |
| 986 | /** |
Mike Lockwood | ef73162 | 2010-01-27 17:51:34 -0500 | [diff] [blame] | 987 | * Called when userActivity is signalled in the power manager. |
| 988 | * This is safe to call from any thread, with any window manager locks held or not. |
| 989 | */ |
| 990 | public void userActivity(); |
| 991 | |
| 992 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 993 | * Called when we have finished booting and can now display the home |
| 994 | * screen to the user. This wilWl happen after systemReady(), and at |
| 995 | * this point the display is active. |
| 996 | */ |
| 997 | public void enableScreenAfterBoot(); |
| 998 | |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 999 | public void setCurrentOrientationLw(int newOrientation); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1000 | |
| 1001 | /** |
| 1002 | * Call from application to perform haptic feedback on its window. |
| 1003 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 1004 | public boolean performHapticFeedbackLw(WindowState win, int effectId, boolean always); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1005 | |
| 1006 | /** |
Daniel Sandler | 0601eb7 | 2011-04-13 01:01:32 -0400 | [diff] [blame] | 1007 | * Called when we have started keeping the screen on because a window |
| 1008 | * requesting this has become visible. |
| 1009 | */ |
| 1010 | public void screenOnStartedLw(); |
| 1011 | |
| 1012 | /** |
| 1013 | * 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] | 1014 | * requesting this is no longer visible. |
| 1015 | */ |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 1016 | public void screenOnStoppedLw(); |
Mike Lockwood | 3d0ea72 | 2009-10-21 22:58:29 -0400 | [diff] [blame] | 1017 | |
| 1018 | /** |
| 1019 | * Return false to disable key repeat events from being generated. |
| 1020 | */ |
| 1021 | public boolean allowKeyRepeat(); |
Daniel Sandler | b73617d | 2010-08-17 00:41:00 -0400 | [diff] [blame] | 1022 | |
| 1023 | /** |
| 1024 | * Inform the policy that the user has chosen a preferred orientation ("rotation lock"). |
| 1025 | * |
| 1026 | * @param mode One of {@link WindowManagerPolicy#USER_ROTATION_LOCKED} or |
| 1027 | * {@link * WindowManagerPolicy#USER_ROTATION_FREE}. |
| 1028 | * @param rotation One of {@link Surface#ROTATION_0}, {@link Surface#ROTATION_90}, |
| 1029 | * {@link Surface#ROTATION_180}, {@link Surface#ROTATION_270}. |
| 1030 | */ |
| 1031 | public void setUserRotationMode(int mode, int rotation); |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1032 | |
| 1033 | /** |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 1034 | * Called when a new system UI visibility is being reported, allowing |
| 1035 | * the policy to adjust what is actually reported. |
| 1036 | * @param visibility The raw visiblity reported by the status bar. |
| 1037 | * @return The new desired visibility. |
| 1038 | */ |
| 1039 | public int adjustSystemUiVisibilityLw(int visibility); |
| 1040 | |
| 1041 | /** |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 1042 | * Specifies whether there is an on-screen navigation bar separate from the status bar. |
| 1043 | */ |
| 1044 | public boolean hasNavigationBar(); |
| 1045 | |
| 1046 | /** |
Jim Miller | 93c518e | 2012-01-17 15:55:31 -0800 | [diff] [blame] | 1047 | * Lock the device now. |
| 1048 | */ |
| 1049 | public void lockNow(); |
| 1050 | |
| 1051 | /** |
Dianne Hackborn | f99f9c5 | 2011-01-12 15:49:25 -0800 | [diff] [blame] | 1052 | * Print the WindowManagerPolicy's state into the given stream. |
| 1053 | * |
| 1054 | * @param prefix Text to print at the front of each line. |
| 1055 | * @param fd The raw file descriptor that the dump is being sent to. |
| 1056 | * @param writer The PrintWriter to which you should dump your state. This will be |
| 1057 | * closed for you after you return. |
| 1058 | * @param args additional arguments to the dump request. |
| 1059 | */ |
| 1060 | public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1061 | } |