WindowManager.java revision 0a4dc2258fa8216920e1a0b83cbf7d3729386e2f
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.annotation.SystemApi; 20import android.app.Presentation; 21import android.content.Context; 22import android.content.pm.ActivityInfo; 23import android.graphics.Insets; 24import android.graphics.PixelFormat; 25import android.graphics.Rect; 26import android.os.IBinder; 27import android.os.Parcel; 28import android.os.Parcelable; 29import android.text.TextUtils; 30import android.util.Log; 31 32 33/** 34 * The interface that apps use to talk to the window manager. 35 * <p> 36 * Use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> to get one of these. 37 * </p><p> 38 * Each window manager instance is bound to a particular {@link Display}. 39 * To obtain a {@link WindowManager} for a different display, use 40 * {@link Context#createDisplayContext} to obtain a {@link Context} for that 41 * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> 42 * to get the WindowManager. 43 * </p><p> 44 * The simplest way to show a window on another display is to create a 45 * {@link Presentation}. The presentation will automatically obtain a 46 * {@link WindowManager} and {@link Context} for that display. 47 * </p> 48 * 49 * @see android.content.Context#getSystemService 50 * @see android.content.Context#WINDOW_SERVICE 51 */ 52public interface WindowManager extends ViewManager { 53 /** 54 * Exception that is thrown when trying to add view whose 55 * {@link LayoutParams} {@link LayoutParams#token} 56 * is invalid. 57 */ 58 public static class BadTokenException extends RuntimeException { 59 public BadTokenException() { 60 } 61 62 public BadTokenException(String name) { 63 super(name); 64 } 65 } 66 67 /** 68 * Exception that is thrown when calling {@link #addView} to a secondary display that cannot 69 * be found. See {@link android.app.Presentation} for more information on secondary displays. 70 */ 71 public static class InvalidDisplayException extends RuntimeException { 72 public InvalidDisplayException() { 73 } 74 75 public InvalidDisplayException(String name) { 76 super(name); 77 } 78 } 79 80 /** 81 * Returns the {@link Display} upon which this {@link WindowManager} instance 82 * will create new windows. 83 * <p> 84 * Despite the name of this method, the display that is returned is not 85 * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}). 86 * The returned display could instead be a secondary display that this 87 * window manager instance is managing. Think of it as the display that 88 * this {@link WindowManager} instance uses by default. 89 * </p><p> 90 * To create windows on a different display, you need to obtain a 91 * {@link WindowManager} for that {@link Display}. (See the {@link WindowManager} 92 * class documentation for more information.) 93 * </p> 94 * 95 * @return The display that this window manager is managing. 96 */ 97 public Display getDefaultDisplay(); 98 99 /** 100 * Special variation of {@link #removeView} that immediately invokes 101 * the given view hierarchy's {@link View#onDetachedFromWindow() 102 * View.onDetachedFromWindow()} methods before returning. This is not 103 * for normal applications; using it correctly requires great care. 104 * 105 * @param view The view to be removed. 106 */ 107 public void removeViewImmediate(View view); 108 109 public static class LayoutParams extends ViewGroup.LayoutParams 110 implements Parcelable { 111 /** 112 * X position for this window. With the default gravity it is ignored. 113 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or 114 * {@link Gravity#END} it provides an offset from the given edge. 115 */ 116 @ViewDebug.ExportedProperty 117 public int x; 118 119 /** 120 * Y position for this window. With the default gravity it is ignored. 121 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides 122 * an offset from the given edge. 123 */ 124 @ViewDebug.ExportedProperty 125 public int y; 126 127 /** 128 * Indicates how much of the extra space will be allocated horizontally 129 * to the view associated with these LayoutParams. Specify 0 if the view 130 * should not be stretched. Otherwise the extra pixels will be pro-rated 131 * among all views whose weight is greater than 0. 132 */ 133 @ViewDebug.ExportedProperty 134 public float horizontalWeight; 135 136 /** 137 * Indicates how much of the extra space will be allocated vertically 138 * to the view associated with these LayoutParams. Specify 0 if the view 139 * should not be stretched. Otherwise the extra pixels will be pro-rated 140 * among all views whose weight is greater than 0. 141 */ 142 @ViewDebug.ExportedProperty 143 public float verticalWeight; 144 145 /** 146 * The general type of window. There are three main classes of 147 * window types: 148 * <ul> 149 * <li> <strong>Application windows</strong> (ranging from 150 * {@link #FIRST_APPLICATION_WINDOW} to 151 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application 152 * windows. For these types of windows, the {@link #token} must be 153 * set to the token of the activity they are a part of (this will 154 * normally be done for you if {@link #token} is null). 155 * <li> <strong>Sub-windows</strong> (ranging from 156 * {@link #FIRST_SUB_WINDOW} to 157 * {@link #LAST_SUB_WINDOW}) are associated with another top-level 158 * window. For these types of windows, the {@link #token} must be 159 * the token of the window it is attached to. 160 * <li> <strong>System windows</strong> (ranging from 161 * {@link #FIRST_SYSTEM_WINDOW} to 162 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for 163 * use by the system for specific purposes. They should not normally 164 * be used by applications, and a special permission is required 165 * to use them. 166 * </ul> 167 * 168 * @see #TYPE_BASE_APPLICATION 169 * @see #TYPE_APPLICATION 170 * @see #TYPE_APPLICATION_STARTING 171 * @see #TYPE_APPLICATION_PANEL 172 * @see #TYPE_APPLICATION_MEDIA 173 * @see #TYPE_APPLICATION_SUB_PANEL 174 * @see #TYPE_APPLICATION_ABOVE_SUB_PANEL 175 * @see #TYPE_APPLICATION_ATTACHED_DIALOG 176 * @see #TYPE_STATUS_BAR 177 * @see #TYPE_SEARCH_BAR 178 * @see #TYPE_PHONE 179 * @see #TYPE_SYSTEM_ALERT 180 * @see #TYPE_TOAST 181 * @see #TYPE_SYSTEM_OVERLAY 182 * @see #TYPE_PRIORITY_PHONE 183 * @see #TYPE_STATUS_BAR_PANEL 184 * @see #TYPE_SYSTEM_DIALOG 185 * @see #TYPE_KEYGUARD_DIALOG 186 * @see #TYPE_SYSTEM_ERROR 187 * @see #TYPE_INPUT_METHOD 188 * @see #TYPE_INPUT_METHOD_DIALOG 189 */ 190 @ViewDebug.ExportedProperty(mapping = { 191 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, to = "TYPE_BASE_APPLICATION"), 192 @ViewDebug.IntToString(from = TYPE_APPLICATION, to = "TYPE_APPLICATION"), 193 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, to = "TYPE_APPLICATION_STARTING"), 194 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, to = "TYPE_APPLICATION_PANEL"), 195 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, to = "TYPE_APPLICATION_MEDIA"), 196 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, to = "TYPE_APPLICATION_SUB_PANEL"), 197 @ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL, to = "TYPE_APPLICATION_ABOVE_SUB_PANEL"), 198 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, to = "TYPE_APPLICATION_ATTACHED_DIALOG"), 199 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, to = "TYPE_APPLICATION_MEDIA_OVERLAY"), 200 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, to = "TYPE_STATUS_BAR"), 201 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, to = "TYPE_SEARCH_BAR"), 202 @ViewDebug.IntToString(from = TYPE_PHONE, to = "TYPE_PHONE"), 203 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, to = "TYPE_SYSTEM_ALERT"), 204 @ViewDebug.IntToString(from = TYPE_TOAST, to = "TYPE_TOAST"), 205 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, to = "TYPE_SYSTEM_OVERLAY"), 206 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, to = "TYPE_PRIORITY_PHONE"), 207 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, to = "TYPE_SYSTEM_DIALOG"), 208 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, to = "TYPE_KEYGUARD_DIALOG"), 209 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, to = "TYPE_SYSTEM_ERROR"), 210 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, to = "TYPE_INPUT_METHOD"), 211 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, to = "TYPE_INPUT_METHOD_DIALOG"), 212 @ViewDebug.IntToString(from = TYPE_WALLPAPER, to = "TYPE_WALLPAPER"), 213 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, to = "TYPE_STATUS_BAR_PANEL"), 214 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, to = "TYPE_SECURE_SYSTEM_OVERLAY"), 215 @ViewDebug.IntToString(from = TYPE_DRAG, to = "TYPE_DRAG"), 216 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, to = "TYPE_STATUS_BAR_SUB_PANEL"), 217 @ViewDebug.IntToString(from = TYPE_POINTER, to = "TYPE_POINTER"), 218 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, to = "TYPE_NAVIGATION_BAR"), 219 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, to = "TYPE_VOLUME_OVERLAY"), 220 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, to = "TYPE_BOOT_PROGRESS"), 221 @ViewDebug.IntToString(from = TYPE_HIDDEN_NAV_CONSUMER, to = "TYPE_HIDDEN_NAV_CONSUMER"), 222 @ViewDebug.IntToString(from = TYPE_DREAM, to = "TYPE_DREAM"), 223 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, to = "TYPE_NAVIGATION_BAR_PANEL"), 224 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, to = "TYPE_DISPLAY_OVERLAY"), 225 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, to = "TYPE_MAGNIFICATION_OVERLAY"), 226 @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION, to = "TYPE_PRIVATE_PRESENTATION"), 227 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION, to = "TYPE_VOICE_INTERACTION"), 228 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING, to = "TYPE_VOICE_INTERACTION_STARTING"), 229 }) 230 public int type; 231 232 /** 233 * Start of window types that represent normal application windows. 234 */ 235 public static final int FIRST_APPLICATION_WINDOW = 1; 236 237 /** 238 * Window type: an application window that serves as the "base" window 239 * of the overall application; all other application windows will 240 * appear on top of it. 241 * In multiuser systems shows only on the owning user's window. 242 */ 243 public static final int TYPE_BASE_APPLICATION = 1; 244 245 /** 246 * Window type: a normal application window. The {@link #token} must be 247 * an Activity token identifying who the window belongs to. 248 * In multiuser systems shows only on the owning user's window. 249 */ 250 public static final int TYPE_APPLICATION = 2; 251 252 /** 253 * Window type: special application window that is displayed while the 254 * application is starting. Not for use by applications themselves; 255 * this is used by the system to display something until the 256 * application can show its own windows. 257 * In multiuser systems shows on all users' windows. 258 */ 259 public static final int TYPE_APPLICATION_STARTING = 3; 260 261 /** 262 * End of types of application windows. 263 */ 264 public static final int LAST_APPLICATION_WINDOW = 99; 265 266 /** 267 * Start of types of sub-windows. The {@link #token} of these windows 268 * must be set to the window they are attached to. These types of 269 * windows are kept next to their attached window in Z-order, and their 270 * coordinate space is relative to their attached window. 271 */ 272 public static final int FIRST_SUB_WINDOW = 1000; 273 274 /** 275 * Window type: a panel on top of an application window. These windows 276 * appear on top of their attached window. 277 */ 278 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; 279 280 /** 281 * Window type: window for showing media (such as video). These windows 282 * are displayed behind their attached window. 283 */ 284 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1; 285 286 /** 287 * Window type: a sub-panel on top of an application window. These 288 * windows are displayed on top their attached window and any 289 * {@link #TYPE_APPLICATION_PANEL} panels. 290 */ 291 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2; 292 293 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout 294 * of the window happens as that of a top-level window, <em>not</em> 295 * as a child of its container. 296 */ 297 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3; 298 299 /** 300 * Window type: window for showing overlays on top of media windows. 301 * These windows are displayed between TYPE_APPLICATION_MEDIA and the 302 * application window. They should be translucent to be useful. This 303 * is a big ugly hack so: 304 * @hide 305 */ 306 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4; 307 308 /** 309 * Window type: a above sub-panel on top of an application window and it's 310 * sub-panel windows. These windows are displayed on top of their attached window 311 * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels. 312 */ 313 public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5; 314 315 /** 316 * End of types of sub-windows. 317 */ 318 public static final int LAST_SUB_WINDOW = 1999; 319 320 /** 321 * Start of system-specific window types. These are not normally 322 * created by applications. 323 */ 324 public static final int FIRST_SYSTEM_WINDOW = 2000; 325 326 /** 327 * Window type: the status bar. There can be only one status bar 328 * window; it is placed at the top of the screen, and all other 329 * windows are shifted down so they are below it. 330 * In multiuser systems shows on all users' windows. 331 */ 332 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; 333 334 /** 335 * Window type: the search bar. There can be only one search bar 336 * window; it is placed at the top of the screen. 337 * In multiuser systems shows on all users' windows. 338 */ 339 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; 340 341 /** 342 * Window type: phone. These are non-application windows providing 343 * user interaction with the phone (in particular incoming calls). 344 * These windows are normally placed above all applications, but behind 345 * the status bar. 346 * In multiuser systems shows on all users' windows. 347 */ 348 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; 349 350 /** 351 * Window type: system window, such as low power alert. These windows 352 * are always on top of application windows. 353 * In multiuser systems shows only on the owning user's window. 354 */ 355 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; 356 357 /** 358 * Window type: keyguard window. 359 * In multiuser systems shows on all users' windows. 360 * @removed 361 */ 362 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; 363 364 /** 365 * Window type: transient notifications. 366 * In multiuser systems shows only on the owning user's window. 367 */ 368 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; 369 370 /** 371 * Window type: system overlay windows, which need to be displayed 372 * on top of everything else. These windows must not take input 373 * focus, or they will interfere with the keyguard. 374 * In multiuser systems shows only on the owning user's window. 375 */ 376 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; 377 378 /** 379 * Window type: priority phone UI, which needs to be displayed even if 380 * the keyguard is active. These windows must not take input 381 * focus, or they will interfere with the keyguard. 382 * In multiuser systems shows on all users' windows. 383 */ 384 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; 385 386 /** 387 * Window type: panel that slides out from the status bar 388 * In multiuser systems shows on all users' windows. 389 */ 390 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; 391 392 /** 393 * Window type: dialogs that the keyguard shows 394 * In multiuser systems shows on all users' windows. 395 */ 396 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; 397 398 /** 399 * Window type: internal system error windows, appear on top of 400 * everything they can. 401 * In multiuser systems shows only on the owning user's window. 402 */ 403 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; 404 405 /** 406 * Window type: internal input methods windows, which appear above 407 * the normal UI. Application windows may be resized or panned to keep 408 * the input focus visible while this window is displayed. 409 * In multiuser systems shows only on the owning user's window. 410 */ 411 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; 412 413 /** 414 * Window type: internal input methods dialog windows, which appear above 415 * the current input method window. 416 * In multiuser systems shows only on the owning user's window. 417 */ 418 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; 419 420 /** 421 * Window type: wallpaper window, placed behind any window that wants 422 * to sit on top of the wallpaper. 423 * In multiuser systems shows only on the owning user's window. 424 */ 425 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; 426 427 /** 428 * Window type: panel that slides out from over the status bar 429 * In multiuser systems shows on all users' windows. 430 */ 431 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; 432 433 /** 434 * Window type: secure system overlay windows, which need to be displayed 435 * on top of everything else. These windows must not take input 436 * focus, or they will interfere with the keyguard. 437 * 438 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the 439 * system itself is allowed to create these overlays. Applications cannot 440 * obtain permission to create secure system overlays. 441 * 442 * In multiuser systems shows only on the owning user's window. 443 * @hide 444 */ 445 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; 446 447 /** 448 * Window type: the drag-and-drop pseudowindow. There is only one 449 * drag layer (at most), and it is placed on top of all other windows. 450 * In multiuser systems shows only on the owning user's window. 451 * @hide 452 */ 453 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; 454 455 /** 456 * Window type: panel that slides out from under the status bar 457 * In multiuser systems shows on all users' windows. 458 * @hide 459 */ 460 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; 461 462 /** 463 * Window type: (mouse) pointer 464 * In multiuser systems shows on all users' windows. 465 * @hide 466 */ 467 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; 468 469 /** 470 * Window type: Navigation bar (when distinct from status bar) 471 * In multiuser systems shows on all users' windows. 472 * @hide 473 */ 474 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; 475 476 /** 477 * Window type: The volume level overlay/dialog shown when the user 478 * changes the system volume. 479 * In multiuser systems shows on all users' windows. 480 * @hide 481 */ 482 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; 483 484 /** 485 * Window type: The boot progress dialog, goes on top of everything 486 * in the world. 487 * In multiuser systems shows on all users' windows. 488 * @hide 489 */ 490 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; 491 492 /** 493 * Window type: Fake window to consume touch events when the navigation 494 * bar is hidden. 495 * In multiuser systems shows on all users' windows. 496 * @hide 497 */ 498 public static final int TYPE_HIDDEN_NAV_CONSUMER = FIRST_SYSTEM_WINDOW+22; 499 500 /** 501 * Window type: Dreams (screen saver) window, just above keyguard. 502 * In multiuser systems shows only on the owning user's window. 503 * @hide 504 */ 505 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23; 506 507 /** 508 * Window type: Navigation bar panel (when navigation bar is distinct from status bar) 509 * In multiuser systems shows on all users' windows. 510 * @hide 511 */ 512 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; 513 514 /** 515 * Window type: Display overlay window. Used to simulate secondary display devices. 516 * In multiuser systems shows on all users' windows. 517 * @hide 518 */ 519 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; 520 521 /** 522 * Window type: Magnification overlay window. Used to highlight the magnified 523 * portion of a display when accessibility magnification is enabled. 524 * In multiuser systems shows on all users' windows. 525 * @hide 526 */ 527 public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27; 528 529 /** 530 * Window type: keyguard scrim window. Shows if keyguard needs to be restarted. 531 * In multiuser systems shows on all users' windows. 532 * @hide 533 */ 534 public static final int TYPE_KEYGUARD_SCRIM = FIRST_SYSTEM_WINDOW+29; 535 536 /** 537 * Window type: Window for Presentation on top of private 538 * virtual display. 539 */ 540 public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30; 541 542 /** 543 * Window type: Windows in the voice interaction layer. 544 * @hide 545 */ 546 public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31; 547 548 /** 549 * Window type: Windows that are overlaid <em>only</em> by an {@link 550 * android.accessibilityservice.AccessibilityService} for interception of 551 * user interactions without changing the windows an accessibility service 552 * can introspect. In particular, an accessibility service can introspect 553 * only windows that a sighted user can interact with which is they can touch 554 * these windows or can type into these windows. For example, if there 555 * is a full screen accessibility overlay that is touchable, the windows 556 * below it will be introspectable by an accessibility service regardless 557 * they are covered by a touchable window. 558 */ 559 public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32; 560 561 /** 562 * Window type: Starting window for voice interaction layer. 563 * @hide 564 */ 565 public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33; 566 567 /** 568 * End of types of system windows. 569 */ 570 public static final int LAST_SYSTEM_WINDOW = 2999; 571 572 /** @deprecated this is ignored, this value is set automatically when needed. */ 573 @Deprecated 574 public static final int MEMORY_TYPE_NORMAL = 0; 575 /** @deprecated this is ignored, this value is set automatically when needed. */ 576 @Deprecated 577 public static final int MEMORY_TYPE_HARDWARE = 1; 578 /** @deprecated this is ignored, this value is set automatically when needed. */ 579 @Deprecated 580 public static final int MEMORY_TYPE_GPU = 2; 581 /** @deprecated this is ignored, this value is set automatically when needed. */ 582 @Deprecated 583 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 584 585 /** 586 * @deprecated this is ignored 587 */ 588 @Deprecated 589 public int memoryType; 590 591 /** Window flag: as long as this window is visible to the user, allow 592 * the lock screen to activate while the screen is on. 593 * This can be used independently, or in combination with 594 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 595 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 596 597 /** Window flag: everything behind this window will be dimmed. 598 * Use {@link #dimAmount} to control the amount of dim. */ 599 public static final int FLAG_DIM_BEHIND = 0x00000002; 600 601 /** Window flag: blur everything behind this window. 602 * @deprecated Blurring is no longer supported. */ 603 @Deprecated 604 public static final int FLAG_BLUR_BEHIND = 0x00000004; 605 606 /** Window flag: this window won't ever get key input focus, so the 607 * user can not send key or other button events to it. Those will 608 * instead go to whatever focusable window is behind it. This flag 609 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 610 * is explicitly set. 611 * 612 * <p>Setting this flag also implies that the window will not need to 613 * interact with 614 * a soft input method, so it will be Z-ordered and positioned 615 * independently of any active input method (typically this means it 616 * gets Z-ordered on top of the input method, so it can use the full 617 * screen for its content and cover the input method if needed. You 618 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 619 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 620 621 /** Window flag: this window can never receive touch events. */ 622 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 623 624 /** Window flag: even when this window is focusable (its 625 * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events 626 * outside of the window to be sent to the windows behind it. Otherwise 627 * it will consume all pointer events itself, regardless of whether they 628 * are inside of the window. */ 629 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 630 631 /** Window flag: when set, if the device is asleep when the touch 632 * screen is pressed, you will receive this first touch event. Usually 633 * the first touch event is consumed by the system since the user can 634 * not see what they are pressing on. 635 * 636 * @deprecated This flag has no effect. 637 */ 638 @Deprecated 639 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 640 641 /** Window flag: as long as this window is visible to the user, keep 642 * the device's screen turned on and bright. */ 643 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 644 645 /** Window flag: place the window within the entire screen, ignoring 646 * decorations around the border (such as the status bar). The 647 * window must correctly position its contents to take the screen 648 * decoration into account. This flag is normally set for you 649 * by Window as described in {@link Window#setFlags}. */ 650 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 651 652 /** Window flag: allow window to extend outside of the screen. */ 653 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 654 655 /** 656 * Window flag: hide all screen decorations (such as the status bar) while 657 * this window is displayed. This allows the window to use the entire 658 * display space for itself -- the status bar will be hidden when 659 * an app window with this flag set is on the top layer. A fullscreen window 660 * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's 661 * {@link #softInputMode} field; the window will stay fullscreen 662 * and will not resize. 663 * 664 * <p>This flag can be controlled in your theme through the 665 * {@link android.R.attr#windowFullscreen} attribute; this attribute 666 * is automatically set for you in the standard fullscreen themes 667 * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen}, 668 * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen}, 669 * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen}, 670 * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen}, 671 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen}, 672 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and 673 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p> 674 */ 675 public static final int FLAG_FULLSCREEN = 0x00000400; 676 677 /** Window flag: override {@link #FLAG_FULLSCREEN} and force the 678 * screen decorations (such as the status bar) to be shown. */ 679 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 680 681 /** Window flag: turn on dithering when compositing this window to 682 * the screen. 683 * @deprecated This flag is no longer used. */ 684 @Deprecated 685 public static final int FLAG_DITHER = 0x00001000; 686 687 /** Window flag: treat the content of the window as secure, preventing 688 * it from appearing in screenshots or from being viewed on non-secure 689 * displays. 690 * 691 * <p>See {@link android.view.Display#FLAG_SECURE} for more details about 692 * secure surfaces and secure displays. 693 */ 694 public static final int FLAG_SECURE = 0x00002000; 695 696 /** Window flag: a special mode where the layout parameters are used 697 * to perform scaling of the surface when it is composited to the 698 * screen. */ 699 public static final int FLAG_SCALED = 0x00004000; 700 701 /** Window flag: intended for windows that will often be used when the user is 702 * holding the screen against their face, it will aggressively filter the event 703 * stream to prevent unintended presses in this situation that may not be 704 * desired for a particular window, when such an event stream is detected, the 705 * application will receive a CANCEL motion event to indicate this so applications 706 * can handle this accordingly by taking no action on the event 707 * until the finger is released. */ 708 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 709 710 /** Window flag: a special option only for use in combination with 711 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 712 * screen your window may appear on top of or behind screen decorations 713 * such as the status bar. By also including this flag, the window 714 * manager will report the inset rectangle needed to ensure your 715 * content is not covered by screen decorations. This flag is normally 716 * set for you by Window as described in {@link Window#setFlags}.*/ 717 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 718 719 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with 720 * respect to how this window interacts with the current method. That 721 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the 722 * window will behave as if it needs to interact with the input method 723 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is 724 * not set and this flag is set, then the window will behave as if it 725 * doesn't need to interact with the input method and can be placed 726 * to use more space and cover the input method. 727 */ 728 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 729 730 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 731 * can set this flag to receive a single special MotionEvent with 732 * the action 733 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 734 * touches that occur outside of your window. Note that you will not 735 * receive the full down/move/up gesture, only the location of the 736 * first down as an ACTION_OUTSIDE. 737 */ 738 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 739 740 /** Window flag: special flag to let windows be shown when the screen 741 * is locked. This will let application windows take precedence over 742 * key guard or any other lock screens. Can be used with 743 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 744 * directly before showing the key guard window. Can be used with 745 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 746 * non-secure keyguards. This flag only applies to the top-most 747 * full-screen window. 748 */ 749 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 750 751 /** Window flag: ask that the system wallpaper be shown behind 752 * your window. The window surface must be translucent to be able 753 * to actually see the wallpaper behind it; this flag just ensures 754 * that the wallpaper surface will be there if this window actually 755 * has translucent regions. 756 * 757 * <p>This flag can be controlled in your theme through the 758 * {@link android.R.attr#windowShowWallpaper} attribute; this attribute 759 * is automatically set for you in the standard wallpaper themes 760 * such as {@link android.R.style#Theme_Wallpaper}, 761 * {@link android.R.style#Theme_Wallpaper_NoTitleBar}, 762 * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen}, 763 * {@link android.R.style#Theme_Holo_Wallpaper}, 764 * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar}, 765 * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and 766 * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p> 767 */ 768 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 769 770 /** Window flag: when set as a window is being added or made 771 * visible, once the window has been shown then the system will 772 * poke the power manager's user activity (as if the user had woken 773 * up the device) to turn the screen on. */ 774 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 775 776 /** Window flag: when set the window will cause the keyguard to 777 * be dismissed, only if it is not a secure lock keyguard. Because such 778 * a keyguard is not needed for security, it will never re-appear if 779 * the user navigates to another window (in contrast to 780 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily 781 * hide both secure and non-secure keyguards but ensure they reappear 782 * when the user moves to another UI that doesn't hide them). 783 * If the keyguard is currently active and is secure (requires an 784 * unlock pattern) than the user will still need to confirm it before 785 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has 786 * also been set. 787 */ 788 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 789 790 /** Window flag: when set the window will accept for touch events 791 * outside of its bounds to be sent to other windows that also 792 * support split touch. When this flag is not set, the first pointer 793 * that goes down determines the window to which all subsequent touches 794 * go until all pointers go up. When this flag is set, each pointer 795 * (not necessarily the first) that goes down determines the window 796 * to which all subsequent touches of that pointer will go until that 797 * pointer goes up thereby enabling touches with multiple pointers 798 * to be split across multiple windows. 799 */ 800 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 801 802 /** 803 * <p>Indicates whether this window should be hardware accelerated. 804 * Requesting hardware acceleration does not guarantee it will happen.</p> 805 * 806 * <p>This flag can be controlled programmatically <em>only</em> to enable 807 * hardware acceleration. To enable hardware acceleration for a given 808 * window programmatically, do the following:</p> 809 * 810 * <pre> 811 * Window w = activity.getWindow(); // in Activity's onCreate() for instance 812 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 813 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); 814 * </pre> 815 * 816 * <p>It is important to remember that this flag <strong>must</strong> 817 * be set before setting the content view of your activity or dialog.</p> 818 * 819 * <p>This flag cannot be used to disable hardware acceleration after it 820 * was enabled in your manifest using 821 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively 822 * and programmatically disable hardware acceleration (for automated testing 823 * for instance), make sure it is turned off in your manifest and enable it 824 * on your activity or dialog when you need it instead, using the method 825 * described above.</p> 826 * 827 * <p>This flag is automatically set by the system if the 828 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 829 * XML attribute is set to true on an activity or on the application.</p> 830 */ 831 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; 832 833 /** 834 * Window flag: allow window contents to extend in to the screen's 835 * overscan area, if there is one. The window should still correctly 836 * position its contents to take the overscan area into account. 837 * 838 * <p>This flag can be controlled in your theme through the 839 * {@link android.R.attr#windowOverscan} attribute; this attribute 840 * is automatically set for you in the standard overscan themes 841 * such as 842 * {@link android.R.style#Theme_Holo_NoActionBar_Overscan}, 843 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan}, 844 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and 845 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p> 846 * 847 * <p>When this flag is enabled for a window, its normal content may be obscured 848 * to some degree by the overscan region of the display. To ensure key parts of 849 * that content are visible to the user, you can use 850 * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)} 851 * to set the point in the view hierarchy where the appropriate offsets should 852 * be applied. (This can be done either by directly calling this function, using 853 * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy, 854 * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect) 855 * View.fitSystemWindows(Rect)} method).</p> 856 * 857 * <p>This mechanism for positioning content elements is identical to its equivalent 858 * use with layout and {@link View#setSystemUiVisibility(int) 859 * View.setSystemUiVisibility(int)}; here is an example layout that will correctly 860 * position its UI elements with this overscan flag is set:</p> 861 * 862 * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete} 863 */ 864 public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000; 865 866 /** 867 * Window flag: request a translucent status bar with minimal system-provided 868 * background protection. 869 * 870 * <p>This flag can be controlled in your theme through the 871 * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute 872 * is automatically set for you in the standard translucent decor themes 873 * such as 874 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 875 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 876 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 877 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 878 * 879 * <p>When this flag is enabled for a window, it automatically sets 880 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 881 * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p> 882 */ 883 public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000; 884 885 /** 886 * Window flag: request a translucent navigation bar with minimal system-provided 887 * background protection. 888 * 889 * <p>This flag can be controlled in your theme through the 890 * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute 891 * is automatically set for you in the standard translucent decor themes 892 * such as 893 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 894 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 895 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 896 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 897 * 898 * <p>When this flag is enabled for a window, it automatically sets 899 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 900 * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p> 901 */ 902 public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000; 903 904 /** 905 * Flag for a window in local focus mode. 906 * Window in local focus mode can control focus independent of window manager using 907 * {@link Window#setLocalFocus(boolean, boolean)}. 908 * Usually window in this mode will not get touch/key events from window manager, but will 909 * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}. 910 */ 911 public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000; 912 913 /** Window flag: Enable touches to slide out of a window into neighboring 914 * windows in mid-gesture instead of being captured for the duration of 915 * the gesture. 916 * 917 * This flag changes the behavior of touch focus for this window only. 918 * Touches can slide out of the window but they cannot necessarily slide 919 * back in (unless the other window with touch focus permits it). 920 * 921 * {@hide} 922 */ 923 public static final int FLAG_SLIPPERY = 0x20000000; 924 925 /** 926 * Window flag: When requesting layout with an attached window, the attached window may 927 * overlap with the screen decorations of the parent window such as the navigation bar. By 928 * including this flag, the window manager will layout the attached window within the decor 929 * frame of the parent window such that it doesn't overlap with screen decorations. 930 */ 931 public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000; 932 933 /** 934 * Flag indicating that this Window is responsible for drawing the background for the 935 * system bars. If set, the system bars are drawn with a transparent background and the 936 * corresponding areas in this window are filled with the colors specified in 937 * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}. 938 */ 939 public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000; 940 941 /** 942 * Various behavioral options/flags. Default is none. 943 * 944 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 945 * @see #FLAG_DIM_BEHIND 946 * @see #FLAG_NOT_FOCUSABLE 947 * @see #FLAG_NOT_TOUCHABLE 948 * @see #FLAG_NOT_TOUCH_MODAL 949 * @see #FLAG_TOUCHABLE_WHEN_WAKING 950 * @see #FLAG_KEEP_SCREEN_ON 951 * @see #FLAG_LAYOUT_IN_SCREEN 952 * @see #FLAG_LAYOUT_NO_LIMITS 953 * @see #FLAG_FULLSCREEN 954 * @see #FLAG_FORCE_NOT_FULLSCREEN 955 * @see #FLAG_SECURE 956 * @see #FLAG_SCALED 957 * @see #FLAG_IGNORE_CHEEK_PRESSES 958 * @see #FLAG_LAYOUT_INSET_DECOR 959 * @see #FLAG_ALT_FOCUSABLE_IM 960 * @see #FLAG_WATCH_OUTSIDE_TOUCH 961 * @see #FLAG_SHOW_WHEN_LOCKED 962 * @see #FLAG_SHOW_WALLPAPER 963 * @see #FLAG_TURN_SCREEN_ON 964 * @see #FLAG_DISMISS_KEYGUARD 965 * @see #FLAG_SPLIT_TOUCH 966 * @see #FLAG_HARDWARE_ACCELERATED 967 * @see #FLAG_LOCAL_FOCUS_MODE 968 * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 969 */ 970 @ViewDebug.ExportedProperty(flagMapping = { 971 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 972 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), 973 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 974 name = "FLAG_DIM_BEHIND"), 975 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 976 name = "FLAG_BLUR_BEHIND"), 977 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 978 name = "FLAG_NOT_FOCUSABLE"), 979 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 980 name = "FLAG_NOT_TOUCHABLE"), 981 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 982 name = "FLAG_NOT_TOUCH_MODAL"), 983 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING, 984 name = "FLAG_TOUCHABLE_WHEN_WAKING"), 985 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 986 name = "FLAG_KEEP_SCREEN_ON"), 987 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 988 name = "FLAG_LAYOUT_IN_SCREEN"), 989 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS, 990 name = "FLAG_LAYOUT_NO_LIMITS"), 991 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 992 name = "FLAG_FULLSCREEN"), 993 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN, 994 name = "FLAG_FORCE_NOT_FULLSCREEN"), 995 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 996 name = "FLAG_DITHER"), 997 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE, 998 name = "FLAG_SECURE"), 999 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED, 1000 name = "FLAG_SCALED"), 1001 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES, 1002 name = "FLAG_IGNORE_CHEEK_PRESSES"), 1003 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR, 1004 name = "FLAG_LAYOUT_INSET_DECOR"), 1005 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM, 1006 name = "FLAG_ALT_FOCUSABLE_IM"), 1007 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH, 1008 name = "FLAG_WATCH_OUTSIDE_TOUCH"), 1009 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 1010 name = "FLAG_SHOW_WHEN_LOCKED"), 1011 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER, 1012 name = "FLAG_SHOW_WALLPAPER"), 1013 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 1014 name = "FLAG_TURN_SCREEN_ON"), 1015 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 1016 name = "FLAG_DISMISS_KEYGUARD"), 1017 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH, 1018 name = "FLAG_SPLIT_TOUCH"), 1019 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED, 1020 name = "FLAG_HARDWARE_ACCELERATED"), 1021 @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE, 1022 name = "FLAG_LOCAL_FOCUS_MODE"), 1023 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS, 1024 name = "FLAG_TRANSLUCENT_STATUS"), 1025 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION, 1026 name = "FLAG_TRANSLUCENT_NAVIGATION"), 1027 @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, 1028 name = "FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS") 1029 }, formatToHexString = true) 1030 public int flags; 1031 1032 /** 1033 * If the window has requested hardware acceleration, but this is not 1034 * allowed in the process it is in, then still render it as if it is 1035 * hardware accelerated. This is used for the starting preview windows 1036 * in the system process, which don't need to have the overhead of 1037 * hardware acceleration (they are just a static rendering), but should 1038 * be rendered as such to match the actual window of the app even if it 1039 * is hardware accelerated. 1040 * Even if the window isn't hardware accelerated, still do its rendering 1041 * as if it was. 1042 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows 1043 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration 1044 * is generally disabled. This flag must be specified in addition to 1045 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system 1046 * windows. 1047 * 1048 * @hide 1049 */ 1050 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001; 1051 1052 /** 1053 * In the system process, we globally do not use hardware acceleration 1054 * because there are many threads doing UI there and they conflict. 1055 * If certain parts of the UI that really do want to use hardware 1056 * acceleration, this flag can be set to force it. This is basically 1057 * for the lock screen. Anyone else using it, you are probably wrong. 1058 * 1059 * @hide 1060 */ 1061 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002; 1062 1063 /** 1064 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers 1065 * may elect to skip these notifications if they are not doing anything productive with 1066 * them (they do not affect the wallpaper scrolling operation) by calling 1067 * {@link 1068 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}. 1069 * 1070 * @hide 1071 */ 1072 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004; 1073 1074 /** In a multiuser system if this flag is set and the owner is a system process then this 1075 * window will appear on all user screens. This overrides the default behavior of window 1076 * types that normally only appear on the owning user's screen. Refer to each window type 1077 * to determine its default behavior. 1078 * 1079 * {@hide} */ 1080 public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010; 1081 1082 /** 1083 * Never animate position changes of the window. 1084 * 1085 * {@hide} */ 1086 public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040; 1087 1088 /** Window flag: special flag to limit the size of the window to be 1089 * original size ([320x480] x density). Used to create window for applications 1090 * running under compatibility mode. 1091 * 1092 * {@hide} */ 1093 public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080; 1094 1095 /** Window flag: a special option intended for system dialogs. When 1096 * this flag is set, the window will demand focus unconditionally when 1097 * it is created. 1098 * {@hide} */ 1099 public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100; 1100 1101 /** Window flag: maintain the previous translucent decor state when this window 1102 * becomes top-most. 1103 * {@hide} */ 1104 public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200; 1105 1106 /** 1107 * Flag whether the current window is a keyguard window, meaning that it will hide all other 1108 * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set. 1109 * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}. 1110 * {@hide} 1111 */ 1112 public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400; 1113 1114 /** 1115 * Flag that prevents the wallpaper behind the current window from receiving touch events. 1116 * 1117 * {@hide} 1118 */ 1119 public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800; 1120 1121 /** 1122 * Control flags that are private to the platform. 1123 * @hide 1124 */ 1125 public int privateFlags; 1126 1127 /** 1128 * Value for {@link #needsMenuKey} for a window that has not explicitly specified if it 1129 * needs {@link #NEEDS_MENU_SET_TRUE} or doesn't need {@link #NEEDS_MENU_SET_FALSE} a menu 1130 * key. For this case, we should look at windows behind it to determine the appropriate 1131 * value. 1132 * 1133 * @hide 1134 */ 1135 public static final int NEEDS_MENU_UNSET = 0; 1136 1137 /** 1138 * Value for {@link #needsMenuKey} for a window that has explicitly specified it needs a 1139 * menu key. 1140 * 1141 * @hide 1142 */ 1143 public static final int NEEDS_MENU_SET_TRUE = 1; 1144 1145 /** 1146 * Value for {@link #needsMenuKey} for a window that has explicitly specified it doesn't 1147 * needs a menu key. 1148 * 1149 * @hide 1150 */ 1151 public static final int NEEDS_MENU_SET_FALSE = 2; 1152 1153 /** 1154 * State variable for a window belonging to an activity that responds to 1155 * {@link KeyEvent#KEYCODE_MENU} and therefore needs a Menu key. For devices where Menu is a 1156 * physical button this variable is ignored, but on devices where the Menu key is drawn in 1157 * software it may be hidden unless this variable is set to {@link #NEEDS_MENU_SET_TRUE}. 1158 * 1159 * (Note that Action Bars, when available, are the preferred way to offer additional 1160 * functions otherwise accessed via an options menu.) 1161 * 1162 * {@hide} 1163 */ 1164 public int needsMenuKey = NEEDS_MENU_UNSET; 1165 1166 /** 1167 * Given a particular set of window manager flags, determine whether 1168 * such a window may be a target for an input method when it has 1169 * focus. In particular, this checks the 1170 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 1171 * flags and returns true if the combination of the two corresponds 1172 * to a window that needs to be behind the input method so that the 1173 * user can type into it. 1174 * 1175 * @param flags The current window manager flags. 1176 * 1177 * @return Returns true if such a window should be behind/interact 1178 * with an input method, false if not. 1179 */ 1180 public static boolean mayUseInputMethod(int flags) { 1181 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { 1182 case 0: 1183 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: 1184 return true; 1185 } 1186 return false; 1187 } 1188 1189 /** 1190 * Mask for {@link #softInputMode} of the bits that determine the 1191 * desired visibility state of the soft input area for this window. 1192 */ 1193 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 1194 1195 /** 1196 * Visibility state for {@link #softInputMode}: no state has been specified. 1197 */ 1198 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 1199 1200 /** 1201 * Visibility state for {@link #softInputMode}: please don't change the state of 1202 * the soft input area. 1203 */ 1204 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 1205 1206 /** 1207 * Visibility state for {@link #softInputMode}: please hide any soft input 1208 * area when normally appropriate (when the user is navigating 1209 * forward to your window). 1210 */ 1211 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 1212 1213 /** 1214 * Visibility state for {@link #softInputMode}: please always hide any 1215 * soft input area when this window receives focus. 1216 */ 1217 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 1218 1219 /** 1220 * Visibility state for {@link #softInputMode}: please show the soft 1221 * input area when normally appropriate (when the user is navigating 1222 * forward to your window). 1223 */ 1224 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 1225 1226 /** 1227 * Visibility state for {@link #softInputMode}: please always make the 1228 * soft input area visible when this window receives input focus. 1229 */ 1230 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 1231 1232 /** 1233 * Mask for {@link #softInputMode} of the bits that determine the 1234 * way that the window should be adjusted to accommodate the soft 1235 * input window. 1236 */ 1237 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 1238 1239 /** Adjustment option for {@link #softInputMode}: nothing specified. 1240 * The system will try to pick one or 1241 * the other depending on the contents of the window. 1242 */ 1243 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 1244 1245 /** Adjustment option for {@link #softInputMode}: set to allow the 1246 * window to be resized when an input 1247 * method is shown, so that its contents are not covered by the input 1248 * method. This can <em>not</em> be combined with 1249 * {@link #SOFT_INPUT_ADJUST_PAN}; if 1250 * neither of these are set, then the system will try to pick one or 1251 * the other depending on the contents of the window. If the window's 1252 * layout parameter flags include {@link #FLAG_FULLSCREEN}, this 1253 * value for {@link #softInputMode} will be ignored; the window will 1254 * not resize, but will stay fullscreen. 1255 */ 1256 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 1257 1258 /** Adjustment option for {@link #softInputMode}: set to have a window 1259 * pan when an input method is 1260 * shown, so it doesn't need to deal with resizing but just panned 1261 * by the framework to ensure the current input focus is visible. This 1262 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 1263 * neither of these are set, then the system will try to pick one or 1264 * the other depending on the contents of the window. 1265 */ 1266 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 1267 1268 /** Adjustment option for {@link #softInputMode}: set to have a window 1269 * not adjust for a shown input method. The window will not be resized, 1270 * and it will not be panned to make its focus visible. 1271 */ 1272 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 1273 1274 /** 1275 * Bit for {@link #softInputMode}: set when the user has navigated 1276 * forward to the window. This is normally set automatically for 1277 * you by the system, though you may want to set it in certain cases 1278 * when you are displaying a window yourself. This flag will always 1279 * be cleared automatically after the window is displayed. 1280 */ 1281 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 1282 1283 /** 1284 * Desired operating mode for any soft input area. May be any combination 1285 * of: 1286 * 1287 * <ul> 1288 * <li> One of the visibility states 1289 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 1290 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or 1291 * {@link #SOFT_INPUT_STATE_VISIBLE}. 1292 * <li> One of the adjustment options 1293 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, 1294 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or 1295 * {@link #SOFT_INPUT_ADJUST_PAN}. 1296 * </ul> 1297 * 1298 * 1299 * <p>This flag can be controlled in your theme through the 1300 * {@link android.R.attr#windowSoftInputMode} attribute.</p> 1301 */ 1302 public int softInputMode; 1303 1304 /** 1305 * Placement of window within the screen as per {@link Gravity}. Both 1306 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1307 * android.graphics.Rect) Gravity.apply} and 1308 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1309 * Gravity.applyDisplay} are used during window layout, with this value 1310 * given as the desired gravity. For example you can specify 1311 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 1312 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 1313 * to control the behavior of 1314 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1315 * Gravity.applyDisplay}. 1316 * 1317 * @see Gravity 1318 */ 1319 public int gravity; 1320 1321 /** 1322 * The horizontal margin, as a percentage of the container's width, 1323 * between the container and the widget. See 1324 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1325 * android.graphics.Rect) Gravity.apply} for how this is used. This 1326 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 1327 */ 1328 public float horizontalMargin; 1329 1330 /** 1331 * The vertical margin, as a percentage of the container's height, 1332 * between the container and the widget. See 1333 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1334 * android.graphics.Rect) Gravity.apply} for how this is used. This 1335 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 1336 */ 1337 public float verticalMargin; 1338 1339 /** 1340 * Positive insets between the drawing surface and window content. 1341 * 1342 * @hide 1343 */ 1344 public final Rect surfaceInsets = new Rect(); 1345 1346 /** 1347 * Whether the surface insets have been manually set. When set to 1348 * {@code false}, the view root will automatically determine the 1349 * appropriate surface insets. 1350 * 1351 * @see #surfaceInsets 1352 * @hide 1353 */ 1354 public boolean hasManualSurfaceInsets; 1355 1356 /** 1357 * The desired bitmap format. May be one of the constants in 1358 * {@link android.graphics.PixelFormat}. Default is OPAQUE. 1359 */ 1360 public int format; 1361 1362 /** 1363 * A style resource defining the animations to use for this window. 1364 * This must be a system resource; it can not be an application resource 1365 * because the window manager does not have access to applications. 1366 */ 1367 public int windowAnimations; 1368 1369 /** 1370 * An alpha value to apply to this entire window. 1371 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 1372 */ 1373 public float alpha = 1.0f; 1374 1375 /** 1376 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 1377 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 1378 * dim. 1379 */ 1380 public float dimAmount = 1.0f; 1381 1382 /** 1383 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 1384 * indicating that the brightness value is not overridden for this window 1385 * and normal brightness policy should be used. 1386 */ 1387 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 1388 1389 /** 1390 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1391 * indicating that the screen or button backlight brightness should be set 1392 * to the lowest value when this window is in front. 1393 */ 1394 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 1395 1396 /** 1397 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1398 * indicating that the screen or button backlight brightness should be set 1399 * to the hightest value when this window is in front. 1400 */ 1401 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 1402 1403 /** 1404 * This can be used to override the user's preferred brightness of 1405 * the screen. A value of less than 0, the default, means to use the 1406 * preferred screen brightness. 0 to 1 adjusts the brightness from 1407 * dark to full bright. 1408 */ 1409 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 1410 1411 /** 1412 * This can be used to override the standard behavior of the button and 1413 * keyboard backlights. A value of less than 0, the default, means to 1414 * use the standard backlight behavior. 0 to 1 adjusts the brightness 1415 * from dark to full bright. 1416 */ 1417 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 1418 1419 /** 1420 * Value for {@link #rotationAnimation} to define the animation used to 1421 * specify that this window will rotate in or out following a rotation. 1422 */ 1423 public static final int ROTATION_ANIMATION_ROTATE = 0; 1424 1425 /** 1426 * Value for {@link #rotationAnimation} to define the animation used to 1427 * specify that this window will fade in or out following a rotation. 1428 */ 1429 public static final int ROTATION_ANIMATION_CROSSFADE = 1; 1430 1431 /** 1432 * Value for {@link #rotationAnimation} to define the animation used to 1433 * specify that this window will immediately disappear or appear following 1434 * a rotation. 1435 */ 1436 public static final int ROTATION_ANIMATION_JUMPCUT = 2; 1437 1438 /** 1439 * Define the exit and entry animations used on this window when the device is rotated. 1440 * This only has an affect if the incoming and outgoing topmost 1441 * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered 1442 * by other windows. All other situations default to the 1443 * {@link #ROTATION_ANIMATION_ROTATE} behavior. 1444 * 1445 * @see #ROTATION_ANIMATION_ROTATE 1446 * @see #ROTATION_ANIMATION_CROSSFADE 1447 * @see #ROTATION_ANIMATION_JUMPCUT 1448 */ 1449 public int rotationAnimation = ROTATION_ANIMATION_ROTATE; 1450 1451 /** 1452 * Identifier for this window. This will usually be filled in for 1453 * you. 1454 */ 1455 public IBinder token = null; 1456 1457 /** 1458 * Name of the package owning this window. 1459 */ 1460 public String packageName = null; 1461 1462 /** 1463 * Specific orientation value for a window. 1464 * May be any of the same values allowed 1465 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 1466 * If not set, a default value of 1467 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 1468 * will be used. 1469 */ 1470 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 1471 1472 /** 1473 * The preferred refresh rate for the window. 1474 * 1475 * This must be one of the supported refresh rates obtained for the display(s) the window 1476 * is on. 1477 * 1478 * @see Display#getSupportedRefreshRates() 1479 */ 1480 public float preferredRefreshRate; 1481 1482 /** 1483 * Control the visibility of the status bar. 1484 * 1485 * @see View#STATUS_BAR_VISIBLE 1486 * @see View#STATUS_BAR_HIDDEN 1487 */ 1488 public int systemUiVisibility; 1489 1490 /** 1491 * @hide 1492 * The ui visibility as requested by the views in this hierarchy. 1493 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. 1494 */ 1495 public int subtreeSystemUiVisibility; 1496 1497 /** 1498 * Get callbacks about the system ui visibility changing. 1499 * 1500 * TODO: Maybe there should be a bitfield of optional callbacks that we need. 1501 * 1502 * @hide 1503 */ 1504 public boolean hasSystemUiListeners; 1505 1506 /** 1507 * When this window has focus, disable touch pad pointer gesture processing. 1508 * The window will receive raw position updates from the touch pad instead 1509 * of pointer movements and synthetic touch events. 1510 * 1511 * @hide 1512 */ 1513 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001; 1514 1515 /** 1516 * Does not construct an input channel for this window. The channel will therefore 1517 * be incapable of receiving input. 1518 * 1519 * @hide 1520 */ 1521 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002; 1522 1523 /** 1524 * When this window has focus, does not call user activity for all input events so 1525 * the application will have to do it itself. Should only be used by 1526 * the keyguard and phone app. 1527 * <p> 1528 * Should only be used by the keyguard and phone app. 1529 * </p> 1530 * 1531 * @hide 1532 */ 1533 public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004; 1534 1535 /** 1536 * Control special features of the input subsystem. 1537 * 1538 * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES 1539 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL 1540 * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY 1541 * @hide 1542 */ 1543 public int inputFeatures; 1544 1545 /** 1546 * Sets the number of milliseconds before the user activity timeout occurs 1547 * when this window has focus. A value of -1 uses the standard timeout. 1548 * A value of 0 uses the minimum support display timeout. 1549 * <p> 1550 * This property can only be used to reduce the user specified display timeout; 1551 * it can never make the timeout longer than it normally would be. 1552 * </p><p> 1553 * Should only be used by the keyguard and phone app. 1554 * </p> 1555 * 1556 * @hide 1557 */ 1558 public long userActivityTimeout = -1; 1559 1560 public LayoutParams() { 1561 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1562 type = TYPE_APPLICATION; 1563 format = PixelFormat.OPAQUE; 1564 } 1565 1566 public LayoutParams(int _type) { 1567 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1568 type = _type; 1569 format = PixelFormat.OPAQUE; 1570 } 1571 1572 public LayoutParams(int _type, int _flags) { 1573 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1574 type = _type; 1575 flags = _flags; 1576 format = PixelFormat.OPAQUE; 1577 } 1578 1579 public LayoutParams(int _type, int _flags, int _format) { 1580 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1581 type = _type; 1582 flags = _flags; 1583 format = _format; 1584 } 1585 1586 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 1587 super(w, h); 1588 type = _type; 1589 flags = _flags; 1590 format = _format; 1591 } 1592 1593 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 1594 int _flags, int _format) { 1595 super(w, h); 1596 x = xpos; 1597 y = ypos; 1598 type = _type; 1599 flags = _flags; 1600 format = _format; 1601 } 1602 1603 public final void setTitle(CharSequence title) { 1604 if (null == title) 1605 title = ""; 1606 1607 mTitle = TextUtils.stringOrSpannedString(title); 1608 } 1609 1610 public final CharSequence getTitle() { 1611 return mTitle; 1612 } 1613 1614 /** @hide */ 1615 @SystemApi 1616 public final void setUserActivityTimeout(long timeout) { 1617 userActivityTimeout = timeout; 1618 } 1619 1620 /** @hide */ 1621 @SystemApi 1622 public final long getUserActivityTimeout() { 1623 return userActivityTimeout; 1624 } 1625 1626 public int describeContents() { 1627 return 0; 1628 } 1629 1630 public void writeToParcel(Parcel out, int parcelableFlags) { 1631 out.writeInt(width); 1632 out.writeInt(height); 1633 out.writeInt(x); 1634 out.writeInt(y); 1635 out.writeInt(type); 1636 out.writeInt(flags); 1637 out.writeInt(privateFlags); 1638 out.writeInt(softInputMode); 1639 out.writeInt(gravity); 1640 out.writeFloat(horizontalMargin); 1641 out.writeFloat(verticalMargin); 1642 out.writeInt(format); 1643 out.writeInt(windowAnimations); 1644 out.writeFloat(alpha); 1645 out.writeFloat(dimAmount); 1646 out.writeFloat(screenBrightness); 1647 out.writeFloat(buttonBrightness); 1648 out.writeInt(rotationAnimation); 1649 out.writeStrongBinder(token); 1650 out.writeString(packageName); 1651 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 1652 out.writeInt(screenOrientation); 1653 out.writeFloat(preferredRefreshRate); 1654 out.writeInt(systemUiVisibility); 1655 out.writeInt(subtreeSystemUiVisibility); 1656 out.writeInt(hasSystemUiListeners ? 1 : 0); 1657 out.writeInt(inputFeatures); 1658 out.writeLong(userActivityTimeout); 1659 out.writeInt(surfaceInsets.left); 1660 out.writeInt(surfaceInsets.top); 1661 out.writeInt(surfaceInsets.right); 1662 out.writeInt(surfaceInsets.bottom); 1663 out.writeInt(hasManualSurfaceInsets ? 1 : 0); 1664 out.writeInt(needsMenuKey); 1665 } 1666 1667 public static final Parcelable.Creator<LayoutParams> CREATOR 1668 = new Parcelable.Creator<LayoutParams>() { 1669 public LayoutParams createFromParcel(Parcel in) { 1670 return new LayoutParams(in); 1671 } 1672 1673 public LayoutParams[] newArray(int size) { 1674 return new LayoutParams[size]; 1675 } 1676 }; 1677 1678 1679 public LayoutParams(Parcel in) { 1680 width = in.readInt(); 1681 height = in.readInt(); 1682 x = in.readInt(); 1683 y = in.readInt(); 1684 type = in.readInt(); 1685 flags = in.readInt(); 1686 privateFlags = in.readInt(); 1687 softInputMode = in.readInt(); 1688 gravity = in.readInt(); 1689 horizontalMargin = in.readFloat(); 1690 verticalMargin = in.readFloat(); 1691 format = in.readInt(); 1692 windowAnimations = in.readInt(); 1693 alpha = in.readFloat(); 1694 dimAmount = in.readFloat(); 1695 screenBrightness = in.readFloat(); 1696 buttonBrightness = in.readFloat(); 1697 rotationAnimation = in.readInt(); 1698 token = in.readStrongBinder(); 1699 packageName = in.readString(); 1700 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 1701 screenOrientation = in.readInt(); 1702 preferredRefreshRate = in.readFloat(); 1703 systemUiVisibility = in.readInt(); 1704 subtreeSystemUiVisibility = in.readInt(); 1705 hasSystemUiListeners = in.readInt() != 0; 1706 inputFeatures = in.readInt(); 1707 userActivityTimeout = in.readLong(); 1708 surfaceInsets.left = in.readInt(); 1709 surfaceInsets.top = in.readInt(); 1710 surfaceInsets.right = in.readInt(); 1711 surfaceInsets.bottom = in.readInt(); 1712 hasManualSurfaceInsets = in.readInt() != 0; 1713 needsMenuKey = in.readInt(); 1714 } 1715 1716 @SuppressWarnings({"PointlessBitwiseExpression"}) 1717 public static final int LAYOUT_CHANGED = 1<<0; 1718 public static final int TYPE_CHANGED = 1<<1; 1719 public static final int FLAGS_CHANGED = 1<<2; 1720 public static final int FORMAT_CHANGED = 1<<3; 1721 public static final int ANIMATION_CHANGED = 1<<4; 1722 public static final int DIM_AMOUNT_CHANGED = 1<<5; 1723 public static final int TITLE_CHANGED = 1<<6; 1724 public static final int ALPHA_CHANGED = 1<<7; 1725 public static final int MEMORY_TYPE_CHANGED = 1<<8; 1726 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 1727 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 1728 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 1729 public static final int ROTATION_ANIMATION_CHANGED = 1<<12; 1730 /** {@hide} */ 1731 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13; 1732 /** {@hide} */ 1733 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14; 1734 /** {@hide} */ 1735 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15; 1736 /** {@hide} */ 1737 public static final int INPUT_FEATURES_CHANGED = 1<<16; 1738 /** {@hide} */ 1739 public static final int PRIVATE_FLAGS_CHANGED = 1<<17; 1740 /** {@hide} */ 1741 public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18; 1742 /** {@hide} */ 1743 public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19; 1744 /** {@hide} */ 1745 public static final int SURFACE_INSETS_CHANGED = 1<<20; 1746 /** {@hide} */ 1747 public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21; 1748 /** {@hide} */ 1749 public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22; 1750 /** {@hide} */ 1751 public static final int EVERYTHING_CHANGED = 0xffffffff; 1752 1753 // internal buffer to backup/restore parameters under compatibility mode. 1754 private int[] mCompatibilityParamsBackup = null; 1755 1756 public final int copyFrom(LayoutParams o) { 1757 int changes = 0; 1758 1759 if (width != o.width) { 1760 width = o.width; 1761 changes |= LAYOUT_CHANGED; 1762 } 1763 if (height != o.height) { 1764 height = o.height; 1765 changes |= LAYOUT_CHANGED; 1766 } 1767 if (x != o.x) { 1768 x = o.x; 1769 changes |= LAYOUT_CHANGED; 1770 } 1771 if (y != o.y) { 1772 y = o.y; 1773 changes |= LAYOUT_CHANGED; 1774 } 1775 if (horizontalWeight != o.horizontalWeight) { 1776 horizontalWeight = o.horizontalWeight; 1777 changes |= LAYOUT_CHANGED; 1778 } 1779 if (verticalWeight != o.verticalWeight) { 1780 verticalWeight = o.verticalWeight; 1781 changes |= LAYOUT_CHANGED; 1782 } 1783 if (horizontalMargin != o.horizontalMargin) { 1784 horizontalMargin = o.horizontalMargin; 1785 changes |= LAYOUT_CHANGED; 1786 } 1787 if (verticalMargin != o.verticalMargin) { 1788 verticalMargin = o.verticalMargin; 1789 changes |= LAYOUT_CHANGED; 1790 } 1791 if (type != o.type) { 1792 type = o.type; 1793 changes |= TYPE_CHANGED; 1794 } 1795 if (flags != o.flags) { 1796 final int diff = flags ^ o.flags; 1797 if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) { 1798 changes |= TRANSLUCENT_FLAGS_CHANGED; 1799 } 1800 flags = o.flags; 1801 changes |= FLAGS_CHANGED; 1802 } 1803 if (privateFlags != o.privateFlags) { 1804 privateFlags = o.privateFlags; 1805 changes |= PRIVATE_FLAGS_CHANGED; 1806 } 1807 if (softInputMode != o.softInputMode) { 1808 softInputMode = o.softInputMode; 1809 changes |= SOFT_INPUT_MODE_CHANGED; 1810 } 1811 if (gravity != o.gravity) { 1812 gravity = o.gravity; 1813 changes |= LAYOUT_CHANGED; 1814 } 1815 if (format != o.format) { 1816 format = o.format; 1817 changes |= FORMAT_CHANGED; 1818 } 1819 if (windowAnimations != o.windowAnimations) { 1820 windowAnimations = o.windowAnimations; 1821 changes |= ANIMATION_CHANGED; 1822 } 1823 if (token == null) { 1824 // NOTE: token only copied if the recipient doesn't 1825 // already have one. 1826 token = o.token; 1827 } 1828 if (packageName == null) { 1829 // NOTE: packageName only copied if the recipient doesn't 1830 // already have one. 1831 packageName = o.packageName; 1832 } 1833 if (!mTitle.equals(o.mTitle)) { 1834 mTitle = o.mTitle; 1835 changes |= TITLE_CHANGED; 1836 } 1837 if (alpha != o.alpha) { 1838 alpha = o.alpha; 1839 changes |= ALPHA_CHANGED; 1840 } 1841 if (dimAmount != o.dimAmount) { 1842 dimAmount = o.dimAmount; 1843 changes |= DIM_AMOUNT_CHANGED; 1844 } 1845 if (screenBrightness != o.screenBrightness) { 1846 screenBrightness = o.screenBrightness; 1847 changes |= SCREEN_BRIGHTNESS_CHANGED; 1848 } 1849 if (buttonBrightness != o.buttonBrightness) { 1850 buttonBrightness = o.buttonBrightness; 1851 changes |= BUTTON_BRIGHTNESS_CHANGED; 1852 } 1853 if (rotationAnimation != o.rotationAnimation) { 1854 rotationAnimation = o.rotationAnimation; 1855 changes |= ROTATION_ANIMATION_CHANGED; 1856 } 1857 1858 if (screenOrientation != o.screenOrientation) { 1859 screenOrientation = o.screenOrientation; 1860 changes |= SCREEN_ORIENTATION_CHANGED; 1861 } 1862 1863 if (preferredRefreshRate != o.preferredRefreshRate) { 1864 preferredRefreshRate = o.preferredRefreshRate; 1865 changes |= PREFERRED_REFRESH_RATE_CHANGED; 1866 } 1867 1868 if (systemUiVisibility != o.systemUiVisibility 1869 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { 1870 systemUiVisibility = o.systemUiVisibility; 1871 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; 1872 changes |= SYSTEM_UI_VISIBILITY_CHANGED; 1873 } 1874 1875 if (hasSystemUiListeners != o.hasSystemUiListeners) { 1876 hasSystemUiListeners = o.hasSystemUiListeners; 1877 changes |= SYSTEM_UI_LISTENER_CHANGED; 1878 } 1879 1880 if (inputFeatures != o.inputFeatures) { 1881 inputFeatures = o.inputFeatures; 1882 changes |= INPUT_FEATURES_CHANGED; 1883 } 1884 1885 if (userActivityTimeout != o.userActivityTimeout) { 1886 userActivityTimeout = o.userActivityTimeout; 1887 changes |= USER_ACTIVITY_TIMEOUT_CHANGED; 1888 } 1889 1890 if (!surfaceInsets.equals(o.surfaceInsets)) { 1891 surfaceInsets.set(o.surfaceInsets); 1892 changes |= SURFACE_INSETS_CHANGED; 1893 } 1894 1895 if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) { 1896 hasManualSurfaceInsets = o.hasManualSurfaceInsets; 1897 changes |= SURFACE_INSETS_CHANGED; 1898 } 1899 1900 if (needsMenuKey != o.needsMenuKey) { 1901 needsMenuKey = o.needsMenuKey; 1902 changes |= NEEDS_MENU_KEY_CHANGED; 1903 } 1904 1905 return changes; 1906 } 1907 1908 @Override 1909 public String debug(String output) { 1910 output += "Contents of " + this + ":"; 1911 Log.d("Debug", output); 1912 output = super.debug(""); 1913 Log.d("Debug", output); 1914 Log.d("Debug", ""); 1915 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 1916 return ""; 1917 } 1918 1919 @Override 1920 public String toString() { 1921 StringBuilder sb = new StringBuilder(256); 1922 sb.append("WM.LayoutParams{"); 1923 sb.append("("); 1924 sb.append(x); 1925 sb.append(','); 1926 sb.append(y); 1927 sb.append(")("); 1928 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width))); 1929 sb.append('x'); 1930 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height))); 1931 sb.append(")"); 1932 if (horizontalMargin != 0) { 1933 sb.append(" hm="); 1934 sb.append(horizontalMargin); 1935 } 1936 if (verticalMargin != 0) { 1937 sb.append(" vm="); 1938 sb.append(verticalMargin); 1939 } 1940 if (gravity != 0) { 1941 sb.append(" gr=#"); 1942 sb.append(Integer.toHexString(gravity)); 1943 } 1944 if (softInputMode != 0) { 1945 sb.append(" sim=#"); 1946 sb.append(Integer.toHexString(softInputMode)); 1947 } 1948 sb.append(" ty="); 1949 sb.append(type); 1950 sb.append(" fl=#"); 1951 sb.append(Integer.toHexString(flags)); 1952 if (privateFlags != 0) { 1953 if ((privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0) { 1954 sb.append(" compatible=true"); 1955 } 1956 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags)); 1957 } 1958 if (format != PixelFormat.OPAQUE) { 1959 sb.append(" fmt="); 1960 sb.append(format); 1961 } 1962 if (windowAnimations != 0) { 1963 sb.append(" wanim=0x"); 1964 sb.append(Integer.toHexString(windowAnimations)); 1965 } 1966 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 1967 sb.append(" or="); 1968 sb.append(screenOrientation); 1969 } 1970 if (alpha != 1.0f) { 1971 sb.append(" alpha="); 1972 sb.append(alpha); 1973 } 1974 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1975 sb.append(" sbrt="); 1976 sb.append(screenBrightness); 1977 } 1978 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 1979 sb.append(" bbrt="); 1980 sb.append(buttonBrightness); 1981 } 1982 if (rotationAnimation != ROTATION_ANIMATION_ROTATE) { 1983 sb.append(" rotAnim="); 1984 sb.append(rotationAnimation); 1985 } 1986 if (preferredRefreshRate != 0) { 1987 sb.append(" preferredRefreshRate="); 1988 sb.append(preferredRefreshRate); 1989 } 1990 if (systemUiVisibility != 0) { 1991 sb.append(" sysui=0x"); 1992 sb.append(Integer.toHexString(systemUiVisibility)); 1993 } 1994 if (subtreeSystemUiVisibility != 0) { 1995 sb.append(" vsysui=0x"); 1996 sb.append(Integer.toHexString(subtreeSystemUiVisibility)); 1997 } 1998 if (hasSystemUiListeners) { 1999 sb.append(" sysuil="); 2000 sb.append(hasSystemUiListeners); 2001 } 2002 if (inputFeatures != 0) { 2003 sb.append(" if=0x").append(Integer.toHexString(inputFeatures)); 2004 } 2005 if (userActivityTimeout >= 0) { 2006 sb.append(" userActivityTimeout=").append(userActivityTimeout); 2007 } 2008 if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 || 2009 surfaceInsets.bottom != 0 || hasManualSurfaceInsets) { 2010 sb.append(" surfaceInsets=").append(surfaceInsets); 2011 if (hasManualSurfaceInsets) { 2012 sb.append(" (manual)"); 2013 } 2014 } 2015 if (needsMenuKey != NEEDS_MENU_UNSET) { 2016 sb.append(" needsMenuKey="); 2017 sb.append(needsMenuKey); 2018 } 2019 sb.append('}'); 2020 return sb.toString(); 2021 } 2022 2023 /** 2024 * Scale the layout params' coordinates and size. 2025 * @hide 2026 */ 2027 public void scale(float scale) { 2028 x = (int) (x * scale + 0.5f); 2029 y = (int) (y * scale + 0.5f); 2030 if (width > 0) { 2031 width = (int) (width * scale + 0.5f); 2032 } 2033 if (height > 0) { 2034 height = (int) (height * scale + 0.5f); 2035 } 2036 } 2037 2038 /** 2039 * Backup the layout parameters used in compatibility mode. 2040 * @see LayoutParams#restore() 2041 */ 2042 void backup() { 2043 int[] backup = mCompatibilityParamsBackup; 2044 if (backup == null) { 2045 // we backup 4 elements, x, y, width, height 2046 backup = mCompatibilityParamsBackup = new int[4]; 2047 } 2048 backup[0] = x; 2049 backup[1] = y; 2050 backup[2] = width; 2051 backup[3] = height; 2052 } 2053 2054 /** 2055 * Restore the layout params' coordinates, size and gravity 2056 * @see LayoutParams#backup() 2057 */ 2058 void restore() { 2059 int[] backup = mCompatibilityParamsBackup; 2060 if (backup != null) { 2061 x = backup[0]; 2062 y = backup[1]; 2063 width = backup[2]; 2064 height = backup[3]; 2065 } 2066 } 2067 2068 private CharSequence mTitle = ""; 2069 } 2070} 2071