WindowManager.java revision f83e824216435e45f36a3587e269888f791b2a01
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.NonNull; 20import android.annotation.SystemApi; 21import android.app.Presentation; 22import android.content.Context; 23import android.content.pm.ActivityInfo; 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_INPUT_CONSUMER, to = "TYPE_INPUT_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 to consume input events when the systemUI bars are hidden. 494 * In multiuser systems shows on all users' windows. 495 * @hide 496 */ 497 public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22; 498 499 /** 500 * Window type: Dreams (screen saver) window, just above keyguard. 501 * In multiuser systems shows only on the owning user's window. 502 * @hide 503 */ 504 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23; 505 506 /** 507 * Window type: Navigation bar panel (when navigation bar is distinct from status bar) 508 * In multiuser systems shows on all users' windows. 509 * @hide 510 */ 511 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; 512 513 /** 514 * Window type: Display overlay window. Used to simulate secondary display devices. 515 * In multiuser systems shows on all users' windows. 516 * @hide 517 */ 518 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; 519 520 /** 521 * Window type: Magnification overlay window. Used to highlight the magnified 522 * portion of a display when accessibility magnification is enabled. 523 * In multiuser systems shows on all users' windows. 524 * @hide 525 */ 526 public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27; 527 528 /** 529 * Window type: keyguard scrim window. Shows if keyguard needs to be restarted. 530 * In multiuser systems shows on all users' windows. 531 * @hide 532 */ 533 public static final int TYPE_KEYGUARD_SCRIM = FIRST_SYSTEM_WINDOW+29; 534 535 /** 536 * Window type: Window for Presentation on top of private 537 * virtual display. 538 */ 539 public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30; 540 541 /** 542 * Window type: Windows in the voice interaction layer. 543 * @hide 544 */ 545 public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31; 546 547 /** 548 * Window type: Windows that are overlaid <em>only</em> by an {@link 549 * android.accessibilityservice.AccessibilityService} for interception of 550 * user interactions without changing the windows an accessibility service 551 * can introspect. In particular, an accessibility service can introspect 552 * only windows that a sighted user can interact with which is they can touch 553 * these windows or can type into these windows. For example, if there 554 * is a full screen accessibility overlay that is touchable, the windows 555 * below it will be introspectable by an accessibility service regardless 556 * they are covered by a touchable window. 557 */ 558 public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32; 559 560 /** 561 * Window type: Starting window for voice interaction layer. 562 * @hide 563 */ 564 public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33; 565 566 /** 567 * End of types of system windows. 568 */ 569 public static final int LAST_SYSTEM_WINDOW = 2999; 570 571 /** @deprecated this is ignored, this value is set automatically when needed. */ 572 @Deprecated 573 public static final int MEMORY_TYPE_NORMAL = 0; 574 /** @deprecated this is ignored, this value is set automatically when needed. */ 575 @Deprecated 576 public static final int MEMORY_TYPE_HARDWARE = 1; 577 /** @deprecated this is ignored, this value is set automatically when needed. */ 578 @Deprecated 579 public static final int MEMORY_TYPE_GPU = 2; 580 /** @deprecated this is ignored, this value is set automatically when needed. */ 581 @Deprecated 582 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 583 584 /** 585 * @deprecated this is ignored 586 */ 587 @Deprecated 588 public int memoryType; 589 590 /** Window flag: as long as this window is visible to the user, allow 591 * the lock screen to activate while the screen is on. 592 * This can be used independently, or in combination with 593 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 594 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 595 596 /** Window flag: everything behind this window will be dimmed. 597 * Use {@link #dimAmount} to control the amount of dim. */ 598 public static final int FLAG_DIM_BEHIND = 0x00000002; 599 600 /** Window flag: blur everything behind this window. 601 * @deprecated Blurring is no longer supported. */ 602 @Deprecated 603 public static final int FLAG_BLUR_BEHIND = 0x00000004; 604 605 /** Window flag: this window won't ever get key input focus, so the 606 * user can not send key or other button events to it. Those will 607 * instead go to whatever focusable window is behind it. This flag 608 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 609 * is explicitly set. 610 * 611 * <p>Setting this flag also implies that the window will not need to 612 * interact with 613 * a soft input method, so it will be Z-ordered and positioned 614 * independently of any active input method (typically this means it 615 * gets Z-ordered on top of the input method, so it can use the full 616 * screen for its content and cover the input method if needed. You 617 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 618 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 619 620 /** Window flag: this window can never receive touch events. */ 621 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 622 623 /** Window flag: even when this window is focusable (its 624 * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events 625 * outside of the window to be sent to the windows behind it. Otherwise 626 * it will consume all pointer events itself, regardless of whether they 627 * are inside of the window. */ 628 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 629 630 /** Window flag: when set, if the device is asleep when the touch 631 * screen is pressed, you will receive this first touch event. Usually 632 * the first touch event is consumed by the system since the user can 633 * not see what they are pressing on. 634 * 635 * @deprecated This flag has no effect. 636 */ 637 @Deprecated 638 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 639 640 /** Window flag: as long as this window is visible to the user, keep 641 * the device's screen turned on and bright. */ 642 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 643 644 /** Window flag: place the window within the entire screen, ignoring 645 * decorations around the border (such as the status bar). The 646 * window must correctly position its contents to take the screen 647 * decoration into account. This flag is normally set for you 648 * by Window as described in {@link Window#setFlags}. */ 649 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 650 651 /** Window flag: allow window to extend outside of the screen. */ 652 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 653 654 /** 655 * Window flag: hide all screen decorations (such as the status bar) while 656 * this window is displayed. This allows the window to use the entire 657 * display space for itself -- the status bar will be hidden when 658 * an app window with this flag set is on the top layer. A fullscreen window 659 * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's 660 * {@link #softInputMode} field; the window will stay fullscreen 661 * and will not resize. 662 * 663 * <p>This flag can be controlled in your theme through the 664 * {@link android.R.attr#windowFullscreen} attribute; this attribute 665 * is automatically set for you in the standard fullscreen themes 666 * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen}, 667 * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen}, 668 * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen}, 669 * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen}, 670 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen}, 671 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and 672 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p> 673 */ 674 public static final int FLAG_FULLSCREEN = 0x00000400; 675 676 /** Window flag: override {@link #FLAG_FULLSCREEN} and force the 677 * screen decorations (such as the status bar) to be shown. */ 678 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 679 680 /** Window flag: turn on dithering when compositing this window to 681 * the screen. 682 * @deprecated This flag is no longer used. */ 683 @Deprecated 684 public static final int FLAG_DITHER = 0x00001000; 685 686 /** Window flag: treat the content of the window as secure, preventing 687 * it from appearing in screenshots or from being viewed on non-secure 688 * displays. 689 * 690 * <p>See {@link android.view.Display#FLAG_SECURE} for more details about 691 * secure surfaces and secure displays. 692 */ 693 public static final int FLAG_SECURE = 0x00002000; 694 695 /** Window flag: a special mode where the layout parameters are used 696 * to perform scaling of the surface when it is composited to the 697 * screen. */ 698 public static final int FLAG_SCALED = 0x00004000; 699 700 /** Window flag: intended for windows that will often be used when the user is 701 * holding the screen against their face, it will aggressively filter the event 702 * stream to prevent unintended presses in this situation that may not be 703 * desired for a particular window, when such an event stream is detected, the 704 * application will receive a CANCEL motion event to indicate this so applications 705 * can handle this accordingly by taking no action on the event 706 * until the finger is released. */ 707 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 708 709 /** Window flag: a special option only for use in combination with 710 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 711 * screen your window may appear on top of or behind screen decorations 712 * such as the status bar. By also including this flag, the window 713 * manager will report the inset rectangle needed to ensure your 714 * content is not covered by screen decorations. This flag is normally 715 * set for you by Window as described in {@link Window#setFlags}.*/ 716 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 717 718 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with 719 * respect to how this window interacts with the current method. That 720 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the 721 * window will behave as if it needs to interact with the input method 722 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is 723 * not set and this flag is set, then the window will behave as if it 724 * doesn't need to interact with the input method and can be placed 725 * to use more space and cover the input method. 726 */ 727 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 728 729 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 730 * can set this flag to receive a single special MotionEvent with 731 * the action 732 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 733 * touches that occur outside of your window. Note that you will not 734 * receive the full down/move/up gesture, only the location of the 735 * first down as an ACTION_OUTSIDE. 736 */ 737 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 738 739 /** Window flag: special flag to let windows be shown when the screen 740 * is locked. This will let application windows take precedence over 741 * key guard or any other lock screens. Can be used with 742 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 743 * directly before showing the key guard window. Can be used with 744 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 745 * non-secure keyguards. This flag only applies to the top-most 746 * full-screen window. 747 */ 748 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 749 750 /** Window flag: ask that the system wallpaper be shown behind 751 * your window. The window surface must be translucent to be able 752 * to actually see the wallpaper behind it; this flag just ensures 753 * that the wallpaper surface will be there if this window actually 754 * has translucent regions. 755 * 756 * <p>This flag can be controlled in your theme through the 757 * {@link android.R.attr#windowShowWallpaper} attribute; this attribute 758 * is automatically set for you in the standard wallpaper themes 759 * such as {@link android.R.style#Theme_Wallpaper}, 760 * {@link android.R.style#Theme_Wallpaper_NoTitleBar}, 761 * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen}, 762 * {@link android.R.style#Theme_Holo_Wallpaper}, 763 * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar}, 764 * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and 765 * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p> 766 */ 767 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 768 769 /** Window flag: when set as a window is being added or made 770 * visible, once the window has been shown then the system will 771 * poke the power manager's user activity (as if the user had woken 772 * up the device) to turn the screen on. */ 773 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 774 775 /** Window flag: when set the window will cause the keyguard to 776 * be dismissed, only if it is not a secure lock keyguard. Because such 777 * a keyguard is not needed for security, it will never re-appear if 778 * the user navigates to another window (in contrast to 779 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily 780 * hide both secure and non-secure keyguards but ensure they reappear 781 * when the user moves to another UI that doesn't hide them). 782 * If the keyguard is currently active and is secure (requires an 783 * unlock pattern) than the user will still need to confirm it before 784 * seeing this window, unless {@link #FLAG_SHOW_WHEN_LOCKED} has 785 * also been set. 786 */ 787 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 788 789 /** Window flag: when set the window will accept for touch events 790 * outside of its bounds to be sent to other windows that also 791 * support split touch. When this flag is not set, the first pointer 792 * that goes down determines the window to which all subsequent touches 793 * go until all pointers go up. When this flag is set, each pointer 794 * (not necessarily the first) that goes down determines the window 795 * to which all subsequent touches of that pointer will go until that 796 * pointer goes up thereby enabling touches with multiple pointers 797 * to be split across multiple windows. 798 */ 799 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 800 801 /** 802 * <p>Indicates whether this window should be hardware accelerated. 803 * Requesting hardware acceleration does not guarantee it will happen.</p> 804 * 805 * <p>This flag can be controlled programmatically <em>only</em> to enable 806 * hardware acceleration. To enable hardware acceleration for a given 807 * window programmatically, do the following:</p> 808 * 809 * <pre> 810 * Window w = activity.getWindow(); // in Activity's onCreate() for instance 811 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 812 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); 813 * </pre> 814 * 815 * <p>It is important to remember that this flag <strong>must</strong> 816 * be set before setting the content view of your activity or dialog.</p> 817 * 818 * <p>This flag cannot be used to disable hardware acceleration after it 819 * was enabled in your manifest using 820 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively 821 * and programmatically disable hardware acceleration (for automated testing 822 * for instance), make sure it is turned off in your manifest and enable it 823 * on your activity or dialog when you need it instead, using the method 824 * described above.</p> 825 * 826 * <p>This flag is automatically set by the system if the 827 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 828 * XML attribute is set to true on an activity or on the application.</p> 829 */ 830 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; 831 832 /** 833 * Window flag: allow window contents to extend in to the screen's 834 * overscan area, if there is one. The window should still correctly 835 * position its contents to take the overscan area into account. 836 * 837 * <p>This flag can be controlled in your theme through the 838 * {@link android.R.attr#windowOverscan} attribute; this attribute 839 * is automatically set for you in the standard overscan themes 840 * such as 841 * {@link android.R.style#Theme_Holo_NoActionBar_Overscan}, 842 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan}, 843 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and 844 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p> 845 * 846 * <p>When this flag is enabled for a window, its normal content may be obscured 847 * to some degree by the overscan region of the display. To ensure key parts of 848 * that content are visible to the user, you can use 849 * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)} 850 * to set the point in the view hierarchy where the appropriate offsets should 851 * be applied. (This can be done either by directly calling this function, using 852 * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy, 853 * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect) 854 * View.fitSystemWindows(Rect)} method).</p> 855 * 856 * <p>This mechanism for positioning content elements is identical to its equivalent 857 * use with layout and {@link View#setSystemUiVisibility(int) 858 * View.setSystemUiVisibility(int)}; here is an example layout that will correctly 859 * position its UI elements with this overscan flag is set:</p> 860 * 861 * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete} 862 */ 863 public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000; 864 865 /** 866 * Window flag: request a translucent status bar with minimal system-provided 867 * background protection. 868 * 869 * <p>This flag can be controlled in your theme through the 870 * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute 871 * is automatically set for you in the standard translucent decor themes 872 * such as 873 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 874 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 875 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 876 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 877 * 878 * <p>When this flag is enabled for a window, it automatically sets 879 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 880 * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p> 881 */ 882 public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000; 883 884 /** 885 * Window flag: request a translucent navigation bar with minimal system-provided 886 * background protection. 887 * 888 * <p>This flag can be controlled in your theme through the 889 * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute 890 * is automatically set for you in the standard translucent decor themes 891 * such as 892 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 893 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 894 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 895 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 896 * 897 * <p>When this flag is enabled for a window, it automatically sets 898 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 899 * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p> 900 */ 901 public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000; 902 903 /** 904 * Flag for a window in local focus mode. 905 * Window in local focus mode can control focus independent of window manager using 906 * {@link Window#setLocalFocus(boolean, boolean)}. 907 * Usually window in this mode will not get touch/key events from window manager, but will 908 * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}. 909 */ 910 public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000; 911 912 /** Window flag: Enable touches to slide out of a window into neighboring 913 * windows in mid-gesture instead of being captured for the duration of 914 * the gesture. 915 * 916 * This flag changes the behavior of touch focus for this window only. 917 * Touches can slide out of the window but they cannot necessarily slide 918 * back in (unless the other window with touch focus permits it). 919 * 920 * {@hide} 921 */ 922 public static final int FLAG_SLIPPERY = 0x20000000; 923 924 /** 925 * Window flag: When requesting layout with an attached window, the attached window may 926 * overlap with the screen decorations of the parent window such as the navigation bar. By 927 * including this flag, the window manager will layout the attached window within the decor 928 * frame of the parent window such that it doesn't overlap with screen decorations. 929 */ 930 public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000; 931 932 /** 933 * Flag indicating that this Window is responsible for drawing the background for the 934 * system bars. If set, the system bars are drawn with a transparent background and the 935 * corresponding areas in this window are filled with the colors specified in 936 * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}. 937 */ 938 public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000; 939 940 /** 941 * Various behavioral options/flags. Default is none. 942 * 943 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 944 * @see #FLAG_DIM_BEHIND 945 * @see #FLAG_NOT_FOCUSABLE 946 * @see #FLAG_NOT_TOUCHABLE 947 * @see #FLAG_NOT_TOUCH_MODAL 948 * @see #FLAG_TOUCHABLE_WHEN_WAKING 949 * @see #FLAG_KEEP_SCREEN_ON 950 * @see #FLAG_LAYOUT_IN_SCREEN 951 * @see #FLAG_LAYOUT_NO_LIMITS 952 * @see #FLAG_FULLSCREEN 953 * @see #FLAG_FORCE_NOT_FULLSCREEN 954 * @see #FLAG_SECURE 955 * @see #FLAG_SCALED 956 * @see #FLAG_IGNORE_CHEEK_PRESSES 957 * @see #FLAG_LAYOUT_INSET_DECOR 958 * @see #FLAG_ALT_FOCUSABLE_IM 959 * @see #FLAG_WATCH_OUTSIDE_TOUCH 960 * @see #FLAG_SHOW_WHEN_LOCKED 961 * @see #FLAG_SHOW_WALLPAPER 962 * @see #FLAG_TURN_SCREEN_ON 963 * @see #FLAG_DISMISS_KEYGUARD 964 * @see #FLAG_SPLIT_TOUCH 965 * @see #FLAG_HARDWARE_ACCELERATED 966 * @see #FLAG_LOCAL_FOCUS_MODE 967 * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 968 */ 969 @ViewDebug.ExportedProperty(flagMapping = { 970 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 971 name = "FLAG_ALLOW_LOCK_WHILE_SCREEN_ON"), 972 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 973 name = "FLAG_DIM_BEHIND"), 974 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 975 name = "FLAG_BLUR_BEHIND"), 976 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 977 name = "FLAG_NOT_FOCUSABLE"), 978 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 979 name = "FLAG_NOT_TOUCHABLE"), 980 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 981 name = "FLAG_NOT_TOUCH_MODAL"), 982 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING, 983 name = "FLAG_TOUCHABLE_WHEN_WAKING"), 984 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 985 name = "FLAG_KEEP_SCREEN_ON"), 986 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 987 name = "FLAG_LAYOUT_IN_SCREEN"), 988 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS, 989 name = "FLAG_LAYOUT_NO_LIMITS"), 990 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 991 name = "FLAG_FULLSCREEN"), 992 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN, 993 name = "FLAG_FORCE_NOT_FULLSCREEN"), 994 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 995 name = "FLAG_DITHER"), 996 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE, 997 name = "FLAG_SECURE"), 998 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED, 999 name = "FLAG_SCALED"), 1000 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES, 1001 name = "FLAG_IGNORE_CHEEK_PRESSES"), 1002 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR, 1003 name = "FLAG_LAYOUT_INSET_DECOR"), 1004 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM, 1005 name = "FLAG_ALT_FOCUSABLE_IM"), 1006 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH, 1007 name = "FLAG_WATCH_OUTSIDE_TOUCH"), 1008 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 1009 name = "FLAG_SHOW_WHEN_LOCKED"), 1010 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER, 1011 name = "FLAG_SHOW_WALLPAPER"), 1012 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 1013 name = "FLAG_TURN_SCREEN_ON"), 1014 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 1015 name = "FLAG_DISMISS_KEYGUARD"), 1016 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH, 1017 name = "FLAG_SPLIT_TOUCH"), 1018 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED, 1019 name = "FLAG_HARDWARE_ACCELERATED"), 1020 @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE, 1021 name = "FLAG_LOCAL_FOCUS_MODE"), 1022 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS, 1023 name = "FLAG_TRANSLUCENT_STATUS"), 1024 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION, 1025 name = "FLAG_TRANSLUCENT_NAVIGATION"), 1026 @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, 1027 name = "FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS") 1028 }, formatToHexString = true) 1029 public int flags; 1030 1031 /** 1032 * If the window has requested hardware acceleration, but this is not 1033 * allowed in the process it is in, then still render it as if it is 1034 * hardware accelerated. This is used for the starting preview windows 1035 * in the system process, which don't need to have the overhead of 1036 * hardware acceleration (they are just a static rendering), but should 1037 * be rendered as such to match the actual window of the app even if it 1038 * is hardware accelerated. 1039 * Even if the window isn't hardware accelerated, still do its rendering 1040 * as if it was. 1041 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows 1042 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration 1043 * is generally disabled. This flag must be specified in addition to 1044 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system 1045 * windows. 1046 * 1047 * @hide 1048 */ 1049 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001; 1050 1051 /** 1052 * In the system process, we globally do not use hardware acceleration 1053 * because there are many threads doing UI there and they conflict. 1054 * If certain parts of the UI that really do want to use hardware 1055 * acceleration, this flag can be set to force it. This is basically 1056 * for the lock screen. Anyone else using it, you are probably wrong. 1057 * 1058 * @hide 1059 */ 1060 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002; 1061 1062 /** 1063 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers 1064 * may elect to skip these notifications if they are not doing anything productive with 1065 * them (they do not affect the wallpaper scrolling operation) by calling 1066 * {@link 1067 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}. 1068 * 1069 * @hide 1070 */ 1071 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004; 1072 1073 /** In a multiuser system if this flag is set and the owner is a system process then this 1074 * window will appear on all user screens. This overrides the default behavior of window 1075 * types that normally only appear on the owning user's screen. Refer to each window type 1076 * to determine its default behavior. 1077 * 1078 * {@hide} */ 1079 public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010; 1080 1081 /** 1082 * Never animate position changes of the window. 1083 * 1084 * {@hide} */ 1085 public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040; 1086 1087 /** Window flag: special flag to limit the size of the window to be 1088 * original size ([320x480] x density). Used to create window for applications 1089 * running under compatibility mode. 1090 * 1091 * {@hide} */ 1092 public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080; 1093 1094 /** Window flag: a special option intended for system dialogs. When 1095 * this flag is set, the window will demand focus unconditionally when 1096 * it is created. 1097 * {@hide} */ 1098 public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100; 1099 1100 /** Window flag: maintain the previous translucent decor state when this window 1101 * becomes top-most. 1102 * {@hide} */ 1103 public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200; 1104 1105 /** 1106 * Flag whether the current window is a keyguard window, meaning that it will hide all other 1107 * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set. 1108 * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}. 1109 * {@hide} 1110 */ 1111 public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400; 1112 1113 /** 1114 * Flag that prevents the wallpaper behind the current window from receiving touch events. 1115 * 1116 * {@hide} 1117 */ 1118 public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800; 1119 1120 /** 1121 * Flag to force the status bar window to be visible all the time. If the bar is hidden when 1122 * this flag is set it will be shown again and the bar will have a transparent background. 1123 * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}. 1124 * 1125 * {@hide} 1126 */ 1127 public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000; 1128 1129 /** 1130 * Control flags that are private to the platform. 1131 * @hide 1132 */ 1133 public int privateFlags; 1134 1135 /** 1136 * Value for {@link #needsMenuKey} for a window that has not explicitly specified if it 1137 * needs {@link #NEEDS_MENU_SET_TRUE} or doesn't need {@link #NEEDS_MENU_SET_FALSE} a menu 1138 * key. For this case, we should look at windows behind it to determine the appropriate 1139 * value. 1140 * 1141 * @hide 1142 */ 1143 public static final int NEEDS_MENU_UNSET = 0; 1144 1145 /** 1146 * Value for {@link #needsMenuKey} for a window that has explicitly specified it needs a 1147 * menu key. 1148 * 1149 * @hide 1150 */ 1151 public static final int NEEDS_MENU_SET_TRUE = 1; 1152 1153 /** 1154 * Value for {@link #needsMenuKey} for a window that has explicitly specified it doesn't 1155 * needs a menu key. 1156 * 1157 * @hide 1158 */ 1159 public static final int NEEDS_MENU_SET_FALSE = 2; 1160 1161 /** 1162 * State variable for a window belonging to an activity that responds to 1163 * {@link KeyEvent#KEYCODE_MENU} and therefore needs a Menu key. For devices where Menu is a 1164 * physical button this variable is ignored, but on devices where the Menu key is drawn in 1165 * software it may be hidden unless this variable is set to {@link #NEEDS_MENU_SET_TRUE}. 1166 * 1167 * (Note that Action Bars, when available, are the preferred way to offer additional 1168 * functions otherwise accessed via an options menu.) 1169 * 1170 * {@hide} 1171 */ 1172 public int needsMenuKey = NEEDS_MENU_UNSET; 1173 1174 /** 1175 * Given a particular set of window manager flags, determine whether 1176 * such a window may be a target for an input method when it has 1177 * focus. In particular, this checks the 1178 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 1179 * flags and returns true if the combination of the two corresponds 1180 * to a window that needs to be behind the input method so that the 1181 * user can type into it. 1182 * 1183 * @param flags The current window manager flags. 1184 * 1185 * @return Returns true if such a window should be behind/interact 1186 * with an input method, false if not. 1187 */ 1188 public static boolean mayUseInputMethod(int flags) { 1189 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { 1190 case 0: 1191 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: 1192 return true; 1193 } 1194 return false; 1195 } 1196 1197 /** 1198 * Mask for {@link #softInputMode} of the bits that determine the 1199 * desired visibility state of the soft input area for this window. 1200 */ 1201 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 1202 1203 /** 1204 * Visibility state for {@link #softInputMode}: no state has been specified. 1205 */ 1206 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 1207 1208 /** 1209 * Visibility state for {@link #softInputMode}: please don't change the state of 1210 * the soft input area. 1211 */ 1212 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 1213 1214 /** 1215 * Visibility state for {@link #softInputMode}: please hide any soft input 1216 * area when normally appropriate (when the user is navigating 1217 * forward to your window). 1218 */ 1219 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 1220 1221 /** 1222 * Visibility state for {@link #softInputMode}: please always hide any 1223 * soft input area when this window receives focus. 1224 */ 1225 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 1226 1227 /** 1228 * Visibility state for {@link #softInputMode}: please show the soft 1229 * input area when normally appropriate (when the user is navigating 1230 * forward to your window). 1231 */ 1232 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 1233 1234 /** 1235 * Visibility state for {@link #softInputMode}: please always make the 1236 * soft input area visible when this window receives input focus. 1237 */ 1238 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 1239 1240 /** 1241 * Mask for {@link #softInputMode} of the bits that determine the 1242 * way that the window should be adjusted to accommodate the soft 1243 * input window. 1244 */ 1245 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 1246 1247 /** Adjustment option for {@link #softInputMode}: nothing specified. 1248 * The system will try to pick one or 1249 * the other depending on the contents of the window. 1250 */ 1251 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 1252 1253 /** Adjustment option for {@link #softInputMode}: set to allow the 1254 * window to be resized when an input 1255 * method is shown, so that its contents are not covered by the input 1256 * method. This can <em>not</em> be combined with 1257 * {@link #SOFT_INPUT_ADJUST_PAN}; if 1258 * neither of these are set, then the system will try to pick one or 1259 * the other depending on the contents of the window. If the window's 1260 * layout parameter flags include {@link #FLAG_FULLSCREEN}, this 1261 * value for {@link #softInputMode} will be ignored; the window will 1262 * not resize, but will stay fullscreen. 1263 */ 1264 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 1265 1266 /** Adjustment option for {@link #softInputMode}: set to have a window 1267 * pan when an input method is 1268 * shown, so it doesn't need to deal with resizing but just panned 1269 * by the framework to ensure the current input focus is visible. This 1270 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 1271 * neither of these are set, then the system will try to pick one or 1272 * the other depending on the contents of the window. 1273 */ 1274 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 1275 1276 /** Adjustment option for {@link #softInputMode}: set to have a window 1277 * not adjust for a shown input method. The window will not be resized, 1278 * and it will not be panned to make its focus visible. 1279 */ 1280 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 1281 1282 /** 1283 * Bit for {@link #softInputMode}: set when the user has navigated 1284 * forward to the window. This is normally set automatically for 1285 * you by the system, though you may want to set it in certain cases 1286 * when you are displaying a window yourself. This flag will always 1287 * be cleared automatically after the window is displayed. 1288 */ 1289 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 1290 1291 /** 1292 * Desired operating mode for any soft input area. May be any combination 1293 * of: 1294 * 1295 * <ul> 1296 * <li> One of the visibility states 1297 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 1298 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}, or 1299 * {@link #SOFT_INPUT_STATE_VISIBLE}. 1300 * <li> One of the adjustment options 1301 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, 1302 * {@link #SOFT_INPUT_ADJUST_RESIZE}, or 1303 * {@link #SOFT_INPUT_ADJUST_PAN}. 1304 * </ul> 1305 * 1306 * 1307 * <p>This flag can be controlled in your theme through the 1308 * {@link android.R.attr#windowSoftInputMode} attribute.</p> 1309 */ 1310 public int softInputMode; 1311 1312 /** 1313 * Placement of window within the screen as per {@link Gravity}. Both 1314 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1315 * android.graphics.Rect) Gravity.apply} and 1316 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1317 * Gravity.applyDisplay} are used during window layout, with this value 1318 * given as the desired gravity. For example you can specify 1319 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 1320 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 1321 * to control the behavior of 1322 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 1323 * Gravity.applyDisplay}. 1324 * 1325 * @see Gravity 1326 */ 1327 public int gravity; 1328 1329 /** 1330 * The horizontal margin, as a percentage of the container's width, 1331 * between the container and the widget. See 1332 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1333 * android.graphics.Rect) Gravity.apply} for how this is used. This 1334 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 1335 */ 1336 public float horizontalMargin; 1337 1338 /** 1339 * The vertical margin, as a percentage of the container's height, 1340 * between the container and the widget. See 1341 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1342 * android.graphics.Rect) Gravity.apply} for how this is used. This 1343 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 1344 */ 1345 public float verticalMargin; 1346 1347 /** 1348 * Positive insets between the drawing surface and window content. 1349 * 1350 * @hide 1351 */ 1352 public final Rect surfaceInsets = new Rect(); 1353 1354 /** 1355 * Whether the surface insets have been manually set. When set to 1356 * {@code false}, the view root will automatically determine the 1357 * appropriate surface insets. 1358 * 1359 * @see #surfaceInsets 1360 * @hide 1361 */ 1362 public boolean hasManualSurfaceInsets; 1363 1364 /** 1365 * The desired bitmap format. May be one of the constants in 1366 * {@link android.graphics.PixelFormat}. Default is OPAQUE. 1367 */ 1368 public int format; 1369 1370 /** 1371 * A style resource defining the animations to use for this window. 1372 * This must be a system resource; it can not be an application resource 1373 * because the window manager does not have access to applications. 1374 */ 1375 public int windowAnimations; 1376 1377 /** 1378 * An alpha value to apply to this entire window. 1379 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 1380 */ 1381 public float alpha = 1.0f; 1382 1383 /** 1384 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 1385 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 1386 * dim. 1387 */ 1388 public float dimAmount = 1.0f; 1389 1390 /** 1391 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 1392 * indicating that the brightness value is not overridden for this window 1393 * and normal brightness policy should be used. 1394 */ 1395 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 1396 1397 /** 1398 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1399 * indicating that the screen or button backlight brightness should be set 1400 * to the lowest value when this window is in front. 1401 */ 1402 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 1403 1404 /** 1405 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 1406 * indicating that the screen or button backlight brightness should be set 1407 * to the hightest value when this window is in front. 1408 */ 1409 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 1410 1411 /** 1412 * This can be used to override the user's preferred brightness of 1413 * the screen. A value of less than 0, the default, means to use the 1414 * preferred screen brightness. 0 to 1 adjusts the brightness from 1415 * dark to full bright. 1416 */ 1417 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 1418 1419 /** 1420 * This can be used to override the standard behavior of the button and 1421 * keyboard backlights. A value of less than 0, the default, means to 1422 * use the standard backlight behavior. 0 to 1 adjusts the brightness 1423 * from dark to full bright. 1424 */ 1425 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 1426 1427 /** 1428 * Value for {@link #rotationAnimation} to define the animation used to 1429 * specify that this window will rotate in or out following a rotation. 1430 */ 1431 public static final int ROTATION_ANIMATION_ROTATE = 0; 1432 1433 /** 1434 * Value for {@link #rotationAnimation} to define the animation used to 1435 * specify that this window will fade in or out following a rotation. 1436 */ 1437 public static final int ROTATION_ANIMATION_CROSSFADE = 1; 1438 1439 /** 1440 * Value for {@link #rotationAnimation} to define the animation used to 1441 * specify that this window will immediately disappear or appear following 1442 * a rotation. 1443 */ 1444 public static final int ROTATION_ANIMATION_JUMPCUT = 2; 1445 1446 /** 1447 * Define the exit and entry animations used on this window when the device is rotated. 1448 * This only has an affect if the incoming and outgoing topmost 1449 * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered 1450 * by other windows. All other situations default to the 1451 * {@link #ROTATION_ANIMATION_ROTATE} behavior. 1452 * 1453 * @see #ROTATION_ANIMATION_ROTATE 1454 * @see #ROTATION_ANIMATION_CROSSFADE 1455 * @see #ROTATION_ANIMATION_JUMPCUT 1456 */ 1457 public int rotationAnimation = ROTATION_ANIMATION_ROTATE; 1458 1459 /** 1460 * Identifier for this window. This will usually be filled in for 1461 * you. 1462 */ 1463 public IBinder token = null; 1464 1465 /** 1466 * Name of the package owning this window. 1467 */ 1468 public String packageName = null; 1469 1470 /** 1471 * Specific orientation value for a window. 1472 * May be any of the same values allowed 1473 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 1474 * If not set, a default value of 1475 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 1476 * will be used. 1477 */ 1478 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 1479 1480 /** 1481 * The preferred refresh rate for the window. 1482 * 1483 * This must be one of the supported refresh rates obtained for the display(s) the window 1484 * is on. The selected refresh rate will be applied to the display's default mode. 1485 * 1486 * This value is ignored if {@link #preferredDisplayModeId} is set. 1487 * 1488 * @see Display#getSupportedRefreshRates() 1489 * @deprecated use {@link #preferredDisplayModeId} instead 1490 */ 1491 @Deprecated 1492 public float preferredRefreshRate; 1493 1494 /** 1495 * Id of the preferred display mode for the window. 1496 * <p> 1497 * This must be one of the supported modes obtained for the display(s) the window is on. 1498 * A value of {@code 0} means no preference. 1499 * 1500 * @see Display#getSupportedModes() 1501 * @see Display.Mode#getModeId() 1502 */ 1503 public int preferredDisplayModeId; 1504 1505 /** 1506 * Control the visibility of the status bar. 1507 * 1508 * @see View#STATUS_BAR_VISIBLE 1509 * @see View#STATUS_BAR_HIDDEN 1510 */ 1511 public int systemUiVisibility; 1512 1513 /** 1514 * @hide 1515 * The ui visibility as requested by the views in this hierarchy. 1516 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. 1517 */ 1518 public int subtreeSystemUiVisibility; 1519 1520 /** 1521 * Get callbacks about the system ui visibility changing. 1522 * 1523 * TODO: Maybe there should be a bitfield of optional callbacks that we need. 1524 * 1525 * @hide 1526 */ 1527 public boolean hasSystemUiListeners; 1528 1529 /** 1530 * When this window has focus, disable touch pad pointer gesture processing. 1531 * The window will receive raw position updates from the touch pad instead 1532 * of pointer movements and synthetic touch events. 1533 * 1534 * @hide 1535 */ 1536 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001; 1537 1538 /** 1539 * Does not construct an input channel for this window. The channel will therefore 1540 * be incapable of receiving input. 1541 * 1542 * @hide 1543 */ 1544 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002; 1545 1546 /** 1547 * When this window has focus, does not call user activity for all input events so 1548 * the application will have to do it itself. Should only be used by 1549 * the keyguard and phone app. 1550 * <p> 1551 * Should only be used by the keyguard and phone app. 1552 * </p> 1553 * 1554 * @hide 1555 */ 1556 public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004; 1557 1558 /** 1559 * Control special features of the input subsystem. 1560 * 1561 * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES 1562 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL 1563 * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY 1564 * @hide 1565 */ 1566 public int inputFeatures; 1567 1568 /** 1569 * Sets the number of milliseconds before the user activity timeout occurs 1570 * when this window has focus. A value of -1 uses the standard timeout. 1571 * A value of 0 uses the minimum support display timeout. 1572 * <p> 1573 * This property can only be used to reduce the user specified display timeout; 1574 * it can never make the timeout longer than it normally would be. 1575 * </p><p> 1576 * Should only be used by the keyguard and phone app. 1577 * </p> 1578 * 1579 * @hide 1580 */ 1581 public long userActivityTimeout = -1; 1582 1583 public LayoutParams() { 1584 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1585 type = TYPE_APPLICATION; 1586 format = PixelFormat.OPAQUE; 1587 } 1588 1589 public LayoutParams(int _type) { 1590 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1591 type = _type; 1592 format = PixelFormat.OPAQUE; 1593 } 1594 1595 public LayoutParams(int _type, int _flags) { 1596 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1597 type = _type; 1598 flags = _flags; 1599 format = PixelFormat.OPAQUE; 1600 } 1601 1602 public LayoutParams(int _type, int _flags, int _format) { 1603 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 1604 type = _type; 1605 flags = _flags; 1606 format = _format; 1607 } 1608 1609 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 1610 super(w, h); 1611 type = _type; 1612 flags = _flags; 1613 format = _format; 1614 } 1615 1616 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 1617 int _flags, int _format) { 1618 super(w, h); 1619 x = xpos; 1620 y = ypos; 1621 type = _type; 1622 flags = _flags; 1623 format = _format; 1624 } 1625 1626 public final void setTitle(CharSequence title) { 1627 if (null == title) 1628 title = ""; 1629 1630 mTitle = TextUtils.stringOrSpannedString(title); 1631 } 1632 1633 public final CharSequence getTitle() { 1634 return mTitle; 1635 } 1636 1637 /** @hide */ 1638 @SystemApi 1639 public final void setUserActivityTimeout(long timeout) { 1640 userActivityTimeout = timeout; 1641 } 1642 1643 /** @hide */ 1644 @SystemApi 1645 public final long getUserActivityTimeout() { 1646 return userActivityTimeout; 1647 } 1648 1649 public int describeContents() { 1650 return 0; 1651 } 1652 1653 public void writeToParcel(Parcel out, int parcelableFlags) { 1654 out.writeInt(width); 1655 out.writeInt(height); 1656 out.writeInt(x); 1657 out.writeInt(y); 1658 out.writeInt(type); 1659 out.writeInt(flags); 1660 out.writeInt(privateFlags); 1661 out.writeInt(softInputMode); 1662 out.writeInt(gravity); 1663 out.writeFloat(horizontalMargin); 1664 out.writeFloat(verticalMargin); 1665 out.writeInt(format); 1666 out.writeInt(windowAnimations); 1667 out.writeFloat(alpha); 1668 out.writeFloat(dimAmount); 1669 out.writeFloat(screenBrightness); 1670 out.writeFloat(buttonBrightness); 1671 out.writeInt(rotationAnimation); 1672 out.writeStrongBinder(token); 1673 out.writeString(packageName); 1674 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 1675 out.writeInt(screenOrientation); 1676 out.writeFloat(preferredRefreshRate); 1677 out.writeInt(preferredDisplayModeId); 1678 out.writeInt(systemUiVisibility); 1679 out.writeInt(subtreeSystemUiVisibility); 1680 out.writeInt(hasSystemUiListeners ? 1 : 0); 1681 out.writeInt(inputFeatures); 1682 out.writeLong(userActivityTimeout); 1683 out.writeInt(surfaceInsets.left); 1684 out.writeInt(surfaceInsets.top); 1685 out.writeInt(surfaceInsets.right); 1686 out.writeInt(surfaceInsets.bottom); 1687 out.writeInt(hasManualSurfaceInsets ? 1 : 0); 1688 out.writeInt(needsMenuKey); 1689 } 1690 1691 public static final Parcelable.Creator<LayoutParams> CREATOR 1692 = new Parcelable.Creator<LayoutParams>() { 1693 public LayoutParams createFromParcel(Parcel in) { 1694 return new LayoutParams(in); 1695 } 1696 1697 public LayoutParams[] newArray(int size) { 1698 return new LayoutParams[size]; 1699 } 1700 }; 1701 1702 1703 public LayoutParams(Parcel in) { 1704 width = in.readInt(); 1705 height = in.readInt(); 1706 x = in.readInt(); 1707 y = in.readInt(); 1708 type = in.readInt(); 1709 flags = in.readInt(); 1710 privateFlags = in.readInt(); 1711 softInputMode = in.readInt(); 1712 gravity = in.readInt(); 1713 horizontalMargin = in.readFloat(); 1714 verticalMargin = in.readFloat(); 1715 format = in.readInt(); 1716 windowAnimations = in.readInt(); 1717 alpha = in.readFloat(); 1718 dimAmount = in.readFloat(); 1719 screenBrightness = in.readFloat(); 1720 buttonBrightness = in.readFloat(); 1721 rotationAnimation = in.readInt(); 1722 token = in.readStrongBinder(); 1723 packageName = in.readString(); 1724 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 1725 screenOrientation = in.readInt(); 1726 preferredRefreshRate = in.readFloat(); 1727 preferredDisplayModeId = in.readInt(); 1728 systemUiVisibility = in.readInt(); 1729 subtreeSystemUiVisibility = in.readInt(); 1730 hasSystemUiListeners = in.readInt() != 0; 1731 inputFeatures = in.readInt(); 1732 userActivityTimeout = in.readLong(); 1733 surfaceInsets.left = in.readInt(); 1734 surfaceInsets.top = in.readInt(); 1735 surfaceInsets.right = in.readInt(); 1736 surfaceInsets.bottom = in.readInt(); 1737 hasManualSurfaceInsets = in.readInt() != 0; 1738 needsMenuKey = in.readInt(); 1739 } 1740 1741 @SuppressWarnings({"PointlessBitwiseExpression"}) 1742 public static final int LAYOUT_CHANGED = 1<<0; 1743 public static final int TYPE_CHANGED = 1<<1; 1744 public static final int FLAGS_CHANGED = 1<<2; 1745 public static final int FORMAT_CHANGED = 1<<3; 1746 public static final int ANIMATION_CHANGED = 1<<4; 1747 public static final int DIM_AMOUNT_CHANGED = 1<<5; 1748 public static final int TITLE_CHANGED = 1<<6; 1749 public static final int ALPHA_CHANGED = 1<<7; 1750 public static final int MEMORY_TYPE_CHANGED = 1<<8; 1751 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 1752 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 1753 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 1754 public static final int ROTATION_ANIMATION_CHANGED = 1<<12; 1755 /** {@hide} */ 1756 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13; 1757 /** {@hide} */ 1758 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14; 1759 /** {@hide} */ 1760 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15; 1761 /** {@hide} */ 1762 public static final int INPUT_FEATURES_CHANGED = 1<<16; 1763 /** {@hide} */ 1764 public static final int PRIVATE_FLAGS_CHANGED = 1<<17; 1765 /** {@hide} */ 1766 public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18; 1767 /** {@hide} */ 1768 public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19; 1769 /** {@hide} */ 1770 public static final int SURFACE_INSETS_CHANGED = 1<<20; 1771 /** {@hide} */ 1772 public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21; 1773 /** {@hide} */ 1774 public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22; 1775 /** {@hide} */ 1776 public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23; 1777 /** {@hide} */ 1778 public static final int EVERYTHING_CHANGED = 0xffffffff; 1779 1780 // internal buffer to backup/restore parameters under compatibility mode. 1781 private int[] mCompatibilityParamsBackup = null; 1782 1783 public final int copyFrom(LayoutParams o) { 1784 int changes = 0; 1785 1786 if (width != o.width) { 1787 width = o.width; 1788 changes |= LAYOUT_CHANGED; 1789 } 1790 if (height != o.height) { 1791 height = o.height; 1792 changes |= LAYOUT_CHANGED; 1793 } 1794 if (x != o.x) { 1795 x = o.x; 1796 changes |= LAYOUT_CHANGED; 1797 } 1798 if (y != o.y) { 1799 y = o.y; 1800 changes |= LAYOUT_CHANGED; 1801 } 1802 if (horizontalWeight != o.horizontalWeight) { 1803 horizontalWeight = o.horizontalWeight; 1804 changes |= LAYOUT_CHANGED; 1805 } 1806 if (verticalWeight != o.verticalWeight) { 1807 verticalWeight = o.verticalWeight; 1808 changes |= LAYOUT_CHANGED; 1809 } 1810 if (horizontalMargin != o.horizontalMargin) { 1811 horizontalMargin = o.horizontalMargin; 1812 changes |= LAYOUT_CHANGED; 1813 } 1814 if (verticalMargin != o.verticalMargin) { 1815 verticalMargin = o.verticalMargin; 1816 changes |= LAYOUT_CHANGED; 1817 } 1818 if (type != o.type) { 1819 type = o.type; 1820 changes |= TYPE_CHANGED; 1821 } 1822 if (flags != o.flags) { 1823 final int diff = flags ^ o.flags; 1824 if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) { 1825 changes |= TRANSLUCENT_FLAGS_CHANGED; 1826 } 1827 flags = o.flags; 1828 changes |= FLAGS_CHANGED; 1829 } 1830 if (privateFlags != o.privateFlags) { 1831 privateFlags = o.privateFlags; 1832 changes |= PRIVATE_FLAGS_CHANGED; 1833 } 1834 if (softInputMode != o.softInputMode) { 1835 softInputMode = o.softInputMode; 1836 changes |= SOFT_INPUT_MODE_CHANGED; 1837 } 1838 if (gravity != o.gravity) { 1839 gravity = o.gravity; 1840 changes |= LAYOUT_CHANGED; 1841 } 1842 if (format != o.format) { 1843 format = o.format; 1844 changes |= FORMAT_CHANGED; 1845 } 1846 if (windowAnimations != o.windowAnimations) { 1847 windowAnimations = o.windowAnimations; 1848 changes |= ANIMATION_CHANGED; 1849 } 1850 if (token == null) { 1851 // NOTE: token only copied if the recipient doesn't 1852 // already have one. 1853 token = o.token; 1854 } 1855 if (packageName == null) { 1856 // NOTE: packageName only copied if the recipient doesn't 1857 // already have one. 1858 packageName = o.packageName; 1859 } 1860 if (!mTitle.equals(o.mTitle)) { 1861 mTitle = o.mTitle; 1862 changes |= TITLE_CHANGED; 1863 } 1864 if (alpha != o.alpha) { 1865 alpha = o.alpha; 1866 changes |= ALPHA_CHANGED; 1867 } 1868 if (dimAmount != o.dimAmount) { 1869 dimAmount = o.dimAmount; 1870 changes |= DIM_AMOUNT_CHANGED; 1871 } 1872 if (screenBrightness != o.screenBrightness) { 1873 screenBrightness = o.screenBrightness; 1874 changes |= SCREEN_BRIGHTNESS_CHANGED; 1875 } 1876 if (buttonBrightness != o.buttonBrightness) { 1877 buttonBrightness = o.buttonBrightness; 1878 changes |= BUTTON_BRIGHTNESS_CHANGED; 1879 } 1880 if (rotationAnimation != o.rotationAnimation) { 1881 rotationAnimation = o.rotationAnimation; 1882 changes |= ROTATION_ANIMATION_CHANGED; 1883 } 1884 1885 if (screenOrientation != o.screenOrientation) { 1886 screenOrientation = o.screenOrientation; 1887 changes |= SCREEN_ORIENTATION_CHANGED; 1888 } 1889 1890 if (preferredRefreshRate != o.preferredRefreshRate) { 1891 preferredRefreshRate = o.preferredRefreshRate; 1892 changes |= PREFERRED_REFRESH_RATE_CHANGED; 1893 } 1894 1895 if (preferredDisplayModeId != o.preferredDisplayModeId) { 1896 preferredDisplayModeId = o.preferredDisplayModeId; 1897 changes |= PREFERRED_DISPLAY_MODE_ID; 1898 } 1899 1900 if (systemUiVisibility != o.systemUiVisibility 1901 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { 1902 systemUiVisibility = o.systemUiVisibility; 1903 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; 1904 changes |= SYSTEM_UI_VISIBILITY_CHANGED; 1905 } 1906 1907 if (hasSystemUiListeners != o.hasSystemUiListeners) { 1908 hasSystemUiListeners = o.hasSystemUiListeners; 1909 changes |= SYSTEM_UI_LISTENER_CHANGED; 1910 } 1911 1912 if (inputFeatures != o.inputFeatures) { 1913 inputFeatures = o.inputFeatures; 1914 changes |= INPUT_FEATURES_CHANGED; 1915 } 1916 1917 if (userActivityTimeout != o.userActivityTimeout) { 1918 userActivityTimeout = o.userActivityTimeout; 1919 changes |= USER_ACTIVITY_TIMEOUT_CHANGED; 1920 } 1921 1922 if (!surfaceInsets.equals(o.surfaceInsets)) { 1923 surfaceInsets.set(o.surfaceInsets); 1924 changes |= SURFACE_INSETS_CHANGED; 1925 } 1926 1927 if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) { 1928 hasManualSurfaceInsets = o.hasManualSurfaceInsets; 1929 changes |= SURFACE_INSETS_CHANGED; 1930 } 1931 1932 if (needsMenuKey != o.needsMenuKey) { 1933 needsMenuKey = o.needsMenuKey; 1934 changes |= NEEDS_MENU_KEY_CHANGED; 1935 } 1936 1937 return changes; 1938 } 1939 1940 @Override 1941 public String debug(String output) { 1942 output += "Contents of " + this + ":"; 1943 Log.d("Debug", output); 1944 output = super.debug(""); 1945 Log.d("Debug", output); 1946 Log.d("Debug", ""); 1947 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 1948 return ""; 1949 } 1950 1951 @Override 1952 public String toString() { 1953 StringBuilder sb = new StringBuilder(256); 1954 sb.append("WM.LayoutParams{"); 1955 sb.append("("); 1956 sb.append(x); 1957 sb.append(','); 1958 sb.append(y); 1959 sb.append(")("); 1960 sb.append((width== MATCH_PARENT ?"fill":(width==WRAP_CONTENT?"wrap":width))); 1961 sb.append('x'); 1962 sb.append((height== MATCH_PARENT ?"fill":(height==WRAP_CONTENT?"wrap":height))); 1963 sb.append(")"); 1964 if (horizontalMargin != 0) { 1965 sb.append(" hm="); 1966 sb.append(horizontalMargin); 1967 } 1968 if (verticalMargin != 0) { 1969 sb.append(" vm="); 1970 sb.append(verticalMargin); 1971 } 1972 if (gravity != 0) { 1973 sb.append(" gr=#"); 1974 sb.append(Integer.toHexString(gravity)); 1975 } 1976 if (softInputMode != 0) { 1977 sb.append(" sim=#"); 1978 sb.append(Integer.toHexString(softInputMode)); 1979 } 1980 sb.append(" ty="); 1981 sb.append(type); 1982 sb.append(" fl=#"); 1983 sb.append(Integer.toHexString(flags)); 1984 if (privateFlags != 0) { 1985 if ((privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0) { 1986 sb.append(" compatible=true"); 1987 } 1988 sb.append(" pfl=0x").append(Integer.toHexString(privateFlags)); 1989 } 1990 if (format != PixelFormat.OPAQUE) { 1991 sb.append(" fmt="); 1992 sb.append(format); 1993 } 1994 if (windowAnimations != 0) { 1995 sb.append(" wanim=0x"); 1996 sb.append(Integer.toHexString(windowAnimations)); 1997 } 1998 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 1999 sb.append(" or="); 2000 sb.append(screenOrientation); 2001 } 2002 if (alpha != 1.0f) { 2003 sb.append(" alpha="); 2004 sb.append(alpha); 2005 } 2006 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 2007 sb.append(" sbrt="); 2008 sb.append(screenBrightness); 2009 } 2010 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 2011 sb.append(" bbrt="); 2012 sb.append(buttonBrightness); 2013 } 2014 if (rotationAnimation != ROTATION_ANIMATION_ROTATE) { 2015 sb.append(" rotAnim="); 2016 sb.append(rotationAnimation); 2017 } 2018 if (preferredRefreshRate != 0) { 2019 sb.append(" preferredRefreshRate="); 2020 sb.append(preferredRefreshRate); 2021 } 2022 if (preferredDisplayModeId != 0) { 2023 sb.append(" preferredDisplayMode="); 2024 sb.append(preferredDisplayModeId); 2025 } 2026 if (systemUiVisibility != 0) { 2027 sb.append(" sysui=0x"); 2028 sb.append(Integer.toHexString(systemUiVisibility)); 2029 } 2030 if (subtreeSystemUiVisibility != 0) { 2031 sb.append(" vsysui=0x"); 2032 sb.append(Integer.toHexString(subtreeSystemUiVisibility)); 2033 } 2034 if (hasSystemUiListeners) { 2035 sb.append(" sysuil="); 2036 sb.append(hasSystemUiListeners); 2037 } 2038 if (inputFeatures != 0) { 2039 sb.append(" if=0x").append(Integer.toHexString(inputFeatures)); 2040 } 2041 if (userActivityTimeout >= 0) { 2042 sb.append(" userActivityTimeout=").append(userActivityTimeout); 2043 } 2044 if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 || 2045 surfaceInsets.bottom != 0 || hasManualSurfaceInsets) { 2046 sb.append(" surfaceInsets=").append(surfaceInsets); 2047 if (hasManualSurfaceInsets) { 2048 sb.append(" (manual)"); 2049 } 2050 } 2051 if (needsMenuKey != NEEDS_MENU_UNSET) { 2052 sb.append(" needsMenuKey="); 2053 sb.append(needsMenuKey); 2054 } 2055 sb.append('}'); 2056 return sb.toString(); 2057 } 2058 2059 /** 2060 * Scale the layout params' coordinates and size. 2061 * @hide 2062 */ 2063 public void scale(float scale) { 2064 x = (int) (x * scale + 0.5f); 2065 y = (int) (y * scale + 0.5f); 2066 if (width > 0) { 2067 width = (int) (width * scale + 0.5f); 2068 } 2069 if (height > 0) { 2070 height = (int) (height * scale + 0.5f); 2071 } 2072 } 2073 2074 /** 2075 * Backup the layout parameters used in compatibility mode. 2076 * @see LayoutParams#restore() 2077 */ 2078 void backup() { 2079 int[] backup = mCompatibilityParamsBackup; 2080 if (backup == null) { 2081 // we backup 4 elements, x, y, width, height 2082 backup = mCompatibilityParamsBackup = new int[4]; 2083 } 2084 backup[0] = x; 2085 backup[1] = y; 2086 backup[2] = width; 2087 backup[3] = height; 2088 } 2089 2090 /** 2091 * Restore the layout params' coordinates, size and gravity 2092 * @see LayoutParams#backup() 2093 */ 2094 void restore() { 2095 int[] backup = mCompatibilityParamsBackup; 2096 if (backup != null) { 2097 x = backup[0]; 2098 y = backup[1]; 2099 width = backup[2]; 2100 height = backup[3]; 2101 } 2102 } 2103 2104 private CharSequence mTitle = ""; 2105 2106 /** @hide */ 2107 @Override 2108 protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { 2109 super.encodeProperties(encoder); 2110 2111 encoder.addProperty("x", x); 2112 encoder.addProperty("y", y); 2113 encoder.addProperty("horizontalWeight", horizontalWeight); 2114 encoder.addProperty("verticalWeight", verticalWeight); 2115 encoder.addProperty("type", type); 2116 encoder.addProperty("flags", flags); 2117 } 2118 } 2119} 2120