WindowManager.java revision 935772129d244122e23308b812765d4591a3c04f
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 static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT; 20import static android.view.WindowLayoutParamsProto.ALPHA; 21import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS; 22import static android.view.WindowLayoutParamsProto.COLOR_MODE; 23import static android.view.WindowLayoutParamsProto.FLAGS; 24import static android.view.WindowLayoutParamsProto.FORMAT; 25import static android.view.WindowLayoutParamsProto.GRAVITY; 26import static android.view.WindowLayoutParamsProto.HAS_SYSTEM_UI_LISTENERS; 27import static android.view.WindowLayoutParamsProto.HEIGHT; 28import static android.view.WindowLayoutParamsProto.HORIZONTAL_MARGIN; 29import static android.view.WindowLayoutParamsProto.INPUT_FEATURE_FLAGS; 30import static android.view.WindowLayoutParamsProto.NEEDS_MENU_KEY; 31import static android.view.WindowLayoutParamsProto.PREFERRED_REFRESH_RATE; 32import static android.view.WindowLayoutParamsProto.PRIVATE_FLAGS; 33import static android.view.WindowLayoutParamsProto.ROTATION_ANIMATION; 34import static android.view.WindowLayoutParamsProto.SCREEN_BRIGHTNESS; 35import static android.view.WindowLayoutParamsProto.SOFT_INPUT_MODE; 36import static android.view.WindowLayoutParamsProto.SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS; 37import static android.view.WindowLayoutParamsProto.SYSTEM_UI_VISIBILITY_FLAGS; 38import static android.view.WindowLayoutParamsProto.TYPE; 39import static android.view.WindowLayoutParamsProto.USER_ACTIVITY_TIMEOUT; 40import static android.view.WindowLayoutParamsProto.VERTICAL_MARGIN; 41import static android.view.WindowLayoutParamsProto.WIDTH; 42import static android.view.WindowLayoutParamsProto.WINDOW_ANIMATIONS; 43import static android.view.WindowLayoutParamsProto.X; 44import static android.view.WindowLayoutParamsProto.Y; 45 46import android.Manifest.permission; 47import android.annotation.IntDef; 48import android.annotation.NonNull; 49import android.annotation.RequiresPermission; 50import android.annotation.SystemApi; 51import android.annotation.SystemService; 52import android.annotation.TestApi; 53import android.app.KeyguardManager; 54import android.app.Presentation; 55import android.content.Context; 56import android.content.pm.ActivityInfo; 57import android.graphics.PixelFormat; 58import android.graphics.Rect; 59import android.graphics.Region; 60import android.os.IBinder; 61import android.os.Parcel; 62import android.os.Parcelable; 63import android.text.TextUtils; 64import android.util.Log; 65import android.util.proto.ProtoOutputStream; 66import android.view.accessibility.AccessibilityNodeInfo; 67 68import java.lang.annotation.Retention; 69import java.lang.annotation.RetentionPolicy; 70import java.util.List; 71import java.util.Objects; 72 73/** 74 * The interface that apps use to talk to the window manager. 75 * </p><p> 76 * Each window manager instance is bound to a particular {@link Display}. 77 * To obtain a {@link WindowManager} for a different display, use 78 * {@link Context#createDisplayContext} to obtain a {@link Context} for that 79 * display, then use <code>Context.getSystemService(Context.WINDOW_SERVICE)</code> 80 * to get the WindowManager. 81 * </p><p> 82 * The simplest way to show a window on another display is to create a 83 * {@link Presentation}. The presentation will automatically obtain a 84 * {@link WindowManager} and {@link Context} for that display. 85 * </p> 86 */ 87@SystemService(Context.WINDOW_SERVICE) 88public interface WindowManager extends ViewManager { 89 90 /** @hide */ 91 int DOCKED_INVALID = -1; 92 /** @hide */ 93 int DOCKED_LEFT = 1; 94 /** @hide */ 95 int DOCKED_TOP = 2; 96 /** @hide */ 97 int DOCKED_RIGHT = 3; 98 /** @hide */ 99 int DOCKED_BOTTOM = 4; 100 101 /** @hide */ 102 String INPUT_CONSUMER_PIP = "pip_input_consumer"; 103 /** @hide */ 104 String INPUT_CONSUMER_NAVIGATION = "nav_input_consumer"; 105 /** @hide */ 106 String INPUT_CONSUMER_WALLPAPER = "wallpaper_input_consumer"; 107 /** @hide */ 108 String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer"; 109 110 /** 111 * Not set up for a transition. 112 * @hide 113 */ 114 int TRANSIT_UNSET = -1; 115 116 /** 117 * No animation for transition. 118 * @hide 119 */ 120 int TRANSIT_NONE = 0; 121 122 /** 123 * A window in a new activity is being opened on top of an existing one in the same task. 124 * @hide 125 */ 126 int TRANSIT_ACTIVITY_OPEN = 6; 127 128 /** 129 * The window in the top-most activity is being closed to reveal the previous activity in the 130 * same task. 131 * @hide 132 */ 133 int TRANSIT_ACTIVITY_CLOSE = 7; 134 135 /** 136 * A window in a new task is being opened on top of an existing one in another activity's task. 137 * @hide 138 */ 139 int TRANSIT_TASK_OPEN = 8; 140 141 /** 142 * A window in the top-most activity is being closed to reveal the previous activity in a 143 * different task. 144 * @hide 145 */ 146 int TRANSIT_TASK_CLOSE = 9; 147 148 /** 149 * A window in an existing task is being displayed on top of an existing one in another 150 * activity's task. 151 * @hide 152 */ 153 int TRANSIT_TASK_TO_FRONT = 10; 154 155 /** 156 * A window in an existing task is being put below all other tasks. 157 * @hide 158 */ 159 int TRANSIT_TASK_TO_BACK = 11; 160 161 /** 162 * A window in a new activity that doesn't have a wallpaper is being opened on top of one that 163 * does, effectively closing the wallpaper. 164 * @hide 165 */ 166 int TRANSIT_WALLPAPER_CLOSE = 12; 167 168 /** 169 * A window in a new activity that does have a wallpaper is being opened on one that didn't, 170 * effectively opening the wallpaper. 171 * @hide 172 */ 173 int TRANSIT_WALLPAPER_OPEN = 13; 174 175 /** 176 * A window in a new activity is being opened on top of an existing one, and both are on top 177 * of the wallpaper. 178 * @hide 179 */ 180 int TRANSIT_WALLPAPER_INTRA_OPEN = 14; 181 182 /** 183 * The window in the top-most activity is being closed to reveal the previous activity, and 184 * both are on top of the wallpaper. 185 * @hide 186 */ 187 int TRANSIT_WALLPAPER_INTRA_CLOSE = 15; 188 189 /** 190 * A window in a new task is being opened behind an existing one in another activity's task. 191 * The new window will show briefly and then be gone. 192 * @hide 193 */ 194 int TRANSIT_TASK_OPEN_BEHIND = 16; 195 196 /** 197 * A window in a task is being animated in-place. 198 * @hide 199 */ 200 int TRANSIT_TASK_IN_PLACE = 17; 201 202 /** 203 * An activity is being relaunched (e.g. due to configuration change). 204 * @hide 205 */ 206 int TRANSIT_ACTIVITY_RELAUNCH = 18; 207 208 /** 209 * A task is being docked from recents. 210 * @hide 211 */ 212 int TRANSIT_DOCK_TASK_FROM_RECENTS = 19; 213 214 /** 215 * Keyguard is going away. 216 * @hide 217 */ 218 int TRANSIT_KEYGUARD_GOING_AWAY = 20; 219 220 /** 221 * Keyguard is going away with showing an activity behind that requests wallpaper. 222 * @hide 223 */ 224 int TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21; 225 226 /** 227 * Keyguard is being occluded. 228 * @hide 229 */ 230 int TRANSIT_KEYGUARD_OCCLUDE = 22; 231 232 /** 233 * Keyguard is being unoccluded. 234 * @hide 235 */ 236 int TRANSIT_KEYGUARD_UNOCCLUDE = 23; 237 238 /** 239 * A translucent activity is being opened. 240 * @hide 241 */ 242 int TRANSIT_TRANSLUCENT_ACTIVITY_OPEN = 24; 243 244 /** 245 * A translucent activity is being closed. 246 * @hide 247 */ 248 int TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE = 25; 249 250 /** 251 * A crashing activity is being closed. 252 * @hide 253 */ 254 int TRANSIT_CRASHING_ACTIVITY_CLOSE = 26; 255 256 /** 257 * @hide 258 */ 259 @IntDef(prefix = { "TRANSIT_" }, value = { 260 TRANSIT_UNSET, 261 TRANSIT_NONE, 262 TRANSIT_ACTIVITY_OPEN, 263 TRANSIT_ACTIVITY_CLOSE, 264 TRANSIT_TASK_OPEN, 265 TRANSIT_TASK_CLOSE, 266 TRANSIT_TASK_TO_FRONT, 267 TRANSIT_TASK_TO_BACK, 268 TRANSIT_WALLPAPER_CLOSE, 269 TRANSIT_WALLPAPER_OPEN, 270 TRANSIT_WALLPAPER_INTRA_OPEN, 271 TRANSIT_WALLPAPER_INTRA_CLOSE, 272 TRANSIT_TASK_OPEN_BEHIND, 273 TRANSIT_TASK_IN_PLACE, 274 TRANSIT_ACTIVITY_RELAUNCH, 275 TRANSIT_DOCK_TASK_FROM_RECENTS, 276 TRANSIT_KEYGUARD_GOING_AWAY, 277 TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER, 278 TRANSIT_KEYGUARD_OCCLUDE, 279 TRANSIT_KEYGUARD_UNOCCLUDE, 280 TRANSIT_TRANSLUCENT_ACTIVITY_OPEN, 281 TRANSIT_TRANSLUCENT_ACTIVITY_CLOSE 282 }) 283 @Retention(RetentionPolicy.SOURCE) 284 @interface TransitionType {} 285 286 /** 287 * Transition flag: Keyguard is going away, but keeping the notification shade open 288 * @hide 289 */ 290 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = 0x1; 291 292 /** 293 * Transition flag: Keyguard is going away, but doesn't want an animation for it 294 * @hide 295 */ 296 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = 0x2; 297 298 /** 299 * Transition flag: Keyguard is going away while it was showing the system wallpaper. 300 * @hide 301 */ 302 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = 0x4; 303 304 /** 305 * @hide 306 */ 307 @IntDef(flag = true, prefix = { "TRANSIT_FLAG_" }, value = { 308 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE, 309 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION, 310 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER, 311 }) 312 @Retention(RetentionPolicy.SOURCE) 313 @interface TransitionFlags {} 314 315 /** 316 * Exception that is thrown when trying to add view whose 317 * {@link LayoutParams} {@link LayoutParams#token} 318 * is invalid. 319 */ 320 public static class BadTokenException extends RuntimeException { 321 public BadTokenException() { 322 } 323 324 public BadTokenException(String name) { 325 super(name); 326 } 327 } 328 329 /** 330 * Exception that is thrown when calling {@link #addView} to a secondary display that cannot 331 * be found. See {@link android.app.Presentation} for more information on secondary displays. 332 */ 333 public static class InvalidDisplayException extends RuntimeException { 334 public InvalidDisplayException() { 335 } 336 337 public InvalidDisplayException(String name) { 338 super(name); 339 } 340 } 341 342 /** 343 * Returns the {@link Display} upon which this {@link WindowManager} instance 344 * will create new windows. 345 * <p> 346 * Despite the name of this method, the display that is returned is not 347 * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}). 348 * The returned display could instead be a secondary display that this 349 * window manager instance is managing. Think of it as the display that 350 * this {@link WindowManager} instance uses by default. 351 * </p><p> 352 * To create windows on a different display, you need to obtain a 353 * {@link WindowManager} for that {@link Display}. (See the {@link WindowManager} 354 * class documentation for more information.) 355 * </p> 356 * 357 * @return The display that this window manager is managing. 358 */ 359 public Display getDefaultDisplay(); 360 361 /** 362 * Special variation of {@link #removeView} that immediately invokes 363 * the given view hierarchy's {@link View#onDetachedFromWindow() 364 * View.onDetachedFromWindow()} methods before returning. This is not 365 * for normal applications; using it correctly requires great care. 366 * 367 * @param view The view to be removed. 368 */ 369 public void removeViewImmediate(View view); 370 371 /** 372 * Used to asynchronously request Keyboard Shortcuts from the focused window. 373 * 374 * @hide 375 */ 376 public interface KeyboardShortcutsReceiver { 377 /** 378 * Callback used when the focused window keyboard shortcuts are ready to be displayed. 379 * 380 * @param result The keyboard shortcuts to be displayed. 381 */ 382 void onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result); 383 } 384 385 /** 386 * Message for taking fullscreen screenshot 387 * @hide 388 */ 389 final int TAKE_SCREENSHOT_FULLSCREEN = 1; 390 391 /** 392 * Message for taking screenshot of selected region. 393 * @hide 394 */ 395 final int TAKE_SCREENSHOT_SELECTED_REGION = 2; 396 397 /** 398 * @hide 399 */ 400 public static final String PARCEL_KEY_SHORTCUTS_ARRAY = "shortcuts_array"; 401 402 /** 403 * Request for keyboard shortcuts to be retrieved asynchronously. 404 * 405 * @param receiver The callback to be triggered when the result is ready. 406 * 407 * @hide 408 */ 409 public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId); 410 411 /** 412 * Return the touch region for the current IME window, or an empty region if there is none. 413 * 414 * @return The region of the IME that is accepting touch inputs, or null if there is no IME, no 415 * region or there was an error. 416 * 417 * @hide 418 */ 419 @SystemApi 420 @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) 421 public Region getCurrentImeTouchRegion(); 422 423 public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable { 424 /** 425 * X position for this window. With the default gravity it is ignored. 426 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or 427 * {@link Gravity#END} it provides an offset from the given edge. 428 */ 429 @ViewDebug.ExportedProperty 430 public int x; 431 432 /** 433 * Y position for this window. With the default gravity it is ignored. 434 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides 435 * an offset from the given edge. 436 */ 437 @ViewDebug.ExportedProperty 438 public int y; 439 440 /** 441 * Indicates how much of the extra space will be allocated horizontally 442 * to the view associated with these LayoutParams. Specify 0 if the view 443 * should not be stretched. Otherwise the extra pixels will be pro-rated 444 * among all views whose weight is greater than 0. 445 */ 446 @ViewDebug.ExportedProperty 447 public float horizontalWeight; 448 449 /** 450 * Indicates how much of the extra space will be allocated vertically 451 * to the view associated with these LayoutParams. Specify 0 if the view 452 * should not be stretched. Otherwise the extra pixels will be pro-rated 453 * among all views whose weight is greater than 0. 454 */ 455 @ViewDebug.ExportedProperty 456 public float verticalWeight; 457 458 /** 459 * The general type of window. There are three main classes of 460 * window types: 461 * <ul> 462 * <li> <strong>Application windows</strong> (ranging from 463 * {@link #FIRST_APPLICATION_WINDOW} to 464 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application 465 * windows. For these types of windows, the {@link #token} must be 466 * set to the token of the activity they are a part of (this will 467 * normally be done for you if {@link #token} is null). 468 * <li> <strong>Sub-windows</strong> (ranging from 469 * {@link #FIRST_SUB_WINDOW} to 470 * {@link #LAST_SUB_WINDOW}) are associated with another top-level 471 * window. For these types of windows, the {@link #token} must be 472 * the token of the window it is attached to. 473 * <li> <strong>System windows</strong> (ranging from 474 * {@link #FIRST_SYSTEM_WINDOW} to 475 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for 476 * use by the system for specific purposes. They should not normally 477 * be used by applications, and a special permission is required 478 * to use them. 479 * </ul> 480 * 481 * @see #TYPE_BASE_APPLICATION 482 * @see #TYPE_APPLICATION 483 * @see #TYPE_APPLICATION_STARTING 484 * @see #TYPE_DRAWN_APPLICATION 485 * @see #TYPE_APPLICATION_PANEL 486 * @see #TYPE_APPLICATION_MEDIA 487 * @see #TYPE_APPLICATION_SUB_PANEL 488 * @see #TYPE_APPLICATION_ABOVE_SUB_PANEL 489 * @see #TYPE_APPLICATION_ATTACHED_DIALOG 490 * @see #TYPE_STATUS_BAR 491 * @see #TYPE_SEARCH_BAR 492 * @see #TYPE_PHONE 493 * @see #TYPE_SYSTEM_ALERT 494 * @see #TYPE_TOAST 495 * @see #TYPE_SYSTEM_OVERLAY 496 * @see #TYPE_PRIORITY_PHONE 497 * @see #TYPE_STATUS_BAR_PANEL 498 * @see #TYPE_SYSTEM_DIALOG 499 * @see #TYPE_KEYGUARD_DIALOG 500 * @see #TYPE_SYSTEM_ERROR 501 * @see #TYPE_INPUT_METHOD 502 * @see #TYPE_INPUT_METHOD_DIALOG 503 */ 504 @ViewDebug.ExportedProperty(mapping = { 505 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, 506 to = "BASE_APPLICATION"), 507 @ViewDebug.IntToString(from = TYPE_APPLICATION, 508 to = "APPLICATION"), 509 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, 510 to = "APPLICATION_STARTING"), 511 @ViewDebug.IntToString(from = TYPE_DRAWN_APPLICATION, 512 to = "DRAWN_APPLICATION"), 513 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, 514 to = "APPLICATION_PANEL"), 515 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, 516 to = "APPLICATION_MEDIA"), 517 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, 518 to = "APPLICATION_SUB_PANEL"), 519 @ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL, 520 to = "APPLICATION_ABOVE_SUB_PANEL"), 521 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, 522 to = "APPLICATION_ATTACHED_DIALOG"), 523 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, 524 to = "APPLICATION_MEDIA_OVERLAY"), 525 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, 526 to = "STATUS_BAR"), 527 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, 528 to = "SEARCH_BAR"), 529 @ViewDebug.IntToString(from = TYPE_PHONE, 530 to = "PHONE"), 531 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, 532 to = "SYSTEM_ALERT"), 533 @ViewDebug.IntToString(from = TYPE_TOAST, 534 to = "TOAST"), 535 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, 536 to = "SYSTEM_OVERLAY"), 537 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, 538 to = "PRIORITY_PHONE"), 539 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, 540 to = "SYSTEM_DIALOG"), 541 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, 542 to = "KEYGUARD_DIALOG"), 543 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, 544 to = "SYSTEM_ERROR"), 545 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, 546 to = "INPUT_METHOD"), 547 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, 548 to = "INPUT_METHOD_DIALOG"), 549 @ViewDebug.IntToString(from = TYPE_WALLPAPER, 550 to = "WALLPAPER"), 551 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, 552 to = "STATUS_BAR_PANEL"), 553 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, 554 to = "SECURE_SYSTEM_OVERLAY"), 555 @ViewDebug.IntToString(from = TYPE_DRAG, 556 to = "DRAG"), 557 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, 558 to = "STATUS_BAR_SUB_PANEL"), 559 @ViewDebug.IntToString(from = TYPE_POINTER, 560 to = "POINTER"), 561 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, 562 to = "NAVIGATION_BAR"), 563 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, 564 to = "VOLUME_OVERLAY"), 565 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, 566 to = "BOOT_PROGRESS"), 567 @ViewDebug.IntToString(from = TYPE_INPUT_CONSUMER, 568 to = "INPUT_CONSUMER"), 569 @ViewDebug.IntToString(from = TYPE_DREAM, 570 to = "DREAM"), 571 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, 572 to = "NAVIGATION_BAR_PANEL"), 573 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, 574 to = "DISPLAY_OVERLAY"), 575 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, 576 to = "MAGNIFICATION_OVERLAY"), 577 @ViewDebug.IntToString(from = TYPE_PRESENTATION, 578 to = "PRESENTATION"), 579 @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION, 580 to = "PRIVATE_PRESENTATION"), 581 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION, 582 to = "VOICE_INTERACTION"), 583 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING, 584 to = "VOICE_INTERACTION_STARTING"), 585 @ViewDebug.IntToString(from = TYPE_DOCK_DIVIDER, 586 to = "DOCK_DIVIDER"), 587 @ViewDebug.IntToString(from = TYPE_QS_DIALOG, 588 to = "QS_DIALOG"), 589 @ViewDebug.IntToString(from = TYPE_SCREENSHOT, 590 to = "SCREENSHOT"), 591 @ViewDebug.IntToString(from = TYPE_APPLICATION_OVERLAY, 592 to = "APPLICATION_OVERLAY") 593 }) 594 public int type; 595 596 /** 597 * Start of window types that represent normal application windows. 598 */ 599 public static final int FIRST_APPLICATION_WINDOW = 1; 600 601 /** 602 * Window type: an application window that serves as the "base" window 603 * of the overall application; all other application windows will 604 * appear on top of it. 605 * In multiuser systems shows only on the owning user's window. 606 */ 607 public static final int TYPE_BASE_APPLICATION = 1; 608 609 /** 610 * Window type: a normal application window. The {@link #token} must be 611 * an Activity token identifying who the window belongs to. 612 * In multiuser systems shows only on the owning user's window. 613 */ 614 public static final int TYPE_APPLICATION = 2; 615 616 /** 617 * Window type: special application window that is displayed while the 618 * application is starting. Not for use by applications themselves; 619 * this is used by the system to display something until the 620 * application can show its own windows. 621 * In multiuser systems shows on all users' windows. 622 */ 623 public static final int TYPE_APPLICATION_STARTING = 3; 624 625 /** 626 * Window type: a variation on TYPE_APPLICATION that ensures the window 627 * manager will wait for this window to be drawn before the app is shown. 628 * In multiuser systems shows only on the owning user's window. 629 */ 630 public static final int TYPE_DRAWN_APPLICATION = 4; 631 632 /** 633 * End of types of application windows. 634 */ 635 public static final int LAST_APPLICATION_WINDOW = 99; 636 637 /** 638 * Start of types of sub-windows. The {@link #token} of these windows 639 * must be set to the window they are attached to. These types of 640 * windows are kept next to their attached window in Z-order, and their 641 * coordinate space is relative to their attached window. 642 */ 643 public static final int FIRST_SUB_WINDOW = 1000; 644 645 /** 646 * Window type: a panel on top of an application window. These windows 647 * appear on top of their attached window. 648 */ 649 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; 650 651 /** 652 * Window type: window for showing media (such as video). These windows 653 * are displayed behind their attached window. 654 */ 655 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1; 656 657 /** 658 * Window type: a sub-panel on top of an application window. These 659 * windows are displayed on top their attached window and any 660 * {@link #TYPE_APPLICATION_PANEL} panels. 661 */ 662 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2; 663 664 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout 665 * of the window happens as that of a top-level window, <em>not</em> 666 * as a child of its container. 667 */ 668 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3; 669 670 /** 671 * Window type: window for showing overlays on top of media windows. 672 * These windows are displayed between TYPE_APPLICATION_MEDIA and the 673 * application window. They should be translucent to be useful. This 674 * is a big ugly hack so: 675 * @hide 676 */ 677 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4; 678 679 /** 680 * Window type: a above sub-panel on top of an application window and it's 681 * sub-panel windows. These windows are displayed on top of their attached window 682 * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels. 683 * @hide 684 */ 685 public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5; 686 687 /** 688 * End of types of sub-windows. 689 */ 690 public static final int LAST_SUB_WINDOW = 1999; 691 692 /** 693 * Start of system-specific window types. These are not normally 694 * created by applications. 695 */ 696 public static final int FIRST_SYSTEM_WINDOW = 2000; 697 698 /** 699 * Window type: the status bar. There can be only one status bar 700 * window; it is placed at the top of the screen, and all other 701 * windows are shifted down so they are below it. 702 * In multiuser systems shows on all users' windows. 703 */ 704 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; 705 706 /** 707 * Window type: the search bar. There can be only one search bar 708 * window; it is placed at the top of the screen. 709 * In multiuser systems shows on all users' windows. 710 */ 711 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; 712 713 /** 714 * Window type: phone. These are non-application windows providing 715 * user interaction with the phone (in particular incoming calls). 716 * These windows are normally placed above all applications, but behind 717 * the status bar. 718 * In multiuser systems shows on all users' windows. 719 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 720 */ 721 @Deprecated 722 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; 723 724 /** 725 * Window type: system window, such as low power alert. These windows 726 * are always on top of application windows. 727 * In multiuser systems shows only on the owning user's window. 728 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 729 */ 730 @Deprecated 731 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; 732 733 /** 734 * Window type: keyguard window. 735 * In multiuser systems shows on all users' windows. 736 * @removed 737 */ 738 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; 739 740 /** 741 * Window type: transient notifications. 742 * In multiuser systems shows only on the owning user's window. 743 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 744 */ 745 @Deprecated 746 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; 747 748 /** 749 * Window type: system overlay windows, which need to be displayed 750 * on top of everything else. These windows must not take input 751 * focus, or they will interfere with the keyguard. 752 * In multiuser systems shows only on the owning user's window. 753 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 754 */ 755 @Deprecated 756 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; 757 758 /** 759 * Window type: priority phone UI, which needs to be displayed even if 760 * the keyguard is active. These windows must not take input 761 * focus, or they will interfere with the keyguard. 762 * In multiuser systems shows on all users' windows. 763 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 764 */ 765 @Deprecated 766 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; 767 768 /** 769 * Window type: panel that slides out from the status bar 770 * In multiuser systems shows on all users' windows. 771 */ 772 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; 773 774 /** 775 * Window type: dialogs that the keyguard shows 776 * In multiuser systems shows on all users' windows. 777 */ 778 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; 779 780 /** 781 * Window type: internal system error windows, appear on top of 782 * everything they can. 783 * In multiuser systems shows only on the owning user's window. 784 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 785 */ 786 @Deprecated 787 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; 788 789 /** 790 * Window type: internal input methods windows, which appear above 791 * the normal UI. Application windows may be resized or panned to keep 792 * the input focus visible while this window is displayed. 793 * In multiuser systems shows only on the owning user's window. 794 */ 795 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; 796 797 /** 798 * Window type: internal input methods dialog windows, which appear above 799 * the current input method window. 800 * In multiuser systems shows only on the owning user's window. 801 */ 802 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; 803 804 /** 805 * Window type: wallpaper window, placed behind any window that wants 806 * to sit on top of the wallpaper. 807 * In multiuser systems shows only on the owning user's window. 808 */ 809 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; 810 811 /** 812 * Window type: panel that slides out from over the status bar 813 * In multiuser systems shows on all users' windows. 814 */ 815 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; 816 817 /** 818 * Window type: secure system overlay windows, which need to be displayed 819 * on top of everything else. These windows must not take input 820 * focus, or they will interfere with the keyguard. 821 * 822 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the 823 * system itself is allowed to create these overlays. Applications cannot 824 * obtain permission to create secure system overlays. 825 * 826 * In multiuser systems shows only on the owning user's window. 827 * @hide 828 */ 829 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; 830 831 /** 832 * Window type: the drag-and-drop pseudowindow. There is only one 833 * drag layer (at most), and it is placed on top of all other windows. 834 * In multiuser systems shows only on the owning user's window. 835 * @hide 836 */ 837 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; 838 839 /** 840 * Window type: panel that slides out from over the status bar 841 * In multiuser systems shows on all users' windows. These windows 842 * are displayed on top of the stauts bar and any {@link #TYPE_STATUS_BAR_PANEL} 843 * windows. 844 * @hide 845 */ 846 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; 847 848 /** 849 * Window type: (mouse) pointer 850 * In multiuser systems shows on all users' windows. 851 * @hide 852 */ 853 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; 854 855 /** 856 * Window type: Navigation bar (when distinct from status bar) 857 * In multiuser systems shows on all users' windows. 858 * @hide 859 */ 860 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; 861 862 /** 863 * Window type: The volume level overlay/dialog shown when the user 864 * changes the system volume. 865 * In multiuser systems shows on all users' windows. 866 * @hide 867 */ 868 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; 869 870 /** 871 * Window type: The boot progress dialog, goes on top of everything 872 * in the world. 873 * In multiuser systems shows on all users' windows. 874 * @hide 875 */ 876 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; 877 878 /** 879 * Window type to consume input events when the systemUI bars are hidden. 880 * In multiuser systems shows on all users' windows. 881 * @hide 882 */ 883 public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22; 884 885 /** 886 * Window type: Dreams (screen saver) window, just above keyguard. 887 * In multiuser systems shows only on the owning user's window. 888 * @hide 889 */ 890 public static final int TYPE_DREAM = FIRST_SYSTEM_WINDOW+23; 891 892 /** 893 * Window type: Navigation bar panel (when navigation bar is distinct from status bar) 894 * In multiuser systems shows on all users' windows. 895 * @hide 896 */ 897 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; 898 899 /** 900 * Window type: Display overlay window. Used to simulate secondary display devices. 901 * In multiuser systems shows on all users' windows. 902 * @hide 903 */ 904 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; 905 906 /** 907 * Window type: Magnification overlay window. Used to highlight the magnified 908 * portion of a display when accessibility magnification is enabled. 909 * In multiuser systems shows on all users' windows. 910 * @hide 911 */ 912 public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27; 913 914 /** 915 * Window type: Window for Presentation on top of private 916 * virtual display. 917 */ 918 public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30; 919 920 /** 921 * Window type: Windows in the voice interaction layer. 922 * @hide 923 */ 924 public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31; 925 926 /** 927 * Window type: Windows that are overlaid <em>only</em> by a connected {@link 928 * android.accessibilityservice.AccessibilityService} for interception of 929 * user interactions without changing the windows an accessibility service 930 * can introspect. In particular, an accessibility service can introspect 931 * only windows that a sighted user can interact with which is they can touch 932 * these windows or can type into these windows. For example, if there 933 * is a full screen accessibility overlay that is touchable, the windows 934 * below it will be introspectable by an accessibility service even though 935 * they are covered by a touchable window. 936 */ 937 public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32; 938 939 /** 940 * Window type: Starting window for voice interaction layer. 941 * @hide 942 */ 943 public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33; 944 945 /** 946 * Window for displaying a handle used for resizing docked stacks. This window is owned 947 * by the system process. 948 * @hide 949 */ 950 public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34; 951 952 /** 953 * Window type: like {@link #TYPE_APPLICATION_ATTACHED_DIALOG}, but used 954 * by Quick Settings Tiles. 955 * @hide 956 */ 957 public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35; 958 959 /** 960 * Window type: shares similar characteristics with {@link #TYPE_DREAM}. The layer is 961 * reserved for screenshot region selection. These windows must not take input focus. 962 * @hide 963 */ 964 public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36; 965 966 /** 967 * Window type: Window for Presentation on an external display. 968 * @see android.app.Presentation 969 * @hide 970 */ 971 public static final int TYPE_PRESENTATION = FIRST_SYSTEM_WINDOW + 37; 972 973 /** 974 * Window type: Application overlay windows are displayed above all activity windows 975 * (types between {@link #FIRST_APPLICATION_WINDOW} and {@link #LAST_APPLICATION_WINDOW}) 976 * but below critical system windows like the status bar or IME. 977 * <p> 978 * The system may change the position, size, or visibility of these windows at anytime 979 * to reduce visual clutter to the user and also manage resources. 980 * <p> 981 * Requires {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission. 982 * <p> 983 * The system will adjust the importance of processes with this window type to reduce the 984 * chance of the low-memory-killer killing them. 985 * <p> 986 * In multi-user systems shows only on the owning user's screen. 987 */ 988 public static final int TYPE_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 38; 989 990 /** 991 * End of types of system windows. 992 */ 993 public static final int LAST_SYSTEM_WINDOW = 2999; 994 995 /** 996 * @hide 997 * Used internally when there is no suitable type available. 998 */ 999 public static final int INVALID_WINDOW_TYPE = -1; 1000 1001 /** 1002 * Return true if the window type is an alert window. 1003 * 1004 * @param type The window type. 1005 * @return If the window type is an alert window. 1006 * @hide 1007 */ 1008 public static boolean isSystemAlertWindowType(int type) { 1009 switch (type) { 1010 case TYPE_PHONE: 1011 case TYPE_PRIORITY_PHONE: 1012 case TYPE_SYSTEM_ALERT: 1013 case TYPE_SYSTEM_ERROR: 1014 case TYPE_SYSTEM_OVERLAY: 1015 case TYPE_APPLICATION_OVERLAY: 1016 return true; 1017 } 1018 return false; 1019 } 1020 1021 /** @deprecated this is ignored, this value is set automatically when needed. */ 1022 @Deprecated 1023 public static final int MEMORY_TYPE_NORMAL = 0; 1024 /** @deprecated this is ignored, this value is set automatically when needed. */ 1025 @Deprecated 1026 public static final int MEMORY_TYPE_HARDWARE = 1; 1027 /** @deprecated this is ignored, this value is set automatically when needed. */ 1028 @Deprecated 1029 public static final int MEMORY_TYPE_GPU = 2; 1030 /** @deprecated this is ignored, this value is set automatically when needed. */ 1031 @Deprecated 1032 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 1033 1034 /** 1035 * @deprecated this is ignored 1036 */ 1037 @Deprecated 1038 public int memoryType; 1039 1040 /** Window flag: as long as this window is visible to the user, allow 1041 * the lock screen to activate while the screen is on. 1042 * This can be used independently, or in combination with 1043 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 1044 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 1045 1046 /** Window flag: everything behind this window will be dimmed. 1047 * Use {@link #dimAmount} to control the amount of dim. */ 1048 public static final int FLAG_DIM_BEHIND = 0x00000002; 1049 1050 /** Window flag: blur everything behind this window. 1051 * @deprecated Blurring is no longer supported. */ 1052 @Deprecated 1053 public static final int FLAG_BLUR_BEHIND = 0x00000004; 1054 1055 /** Window flag: this window won't ever get key input focus, so the 1056 * user can not send key or other button events to it. Those will 1057 * instead go to whatever focusable window is behind it. This flag 1058 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 1059 * is explicitly set. 1060 * 1061 * <p>Setting this flag also implies that the window will not need to 1062 * interact with 1063 * a soft input method, so it will be Z-ordered and positioned 1064 * independently of any active input method (typically this means it 1065 * gets Z-ordered on top of the input method, so it can use the full 1066 * screen for its content and cover the input method if needed. You 1067 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 1068 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 1069 1070 /** Window flag: this window can never receive touch events. */ 1071 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 1072 1073 /** Window flag: even when this window is focusable (its 1074 * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events 1075 * outside of the window to be sent to the windows behind it. Otherwise 1076 * it will consume all pointer events itself, regardless of whether they 1077 * are inside of the window. */ 1078 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 1079 1080 /** Window flag: when set, if the device is asleep when the touch 1081 * screen is pressed, you will receive this first touch event. Usually 1082 * the first touch event is consumed by the system since the user can 1083 * not see what they are pressing on. 1084 * 1085 * @deprecated This flag has no effect. 1086 */ 1087 @Deprecated 1088 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 1089 1090 /** Window flag: as long as this window is visible to the user, keep 1091 * the device's screen turned on and bright. */ 1092 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 1093 1094 /** Window flag: place the window within the entire screen, ignoring 1095 * decorations around the border (such as the status bar). The 1096 * window must correctly position its contents to take the screen 1097 * decoration into account. This flag is normally set for you 1098 * by Window as described in {@link Window#setFlags}. 1099 * 1100 * <p>Note: on displays that have a {@link DisplayCutout}, the window may be placed 1101 * such that it avoids the {@link DisplayCutout} area if necessary according to the 1102 * {@link #layoutInDisplayCutoutMode}. 1103 */ 1104 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 1105 1106 /** Window flag: allow window to extend outside of the screen. */ 1107 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 1108 1109 /** 1110 * Window flag: hide all screen decorations (such as the status bar) while 1111 * this window is displayed. This allows the window to use the entire 1112 * display space for itself -- the status bar will be hidden when 1113 * an app window with this flag set is on the top layer. A fullscreen window 1114 * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's 1115 * {@link #softInputMode} field; the window will stay fullscreen 1116 * and will not resize. 1117 * 1118 * <p>This flag can be controlled in your theme through the 1119 * {@link android.R.attr#windowFullscreen} attribute; this attribute 1120 * is automatically set for you in the standard fullscreen themes 1121 * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen}, 1122 * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen}, 1123 * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen}, 1124 * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen}, 1125 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen}, 1126 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and 1127 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p> 1128 */ 1129 public static final int FLAG_FULLSCREEN = 0x00000400; 1130 1131 /** Window flag: override {@link #FLAG_FULLSCREEN} and force the 1132 * screen decorations (such as the status bar) to be shown. */ 1133 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 1134 1135 /** Window flag: turn on dithering when compositing this window to 1136 * the screen. 1137 * @deprecated This flag is no longer used. */ 1138 @Deprecated 1139 public static final int FLAG_DITHER = 0x00001000; 1140 1141 /** Window flag: treat the content of the window as secure, preventing 1142 * it from appearing in screenshots or from being viewed on non-secure 1143 * displays. 1144 * 1145 * <p>See {@link android.view.Display#FLAG_SECURE} for more details about 1146 * secure surfaces and secure displays. 1147 */ 1148 public static final int FLAG_SECURE = 0x00002000; 1149 1150 /** Window flag: a special mode where the layout parameters are used 1151 * to perform scaling of the surface when it is composited to the 1152 * screen. */ 1153 public static final int FLAG_SCALED = 0x00004000; 1154 1155 /** Window flag: intended for windows that will often be used when the user is 1156 * holding the screen against their face, it will aggressively filter the event 1157 * stream to prevent unintended presses in this situation that may not be 1158 * desired for a particular window, when such an event stream is detected, the 1159 * application will receive a CANCEL motion event to indicate this so applications 1160 * can handle this accordingly by taking no action on the event 1161 * until the finger is released. */ 1162 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 1163 1164 /** Window flag: a special option only for use in combination with 1165 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 1166 * screen your window may appear on top of or behind screen decorations 1167 * such as the status bar. By also including this flag, the window 1168 * manager will report the inset rectangle needed to ensure your 1169 * content is not covered by screen decorations. This flag is normally 1170 * set for you by Window as described in {@link Window#setFlags}.*/ 1171 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 1172 1173 /** Window flag: invert the state of {@link #FLAG_NOT_FOCUSABLE} with 1174 * respect to how this window interacts with the current method. That 1175 * is, if FLAG_NOT_FOCUSABLE is set and this flag is set, then the 1176 * window will behave as if it needs to interact with the input method 1177 * and thus be placed behind/away from it; if FLAG_NOT_FOCUSABLE is 1178 * not set and this flag is set, then the window will behave as if it 1179 * doesn't need to interact with the input method and can be placed 1180 * to use more space and cover the input method. 1181 */ 1182 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 1183 1184 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 1185 * can set this flag to receive a single special MotionEvent with 1186 * the action 1187 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 1188 * touches that occur outside of your window. Note that you will not 1189 * receive the full down/move/up gesture, only the location of the 1190 * first down as an ACTION_OUTSIDE. 1191 */ 1192 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 1193 1194 /** Window flag: special flag to let windows be shown when the screen 1195 * is locked. This will let application windows take precedence over 1196 * key guard or any other lock screens. Can be used with 1197 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 1198 * directly before showing the key guard window. Can be used with 1199 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 1200 * non-secure keyguards. This flag only applies to the top-most 1201 * full-screen window. 1202 * @deprecated Use {@link android.R.attr#showWhenLocked} or 1203 * {@link android.app.Activity#setShowWhenLocked(boolean)} instead to prevent an 1204 * unintentional double life-cycle event. 1205 */ 1206 @Deprecated 1207 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 1208 1209 /** Window flag: ask that the system wallpaper be shown behind 1210 * your window. The window surface must be translucent to be able 1211 * to actually see the wallpaper behind it; this flag just ensures 1212 * that the wallpaper surface will be there if this window actually 1213 * has translucent regions. 1214 * 1215 * <p>This flag can be controlled in your theme through the 1216 * {@link android.R.attr#windowShowWallpaper} attribute; this attribute 1217 * is automatically set for you in the standard wallpaper themes 1218 * such as {@link android.R.style#Theme_Wallpaper}, 1219 * {@link android.R.style#Theme_Wallpaper_NoTitleBar}, 1220 * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen}, 1221 * {@link android.R.style#Theme_Holo_Wallpaper}, 1222 * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar}, 1223 * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and 1224 * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p> 1225 */ 1226 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 1227 1228 /** Window flag: when set as a window is being added or made 1229 * visible, once the window has been shown then the system will 1230 * poke the power manager's user activity (as if the user had woken 1231 * up the device) to turn the screen on. 1232 * @deprecated Use {@link android.R.attr#turnScreenOn} or 1233 * {@link android.app.Activity#setTurnScreenOn(boolean)} instead to prevent an 1234 * unintentional double life-cycle event. 1235 */ 1236 @Deprecated 1237 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 1238 1239 /** 1240 * Window flag: when set the window will cause the keyguard to be 1241 * dismissed, only if it is not a secure lock keyguard. Because such a 1242 * keyguard is not needed for security, it will never re-appear if the 1243 * user navigates to another window (in contrast to 1244 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily hide both 1245 * secure and non-secure keyguards but ensure they reappear when the 1246 * user moves to another UI that doesn't hide them). If the keyguard is 1247 * currently active and is secure (requires an unlock credential) than 1248 * the user will still need to confirm it before seeing this window, 1249 * unless {@link #FLAG_SHOW_WHEN_LOCKED} has also been set. 1250 * 1251 * @deprecated Use {@link #FLAG_SHOW_WHEN_LOCKED} or 1252 * {@link KeyguardManager#requestDismissKeyguard} instead. 1253 * Since keyguard was dismissed all the time as long as an 1254 * activity with this flag on its window was focused, 1255 * keyguard couldn't guard against unintentional touches on 1256 * the screen, which isn't desired. 1257 */ 1258 @Deprecated 1259 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 1260 1261 /** Window flag: when set the window will accept for touch events 1262 * outside of its bounds to be sent to other windows that also 1263 * support split touch. When this flag is not set, the first pointer 1264 * that goes down determines the window to which all subsequent touches 1265 * go until all pointers go up. When this flag is set, each pointer 1266 * (not necessarily the first) that goes down determines the window 1267 * to which all subsequent touches of that pointer will go until that 1268 * pointer goes up thereby enabling touches with multiple pointers 1269 * to be split across multiple windows. 1270 */ 1271 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 1272 1273 /** 1274 * <p>Indicates whether this window should be hardware accelerated. 1275 * Requesting hardware acceleration does not guarantee it will happen.</p> 1276 * 1277 * <p>This flag can be controlled programmatically <em>only</em> to enable 1278 * hardware acceleration. To enable hardware acceleration for a given 1279 * window programmatically, do the following:</p> 1280 * 1281 * <pre> 1282 * Window w = activity.getWindow(); // in Activity's onCreate() for instance 1283 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 1284 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); 1285 * </pre> 1286 * 1287 * <p>It is important to remember that this flag <strong>must</strong> 1288 * be set before setting the content view of your activity or dialog.</p> 1289 * 1290 * <p>This flag cannot be used to disable hardware acceleration after it 1291 * was enabled in your manifest using 1292 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively 1293 * and programmatically disable hardware acceleration (for automated testing 1294 * for instance), make sure it is turned off in your manifest and enable it 1295 * on your activity or dialog when you need it instead, using the method 1296 * described above.</p> 1297 * 1298 * <p>This flag is automatically set by the system if the 1299 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 1300 * XML attribute is set to true on an activity or on the application.</p> 1301 */ 1302 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; 1303 1304 /** 1305 * Window flag: allow window contents to extend in to the screen's 1306 * overscan area, if there is one. The window should still correctly 1307 * position its contents to take the overscan area into account. 1308 * 1309 * <p>This flag can be controlled in your theme through the 1310 * {@link android.R.attr#windowOverscan} attribute; this attribute 1311 * is automatically set for you in the standard overscan themes 1312 * such as 1313 * {@link android.R.style#Theme_Holo_NoActionBar_Overscan}, 1314 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan}, 1315 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and 1316 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p> 1317 * 1318 * <p>When this flag is enabled for a window, its normal content may be obscured 1319 * to some degree by the overscan region of the display. To ensure key parts of 1320 * that content are visible to the user, you can use 1321 * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)} 1322 * to set the point in the view hierarchy where the appropriate offsets should 1323 * be applied. (This can be done either by directly calling this function, using 1324 * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy, 1325 * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect) 1326 * View.fitSystemWindows(Rect)} method).</p> 1327 * 1328 * <p>This mechanism for positioning content elements is identical to its equivalent 1329 * use with layout and {@link View#setSystemUiVisibility(int) 1330 * View.setSystemUiVisibility(int)}; here is an example layout that will correctly 1331 * position its UI elements with this overscan flag is set:</p> 1332 * 1333 * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete} 1334 */ 1335 public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000; 1336 1337 /** 1338 * Window flag: request a translucent status bar with minimal system-provided 1339 * background protection. 1340 * 1341 * <p>This flag can be controlled in your theme through the 1342 * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute 1343 * is automatically set for you in the standard translucent decor themes 1344 * such as 1345 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 1346 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 1347 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 1348 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 1349 * 1350 * <p>When this flag is enabled for a window, it automatically sets 1351 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 1352 * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p> 1353 */ 1354 public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000; 1355 1356 /** 1357 * Window flag: request a translucent navigation bar with minimal system-provided 1358 * background protection. 1359 * 1360 * <p>This flag can be controlled in your theme through the 1361 * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute 1362 * is automatically set for you in the standard translucent decor themes 1363 * such as 1364 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 1365 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 1366 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 1367 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 1368 * 1369 * <p>When this flag is enabled for a window, it automatically sets 1370 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 1371 * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p> 1372 */ 1373 public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000; 1374 1375 /** 1376 * Flag for a window in local focus mode. 1377 * Window in local focus mode can control focus independent of window manager using 1378 * {@link Window#setLocalFocus(boolean, boolean)}. 1379 * Usually window in this mode will not get touch/key events from window manager, but will 1380 * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}. 1381 */ 1382 public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000; 1383 1384 /** Window flag: Enable touches to slide out of a window into neighboring 1385 * windows in mid-gesture instead of being captured for the duration of 1386 * the gesture. 1387 * 1388 * This flag changes the behavior of touch focus for this window only. 1389 * Touches can slide out of the window but they cannot necessarily slide 1390 * back in (unless the other window with touch focus permits it). 1391 * 1392 * {@hide} 1393 */ 1394 public static final int FLAG_SLIPPERY = 0x20000000; 1395 1396 /** 1397 * Window flag: When requesting layout with an attached window, the attached window may 1398 * overlap with the screen decorations of the parent window such as the navigation bar. By 1399 * including this flag, the window manager will layout the attached window within the decor 1400 * frame of the parent window such that it doesn't overlap with screen decorations. 1401 */ 1402 public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000; 1403 1404 /** 1405 * Flag indicating that this Window is responsible for drawing the background for the 1406 * system bars. If set, the system bars are drawn with a transparent background and the 1407 * corresponding areas in this window are filled with the colors specified in 1408 * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}. 1409 */ 1410 public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000; 1411 1412 /** 1413 * Various behavioral options/flags. Default is none. 1414 * 1415 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 1416 * @see #FLAG_DIM_BEHIND 1417 * @see #FLAG_NOT_FOCUSABLE 1418 * @see #FLAG_NOT_TOUCHABLE 1419 * @see #FLAG_NOT_TOUCH_MODAL 1420 * @see #FLAG_TOUCHABLE_WHEN_WAKING 1421 * @see #FLAG_KEEP_SCREEN_ON 1422 * @see #FLAG_LAYOUT_IN_SCREEN 1423 * @see #FLAG_LAYOUT_NO_LIMITS 1424 * @see #FLAG_FULLSCREEN 1425 * @see #FLAG_FORCE_NOT_FULLSCREEN 1426 * @see #FLAG_SECURE 1427 * @see #FLAG_SCALED 1428 * @see #FLAG_IGNORE_CHEEK_PRESSES 1429 * @see #FLAG_LAYOUT_INSET_DECOR 1430 * @see #FLAG_ALT_FOCUSABLE_IM 1431 * @see #FLAG_WATCH_OUTSIDE_TOUCH 1432 * @see #FLAG_SHOW_WHEN_LOCKED 1433 * @see #FLAG_SHOW_WALLPAPER 1434 * @see #FLAG_TURN_SCREEN_ON 1435 * @see #FLAG_DISMISS_KEYGUARD 1436 * @see #FLAG_SPLIT_TOUCH 1437 * @see #FLAG_HARDWARE_ACCELERATED 1438 * @see #FLAG_LOCAL_FOCUS_MODE 1439 * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 1440 */ 1441 @ViewDebug.ExportedProperty(flagMapping = { 1442 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 1443 name = "ALLOW_LOCK_WHILE_SCREEN_ON"), 1444 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 1445 name = "DIM_BEHIND"), 1446 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 1447 name = "BLUR_BEHIND"), 1448 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 1449 name = "NOT_FOCUSABLE"), 1450 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 1451 name = "NOT_TOUCHABLE"), 1452 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 1453 name = "NOT_TOUCH_MODAL"), 1454 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING, 1455 name = "TOUCHABLE_WHEN_WAKING"), 1456 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 1457 name = "KEEP_SCREEN_ON"), 1458 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 1459 name = "LAYOUT_IN_SCREEN"), 1460 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS, 1461 name = "LAYOUT_NO_LIMITS"), 1462 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 1463 name = "FULLSCREEN"), 1464 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN, 1465 name = "FORCE_NOT_FULLSCREEN"), 1466 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 1467 name = "DITHER"), 1468 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE, 1469 name = "SECURE"), 1470 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED, 1471 name = "SCALED"), 1472 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES, 1473 name = "IGNORE_CHEEK_PRESSES"), 1474 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR, 1475 name = "LAYOUT_INSET_DECOR"), 1476 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM, 1477 name = "ALT_FOCUSABLE_IM"), 1478 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH, 1479 name = "WATCH_OUTSIDE_TOUCH"), 1480 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 1481 name = "SHOW_WHEN_LOCKED"), 1482 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER, 1483 name = "SHOW_WALLPAPER"), 1484 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 1485 name = "TURN_SCREEN_ON"), 1486 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 1487 name = "DISMISS_KEYGUARD"), 1488 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH, 1489 name = "SPLIT_TOUCH"), 1490 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED, 1491 name = "HARDWARE_ACCELERATED"), 1492 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_OVERSCAN, equals = FLAG_LAYOUT_IN_OVERSCAN, 1493 name = "LOCAL_FOCUS_MODE"), 1494 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS, 1495 name = "TRANSLUCENT_STATUS"), 1496 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION, 1497 name = "TRANSLUCENT_NAVIGATION"), 1498 @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE, 1499 name = "LOCAL_FOCUS_MODE"), 1500 @ViewDebug.FlagToString(mask = FLAG_SLIPPERY, equals = FLAG_SLIPPERY, 1501 name = "FLAG_SLIPPERY"), 1502 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_ATTACHED_IN_DECOR, equals = FLAG_LAYOUT_ATTACHED_IN_DECOR, 1503 name = "FLAG_LAYOUT_ATTACHED_IN_DECOR"), 1504 @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, 1505 name = "DRAWS_SYSTEM_BAR_BACKGROUNDS") 1506 }, formatToHexString = true) 1507 public int flags; 1508 1509 /** 1510 * If the window has requested hardware acceleration, but this is not 1511 * allowed in the process it is in, then still render it as if it is 1512 * hardware accelerated. This is used for the starting preview windows 1513 * in the system process, which don't need to have the overhead of 1514 * hardware acceleration (they are just a static rendering), but should 1515 * be rendered as such to match the actual window of the app even if it 1516 * is hardware accelerated. 1517 * Even if the window isn't hardware accelerated, still do its rendering 1518 * as if it was. 1519 * Like {@link #FLAG_HARDWARE_ACCELERATED} except for trusted system windows 1520 * that need hardware acceleration (e.g. LockScreen), where hardware acceleration 1521 * is generally disabled. This flag must be specified in addition to 1522 * {@link #FLAG_HARDWARE_ACCELERATED} to enable hardware acceleration for system 1523 * windows. 1524 * 1525 * @hide 1526 */ 1527 public static final int PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED = 0x00000001; 1528 1529 /** 1530 * In the system process, we globally do not use hardware acceleration 1531 * because there are many threads doing UI there and they conflict. 1532 * If certain parts of the UI that really do want to use hardware 1533 * acceleration, this flag can be set to force it. This is basically 1534 * for the lock screen. Anyone else using it, you are probably wrong. 1535 * 1536 * @hide 1537 */ 1538 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 0x00000002; 1539 1540 /** 1541 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers 1542 * may elect to skip these notifications if they are not doing anything productive with 1543 * them (they do not affect the wallpaper scrolling operation) by calling 1544 * {@link 1545 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}. 1546 * 1547 * @hide 1548 */ 1549 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 0x00000004; 1550 1551 /** In a multiuser system if this flag is set and the owner is a system process then this 1552 * window will appear on all user screens. This overrides the default behavior of window 1553 * types that normally only appear on the owning user's screen. Refer to each window type 1554 * to determine its default behavior. 1555 * 1556 * {@hide} */ 1557 public static final int PRIVATE_FLAG_SHOW_FOR_ALL_USERS = 0x00000010; 1558 1559 /** 1560 * Never animate position changes of the window. 1561 * 1562 * {@hide} 1563 */ 1564 @TestApi 1565 public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 0x00000040; 1566 1567 /** Window flag: special flag to limit the size of the window to be 1568 * original size ([320x480] x density). Used to create window for applications 1569 * running under compatibility mode. 1570 * 1571 * {@hide} */ 1572 public static final int PRIVATE_FLAG_COMPATIBLE_WINDOW = 0x00000080; 1573 1574 /** Window flag: a special option intended for system dialogs. When 1575 * this flag is set, the window will demand focus unconditionally when 1576 * it is created. 1577 * {@hide} */ 1578 public static final int PRIVATE_FLAG_SYSTEM_ERROR = 0x00000100; 1579 1580 /** Window flag: maintain the previous translucent decor state when this window 1581 * becomes top-most. 1582 * {@hide} */ 1583 public static final int PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR = 0x00000200; 1584 1585 /** 1586 * Flag whether the current window is a keyguard window, meaning that it will hide all other 1587 * windows behind it except for windows with flag {@link #FLAG_SHOW_WHEN_LOCKED} set. 1588 * Further, this can only be set by {@link LayoutParams#TYPE_STATUS_BAR}. 1589 * {@hide} 1590 */ 1591 public static final int PRIVATE_FLAG_KEYGUARD = 0x00000400; 1592 1593 /** 1594 * Flag that prevents the wallpaper behind the current window from receiving touch events. 1595 * 1596 * {@hide} 1597 */ 1598 public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 0x00000800; 1599 1600 /** 1601 * Flag to force the status bar window to be visible all the time. If the bar is hidden when 1602 * this flag is set it will be shown again and the bar will have a transparent background. 1603 * This can only be set by {@link LayoutParams#TYPE_STATUS_BAR}. 1604 * 1605 * {@hide} 1606 */ 1607 public static final int PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT = 0x00001000; 1608 1609 /** 1610 * Flag indicating that the x, y, width, and height members should be 1611 * ignored (and thus their previous value preserved). For example 1612 * because they are being managed externally through repositionChild. 1613 * 1614 * {@hide} 1615 */ 1616 public static final int PRIVATE_FLAG_PRESERVE_GEOMETRY = 0x00002000; 1617 1618 /** 1619 * Flag that will make window ignore app visibility and instead depend purely on the decor 1620 * view visibility for determining window visibility. This is used by recents to keep 1621 * drawing after it launches an app. 1622 * @hide 1623 */ 1624 public static final int PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY = 0x00004000; 1625 1626 /** 1627 * Flag to indicate that this window is not expected to be replaced across 1628 * configuration change triggered activity relaunches. In general the WindowManager 1629 * expects Windows to be replaced after relaunch, and thus it will preserve their surfaces 1630 * until the replacement is ready to show in order to prevent visual glitch. However 1631 * some windows, such as PopupWindows expect to be cleared across configuration change, 1632 * and thus should hint to the WindowManager that it should not wait for a replacement. 1633 * @hide 1634 */ 1635 public static final int PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH = 0x00008000; 1636 1637 /** 1638 * Flag to indicate that this child window should always be laid-out in the parent 1639 * frame regardless of the current windowing mode configuration. 1640 * @hide 1641 */ 1642 public static final int PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME = 0x00010000; 1643 1644 /** 1645 * Flag to indicate that this window is always drawing the status bar background, no matter 1646 * what the other flags are. 1647 * @hide 1648 */ 1649 public static final int PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND = 0x00020000; 1650 1651 /** 1652 * Flag to indicate that this window needs Sustained Performance Mode if 1653 * the device supports it. 1654 * @hide 1655 */ 1656 public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 0x00040000; 1657 1658 /** 1659 * Flag to indicate that any window added by an application process that is of type 1660 * {@link #TYPE_TOAST} or that requires 1661 * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when 1662 * this window is visible. 1663 * @hide 1664 */ 1665 @RequiresPermission(permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS) 1666 public static final int PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 0x00080000; 1667 1668 /** 1669 * Indicates that this window is the rounded corners overlay present on some 1670 * devices this means that it will be excluded from: screenshots, 1671 * screen magnification, and mirroring. 1672 * @hide 1673 */ 1674 public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 0x00100000; 1675 1676 /** 1677 * If this flag is set on the window, window manager will acquire a sleep token that puts 1678 * all activities to sleep as long as this window is visible. When this flag is set, the 1679 * window needs to occlude all activity windows. 1680 * @hide 1681 */ 1682 @RequiresPermission(permission.DEVICE_POWER) 1683 public static final int PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN = 0x00200000; 1684 1685 /** 1686 * Flag to indicate that this window should be considered a screen decoration similar to the 1687 * nav bar and status bar. This will cause this window to affect the window insets reported 1688 * to other windows when it is visible. 1689 * @hide 1690 */ 1691 @RequiresPermission(permission.STATUS_BAR_SERVICE) 1692 public static final int PRIVATE_FLAG_IS_SCREEN_DECOR = 0x00400000; 1693 1694 /** 1695 * Control flags that are private to the platform. 1696 * @hide 1697 */ 1698 @ViewDebug.ExportedProperty(flagMapping = { 1699 @ViewDebug.FlagToString( 1700 mask = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED, 1701 equals = PRIVATE_FLAG_FAKE_HARDWARE_ACCELERATED, 1702 name = "FAKE_HARDWARE_ACCELERATED"), 1703 @ViewDebug.FlagToString( 1704 mask = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED, 1705 equals = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED, 1706 name = "FORCE_HARDWARE_ACCELERATED"), 1707 @ViewDebug.FlagToString( 1708 mask = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS, 1709 equals = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS, 1710 name = "WANTS_OFFSET_NOTIFICATIONS"), 1711 @ViewDebug.FlagToString( 1712 mask = PRIVATE_FLAG_SHOW_FOR_ALL_USERS, 1713 equals = PRIVATE_FLAG_SHOW_FOR_ALL_USERS, 1714 name = "SHOW_FOR_ALL_USERS"), 1715 @ViewDebug.FlagToString( 1716 mask = PRIVATE_FLAG_NO_MOVE_ANIMATION, 1717 equals = PRIVATE_FLAG_NO_MOVE_ANIMATION, 1718 name = "NO_MOVE_ANIMATION"), 1719 @ViewDebug.FlagToString( 1720 mask = PRIVATE_FLAG_COMPATIBLE_WINDOW, 1721 equals = PRIVATE_FLAG_COMPATIBLE_WINDOW, 1722 name = "COMPATIBLE_WINDOW"), 1723 @ViewDebug.FlagToString( 1724 mask = PRIVATE_FLAG_SYSTEM_ERROR, 1725 equals = PRIVATE_FLAG_SYSTEM_ERROR, 1726 name = "SYSTEM_ERROR"), 1727 @ViewDebug.FlagToString( 1728 mask = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR, 1729 equals = PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR, 1730 name = "INHERIT_TRANSLUCENT_DECOR"), 1731 @ViewDebug.FlagToString( 1732 mask = PRIVATE_FLAG_KEYGUARD, 1733 equals = PRIVATE_FLAG_KEYGUARD, 1734 name = "KEYGUARD"), 1735 @ViewDebug.FlagToString( 1736 mask = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS, 1737 equals = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS, 1738 name = "DISABLE_WALLPAPER_TOUCH_EVENTS"), 1739 @ViewDebug.FlagToString( 1740 mask = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT, 1741 equals = PRIVATE_FLAG_FORCE_STATUS_BAR_VISIBLE_TRANSPARENT, 1742 name = "FORCE_STATUS_BAR_VISIBLE_TRANSPARENT"), 1743 @ViewDebug.FlagToString( 1744 mask = PRIVATE_FLAG_PRESERVE_GEOMETRY, 1745 equals = PRIVATE_FLAG_PRESERVE_GEOMETRY, 1746 name = "PRESERVE_GEOMETRY"), 1747 @ViewDebug.FlagToString( 1748 mask = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY, 1749 equals = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY, 1750 name = "FORCE_DECOR_VIEW_VISIBILITY"), 1751 @ViewDebug.FlagToString( 1752 mask = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH, 1753 equals = PRIVATE_FLAG_WILL_NOT_REPLACE_ON_RELAUNCH, 1754 name = "WILL_NOT_REPLACE_ON_RELAUNCH"), 1755 @ViewDebug.FlagToString( 1756 mask = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME, 1757 equals = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME, 1758 name = "LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"), 1759 @ViewDebug.FlagToString( 1760 mask = PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND, 1761 equals = PRIVATE_FLAG_FORCE_DRAW_STATUS_BAR_BACKGROUND, 1762 name = "FORCE_DRAW_STATUS_BAR_BACKGROUND"), 1763 @ViewDebug.FlagToString( 1764 mask = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, 1765 equals = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, 1766 name = "SUSTAINED_PERFORMANCE_MODE"), 1767 @ViewDebug.FlagToString( 1768 mask = PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, 1769 equals = PRIVATE_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, 1770 name = "HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), 1771 @ViewDebug.FlagToString( 1772 mask = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY, 1773 equals = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY, 1774 name = "IS_ROUNDED_CORNERS_OVERLAY"), 1775 @ViewDebug.FlagToString( 1776 mask = PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN, 1777 equals = PRIVATE_FLAG_ACQUIRES_SLEEP_TOKEN, 1778 name = "ACQUIRES_SLEEP_TOKEN"), 1779 @ViewDebug.FlagToString( 1780 mask = PRIVATE_FLAG_IS_SCREEN_DECOR, 1781 equals = PRIVATE_FLAG_IS_SCREEN_DECOR, 1782 name = "IS_SCREEN_DECOR") 1783 }) 1784 @TestApi 1785 public int privateFlags; 1786 1787 /** 1788 * Value for {@link #needsMenuKey} for a window that has not explicitly specified if it 1789 * needs {@link #NEEDS_MENU_SET_TRUE} or doesn't need {@link #NEEDS_MENU_SET_FALSE} a menu 1790 * key. For this case, we should look at windows behind it to determine the appropriate 1791 * value. 1792 * 1793 * @hide 1794 */ 1795 public static final int NEEDS_MENU_UNSET = 0; 1796 1797 /** 1798 * Value for {@link #needsMenuKey} for a window that has explicitly specified it needs a 1799 * menu key. 1800 * 1801 * @hide 1802 */ 1803 public static final int NEEDS_MENU_SET_TRUE = 1; 1804 1805 /** 1806 * Value for {@link #needsMenuKey} for a window that has explicitly specified it doesn't 1807 * needs a menu key. 1808 * 1809 * @hide 1810 */ 1811 public static final int NEEDS_MENU_SET_FALSE = 2; 1812 1813 /** 1814 * State variable for a window belonging to an activity that responds to 1815 * {@link KeyEvent#KEYCODE_MENU} and therefore needs a Menu key. For devices where Menu is a 1816 * physical button this variable is ignored, but on devices where the Menu key is drawn in 1817 * software it may be hidden unless this variable is set to {@link #NEEDS_MENU_SET_TRUE}. 1818 * 1819 * (Note that Action Bars, when available, are the preferred way to offer additional 1820 * functions otherwise accessed via an options menu.) 1821 * 1822 * {@hide} 1823 */ 1824 public int needsMenuKey = NEEDS_MENU_UNSET; 1825 1826 /** 1827 * Given a particular set of window manager flags, determine whether 1828 * such a window may be a target for an input method when it has 1829 * focus. In particular, this checks the 1830 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 1831 * flags and returns true if the combination of the two corresponds 1832 * to a window that needs to be behind the input method so that the 1833 * user can type into it. 1834 * 1835 * @param flags The current window manager flags. 1836 * 1837 * @return Returns true if such a window should be behind/interact 1838 * with an input method, false if not. 1839 */ 1840 public static boolean mayUseInputMethod(int flags) { 1841 switch (flags&(FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM)) { 1842 case 0: 1843 case FLAG_NOT_FOCUSABLE|FLAG_ALT_FOCUSABLE_IM: 1844 return true; 1845 } 1846 return false; 1847 } 1848 1849 /** 1850 * Mask for {@link #softInputMode} of the bits that determine the 1851 * desired visibility state of the soft input area for this window. 1852 */ 1853 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 1854 1855 /** 1856 * Visibility state for {@link #softInputMode}: no state has been specified. The system may 1857 * show or hide the software keyboard for better user experience when the window gains 1858 * focus. 1859 */ 1860 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 1861 1862 /** 1863 * Visibility state for {@link #softInputMode}: please don't change the state of 1864 * the soft input area. 1865 */ 1866 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 1867 1868 /** 1869 * Visibility state for {@link #softInputMode}: please hide any soft input 1870 * area when normally appropriate (when the user is navigating 1871 * forward to your window). 1872 */ 1873 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 1874 1875 /** 1876 * Visibility state for {@link #softInputMode}: please always hide any 1877 * soft input area when this window receives focus. 1878 */ 1879 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 1880 1881 /** 1882 * Visibility state for {@link #softInputMode}: please show the soft 1883 * input area when normally appropriate (when the user is navigating 1884 * forward to your window). 1885 * 1886 * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag 1887 * is ignored unless there is a focused view that returns {@code true} from 1888 * {@link View#isInEditMode()} when the window is focused.</p> 1889 */ 1890 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 1891 1892 /** 1893 * Visibility state for {@link #softInputMode}: please always make the 1894 * soft input area visible when this window receives input focus. 1895 * 1896 * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag 1897 * is ignored unless there is a focused view that returns {@code true} from 1898 * {@link View#isInEditMode()} when the window is focused.</p> 1899 */ 1900 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 1901 1902 /** 1903 * Mask for {@link #softInputMode} of the bits that determine the 1904 * way that the window should be adjusted to accommodate the soft 1905 * input window. 1906 */ 1907 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 1908 1909 /** Adjustment option for {@link #softInputMode}: nothing specified. 1910 * The system will try to pick one or 1911 * the other depending on the contents of the window. 1912 */ 1913 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 1914 1915 /** Adjustment option for {@link #softInputMode}: set to allow the 1916 * window to be resized when an input 1917 * method is shown, so that its contents are not covered by the input 1918 * method. This can <em>not</em> be combined with 1919 * {@link #SOFT_INPUT_ADJUST_PAN}; if 1920 * neither of these are set, then the system will try to pick one or 1921 * the other depending on the contents of the window. If the window's 1922 * layout parameter flags include {@link #FLAG_FULLSCREEN}, this 1923 * value for {@link #softInputMode} will be ignored; the window will 1924 * not resize, but will stay fullscreen. 1925 */ 1926 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 1927 1928 /** Adjustment option for {@link #softInputMode}: set to have a window 1929 * pan when an input method is 1930 * shown, so it doesn't need to deal with resizing but just panned 1931 * by the framework to ensure the current input focus is visible. This 1932 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 1933 * neither of these are set, then the system will try to pick one or 1934 * the other depending on the contents of the window. 1935 */ 1936 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 1937 1938 /** Adjustment option for {@link #softInputMode}: set to have a window 1939 * not adjust for a shown input method. The window will not be resized, 1940 * and it will not be panned to make its focus visible. 1941 */ 1942 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 1943 1944 /** 1945 * Bit for {@link #softInputMode}: set when the user has navigated 1946 * forward to the window. This is normally set automatically for 1947 * you by the system, though you may want to set it in certain cases 1948 * when you are displaying a window yourself. This flag will always 1949 * be cleared automatically after the window is displayed. 1950 */ 1951 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 1952 1953 /** 1954 * An internal annotation for flags that can be specified to {@link #softInputMode}. 1955 * 1956 * @hide 1957 */ 1958 @Retention(RetentionPolicy.SOURCE) 1959 @IntDef(flag = true, prefix = { "SOFT_INPUT_" }, value = { 1960 SOFT_INPUT_STATE_UNSPECIFIED, 1961 SOFT_INPUT_STATE_UNCHANGED, 1962 SOFT_INPUT_STATE_HIDDEN, 1963 SOFT_INPUT_STATE_ALWAYS_HIDDEN, 1964 SOFT_INPUT_STATE_VISIBLE, 1965 SOFT_INPUT_STATE_ALWAYS_VISIBLE, 1966 SOFT_INPUT_ADJUST_UNSPECIFIED, 1967 SOFT_INPUT_ADJUST_RESIZE, 1968 SOFT_INPUT_ADJUST_PAN, 1969 SOFT_INPUT_ADJUST_NOTHING, 1970 SOFT_INPUT_IS_FORWARD_NAVIGATION, 1971 }) 1972 public @interface SoftInputModeFlags {} 1973 1974 /** 1975 * Desired operating mode for any soft input area. May be any combination 1976 * of: 1977 * 1978 * <ul> 1979 * <li> One of the visibility states 1980 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 1981 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_HIDDEN}, 1982 * {@link #SOFT_INPUT_STATE_VISIBLE}, or {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}. 1983 * <li> One of the adjustment options 1984 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, {@link #SOFT_INPUT_ADJUST_RESIZE}, 1985 * {@link #SOFT_INPUT_ADJUST_PAN}, or {@link #SOFT_INPUT_ADJUST_NOTHING}. 1986 * </ul> 1987 * 1988 * 1989 * <p>This flag can be controlled in your theme through the 1990 * {@link android.R.attr#windowSoftInputMode} attribute.</p> 1991 */ 1992 @SoftInputModeFlags 1993 public int softInputMode; 1994 1995 /** 1996 * Placement of window within the screen as per {@link Gravity}. Both 1997 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 1998 * android.graphics.Rect) Gravity.apply} and 1999 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 2000 * Gravity.applyDisplay} are used during window layout, with this value 2001 * given as the desired gravity. For example you can specify 2002 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 2003 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 2004 * to control the behavior of 2005 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 2006 * Gravity.applyDisplay}. 2007 * 2008 * @see Gravity 2009 */ 2010 public int gravity; 2011 2012 /** 2013 * The horizontal margin, as a percentage of the container's width, 2014 * between the container and the widget. See 2015 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 2016 * android.graphics.Rect) Gravity.apply} for how this is used. This 2017 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 2018 */ 2019 public float horizontalMargin; 2020 2021 /** 2022 * The vertical margin, as a percentage of the container's height, 2023 * between the container and the widget. See 2024 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 2025 * android.graphics.Rect) Gravity.apply} for how this is used. This 2026 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 2027 */ 2028 public float verticalMargin; 2029 2030 /** 2031 * Positive insets between the drawing surface and window content. 2032 * 2033 * @hide 2034 */ 2035 public final Rect surfaceInsets = new Rect(); 2036 2037 /** 2038 * Whether the surface insets have been manually set. When set to 2039 * {@code false}, the view root will automatically determine the 2040 * appropriate surface insets. 2041 * 2042 * @see #surfaceInsets 2043 * @hide 2044 */ 2045 public boolean hasManualSurfaceInsets; 2046 2047 /** 2048 * Whether the previous surface insets should be used vs. what is currently set. When set 2049 * to {@code true}, the view root will ignore surfaces insets in this object and use what 2050 * it currently has. 2051 * 2052 * @see #surfaceInsets 2053 * @hide 2054 */ 2055 public boolean preservePreviousSurfaceInsets = true; 2056 2057 /** 2058 * The desired bitmap format. May be one of the constants in 2059 * {@link android.graphics.PixelFormat}. The choice of format 2060 * might be overridden by {@link #setColorMode(int)}. Default is OPAQUE. 2061 */ 2062 public int format; 2063 2064 /** 2065 * A style resource defining the animations to use for this window. 2066 * This must be a system resource; it can not be an application resource 2067 * because the window manager does not have access to applications. 2068 */ 2069 public int windowAnimations; 2070 2071 /** 2072 * An alpha value to apply to this entire window. 2073 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 2074 */ 2075 public float alpha = 1.0f; 2076 2077 /** 2078 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 2079 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 2080 * dim. 2081 */ 2082 public float dimAmount = 1.0f; 2083 2084 /** 2085 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 2086 * indicating that the brightness value is not overridden for this window 2087 * and normal brightness policy should be used. 2088 */ 2089 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 2090 2091 /** 2092 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 2093 * indicating that the screen or button backlight brightness should be set 2094 * to the lowest value when this window is in front. 2095 */ 2096 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 2097 2098 /** 2099 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 2100 * indicating that the screen or button backlight brightness should be set 2101 * to the hightest value when this window is in front. 2102 */ 2103 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 2104 2105 /** 2106 * This can be used to override the user's preferred brightness of 2107 * the screen. A value of less than 0, the default, means to use the 2108 * preferred screen brightness. 0 to 1 adjusts the brightness from 2109 * dark to full bright. 2110 */ 2111 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 2112 2113 /** 2114 * This can be used to override the standard behavior of the button and 2115 * keyboard backlights. A value of less than 0, the default, means to 2116 * use the standard backlight behavior. 0 to 1 adjusts the brightness 2117 * from dark to full bright. 2118 */ 2119 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 2120 2121 /** 2122 * Unspecified value for {@link #rotationAnimation} indicating 2123 * a lack of preference. 2124 * @hide 2125 */ 2126 public static final int ROTATION_ANIMATION_UNSPECIFIED = -1; 2127 2128 /** 2129 * Value for {@link #rotationAnimation} which specifies that this 2130 * window will visually rotate in or out following a rotation. 2131 */ 2132 public static final int ROTATION_ANIMATION_ROTATE = 0; 2133 2134 /** 2135 * Value for {@link #rotationAnimation} which specifies that this 2136 * window will fade in or out following a rotation. 2137 */ 2138 public static final int ROTATION_ANIMATION_CROSSFADE = 1; 2139 2140 /** 2141 * Value for {@link #rotationAnimation} which specifies that this window 2142 * will immediately disappear or appear following a rotation. 2143 */ 2144 public static final int ROTATION_ANIMATION_JUMPCUT = 2; 2145 2146 /** 2147 * Value for {@link #rotationAnimation} to specify seamless rotation mode. 2148 * This works like JUMPCUT but will fall back to CROSSFADE if rotation 2149 * can't be applied without pausing the screen. For example, this is ideal 2150 * for Camera apps which don't want the viewfinder contents to ever rotate 2151 * or fade (and rather to be seamless) but also don't want ROTATION_ANIMATION_JUMPCUT 2152 * during app transition scenarios where seamless rotation can't be applied. 2153 */ 2154 public static final int ROTATION_ANIMATION_SEAMLESS = 3; 2155 2156 /** 2157 * Define the exit and entry animations used on this window when the device is rotated. 2158 * This only has an affect if the incoming and outgoing topmost 2159 * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered 2160 * by other windows. All other situations default to the 2161 * {@link #ROTATION_ANIMATION_ROTATE} behavior. 2162 * 2163 * @see #ROTATION_ANIMATION_ROTATE 2164 * @see #ROTATION_ANIMATION_CROSSFADE 2165 * @see #ROTATION_ANIMATION_JUMPCUT 2166 */ 2167 public int rotationAnimation = ROTATION_ANIMATION_ROTATE; 2168 2169 /** 2170 * Identifier for this window. This will usually be filled in for 2171 * you. 2172 */ 2173 public IBinder token = null; 2174 2175 /** 2176 * Name of the package owning this window. 2177 */ 2178 public String packageName = null; 2179 2180 /** 2181 * Specific orientation value for a window. 2182 * May be any of the same values allowed 2183 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 2184 * If not set, a default value of 2185 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 2186 * will be used. 2187 */ 2188 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 2189 2190 /** 2191 * The preferred refresh rate for the window. 2192 * 2193 * This must be one of the supported refresh rates obtained for the display(s) the window 2194 * is on. The selected refresh rate will be applied to the display's default mode. 2195 * 2196 * This value is ignored if {@link #preferredDisplayModeId} is set. 2197 * 2198 * @see Display#getSupportedRefreshRates() 2199 * @deprecated use {@link #preferredDisplayModeId} instead 2200 */ 2201 @Deprecated 2202 public float preferredRefreshRate; 2203 2204 /** 2205 * Id of the preferred display mode for the window. 2206 * <p> 2207 * This must be one of the supported modes obtained for the display(s) the window is on. 2208 * A value of {@code 0} means no preference. 2209 * 2210 * @see Display#getSupportedModes() 2211 * @see Display.Mode#getModeId() 2212 */ 2213 public int preferredDisplayModeId; 2214 2215 /** 2216 * Control the visibility of the status bar. 2217 * 2218 * @see View#STATUS_BAR_VISIBLE 2219 * @see View#STATUS_BAR_HIDDEN 2220 */ 2221 public int systemUiVisibility; 2222 2223 /** 2224 * @hide 2225 * The ui visibility as requested by the views in this hierarchy. 2226 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. 2227 */ 2228 public int subtreeSystemUiVisibility; 2229 2230 /** 2231 * Get callbacks about the system ui visibility changing. 2232 * 2233 * TODO: Maybe there should be a bitfield of optional callbacks that we need. 2234 * 2235 * @hide 2236 */ 2237 public boolean hasSystemUiListeners; 2238 2239 2240 /** @hide */ 2241 @Retention(RetentionPolicy.SOURCE) 2242 @IntDef( 2243 flag = true, 2244 value = {LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT, 2245 LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, 2246 LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER}) 2247 @interface LayoutInDisplayCutoutMode {} 2248 2249 /** 2250 * Controls how the window is laid out if there is a {@link DisplayCutout}. 2251 * 2252 * <p> 2253 * Defaults to {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT}. 2254 * 2255 * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT 2256 * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES 2257 * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER 2258 * @see DisplayCutout 2259 * @see android.R.attr#windowLayoutInDisplayCutoutMode 2260 * android:windowLayoutInDisplayCutoutMode 2261 */ 2262 @LayoutInDisplayCutoutMode 2263 public int layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT; 2264 2265 /** 2266 * The window is allowed to extend into the {@link DisplayCutout} area, only if the 2267 * {@link DisplayCutout} is fully contained within a system bar. Otherwise, the window is 2268 * laid out such that it does not overlap with the {@link DisplayCutout} area. 2269 * 2270 * <p> 2271 * In practice, this means that if the window did not set {@link #FLAG_FULLSCREEN} or 2272 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN}, it can extend into the cutout area in portrait 2273 * if the cutout is at the top edge. Similarly for 2274 * {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} and a cutout at the bottom of the screen. 2275 * Otherwise (i.e. fullscreen or landscape) it is laid out such that it does not overlap the 2276 * cutout area. 2277 * 2278 * <p> 2279 * The usual precautions for not overlapping with the status and navigation bar are 2280 * sufficient for ensuring that no important content overlaps with the DisplayCutout. 2281 * 2282 * @see DisplayCutout 2283 * @see WindowInsets 2284 * @see #layoutInDisplayCutoutMode 2285 * @see android.R.attr#windowLayoutInDisplayCutoutMode 2286 * android:windowLayoutInDisplayCutoutMode 2287 */ 2288 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0; 2289 2290 /** 2291 * @deprecated use {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES} 2292 * @hide 2293 */ 2294 @Deprecated 2295 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 1; 2296 2297 /** 2298 * The window is always allowed to extend into the {@link DisplayCutout} areas on the short 2299 * edges of the screen. 2300 * 2301 * The window will never extend into a {@link DisplayCutout} area on the long edges of the 2302 * screen. 2303 * 2304 * <p> 2305 * The window must make sure that no important content overlaps with the 2306 * {@link DisplayCutout}. 2307 * 2308 * <p> 2309 * In this mode, the window extends under cutouts on the short edge of the display in both 2310 * portrait and landscape, regardless of whether the window is hiding the system bars:<br/> 2311 * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/fullscreen_top_no_letterbox.png" 2312 * height="720" 2313 * alt="Screenshot of a fullscreen activity on a display with a cutout at the top edge in 2314 * portrait, no letterbox is applied."/> 2315 * 2316 * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/landscape_top_no_letterbox.png" 2317 * width="720" 2318 * alt="Screenshot of an activity on a display with a cutout at the top edge in landscape, 2319 * no letterbox is applied."/> 2320 * 2321 * <p> 2322 * A cutout in the corner is considered to be on the short edge: <br/> 2323 * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/fullscreen_corner_no_letterbox.png" 2324 * height="720" 2325 * alt="Screenshot of a fullscreen activity on a display with a cutout in the corner in 2326 * portrait, no letterbox is applied."/> 2327 * 2328 * <p> 2329 * On the other hand, should the cutout be on the long edge of the display, a letterbox will 2330 * be applied such that the window does not extend into the cutout on either long edge: 2331 * <br/> 2332 * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/portrait_side_letterbox.png" 2333 * height="720" 2334 * alt="Screenshot of an activity on a display with a cutout on the long edge in portrait, 2335 * letterbox is applied."/> 2336 * 2337 * @see DisplayCutout 2338 * @see WindowInsets#getDisplayCutout() 2339 * @see #layoutInDisplayCutoutMode 2340 * @see android.R.attr#windowLayoutInDisplayCutoutMode 2341 * android:windowLayoutInDisplayCutoutMode 2342 */ 2343 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES = 1; 2344 2345 /** 2346 * The window is never allowed to overlap with the DisplayCutout area. 2347 * 2348 * <p> 2349 * This should be used with windows that transiently set 2350 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN} or {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} 2351 * to avoid a relayout of the window when the respective flag is set or cleared. 2352 * 2353 * @see DisplayCutout 2354 * @see #layoutInDisplayCutoutMode 2355 * @see android.R.attr#windowLayoutInDisplayCutoutMode 2356 * android:windowLayoutInDisplayCutoutMode 2357 */ 2358 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2; 2359 2360 2361 /** 2362 * When this window has focus, disable touch pad pointer gesture processing. 2363 * The window will receive raw position updates from the touch pad instead 2364 * of pointer movements and synthetic touch events. 2365 * 2366 * @hide 2367 */ 2368 public static final int INPUT_FEATURE_DISABLE_POINTER_GESTURES = 0x00000001; 2369 2370 /** 2371 * Does not construct an input channel for this window. The channel will therefore 2372 * be incapable of receiving input. 2373 * 2374 * @hide 2375 */ 2376 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 0x00000002; 2377 2378 /** 2379 * When this window has focus, does not call user activity for all input events so 2380 * the application will have to do it itself. Should only be used by 2381 * the keyguard and phone app. 2382 * <p> 2383 * Should only be used by the keyguard and phone app. 2384 * </p> 2385 * 2386 * @hide 2387 */ 2388 public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 0x00000004; 2389 2390 /** 2391 * Control special features of the input subsystem. 2392 * 2393 * @see #INPUT_FEATURE_DISABLE_POINTER_GESTURES 2394 * @see #INPUT_FEATURE_NO_INPUT_CHANNEL 2395 * @see #INPUT_FEATURE_DISABLE_USER_ACTIVITY 2396 * @hide 2397 */ 2398 public int inputFeatures; 2399 2400 /** 2401 * Sets the number of milliseconds before the user activity timeout occurs 2402 * when this window has focus. A value of -1 uses the standard timeout. 2403 * A value of 0 uses the minimum support display timeout. 2404 * <p> 2405 * This property can only be used to reduce the user specified display timeout; 2406 * it can never make the timeout longer than it normally would be. 2407 * </p><p> 2408 * Should only be used by the keyguard and phone app. 2409 * </p> 2410 * 2411 * @hide 2412 */ 2413 public long userActivityTimeout = -1; 2414 2415 /** 2416 * For windows with an anchor (e.g. PopupWindow), keeps track of the View that anchors the 2417 * window. 2418 * 2419 * @hide 2420 */ 2421 public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID; 2422 2423 /** 2424 * The window title isn't kept in sync with what is displayed in the title bar, so we 2425 * separately track the currently shown title to provide to accessibility. 2426 * 2427 * @hide 2428 */ 2429 @TestApi 2430 public CharSequence accessibilityTitle; 2431 2432 /** 2433 * Sets a timeout in milliseconds before which the window will be hidden 2434 * by the window manager. Useful for transient notifications like toasts 2435 * so we don't have to rely on client cooperation to ensure the window 2436 * is hidden. Must be specified at window creation time. Note that apps 2437 * are not prepared to handle their windows being removed without their 2438 * explicit request and may try to interact with the removed window 2439 * resulting in undefined behavior and crashes. Therefore, we do hide 2440 * such windows to prevent them from overlaying other apps. 2441 * 2442 * @hide 2443 */ 2444 public long hideTimeoutMilliseconds = -1; 2445 2446 /** 2447 * The color mode requested by this window. The target display may 2448 * not be able to honor the request. When the color mode is not set 2449 * to {@link ActivityInfo#COLOR_MODE_DEFAULT}, it might override the 2450 * pixel format specified in {@link #format}. 2451 * 2452 * @hide 2453 */ 2454 @ActivityInfo.ColorMode 2455 private int mColorMode = COLOR_MODE_DEFAULT; 2456 2457 public LayoutParams() { 2458 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 2459 type = TYPE_APPLICATION; 2460 format = PixelFormat.OPAQUE; 2461 } 2462 2463 public LayoutParams(int _type) { 2464 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 2465 type = _type; 2466 format = PixelFormat.OPAQUE; 2467 } 2468 2469 public LayoutParams(int _type, int _flags) { 2470 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 2471 type = _type; 2472 flags = _flags; 2473 format = PixelFormat.OPAQUE; 2474 } 2475 2476 public LayoutParams(int _type, int _flags, int _format) { 2477 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 2478 type = _type; 2479 flags = _flags; 2480 format = _format; 2481 } 2482 2483 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 2484 super(w, h); 2485 type = _type; 2486 flags = _flags; 2487 format = _format; 2488 } 2489 2490 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 2491 int _flags, int _format) { 2492 super(w, h); 2493 x = xpos; 2494 y = ypos; 2495 type = _type; 2496 flags = _flags; 2497 format = _format; 2498 } 2499 2500 public final void setTitle(CharSequence title) { 2501 if (null == title) 2502 title = ""; 2503 2504 mTitle = TextUtils.stringOrSpannedString(title); 2505 } 2506 2507 public final CharSequence getTitle() { 2508 return mTitle != null ? mTitle : ""; 2509 } 2510 2511 /** 2512 * Sets the surface insets based on the elevation (visual z position) of the input view. 2513 * @hide 2514 */ 2515 public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) { 2516 final int surfaceInset = (int) Math.ceil(view.getZ() * 2); 2517 // Partial workaround for b/28318973. Every inset change causes a freeform window 2518 // to jump a little for a few frames. If we never allow surface insets to decrease, 2519 // they will stabilize quickly (often from the very beginning, as most windows start 2520 // as focused). 2521 // TODO(b/22668382) to fix this properly. 2522 if (surfaceInset == 0) { 2523 // OK to have 0 (this is the case for non-freeform windows). 2524 surfaceInsets.set(0, 0, 0, 0); 2525 } else { 2526 surfaceInsets.set( 2527 Math.max(surfaceInset, surfaceInsets.left), 2528 Math.max(surfaceInset, surfaceInsets.top), 2529 Math.max(surfaceInset, surfaceInsets.right), 2530 Math.max(surfaceInset, surfaceInsets.bottom)); 2531 } 2532 hasManualSurfaceInsets = manual; 2533 preservePreviousSurfaceInsets = preservePrevious; 2534 } 2535 2536 /** 2537 * <p>Set the color mode of the window. Setting the color mode might 2538 * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p> 2539 * 2540 * <p>The color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT}, 2541 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or 2542 * {@link ActivityInfo#COLOR_MODE_HDR}.</p> 2543 * 2544 * @see #getColorMode() 2545 */ 2546 public void setColorMode(@ActivityInfo.ColorMode int colorMode) { 2547 mColorMode = colorMode; 2548 } 2549 2550 /** 2551 * Returns the color mode of the window, one of {@link ActivityInfo#COLOR_MODE_DEFAULT}, 2552 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}. 2553 * 2554 * @see #setColorMode(int) 2555 */ 2556 @ActivityInfo.ColorMode 2557 public int getColorMode() { 2558 return mColorMode; 2559 } 2560 2561 /** @hide */ 2562 @SystemApi 2563 public final void setUserActivityTimeout(long timeout) { 2564 userActivityTimeout = timeout; 2565 } 2566 2567 /** @hide */ 2568 @SystemApi 2569 public final long getUserActivityTimeout() { 2570 return userActivityTimeout; 2571 } 2572 2573 public int describeContents() { 2574 return 0; 2575 } 2576 2577 public void writeToParcel(Parcel out, int parcelableFlags) { 2578 out.writeInt(width); 2579 out.writeInt(height); 2580 out.writeInt(x); 2581 out.writeInt(y); 2582 out.writeInt(type); 2583 out.writeInt(flags); 2584 out.writeInt(privateFlags); 2585 out.writeInt(softInputMode); 2586 out.writeInt(layoutInDisplayCutoutMode); 2587 out.writeInt(gravity); 2588 out.writeFloat(horizontalMargin); 2589 out.writeFloat(verticalMargin); 2590 out.writeInt(format); 2591 out.writeInt(windowAnimations); 2592 out.writeFloat(alpha); 2593 out.writeFloat(dimAmount); 2594 out.writeFloat(screenBrightness); 2595 out.writeFloat(buttonBrightness); 2596 out.writeInt(rotationAnimation); 2597 out.writeStrongBinder(token); 2598 out.writeString(packageName); 2599 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 2600 out.writeInt(screenOrientation); 2601 out.writeFloat(preferredRefreshRate); 2602 out.writeInt(preferredDisplayModeId); 2603 out.writeInt(systemUiVisibility); 2604 out.writeInt(subtreeSystemUiVisibility); 2605 out.writeInt(hasSystemUiListeners ? 1 : 0); 2606 out.writeInt(inputFeatures); 2607 out.writeLong(userActivityTimeout); 2608 out.writeInt(surfaceInsets.left); 2609 out.writeInt(surfaceInsets.top); 2610 out.writeInt(surfaceInsets.right); 2611 out.writeInt(surfaceInsets.bottom); 2612 out.writeInt(hasManualSurfaceInsets ? 1 : 0); 2613 out.writeInt(preservePreviousSurfaceInsets ? 1 : 0); 2614 out.writeInt(needsMenuKey); 2615 out.writeLong(accessibilityIdOfAnchor); 2616 TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); 2617 out.writeInt(mColorMode); 2618 out.writeLong(hideTimeoutMilliseconds); 2619 } 2620 2621 public static final Parcelable.Creator<LayoutParams> CREATOR 2622 = new Parcelable.Creator<LayoutParams>() { 2623 public LayoutParams createFromParcel(Parcel in) { 2624 return new LayoutParams(in); 2625 } 2626 2627 public LayoutParams[] newArray(int size) { 2628 return new LayoutParams[size]; 2629 } 2630 }; 2631 2632 2633 public LayoutParams(Parcel in) { 2634 width = in.readInt(); 2635 height = in.readInt(); 2636 x = in.readInt(); 2637 y = in.readInt(); 2638 type = in.readInt(); 2639 flags = in.readInt(); 2640 privateFlags = in.readInt(); 2641 softInputMode = in.readInt(); 2642 layoutInDisplayCutoutMode = in.readInt(); 2643 gravity = in.readInt(); 2644 horizontalMargin = in.readFloat(); 2645 verticalMargin = in.readFloat(); 2646 format = in.readInt(); 2647 windowAnimations = in.readInt(); 2648 alpha = in.readFloat(); 2649 dimAmount = in.readFloat(); 2650 screenBrightness = in.readFloat(); 2651 buttonBrightness = in.readFloat(); 2652 rotationAnimation = in.readInt(); 2653 token = in.readStrongBinder(); 2654 packageName = in.readString(); 2655 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 2656 screenOrientation = in.readInt(); 2657 preferredRefreshRate = in.readFloat(); 2658 preferredDisplayModeId = in.readInt(); 2659 systemUiVisibility = in.readInt(); 2660 subtreeSystemUiVisibility = in.readInt(); 2661 hasSystemUiListeners = in.readInt() != 0; 2662 inputFeatures = in.readInt(); 2663 userActivityTimeout = in.readLong(); 2664 surfaceInsets.left = in.readInt(); 2665 surfaceInsets.top = in.readInt(); 2666 surfaceInsets.right = in.readInt(); 2667 surfaceInsets.bottom = in.readInt(); 2668 hasManualSurfaceInsets = in.readInt() != 0; 2669 preservePreviousSurfaceInsets = in.readInt() != 0; 2670 needsMenuKey = in.readInt(); 2671 accessibilityIdOfAnchor = in.readLong(); 2672 accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 2673 mColorMode = in.readInt(); 2674 hideTimeoutMilliseconds = in.readLong(); 2675 } 2676 2677 @SuppressWarnings({"PointlessBitwiseExpression"}) 2678 public static final int LAYOUT_CHANGED = 1<<0; 2679 public static final int TYPE_CHANGED = 1<<1; 2680 public static final int FLAGS_CHANGED = 1<<2; 2681 public static final int FORMAT_CHANGED = 1<<3; 2682 public static final int ANIMATION_CHANGED = 1<<4; 2683 public static final int DIM_AMOUNT_CHANGED = 1<<5; 2684 public static final int TITLE_CHANGED = 1<<6; 2685 public static final int ALPHA_CHANGED = 1<<7; 2686 public static final int MEMORY_TYPE_CHANGED = 1<<8; 2687 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 2688 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 2689 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 2690 public static final int ROTATION_ANIMATION_CHANGED = 1<<12; 2691 /** {@hide} */ 2692 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13; 2693 /** {@hide} */ 2694 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14; 2695 /** {@hide} */ 2696 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15; 2697 /** {@hide} */ 2698 public static final int INPUT_FEATURES_CHANGED = 1<<16; 2699 /** {@hide} */ 2700 public static final int PRIVATE_FLAGS_CHANGED = 1<<17; 2701 /** {@hide} */ 2702 public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18; 2703 /** {@hide} */ 2704 public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19; 2705 /** {@hide} */ 2706 public static final int SURFACE_INSETS_CHANGED = 1<<20; 2707 /** {@hide} */ 2708 public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21; 2709 /** {@hide} */ 2710 public static final int NEEDS_MENU_KEY_CHANGED = 1 << 22; 2711 /** {@hide} */ 2712 public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23; 2713 /** {@hide} */ 2714 public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24; 2715 /** {@hide} */ 2716 @TestApi 2717 public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25; 2718 /** {@hide} */ 2719 public static final int COLOR_MODE_CHANGED = 1 << 26; 2720 /** {@hide} */ 2721 public static final int EVERYTHING_CHANGED = 0xffffffff; 2722 2723 // internal buffer to backup/restore parameters under compatibility mode. 2724 private int[] mCompatibilityParamsBackup = null; 2725 2726 public final int copyFrom(LayoutParams o) { 2727 int changes = 0; 2728 2729 if (width != o.width) { 2730 width = o.width; 2731 changes |= LAYOUT_CHANGED; 2732 } 2733 if (height != o.height) { 2734 height = o.height; 2735 changes |= LAYOUT_CHANGED; 2736 } 2737 if (x != o.x) { 2738 x = o.x; 2739 changes |= LAYOUT_CHANGED; 2740 } 2741 if (y != o.y) { 2742 y = o.y; 2743 changes |= LAYOUT_CHANGED; 2744 } 2745 if (horizontalWeight != o.horizontalWeight) { 2746 horizontalWeight = o.horizontalWeight; 2747 changes |= LAYOUT_CHANGED; 2748 } 2749 if (verticalWeight != o.verticalWeight) { 2750 verticalWeight = o.verticalWeight; 2751 changes |= LAYOUT_CHANGED; 2752 } 2753 if (horizontalMargin != o.horizontalMargin) { 2754 horizontalMargin = o.horizontalMargin; 2755 changes |= LAYOUT_CHANGED; 2756 } 2757 if (verticalMargin != o.verticalMargin) { 2758 verticalMargin = o.verticalMargin; 2759 changes |= LAYOUT_CHANGED; 2760 } 2761 if (type != o.type) { 2762 type = o.type; 2763 changes |= TYPE_CHANGED; 2764 } 2765 if (flags != o.flags) { 2766 final int diff = flags ^ o.flags; 2767 if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) { 2768 changes |= TRANSLUCENT_FLAGS_CHANGED; 2769 } 2770 flags = o.flags; 2771 changes |= FLAGS_CHANGED; 2772 } 2773 if (privateFlags != o.privateFlags) { 2774 privateFlags = o.privateFlags; 2775 changes |= PRIVATE_FLAGS_CHANGED; 2776 } 2777 if (softInputMode != o.softInputMode) { 2778 softInputMode = o.softInputMode; 2779 changes |= SOFT_INPUT_MODE_CHANGED; 2780 } 2781 if (layoutInDisplayCutoutMode != o.layoutInDisplayCutoutMode) { 2782 layoutInDisplayCutoutMode = o.layoutInDisplayCutoutMode; 2783 changes |= LAYOUT_CHANGED; 2784 } 2785 if (gravity != o.gravity) { 2786 gravity = o.gravity; 2787 changes |= LAYOUT_CHANGED; 2788 } 2789 if (format != o.format) { 2790 format = o.format; 2791 changes |= FORMAT_CHANGED; 2792 } 2793 if (windowAnimations != o.windowAnimations) { 2794 windowAnimations = o.windowAnimations; 2795 changes |= ANIMATION_CHANGED; 2796 } 2797 if (token == null) { 2798 // NOTE: token only copied if the recipient doesn't 2799 // already have one. 2800 token = o.token; 2801 } 2802 if (packageName == null) { 2803 // NOTE: packageName only copied if the recipient doesn't 2804 // already have one. 2805 packageName = o.packageName; 2806 } 2807 if (!Objects.equals(mTitle, o.mTitle) && o.mTitle != null) { 2808 // NOTE: mTitle only copied if the originator set one. 2809 mTitle = o.mTitle; 2810 changes |= TITLE_CHANGED; 2811 } 2812 if (alpha != o.alpha) { 2813 alpha = o.alpha; 2814 changes |= ALPHA_CHANGED; 2815 } 2816 if (dimAmount != o.dimAmount) { 2817 dimAmount = o.dimAmount; 2818 changes |= DIM_AMOUNT_CHANGED; 2819 } 2820 if (screenBrightness != o.screenBrightness) { 2821 screenBrightness = o.screenBrightness; 2822 changes |= SCREEN_BRIGHTNESS_CHANGED; 2823 } 2824 if (buttonBrightness != o.buttonBrightness) { 2825 buttonBrightness = o.buttonBrightness; 2826 changes |= BUTTON_BRIGHTNESS_CHANGED; 2827 } 2828 if (rotationAnimation != o.rotationAnimation) { 2829 rotationAnimation = o.rotationAnimation; 2830 changes |= ROTATION_ANIMATION_CHANGED; 2831 } 2832 2833 if (screenOrientation != o.screenOrientation) { 2834 screenOrientation = o.screenOrientation; 2835 changes |= SCREEN_ORIENTATION_CHANGED; 2836 } 2837 2838 if (preferredRefreshRate != o.preferredRefreshRate) { 2839 preferredRefreshRate = o.preferredRefreshRate; 2840 changes |= PREFERRED_REFRESH_RATE_CHANGED; 2841 } 2842 2843 if (preferredDisplayModeId != o.preferredDisplayModeId) { 2844 preferredDisplayModeId = o.preferredDisplayModeId; 2845 changes |= PREFERRED_DISPLAY_MODE_ID; 2846 } 2847 2848 if (systemUiVisibility != o.systemUiVisibility 2849 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { 2850 systemUiVisibility = o.systemUiVisibility; 2851 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; 2852 changes |= SYSTEM_UI_VISIBILITY_CHANGED; 2853 } 2854 2855 if (hasSystemUiListeners != o.hasSystemUiListeners) { 2856 hasSystemUiListeners = o.hasSystemUiListeners; 2857 changes |= SYSTEM_UI_LISTENER_CHANGED; 2858 } 2859 2860 if (inputFeatures != o.inputFeatures) { 2861 inputFeatures = o.inputFeatures; 2862 changes |= INPUT_FEATURES_CHANGED; 2863 } 2864 2865 if (userActivityTimeout != o.userActivityTimeout) { 2866 userActivityTimeout = o.userActivityTimeout; 2867 changes |= USER_ACTIVITY_TIMEOUT_CHANGED; 2868 } 2869 2870 if (!surfaceInsets.equals(o.surfaceInsets)) { 2871 surfaceInsets.set(o.surfaceInsets); 2872 changes |= SURFACE_INSETS_CHANGED; 2873 } 2874 2875 if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) { 2876 hasManualSurfaceInsets = o.hasManualSurfaceInsets; 2877 changes |= SURFACE_INSETS_CHANGED; 2878 } 2879 2880 if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) { 2881 preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets; 2882 changes |= SURFACE_INSETS_CHANGED; 2883 } 2884 2885 if (needsMenuKey != o.needsMenuKey) { 2886 needsMenuKey = o.needsMenuKey; 2887 changes |= NEEDS_MENU_KEY_CHANGED; 2888 } 2889 2890 if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) { 2891 accessibilityIdOfAnchor = o.accessibilityIdOfAnchor; 2892 changes |= ACCESSIBILITY_ANCHOR_CHANGED; 2893 } 2894 2895 if (!Objects.equals(accessibilityTitle, o.accessibilityTitle) 2896 && o.accessibilityTitle != null) { 2897 // NOTE: accessibilityTitle only copied if the originator set one. 2898 accessibilityTitle = o.accessibilityTitle; 2899 changes |= ACCESSIBILITY_TITLE_CHANGED; 2900 } 2901 2902 if (mColorMode != o.mColorMode) { 2903 mColorMode = o.mColorMode; 2904 changes |= COLOR_MODE_CHANGED; 2905 } 2906 2907 // This can't change, it's only set at window creation time. 2908 hideTimeoutMilliseconds = o.hideTimeoutMilliseconds; 2909 2910 return changes; 2911 } 2912 2913 @Override 2914 public String debug(String output) { 2915 output += "Contents of " + this + ":"; 2916 Log.d("Debug", output); 2917 output = super.debug(""); 2918 Log.d("Debug", output); 2919 Log.d("Debug", ""); 2920 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 2921 return ""; 2922 } 2923 2924 @Override 2925 public String toString() { 2926 return toString(""); 2927 } 2928 2929 /** 2930 * @hide 2931 */ 2932 public void dumpDimensions(StringBuilder sb) { 2933 sb.append('('); 2934 sb.append(x); 2935 sb.append(','); 2936 sb.append(y); 2937 sb.append(")("); 2938 sb.append((width == MATCH_PARENT ? "fill" : (width == WRAP_CONTENT 2939 ? "wrap" : String.valueOf(width)))); 2940 sb.append('x'); 2941 sb.append((height == MATCH_PARENT ? "fill" : (height == WRAP_CONTENT 2942 ? "wrap" : String.valueOf(height)))); 2943 sb.append(")"); 2944 } 2945 2946 /** 2947 * @hide 2948 */ 2949 public String toString(String prefix) { 2950 StringBuilder sb = new StringBuilder(256); 2951 sb.append('{'); 2952 dumpDimensions(sb); 2953 if (horizontalMargin != 0) { 2954 sb.append(" hm="); 2955 sb.append(horizontalMargin); 2956 } 2957 if (verticalMargin != 0) { 2958 sb.append(" vm="); 2959 sb.append(verticalMargin); 2960 } 2961 if (gravity != 0) { 2962 sb.append(" gr="); 2963 sb.append(Gravity.toString(gravity)); 2964 } 2965 if (softInputMode != 0) { 2966 sb.append(" sim={"); 2967 sb.append(softInputModeToString(softInputMode)); 2968 sb.append('}'); 2969 } 2970 if (layoutInDisplayCutoutMode != 0) { 2971 sb.append(" layoutInDisplayCutoutMode="); 2972 sb.append(layoutInDisplayCutoutModeToString(layoutInDisplayCutoutMode)); 2973 } 2974 sb.append(" ty="); 2975 sb.append(ViewDebug.intToString(LayoutParams.class, "type", type)); 2976 if (format != PixelFormat.OPAQUE) { 2977 sb.append(" fmt="); 2978 sb.append(PixelFormat.formatToString(format)); 2979 } 2980 if (windowAnimations != 0) { 2981 sb.append(" wanim=0x"); 2982 sb.append(Integer.toHexString(windowAnimations)); 2983 } 2984 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 2985 sb.append(" or="); 2986 sb.append(ActivityInfo.screenOrientationToString(screenOrientation)); 2987 } 2988 if (alpha != 1.0f) { 2989 sb.append(" alpha="); 2990 sb.append(alpha); 2991 } 2992 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 2993 sb.append(" sbrt="); 2994 sb.append(screenBrightness); 2995 } 2996 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 2997 sb.append(" bbrt="); 2998 sb.append(buttonBrightness); 2999 } 3000 if (rotationAnimation != ROTATION_ANIMATION_ROTATE) { 3001 sb.append(" rotAnim="); 3002 sb.append(rotationAnimationToString(rotationAnimation)); 3003 } 3004 if (preferredRefreshRate != 0) { 3005 sb.append(" preferredRefreshRate="); 3006 sb.append(preferredRefreshRate); 3007 } 3008 if (preferredDisplayModeId != 0) { 3009 sb.append(" preferredDisplayMode="); 3010 sb.append(preferredDisplayModeId); 3011 } 3012 if (hasSystemUiListeners) { 3013 sb.append(" sysuil="); 3014 sb.append(hasSystemUiListeners); 3015 } 3016 if (inputFeatures != 0) { 3017 sb.append(" if=").append(inputFeatureToString(inputFeatures)); 3018 } 3019 if (userActivityTimeout >= 0) { 3020 sb.append(" userActivityTimeout=").append(userActivityTimeout); 3021 } 3022 if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 || 3023 surfaceInsets.bottom != 0 || hasManualSurfaceInsets 3024 || !preservePreviousSurfaceInsets) { 3025 sb.append(" surfaceInsets=").append(surfaceInsets); 3026 if (hasManualSurfaceInsets) { 3027 sb.append(" (manual)"); 3028 } 3029 if (!preservePreviousSurfaceInsets) { 3030 sb.append(" (!preservePreviousSurfaceInsets)"); 3031 } 3032 } 3033 if (needsMenuKey == NEEDS_MENU_SET_TRUE) { 3034 sb.append(" needsMenuKey"); 3035 } 3036 if (mColorMode != COLOR_MODE_DEFAULT) { 3037 sb.append(" colorMode=").append(ActivityInfo.colorModeToString(mColorMode)); 3038 } 3039 sb.append(System.lineSeparator()); 3040 sb.append(prefix).append(" fl=").append( 3041 ViewDebug.flagsToString(LayoutParams.class, "flags", flags)); 3042 if (privateFlags != 0) { 3043 sb.append(System.lineSeparator()); 3044 sb.append(prefix).append(" pfl=").append(ViewDebug.flagsToString( 3045 LayoutParams.class, "privateFlags", privateFlags)); 3046 } 3047 if (systemUiVisibility != 0) { 3048 sb.append(System.lineSeparator()); 3049 sb.append(prefix).append(" sysui=").append(ViewDebug.flagsToString( 3050 View.class, "mSystemUiVisibility", systemUiVisibility)); 3051 } 3052 if (subtreeSystemUiVisibility != 0) { 3053 sb.append(System.lineSeparator()); 3054 sb.append(prefix).append(" vsysui=").append(ViewDebug.flagsToString( 3055 View.class, "mSystemUiVisibility", subtreeSystemUiVisibility)); 3056 } 3057 sb.append('}'); 3058 return sb.toString(); 3059 } 3060 3061 /** 3062 * @hide 3063 */ 3064 public void writeToProto(ProtoOutputStream proto, long fieldId) { 3065 final long token = proto.start(fieldId); 3066 proto.write(TYPE, type); 3067 proto.write(X, x); 3068 proto.write(Y, y); 3069 proto.write(WIDTH, width); 3070 proto.write(HEIGHT, height); 3071 proto.write(HORIZONTAL_MARGIN, horizontalMargin); 3072 proto.write(VERTICAL_MARGIN, verticalMargin); 3073 proto.write(GRAVITY, gravity); 3074 proto.write(SOFT_INPUT_MODE, softInputMode); 3075 proto.write(FORMAT, format); 3076 proto.write(WINDOW_ANIMATIONS, windowAnimations); 3077 proto.write(ALPHA, alpha); 3078 proto.write(SCREEN_BRIGHTNESS, screenBrightness); 3079 proto.write(BUTTON_BRIGHTNESS, buttonBrightness); 3080 proto.write(ROTATION_ANIMATION, rotationAnimation); 3081 proto.write(PREFERRED_REFRESH_RATE, preferredRefreshRate); 3082 proto.write(WindowLayoutParamsProto.PREFERRED_DISPLAY_MODE_ID, preferredDisplayModeId); 3083 proto.write(HAS_SYSTEM_UI_LISTENERS, hasSystemUiListeners); 3084 proto.write(INPUT_FEATURE_FLAGS, inputFeatures); 3085 proto.write(USER_ACTIVITY_TIMEOUT, userActivityTimeout); 3086 proto.write(NEEDS_MENU_KEY, needsMenuKey); 3087 proto.write(COLOR_MODE, mColorMode); 3088 proto.write(FLAGS, flags); 3089 proto.write(PRIVATE_FLAGS, privateFlags); 3090 proto.write(SYSTEM_UI_VISIBILITY_FLAGS, systemUiVisibility); 3091 proto.write(SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS, subtreeSystemUiVisibility); 3092 proto.end(token); 3093 } 3094 3095 /** 3096 * Scale the layout params' coordinates and size. 3097 * @hide 3098 */ 3099 public void scale(float scale) { 3100 x = (int) (x * scale + 0.5f); 3101 y = (int) (y * scale + 0.5f); 3102 if (width > 0) { 3103 width = (int) (width * scale + 0.5f); 3104 } 3105 if (height > 0) { 3106 height = (int) (height * scale + 0.5f); 3107 } 3108 } 3109 3110 /** 3111 * Backup the layout parameters used in compatibility mode. 3112 * @see LayoutParams#restore() 3113 */ 3114 void backup() { 3115 int[] backup = mCompatibilityParamsBackup; 3116 if (backup == null) { 3117 // we backup 4 elements, x, y, width, height 3118 backup = mCompatibilityParamsBackup = new int[4]; 3119 } 3120 backup[0] = x; 3121 backup[1] = y; 3122 backup[2] = width; 3123 backup[3] = height; 3124 } 3125 3126 /** 3127 * Restore the layout params' coordinates, size and gravity 3128 * @see LayoutParams#backup() 3129 */ 3130 void restore() { 3131 int[] backup = mCompatibilityParamsBackup; 3132 if (backup != null) { 3133 x = backup[0]; 3134 y = backup[1]; 3135 width = backup[2]; 3136 height = backup[3]; 3137 } 3138 } 3139 3140 private CharSequence mTitle = null; 3141 3142 /** @hide */ 3143 @Override 3144 protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { 3145 super.encodeProperties(encoder); 3146 3147 encoder.addProperty("x", x); 3148 encoder.addProperty("y", y); 3149 encoder.addProperty("horizontalWeight", horizontalWeight); 3150 encoder.addProperty("verticalWeight", verticalWeight); 3151 encoder.addProperty("type", type); 3152 encoder.addProperty("flags", flags); 3153 } 3154 3155 /** 3156 * @hide 3157 * @return True if the layout parameters will cause the window to cover the full screen; 3158 * false otherwise. 3159 */ 3160 public boolean isFullscreen() { 3161 return x == 0 && y == 0 3162 && width == WindowManager.LayoutParams.MATCH_PARENT 3163 && height == WindowManager.LayoutParams.MATCH_PARENT; 3164 } 3165 3166 private static String layoutInDisplayCutoutModeToString( 3167 @LayoutInDisplayCutoutMode int mode) { 3168 switch (mode) { 3169 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT: 3170 return "default"; 3171 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS: 3172 return "always"; 3173 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER: 3174 return "never"; 3175 default: 3176 return "unknown(" + mode + ")"; 3177 } 3178 } 3179 3180 private static String softInputModeToString(@SoftInputModeFlags int softInputMode) { 3181 final StringBuilder result = new StringBuilder(); 3182 final int state = softInputMode & SOFT_INPUT_MASK_STATE; 3183 if (state != 0) { 3184 result.append("state="); 3185 switch (state) { 3186 case SOFT_INPUT_STATE_UNCHANGED: 3187 result.append("unchanged"); 3188 break; 3189 case SOFT_INPUT_STATE_HIDDEN: 3190 result.append("hidden"); 3191 break; 3192 case SOFT_INPUT_STATE_ALWAYS_HIDDEN: 3193 result.append("always_hidden"); 3194 break; 3195 case SOFT_INPUT_STATE_VISIBLE: 3196 result.append("visible"); 3197 break; 3198 case SOFT_INPUT_STATE_ALWAYS_VISIBLE: 3199 result.append("always_visible"); 3200 break; 3201 default: 3202 result.append(state); 3203 break; 3204 } 3205 result.append(' '); 3206 } 3207 final int adjust = softInputMode & SOFT_INPUT_MASK_ADJUST; 3208 if (adjust != 0) { 3209 result.append("adjust="); 3210 switch (adjust) { 3211 case SOFT_INPUT_ADJUST_RESIZE: 3212 result.append("resize"); 3213 break; 3214 case SOFT_INPUT_ADJUST_PAN: 3215 result.append("pan"); 3216 break; 3217 case SOFT_INPUT_ADJUST_NOTHING: 3218 result.append("nothing"); 3219 break; 3220 default: 3221 result.append(adjust); 3222 break; 3223 } 3224 result.append(' '); 3225 } 3226 if ((softInputMode & SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) { 3227 result.append("forwardNavigation").append(' '); 3228 } 3229 result.deleteCharAt(result.length() - 1); 3230 return result.toString(); 3231 } 3232 3233 private static String rotationAnimationToString(int rotationAnimation) { 3234 switch (rotationAnimation) { 3235 case ROTATION_ANIMATION_UNSPECIFIED: 3236 return "UNSPECIFIED"; 3237 case ROTATION_ANIMATION_ROTATE: 3238 return "ROTATE"; 3239 case ROTATION_ANIMATION_CROSSFADE: 3240 return "CROSSFADE"; 3241 case ROTATION_ANIMATION_JUMPCUT: 3242 return "JUMPCUT"; 3243 case ROTATION_ANIMATION_SEAMLESS: 3244 return "SEAMLESS"; 3245 default: 3246 return Integer.toString(rotationAnimation); 3247 } 3248 } 3249 3250 private static String inputFeatureToString(int inputFeature) { 3251 switch (inputFeature) { 3252 case INPUT_FEATURE_DISABLE_POINTER_GESTURES: 3253 return "DISABLE_POINTER_GESTURES"; 3254 case INPUT_FEATURE_NO_INPUT_CHANNEL: 3255 return "NO_INPUT_CHANNEL"; 3256 case INPUT_FEATURE_DISABLE_USER_ACTIVITY: 3257 return "DISABLE_USER_ACTIVITY"; 3258 default: 3259 return Integer.toString(inputFeature); 3260 } 3261 } 3262 } 3263} 3264