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