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