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