WindowManager.java revision f21c9b0f52d5a1de5050f90f0818467fad014eaa
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 17package android.view; 18 19import android.content.pm.ActivityInfo; 20import android.graphics.PixelFormat; 21import android.os.IBinder; 22import android.os.Parcel; 23import android.os.Parcelable; 24import android.text.TextUtils; 25import android.util.Log; 26 27 28/** 29 * The interface that apps use to talk to the window manager. 30 * <p> 31 * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these. 32 * 33 * @see android.content.Context#getSystemService 34 * @see android.content.Context#WINDOW_SERVICE 35 */ 36public interface WindowManager extends ViewManager { 37 /** 38 * Exception that is thrown when trying to add view whose 39 * {@link WindowManager.LayoutParams} {@link WindowManager.LayoutParams#token} 40 * is invalid. 41 */ 42 public static class BadTokenException extends RuntimeException { 43 public BadTokenException() { 44 } 45 46 public BadTokenException(String name) { 47 super(name); 48 } 49 } 50 51 /** 52 * Use this method to get the default Display object. 53 * 54 * @return default Display object 55 */ 56 public Display getDefaultDisplay(); 57 58 /** 59 * Special variation of {@link #removeView} that immediately invokes 60 * the given view hierarchy's {@link View#onDetachedFromWindow() 61 * View.onDetachedFromWindow()} methods before returning. This is not 62 * for normal applications; using it correctly requires great care. 63 * 64 * @param view The view to be removed. 65 */ 66 public void removeViewImmediate(View view); 67 68 /** 69 * Return true if this window manager is configured to request hardware 70 * accelerated windows. This does <em>not</em> guarantee that they will 71 * actually be accelerated, since that depends on the device supporting them. 72 * @hide 73 */ 74 public boolean isHardwareAccelerated(); 75 76 public static class LayoutParams extends ViewGroup.LayoutParams 77 implements Parcelable { 78 /** 79 * X position for this window. With the default gravity it is ignored. 80 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or 81 * {@link Gravity#END} it provides an offset from the given edge. 82 */ 83 @ViewDebug.ExportedProperty 84 public int x; 85 86 /** 87 * Y position for this window. With the default gravity it is ignored. 88 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides 89 * an offset from the given edge. 90 */ 91 @ViewDebug.ExportedProperty 92 public int y; 93 94 /** 95 * Indicates how much of the extra space will be allocated horizontally 96 * to the view associated with these LayoutParams. Specify 0 if the view 97 * should not be stretched. Otherwise the extra pixels will be pro-rated 98 * among all views whose weight is greater than 0. 99 */ 100 @ViewDebug.ExportedProperty 101 public float horizontalWeight; 102 103 /** 104 * Indicates how much of the extra space will be allocated vertically 105 * to the view associated with these LayoutParams. Specify 0 if the view 106 * should not be stretched. Otherwise the extra pixels will be pro-rated 107 * among all views whose weight is greater than 0. 108 */ 109 @ViewDebug.ExportedProperty 110 public float verticalWeight; 111 112 /** 113 * The general type of window. There are three main classes of 114 * window types: 115 * <ul> 116 * <li> <strong>Application windows</strong> (ranging from 117 * {@link #FIRST_APPLICATION_WINDOW} to 118 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application 119 * windows. For these types of windows, the {@link #token} must be 120 * set to the token of the activity they are a part of (this will 121 * normally be done for you if {@link #token} is null). 122 * <li> <strong>Sub-windows</strong> (ranging from 123 * {@link #FIRST_SUB_WINDOW} to 124 * {@link #LAST_SUB_WINDOW}) are associated with another top-level 125 * window. For these types of windows, the {@link #token} must be 126 * the token of the window it is attached to. 127 * <li> <strong>System windows</strong> (ranging from 128 * {@link #FIRST_SYSTEM_WINDOW} to 129 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for 130 * use by the system for specific purposes. They should not normally 131 * be used by applications, and a special permission is required 132 * to use them. 133 * </ul> 134 * 135 * @see #TYPE_BASE_APPLICATION 136 * @see #TYPE_APPLICATION 137 * @see #TYPE_APPLICATION_STARTING 138 * @see #TYPE_APPLICATION_PANEL 139 * @see #TYPE_APPLICATION_MEDIA 140 * @see #TYPE_APPLICATION_SUB_PANEL 141 * @see #TYPE_APPLICATION_ATTACHED_DIALOG 142 * @see #TYPE_STATUS_BAR 143 * @see #TYPE_SEARCH_BAR 144 * @see #TYPE_PHONE 145 * @see #TYPE_SYSTEM_ALERT 146 * @see #TYPE_KEYGUARD 147 * @see #TYPE_TOAST 148 * @see #TYPE_SYSTEM_OVERLAY 149 * @see #TYPE_PRIORITY_PHONE 150 * @see #TYPE_STATUS_BAR_PANEL 151 * @see #TYPE_SYSTEM_DIALOG 152 * @see #TYPE_KEYGUARD_DIALOG 153 * @see #TYPE_SYSTEM_ERROR 154 * @see #TYPE_INPUT_METHOD 155 * @see #TYPE_INPUT_METHOD_DIALOG 156 */ 157 @ViewDebug.ExportedProperty(mapping = { 158 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"), 159 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"), 160 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"), 161 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"), 162 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"), 163 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"), 164 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"), 165 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"), 166 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"), 167 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"), 168 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"), 169 @ViewDebug.IntToString(from = TYPE_KEYGUARD, to = "TYPE_KEYGUARD"), 170 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"), 171 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"), 172 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"), 173 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"), 174 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"), 175 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"), 176 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"), 177 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"), 178 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"), 179 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"), 180 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"), 181 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS") 182 }) 183 public int type; 184 185 /** 186 * Start of window types that represent normal application windows. 187 */ 188 public static final int FIRST_APPLICATION_WINDOW = 1; 189 190 /** 191 * Window type: an application window that serves as the "base" window 192 * of the overall application; all other application windows will 193 * appear on top of it. 194 */ 195 public static final int TYPE_BASE_APPLICATION = 1; 196 197 /** 198 * Window type: a normal application window. The {@link #token} must be 199 * an Activity token identifying who the window belongs to. 200 */ 201 public static final int TYPE_APPLICATION = 2; 202 203 /** 204 * Window type: special application window that is displayed while the 205 * application is starting. Not for use by applications themselves; 206 * this is used by the system to display something until the 207 * application can show its own windows. 208 */ 209 public static final int TYPE_APPLICATION_STARTING = 3; 210 211 /** 212 * End of types of application windows. 213 */ 214 public static final int LAST_APPLICATION_WINDOW = 99; 215 216 /** 217 * Start of types of sub-windows. The {@link #token} of these windows 218 * must be set to the window they are attached to. These types of 219 * windows are kept next to their attached window in Z-order, and their 220 * coordinate space is relative to their attached window. 221 */ 222 public static final int FIRST_SUB_WINDOW = 1000; 223 224 /** 225 * Window type: a panel on top of an application window. These windows 226 * appear on top of their attached window. 227 */ 228 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; 229 230 /** 231 * Window type: window for showing media (e.g. video). These windows 232 * are displayed behind their attached window. 233 */ 234 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW+1; 235 236 /** 237 * Window type: a sub-panel on top of an application window. These 238 * windows are displayed on top their attached window and any 239 * {@link #TYPE_APPLICATION_PANEL} panels. 240 */ 241 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW+2; 242 243 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout 244 * of the window happens as that of a top-level window, <em>not</em> 245 * as a child of its container. 246 */ 247 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW+3; 248 249 /** 250 * Window type: window for showing overlays on top of media windows. 251 * These windows are displayed between TYPE_APPLICATION_MEDIA and the 252 * application window. They should be translucent to be useful. This 253 * is a big ugly hack so: 254 * @hide 255 */ 256 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW+4; 257 258 /** 259 * End of types of sub-windows. 260 */ 261 public static final int LAST_SUB_WINDOW = 1999; 262 263 /** 264 * Start of system-specific window types. These are not normally 265 * created by applications. 266 */ 267 public static final int FIRST_SYSTEM_WINDOW = 2000; 268 269 /** 270 * Window type: the status bar. There can be only one status bar 271 * window; it is placed at the top of the screen, and all other 272 * windows are shifted down so they are below it. 273 */ 274 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; 275 276 /** 277 * Window type: the search bar. There can be only one search bar 278 * window; it is placed at the top of the screen. 279 */ 280 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; 281 282 /** 283 * Window type: phone. These are non-application windows providing 284 * user interaction with the phone (in particular incoming calls). 285 * These windows are normally placed above all applications, but behind 286 * the status bar. 287 */ 288 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; 289 290 /** 291 * Window type: system window, such as low power alert. These windows 292 * are always on top of application windows. 293 */ 294 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; 295 296 /** 297 * Window type: keyguard window. 298 */ 299 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; 300 301 /** 302 * Window type: transient notifications. 303 */ 304 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; 305 306 /** 307 * Window type: system overlay windows, which need to be displayed 308 * on top of everything else. These windows must not take input 309 * focus, or they will interfere with the keyguard. 310 */ 311 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; 312 313 /** 314 * Window type: priority phone UI, which needs to be displayed even if 315 * the keyguard is active. These windows must not take input 316 * focus, or they will interfere with the keyguard. 317 */ 318 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; 319 320 /** 321 * Window type: panel that slides out from the status bar 322 */ 323 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; 324 325 /** 326 * Window type: dialogs that the keyguard shows 327 */ 328 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; 329 330 /** 331 * Window type: internal system error windows, appear on top of 332 * everything they can. 333 */ 334 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; 335 336 /** 337 * Window type: internal input methods windows, which appear above 338 * the normal UI. Application windows may be resized or panned to keep 339 * the input focus visible while this window is displayed. 340 */ 341 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; 342 343 /** 344 * Window type: internal input methods dialog windows, which appear above 345 * the current input method window. 346 */ 347 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; 348 349 /** 350 * Window type: wallpaper window, placed behind any window that wants 351 * to sit on top of the wallpaper. 352 */ 353 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; 354 355 /** 356 * Window type: panel that slides out from over the status bar 357 */ 358 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; 359 360 /** 361 * Window type: secure system overlay windows, which need to be displayed 362 * on top of everything else. These windows must not take input 363 * focus, or they will interfere with the keyguard. 364 * 365 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the 366 * system itself is allowed to create these overlays. Applications cannot 367 * obtain permission to create secure system overlays. 368 * @hide 369 */ 370 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; 371 372 /** 373 * Window type: the drag-and-drop pseudowindow. There is only one 374 * drag layer (at most), and it is placed on top of all other windows. 375 * @hide 376 */ 377 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; 378 379 /** 380 * Window type: panel that slides out from under the status bar 381 * @hide 382 */ 383 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; 384 385 /** 386 * Window type: (mouse) pointer 387 * @hide 388 */ 389 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; 390 391 /** 392 * Window type: Navigation bar (when distinct from status bar) 393 * @hide 394 */ 395 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; 396 397 /** 398 * Window type: The volume level overlay/dialog shown when the user 399 * changes the system volume. 400 * @hide 401 */ 402 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; 403 404 /** 405 * Window type: The boot progress dialog, goes on top of everything 406 * in the world. 407 * @hide 408 */ 409 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; 410 411 /** 412 * End of types of system windows. 413 */ 414 public static final int LAST_SYSTEM_WINDOW = 2999; 415 416 /** @deprecated this is ignored, this value is set automatically when needed. */ 417 @Deprecated 418 public static final int MEMORY_TYPE_NORMAL = 0; 419 /** @deprecated this is ignored, this value is set automatically when needed. */ 420 @Deprecated 421 public static final int MEMORY_TYPE_HARDWARE = 1; 422 /** @deprecated this is ignored, this value is set automatically when needed. */ 423 @Deprecated 424 public static final int MEMORY_TYPE_GPU = 2; 425 /** @deprecated this is ignored, this value is set automatically when needed. */ 426 @Deprecated 427 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 428 429 /** 430 * @deprecated this is ignored 431 */ 432 @Deprecated 433 public int memoryType; 434 435 /** Window flag: as long as this window is visible to the user, allow 436 * the lock screen to activate while the screen is on. 437 * This can be used independently, or in combination with 438 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 439 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 440 441 /** Window flag: everything behind this window will be dimmed. 442 * Use {@link #dimAmount} to control the amount of dim. */ 443 public static final int FLAG_DIM_BEHIND = 0x00000002; 444 445 /** Window flag: blur everything behind this window. 446 * @deprecated Blurring is no longer supported. */ 447 @Deprecated 448 public static final int FLAG_BLUR_BEHIND = 0x00000004; 449 450 /** Window flag: this window won't ever get key input focus, so the 451 * user can not send key or other button events to it. Those will 452 * instead go to whatever focusable window is behind it. This flag 453 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 454 * is explicitly set. 455 * 456 * <p>Setting this flag also implies that the window will not need to 457 * interact with 458 * a soft input method, so it will be Z-ordered and positioned 459 * independently of any active input method (typically this means it 460 * gets Z-ordered on top of the input method, so it can use the full 461 * screen for its content and cover the input method if needed. You 462 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 463 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 464 465 /** Window flag: this window can never receive touch events. */ 466 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 467 468 /** Window flag: Even when this window is focusable (its 469 * {@link #FLAG_NOT_FOCUSABLE is not set), allow any pointer events 470 * outside of the window to be sent to the windows behind it. Otherwise 471 * it will consume all pointer events itself, regardless of whether they 472 * are inside of the window. */ 473 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 474 475 /** Window flag: When set, if the device is asleep when the touch 476 * screen is pressed, you will receive this first touch event. Usually 477 * the first touch event is consumed by the system since the user can 478 * not see what they are pressing on. 479 */ 480 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 481 482 /** Window flag: as long as this window is visible to the user, keep 483 * the device's screen turned on and bright. */ 484 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 485 486 /** Window flag: place the window within the entire screen, ignoring 487 * decorations around the border (a.k.a. the status bar). The 488 * window must correctly position its contents to take the screen 489 * decoration into account. This flag is normally set for you 490 * by Window as described in {@link Window#setFlags}. */ 491 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 492 493 /** Window flag: allow window to extend outside of the screen. */ 494 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 495 496 /** Window flag: Hide all screen decorations (e.g. status bar) while 497 * this window is displayed. This allows the window to use the entire 498 * display space for itself -- the status bar will be hidden when 499 * an app window with this flag set is on the top layer. */ 500 public static final int FLAG_FULLSCREEN = 0x00000400; 501 502 /** Window flag: Override {@link #FLAG_FULLSCREEN and force the 503 * screen decorations (such as status bar) to be shown. */ 504 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 505 506 /** Window flag: turn on dithering when compositing this window to 507 * the screen. */ 508 public static final int FLAG_DITHER = 0x00001000; 509 510 /** Window flag: don't allow screen shots while this window is 511 * displayed. Maps to Surface.SECURE. */ 512 public static final int FLAG_SECURE = 0x00002000; 513 514 /** Window flag: a special mode where the layout parameters are used 515 * to perform scaling of the surface when it is composited to the 516 * screen. */ 517 public static final int FLAG_SCALED = 0x00004000; 518 519 /** Window flag: intended for windows that will often be used when the user is 520 * holding the screen against their face, it will aggressively filter the event 521 * stream to prevent unintended presses in this situation that may not be 522 * desired for a particular window, when such an event stream is detected, the 523 * application will receive a CANCEL motion event to indicate this so applications 524 * can handle this accordingly by taking no action on the event 525 * until the finger is released. */ 526 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 527 528 /** Window flag: a special option only for use in combination with 529 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 530 * screen your window may appear on top of or behind screen decorations 531 * such as the status bar. By also including this flag, the window 532 * manager will report the inset rectangle needed to ensure your 533 * content is not covered by screen decorations. This flag is normally 534 * set for you by Window as described in {@link Window#setFlags}.*/ 535 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 536 537 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with 538 * respect to how this window interacts with the current method. That 539 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the 540 * window will behave as if it needs to interact with the input method 541 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is 542 * not set and this flag is set, then the window will behave as if it 543 * doesn't need to interact with the input method and can be placed 544 * to use more space and cover the input method. 545 */ 546 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 547 548 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 549 * can set this flag to receive a single special MotionEvent with 550 * the action 551 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 552 * touches that occur outside of your window. Note that you will not 553 * receive the full down/move/up gesture, only the location of the 554 * first down as an ACTION_OUTSIDE. 555 */ 556 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 557 558 /** Window flag: special flag to let windows be shown when the screen 559 * is locked. This will let application windows take precedence over 560 * key guard or any other lock screens. Can be used with 561 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 562 * directly before showing the key guard window. Can be used with 563 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 564 * non-secure keyguards. This flag only applies to the top-most 565 * full-screen window. 566 */ 567 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 568 569 /** Window flag: ask that the system wallpaper be shown behind 570 * your window. The window surface must be translucent to be able 571 * to actually see the wallpaper behind it; this flag just ensures 572 * that the wallpaper surface will be there if this window actually 573 * has translucent regions. 574 */ 575 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 576 577 /** Window flag: when set as a window is being added or made 578 * visible, once the window has been shown then the system will 579 * poke the power manager's user activity (as if the user had woken 580 * up the device) to turn the screen on. */ 581 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 582 583 /** Window flag: when set the window will cause the keyguard to 584 * be dismissed, only if it is not a secure lock keyguard. Because such 585 * a keyguard is not needed for security, it will never re-appear if 586 * the user navigates to another window (in contrast to 587 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily 588 * hide both secure and non-secure keyguards but ensure they reappear 589 * when the user moves to another UI that doesn't hide them). 590 * If the keyguard is currently active and is secure (requires an 591 * unlock pattern) than the user will still need to confirm it before 592 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has 593 * also been set. 594 */ 595 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 596 597 /** Window flag: when set the window will accept for touch events 598 * outside of its bounds to be sent to other windows that also 599 * support split touch. When this flag is not set, the first pointer 600 * that goes down determines the window to which all subsequent touches 601 * go until all pointers go up. When this flag is set, each pointer 602 * (not necessarily the first) that goes down determines the window 603 * to which all subsequent touches of that pointer will go until that 604 * pointer goes up thereby enabling touches with multiple pointers 605 * to be split across multiple windows. 606 */ 607 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 608 609 /** 610 * <p>Indicates whether this window should be hardware accelerated. 611 * Requesting hardware acceleration does not guarantee it will happen.</p> 612 * 613 * <p>This flag can be controlled programmatically <em>only</em> to enable 614 * hardware acceleration. To enable hardware acceleration for a given 615 * window programmatically, do the following:</p> 616 * 617 * <pre> 618 * Window w = activity.getWindow(); // in Activity's onCreate() for instance 619 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 620 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); 621 * </pre> 622 * 623 * <p>It is important to remember that this flag <strong>must</strong> 624 * be set before setting the content view of your activity or dialog.</p> 625 * 626 * <p>This flag cannot be used to disable hardware acceleration after it 627 * was enabled in your manifest using 628 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively 629 * and programmatically disable hardware acceleration (for automated testing 630 * for instance), make sure it is turned off in your manifest and enable it 631 * on your activity or dialog when you need it instead, using the method 632 * described above.</p> 633 * 634 * <p>This flag is automatically set by the system if the 635 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 636 * XML attribute is set to true on an activity or on the application.</p> 637 */ 638 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; 639 640 // ----- HIDDEN FLAGS. 641 // These start at the high bit and go down. 642 643 /** Window flag: Enable touches to slide out of a window into neighboring 644 * windows in mid-gesture instead of being captured for the duration of 645 * the gesture. 646 * 647 * This flag changes the behavior of touch focus for this window only. 648 * Touches can slide out of the window but they cannot necessarily slide 649 * back in (unless the other window with touch focus permits it). 650 * 651 * {@hide} 652 */ 653 public static final int FLAG_SLIPPERY = 0x04000000; 654 655 /** 656 * Flag for a window belonging to an activity that responds to {@link KeyEvent#KEYCODE_MENU} 657 * and therefore needs a Menu key. For devices where Menu is a physical button this flag is 658 * ignored, but on devices where the Menu key is drawn in software it may be hidden unless 659 * this flag is set. 660 * 661 * (Note that Action Bars, when available, are the preferred way to offer additional 662 * functions otherwise accessed via an options menu.) 663 * 664 * {@hide} 665 */ 666 public static final int FLAG_NEEDS_MENU_KEY = 0x08000000; 667 668 /** Window flag: *sigh* The lock screen wants to continue running its 669 * animation while it is fading. A kind-of hack to allow this. Maybe 670 * in the future we just make this the default behavior. 671 * 672 * {@hide} */ 673 public static final int FLAG_KEEP_SURFACE_WHILE_ANIMATING = 0x10000000; 674 675 /** Window flag: special flag to limit the size of the window to be 676 * original size ([320x480] x density). Used to create window for applications 677 * running under compatibility mode. 678 * 679 * {@hide} */ 680 public static final int FLAG_COMPATIBLE_WINDOW = 0x20000000; 681 682 /** Window flag: a special option intended for system dialogs. When 683 * this flag is set, the window will demand focus unconditionally when 684 * it is created. 685 * {@hide} */ 686 public static final int FLAG_SYSTEM_ERROR = 0x40000000; 687 688 /** 689 * Various behavioral options/flags. Default is none. 690 * 691 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 692 * @see #FLAG_DIM_BEHIND 693 * @see #FLAG_NOT_FOCUSABLE 694 * @see #FLAG_NOT_TOUCHABLE 695 * @see #FLAG_NOT_TOUCH_MODAL 696 * @see #FLAG_TOUCHABLE_WHEN_WAKING 697 * @see #FLAG_KEEP_SCREEN_ON 698 * @see #FLAG_LAYOUT_IN_SCREEN 699 * @see #FLAG_LAYOUT_NO_LIMITS 700 * @see #FLAG_FULLSCREEN 701 * @see #FLAG_FORCE_NOT_FULLSCREEN 702 * @see #FLAG_DITHER 703 * @see #FLAG_SECURE 704 * @see #FLAG_SCALED 705 * @see #FLAG_IGNORE_CHEEK_PRESSES 706 * @see #FLAG_LAYOUT_INSET_DECOR 707 * @see #FLAG_ALT_FOCUSABLE_IM 708 * @see #FLAG_WATCH_OUTSIDE_TOUCH 709 * @see #FLAG_SHOW_WHEN_LOCKED 710 * @see #FLAG_SHOW_WALLPAPER 711 * @see #FLAG_TURN_SCREEN_ON 712 * @see #FLAG_DISMISS_KEYGUARD 713 * @see #FLAG_SPLIT_TOUCH 714 * @see #FLAG_HARDWARE_ACCELERATED 715 */ 716 @ViewDebug.ExportedProperty(flagMapping = { 717 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 718 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), 719 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 720 name = "FLAG_DIM_BEHIND"), 721 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 722 name = "FLAG_BLUR_BEHIND"), 723 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 724 name = "FLAG_NOT_FOCUSABLE"), 725 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 726 name = "FLAG_NOT_TOUCHABLE"), 727 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 728 name = "FLAG_NOT_TOUCH_MODAL"), 729 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING, 730 name = "FLAG_TOUCHABLE_WHEN_WAKING"), 731 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 732 name = "FLAG_KEEP_SCREEN_ON"), 733 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 734 name = "FLAG_LAYOUT_IN_SCREEN"), 735 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS, 736 name = "FLAG_LAYOUT_NO_LIMITS"), 737 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 738 name = "FLAG_FULLSCREEN"), 739 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN, 740 name = "FLAG_FORCE_NOT_FULLSCREEN"), 741 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 742 name = "FLAG_DITHER"), 743 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE, 744 name = "FLAG_SECURE"), 745 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED, 746 name = "FLAG_SCALED"), 747 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES, 748 name = "FLAG_IGNORE_CHEEK_PRESSES"), 749 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR, 750 name = "FLAG_LAYOUT_INSET_DECOR"), 751 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM, 752 name = "FLAG_ALT_FOCUSABLE_IM"), 753 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH, 754 name = "FLAG_WATCH_OUTSIDE_TOUCH"), 755 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 756 name = "FLAG_SHOW_WHEN_LOCKED"), 757 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER, 758 name = "FLAG_SHOW_WALLPAPER"), 759 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 760 name = "FLAG_TURN_SCREEN_ON"), 761 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 762 name = "FLAG_DISMISS_KEYGUARD"), 763 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH, 764 name = "FLAG_SPLIT_TOUCH"), 765 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED, 766 name = "FLAG_HARDWARE_ACCELERATED") 767 }) 768 public int flags; 769 770 /** 771 * If the window has requested hardware acceleration, but this is not 772 * allowed in the process it is in, then still render it as if it is 773 * hardware accelerated. This is used for the starting preview windows 774 * in the system process, which don't need to have the overhead of 775 * hardware acceleration (they are just a static rendering), but should 776 * be rendered as much to match the actual window of the app even if it 777 * is hardware accelerated. 778 * Even if the window isn't hardware accelerated, still do its rendering 779 * as if it is. 780 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows 781 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration 782 * is generally disabled. This flag must be specified in addition to 783 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system 784 * windows. 785 * 786 * @hide 787 */ 788 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001; 789 790 /** 791 * In the system process, we globally do not use hardware acceleration 792 * because there are many threads doing UI there and they an conflict. 793 * If certain parts of the UI that really do want to use hardware 794 * acceleration, this flag can be set to force it. This is basically 795 * for the lock screen. Anyone else using it, you are probably wrong. 796 * 797 * @hide 798 */ 799 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002; 800 801 /** 802 * Control flags that are private to the platform. 803 * @hide 804 */ 805 public int privateFlags; 806 807 /** 808 * Given a particular set of window manager flags, determine whether 809 * such a window may be a target for an input method when it has 810 * focus. In particular, this checks the 811 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 812 * flags and returns true if the combination of the two corresponds 813 * to a window that needs to be behind the input method so that the 814 * user can type into it. 815 * 816 * @param flags The current window manager flags. 817 * 818 * @return Returns true if such a window should be behind/interact 819 * with an input method, false if not. 820 */ 821 public static boolean mayUseInputMethod(int flags) { 822 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { 823 case 0: 824 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: 825 return true; 826 } 827 return false; 828 } 829 830 /** 831 * Mask for {@link #softInputMode} of the bits that determine the 832 * desired visibility state of the soft input area for this window. 833 */ 834 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 835 836 /** 837 * Visibility state for {@link #softInputMode}: no state has been specified. 838 */ 839 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 840 841 /** 842 * Visibility state for {@link #softInputMode}: please don't change the state of 843 * the soft input area. 844 */ 845 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 846 847 /** 848 * Visibility state for {@link #softInputMode}: please hide any soft input 849 * area when normally appropriate (when the user is navigating 850 * forward to your window). 851 */ 852 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 853 854 /** 855 * Visibility state for {@link #softInputMode}: please always hide any 856 * soft input area when this window receives focus. 857 */ 858 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 859 860 /** 861 * Visibility state for {@link #softInputMode}: please show the soft 862 * input area when normally appropriate (when the user is navigating 863 * forward to your window). 864 */ 865 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 866 867 /** 868 * Visibility state for {@link #softInputMode}: please always make the 869 * soft input area visible when this window receives input focus. 870 */ 871 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 872 873 /** 874 * Mask for {@link #softInputMode} of the bits that determine the 875 * way that the window should be adjusted to accommodate the soft 876 * input window. 877 */ 878 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 879 880 /** Adjustment option for {@link #softInputMode}: nothing specified. 881 * The system will try to pick one or 882 * the other depending on the contents of the window. 883 */ 884 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 885 886 /** Adjustment option for {@link #softInputMode}: set to allow the 887 * window to be resized when an input 888 * method is shown, so that its contents are not covered by the input 889 * method. This can <em>not</em> be combined with 890 * {@link #SOFT_INPUT_ADJUST_PAN}; if 891 * neither of these are set, then the system will try to pick one or 892 * the other depending on the contents of the window. 893 */ 894 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 895 896 /** Adjustment option for {@link #softInputMode}: set to have a window 897 * pan when an input method is 898 * shown, so it doesn't need to deal with resizing but just panned 899 * by the framework to ensure the current input focus is visible. This 900 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 901 * neither of these are set, then the system will try to pick one or 902 * the other depending on the contents of the window. 903 */ 904 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 905 906 /** Adjustment option for {@link #softInputMode}: set to have a window 907 * not adjust for a shown input method. The window will not be resized, 908 * and it will not be panned to make its focus visible. 909 */ 910 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 911 912 /** 913 * Bit for {@link #softInputMode}: set when the user has navigated 914 * forward to the window. This is normally set automatically for 915 * you by the system, though you may want to set it in certain cases 916 * when you are displaying a window yourself. This flag will always 917 * be cleared automatically after the window is displayed. 918 */ 919 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 920 921 /** 922 * Desired operating mode for any soft input area. May be any combination 923 * of: 924 * 925 * <ul> 926 * <li> One of the visibility states 927 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 928 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or 929 * {@link #SOFT_INPUT_STATE_VISIBLE}. 930 * <li> One of the adjustment options 931 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, 932 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or 933 * {@link #SOFT_INPUT_ADJUST_PAN}. 934 */ 935 public int softInputMode; 936 937 /** 938 * Placement of window within the screen as per {@link Gravity}. Both 939 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 940 * android.graphics.Rect) Gravity.apply} and 941 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 942 * Gravity.applyDisplay} are used during window layout, with this value 943 * given as the desired gravity. For example you can specify 944 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 945 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 946 * to control the behavior of 947 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 948 * Gravity.applyDisplay}. 949 * 950 * @see Gravity 951 */ 952 public int gravity; 953 954 /** 955 * The horizontal margin, as a percentage of the container's width, 956 * between the container and the widget. See 957 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 958 * android.graphics.Rect) Gravity.apply} for how this is used. This 959 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 960 */ 961 public float horizontalMargin; 962 963 /** 964 * The vertical margin, as a percentage of the container's height, 965 * between the container and the widget. See 966 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 967 * android.graphics.Rect) Gravity.apply} for how this is used. This 968 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 969 */ 970 public float verticalMargin; 971 972 /** 973 * The desired bitmap format. May be one of the constants in 974 * {@link android.graphics.PixelFormat}. Default is OPAQUE. 975 */ 976 public int format; 977 978 /** 979 * A style resource defining the animations to use for this window. 980 * This must be a system resource; it can not be an application resource 981 * because the window manager does not have access to applications. 982 */ 983 public int windowAnimations; 984 985 /** 986 * An alpha value to apply to this entire window. 987 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 988 */ 989 public float alpha = 1.0f; 990 991 /** 992 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 993 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 994 * dim. 995 */ 996 public float dimAmount = 1.0f; 997 998 /** 999 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 1000 * indicating that the brightness value is not overridden for this window 1001 * and normal brightness policy should be used. 1002 */ 1003 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 1004 1005 /** 1006 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1007 * indicating that the screen or button backlight brightness should be set 1008 * to the lowest value when this window is in front. 1009 */ 1010 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 1011 1012 /** 1013 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1014 * indicating that the screen or button backlight brightness should be set 1015 * to the hightest value when this window is in front. 1016 */ 1017 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 1018 1019 /** 1020 * This can be used to override the user's preferred brightness of 1021 * the screen. A value of less than 0, the default, means to use the 1022 * preferred screen brightness. 0 to 1 adjusts the brightness from 1023 * dark to full bright. 1024 */ 1025 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 1026 1027 /** 1028 * This can be used to override the standard behavior of the button and 1029 * keyboard backlights. A value of less than 0, the default, means to 1030 * use the standard backlight behavior. 0 to 1 adjusts the brightness 1031 * from dark to full bright. 1032 */ 1033 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 1034 1035 /** 1036 * Identifier for this window. This will usually be filled in for 1037 * you. 1038 */ 1039 public IBinder token = null; 1040 1041 /** 1042 * Name of the package owning this window. 1043 */ 1044 public String packageName = null; 1045 1046 /** 1047 * Specific orientation value for a window. 1048 * May be any of the same values allowed 1049 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 1050 * If not set, a default value of 1051 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 1052 * will be used. 1053 */ 1054 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 1055 1056 /** 1057 * Control the visibility of the status bar. 1058 * 1059 * @see View#STATUS_BAR_VISIBLE 1060 * @see View#STATUS_BAR_HIDDEN 1061 */ 1062 public int systemUiVisibility; 1063 1064 /** 1065 * @hide 1066 * The ui visibility as requested by the views in this hierarchy. 1067 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. 1068 */ 1069 public int subtreeSystemUiVisibility; 1070 1071 /** 1072 * Get callbacks about the system ui visibility changing. 1073 * 1074 * TODO: Maybe there should be a bitfield of optional callbacks that we need. 1075 * 1076 * @hide 1077 */ 1078 public boolean hasSystemUiListeners; 1079 1080 /** 1081 * When this window has focus, disable touch pad pointer gesture processing. 1082 * The window will receive raw position updates from the touch pad instead 1083 * of pointer movements and synthetic touch events. 1084 * 1085 * @hide 1086 */ 1087 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001; 1088 1089 /** 1090 * Does not construct an input channel for this window. The channel will therefore 1091 * be incapable of receiving input. 1092 * 1093 * @hide 1094 */ 1095 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002; 1096 1097 /** 1098 * Control special features of the input subsystem. 1099 * 1100 * @see #INPUT_FEATURE_DISABLE_TOUCH_PAD_GESTURES 1101 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL 1102 * @hide 1103 */ 1104 public int inputFeatures; 1105 1106 public LayoutParams() { 1107 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1108 type = TYPE_APPLICATION; 1109 format = PixelFormat.OPAQUE; 1110 } 1111 1112 public LayoutParams(int _type) { 1113 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1114 type = _type; 1115 format = PixelFormat.OPAQUE; 1116 } 1117 1118 public LayoutParams(int _type, int _flags) { 1119 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1120 type = _type; 1121 flags = _flags; 1122 format = PixelFormat.OPAQUE; 1123 } 1124 1125 public LayoutParams(int _type, int _flags, int _format) { 1126 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1127 type = _type; 1128 flags = _flags; 1129 format = _format; 1130 } 1131 1132 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 1133 super(w, h); 1134 type = _type; 1135 flags = _flags; 1136 format = _format; 1137 } 1138 1139 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 1140 int _flags, int _format) { 1141 super(w, h); 1142 x = xpos; 1143 y = ypos; 1144 type = _type; 1145 flags = _flags; 1146 format = _format; 1147 } 1148 1149 public final void setTitle(CharSequence title) { 1150 if (null == title) 1151 title = ""; 1152 1153 mTitle = TextUtils.stringOrSpannedString(title); 1154 } 1155 1156 public final CharSequence getTitle() { 1157 return mTitle; 1158 } 1159 1160 public int describeContents() { 1161 return 0; 1162 } 1163 1164 public void writeToParcel(Parcel out, int parcelableFlags) { 1165 out.writeInt(width); 1166 out.writeInt(height); 1167 out.writeInt(x); 1168 out.writeInt(y); 1169 out.writeInt(type); 1170 out.writeInt(flags); 1171 out.writeInt(privateFlags); 1172 out.writeInt(softInputMode); 1173 out.writeInt(gravity); 1174 out.writeFloat(horizontalMargin); 1175 out.writeFloat(verticalMargin); 1176 out.writeInt(format); 1177 out.writeInt(windowAnimations); 1178 out.writeFloat(alpha); 1179 out.writeFloat(dimAmount); 1180 out.writeFloat(screenBrightness); 1181 out.writeFloat(buttonBrightness); 1182 out.writeStrongBinder(token); 1183 out.writeString(packageName); 1184 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 1185 out.writeInt(screenOrientation); 1186 out.writeInt(systemUiVisibility); 1187 out.writeInt(subtreeSystemUiVisibility); 1188 out.writeInt(hasSystemUiListeners ? 1 : 0); 1189 out.writeInt(inputFeatures); 1190 } 1191 1192 public static final Parcelable.Creator<LayoutParams> CREATOR 1193 = new Parcelable.Creator<LayoutParams>() { 1194 public LayoutParams createFromParcel(Parcel in) { 1195 return new LayoutParams(in); 1196 } 1197 1198 public LayoutParams[] newArray(int size) { 1199 return new LayoutParams[size]; 1200 } 1201 }; 1202 1203 1204 public LayoutParams(Parcel in) { 1205 width = in.readInt(); 1206 height = in.readInt(); 1207 x = in.readInt(); 1208 y = in.readInt(); 1209 type = in.readInt(); 1210 flags = in.readInt(); 1211 privateFlags = in.readInt(); 1212 softInputMode = in.readInt(); 1213 gravity = in.readInt(); 1214 horizontalMargin = in.readFloat(); 1215 verticalMargin = in.readFloat(); 1216 format = in.readInt(); 1217 windowAnimations = in.readInt(); 1218 alpha = in.readFloat(); 1219 dimAmount = in.readFloat(); 1220 screenBrightness = in.readFloat(); 1221 buttonBrightness = in.readFloat(); 1222 token = in.readStrongBinder(); 1223 packageName = in.readString(); 1224 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 1225 screenOrientation = in.readInt(); 1226 systemUiVisibility = in.readInt(); 1227 subtreeSystemUiVisibility = in.readInt(); 1228 hasSystemUiListeners = in.readInt() != 0; 1229 inputFeatures = in.readInt(); 1230 } 1231 1232 @SuppressWarnings({"PointlessBitwiseExpression"}) 1233 public static final int LAYOUT_CHANGED = 1<<0; 1234 public static final int TYPE_CHANGED = 1<<1; 1235 public static final int FLAGS_CHANGED = 1<<2; 1236 public static final int FORMAT_CHANGED = 1<<3; 1237 public static final int ANIMATION_CHANGED = 1<<4; 1238 public static final int DIM_AMOUNT_CHANGED = 1<<5; 1239 public static final int TITLE_CHANGED = 1<<6; 1240 public static final int ALPHA_CHANGED = 1<<7; 1241 public static final int MEMORY_TYPE_CHANGED = 1<<8; 1242 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 1243 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 1244 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 1245 /** {@hide} */ 1246 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<12; 1247 /** {@hide} */ 1248 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<13; 1249 /** {@hide} */ 1250 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<14; 1251 /** {@hide} */ 1252 public static final int INPUT_FEATURES_CHANGED = 1<<15; 1253 /** {@hide} */ 1254 public static final int PRIVATE_FLAGS_CHANGED = 1<<16; 1255 /** {@hide} */ 1256 public static final int BUFFER_CHANGED = 1<<17; 1257 /** {@hide} */ 1258 public static final int EVERYTHING_CHANGED = 0xffffffff; 1259 1260 // internal buffer to backup/restore parameters under compatibility mode. 1261 private int[] mCompatibilityParamsBackup = null; 1262 1263 public final int copyFrom(LayoutParams o) { 1264 int changes = 0; 1265 1266 if (width != o.width) { 1267 width = o.width; 1268 changes |= LAYOUT_CHANGED | BUFFER_CHANGED; 1269 } 1270 if (height != o.height) { 1271 height = o.height; 1272 changes |= LAYOUT_CHANGED | BUFFER_CHANGED; 1273 } 1274 if (x != o.x) { 1275 x = o.x; 1276 changes |= LAYOUT_CHANGED; 1277 } 1278 if (y != o.y) { 1279 y = o.y; 1280 changes |= LAYOUT_CHANGED; 1281 } 1282 if (horizontalWeight != o.horizontalWeight) { 1283 horizontalWeight = o.horizontalWeight; 1284 changes |= LAYOUT_CHANGED | BUFFER_CHANGED; 1285 } 1286 if (verticalWeight != o.verticalWeight) { 1287 verticalWeight = o.verticalWeight; 1288 changes |= LAYOUT_CHANGED | BUFFER_CHANGED; 1289 } 1290 if (horizontalMargin != o.horizontalMargin) { 1291 horizontalMargin = o.horizontalMargin; 1292 changes |= LAYOUT_CHANGED | BUFFER_CHANGED; 1293 } 1294 if (verticalMargin != o.verticalMargin) { 1295 verticalMargin = o.verticalMargin; 1296 changes |= LAYOUT_CHANGED | BUFFER_CHANGED; 1297 } 1298 if (type != o.type) { 1299 type = o.type; 1300 changes |= TYPE_CHANGED; 1301 } 1302 if (flags != o.flags) { 1303 flags = o.flags; 1304 changes |= FLAGS_CHANGED | BUFFER_CHANGED; 1305 } 1306 if (privateFlags != o.privateFlags) { 1307 privateFlags = o.privateFlags; 1308 changes |= PRIVATE_FLAGS_CHANGED; 1309 } 1310 if (softInputMode != o.softInputMode) { 1311 softInputMode = o.softInputMode; 1312 changes |= SOFT_INPUT_MODE_CHANGED; 1313 } 1314 if (gravity != o.gravity) { 1315 gravity = o.gravity; 1316 changes |= LAYOUT_CHANGED | BUFFER_CHANGED; 1317 } 1318 if (format != o.format) { 1319 format = o.format; 1320 changes |= FORMAT_CHANGED | BUFFER_CHANGED; 1321 } 1322 if (windowAnimations != o.windowAnimations) { 1323 windowAnimations = o.windowAnimations; 1324 changes |= ANIMATION_CHANGED; 1325 } 1326 if (token == null) { 1327 // NOTE: token only copied if the recipient doesn't 1328 // already have one. 1329 token = o.token; 1330 } 1331 if (packageName == null) { 1332 // NOTE: packageName only copied if the recipient doesn't 1333 // already have one. 1334 packageName = o.packageName; 1335 } 1336 if (!mTitle.equals(o.mTitle)) { 1337 mTitle = o.mTitle; 1338 changes |= TITLE_CHANGED; 1339 } 1340 if (alpha != o.alpha) { 1341 alpha = o.alpha; 1342 changes |= ALPHA_CHANGED; 1343 } 1344 if (dimAmount != o.dimAmount) { 1345 dimAmount = o.dimAmount; 1346 changes |= DIM_AMOUNT_CHANGED; 1347 } 1348 if (screenBrightness != o.screenBrightness) { 1349 screenBrightness = o.screenBrightness; 1350 changes |= SCREEN_BRIGHTNESS_CHANGED; 1351 } 1352 if (buttonBrightness != o.buttonBrightness) { 1353 buttonBrightness = o.buttonBrightness; 1354 changes |= BUTTON_BRIGHTNESS_CHANGED; 1355 } 1356 1357 if (screenOrientation != o.screenOrientation) { 1358 screenOrientation = o.screenOrientation; 1359 changes |= SCREEN_ORIENTATION_CHANGED | BUFFER_CHANGED; 1360 } 1361 1362 if (systemUiVisibility != o.systemUiVisibility 1363 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { 1364 systemUiVisibility = o.systemUiVisibility; 1365 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; 1366 changes |= SYSTEM_UI_VISIBILITY_CHANGED; 1367 } 1368 1369 if (hasSystemUiListeners != o.hasSystemUiListeners) { 1370 hasSystemUiListeners = o.hasSystemUiListeners; 1371 changes |= SYSTEM_UI_LISTENER_CHANGED; 1372 } 1373 1374 if (inputFeatures != o.inputFeatures) { 1375 inputFeatures = o.inputFeatures; 1376 changes |= INPUT_FEATURES_CHANGED; 1377 } 1378 1379 return changes; 1380 } 1381 1382 @Override 1383 public String debug(String output) { 1384 output += "Contents of " + this + ":"; 1385 Log.d("Debug", output); 1386 output = super.debug(""); 1387 Log.d("Debug", output); 1388 Log.d("Debug", ""); 1389 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 1390 return ""; 1391 } 1392 1393 @Override 1394 public String toString() { 1395 StringBuilder sb = new StringBuilder(256); 1396 sb.append("WM.LayoutParams{"); 1397 sb.append("("); 1398 sb.append(x); 1399 sb.append(','); 1400 sb.append(y); 1401 sb.append(")("); 1402 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width))); 1403 sb.append('x'); 1404 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height))); 1405 sb.append(")"); 1406 if (horizontalMargin != 0) { 1407 sb.append(" hm="); 1408 sb.append(horizontalMargin); 1409 } 1410 if (verticalMargin != 0) { 1411 sb.append(" vm="); 1412 sb.append(verticalMargin); 1413 } 1414 if (gravity != 0) { 1415 sb.append(" gr=#"); 1416 sb.append(Integer.toHexString(gravity)); 1417 } 1418 if (softInputMode != 0) { 1419 sb.append(" sim=#"); 1420 sb.append(Integer.toHexString(softInputMode)); 1421 } 1422 sb.append(" ty="); 1423 sb.append(type); 1424 sb.append(" fl=#"); 1425 sb.append(Integer.toHexString(flags)); 1426 if (privateFlags != 0) { 1427 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags)); 1428 } 1429 if (format != PixelFormat.OPAQUE) { 1430 sb.append(" fmt="); 1431 sb.append(format); 1432 } 1433 if (windowAnimations != 0) { 1434 sb.append(" wanim=0x"); 1435 sb.append(Integer.toHexString(windowAnimations)); 1436 } 1437 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 1438 sb.append(" or="); 1439 sb.append(screenOrientation); 1440 } 1441 if (alpha != 1.0f) { 1442 sb.append(" alpha="); 1443 sb.append(alpha); 1444 } 1445 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1446 sb.append(" sbrt="); 1447 sb.append(screenBrightness); 1448 } 1449 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1450 sb.append(" bbrt="); 1451 sb.append(buttonBrightness); 1452 } 1453 if ((flags & FLAG_COMPATIBLE_WINDOW) != 0) { 1454 sb.append(" compatible=true"); 1455 } 1456 if (systemUiVisibility != 0) { 1457 sb.append(" sysui=0x"); 1458 sb.append(Integer.toHexString(systemUiVisibility)); 1459 } 1460 if (subtreeSystemUiVisibility != 0) { 1461 sb.append(" vsysui=0x"); 1462 sb.append(Integer.toHexString(subtreeSystemUiVisibility)); 1463 } 1464 if (hasSystemUiListeners) { 1465 sb.append(" sysuil="); 1466 sb.append(hasSystemUiListeners); 1467 } 1468 if (inputFeatures != 0) { 1469 sb.append(" if=0x").append(Integer.toHexString(inputFeatures)); 1470 } 1471 sb.append('}'); 1472 return sb.toString(); 1473 } 1474 1475 /** 1476 * Scale the layout params' coordinates and size. 1477 * @hide 1478 */ 1479 public void scale(float scale) { 1480 x = (int) (x * scale + 0.5f); 1481 y = (int) (y * scale + 0.5f); 1482 if (width > 0) { 1483 width = (int) (width * scale + 0.5f); 1484 } 1485 if (height > 0) { 1486 height = (int) (height * scale + 0.5f); 1487 } 1488 } 1489 1490 /** 1491 * Backup the layout parameters used in compatibility mode. 1492 * @see LayoutParams#restore() 1493 */ 1494 void backup() { 1495 int[] backup = mCompatibilityParamsBackup; 1496 if (backup == null) { 1497 // we backup 4 elements, x, y, width, height 1498 backup = mCompatibilityParamsBackup = new int[4]; 1499 } 1500 backup[0] = x; 1501 backup[1] = y; 1502 backup[2] = width; 1503 backup[3] = height; 1504 } 1505 1506 /** 1507 * Restore the layout params' coordinates, size and gravity 1508 * @see LayoutParams#backup() 1509 */ 1510 void restore() { 1511 int[] backup = mCompatibilityParamsBackup; 1512 if (backup != null) { 1513 x = backup[0]; 1514 y = backup[1]; 1515 width = backup[2]; 1516 height = backup[3]; 1517 } 1518 } 1519 1520 private CharSequence mTitle = ""; 1521 } 1522} 1523