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 17 package android.view; 18 19 import static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT; 20 import static android.view.View.STATUS_BAR_DISABLE_BACK; 21 import static android.view.View.STATUS_BAR_DISABLE_CLOCK; 22 import static android.view.View.STATUS_BAR_DISABLE_EXPAND; 23 import static android.view.View.STATUS_BAR_DISABLE_HOME; 24 import static android.view.View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS; 25 import static android.view.View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS; 26 import static android.view.View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER; 27 import static android.view.View.STATUS_BAR_DISABLE_RECENT; 28 import static android.view.View.STATUS_BAR_DISABLE_SEARCH; 29 import static android.view.View.STATUS_BAR_DISABLE_SYSTEM_INFO; 30 import static android.view.View.SYSTEM_UI_FLAG_FULLSCREEN; 31 import static android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; 32 import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE; 33 import static android.view.View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; 34 import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; 35 import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; 36 import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE; 37 import static android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; 38 import static android.view.View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; 39 import static android.view.View.SYSTEM_UI_FLAG_LOW_PROFILE; 40 import static android.view.View.SYSTEM_UI_FLAG_VISIBLE; 41 import static android.view.WindowInsets.Side.BOTTOM; 42 import static android.view.WindowInsets.Side.LEFT; 43 import static android.view.WindowInsets.Side.RIGHT; 44 import static android.view.WindowInsets.Side.TOP; 45 import static android.view.WindowInsets.Type.CAPTION_BAR; 46 import static android.view.WindowInsets.Type.IME; 47 import static android.view.WindowInsets.Type.MANDATORY_SYSTEM_GESTURES; 48 import static android.view.WindowInsets.Type.NAVIGATION_BARS; 49 import static android.view.WindowInsets.Type.STATUS_BARS; 50 import static android.view.WindowInsets.Type.SYSTEM_GESTURES; 51 import static android.view.WindowInsets.Type.TAPPABLE_ELEMENT; 52 import static android.view.WindowInsets.Type.WINDOW_DECOR; 53 import static android.view.WindowLayoutParamsProto.ALPHA; 54 import static android.view.WindowLayoutParamsProto.APPEARANCE; 55 import static android.view.WindowLayoutParamsProto.BEHAVIOR; 56 import static android.view.WindowLayoutParamsProto.BUTTON_BRIGHTNESS; 57 import static android.view.WindowLayoutParamsProto.COLOR_MODE; 58 import static android.view.WindowLayoutParamsProto.FIT_IGNORE_VISIBILITY; 59 import static android.view.WindowLayoutParamsProto.FIT_INSETS_SIDES; 60 import static android.view.WindowLayoutParamsProto.FIT_INSETS_TYPES; 61 import static android.view.WindowLayoutParamsProto.FLAGS; 62 import static android.view.WindowLayoutParamsProto.FORMAT; 63 import static android.view.WindowLayoutParamsProto.GRAVITY; 64 import static android.view.WindowLayoutParamsProto.HAS_SYSTEM_UI_LISTENERS; 65 import static android.view.WindowLayoutParamsProto.HEIGHT; 66 import static android.view.WindowLayoutParamsProto.HORIZONTAL_MARGIN; 67 import static android.view.WindowLayoutParamsProto.INPUT_FEATURE_FLAGS; 68 import static android.view.WindowLayoutParamsProto.PREFERRED_REFRESH_RATE; 69 import static android.view.WindowLayoutParamsProto.PRIVATE_FLAGS; 70 import static android.view.WindowLayoutParamsProto.ROTATION_ANIMATION; 71 import static android.view.WindowLayoutParamsProto.SCREEN_BRIGHTNESS; 72 import static android.view.WindowLayoutParamsProto.SOFT_INPUT_MODE; 73 import static android.view.WindowLayoutParamsProto.SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS; 74 import static android.view.WindowLayoutParamsProto.SYSTEM_UI_VISIBILITY_FLAGS; 75 import static android.view.WindowLayoutParamsProto.TYPE; 76 import static android.view.WindowLayoutParamsProto.USER_ACTIVITY_TIMEOUT; 77 import static android.view.WindowLayoutParamsProto.VERTICAL_MARGIN; 78 import static android.view.WindowLayoutParamsProto.WIDTH; 79 import static android.view.WindowLayoutParamsProto.WINDOW_ANIMATIONS; 80 import static android.view.WindowLayoutParamsProto.X; 81 import static android.view.WindowLayoutParamsProto.Y; 82 83 import android.Manifest.permission; 84 import android.annotation.CallbackExecutor; 85 import android.annotation.FlaggedApi; 86 import android.annotation.FloatRange; 87 import android.annotation.IntDef; 88 import android.annotation.IntRange; 89 import android.annotation.NonNull; 90 import android.annotation.Nullable; 91 import android.annotation.RequiresPermission; 92 import android.annotation.SuppressLint; 93 import android.annotation.SystemApi; 94 import android.annotation.SystemService; 95 import android.annotation.TestApi; 96 import android.app.ActivityTaskManager; 97 import android.app.ActivityThread; 98 import android.app.KeyguardManager; 99 import android.app.Presentation; 100 import android.compat.annotation.ChangeId; 101 import android.compat.annotation.EnabledSince; 102 import android.compat.annotation.UnsupportedAppUsage; 103 import android.content.ClipData; 104 import android.content.ComponentName; 105 import android.content.Context; 106 import android.content.pm.ActivityInfo; 107 import android.content.pm.PackageManager; 108 import android.content.res.Configuration; 109 import android.graphics.Bitmap; 110 import android.graphics.Insets; 111 import android.graphics.PixelFormat; 112 import android.graphics.Point; 113 import android.graphics.Rect; 114 import android.graphics.Region; 115 import android.os.Build; 116 import android.os.Bundle; 117 import android.os.IBinder; 118 import android.os.Looper; 119 import android.os.Parcel; 120 import android.os.Parcelable; 121 import android.os.SystemProperties; 122 import android.text.TextUtils; 123 import android.util.Log; 124 import android.util.proto.ProtoOutputStream; 125 import android.view.Gravity.GravityFlags; 126 import android.view.View.OnApplyWindowInsetsListener; 127 import android.view.WindowInsets.Side; 128 import android.view.WindowInsets.Side.InsetsSide; 129 import android.view.WindowInsets.Type; 130 import android.view.WindowInsets.Type.InsetsType; 131 import android.view.accessibility.AccessibilityNodeInfo; 132 import android.window.InputTransferToken; 133 import android.window.TaskFpsCallback; 134 import android.window.TrustedPresentationThresholds; 135 136 import com.android.internal.R; 137 import com.android.window.flags.Flags; 138 139 import java.lang.annotation.ElementType; 140 import java.lang.annotation.Retention; 141 import java.lang.annotation.RetentionPolicy; 142 import java.lang.annotation.Target; 143 import java.util.ArrayList; 144 import java.util.Arrays; 145 import java.util.List; 146 import java.util.Objects; 147 import java.util.Set; 148 import java.util.concurrent.Executor; 149 import java.util.function.Consumer; 150 import java.util.function.IntConsumer; 151 152 /** 153 * The interface that apps use to talk to the window manager. 154 * <p> 155 * Each window manager instance is bound to a {@link Display}. To obtain the 156 * <code>WindowManager</code> associated with a display, 157 * call {@link Context#createWindowContext(Display, int, Bundle)} to get the display's UI context, 158 * then call {@link Context#getSystemService(String)} or {@link Context#getSystemService(Class)} on 159 * the UI context. 160 * <p> 161 * The simplest way to show a window on a particular display is to create a {@link Presentation}, 162 * which automatically obtains a <code>WindowManager</code> and context for the display. 163 */ 164 @SystemService(Context.WINDOW_SERVICE) 165 public interface WindowManager extends ViewManager { 166 167 /** @hide */ 168 int DOCKED_INVALID = -1; 169 /** @hide */ 170 int DOCKED_LEFT = 1; 171 /** @hide */ 172 int DOCKED_TOP = 2; 173 /** @hide */ 174 int DOCKED_RIGHT = 3; 175 /** @hide */ 176 int DOCKED_BOTTOM = 4; 177 178 /** @hide */ 179 String INPUT_CONSUMER_PIP = "pip_input_consumer"; 180 /** @hide */ 181 String INPUT_CONSUMER_NAVIGATION = "nav_input_consumer"; 182 /** @hide */ 183 String INPUT_CONSUMER_WALLPAPER = "wallpaper_input_consumer"; 184 /** @hide */ 185 String INPUT_CONSUMER_RECENTS_ANIMATION = "recents_animation_input_consumer"; 186 187 /** @hide */ 188 int SHELL_ROOT_LAYER_DIVIDER = 0; 189 /** @hide */ 190 int SHELL_ROOT_LAYER_PIP = 1; 191 192 /** 193 * Declares the layer the shell root will belong to. This is for z-ordering. 194 * @hide 195 */ 196 @IntDef(prefix = { "SHELL_ROOT_LAYER_" }, value = { 197 SHELL_ROOT_LAYER_DIVIDER, 198 SHELL_ROOT_LAYER_PIP 199 }) 200 @Retention(RetentionPolicy.SOURCE) 201 @interface ShellRootLayer {} 202 203 /** 204 * Not set up for a transition. 205 * @hide 206 */ 207 int TRANSIT_OLD_UNSET = -1; 208 209 /** 210 * No animation for transition. 211 * @hide 212 */ 213 int TRANSIT_OLD_NONE = 0; 214 215 /** 216 * A window in a new activity is being opened on top of an existing one in the same task. 217 * @hide 218 */ 219 int TRANSIT_OLD_ACTIVITY_OPEN = 6; 220 221 /** 222 * The window in the top-most activity is being closed to reveal the previous activity in the 223 * same task. 224 * @hide 225 */ 226 int TRANSIT_OLD_ACTIVITY_CLOSE = 7; 227 228 /** 229 * A window in a new task is being opened on top of an existing one in another activity's task. 230 * @hide 231 */ 232 int TRANSIT_OLD_TASK_OPEN = 8; 233 234 /** 235 * A window in the top-most activity is being closed to reveal the previous activity in a 236 * different task. 237 * @hide 238 */ 239 int TRANSIT_OLD_TASK_CLOSE = 9; 240 241 /** 242 * A window in an existing task is being displayed on top of an existing one in another 243 * activity's task. 244 * @hide 245 */ 246 int TRANSIT_OLD_TASK_TO_FRONT = 10; 247 248 /** 249 * A window in an existing task is being put below all other tasks. 250 * @hide 251 */ 252 int TRANSIT_OLD_TASK_TO_BACK = 11; 253 254 /** 255 * A window in a new activity that doesn't have a wallpaper is being opened on top of one that 256 * does, effectively closing the wallpaper. 257 * @hide 258 */ 259 int TRANSIT_OLD_WALLPAPER_CLOSE = 12; 260 261 /** 262 * A window in a new activity that does have a wallpaper is being opened on one that didn't, 263 * effectively opening the wallpaper. 264 * @hide 265 */ 266 int TRANSIT_OLD_WALLPAPER_OPEN = 13; 267 268 /** 269 * A window in a new activity is being opened on top of an existing one, and both are on top 270 * of the wallpaper. 271 * @hide 272 */ 273 int TRANSIT_OLD_WALLPAPER_INTRA_OPEN = 14; 274 275 /** 276 * The window in the top-most activity is being closed to reveal the previous activity, and 277 * both are on top of the wallpaper. 278 * @hide 279 */ 280 int TRANSIT_OLD_WALLPAPER_INTRA_CLOSE = 15; 281 282 /** 283 * A window in a new task is being opened behind an existing one in another activity's task. 284 * The new window will show briefly and then be gone. 285 * @hide 286 */ 287 int TRANSIT_OLD_TASK_OPEN_BEHIND = 16; 288 289 /** 290 * An activity is being relaunched (e.g. due to configuration change). 291 * @hide 292 */ 293 int TRANSIT_OLD_ACTIVITY_RELAUNCH = 18; 294 295 /** 296 * Keyguard is going away. 297 * @hide 298 */ 299 int TRANSIT_OLD_KEYGUARD_GOING_AWAY = 20; 300 301 /** 302 * Keyguard is going away with showing an activity behind that requests wallpaper. 303 * @hide 304 */ 305 int TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER = 21; 306 307 /** 308 * Keyguard is being occluded by non-Dream. 309 * @hide 310 */ 311 int TRANSIT_OLD_KEYGUARD_OCCLUDE = 22; 312 313 /** 314 * Keyguard is being occluded by Dream. 315 * @hide 316 */ 317 int TRANSIT_OLD_KEYGUARD_OCCLUDE_BY_DREAM = 33; 318 319 /** 320 * Keyguard is being unoccluded. 321 * @hide 322 */ 323 int TRANSIT_OLD_KEYGUARD_UNOCCLUDE = 23; 324 325 /** 326 * A translucent activity is being opened. 327 * @hide 328 */ 329 int TRANSIT_OLD_TRANSLUCENT_ACTIVITY_OPEN = 24; 330 331 /** 332 * A translucent activity is being closed. 333 * @hide 334 */ 335 int TRANSIT_OLD_TRANSLUCENT_ACTIVITY_CLOSE = 25; 336 337 /** 338 * A crashing activity is being closed. 339 * @hide 340 */ 341 int TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE = 26; 342 343 /** 344 * A task is changing windowing modes 345 * @hide 346 */ 347 int TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE = 27; 348 349 /** 350 * A window in a new task fragment is being opened. 351 * @hide 352 */ 353 int TRANSIT_OLD_TASK_FRAGMENT_OPEN = 28; 354 355 /** 356 * A window in the top-most activity of task fragment is being closed to reveal the activity 357 * below. 358 * @hide 359 */ 360 int TRANSIT_OLD_TASK_FRAGMENT_CLOSE = 29; 361 362 /** 363 * A window of task fragment is changing bounds. 364 * @hide 365 */ 366 int TRANSIT_OLD_TASK_FRAGMENT_CHANGE = 30; 367 368 /** 369 * A dream activity is being opened. 370 * @hide 371 */ 372 int TRANSIT_OLD_DREAM_ACTIVITY_OPEN = 31; 373 374 /** 375 * A dream activity is being closed. 376 * @hide 377 */ 378 int TRANSIT_OLD_DREAM_ACTIVITY_CLOSE = 32; 379 380 /** 381 * @hide 382 */ 383 @IntDef(prefix = { "TRANSIT_OLD_" }, value = { 384 TRANSIT_OLD_UNSET, 385 TRANSIT_OLD_NONE, 386 TRANSIT_OLD_ACTIVITY_OPEN, 387 TRANSIT_OLD_ACTIVITY_CLOSE, 388 TRANSIT_OLD_TASK_OPEN, 389 TRANSIT_OLD_TASK_CLOSE, 390 TRANSIT_OLD_TASK_TO_FRONT, 391 TRANSIT_OLD_TASK_TO_BACK, 392 TRANSIT_OLD_WALLPAPER_CLOSE, 393 TRANSIT_OLD_WALLPAPER_OPEN, 394 TRANSIT_OLD_WALLPAPER_INTRA_OPEN, 395 TRANSIT_OLD_WALLPAPER_INTRA_CLOSE, 396 TRANSIT_OLD_TASK_OPEN_BEHIND, 397 TRANSIT_OLD_ACTIVITY_RELAUNCH, 398 TRANSIT_OLD_KEYGUARD_GOING_AWAY, 399 TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER, 400 TRANSIT_OLD_KEYGUARD_OCCLUDE, 401 TRANSIT_OLD_KEYGUARD_UNOCCLUDE, 402 TRANSIT_OLD_TRANSLUCENT_ACTIVITY_OPEN, 403 TRANSIT_OLD_TRANSLUCENT_ACTIVITY_CLOSE, 404 TRANSIT_OLD_CRASHING_ACTIVITY_CLOSE, 405 TRANSIT_OLD_TASK_CHANGE_WINDOWING_MODE, 406 TRANSIT_OLD_TASK_FRAGMENT_OPEN, 407 TRANSIT_OLD_TASK_FRAGMENT_CLOSE, 408 TRANSIT_OLD_TASK_FRAGMENT_CHANGE, 409 TRANSIT_OLD_DREAM_ACTIVITY_OPEN, 410 TRANSIT_OLD_DREAM_ACTIVITY_CLOSE 411 }) 412 @Retention(RetentionPolicy.SOURCE) 413 @interface TransitionOldType {} 414 415 /** @hide */ 416 int TRANSIT_NONE = 0; 417 /** 418 * A window that didn't exist before has been created and made visible. 419 * @hide 420 */ 421 int TRANSIT_OPEN = 1; 422 /** 423 * A window that was visible no-longer exists (was finished or destroyed). 424 * @hide 425 */ 426 int TRANSIT_CLOSE = 2; 427 /** 428 * A window that already existed but was not visible is made visible. 429 * @hide 430 */ 431 int TRANSIT_TO_FRONT = 3; 432 /** 433 * A window that was visible is made invisible but still exists. 434 * @hide 435 */ 436 int TRANSIT_TO_BACK = 4; 437 /** @hide */ 438 int TRANSIT_RELAUNCH = 5; 439 /** 440 * A window is visible before and after but changes in some way (eg. it resizes or changes 441 * windowing-mode). 442 * @hide 443 */ 444 int TRANSIT_CHANGE = 6; 445 /** 446 * The keyguard was visible and has been dismissed. 447 * @deprecated use {@link #TRANSIT_TO_BACK} + {@link #TRANSIT_FLAG_KEYGUARD_GOING_AWAY} for 448 * keyguard going away with Shell transition. 449 * @hide 450 */ 451 @Deprecated 452 int TRANSIT_KEYGUARD_GOING_AWAY = 7; 453 /** 454 * A window is appearing above a locked keyguard. 455 * @deprecated use {@link #TRANSIT_TO_FRONT} + {@link #TRANSIT_FLAG_KEYGUARD_OCCLUDING} for 456 * keyguard occluding with Shell transition. 457 * @hide 458 */ 459 int TRANSIT_KEYGUARD_OCCLUDE = 8; 460 /** 461 * A window is made invisible revealing a locked keyguard. 462 * @deprecated use {@link #TRANSIT_TO_BACK} + {@link #TRANSIT_FLAG_KEYGUARD_UNOCCLUDING} for 463 * keyguard occluding with Shell transition. 464 * @hide 465 */ 466 int TRANSIT_KEYGUARD_UNOCCLUDE = 9; 467 /** 468 * A window is starting to enter PiP. 469 * @hide 470 */ 471 int TRANSIT_PIP = 10; 472 /** 473 * The screen is turning on. 474 * @hide 475 */ 476 int TRANSIT_WAKE = 11; 477 /** 478 * The screen is turning off. This is used as a message to stop all animations. 479 * @hide 480 */ 481 int TRANSIT_SLEEP = 12; 482 /** 483 * An Activity was going to be visible from back navigation. 484 * @hide 485 */ 486 int TRANSIT_PREPARE_BACK_NAVIGATION = 13; 487 /** 488 * An Activity was going to be invisible from back navigation. 489 * @hide 490 */ 491 int TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION = 14; 492 493 /** 494 * The first slot for custom transition types. Callers (like Shell) can make use of custom 495 * transition types for dealing with special cases. These types are effectively ignored by 496 * Core and will just be passed along as part of TransitionInfo objects. An example is 497 * split-screen using a custom type for it's snap-to-dismiss action. By using a custom type, 498 * Shell can properly dispatch the results of that transition to the split-screen 499 * implementation. 500 * @hide 501 */ 502 int TRANSIT_FIRST_CUSTOM = 1000; 503 504 /** 505 * @hide 506 */ 507 @IntDef(prefix = { "TRANSIT_" }, value = { 508 TRANSIT_NONE, 509 TRANSIT_OPEN, 510 TRANSIT_CLOSE, 511 TRANSIT_TO_FRONT, 512 TRANSIT_TO_BACK, 513 TRANSIT_RELAUNCH, 514 TRANSIT_CHANGE, 515 TRANSIT_KEYGUARD_GOING_AWAY, 516 TRANSIT_KEYGUARD_OCCLUDE, 517 TRANSIT_KEYGUARD_UNOCCLUDE, 518 TRANSIT_PIP, 519 TRANSIT_WAKE, 520 TRANSIT_SLEEP, 521 TRANSIT_PREPARE_BACK_NAVIGATION, 522 TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION, 523 TRANSIT_FIRST_CUSTOM 524 }) 525 @Retention(RetentionPolicy.SOURCE) 526 @interface TransitionType {} 527 528 /** 529 * Transition flag: Keyguard is going away, but keeping the notification shade open 530 * @hide 531 */ 532 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE = (1 << 0); // 0x1 533 534 /** 535 * Transition flag: Keyguard is going away, but doesn't want an animation for it 536 * @hide 537 */ 538 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION = (1 << 1); // 0x2 539 540 /** 541 * Transition flag: Keyguard is going away while it was showing the system wallpaper. 542 * @hide 543 */ 544 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER = (1 << 2); // 0x4 545 546 /** 547 * Transition flag: Keyguard is going away with subtle animation. 548 * @hide 549 */ 550 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION = (1 << 3); // 0x8 551 552 /** 553 * Transition flag: App is crashed. 554 * @hide 555 */ 556 int TRANSIT_FLAG_APP_CRASHED = (1 << 4); // 0x10 557 558 /** 559 * Transition flag: A window in a new task is being opened behind an existing one in another 560 * activity's task. 561 * @hide 562 */ 563 int TRANSIT_FLAG_OPEN_BEHIND = (1 << 5); // 0x20 564 565 /** 566 * Transition flag: The keyguard is locked throughout the whole transition. 567 * @hide 568 */ 569 int TRANSIT_FLAG_KEYGUARD_LOCKED = (1 << 6); // 0x40 570 571 /** 572 * Transition flag: Indicates that this transition is for recents animation. 573 * TODO(b/188669821): Remove once special-case logic moves to shell. 574 * @hide 575 */ 576 int TRANSIT_FLAG_IS_RECENTS = (1 << 7); // 0x80 577 578 /** 579 * Transition flag: Indicates that keyguard should go away with this transition. 580 * @hide 581 */ 582 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY = (1 << 8); // 0x100 583 584 /** 585 * Transition flag: Keyguard is going away to the launcher, and it needs us to clear the task 586 * snapshot of the launcher because it has changed something in the Launcher window. 587 * @hide 588 */ 589 int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT = (1 << 9); // 0x200 590 591 /** 592 * Transition flag: The transition is prepared when nothing is visible on screen, e.g. screen 593 * is off. The animation handlers can decide whether to skip animations. 594 * @hide 595 */ 596 int TRANSIT_FLAG_INVISIBLE = (1 << 10); // 0x400 597 598 /** 599 * Transition flag: Indicates that keyguard will be showing (locked) with this transition, 600 * which is the opposite of {@link #TRANSIT_FLAG_KEYGUARD_GOING_AWAY}. 601 * @hide 602 */ 603 int TRANSIT_FLAG_KEYGUARD_APPEARING = (1 << 11); // 0x800 604 605 /** 606 * Transition flag: Indicates that keyguard is becoming hidden by an app 607 * @hide 608 */ 609 int TRANSIT_FLAG_KEYGUARD_OCCLUDING = (1 << 12); // 0x1000 610 611 /** 612 * Transition flag: Indicates that keyguard is being revealed after an app was occluding it. 613 * @hide 614 */ 615 int TRANSIT_FLAG_KEYGUARD_UNOCCLUDING = (1 << 13); // 0x2000 616 617 /** 618 * Transition flag: Indicates that there is a physical display switch 619 * TODO(b/316112906) remove after defer_display_updates flag roll out 620 * @hide 621 */ 622 int TRANSIT_FLAG_PHYSICAL_DISPLAY_SWITCH = (1 << 14); // 0x4000 623 624 /** 625 * Transition flag: Indicates that aod is showing hidden by entering doze 626 * @hide 627 */ 628 int TRANSIT_FLAG_AOD_APPEARING = (1 << 15); // 0x8000 629 630 /** 631 * Transition flag: Indicates that the task shouldn't move to front when launching the activity. 632 * @hide 633 */ 634 int TRANSIT_FLAG_AVOID_MOVE_TO_FRONT = (1 << 16); // 0x10000 635 636 /** 637 * @hide 638 */ 639 @IntDef(flag = true, prefix = { "TRANSIT_FLAG_" }, value = { 640 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE, 641 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION, 642 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER, 643 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION, 644 TRANSIT_FLAG_APP_CRASHED, 645 TRANSIT_FLAG_OPEN_BEHIND, 646 TRANSIT_FLAG_KEYGUARD_LOCKED, 647 TRANSIT_FLAG_IS_RECENTS, 648 TRANSIT_FLAG_KEYGUARD_GOING_AWAY, 649 TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT, 650 TRANSIT_FLAG_INVISIBLE, 651 TRANSIT_FLAG_KEYGUARD_APPEARING, 652 TRANSIT_FLAG_KEYGUARD_OCCLUDING, 653 TRANSIT_FLAG_KEYGUARD_UNOCCLUDING, 654 TRANSIT_FLAG_PHYSICAL_DISPLAY_SWITCH, 655 TRANSIT_FLAG_AOD_APPEARING, 656 TRANSIT_FLAG_AVOID_MOVE_TO_FRONT, 657 }) 658 @Retention(RetentionPolicy.SOURCE) 659 @interface TransitionFlags {} 660 661 /** 662 * Transit flags used to signal keyguard visibility is changing for animations. 663 * 664 * <p>These roughly correspond to CLOSE, OPEN, TO_BACK, and TO_FRONT on a hypothetical Keyguard 665 * container. Since Keyguard isn't a container we can't include it in changes and need to send 666 * this information in its own channel. 667 * @hide 668 */ 669 int KEYGUARD_VISIBILITY_TRANSIT_FLAGS = 670 (TRANSIT_FLAG_KEYGUARD_GOING_AWAY 671 | TRANSIT_FLAG_KEYGUARD_APPEARING 672 | TRANSIT_FLAG_KEYGUARD_OCCLUDING 673 | TRANSIT_FLAG_KEYGUARD_UNOCCLUDING 674 | TRANSIT_FLAG_AOD_APPEARING); 675 676 /** 677 * Remove content mode: Indicates remove content mode is currently not defined. 678 * @hide 679 */ 680 int REMOVE_CONTENT_MODE_UNDEFINED = 0; 681 682 /** 683 * Remove content mode: Indicates that when display is removed, all its activities will be moved 684 * to the primary display and the topmost activity should become focused. 685 * @hide 686 */ 687 int REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY = 1; 688 689 /** 690 * Remove content mode: Indicates that when display is removed, all its stacks and tasks will be 691 * removed, all activities will be destroyed according to the usual lifecycle. 692 * @hide 693 */ 694 int REMOVE_CONTENT_MODE_DESTROY = 2; 695 696 /** 697 * @hide 698 */ 699 @IntDef(prefix = { "REMOVE_CONTENT_MODE_" }, value = { 700 REMOVE_CONTENT_MODE_UNDEFINED, 701 REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY, 702 REMOVE_CONTENT_MODE_DESTROY, 703 }) 704 @Retention(RetentionPolicy.SOURCE) 705 @interface RemoveContentMode {} 706 707 /** 708 * Display IME Policy: The IME should appear on the local display. 709 * 710 * @hide 711 */ 712 @SuppressLint("UnflaggedApi") // promoting from @TestApi. 713 @SystemApi 714 int DISPLAY_IME_POLICY_LOCAL = 0; 715 716 /** 717 * Display IME Policy: The IME should appear on a fallback display. 718 * 719 * <p>The fallback display is always {@link Display#DEFAULT_DISPLAY}.</p> 720 * 721 * @hide 722 */ 723 @SuppressLint("UnflaggedApi") // promoting from @TestApi. 724 @SystemApi 725 int DISPLAY_IME_POLICY_FALLBACK_DISPLAY = 1; 726 727 /** 728 * Display IME Policy: The IME should be hidden. 729 * 730 * <p>Setting this policy will prevent the IME from making a connection. This 731 * will prevent any IME from receiving metadata about input and this display will effectively 732 * have no IME.</p> 733 * 734 * @hide 735 */ 736 @SuppressLint("UnflaggedApi") // promoting from @TestApi. 737 @SystemApi 738 int DISPLAY_IME_POLICY_HIDE = 2; 739 740 /** 741 * @hide 742 */ 743 @IntDef({ 744 DISPLAY_IME_POLICY_LOCAL, 745 DISPLAY_IME_POLICY_FALLBACK_DISPLAY, 746 DISPLAY_IME_POLICY_HIDE, 747 }) 748 @Retention(RetentionPolicy.SOURCE) 749 @interface DisplayImePolicy {} 750 751 /** 752 * Exception that is thrown when trying to add view whose 753 * {@link LayoutParams} {@link LayoutParams#token} 754 * is invalid. 755 */ 756 public static class BadTokenException extends RuntimeException { BadTokenException()757 public BadTokenException() { 758 } 759 BadTokenException(String name)760 public BadTokenException(String name) { 761 super(name); 762 } 763 } 764 765 /** 766 * Exception that is thrown when calling {@link #addView} to a secondary display that cannot 767 * be found. See {@link android.app.Presentation} for more information on secondary displays. 768 */ 769 public static class InvalidDisplayException extends RuntimeException { InvalidDisplayException()770 public InvalidDisplayException() { 771 } 772 InvalidDisplayException(String name)773 public InvalidDisplayException(String name) { 774 super(name); 775 } 776 } 777 778 /** 779 * Returns the {@link Display} upon which this {@link WindowManager} instance 780 * will create new windows. 781 * <p> 782 * Despite the name of this method, the display that is returned is not 783 * necessarily the primary display of the system (see {@link Display#DEFAULT_DISPLAY}). 784 * The returned display could instead be a secondary display that this 785 * window manager instance is managing. Think of it as the display that 786 * this {@link WindowManager} instance uses by default. 787 * </p><p> 788 * To create windows on a different display, you need to obtain a 789 * {@link WindowManager} for that {@link Display}. (See the {@link WindowManager} 790 * class documentation for more information.) 791 * </p> 792 * 793 * @return The display that this window manager is managing. 794 * @deprecated Use {@link Context#getDisplay()} instead. 795 */ 796 @Deprecated getDefaultDisplay()797 public Display getDefaultDisplay(); 798 799 /** 800 * Special variation of {@link #removeView} that immediately invokes 801 * the given view hierarchy's {@link View#onDetachedFromWindow() 802 * View.onDetachedFromWindow()} methods before returning. This is not 803 * for normal applications; using it correctly requires great care. 804 * 805 * @param view The view to be removed. 806 */ removeViewImmediate(View view)807 public void removeViewImmediate(View view); 808 809 /** 810 * Returns the {@link WindowMetrics} according to the current system state. 811 * <p> 812 * The metrics describe the size of the area the window would occupy with 813 * {@link LayoutParams#MATCH_PARENT MATCH_PARENT} width and height, and the {@link WindowInsets} 814 * such a window would have. The {@link WindowInsets} are not deducted from the bounds. 815 * <p> 816 * The value of this is based on the <b>current</b> windowing state of the system. 817 * 818 * For example, for activities in multi-window mode, the metrics returned are based on the 819 * current bounds that the user has selected for the {@link android.app.Activity Activity}'s 820 * task. 821 * <p> 822 * In most scenarios, {@link #getCurrentWindowMetrics()} rather than 823 * {@link #getMaximumWindowMetrics()} is the correct API to use, since it ensures values reflect 824 * window size when the app is not fullscreen. 825 * 826 * @see #getMaximumWindowMetrics() 827 * @see WindowMetrics 828 */ getCurrentWindowMetrics()829 default @NonNull WindowMetrics getCurrentWindowMetrics() { 830 throw new UnsupportedOperationException(); 831 } 832 833 /** 834 * Returns the largest {@link WindowMetrics} an app may expect in the current system state. 835 * <p> 836 * The value of this is based on the largest <b>potential</b> windowing state of the system. 837 * 838 * For example, for activities in multi-window mode, the metrics returned are based on the 839 * what the bounds would be if the user expanded the {@link android.app.Activity Activity}'s 840 * task to cover the entire screen. 841 * <p> 842 * The metrics describe the size of the largest potential area the window might occupy with 843 * {@link LayoutParams#MATCH_PARENT MATCH_PARENT} width and height, and the {@link WindowInsets} 844 * such a window would have. The {@link WindowInsets} are not deducted from the bounds. 845 * <p> 846 * Note that this might still be smaller than the size of the physical display if certain areas 847 * of the display are not available to windows created in this {@link Context}. 848 * 849 * For example, given that there's a device which have a multi-task mode to limit activities 850 * to a half screen. In this case, {@link #getMaximumWindowMetrics()} reports the bounds of 851 * the half screen which the activity is located. 852 * <p> 853 * <b>Generally {@link #getCurrentWindowMetrics()} is the correct API to use</b> for choosing 854 * UI layouts. {@link #getMaximumWindowMetrics()} are only appropriate when the application 855 * needs to know the largest possible size it can occupy if the user expands/maximizes it on the 856 * screen. 857 * 858 * @see #getCurrentWindowMetrics() 859 * @see WindowMetrics 860 * @see Display#getRealSize(Point) 861 */ getMaximumWindowMetrics()862 default @NonNull WindowMetrics getMaximumWindowMetrics() { 863 throw new UnsupportedOperationException(); 864 } 865 866 /** 867 * Returns a set of {@link WindowMetrics} for the given display. Each WindowMetrics instance 868 * is the maximum WindowMetrics for a device state. This is not guaranteed to include all 869 * possible device states. 870 * 871 * This API can only be used by Launcher. 872 * 873 * @param displayId the id of the logical display 874 * @hide 875 */ getPossibleMaximumWindowMetrics(int displayId)876 default @NonNull Set<WindowMetrics> getPossibleMaximumWindowMetrics(int displayId) { 877 throw new UnsupportedOperationException(); 878 } 879 880 /** 881 * Used to asynchronously request Keyboard Shortcuts from the focused window. 882 * 883 * @hide 884 */ 885 public interface KeyboardShortcutsReceiver { 886 /** 887 * Callback used when the focused window keyboard shortcuts are ready to be displayed. 888 * 889 * @param result The keyboard shortcuts to be displayed. 890 */ onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result)891 void onKeyboardShortcutsReceived(List<KeyboardShortcutGroup> result); 892 } 893 894 /** 895 * Invoke screenshot flow to capture a full-screen image. 896 * @hide 897 */ 898 int TAKE_SCREENSHOT_FULLSCREEN = 1; 899 900 /** 901 * Invoke screenshot flow with an image provided by the caller. 902 * @hide 903 */ 904 int TAKE_SCREENSHOT_PROVIDED_IMAGE = 3; 905 906 /** 907 * Enum listing the types of screenshot requests available. 908 * 909 * @hide 910 */ 911 @IntDef({TAKE_SCREENSHOT_FULLSCREEN, 912 TAKE_SCREENSHOT_PROVIDED_IMAGE}) 913 @interface ScreenshotType {} 914 915 /** 916 * Enum listing the possible sources from which a screenshot was originated. Used for logging. 917 * 918 * @hide 919 */ 920 @IntDef({ScreenshotSource.SCREENSHOT_GLOBAL_ACTIONS, 921 ScreenshotSource.SCREENSHOT_KEY_CHORD, 922 ScreenshotSource.SCREENSHOT_KEY_OTHER, 923 ScreenshotSource.SCREENSHOT_OVERVIEW, 924 ScreenshotSource.SCREENSHOT_ACCESSIBILITY_ACTIONS, 925 ScreenshotSource.SCREENSHOT_OTHER, 926 ScreenshotSource.SCREENSHOT_VENDOR_GESTURE}) 927 @interface ScreenshotSource { 928 int SCREENSHOT_GLOBAL_ACTIONS = 0; 929 int SCREENSHOT_KEY_CHORD = 1; 930 int SCREENSHOT_KEY_OTHER = 2; 931 int SCREENSHOT_OVERVIEW = 3; 932 int SCREENSHOT_ACCESSIBILITY_ACTIONS = 4; 933 int SCREENSHOT_OTHER = 5; 934 int SCREENSHOT_VENDOR_GESTURE = 6; 935 } 936 937 /** 938 * If the display {@link Configuration#smallestScreenWidthDp} is greater or equal to this value, 939 * we will treat it as a large screen device, which will have some multi window features enabled 940 * by default. 941 * @hide 942 */ 943 @TestApi 944 int LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP = 600; 945 946 /** 947 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 948 * for an app to inform the system that the app can be opted-in or opted-out from the 949 * compatibility treatment that avoids {@link android.app.Activity#setRequestedOrientation 950 * Activity#setRequestedOrientation()} loops. Loops can be triggered by the OEM-configured 951 * ignore requested orientation display setting (on Android 12 (API level 31) and higher) or by 952 * the landscape natural orientation of the device. 953 * 954 * <p>The treatment is disabled by default but device manufacturers can enable the treatment 955 * using their discretion to improve display compatibility. 956 * 957 * <p>With this property set to {@code true}, the system could ignore 958 * {@link android.app.Activity#setRequestedOrientation Activity#setRequestedOrientation()} call 959 * from an app if one of the following conditions are true: 960 * <ul> 961 * <li>Activity is relaunching due to the previous 962 * {@link android.app.Activity#setRequestedOrientation Activity#setRequestedOrientation()} 963 * call. 964 * <li>Camera compatibility force rotation treatment is active for the package. 965 * </ul> 966 * 967 * <p>Setting this property to {@code false} informs the system that the app must be 968 * opted-out from the compatibility treatment even if the device manufacturer has opted the app 969 * into the treatment. 970 * 971 * <p><b>Syntax:</b> 972 * <pre> 973 * <application> 974 * <property 975 * android:name="android.window.PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION" 976 * android:value="true|false"/> 977 * </application> 978 * </pre> 979 */ 980 String PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION = 981 "android.window.PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION"; 982 983 /** 984 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 985 * for an app to inform the system that the app can be opted-out from the compatibility 986 * treatment that avoids {@link android.app.Activity#setRequestedOrientation 987 * Activity#setRequestedOrientation()} loops. Loops can be triggered by the OEM-configured 988 * ignore requested orientation display setting (on Android 12 (API level 31) and higher) or by 989 * the landscape natural orientation of the device. 990 * 991 * <p>The system could ignore {@link android.app.Activity#setRequestedOrientation 992 * Activity#setRequestedOrientation()} call from an app if both of the following conditions are 993 * true: 994 * <ul> 995 * <li>Activity has requested orientation more than two times within one-second timer 996 * <li>Activity is not letterboxed for fixed-orientation apps 997 * </ul> 998 * 999 * <p>Setting this property to {@code false} informs the system that the app must be 1000 * opted-out from the compatibility treatment even if the device manufacturer has opted the app 1001 * into the treatment. 1002 * 1003 * <p>Not setting this property at all, or setting this property to {@code true} has no effect. 1004 * 1005 * <p><b>Syntax:</b> 1006 * <pre> 1007 * <application> 1008 * <property 1009 * android:name= 1010 * "android.window.PROPERTY_COMPAT_ALLOW_IGNORING_ORIENTATION_REQUEST_WHEN_LOOP_DETECTED" 1011 * android:value="false"/> 1012 * </application> 1013 * </pre> 1014 */ 1015 @FlaggedApi(Flags.FLAG_APP_COMPAT_PROPERTIES_API) 1016 String PROPERTY_COMPAT_ALLOW_IGNORING_ORIENTATION_REQUEST_WHEN_LOOP_DETECTED = 1017 "android.window.PROPERTY_COMPAT_ALLOW_IGNORING_ORIENTATION_REQUEST_WHEN_LOOP_DETECTED"; 1018 1019 /** 1020 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1021 * for an app to inform the system that it needs to be opted-out from the compatibility 1022 * treatment that sandboxes the {@link android.view.View View} API. 1023 * 1024 * <p>The treatment can be enabled by device manufacturers for applications which misuse 1025 * {@link android.view.View View} APIs by expecting that 1026 * {@link android.view.View#getLocationOnScreen View#getLocationOnScreen()} and 1027 * {@link android.view.View#getWindowVisibleDisplayFrame View#getWindowVisibleDisplayFrame()} 1028 * return coordinates as if an activity is positioned in the top-left corner of the screen, with 1029 * left coordinate equal to 0. This may not be the case for applications in multi-window and 1030 * letterbox modes. 1031 * 1032 * <p>Setting this property to {@code false} informs the system that the application must be 1033 * opted-out from the "Sandbox View API to Activity bounds" treatment even if the device 1034 * manufacturer has opted the app into the treatment. 1035 * 1036 * <p>Not setting this property at all, or setting this property to {@code true} has no effect. 1037 * 1038 * <p><b>Syntax:</b> 1039 * <pre> 1040 * <application> 1041 * <property 1042 * android:name="android.window.PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS" 1043 * android:value="false"/> 1044 * </application> 1045 * </pre> 1046 */ 1047 String PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS = 1048 "android.window.PROPERTY_COMPAT_ALLOW_SANDBOXING_VIEW_BOUNDS_APIS"; 1049 1050 /** 1051 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1052 * for an app to inform the system that the application can be opted-in or opted-out from the 1053 * compatibility treatment that enables sending a fake focus event for unfocused resumed 1054 * split-screen activities. This is needed because some game engines wait to get focus before 1055 * drawing the content of the app which isn't guaranteed by default in multi-window mode. 1056 * 1057 * <p>Device manufacturers can enable this treatment using their discretion on a per-device 1058 * basis to improve display compatibility. The treatment also needs to be specifically enabled 1059 * on a per-app basis afterwards. This can either be done by device manufacturers or developers. 1060 * 1061 * <p>With this property set to {@code true}, the system will apply the treatment only if the 1062 * device manufacturer had previously enabled it on the device. A fake focus event will be sent 1063 * to the app after it is resumed only if the app is in split-screen. 1064 * 1065 * <p>Setting this property to {@code false} informs the system that the activity must be 1066 * opted-out from the compatibility treatment even if the device manufacturer has opted the app 1067 * into the treatment. 1068 * 1069 * <p>If the property remains unset the system will apply the treatment only if it had 1070 * previously been enabled both at the device and app level by the device manufacturer. 1071 * 1072 * <p><b>Syntax:</b> 1073 * <pre> 1074 * <application> 1075 * <property 1076 * android:name="android.window.PROPERTY_COMPAT_ENABLE_FAKE_FOCUS" 1077 * android:value="true|false"/> 1078 * </application> 1079 * </pre> 1080 */ 1081 String PROPERTY_COMPAT_ENABLE_FAKE_FOCUS = "android.window.PROPERTY_COMPAT_ENABLE_FAKE_FOCUS"; 1082 1083 /** 1084 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1085 * for an app to inform the system that the app should be excluded from the camera compatibility 1086 * force rotation treatment. 1087 * 1088 * <p>The camera compatibility treatment aligns portrait app windows with the natural 1089 * orientation of the device and landscape app windows opposite the device natural orientation. 1090 * Mismatch between the orientations can lead to camera issues like a sideways or stretched 1091 * viewfinder since this is one of the strongest assumptions that apps make when they implement 1092 * camera previews. Since app and device natural orientations aren't guaranteed to match, the 1093 * rotation can cause letterboxing. The forced rotation is triggered as soon as an app opens the 1094 * camera and is removed once camera is closed. 1095 * 1096 * <p>Camera compatibility can be enabled by device manufacturers on displays that have the 1097 * ignore requested orientation display setting enabled, which enables compatibility mode for 1098 * fixed-orientation apps on Android 12 (API level 31) or higher. See 1099 * <a href="{@docRoot}guide/practices/device-compatibility-mode">Device compatibility mode</a> 1100 * for more details. 1101 * 1102 * <p>With this property set to {@code true} or unset, the system may apply the force rotation 1103 * treatment to fixed-orientation activities. Device manufacturers can exclude packages from the 1104 * treatment using their discretion to improve display compatibility. 1105 * 1106 * <p>With this property set to {@code false}, the system will not apply the force rotation 1107 * treatment. 1108 * 1109 * <p><b>Syntax:</b> 1110 * <pre> 1111 * <application> 1112 * <property 1113 * android:name="android.window.PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION" 1114 * android:value="true|false"/> 1115 * </application> 1116 * </pre> 1117 */ 1118 String PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION = 1119 "android.window.PROPERTY_CAMERA_COMPAT_ALLOW_FORCE_ROTATION"; 1120 1121 /** 1122 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1123 * for an app to inform the system that the app should be excluded from the activity "refresh" 1124 * after the camera compatibility force rotation treatment. 1125 * 1126 * <p>The camera compatibility treatment aligns portrait app windows with the natural 1127 * orientation of the device and landscape app windows opposite the device natural orientation. 1128 * Mismatch between the orientations can lead to camera issues like a sideways or stretched 1129 * viewfinder since this is one of the strongest assumptions that apps make when they implement 1130 * camera previews. Since app and device natural orientations aren't guaranteed to match, the 1131 * rotation can cause letterboxing. The forced rotation is triggered as soon as an app opens the 1132 * camera and is removed once camera is closed. 1133 * 1134 * <p>Force rotation is followed by the "Refresh" of the activity by going through "resumed -> 1135 * ... -> stopped -> ... -> resumed" cycle (by default) or "resumed -> paused -> resumed" cycle 1136 * (if overridden, see {@link #PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE} for context). 1137 * This allows to clear cached values in apps (e.g. display or camera rotation) that influence 1138 * camera preview and can lead to sideways or stretching issues persisting even after force 1139 * rotation. 1140 * 1141 * <p>The camera compatibility can be enabled by device manufacturers on displays that have the 1142 * ignore requested orientation display setting enabled, which enables compatibility mode for 1143 * fixed-orientation apps on Android 12 (API level 31) or higher. See 1144 * <a href="{@docRoot}guide/practices/device-compatibility-mode">Device compatibility mode</a> 1145 * for more details. 1146 * 1147 * <p>With this property set to {@code true} or unset, the system may "refresh" activity after 1148 * the force rotation treatment. Device manufacturers can exclude packages from the "refresh" 1149 * using their discretion to improve display compatibility. 1150 * 1151 * <p>With this property set to {@code false}, the system will not "refresh" activity after the 1152 * force rotation treatment. 1153 * 1154 * <p><b>Syntax:</b> 1155 * <pre> 1156 * <application> 1157 * <property 1158 * android:name="android.window.PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH" 1159 * android:value="true|false"/> 1160 * </application> 1161 * </pre> 1162 */ 1163 String PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH = 1164 "android.window.PROPERTY_CAMERA_COMPAT_ALLOW_REFRESH"; 1165 1166 /** 1167 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1168 * for an app to inform the system that the activity should be or shouldn't be "refreshed" after 1169 * the camera compatibility force rotation treatment using "paused -> resumed" cycle rather than 1170 * "stopped -> resumed". 1171 * 1172 * <p>The camera compatibility treatment aligns orientations of portrait app window and natural 1173 * orientation of the device. Mismatch between the orientations can lead to camera issues like a 1174 * sideways or stretched viewfinder since this is one of the strongest assumptions that apps 1175 * make when they implement camera previews. Since app and natural display orientations aren't 1176 * guaranteed to match, the rotation can cause letterboxing. The forced rotation is triggered as 1177 * soon as app opens the camera and is removed once camera is closed. 1178 * 1179 * <p>Force rotation is followed by the "Refresh" of the activity by going through "resumed -> 1180 * ... -> stopped -> ... -> resumed" cycle (by default) or "resumed -> paused -> resumed" cycle 1181 * (if overridden by device manufacturers or using this property). This allows to clear cached 1182 * values in apps (e.g., display or camera rotation) that influence camera preview and can lead 1183 * to sideways or stretching issues persisting even after force rotation. 1184 * 1185 * <p>The camera compatibility can be enabled by device manufacturers on displays that have the 1186 * ignore requested orientation display setting enabled, which enables compatibility mode for 1187 * fixed-orientation apps on Android 12 (API level 31) or higher. See 1188 * <a href="{@docRoot}guide/practices/device-compatibility-mode">Device compatibility mode</a> 1189 * for more details. 1190 * 1191 * <p>Device manufacturers can override packages to "refresh" via "resumed -> paused -> resumed" 1192 * cycle using their discretion to improve display compatibility. 1193 * 1194 * <p>With this property set to {@code true}, the system will "refresh" activity after the 1195 * force rotation treatment using "resumed -> paused -> resumed" cycle. 1196 * 1197 * <p>With this property set to {@code false}, the system will not "refresh" activity after the 1198 * force rotation treatment using "resumed -> paused -> resumed" cycle even if the device 1199 * manufacturer adds the corresponding override. 1200 * 1201 * <p><b>Syntax:</b> 1202 * <pre> 1203 * <application> 1204 * <property 1205 * android:name="android.window.PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE" 1206 * android:value="true|false"/> 1207 * </application> 1208 * </pre> 1209 */ 1210 String PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE = 1211 "android.window.PROPERTY_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE"; 1212 1213 /** 1214 * Application-level [PackageManager][android.content.pm.PackageManager.Property] tag that (when 1215 * set to false) informs the system the app has opted out of the camera compatibility treatment 1216 * for fixed-orientation apps, which simulates running on a portrait device, in the orientation 1217 * requested by the app. 1218 * 1219 * <p>This treatment aims to mitigate camera issues on large screens, like stretched or sideways 1220 * previews. It simulates running on a portrait device by: 1221 * <ul> 1222 * <li>Letterboxing the app window, 1223 * <li>Cropping the camera buffer to match the app's requested orientation, 1224 * <li>Setting the camera sensor orientation to portrait. 1225 * <li>Setting the display rotation to match the app's requested orientation, given portrait 1226 * natural orientation, 1227 * <li>Refreshes the activity to trigger new camera setup, with sandboxed values. 1228 * </ul> 1229 * 1230 * <p>To opt out of the camera compatibility treatment, add this property to your app manifest 1231 * and set the value to {@code false}. 1232 * 1233 * <p>Not setting this property at all, or setting this property to {@code true} has no effect. 1234 * 1235 * <p><b>Syntax:</b> 1236 * <pre> 1237 * <application> 1238 * <property 1239 * android:name="android.window.PROPERTY_CAMERA_COMPAT_ALLOW_SIMULATE_REQUESTED_ORIENTATION" 1240 * android:value="true|false"/> 1241 * </application> 1242 * </pre> 1243 * 1244 * @hide 1245 */ 1246 //TODO(b/394590412): Make this property public. 1247 String PROPERTY_CAMERA_COMPAT_ALLOW_SIMULATE_REQUESTED_ORIENTATION = 1248 "android.window.PROPERTY_CAMERA_COMPAT_ALLOW_SIMULATE_REQUESTED_ORIENTATION"; 1249 1250 /** 1251 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1252 * for an app to inform the system that the app should be excluded from the compatibility 1253 * override for orientation set by the device manufacturer. When the orientation override is 1254 * applied it can: 1255 * <ul> 1256 * <li>Replace the specific orientation requested by the app with another selected by the 1257 device manufacturer; for example, replace undefined requested by the app with portrait. 1258 * <li>Always use an orientation selected by the device manufacturer. 1259 * <li>Do one of the above but only when camera connection is open. 1260 * </ul> 1261 * 1262 * <p>This property is different from {@link #PROPERTY_COMPAT_IGNORE_REQUESTED_ORIENTATION} 1263 * (which is used to avoid orientation loops caused by the incorrect use of {@link 1264 * android.app.Activity#setRequestedOrientation Activity#setRequestedOrientation()}) because 1265 * this property overrides the app to an orientation selected by the device manufacturer rather 1266 * than ignoring one of orientation requests coming from the app while respecting the previous 1267 * one. 1268 * 1269 * <p>With this property set to {@code true} or unset, device manufacturers can override 1270 * orientation for the app using their discretion to improve display compatibility. 1271 * 1272 * <p>With this property set to {@code false}, device manufacturer per-app override for 1273 * orientation won't be applied. 1274 * 1275 * <p><b>Syntax:</b> 1276 * <pre> 1277 * <application> 1278 * <property 1279 * android:name="android.window.PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE" 1280 * android:value="true|false"/> 1281 * </application> 1282 * </pre> 1283 */ 1284 String PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE = 1285 "android.window.PROPERTY_COMPAT_ALLOW_ORIENTATION_OVERRIDE"; 1286 1287 /** 1288 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1289 * for an app to inform the system that the app should be opted-out from the compatibility 1290 * override that fixes display orientation to landscape natural orientation when an activity is 1291 * fullscreen. 1292 * 1293 * <p>When this compat override is enabled and while display is fixed to the landscape natural 1294 * orientation, the orientation requested by the activity will be still respected by bounds 1295 * resolution logic. For instance, if an activity requests portrait orientation, then activity 1296 * appears in letterbox mode for fixed-orientation apps with the display rotated to the lanscape 1297 * natural orientation. 1298 * 1299 * <p>The treatment is disabled by default but device manufacturers can enable the treatment 1300 * using their discretion to improve display compatibility on displays that have the ignore 1301 * orientation request display setting enabled by OEMs on the device, which enables 1302 * compatibility mode for fixed-orientation apps on Android 12 (API level 31) or higher. See 1303 * <a href="{@docRoot}guide/practices/device-compatibility-mode">Device compatibility mode</a> 1304 * for more details. 1305 * 1306 * <p>With this property set to {@code true} or unset, the system wiil use landscape display 1307 * orientation when the following conditions are met: 1308 * <ul> 1309 * <li>Natural orientation of the display is landscape 1310 * <li>ignore requested orientation display setting is enabled 1311 * <li>Activity is fullscreen. 1312 * <li>Device manufacturer enabled the treatment. 1313 * </ul> 1314 * 1315 * <p>With this property set to {@code false}, device manufacturer per-app override for 1316 * display orientation won't be applied. 1317 * 1318 * <p><b>Syntax:</b> 1319 * <pre> 1320 * <application> 1321 * <property 1322 * android:name="android.window.PROPERTY_COMPAT_ALLOW_DISPLAY_ORIENTATION_OVERRIDE" 1323 * android:value="true|false"/> 1324 * </application> 1325 * </pre> 1326 */ 1327 String PROPERTY_COMPAT_ALLOW_DISPLAY_ORIENTATION_OVERRIDE = 1328 "android.window.PROPERTY_COMPAT_ALLOW_DISPLAY_ORIENTATION_OVERRIDE"; 1329 1330 /** 1331 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1332 * for an app to inform the system that the app should be opted-out from the compatibility 1333 * override that changes the min aspect ratio. 1334 * 1335 * <p>When this compat override is enabled the min aspect ratio given in the app's manifest can 1336 * be overridden by the device manufacturer using their discretion to improve display 1337 * compatibility unless the app's manifest value is higher. This treatment will also apply if 1338 * no min aspect ratio value is provided in the manifest. These treatments can apply either in 1339 * specific cases (e.g. device is in portrait) or each time the app is displayed on screen. 1340 * 1341 * <p>Setting this property to {@code false} informs the system that the app must be 1342 * opted-out from the compatibility treatment even if the device manufacturer has opted the app 1343 * into the treatment. 1344 * 1345 * <p>Not setting this property at all, or setting this property to {@code true} has no effect. 1346 * 1347 * <p><b>Syntax:</b> 1348 * <pre> 1349 * <application> 1350 * <property 1351 * android:name="android.window.PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE" 1352 * android:value="true|false"/> 1353 * </application> 1354 * </pre> 1355 */ 1356 @FlaggedApi(Flags.FLAG_APP_COMPAT_PROPERTIES_API) 1357 String PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE = 1358 "android.window.PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE"; 1359 1360 /** 1361 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1362 * for an app to inform the system that the app should be opted-out from the compatibility 1363 * overrides that change the resizability of the app. 1364 * 1365 * <p>When these compat overrides are enabled they force the packages they are applied to to be 1366 * resizable/unresizable. If the app is forced to be resizable this won't change whether the app 1367 * can be put into multi-windowing mode, but allow the app to resize without going into size 1368 * compatibility mode when the window container resizes, such as display size change or screen 1369 * rotation. 1370 * 1371 * <p>Setting this property to {@code false} informs the system that the app must be 1372 * opted-out from the compatibility treatment even if the device manufacturer has opted the app 1373 * into the treatment. 1374 * 1375 * <p>Not setting this property at all, or setting this property to {@code true} has no effect. 1376 * 1377 * <p><b>Syntax:</b> 1378 * <pre> 1379 * <application> 1380 * <property 1381 * android:name="android.window.PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES" 1382 * android:value="true|false"/> 1383 * </application> 1384 * </pre> 1385 */ 1386 @FlaggedApi(Flags.FLAG_APP_COMPAT_PROPERTIES_API) 1387 String PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES = 1388 "android.window.PROPERTY_COMPAT_ALLOW_RESIZEABLE_ACTIVITY_OVERRIDES"; 1389 1390 /** 1391 * Application level 1392 * {@link android.content.pm.PackageManager.Property PackageManager.Property} 1393 * tag that (when set to false) informs the system the app has opted out of the 1394 * user-facing aspect ratio compatibility override. 1395 * 1396 * <p>The compatibility override enables device users to set the app's aspect 1397 * ratio or force the app to fill the display regardless of the aspect 1398 * ratio or orientation specified in the app manifest. 1399 * 1400 * <p>The aspect ratio compatibility override is exposed to users in device 1401 * settings. A menu in device settings lists all apps that have not opted out of 1402 * the compatibility override. Users select apps from the menu and set the 1403 * app aspect ratio on a per-app basis. Typically, the menu is available 1404 * only on large screen devices. 1405 * 1406 * <p>When users apply the aspect ratio override, the minimum aspect ratio 1407 * specified in the app manifest is overridden. If users choose a 1408 * full-screen aspect ratio, the orientation of the activity is forced to 1409 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_USER}; 1410 * see {@link #PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE} to 1411 * disable the full-screen option only. 1412 * 1413 * <p>The user override is intended to improve the app experience on devices that have the 1414 * ignore orientation request display setting enabled by OEMs, which enables compatibility mode 1415 * for fixed-orientation apps on Android 12 (API level 31) or higher. See 1416 * <a href="{@docRoot}guide/practices/device-compatibility-mode">Device compatibility mode</a> 1417 * for more details. 1418 * 1419 * <p>To opt out of the user aspect ratio compatibility override, add this property 1420 * to your app manifest and set the value to {@code false}. Your app will be excluded 1421 * from the list of apps in device settings, and users will not be able to override 1422 * the app's aspect ratio. 1423 * 1424 * <p>Not setting this property at all, or setting this property to {@code true} has no effect. 1425 * 1426 * <p><b>Syntax:</b> 1427 * <pre> 1428 * <application> 1429 * <property 1430 * android:name="android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE" 1431 * android:value="false"/> 1432 * </application> 1433 * </pre> 1434 */ 1435 @FlaggedApi(Flags.FLAG_APP_COMPAT_PROPERTIES_API) 1436 String PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE = 1437 "android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE"; 1438 1439 /** 1440 * Application level 1441 * {@link android.content.pm.PackageManager.Property PackageManager.Property} 1442 * tag that (when set to false) informs the system the app has opted out of the 1443 * full-screen option of the user aspect ratio compatibility override settings. (For 1444 * background information about the user aspect ratio compatibility override, see 1445 * {@link #PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE}.) 1446 * 1447 * <p>When users apply the full-screen compatibility override, the orientation 1448 * of the activity is forced to {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_USER}. 1449 * 1450 * <p>The user override is intended to improve the app experience on devices that have the 1451 * ignore orientation request display setting enabled by OEMs, which enables compatibility mode 1452 * for fixed-orientation apps on Android 12 (API level 31) or higher. See 1453 * <a href="{@docRoot}guide/practices/device-compatibility-mode">Device compatibility mode</a> 1454 * for more details. 1455 * 1456 * <p>To opt out of the full-screen option of the user aspect ratio compatibility 1457 * override, add this property to your app manifest and set the value to {@code false}. 1458 * Your app will have full-screen option removed from the list of user aspect ratio 1459 * override options in device settings, and users will not be able to apply 1460 * full-screen override to your app. 1461 * 1462 * <p><b>Note:</b> If {@link #PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE} is 1463 * {@code false}, this property has no effect. 1464 * 1465 * <p>Not setting this property at all, or setting this property to {@code true} has no effect. 1466 * 1467 * <p><b>Syntax:</b> 1468 * <pre> 1469 * <application> 1470 * <property 1471 * android:name="android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE" 1472 * android:value="false"/> 1473 * </application> 1474 * </pre> 1475 */ 1476 @FlaggedApi(Flags.FLAG_APP_COMPAT_PROPERTIES_API) 1477 String PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE = 1478 "android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE"; 1479 1480 /** 1481 * Application or Activity level 1482 * {@link android.content.pm.PackageManager.Property PackageManager.Property} 1483 * that specifies whether this package or activity can declare or request 1484 * {@link android.R.attr#screenOrientation fixed orientation}, 1485 * {@link android.R.attr#minAspectRatio max aspect ratio}, 1486 * {@link android.R.attr#maxAspectRatio min aspect ratio} 1487 * {@link android.R.attr#resizeableActivity unresizable} on large screen devices with the 1488 * ignore orientation request display setting enabled since Android 16 (API level 36) or higher. 1489 * 1490 * <p>The default value is {@code false}. 1491 * 1492 * <p><b>Syntax:</b> 1493 * <pre> 1494 * <application> 1495 * <property 1496 * android:name="android.window.PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE" 1497 * android:value="false"/> 1498 * </application> 1499 * </pre>or 1500 * <pre> 1501 * <activity> 1502 * <property 1503 * android:name="android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY" 1504 * android:value="true"/> 1505 * </activity> 1506 * </pre> 1507 * @hide 1508 */ 1509 // TODO(b/357141415): Remove this from sdk 37 1510 String PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY = 1511 "android.window.PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY"; 1512 1513 /** 1514 * Application or Activity level 1515 * {@link android.content.pm.PackageManager.Property PackageManager.Property} that specifies 1516 * whether this package or activity wants to allow safe region letterboxing. A safe 1517 * region policy may be applied by the system to improve the user experience by ensuring that 1518 * the activity does not have any content that is occluded and has the correct current 1519 * window metrics. 1520 * 1521 * <p>Not setting the property at all defaults it to {@code true}. In such a case, the activity 1522 * will be letterboxed in the safe region. 1523 * 1524 * <p>To not allow the safe region letterboxing, add this property to your app 1525 * manifest and set the value to {@code false}. An app should ignore safe region 1526 * letterboxing if it can handle bounds and insets from all four directions correctly when a 1527 * request to go immersive is denied by the system. If the application does not allow safe 1528 * region letterboxing, the system will not override this behavior. 1529 * 1530 * <p><b>Syntax:</b> 1531 * <pre> 1532 * <application> 1533 * <property 1534 * android:name="android.window.PROPERTY_COMPAT_ALLOW_SAFE_REGION_LETTERBOXING" 1535 * android:value="false"/> 1536 * </application> 1537 * </pre>or 1538 * <pre> 1539 * <activity> 1540 * <property 1541 * android:name="android.window.PROPERTY_COMPAT_ALLOW_SAFE_REGION_LETTERBOXING" 1542 * android:value="false"/> 1543 * </activity> 1544 * </pre> 1545 * @hide 1546 */ 1547 @FlaggedApi(Flags.FLAG_SAFE_REGION_LETTERBOXING) 1548 String PROPERTY_COMPAT_ALLOW_SAFE_REGION_LETTERBOXING = 1549 "android.window.PROPERTY_COMPAT_ALLOW_SAFE_REGION_LETTERBOXING"; 1550 1551 /** 1552 * @hide 1553 */ 1554 public static final String PARCEL_KEY_SHORTCUTS_ARRAY = "shortcuts_array"; 1555 1556 /** 1557 * Whether the WindowManager Extensions - Activity Embedding feature should be guarded by 1558 * the app's target SDK on Android 15. 1559 * 1560 * WindowManager Extensions are only required for foldable and large screen before Android 15, 1561 * so we want to guard the Activity Embedding feature since it can have app compat impact on 1562 * devices with a compact size display. 1563 * 1564 * <p>If {@code true}, the feature is only enabled if the app's target SDK is Android 15 or 1565 * above. 1566 * 1567 * <p>If {@code false}, the feature is enabled for all apps. 1568 * 1569 * <p>The default value is {@code true}. OEMs can set to {@code false} by having their device 1570 * config to inherit window_extensions.mk. This is also required for large screen devices. 1571 * <pre> 1572 * $(call inherit-product, $(SRC_TARGET_DIR)/product/window_extensions.mk) 1573 * </pre> 1574 * 1575 * @hide 1576 */ 1577 boolean ACTIVITY_EMBEDDING_GUARD_WITH_ANDROID_15 = SystemProperties.getBoolean( 1578 "persist.wm.extensions.activity_embedding_guard_with_android_15", true); 1579 1580 /** 1581 * For devices with {@link #ACTIVITY_EMBEDDING_GUARD_WITH_ANDROID_15} as {@code true}, 1582 * the Activity Embedding feature is enabled if the app's target SDK is Android 15+. 1583 * 1584 * @see #ACTIVITY_EMBEDDING_GUARD_WITH_ANDROID_15 1585 * @hide 1586 */ 1587 @ChangeId 1588 @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM) 1589 long ENABLE_ACTIVITY_EMBEDDING_FOR_ANDROID_15 = 306666082L; 1590 1591 /** 1592 * Whether the device contains the WindowManager Extensions shared library. 1593 * This is enabled for all devices through window_extensions_base.mk, but can be dropped if the 1594 * device doesn't support multi window. 1595 * 1596 * <p>Note: Large screen devices must also inherit window_extensions.mk to enable the Activity 1597 * Embedding feature by default for all apps. 1598 * 1599 * @see #ACTIVITY_EMBEDDING_GUARD_WITH_ANDROID_15 1600 * @hide 1601 */ 1602 boolean HAS_WINDOW_EXTENSIONS_ON_DEVICE = 1603 SystemProperties.getBoolean("persist.wm.extensions.enabled", false); 1604 1605 /** 1606 * Whether the WindowManager Extensions are enabled. 1607 * If {@code false}, the WM Jetpack will report most of its features as disabled. 1608 * @see #HAS_WINDOW_EXTENSIONS_ON_DEVICE 1609 * @hide 1610 */ 1611 @TestApi hasWindowExtensionsEnabled()1612 static boolean hasWindowExtensionsEnabled() { 1613 if (!HAS_WINDOW_EXTENSIONS_ON_DEVICE) { 1614 return false; 1615 } 1616 1617 try { 1618 final Context context = ActivityThread.currentApplication(); 1619 if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH)) { 1620 // Watch supports multi-window to present essential system UI, but it doesn't need 1621 // WM Extensions. 1622 return false; 1623 } 1624 return ActivityTaskManager.supportsMultiWindow(context); 1625 } catch (Exception e) { 1626 // In case the PackageManager is not set up correctly in test. 1627 Log.e("WindowManager", "Unable to read if the device supports multi window", e); 1628 return false; 1629 } 1630 } 1631 1632 /** 1633 * Application-level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1634 * tag that specifies whether OEMs are permitted to provide activity embedding split-rule 1635 * configurations on behalf of the app. 1636 * 1637 * <p>If {@code true}, the system is permitted to override the app's windowing behavior and 1638 * implement activity embedding split rules, such as displaying activities side by side. A 1639 * system override informs the app that the activity embedding APIs are disabled so the app 1640 * doesn't provide its own activity embedding rules, which would conflict with the system's 1641 * rules. 1642 * 1643 * <p>If {@code false}, the system is not permitted to override the windowing behavior of the 1644 * app. Set the property to {@code false} if the app provides its own activity embedding split 1645 * rules, or if you want to prevent the system override for any other reason. 1646 * 1647 * <p>The default value is {@code false}. 1648 * 1649 * <p class="note"><b>Note:</b> Refusal to permit the system override is not enforceable. OEMs 1650 * can override the app's activity embedding implementation whether or not this property is 1651 * specified and set to {@code false}. The property is, in effect, a hint to OEMs. 1652 * 1653 * <p>OEMs can implement activity embedding on any API level. The best practice for apps is to 1654 * always explicitly set this property in the app manifest file regardless of targeted API level 1655 * rather than rely on the default value. 1656 * 1657 * <p><b>Syntax:</b> 1658 * <pre> 1659 * <application> 1660 * <property 1661 * android:name="android.window.PROPERTY_ACTIVITY_EMBEDDING_ALLOW_SYSTEM_OVERRIDE" 1662 * android:value="true|false"/> 1663 * </application> 1664 * </pre> 1665 */ 1666 String PROPERTY_ACTIVITY_EMBEDDING_ALLOW_SYSTEM_OVERRIDE = 1667 "android.window.PROPERTY_ACTIVITY_EMBEDDING_ALLOW_SYSTEM_OVERRIDE"; 1668 1669 /** 1670 * Activity-level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1671 * that declares whether this (embedded) activity allows the system to share its state with the 1672 * host app when it is embedded in a different process in 1673 * {@link android.R.attr#allowUntrustedActivityEmbedding untrusted mode}. 1674 * 1675 * <p>If this property is "true", the host app may receive event callbacks for the activity 1676 * state change, including the reparent event and the component name of the activity, which are 1677 * required to restore the embedding state after the embedded activity exits picture-in-picture 1678 * mode. This property does not share any of the activity content with the host. Note that, for 1679 * {@link android.R.attr#knownActivityEmbeddingCerts trusted embedding}, the reparent event and 1680 * the component name are always shared with the host regardless of the value of this property. 1681 * 1682 * <p>The default value is {@code false}. 1683 * 1684 * <p><b>Syntax:</b> 1685 * <pre> 1686 * <activity> 1687 * <property 1688 * android:name="android.window.PROPERTY_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING_STATE_SHARING" 1689 * android:value="true|false"/> 1690 * </activity> 1691 * </pre> 1692 * 1693 * @hide 1694 */ 1695 String PROPERTY_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING_STATE_SHARING = 1696 "android.window.PROPERTY_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING_STATE_SHARING"; 1697 1698 /** 1699 * Application level {@link android.content.pm.PackageManager.Property PackageManager.Property} 1700 * that an app can specify to inform the system that the app is activity embedding split feature 1701 * enabled. 1702 * 1703 * <p>With this property, the system could provide custom behaviors for the apps that are 1704 * activity embedding split feature enabled. For example, the fixed-portrait orientation 1705 * requests of the activities could be ignored by the system in order to provide seamless 1706 * activity embedding split experiences while holding large screen devices in landscape 1707 * orientation. 1708 * 1709 * <p><b>Syntax:</b> 1710 * <pre> 1711 * <application> 1712 * <property 1713 * android:name="android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED" 1714 * android:value="true|false"/> 1715 * </application> 1716 * </pre> 1717 */ 1718 String PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED = 1719 "android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED"; 1720 1721 /** 1722 * Activity or Application level {@link android.content.pm.PackageManager.Property 1723 * PackageManager.Property} for an app to declare that System UI should be shown for this 1724 * app/component to allow it to be launched as multiple instances. This property only affects 1725 * SystemUI behavior and does _not_ affect whether a component can actually be launched into 1726 * multiple instances, which is determined by the Activity's {@code launchMode} or the launching 1727 * Intent's flags. If the property is set on the Application, then all components within that 1728 * application will use that value unless specified per component. 1729 * 1730 * The value must be a boolean string. 1731 * 1732 * <p><b>Syntax:</b> 1733 * <pre> 1734 * <activity> 1735 * <property 1736 * android:name="android.window.PROPERTY_SUPPORTS_MULTI_INSTANCE_SYSTEM_UI" 1737 * android:value="true|false"/> 1738 * </activity> 1739 * </pre> 1740 */ 1741 @FlaggedApi(Flags.FLAG_SUPPORTS_MULTI_INSTANCE_SYSTEM_UI) 1742 public static final String PROPERTY_SUPPORTS_MULTI_INSTANCE_SYSTEM_UI = 1743 "android.window.PROPERTY_SUPPORTS_MULTI_INSTANCE_SYSTEM_UI"; 1744 1745 /** 1746 * Application or Activity level 1747 * {@link android.content.pm.PackageManager.Property PackageManager.Property} to provide any 1748 * preferences for showing all or specific Activities on small cover displays of foldable 1749 * style devices. 1750 * 1751 * <p>The only supported value for the property is {@link #COMPAT_SMALL_COVER_SCREEN_OPT_IN}. 1752 * 1753 * <p><b>Syntax:</b> 1754 * <pre> 1755 * <application> 1756 * <property 1757 * android:name="android.window.PROPERTY_COMPAT_ALLOW_SMALL_COVER_SCREEN" 1758 * android:value=1 <!-- COMPAT_COVER_SCREEN_OPT_IN -->/> 1759 * </application> 1760 * </pre> 1761 */ 1762 @FlaggedApi(Flags.FLAG_COVER_DISPLAY_OPT_IN) 1763 String PROPERTY_COMPAT_ALLOW_SMALL_COVER_SCREEN = 1764 "android.window.PROPERTY_COMPAT_ALLOW_SMALL_COVER_SCREEN"; 1765 1766 /** 1767 * Value applicable for the {@link #PROPERTY_COMPAT_ALLOW_SMALL_COVER_SCREEN} property to 1768 * provide a signal to the system that an application or its specific activities explicitly 1769 * opt into being displayed on small cover screens on flippable style foldable devices that 1770 * measure at least 1.5 inches up to 2.2 inches for the shorter dimension and at least 2.4 1771 * inches up to 3.4 inches for the longer dimension 1772 */ 1773 @CompatSmallScreenPolicy 1774 @FlaggedApi(Flags.FLAG_COVER_DISPLAY_OPT_IN) 1775 int COMPAT_SMALL_COVER_SCREEN_OPT_IN = 1; 1776 1777 /** 1778 * @hide 1779 */ 1780 @IntDef({ 1781 COMPAT_SMALL_COVER_SCREEN_OPT_IN, 1782 }) 1783 @Retention(RetentionPolicy.SOURCE) 1784 @interface CompatSmallScreenPolicy {} 1785 1786 1787 1788 /** 1789 * Request for app's keyboard shortcuts to be retrieved asynchronously. 1790 * 1791 * @param receiver The callback to be triggered when the result is ready. 1792 * @param deviceId The deviceId of KeyEvent by which this request is triggered, or -1 if it's 1793 * not triggered by a KeyEvent. 1794 * 1795 * @hide 1796 */ requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId)1797 public void requestAppKeyboardShortcuts(final KeyboardShortcutsReceiver receiver, int deviceId); 1798 1799 /** 1800 * Request the application launch keyboard shortcuts the system has defined. 1801 * 1802 * @param deviceId The id of the {@link InputDevice} that will handle the shortcut. 1803 * 1804 * @hide 1805 */ getApplicationLaunchKeyboardShortcuts(int deviceId)1806 KeyboardShortcutGroup getApplicationLaunchKeyboardShortcuts(int deviceId); 1807 1808 /** 1809 * Request for ime's keyboard shortcuts to be retrieved asynchronously. 1810 * 1811 * @param receiver The callback to be triggered when the result is ready. 1812 * @param deviceId The deviceId of KeyEvent by which this request is triggered, or -1 if it's 1813 * not triggered by a KeyEvent. 1814 * 1815 * @hide 1816 */ requestImeKeyboardShortcuts(KeyboardShortcutsReceiver receiver, int deviceId)1817 default void requestImeKeyboardShortcuts(KeyboardShortcutsReceiver receiver, int deviceId) {}; 1818 1819 /** 1820 * Return the touch region for the current IME window, or an empty region if there is none. 1821 * 1822 * @return The region of the IME that is accepting touch inputs, or null if there is no IME, no 1823 * region or there was an error. 1824 * 1825 * @hide 1826 */ 1827 @SystemApi 1828 @RequiresPermission(android.Manifest.permission.RESTRICTED_VR_ACCESS) getCurrentImeTouchRegion()1829 public Region getCurrentImeTouchRegion(); 1830 1831 /** 1832 * Sets that the display should show its content when non-secure keyguard is shown. 1833 * 1834 * @param displayId Display ID. 1835 * @param shouldShow Indicates that the display should show its content when non-secure keyguard 1836 * is shown. 1837 * @see KeyguardManager#isDeviceSecure() 1838 * @see KeyguardManager#isDeviceLocked() 1839 * @hide 1840 */ 1841 @TestApi setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow)1842 default void setShouldShowWithInsecureKeyguard(int displayId, boolean shouldShow) { 1843 } 1844 1845 /** 1846 * Sets that the display should show system decors. 1847 * <p> 1848 * System decors include status bar, navigation bar, launcher. 1849 * </p> 1850 * 1851 * @param displayId The id of the display. 1852 * @param shouldShow Indicates that the display should show system decors. 1853 * @see #shouldShowSystemDecors(int) 1854 * @hide 1855 */ 1856 @TestApi setShouldShowSystemDecors(int displayId, boolean shouldShow)1857 default void setShouldShowSystemDecors(int displayId, boolean shouldShow) { 1858 } 1859 1860 /** 1861 * Checks if the display supports showing system decors. 1862 * <p> 1863 * System decors include status bar, navigation bar, launcher. 1864 * </p> 1865 * 1866 * @param displayId The id of the display. 1867 * @see #setShouldShowSystemDecors(int, boolean) 1868 * @hide 1869 */ 1870 @TestApi shouldShowSystemDecors(int displayId)1871 default boolean shouldShowSystemDecors(int displayId) { 1872 return false; 1873 } 1874 1875 /** 1876 * Sets the policy for how the display should show IME. 1877 * 1878 * @param displayId Display ID. 1879 * @param imePolicy Indicates the policy for how the display should show IME. 1880 * @hide 1881 */ 1882 @TestApi setDisplayImePolicy(int displayId, @DisplayImePolicy int imePolicy)1883 default void setDisplayImePolicy(int displayId, @DisplayImePolicy int imePolicy) { 1884 } 1885 1886 /** 1887 * Indicates the policy for how the display should show IME. 1888 * 1889 * @param displayId The id of the display. 1890 * @return The policy for how the display should show IME. 1891 * @hide 1892 */ 1893 @TestApi getDisplayImePolicy(int displayId)1894 default @DisplayImePolicy int getDisplayImePolicy(int displayId) { 1895 return DISPLAY_IME_POLICY_FALLBACK_DISPLAY; 1896 } 1897 1898 /** 1899 * Returns {@code true} if the key will be handled globally and not forwarded to all apps. 1900 * 1901 * @param keyCode the key code to check 1902 * @return {@code true} if the key will be handled globally. 1903 * @hide 1904 */ 1905 @TestApi isGlobalKey(int keyCode)1906 default boolean isGlobalKey(int keyCode) { 1907 return false; 1908 } 1909 1910 /** 1911 * <p> 1912 * Returns whether cross-window blur is currently enabled. This affects both window blur behind 1913 * (see {@link LayoutParams#setBlurBehindRadius}) and window background blur (see 1914 * {@link Window#setBackgroundBlurRadius}). 1915 * </p><p> 1916 * Cross-window blur might not be supported by some devices due to GPU limitations. It can also 1917 * be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or 1918 * when minimal post processing is requested. In such situations, no blur will be computed or 1919 * drawn, so the blur target area will not be blurred. To handle this, the app might want to 1920 * change its theme to one that does not use blurs. To listen for cross-window blur 1921 * enabled/disabled events, use {@link #addCrossWindowBlurEnabledListener}. 1922 * </p> 1923 * 1924 * @see #addCrossWindowBlurEnabledListener 1925 * @see LayoutParams#setBlurBehindRadius 1926 * @see Window#setBackgroundBlurRadius 1927 */ isCrossWindowBlurEnabled()1928 default boolean isCrossWindowBlurEnabled() { 1929 return false; 1930 } 1931 1932 /** 1933 * <p> 1934 * Adds a listener, which will be called when cross-window blurs are enabled/disabled at 1935 * runtime. This affects both window blur behind (see {@link LayoutParams#setBlurBehindRadius}) 1936 * and window background blur (see {@link Window#setBackgroundBlurRadius}). 1937 * </p><p> 1938 * Cross-window blur might not be supported by some devices due to GPU limitations. It can also 1939 * be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or 1940 * when minimal post processing is requested. In such situations, no blur will be computed or 1941 * drawn, so the blur target area will not be blurred. To handle this, the app might want to 1942 * change its theme to one that does not use blurs. 1943 * </p><p> 1944 * The listener will be called on the main thread. 1945 * </p><p> 1946 * If the listener is added successfully, it will be called immediately with the current 1947 * cross-window blur enabled state. 1948 * </p> 1949 * 1950 * @param listener the listener to be added. It will be called back with a boolean parameter, 1951 * which is true if cross-window blur is enabled and false if it is disabled 1952 * 1953 * @see #removeCrossWindowBlurEnabledListener 1954 * @see #isCrossWindowBlurEnabled 1955 * @see LayoutParams#setBlurBehindRadius 1956 * @see Window#setBackgroundBlurRadius 1957 */ addCrossWindowBlurEnabledListener(@onNull Consumer<Boolean> listener)1958 default void addCrossWindowBlurEnabledListener(@NonNull Consumer<Boolean> listener) { 1959 } 1960 1961 /** 1962 * <p> 1963 * Adds a listener, which will be called when cross-window blurs are enabled/disabled at 1964 * runtime. This affects both window blur behind (see {@link LayoutParams#setBlurBehindRadius}) 1965 * and window background blur (see {@link Window#setBackgroundBlurRadius}). 1966 * </p><p> 1967 * Cross-window blur might not be supported by some devices due to GPU limitations. It can also 1968 * be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling is used or 1969 * when minimal post processing is requested. In such situations, no blur will be computed or 1970 * drawn, so the blur target area will not be blurred. To handle this, the app might want to 1971 * change its theme to one that does not use blurs. 1972 * </p><p> 1973 * If the listener is added successfully, it will be called immediately with the current 1974 * cross-window blur enabled state. 1975 * </p> 1976 * 1977 * @param executor {@link Executor} to handle the listener callback 1978 * @param listener the listener to be added. It will be called back with a boolean parameter, 1979 * which is true if cross-window blur is enabled and false if it is disabled 1980 * 1981 * @see #removeCrossWindowBlurEnabledListener 1982 * @see #isCrossWindowBlurEnabled 1983 * @see LayoutParams#setBlurBehindRadius 1984 * @see Window#setBackgroundBlurRadius 1985 */ addCrossWindowBlurEnabledListener(@onNull @allbackExecutor Executor executor, @NonNull Consumer<Boolean> listener)1986 default void addCrossWindowBlurEnabledListener(@NonNull @CallbackExecutor Executor executor, 1987 @NonNull Consumer<Boolean> listener) { 1988 } 1989 1990 /** 1991 * Removes a listener, previously added with {@link #addCrossWindowBlurEnabledListener} 1992 * 1993 * @param listener the listener to be removed 1994 * 1995 * @see #addCrossWindowBlurEnabledListener 1996 */ removeCrossWindowBlurEnabledListener(@onNull Consumer<Boolean> listener)1997 default void removeCrossWindowBlurEnabledListener(@NonNull Consumer<Boolean> listener) { 1998 } 1999 2000 /** 2001 * Adds a listener to start monitoring the proposed rotation of the current associated context. 2002 * It reports the current recommendation for the rotation that takes various factors (e.g. 2003 * sensor, context, device state, etc) into account. The proposed rotation might not be applied 2004 * by the system automatically due to the application's active preference to lock the 2005 * orientation (e.g. with {@link android.app.Activity#setRequestedOrientation(int)}). This 2006 * listener gives application an opportunity to selectively react to device orientation changes. 2007 * The newly added listener will be called with current proposed rotation. Note that the context 2008 * of this window manager instance must be a {@code UiContext}. 2009 * 2010 * @param executor The executor on which callback method will be invoked. 2011 * @param listener Called when the proposed rotation for the context is being delivered. 2012 * The reported rotation can be {@link Surface#ROTATION_0}, 2013 * {@link Surface#ROTATION_90}, {@link Surface#ROTATION_180} and 2014 * {@link Surface#ROTATION_270}. 2015 * @throws UnsupportedOperationException if this method is called on an instance that is not 2016 * associated with a {@code UiContext}. 2017 */ addProposedRotationListener(@onNull @allbackExecutor Executor executor, @NonNull IntConsumer listener)2018 default void addProposedRotationListener(@NonNull @CallbackExecutor Executor executor, 2019 @NonNull IntConsumer listener) { 2020 } 2021 2022 /** 2023 * Removes a listener, previously added with {@link #addProposedRotationListener}. It is 2024 * recommended to call when the associated context no longer has visible components. No-op if 2025 * the provided listener is not registered. 2026 * 2027 * @param listener The listener to be removed. 2028 */ removeProposedRotationListener(@onNull IntConsumer listener)2029 default void removeProposedRotationListener(@NonNull IntConsumer listener) { 2030 } 2031 2032 /** 2033 * @hide 2034 */ transitTypeToString(@ransitionType int type)2035 static String transitTypeToString(@TransitionType int type) { 2036 switch (type) { 2037 case TRANSIT_NONE: return "NONE"; 2038 case TRANSIT_OPEN: return "OPEN"; 2039 case TRANSIT_CLOSE: return "CLOSE"; 2040 case TRANSIT_TO_FRONT: return "TO_FRONT"; 2041 case TRANSIT_TO_BACK: return "TO_BACK"; 2042 case TRANSIT_RELAUNCH: return "RELAUNCH"; 2043 case TRANSIT_CHANGE: return "CHANGE"; 2044 case TRANSIT_KEYGUARD_GOING_AWAY: return "KEYGUARD_GOING_AWAY"; 2045 case TRANSIT_KEYGUARD_OCCLUDE: return "KEYGUARD_OCCLUDE"; 2046 case TRANSIT_KEYGUARD_UNOCCLUDE: return "KEYGUARD_UNOCCLUDE"; 2047 case TRANSIT_PIP: return "PIP"; 2048 case TRANSIT_WAKE: return "WAKE"; 2049 case TRANSIT_SLEEP: return "SLEEP"; 2050 case TRANSIT_PREPARE_BACK_NAVIGATION: return "PREDICTIVE_BACK"; 2051 case TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION: return "CLOSE_PREDICTIVE_BACK"; 2052 case TRANSIT_FIRST_CUSTOM: return "FIRST_CUSTOM"; 2053 default: 2054 if (type > TRANSIT_FIRST_CUSTOM) { 2055 return "FIRST_CUSTOM+" + (type - TRANSIT_FIRST_CUSTOM); 2056 } 2057 return "UNKNOWN(" + type + ")"; 2058 } 2059 } 2060 2061 /** 2062 * Ensure scales are between 0 and 20. 2063 * @hide 2064 */ fixScale(float scale)2065 static float fixScale(float scale) { 2066 return Math.max(Math.min(scale, 20), 0); 2067 } 2068 2069 public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable { 2070 /** 2071 * X position for this window. With the default gravity it is ignored. 2072 * When using {@link Gravity#LEFT} or {@link Gravity#START} or {@link Gravity#RIGHT} or 2073 * {@link Gravity#END} it provides an offset from the given edge. 2074 */ 2075 @ViewDebug.ExportedProperty 2076 public int x; 2077 2078 /** 2079 * Y position for this window. With the default gravity it is ignored. 2080 * When using {@link Gravity#TOP} or {@link Gravity#BOTTOM} it provides 2081 * an offset from the given edge. 2082 */ 2083 @ViewDebug.ExportedProperty 2084 public int y; 2085 2086 /** 2087 * Indicates how much of the extra space will be allocated horizontally 2088 * to the view associated with these LayoutParams. Specify 0 if the view 2089 * should not be stretched. Otherwise the extra pixels will be pro-rated 2090 * among all views whose weight is greater than 0. 2091 */ 2092 @ViewDebug.ExportedProperty 2093 public float horizontalWeight; 2094 2095 /** 2096 * Indicates how much of the extra space will be allocated vertically 2097 * to the view associated with these LayoutParams. Specify 0 if the view 2098 * should not be stretched. Otherwise the extra pixels will be pro-rated 2099 * among all views whose weight is greater than 0. 2100 */ 2101 @ViewDebug.ExportedProperty 2102 public float verticalWeight; 2103 2104 /** 2105 * The general type of window. There are three main classes of 2106 * window types: 2107 * <ul> 2108 * <li> <strong>Application windows</strong> (ranging from 2109 * {@link #FIRST_APPLICATION_WINDOW} to 2110 * {@link #LAST_APPLICATION_WINDOW}) are normal top-level application 2111 * windows. For these types of windows, the {@link #token} must be 2112 * set to the token of the activity they are a part of (this will 2113 * normally be done for you if {@link #token} is null). 2114 * <li> <strong>Sub-windows</strong> (ranging from 2115 * {@link #FIRST_SUB_WINDOW} to 2116 * {@link #LAST_SUB_WINDOW}) are associated with another top-level 2117 * window. For these types of windows, the {@link #token} must be 2118 * the token of the window it is attached to. 2119 * <li> <strong>System windows</strong> (ranging from 2120 * {@link #FIRST_SYSTEM_WINDOW} to 2121 * {@link #LAST_SYSTEM_WINDOW}) are special types of windows for 2122 * use by the system for specific purposes. They should not normally 2123 * be used by applications, and a special permission is required 2124 * to use them. 2125 * </ul> 2126 * 2127 * @see #TYPE_BASE_APPLICATION 2128 * @see #TYPE_APPLICATION 2129 * @see #TYPE_APPLICATION_STARTING 2130 * @see #TYPE_DRAWN_APPLICATION 2131 * @see #TYPE_APPLICATION_PANEL 2132 * @see #TYPE_APPLICATION_MEDIA 2133 * @see #TYPE_APPLICATION_SUB_PANEL 2134 * @see #TYPE_APPLICATION_ATTACHED_DIALOG 2135 * @see #TYPE_STATUS_BAR 2136 * @see #TYPE_SEARCH_BAR 2137 * @see #TYPE_PHONE 2138 * @see #TYPE_SYSTEM_ALERT 2139 * @see #TYPE_TOAST 2140 * @see #TYPE_SYSTEM_OVERLAY 2141 * @see #TYPE_PRIORITY_PHONE 2142 * @see #TYPE_SYSTEM_DIALOG 2143 * @see #TYPE_KEYGUARD_DIALOG 2144 * @see #TYPE_SYSTEM_ERROR 2145 * @see #TYPE_INPUT_METHOD 2146 * @see #TYPE_INPUT_METHOD_DIALOG 2147 */ 2148 @ViewDebug.ExportedProperty(mapping = { 2149 @ViewDebug.IntToString(from = TYPE_BASE_APPLICATION, 2150 to = "BASE_APPLICATION"), 2151 @ViewDebug.IntToString(from = TYPE_APPLICATION, 2152 to = "APPLICATION"), 2153 @ViewDebug.IntToString(from = TYPE_APPLICATION_STARTING, 2154 to = "APPLICATION_STARTING"), 2155 @ViewDebug.IntToString(from = TYPE_DRAWN_APPLICATION, 2156 to = "DRAWN_APPLICATION"), 2157 @ViewDebug.IntToString(from = TYPE_APPLICATION_PANEL, 2158 to = "APPLICATION_PANEL"), 2159 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA, 2160 to = "APPLICATION_MEDIA"), 2161 @ViewDebug.IntToString(from = TYPE_APPLICATION_SUB_PANEL, 2162 to = "APPLICATION_SUB_PANEL"), 2163 @ViewDebug.IntToString(from = TYPE_APPLICATION_ABOVE_SUB_PANEL, 2164 to = "APPLICATION_ABOVE_SUB_PANEL"), 2165 @ViewDebug.IntToString(from = TYPE_APPLICATION_ATTACHED_DIALOG, 2166 to = "APPLICATION_ATTACHED_DIALOG"), 2167 @ViewDebug.IntToString(from = TYPE_APPLICATION_MEDIA_OVERLAY, 2168 to = "APPLICATION_MEDIA_OVERLAY"), 2169 @ViewDebug.IntToString(from = TYPE_STATUS_BAR, 2170 to = "STATUS_BAR"), 2171 @ViewDebug.IntToString(from = TYPE_SEARCH_BAR, 2172 to = "SEARCH_BAR"), 2173 @ViewDebug.IntToString(from = TYPE_PHONE, 2174 to = "PHONE"), 2175 @ViewDebug.IntToString(from = TYPE_SYSTEM_ALERT, 2176 to = "SYSTEM_ALERT"), 2177 @ViewDebug.IntToString(from = TYPE_KEYGUARD, 2178 to = "KEYGUARD"), 2179 @ViewDebug.IntToString(from = TYPE_TOAST, 2180 to = "TOAST"), 2181 @ViewDebug.IntToString(from = TYPE_SYSTEM_OVERLAY, 2182 to = "SYSTEM_OVERLAY"), 2183 @ViewDebug.IntToString(from = TYPE_PRIORITY_PHONE, 2184 to = "PRIORITY_PHONE"), 2185 @ViewDebug.IntToString(from = TYPE_SYSTEM_DIALOG, 2186 to = "SYSTEM_DIALOG"), 2187 @ViewDebug.IntToString(from = TYPE_KEYGUARD_DIALOG, 2188 to = "KEYGUARD_DIALOG"), 2189 @ViewDebug.IntToString(from = TYPE_SYSTEM_ERROR, 2190 to = "SYSTEM_ERROR"), 2191 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD, 2192 to = "INPUT_METHOD"), 2193 @ViewDebug.IntToString(from = TYPE_INPUT_METHOD_DIALOG, 2194 to = "INPUT_METHOD_DIALOG"), 2195 @ViewDebug.IntToString(from = TYPE_WALLPAPER, 2196 to = "WALLPAPER"), 2197 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_PANEL, 2198 to = "STATUS_BAR_PANEL"), 2199 @ViewDebug.IntToString(from = TYPE_SECURE_SYSTEM_OVERLAY, 2200 to = "SECURE_SYSTEM_OVERLAY"), 2201 @ViewDebug.IntToString(from = TYPE_DRAG, 2202 to = "DRAG"), 2203 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_SUB_PANEL, 2204 to = "STATUS_BAR_SUB_PANEL"), 2205 @ViewDebug.IntToString(from = TYPE_POINTER, 2206 to = "POINTER"), 2207 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR, 2208 to = "NAVIGATION_BAR"), 2209 @ViewDebug.IntToString(from = TYPE_VOLUME_OVERLAY, 2210 to = "VOLUME_OVERLAY"), 2211 @ViewDebug.IntToString(from = TYPE_BOOT_PROGRESS, 2212 to = "BOOT_PROGRESS"), 2213 @ViewDebug.IntToString(from = TYPE_INPUT_CONSUMER, 2214 to = "INPUT_CONSUMER"), 2215 @ViewDebug.IntToString(from = TYPE_NAVIGATION_BAR_PANEL, 2216 to = "NAVIGATION_BAR_PANEL"), 2217 @ViewDebug.IntToString(from = TYPE_DISPLAY_OVERLAY, 2218 to = "DISPLAY_OVERLAY"), 2219 @ViewDebug.IntToString(from = TYPE_MAGNIFICATION_OVERLAY, 2220 to = "MAGNIFICATION_OVERLAY"), 2221 @ViewDebug.IntToString(from = TYPE_PRESENTATION, 2222 to = "PRESENTATION"), 2223 @ViewDebug.IntToString(from = TYPE_PRIVATE_PRESENTATION, 2224 to = "PRIVATE_PRESENTATION"), 2225 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION, 2226 to = "VOICE_INTERACTION"), 2227 @ViewDebug.IntToString(from = TYPE_ACCESSIBILITY_OVERLAY, 2228 to = "ACCESSIBILITY_OVERLAY"), 2229 @ViewDebug.IntToString(from = TYPE_VOICE_INTERACTION_STARTING, 2230 to = "VOICE_INTERACTION_STARTING"), 2231 @ViewDebug.IntToString(from = TYPE_DOCK_DIVIDER, 2232 to = "DOCK_DIVIDER"), 2233 @ViewDebug.IntToString(from = TYPE_QS_DIALOG, 2234 to = "QS_DIALOG"), 2235 @ViewDebug.IntToString(from = TYPE_SCREENSHOT, 2236 to = "SCREENSHOT"), 2237 @ViewDebug.IntToString(from = TYPE_APPLICATION_OVERLAY, 2238 to = "APPLICATION_OVERLAY"), 2239 @ViewDebug.IntToString(from = TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY, 2240 to = "ACCESSIBILITY_MAGNIFICATION_OVERLAY"), 2241 @ViewDebug.IntToString(from = TYPE_NOTIFICATION_SHADE, 2242 to = "NOTIFICATION_SHADE"), 2243 @ViewDebug.IntToString(from = TYPE_STATUS_BAR_ADDITIONAL, 2244 to = "STATUS_BAR_ADDITIONAL") 2245 }) 2246 @WindowType 2247 public int type; 2248 2249 /** 2250 * Start of window types that represent normal application windows. 2251 */ 2252 public static final int FIRST_APPLICATION_WINDOW = 1; 2253 2254 /** 2255 * Window type: an application window that serves as the "base" window 2256 * of the overall application; all other application windows will 2257 * appear on top of it. 2258 * In multiuser systems shows only on the owning user's window. 2259 */ 2260 public static final int TYPE_BASE_APPLICATION = 1; 2261 2262 /** 2263 * Window type: a normal application window. The {@link #token} must be 2264 * an Activity token identifying who the window belongs to. 2265 * In multiuser systems shows only on the owning user's window. 2266 */ 2267 public static final int TYPE_APPLICATION = 2; 2268 2269 /** 2270 * Window type: special application window that is displayed while the 2271 * application is starting. Not for use by applications themselves; 2272 * this is used by the system to display something until the 2273 * application can show its own windows. 2274 * In multiuser systems shows on all users' windows. 2275 */ 2276 public static final int TYPE_APPLICATION_STARTING = 3; 2277 2278 /** 2279 * Window type: a variation on TYPE_APPLICATION that ensures the window 2280 * manager will wait for this window to be drawn before the app is shown. 2281 * In multiuser systems shows only on the owning user's window. 2282 */ 2283 public static final int TYPE_DRAWN_APPLICATION = 4; 2284 2285 /** 2286 * End of types of application windows. 2287 */ 2288 public static final int LAST_APPLICATION_WINDOW = 99; 2289 2290 /** 2291 * Start of types of sub-windows. The {@link #token} of these windows 2292 * must be set to the window they are attached to. These types of 2293 * windows are kept next to their attached window in Z-order, and their 2294 * coordinate space is relative to their attached window. 2295 */ 2296 public static final int FIRST_SUB_WINDOW = 1000; 2297 2298 /** 2299 * Window type: a panel on top of an application window. These windows 2300 * appear on top of their attached window. 2301 */ 2302 public static final int TYPE_APPLICATION_PANEL = FIRST_SUB_WINDOW; 2303 2304 /** 2305 * Window type: window for showing media (such as video). These windows 2306 * are displayed behind their attached window. 2307 */ 2308 public static final int TYPE_APPLICATION_MEDIA = FIRST_SUB_WINDOW + 1; 2309 2310 /** 2311 * Window type: a sub-panel on top of an application window. These 2312 * windows are displayed on top their attached window and any 2313 * {@link #TYPE_APPLICATION_PANEL} panels. 2314 */ 2315 public static final int TYPE_APPLICATION_SUB_PANEL = FIRST_SUB_WINDOW + 2; 2316 2317 /** Window type: like {@link #TYPE_APPLICATION_PANEL}, but layout 2318 * of the window happens as that of a top-level window, <em>not</em> 2319 * as a child of its container. 2320 */ 2321 public static final int TYPE_APPLICATION_ATTACHED_DIALOG = FIRST_SUB_WINDOW + 3; 2322 2323 /** 2324 * Window type: window for showing overlays on top of media windows. 2325 * These windows are displayed between TYPE_APPLICATION_MEDIA and the 2326 * application window. They should be translucent to be useful. This 2327 * is a big ugly hack so: 2328 * @hide 2329 */ 2330 @UnsupportedAppUsage 2331 public static final int TYPE_APPLICATION_MEDIA_OVERLAY = FIRST_SUB_WINDOW + 4; 2332 2333 /** 2334 * Window type: a above sub-panel on top of an application window and it's 2335 * sub-panel windows. These windows are displayed on top of their attached window 2336 * and any {@link #TYPE_APPLICATION_SUB_PANEL} panels. 2337 * @hide 2338 */ 2339 public static final int TYPE_APPLICATION_ABOVE_SUB_PANEL = FIRST_SUB_WINDOW + 5; 2340 2341 /** 2342 * End of types of sub-windows. 2343 */ 2344 public static final int LAST_SUB_WINDOW = 1999; 2345 2346 /** 2347 * Start of system-specific window types. These are not normally 2348 * created by applications. 2349 */ 2350 public static final int FIRST_SYSTEM_WINDOW = 2000; 2351 2352 /** 2353 * Window type: the status bar. There can be only one status bar 2354 * window; it is placed at the top of the screen, and all other 2355 * windows are shifted down so they are below it. 2356 * In multiuser systems shows on all users' windows. 2357 */ 2358 public static final int TYPE_STATUS_BAR = FIRST_SYSTEM_WINDOW; 2359 2360 /** 2361 * Window type: the search bar. There can be only one search bar 2362 * window; it is placed at the top of the screen. 2363 * In multiuser systems shows on all users' windows. 2364 */ 2365 public static final int TYPE_SEARCH_BAR = FIRST_SYSTEM_WINDOW+1; 2366 2367 /** 2368 * Window type: phone. These are non-application windows providing 2369 * user interaction with the phone (in particular incoming calls). 2370 * These windows are normally placed above all applications, but behind 2371 * the status bar. 2372 * In multiuser systems shows on all users' windows. 2373 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 2374 */ 2375 @Deprecated 2376 public static final int TYPE_PHONE = FIRST_SYSTEM_WINDOW+2; 2377 2378 /** 2379 * Window type: system window, such as low power alert. These windows 2380 * are always on top of application windows. 2381 * In multiuser systems shows only on the owning user's window. 2382 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 2383 */ 2384 @Deprecated 2385 public static final int TYPE_SYSTEM_ALERT = FIRST_SYSTEM_WINDOW+3; 2386 2387 /** 2388 * Window type: keyguard window. 2389 * In multiuser systems shows on all users' windows. 2390 * @removed 2391 */ 2392 public static final int TYPE_KEYGUARD = FIRST_SYSTEM_WINDOW+4; 2393 2394 /** 2395 * Window type: transient notifications. 2396 * In multiuser systems shows only on the owning user's window. 2397 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 2398 */ 2399 @Deprecated 2400 public static final int TYPE_TOAST = FIRST_SYSTEM_WINDOW+5; 2401 2402 /** 2403 * Window type: system overlay windows, which need to be displayed 2404 * on top of everything else. These windows must not take input 2405 * focus, or they will interfere with the keyguard. 2406 * In multiuser systems shows only on the owning user's window. 2407 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 2408 */ 2409 @Deprecated 2410 public static final int TYPE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+6; 2411 2412 /** 2413 * Window type: priority phone UI, which needs to be displayed even if 2414 * the keyguard is active. These windows must not take input 2415 * focus, or they will interfere with the keyguard. 2416 * In multiuser systems shows on all users' windows. 2417 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 2418 */ 2419 @Deprecated 2420 public static final int TYPE_PRIORITY_PHONE = FIRST_SYSTEM_WINDOW+7; 2421 2422 /** 2423 * Window type: panel that slides out from the status bar 2424 * In multiuser systems shows on all users' windows. 2425 */ 2426 public static final int TYPE_SYSTEM_DIALOG = FIRST_SYSTEM_WINDOW+8; 2427 2428 /** 2429 * Window type: dialogs that the keyguard shows 2430 * In multiuser systems shows on all users' windows. 2431 */ 2432 public static final int TYPE_KEYGUARD_DIALOG = FIRST_SYSTEM_WINDOW+9; 2433 2434 /** 2435 * Window type: internal system error windows, appear on top of 2436 * everything they can. 2437 * In multiuser systems shows only on the owning user's window. 2438 * @deprecated for non-system apps. Use {@link #TYPE_APPLICATION_OVERLAY} instead. 2439 */ 2440 @Deprecated 2441 public static final int TYPE_SYSTEM_ERROR = FIRST_SYSTEM_WINDOW+10; 2442 2443 /** 2444 * Window type: internal input methods windows, which appear above 2445 * the normal UI. Application windows may be resized or panned to keep 2446 * the input focus visible while this window is displayed. 2447 * In multiuser systems shows only on the owning user's window. 2448 */ 2449 public static final int TYPE_INPUT_METHOD = FIRST_SYSTEM_WINDOW+11; 2450 2451 /** 2452 * Window type: internal input methods dialog windows, which appear above 2453 * the current input method window. 2454 * In multiuser systems shows only on the owning user's window. 2455 */ 2456 public static final int TYPE_INPUT_METHOD_DIALOG= FIRST_SYSTEM_WINDOW+12; 2457 2458 /** 2459 * Window type: wallpaper window, placed behind any window that wants 2460 * to sit on top of the wallpaper. 2461 * In multiuser systems shows only on the owning user's window. 2462 */ 2463 public static final int TYPE_WALLPAPER = FIRST_SYSTEM_WINDOW+13; 2464 2465 /** 2466 * Window type: panel that slides out from over the status bar 2467 * In multiuser systems shows on all users' windows. 2468 * 2469 * @removed 2470 */ 2471 public static final int TYPE_STATUS_BAR_PANEL = FIRST_SYSTEM_WINDOW+14; 2472 2473 /** 2474 * Window type: secure system overlay windows, which need to be displayed 2475 * on top of everything else. These windows must not take input 2476 * focus, or they will interfere with the keyguard. 2477 * 2478 * This is exactly like {@link #TYPE_SYSTEM_OVERLAY} except that only the 2479 * system itself is allowed to create these overlays. Applications cannot 2480 * obtain permission to create secure system overlays. 2481 * 2482 * In multiuser systems shows only on the owning user's window. 2483 * @hide 2484 */ 2485 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2486 public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15; 2487 2488 /** 2489 * Window type: the drag-and-drop pseudowindow. There is only one 2490 * drag layer (at most), and it is placed on top of all other windows. 2491 * In multiuser systems shows only on the owning user's window. 2492 * @hide 2493 */ 2494 public static final int TYPE_DRAG = FIRST_SYSTEM_WINDOW+16; 2495 2496 /** 2497 * Window type: panel that slides out from over the status bar 2498 * In multiuser systems shows on all users' windows. These windows 2499 * are displayed on top of the status bar and any {@link #TYPE_STATUS_BAR_PANEL} 2500 * windows. 2501 * @hide 2502 */ 2503 public static final int TYPE_STATUS_BAR_SUB_PANEL = FIRST_SYSTEM_WINDOW+17; 2504 2505 /** 2506 * Window type: (mouse) pointer 2507 * In multiuser systems shows on all users' windows. 2508 * @hide 2509 */ 2510 public static final int TYPE_POINTER = FIRST_SYSTEM_WINDOW+18; 2511 2512 /** 2513 * Window type: Navigation bar (when distinct from status bar) 2514 * In multiuser systems shows on all users' windows. 2515 * @hide 2516 */ 2517 public static final int TYPE_NAVIGATION_BAR = FIRST_SYSTEM_WINDOW+19; 2518 2519 /** 2520 * Window type: The volume level overlay/dialog shown when the user 2521 * changes the system volume. 2522 * In multiuser systems shows on all users' windows. 2523 * @hide 2524 */ 2525 public static final int TYPE_VOLUME_OVERLAY = FIRST_SYSTEM_WINDOW+20; 2526 2527 /** 2528 * Window type: The boot progress dialog, goes on top of everything 2529 * in the world. 2530 * In multiuser systems shows on all users' windows. 2531 * @hide 2532 */ 2533 public static final int TYPE_BOOT_PROGRESS = FIRST_SYSTEM_WINDOW+21; 2534 2535 /** 2536 * Window type to consume input events when the systemUI bars are hidden. 2537 * In multiuser systems shows on all users' windows. 2538 * @hide 2539 */ 2540 public static final int TYPE_INPUT_CONSUMER = FIRST_SYSTEM_WINDOW+22; 2541 2542 /** 2543 * Window type: Navigation bar panel (when navigation bar is distinct from status bar) 2544 * In multiuser systems shows on all users' windows. 2545 * @hide 2546 */ 2547 public static final int TYPE_NAVIGATION_BAR_PANEL = FIRST_SYSTEM_WINDOW+24; 2548 2549 /** 2550 * Window type: Display overlay window. Used to simulate secondary display devices. 2551 * In multiuser systems shows on all users' windows. 2552 * @hide 2553 */ 2554 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 2555 public static final int TYPE_DISPLAY_OVERLAY = FIRST_SYSTEM_WINDOW+26; 2556 2557 /** 2558 * Window type: Magnification overlay window. Used to highlight the magnified 2559 * portion of a display when accessibility magnification is enabled. 2560 * In multiuser systems shows on all users' windows. 2561 * @hide 2562 */ 2563 public static final int TYPE_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW+27; 2564 2565 /** 2566 * Window type: Window for Presentation on top of private 2567 * virtual display. 2568 */ 2569 public static final int TYPE_PRIVATE_PRESENTATION = FIRST_SYSTEM_WINDOW+30; 2570 2571 /** 2572 * Window type: Windows in the voice interaction layer. 2573 * @hide 2574 */ 2575 public static final int TYPE_VOICE_INTERACTION = FIRST_SYSTEM_WINDOW+31; 2576 2577 /** 2578 * Window type: Windows that are overlaid <em>only</em> by a connected {@link 2579 * android.accessibilityservice.AccessibilityService} for interception of 2580 * user interactions without changing the windows an accessibility service 2581 * can introspect. In particular, an accessibility service can introspect 2582 * only windows that a sighted user can interact with which is they can touch 2583 * these windows or can type into these windows. For example, if there 2584 * is a full screen accessibility overlay that is touchable, the windows 2585 * below it will be introspectable by an accessibility service even though 2586 * they are covered by a touchable window. 2587 */ 2588 public static final int TYPE_ACCESSIBILITY_OVERLAY = FIRST_SYSTEM_WINDOW+32; 2589 2590 /** 2591 * Window type: Starting window for voice interaction layer. 2592 * @hide 2593 */ 2594 public static final int TYPE_VOICE_INTERACTION_STARTING = FIRST_SYSTEM_WINDOW+33; 2595 2596 /** 2597 * Window for displaying a handle used for resizing docked stacks. This window is owned 2598 * by the system process. 2599 * @hide 2600 */ 2601 public static final int TYPE_DOCK_DIVIDER = FIRST_SYSTEM_WINDOW+34; 2602 2603 /** 2604 * Window type: like {@link #TYPE_APPLICATION_ATTACHED_DIALOG}, but used 2605 * by Quick Settings Tiles. 2606 * @hide 2607 */ 2608 public static final int TYPE_QS_DIALOG = FIRST_SYSTEM_WINDOW+35; 2609 2610 /** 2611 * Window type: shows directly above the keyguard. The layer is 2612 * reserved for screenshot animation, region selection and UI. 2613 * In multiuser systems shows only on the owning user's window. 2614 * @hide 2615 */ 2616 public static final int TYPE_SCREENSHOT = FIRST_SYSTEM_WINDOW + 36; 2617 2618 /** 2619 * Window type: Window for Presentation on an external display. 2620 * @see android.app.Presentation 2621 * @hide 2622 */ 2623 public static final int TYPE_PRESENTATION = FIRST_SYSTEM_WINDOW + 37; 2624 2625 /** 2626 * Window type: Application overlay windows are displayed above all activity windows 2627 * (types between {@link #FIRST_APPLICATION_WINDOW} and {@link #LAST_APPLICATION_WINDOW}) 2628 * but below critical system windows like the status bar or IME. 2629 * <p> 2630 * The system may change the position, size, or visibility of these windows at anytime 2631 * to reduce visual clutter to the user and also manage resources. 2632 * <p> 2633 * Requires {@link android.Manifest.permission#SYSTEM_ALERT_WINDOW} permission. 2634 * <p> 2635 * The system will adjust the importance of processes with this window type to reduce the 2636 * chance of the low-memory-killer killing them. 2637 * <p> 2638 * In multi-user systems shows only on the owning user's screen. 2639 */ 2640 public static final int TYPE_APPLICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 38; 2641 2642 /** 2643 * Window type: Window for adding accessibility window magnification above other windows. 2644 * This will place the window in the overlay windows. 2645 * @hide 2646 */ 2647 public static final int TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY = FIRST_SYSTEM_WINDOW + 39; 2648 2649 /** 2650 * Window type: the notification shade and keyguard. There can be only one status bar 2651 * window; it is placed at the top of the screen, and all other 2652 * windows are shifted down so they are below it. 2653 * In multiuser systems shows on all users' windows. 2654 * @hide 2655 */ 2656 public static final int TYPE_NOTIFICATION_SHADE = FIRST_SYSTEM_WINDOW + 40; 2657 2658 /** 2659 * Window type: used to show the status bar in non conventional parts of the screen (i.e. 2660 * the left or the bottom of the screen). 2661 * In multiuser systems shows on all users' windows. 2662 * @hide 2663 */ 2664 public static final int TYPE_STATUS_BAR_ADDITIONAL = FIRST_SYSTEM_WINDOW + 41; 2665 2666 /** 2667 * End of types of system windows. 2668 */ 2669 public static final int LAST_SYSTEM_WINDOW = 2999; 2670 2671 /** 2672 * @hide 2673 * Used internally when there is no suitable type available. 2674 */ 2675 public static final int INVALID_WINDOW_TYPE = -1; 2676 2677 /** 2678 * @hide 2679 */ 2680 @IntDef(prefix = "TYPE_", value = { 2681 TYPE_BASE_APPLICATION, 2682 TYPE_APPLICATION, 2683 TYPE_APPLICATION_STARTING, 2684 TYPE_DRAWN_APPLICATION, 2685 TYPE_APPLICATION_PANEL, 2686 TYPE_APPLICATION_MEDIA, 2687 TYPE_APPLICATION_SUB_PANEL, 2688 TYPE_APPLICATION_ATTACHED_DIALOG, 2689 TYPE_APPLICATION_MEDIA_OVERLAY, 2690 TYPE_APPLICATION_ABOVE_SUB_PANEL, 2691 TYPE_STATUS_BAR, 2692 TYPE_SEARCH_BAR, 2693 TYPE_PHONE, 2694 TYPE_SYSTEM_ALERT, 2695 TYPE_KEYGUARD, 2696 TYPE_TOAST, 2697 TYPE_SYSTEM_OVERLAY, 2698 TYPE_PRIORITY_PHONE, 2699 TYPE_SYSTEM_DIALOG, 2700 TYPE_KEYGUARD_DIALOG, 2701 TYPE_SYSTEM_ERROR, 2702 TYPE_INPUT_METHOD, 2703 TYPE_INPUT_METHOD_DIALOG, 2704 TYPE_WALLPAPER, 2705 TYPE_STATUS_BAR_PANEL, 2706 TYPE_SECURE_SYSTEM_OVERLAY, 2707 TYPE_DRAG, 2708 TYPE_STATUS_BAR_SUB_PANEL, 2709 TYPE_POINTER, 2710 TYPE_NAVIGATION_BAR, 2711 TYPE_VOLUME_OVERLAY, 2712 TYPE_BOOT_PROGRESS, 2713 TYPE_INPUT_CONSUMER, 2714 TYPE_NAVIGATION_BAR_PANEL, 2715 TYPE_DISPLAY_OVERLAY, 2716 TYPE_MAGNIFICATION_OVERLAY, 2717 TYPE_PRIVATE_PRESENTATION, 2718 TYPE_VOICE_INTERACTION, 2719 TYPE_ACCESSIBILITY_OVERLAY, 2720 TYPE_VOICE_INTERACTION_STARTING, 2721 TYPE_DOCK_DIVIDER, 2722 TYPE_QS_DIALOG, 2723 TYPE_SCREENSHOT, 2724 TYPE_PRESENTATION, 2725 TYPE_APPLICATION_OVERLAY, 2726 TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY, 2727 TYPE_NOTIFICATION_SHADE, 2728 TYPE_STATUS_BAR_ADDITIONAL 2729 }) 2730 @Retention(RetentionPolicy.SOURCE) 2731 public @interface WindowType {} 2732 2733 /** 2734 * Return true if the window type is an alert window. 2735 * 2736 * @param type The window type. 2737 * @return If the window type is an alert window. 2738 * @hide 2739 */ isSystemAlertWindowType(@indowType int type)2740 public static boolean isSystemAlertWindowType(@WindowType int type) { 2741 switch (type) { 2742 case TYPE_PHONE: 2743 case TYPE_PRIORITY_PHONE: 2744 case TYPE_SYSTEM_ALERT: 2745 case TYPE_SYSTEM_ERROR: 2746 case TYPE_SYSTEM_OVERLAY: 2747 case TYPE_APPLICATION_OVERLAY: 2748 return true; 2749 } 2750 return false; 2751 } 2752 2753 /** @deprecated this is ignored, this value is set automatically when needed. */ 2754 @Deprecated 2755 public static final int MEMORY_TYPE_NORMAL = 0; 2756 /** @deprecated this is ignored, this value is set automatically when needed. */ 2757 @Deprecated 2758 public static final int MEMORY_TYPE_HARDWARE = 1; 2759 /** @deprecated this is ignored, this value is set automatically when needed. */ 2760 @Deprecated 2761 public static final int MEMORY_TYPE_GPU = 2; 2762 /** @deprecated this is ignored, this value is set automatically when needed. */ 2763 @Deprecated 2764 public static final int MEMORY_TYPE_PUSH_BUFFERS = 3; 2765 2766 /** 2767 * @deprecated this is ignored 2768 */ 2769 @Deprecated 2770 public int memoryType; 2771 2772 /** Window flag: as long as this window is visible to the user, allow 2773 * the lock screen to activate while the screen is on. 2774 * This can be used independently, or in combination with 2775 * {@link #FLAG_KEEP_SCREEN_ON} and/or {@link #FLAG_SHOW_WHEN_LOCKED} */ 2776 public static final int FLAG_ALLOW_LOCK_WHILE_SCREEN_ON = 0x00000001; 2777 2778 /** Window flag: everything behind this window will be dimmed. 2779 * Use {@link #dimAmount} to control the amount of dim. */ 2780 public static final int FLAG_DIM_BEHIND = 0x00000002; 2781 2782 /** Window flag: enable blur behind for this window. */ 2783 public static final int FLAG_BLUR_BEHIND = 0x00000004; 2784 2785 /** Window flag: this window won't ever get key input focus, so the 2786 * user can not send key or other button events to it. Those will 2787 * instead go to whatever focusable window is behind it. This flag 2788 * will also enable {@link #FLAG_NOT_TOUCH_MODAL} whether or not that 2789 * is explicitly set. 2790 * 2791 * <p>Setting this flag also implies that the window will not need to 2792 * interact with 2793 * a soft input method, so it will be Z-ordered and positioned 2794 * independently of any active input method (typically this means it 2795 * gets Z-ordered on top of the input method, so it can use the full 2796 * screen for its content and cover the input method if needed. You 2797 * can use {@link #FLAG_ALT_FOCUSABLE_IM} to modify this behavior. */ 2798 public static final int FLAG_NOT_FOCUSABLE = 0x00000008; 2799 2800 /** 2801 * Window flag: this window can never receive touch events. 2802 * 2803 * <p>The intention of this flag is to leave the touch to be handled by some window below 2804 * this window (in Z order). 2805 * 2806 * <p>Starting from Android {@link Build.VERSION_CODES#S}, for security reasons, touch 2807 * events that pass through windows containing this flag (ie. are within the bounds of the 2808 * window) will only be delivered to the touch-consuming window if one (or more) of the 2809 * items below are true: 2810 * <ol> 2811 * <li><b>Same UID</b>: This window belongs to the same UID that owns the touch-consuming 2812 * window. 2813 * <li><b>Trusted windows</b>: This window is trusted. Trusted windows include (but are 2814 * not limited to) accessibility windows ({@link #TYPE_ACCESSIBILITY_OVERLAY}), the IME 2815 * ({@link #TYPE_INPUT_METHOD}) and assistant windows (TYPE_VOICE_INTERACTION). Windows of 2816 * type {@link #TYPE_APPLICATION_OVERLAY} are <b>not</b> trusted, see below. 2817 * <li><b>Invisible windows</b>: This window is {@link View#GONE} or 2818 * {@link View#INVISIBLE}. 2819 * <li><b>Fully transparent windows</b>: This window has {@link LayoutParams#alpha} equal 2820 * to 0. 2821 * <li><b>One SAW window with enough transparency</b>: This window is of type {@link 2822 * #TYPE_APPLICATION_OVERLAY}, has {@link LayoutParams#alpha} below or equal to the 2823 * <a href="#MaximumOpacity">maximum obscuring opacity</a> (see below) and it's the 2824 * <b>only</b> window of type {@link #TYPE_APPLICATION_OVERLAY} from this UID in the touch 2825 * path. 2826 * <li><b>Multiple SAW windows with enough transparency</b>: The multiple overlapping 2827 * {@link #TYPE_APPLICATION_OVERLAY} windows in the 2828 * touch path from this UID have a <b>combined obscuring opacity</b> below or equal to 2829 * the <a href="#MaximumOpacity">maximum obscuring opacity</a>. See section 2830 * <a href="#ObscuringOpacity">Combined obscuring opacity</a> below on how to compute this 2831 * value. 2832 * </ol> 2833 * <p>If none of these cases hold, the touch will not be delivered and a message will be 2834 * logged to logcat.</p> 2835 * 2836 * <a name="MaximumOpacity"></a> 2837 * <h3>Maximum obscuring opacity</h3> 2838 * <p>This value is <b>0.8</b>. Apps that want to gather this value from the system rather 2839 * than hard-coding it might want to use {@link 2840 * android.hardware.input.InputManager#getMaximumObscuringOpacityForTouch()}.</p> 2841 * 2842 * <a name="ObscuringOpacity"></a> 2843 * <h3>Combined obscuring opacity</h3> 2844 * 2845 * <p>The <b>combined obscuring opacity</b> of a set of windows is obtained by combining the 2846 * opacity values of all windows in the set using the associative and commutative operation 2847 * defined as: 2848 * <pre> 2849 * opacity({A,B}) = 1 - (1 - opacity(A))*(1 - opacity(B)) 2850 * </pre> 2851 * <p>where {@code opacity(X)} is the {@link LayoutParams#alpha} of window X. So, for a set 2852 * of windows {@code {W1, .., Wn}}, the combined obscuring opacity will be: 2853 * <pre> 2854 * opacity({W1, .., Wn}) = 1 - (1 - opacity(W1)) * ... * (1 - opacity(Wn)) 2855 * </pre> 2856 */ 2857 public static final int FLAG_NOT_TOUCHABLE = 0x00000010; 2858 2859 /** Window flag: even when this window is focusable (its 2860 * {@link #FLAG_NOT_FOCUSABLE} is not set), allow any pointer events 2861 * outside of the window to be sent to the windows behind it. Otherwise 2862 * it will consume all pointer events itself, regardless of whether they 2863 * are inside of the window. */ 2864 public static final int FLAG_NOT_TOUCH_MODAL = 0x00000020; 2865 2866 /** Window flag: when set, if the device is asleep when the touch 2867 * screen is pressed, you will receive this first touch event. Usually 2868 * the first touch event is consumed by the system since the user can 2869 * not see what they are pressing on. 2870 * 2871 * @deprecated This flag has no effect. 2872 */ 2873 @Deprecated 2874 public static final int FLAG_TOUCHABLE_WHEN_WAKING = 0x00000040; 2875 2876 /** Window flag: as long as this window is visible to the user, keep 2877 * the device's screen turned on and bright. */ 2878 public static final int FLAG_KEEP_SCREEN_ON = 0x00000080; 2879 2880 /** 2881 * Window flag for attached windows: Place the window within the entire screen, ignoring 2882 * any constraints from the parent window. 2883 * 2884 * <p>Note: on displays that have a {@link DisplayCutout}, the window may be placed 2885 * such that it avoids the {@link DisplayCutout} area if necessary according to the 2886 * {@link #layoutInDisplayCutoutMode}. 2887 */ 2888 public static final int FLAG_LAYOUT_IN_SCREEN = 0x00000100; 2889 2890 /** Window flag: allow window to extend outside of the screen. */ 2891 public static final int FLAG_LAYOUT_NO_LIMITS = 0x00000200; 2892 2893 /** 2894 * Window flag: hide all screen decorations (such as the status bar) while 2895 * this window is displayed. This allows the window to use the entire 2896 * display space for itself -- the status bar will be hidden when 2897 * an app window with this flag set is on the top layer. A fullscreen window 2898 * will ignore a value of {@link #SOFT_INPUT_ADJUST_RESIZE} for the window's 2899 * {@link #softInputMode} field; the window will stay fullscreen 2900 * and will not resize. 2901 * 2902 * <p>This flag can be controlled in your theme through the 2903 * {@link android.R.attr#windowFullscreen} attribute; this attribute 2904 * is automatically set for you in the standard fullscreen themes 2905 * such as {@link android.R.style#Theme_NoTitleBar_Fullscreen}, 2906 * {@link android.R.style#Theme_Black_NoTitleBar_Fullscreen}, 2907 * {@link android.R.style#Theme_Light_NoTitleBar_Fullscreen}, 2908 * {@link android.R.style#Theme_Holo_NoActionBar_Fullscreen}, 2909 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Fullscreen}, 2910 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Fullscreen}, and 2911 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Fullscreen}.</p> 2912 * 2913 * @deprecated Use {@link WindowInsetsController#hide(int)} with {@link Type#statusBars()} 2914 * instead. 2915 */ 2916 @Deprecated 2917 public static final int FLAG_FULLSCREEN = 0x00000400; 2918 2919 /** 2920 * Window flag: override {@link #FLAG_FULLSCREEN} and force the 2921 * screen decorations (such as the status bar) to be shown. 2922 * 2923 * @deprecated This value became API "by accident", and shouldn't be used by 3rd party 2924 * applications. 2925 */ 2926 @Deprecated 2927 public static final int FLAG_FORCE_NOT_FULLSCREEN = 0x00000800; 2928 2929 /** Window flag: turn on dithering when compositing this window to 2930 * the screen. 2931 * @deprecated This flag is no longer used. */ 2932 @Deprecated 2933 public static final int FLAG_DITHER = 0x00001000; 2934 2935 /** Window flag: treat the content of the window as secure, preventing 2936 * it from appearing in screenshots or from being viewed on non-secure 2937 * displays. 2938 * 2939 * <p>See {@link android.view.View#setContentSensitivity(int)}, a window hosting 2940 * a sensitive view will be marked as secure during media projection, preventing 2941 * it from being viewed on non-secure displays and during screen share. 2942 * 2943 * <p>See {@link android.view.Display#FLAG_SECURE} for more details about 2944 * secure surfaces and secure displays. 2945 */ 2946 public static final int FLAG_SECURE = 0x00002000; 2947 2948 /** Window flag: a special mode where the layout parameters are used 2949 * to perform scaling of the surface when it is composited to the 2950 * screen. */ 2951 public static final int FLAG_SCALED = 0x00004000; 2952 2953 /** Window flag: intended for windows that will often be used when the user is 2954 * holding the screen against their face, it will aggressively filter the event 2955 * stream to prevent unintended presses in this situation that may not be 2956 * desired for a particular window, when such an event stream is detected, the 2957 * application will receive a CANCEL motion event to indicate this so applications 2958 * can handle this accordingly by taking no action on the event 2959 * until the finger is released. */ 2960 public static final int FLAG_IGNORE_CHEEK_PRESSES = 0x00008000; 2961 2962 /** 2963 * Window flag: a special option only for use in combination with 2964 * {@link #FLAG_LAYOUT_IN_SCREEN}. When requesting layout in the 2965 * screen your window may appear on top of or behind screen decorations 2966 * such as the status bar. By also including this flag, the window 2967 * manager will report the inset rectangle needed to ensure your 2968 * content is not covered by screen decorations. This flag is normally 2969 * set for you by Window as described in {@link Window#setFlags} 2970 * 2971 * @deprecated Insets will always be delivered to your application. 2972 */ 2973 @Deprecated 2974 public static final int FLAG_LAYOUT_INSET_DECOR = 0x00010000; 2975 2976 /** Window flag: when set, inverts the input method focusability of the window. 2977 * 2978 * The effect of setting this flag depends on whether {@link #FLAG_NOT_FOCUSABLE} is set: 2979 * <p> 2980 * If {@link #FLAG_NOT_FOCUSABLE} is <em>not</em> set, i.e. when the window is focusable, 2981 * setting this flag prevents this window from becoming the target of the input method. 2982 * Consequently, it will <em>not</em> be able to interact with the input method, 2983 * and will be layered above the input method (unless there is another input method 2984 * target above it). 2985 * 2986 * <p> 2987 * If {@link #FLAG_NOT_FOCUSABLE} <em>is</em> set, setting this flag requests for the window 2988 * to be the input method target even though the window is <em>not</em> focusable. 2989 * Consequently, it will be layered below the input method. 2990 * Note: Windows that set {@link #FLAG_NOT_FOCUSABLE} cannot interact with the input method, 2991 * regardless of this flag. 2992 */ 2993 public static final int FLAG_ALT_FOCUSABLE_IM = 0x00020000; 2994 2995 /** Window flag: if you have set {@link #FLAG_NOT_TOUCH_MODAL}, you 2996 * can set this flag to receive a single special MotionEvent with 2997 * the action 2998 * {@link MotionEvent#ACTION_OUTSIDE MotionEvent.ACTION_OUTSIDE} for 2999 * touches that occur outside of your window. Note that you will not 3000 * receive the full down/move/up gesture, only the location of the 3001 * first down as an ACTION_OUTSIDE. 3002 */ 3003 public static final int FLAG_WATCH_OUTSIDE_TOUCH = 0x00040000; 3004 3005 /** Window flag: special flag to let windows be shown when the screen 3006 * is locked. This will let application windows take precedence over 3007 * key guard or any other lock screens. Can be used with 3008 * {@link #FLAG_KEEP_SCREEN_ON} to turn screen on and display windows 3009 * directly before showing the key guard window. Can be used with 3010 * {@link #FLAG_DISMISS_KEYGUARD} to automatically fully dismisss 3011 * non-secure keyguards. This flag only applies to the top-most 3012 * full-screen window. 3013 * @deprecated Use {@link android.R.attr#showWhenLocked} or 3014 * {@link android.app.Activity#setShowWhenLocked(boolean)} instead to prevent an 3015 * unintentional double life-cycle event. 3016 */ 3017 @Deprecated 3018 public static final int FLAG_SHOW_WHEN_LOCKED = 0x00080000; 3019 3020 /** Window flag: ask that the system wallpaper be shown behind 3021 * your window. The window surface must be translucent to be able 3022 * to actually see the wallpaper behind it; this flag just ensures 3023 * that the wallpaper surface will be there if this window actually 3024 * has translucent regions. 3025 * 3026 * <p>This flag can be controlled in your theme through the 3027 * {@link android.R.attr#windowShowWallpaper} attribute; this attribute 3028 * is automatically set for you in the standard wallpaper themes 3029 * such as {@link android.R.style#Theme_Wallpaper}, 3030 * {@link android.R.style#Theme_Wallpaper_NoTitleBar}, 3031 * {@link android.R.style#Theme_Wallpaper_NoTitleBar_Fullscreen}, 3032 * {@link android.R.style#Theme_Holo_Wallpaper}, 3033 * {@link android.R.style#Theme_Holo_Wallpaper_NoTitleBar}, 3034 * {@link android.R.style#Theme_DeviceDefault_Wallpaper}, and 3035 * {@link android.R.style#Theme_DeviceDefault_Wallpaper_NoTitleBar}.</p> 3036 * 3037 * <p> When this flag is set, all touch events sent to this window is also sent to the 3038 * wallpaper, which is used to interact with live wallpapers. Check 3039 * {@link LayoutParams#areWallpaperTouchEventsEnabled()}, which is set to {@code true} 3040 * by default. When showing sensitive information on the window, if you want to disable 3041 * sending the touch events to the wallpaper, use 3042 * {@link LayoutParams#setWallpaperTouchEventsEnabled(boolean)}.</p> 3043 */ 3044 public static final int FLAG_SHOW_WALLPAPER = 0x00100000; 3045 3046 /** Window flag: when set as a window is being added or made 3047 * visible, once the window has been shown then the system will 3048 * poke the power manager's user activity (as if the user had woken 3049 * up the device) to turn the screen on. 3050 * @deprecated Use {@link android.R.attr#turnScreenOn} or 3051 * {@link android.app.Activity#setTurnScreenOn(boolean)} instead to prevent an 3052 * unintentional double life-cycle event. 3053 */ 3054 @Deprecated 3055 public static final int FLAG_TURN_SCREEN_ON = 0x00200000; 3056 3057 /** 3058 * Window flag: when set the window will cause the keyguard to be 3059 * dismissed, only if it is not a secure lock keyguard. Because such a 3060 * keyguard is not needed for security, it will never re-appear if the 3061 * user navigates to another window (in contrast to 3062 * {@link #FLAG_SHOW_WHEN_LOCKED}, which will only temporarily hide both 3063 * secure and non-secure keyguards but ensure they reappear when the 3064 * user moves to another UI that doesn't hide them). If the keyguard is 3065 * currently active and is secure (requires an unlock credential) than 3066 * the user will still need to confirm it before seeing this window, 3067 * unless {@link #FLAG_SHOW_WHEN_LOCKED} has also been set. 3068 * 3069 * @deprecated Use {@link #FLAG_SHOW_WHEN_LOCKED} or 3070 * {@link KeyguardManager#requestDismissKeyguard} instead. 3071 * Since keyguard was dismissed all the time as long as an 3072 * activity with this flag on its window was focused, 3073 * keyguard couldn't guard against unintentional touches on 3074 * the screen, which isn't desired. 3075 */ 3076 @Deprecated 3077 public static final int FLAG_DISMISS_KEYGUARD = 0x00400000; 3078 3079 /** Window flag: when set the window will accept for touch events 3080 * outside of its bounds to be sent to other windows that also 3081 * support split touch. When this flag is not set, the first pointer 3082 * that goes down determines the window to which all subsequent touches 3083 * go until all pointers go up. When this flag is set, each pointer 3084 * (not necessarily the first) that goes down determines the window 3085 * to which all subsequent touches of that pointer will go until that 3086 * pointer goes up thereby enabling touches with multiple pointers 3087 * to be split across multiple windows. 3088 */ 3089 public static final int FLAG_SPLIT_TOUCH = 0x00800000; 3090 3091 /** 3092 * <p>Indicates whether this window should be hardware accelerated. 3093 * Requesting hardware acceleration does not guarantee it will happen.</p> 3094 * 3095 * <p>This flag can be controlled programmatically <em>only</em> to enable 3096 * hardware acceleration. To enable hardware acceleration for a given 3097 * window programmatically, do the following:</p> 3098 * 3099 * <pre> 3100 * Window w = activity.getWindow(); // in Activity's onCreate() for instance 3101 * w.setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, 3102 * WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); 3103 * </pre> 3104 * 3105 * <p>It is important to remember that this flag <strong>must</strong> 3106 * be set before setting the content view of your activity or dialog.</p> 3107 * 3108 * <p>This flag cannot be used to disable hardware acceleration after it 3109 * was enabled in your manifest using 3110 * {@link android.R.attr#hardwareAccelerated}. If you need to selectively 3111 * and programmatically disable hardware acceleration (for automated testing 3112 * for instance), make sure it is turned off in your manifest and enable it 3113 * on your activity or dialog when you need it instead, using the method 3114 * described above.</p> 3115 * 3116 * <p>This flag is automatically set by the system if the 3117 * {@link android.R.attr#hardwareAccelerated android:hardwareAccelerated} 3118 * XML attribute is set to true on an activity or on the application.</p> 3119 */ 3120 public static final int FLAG_HARDWARE_ACCELERATED = 0x01000000; 3121 3122 /** 3123 * Window flag: allow window contents to extend in to the screen's 3124 * overscan area, if there is one. The window should still correctly 3125 * position its contents to take the overscan area into account. 3126 * 3127 * <p>This flag can be controlled in your theme through the 3128 * {@link android.R.attr#windowOverscan} attribute; this attribute 3129 * is automatically set for you in the standard overscan themes 3130 * such as 3131 * {@link android.R.style#Theme_Holo_NoActionBar_Overscan}, 3132 * {@link android.R.style#Theme_Holo_Light_NoActionBar_Overscan}, 3133 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_Overscan}, and 3134 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_Overscan}.</p> 3135 * 3136 * <p>When this flag is enabled for a window, its normal content may be obscured 3137 * to some degree by the overscan region of the display. To ensure key parts of 3138 * that content are visible to the user, you can use 3139 * {@link View#setFitsSystemWindows(boolean) View.setFitsSystemWindows(boolean)} 3140 * to set the point in the view hierarchy where the appropriate offsets should 3141 * be applied. (This can be done either by directly calling this function, using 3142 * the {@link android.R.attr#fitsSystemWindows} attribute in your view hierarchy, 3143 * or implementing you own {@link View#fitSystemWindows(android.graphics.Rect) 3144 * View.fitSystemWindows(Rect)} method).</p> 3145 * 3146 * <p>This mechanism for positioning content elements is identical to its equivalent 3147 * use with layout and {@link View#setSystemUiVisibility(int) 3148 * View.setSystemUiVisibility(int)}; here is an example layout that will correctly 3149 * position its UI elements with this overscan flag is set:</p> 3150 * 3151 * {@sample development/samples/ApiDemos/res/layout/overscan_activity.xml complete} 3152 * 3153 * @deprecated Overscan areas aren't set by any Android product anymore as of Android 11. 3154 */ 3155 @Deprecated 3156 public static final int FLAG_LAYOUT_IN_OVERSCAN = 0x02000000; 3157 3158 /** 3159 * Window flag: request a translucent status bar with minimal system-provided 3160 * background protection. 3161 * 3162 * <p>This flag can be controlled in your theme through the 3163 * {@link android.R.attr#windowTranslucentStatus} attribute; this attribute 3164 * is automatically set for you in the standard translucent decor themes 3165 * such as 3166 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 3167 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 3168 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 3169 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 3170 * 3171 * <p>When this flag is enabled for a window, it automatically sets 3172 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 3173 * {@link View#SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN}.</p> 3174 * 3175 * <p>Note: For devices that support 3176 * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE} this flag may be ignored. 3177 * 3178 * @deprecated Use {@link Window#setStatusBarColor(int)} with a half-translucent color 3179 * instead. 3180 */ 3181 @Deprecated 3182 public static final int FLAG_TRANSLUCENT_STATUS = 0x04000000; 3183 3184 /** 3185 * Window flag: request a translucent navigation bar with minimal system-provided 3186 * background protection. 3187 * 3188 * <p>This flag can be controlled in your theme through the 3189 * {@link android.R.attr#windowTranslucentNavigation} attribute; this attribute 3190 * is automatically set for you in the standard translucent decor themes 3191 * such as 3192 * {@link android.R.style#Theme_Holo_NoActionBar_TranslucentDecor}, 3193 * {@link android.R.style#Theme_Holo_Light_NoActionBar_TranslucentDecor}, 3194 * {@link android.R.style#Theme_DeviceDefault_NoActionBar_TranslucentDecor}, and 3195 * {@link android.R.style#Theme_DeviceDefault_Light_NoActionBar_TranslucentDecor}.</p> 3196 * 3197 * <p>When this flag is enabled for a window, it automatically sets 3198 * the system UI visibility flags {@link View#SYSTEM_UI_FLAG_LAYOUT_STABLE} and 3199 * {@link View#SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION}.</p> 3200 * 3201 * <p>Note: For devices that support 3202 * {@link android.content.pm.PackageManager#FEATURE_AUTOMOTIVE} this flag can be disabled 3203 * by the car manufacturers. 3204 * 3205 * @deprecated Use {@link Window#setNavigationBarColor(int)} with a half-translucent color 3206 * instead. 3207 */ 3208 @Deprecated 3209 public static final int FLAG_TRANSLUCENT_NAVIGATION = 0x08000000; 3210 3211 /** 3212 * Flag for a window in local focus mode. 3213 * Window in local focus mode can control focus independent of window manager using 3214 * {@link Window#setLocalFocus(boolean, boolean)}. 3215 * Usually window in this mode will not get touch/key events from window manager, but will 3216 * get events only via local injection using {@link Window#injectInputEvent(InputEvent)}. 3217 */ 3218 public static final int FLAG_LOCAL_FOCUS_MODE = 0x10000000; 3219 3220 /** Window flag: Enable touches to slide out of a window into neighboring 3221 * windows in mid-gesture instead of being captured for the duration of 3222 * the gesture. 3223 * 3224 * This flag changes the behavior of touch focus for this window only. 3225 * Touches can slide out of the window but they cannot necessarily slide 3226 * back in (unless the other window with touch focus permits it). 3227 * 3228 * {@hide} 3229 */ 3230 @UnsupportedAppUsage 3231 @TestApi 3232 public static final int FLAG_SLIPPERY = 0x20000000; 3233 3234 /** 3235 * Window flag: When requesting layout with an attached window, the attached window may 3236 * overlap with the screen decorations of the parent window such as the navigation bar. By 3237 * including this flag, the window manager will layout the attached window within the decor 3238 * frame of the parent window such that it doesn't overlap with screen decorations. 3239 * 3240 * @deprecated Use {@link #setFitInsetsTypes(int)} to determine whether the attached 3241 * window will overlap with system bars. 3242 */ 3243 @Deprecated 3244 public static final int FLAG_LAYOUT_ATTACHED_IN_DECOR = 0x40000000; 3245 3246 /** 3247 * Flag indicating that this Window is responsible for drawing the background for the 3248 * system bars. If set, the system bars are drawn with a transparent background and the 3249 * corresponding areas in this window are filled with the colors specified in 3250 * {@link Window#getStatusBarColor()} and {@link Window#getNavigationBarColor()}. 3251 */ 3252 public static final int FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS = 0x80000000; 3253 3254 /** 3255 * @hide 3256 */ 3257 @IntDef(flag = true, prefix = "FLAG_", value = { 3258 FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 3259 FLAG_DIM_BEHIND, 3260 FLAG_BLUR_BEHIND, 3261 FLAG_NOT_FOCUSABLE, 3262 FLAG_NOT_TOUCHABLE, 3263 FLAG_NOT_TOUCH_MODAL, 3264 FLAG_TOUCHABLE_WHEN_WAKING, 3265 FLAG_KEEP_SCREEN_ON, 3266 FLAG_LAYOUT_IN_SCREEN, 3267 FLAG_LAYOUT_NO_LIMITS, 3268 FLAG_FULLSCREEN, 3269 FLAG_FORCE_NOT_FULLSCREEN, 3270 FLAG_DITHER, 3271 FLAG_SECURE, 3272 FLAG_SCALED, 3273 FLAG_IGNORE_CHEEK_PRESSES, 3274 FLAG_LAYOUT_INSET_DECOR, 3275 FLAG_ALT_FOCUSABLE_IM, 3276 FLAG_WATCH_OUTSIDE_TOUCH, 3277 FLAG_SHOW_WHEN_LOCKED, 3278 FLAG_SHOW_WALLPAPER, 3279 FLAG_TURN_SCREEN_ON, 3280 FLAG_DISMISS_KEYGUARD, 3281 FLAG_SPLIT_TOUCH, 3282 FLAG_HARDWARE_ACCELERATED, 3283 FLAG_LAYOUT_IN_OVERSCAN, 3284 FLAG_TRANSLUCENT_STATUS, 3285 FLAG_TRANSLUCENT_NAVIGATION, 3286 FLAG_LOCAL_FOCUS_MODE, 3287 FLAG_SLIPPERY, 3288 FLAG_LAYOUT_ATTACHED_IN_DECOR, 3289 FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, 3290 }) 3291 @Retention(RetentionPolicy.SOURCE) 3292 public @interface Flags {} 3293 3294 /** 3295 * Various behavioral options/flags. Default is none. 3296 * 3297 * @see #FLAG_ALLOW_LOCK_WHILE_SCREEN_ON 3298 * @see #FLAG_DIM_BEHIND 3299 * @see #FLAG_NOT_FOCUSABLE 3300 * @see #FLAG_NOT_TOUCHABLE 3301 * @see #FLAG_NOT_TOUCH_MODAL 3302 * @see #FLAG_TOUCHABLE_WHEN_WAKING 3303 * @see #FLAG_KEEP_SCREEN_ON 3304 * @see #FLAG_LAYOUT_IN_SCREEN 3305 * @see #FLAG_LAYOUT_NO_LIMITS 3306 * @see #FLAG_FULLSCREEN 3307 * @see #FLAG_FORCE_NOT_FULLSCREEN 3308 * @see #FLAG_SECURE 3309 * @see #FLAG_SCALED 3310 * @see #FLAG_IGNORE_CHEEK_PRESSES 3311 * @see #FLAG_LAYOUT_INSET_DECOR 3312 * @see #FLAG_ALT_FOCUSABLE_IM 3313 * @see #FLAG_WATCH_OUTSIDE_TOUCH 3314 * @see #FLAG_SHOW_WHEN_LOCKED 3315 * @see #FLAG_SHOW_WALLPAPER 3316 * @see #FLAG_TURN_SCREEN_ON 3317 * @see #FLAG_DISMISS_KEYGUARD 3318 * @see #FLAG_SPLIT_TOUCH 3319 * @see #FLAG_HARDWARE_ACCELERATED 3320 * @see #FLAG_LOCAL_FOCUS_MODE 3321 * @see #FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 3322 */ 3323 @ViewDebug.ExportedProperty(flagMapping = { 3324 @ViewDebug.FlagToString(mask = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, equals = FLAG_ALLOW_LOCK_WHILE_SCREEN_ON, 3325 name = "ALLOW_LOCK_WHILE_SCREEN_ON"), 3326 @ViewDebug.FlagToString(mask = FLAG_DIM_BEHIND, equals = FLAG_DIM_BEHIND, 3327 name = "DIM_BEHIND"), 3328 @ViewDebug.FlagToString(mask = FLAG_BLUR_BEHIND, equals = FLAG_BLUR_BEHIND, 3329 name = "BLUR_BEHIND"), 3330 @ViewDebug.FlagToString(mask = FLAG_NOT_FOCUSABLE, equals = FLAG_NOT_FOCUSABLE, 3331 name = "NOT_FOCUSABLE"), 3332 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCHABLE, equals = FLAG_NOT_TOUCHABLE, 3333 name = "NOT_TOUCHABLE"), 3334 @ViewDebug.FlagToString(mask = FLAG_NOT_TOUCH_MODAL, equals = FLAG_NOT_TOUCH_MODAL, 3335 name = "NOT_TOUCH_MODAL"), 3336 @ViewDebug.FlagToString(mask = FLAG_TOUCHABLE_WHEN_WAKING, equals = FLAG_TOUCHABLE_WHEN_WAKING, 3337 name = "TOUCHABLE_WHEN_WAKING"), 3338 @ViewDebug.FlagToString(mask = FLAG_KEEP_SCREEN_ON, equals = FLAG_KEEP_SCREEN_ON, 3339 name = "KEEP_SCREEN_ON"), 3340 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_SCREEN, equals = FLAG_LAYOUT_IN_SCREEN, 3341 name = "LAYOUT_IN_SCREEN"), 3342 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_NO_LIMITS, equals = FLAG_LAYOUT_NO_LIMITS, 3343 name = "LAYOUT_NO_LIMITS"), 3344 @ViewDebug.FlagToString(mask = FLAG_FULLSCREEN, equals = FLAG_FULLSCREEN, 3345 name = "FULLSCREEN"), 3346 @ViewDebug.FlagToString(mask = FLAG_FORCE_NOT_FULLSCREEN, equals = FLAG_FORCE_NOT_FULLSCREEN, 3347 name = "FORCE_NOT_FULLSCREEN"), 3348 @ViewDebug.FlagToString(mask = FLAG_DITHER, equals = FLAG_DITHER, 3349 name = "DITHER"), 3350 @ViewDebug.FlagToString(mask = FLAG_SECURE, equals = FLAG_SECURE, 3351 name = "SECURE"), 3352 @ViewDebug.FlagToString(mask = FLAG_SCALED, equals = FLAG_SCALED, 3353 name = "SCALED"), 3354 @ViewDebug.FlagToString(mask = FLAG_IGNORE_CHEEK_PRESSES, equals = FLAG_IGNORE_CHEEK_PRESSES, 3355 name = "IGNORE_CHEEK_PRESSES"), 3356 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_INSET_DECOR, equals = FLAG_LAYOUT_INSET_DECOR, 3357 name = "LAYOUT_INSET_DECOR"), 3358 @ViewDebug.FlagToString(mask = FLAG_ALT_FOCUSABLE_IM, equals = FLAG_ALT_FOCUSABLE_IM, 3359 name = "ALT_FOCUSABLE_IM"), 3360 @ViewDebug.FlagToString(mask = FLAG_WATCH_OUTSIDE_TOUCH, equals = FLAG_WATCH_OUTSIDE_TOUCH, 3361 name = "WATCH_OUTSIDE_TOUCH"), 3362 @ViewDebug.FlagToString(mask = FLAG_SHOW_WHEN_LOCKED, equals = FLAG_SHOW_WHEN_LOCKED, 3363 name = "SHOW_WHEN_LOCKED"), 3364 @ViewDebug.FlagToString(mask = FLAG_SHOW_WALLPAPER, equals = FLAG_SHOW_WALLPAPER, 3365 name = "SHOW_WALLPAPER"), 3366 @ViewDebug.FlagToString(mask = FLAG_TURN_SCREEN_ON, equals = FLAG_TURN_SCREEN_ON, 3367 name = "TURN_SCREEN_ON"), 3368 @ViewDebug.FlagToString(mask = FLAG_DISMISS_KEYGUARD, equals = FLAG_DISMISS_KEYGUARD, 3369 name = "DISMISS_KEYGUARD"), 3370 @ViewDebug.FlagToString(mask = FLAG_SPLIT_TOUCH, equals = FLAG_SPLIT_TOUCH, 3371 name = "SPLIT_TOUCH"), 3372 @ViewDebug.FlagToString(mask = FLAG_HARDWARE_ACCELERATED, equals = FLAG_HARDWARE_ACCELERATED, 3373 name = "HARDWARE_ACCELERATED"), 3374 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_IN_OVERSCAN, equals = FLAG_LAYOUT_IN_OVERSCAN, 3375 name = "LOCAL_FOCUS_MODE"), 3376 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_STATUS, equals = FLAG_TRANSLUCENT_STATUS, 3377 name = "TRANSLUCENT_STATUS"), 3378 @ViewDebug.FlagToString(mask = FLAG_TRANSLUCENT_NAVIGATION, equals = FLAG_TRANSLUCENT_NAVIGATION, 3379 name = "TRANSLUCENT_NAVIGATION"), 3380 @ViewDebug.FlagToString(mask = FLAG_LOCAL_FOCUS_MODE, equals = FLAG_LOCAL_FOCUS_MODE, 3381 name = "LOCAL_FOCUS_MODE"), 3382 @ViewDebug.FlagToString(mask = FLAG_SLIPPERY, equals = FLAG_SLIPPERY, 3383 name = "FLAG_SLIPPERY"), 3384 @ViewDebug.FlagToString(mask = FLAG_LAYOUT_ATTACHED_IN_DECOR, equals = FLAG_LAYOUT_ATTACHED_IN_DECOR, 3385 name = "FLAG_LAYOUT_ATTACHED_IN_DECOR"), 3386 @ViewDebug.FlagToString(mask = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, equals = FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS, 3387 name = "DRAWS_SYSTEM_BAR_BACKGROUNDS") 3388 }, formatToHexString = true) 3389 @Flags 3390 public int flags; 3391 3392 /** 3393 * In the system process, we globally do not use hardware acceleration 3394 * because there are many threads doing UI there and they conflict. 3395 * If certain parts of the UI that really do want to use hardware 3396 * acceleration, this flag can be set to force it. This is basically 3397 * for the lock screen. Anyone else using it, you are probably wrong. 3398 * 3399 * @hide 3400 */ 3401 public static final int PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED = 1 << 1; 3402 3403 /** 3404 * By default, wallpapers are sent new offsets when the wallpaper is scrolled. Wallpapers 3405 * may elect to skip these notifications if they are not doing anything productive with 3406 * them (they do not affect the wallpaper scrolling operation) by calling 3407 * {@link 3408 * android.service.wallpaper.WallpaperService.Engine#setOffsetNotificationsEnabled(boolean)}. 3409 * 3410 * @hide 3411 */ 3412 public static final int PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS = 1 << 2; 3413 3414 /** 3415 * When set {@link LayoutParams#TYPE_APPLICATION_OVERLAY} windows will stay visible, even if 3416 * {@link LayoutParams#SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS} is set for another 3417 * visible window. 3418 * @hide 3419 */ 3420 @RequiresPermission(permission.SYSTEM_APPLICATION_OVERLAY) 3421 public static final int PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY = 1 << 3; 3422 3423 /** In a multiuser system if this flag is set and the owner is a system process then this 3424 * window will appear on all user screens. This overrides the default behavior of window 3425 * types that normally only appear on the owning user's screen. Refer to each window type 3426 * to determine its default behavior. 3427 * 3428 * {@hide} */ 3429 @SystemApi 3430 @RequiresPermission(permission.INTERNAL_SYSTEM_WINDOW) 3431 public static final int SYSTEM_FLAG_SHOW_FOR_ALL_USERS = 1 << 4; 3432 3433 /** 3434 * Flag to allow this window to have unrestricted gesture exclusion. 3435 * 3436 * @see View#setSystemGestureExclusionRects(List) 3437 * @hide 3438 */ 3439 public static final int PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION = 1 << 5; 3440 3441 /** 3442 * Never animate position changes of the window. 3443 * 3444 * @see android.R.styleable#Window_windowNoMoveAnimation 3445 * {@hide} 3446 */ 3447 @UnsupportedAppUsage 3448 public static final int PRIVATE_FLAG_NO_MOVE_ANIMATION = 1 << 6; 3449 3450 /** Window flag: the client side view can intercept back progress, so system does not 3451 * need to pilfer pointers. 3452 * {@hide} */ 3453 public static final int PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED = 1 << 7; 3454 3455 /** Window flag: a special option intended for system dialogs. When 3456 * this flag is set, the window will demand focus unconditionally when 3457 * it is created. 3458 * {@hide} */ 3459 public static final int PRIVATE_FLAG_SYSTEM_ERROR = 1 << 8; 3460 3461 /** 3462 * Flag to indicate that the view hierarchy of the window can only be measured when 3463 * necessary. If a window size can be known by the LayoutParams, we can use the size to 3464 * relayout window, and we don't have to measure the view hierarchy before laying out the 3465 * views. This reduces the chances to perform measure. 3466 * {@hide} 3467 */ 3468 public static final int PRIVATE_FLAG_OPTIMIZE_MEASURE = 1 << 9; 3469 3470 /** 3471 * Flag that prevents the wallpaper behind the current window from receiving touch events. 3472 * 3473 * {@hide} 3474 */ 3475 public static final int PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS = 1 << 10; 3476 3477 /** 3478 * Flag to indicate that the window is forcibly to go edge-to-edge. 3479 * @hide 3480 */ 3481 public static final int PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED = 1 << 11; 3482 3483 /** 3484 * Flag to indicate that the window frame should be the requested frame adding the display 3485 * cutout frame. This will only be applied if a specific size smaller than the parent frame 3486 * is given, and the window is covering the display cutout. The extended frame will not be 3487 * larger than the parent frame. 3488 * 3489 * {@hide} 3490 */ 3491 public static final int PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT = 1 << 12; 3492 3493 /** 3494 * Flag that will make window ignore app visibility and instead depend purely on the decor 3495 * view visibility for determining window visibility. This is used by recents to keep 3496 * drawing after it launches an app. 3497 * @hide 3498 */ 3499 public static final int PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY = 1 << 13; 3500 3501 /** 3502 * Flag to indicate that this child window should always be laid-out in the parent 3503 * frame regardless of the current windowing mode configuration. 3504 * @hide 3505 */ 3506 public static final int PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME = 1 << 14; 3507 3508 /** 3509 * Flag to indicate that this window is always drawing the status bar background, no matter 3510 * what the other flags are. 3511 * @hide 3512 */ 3513 public static final int PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS = 1 << 15; 3514 3515 /** 3516 * Flag to indicate that this window needs Sustained Performance Mode if 3517 * the device supports it. 3518 * @hide 3519 */ 3520 public static final int PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE = 1 << 16; 3521 3522 /** 3523 * Flag to indicate that this window is a immersive mode confirmation window. The window 3524 * should be ignored when calculating insets control. This is used for prompt window 3525 * triggered by insets visibility changes. If it can take over the insets control, the 3526 * visibility will change unexpectedly and the window may dismiss itself. Power button panic 3527 * handling will be disabled when this window exists. 3528 * @hide 3529 */ 3530 public static final int PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW = 1 << 17; 3531 3532 /** 3533 * Flag to indicate that the window is forcibly to layout under the display cutout. 3534 * @hide 3535 */ 3536 public static final int PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE = 1 << 18; 3537 3538 /** 3539 * Flag to indicate that any window added by an application process that is of type 3540 * {@link #TYPE_TOAST} or that requires 3541 * {@link android.app.AppOpsManager#OP_SYSTEM_ALERT_WINDOW} permission should be hidden when 3542 * this window is visible. 3543 * @hide 3544 */ 3545 @SystemApi 3546 @RequiresPermission(permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS) 3547 public static final int SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 1 << 19; 3548 3549 /** 3550 * Indicates that this window is the rounded corners overlay present on some 3551 * devices this means that it will be excluded from: screenshots, 3552 * screen magnification, and mirroring. 3553 * @hide 3554 */ 3555 public static final int PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY = 1 << 20; 3556 3557 /** 3558 * Flag to indicate that this window will be excluded while computing the magnifiable region 3559 * on the un-scaled screen coordinate, which could avoid the cutout on the magnification 3560 * border. It should be used for unmagnifiable overlays. 3561 * 3562 * </p><p> 3563 * Note unlike {@link #PRIVATE_FLAG_NOT_MAGNIFIABLE}, this flag doesn't affect the ability 3564 * of magnification. If you want to the window to be unmagnifiable and doesn't lead to the 3565 * cutout, you need to combine both of them. 3566 * </p><p> 3567 * @hide 3568 */ 3569 public static final int PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION = 1 << 21; 3570 3571 /** 3572 * Flag to prevent the window from being magnified by the accessibility magnifier. 3573 * 3574 * TODO(b/190623172): This is a temporary solution and need to find out another way instead. 3575 * @hide 3576 */ 3577 public static final int PRIVATE_FLAG_NOT_MAGNIFIABLE = 1 << 22; 3578 3579 /** 3580 * Indicates that the window should receive key events including Action/Meta key. 3581 * They will not be intercepted as usual and instead will be passed to the window with other 3582 * key events. 3583 * TODO(b/358569822) Remove this once we have nicer API for listening to shortcuts 3584 * @hide 3585 */ 3586 public static final int PRIVATE_FLAG_ALLOW_ACTION_KEY_EVENTS = 1 << 23; 3587 3588 /** 3589 * Flag to indicate that the window is color space agnostic, and the color can be 3590 * interpreted to any color space. 3591 * @hide 3592 */ 3593 public static final int PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC = 1 << 24; 3594 3595 /** 3596 * Flag to indicate that the window consumes the insets of {@link Type#ime()}. This makes 3597 * windows below this window unable to receive visible IME insets. 3598 * @hide 3599 */ 3600 public static final int PRIVATE_FLAG_CONSUME_IME_INSETS = 1 << 25; 3601 3602 /** 3603 * Flag to indicate that the window has the 3604 * {@link R.styleable.Window_windowOptOutEdgeToEdgeEnforcement} flag set. 3605 * @hide 3606 */ 3607 public static final int PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE = 1 << 26; 3608 3609 /** 3610 * Flag to indicate that the window is controlling how it fits window insets on its own. 3611 * So we don't need to adjust its attributes for fitting window insets. 3612 * @hide 3613 */ 3614 public static final int PRIVATE_FLAG_FIT_INSETS_CONTROLLED = 1 << 28; 3615 3616 /** 3617 * Flag to indicate that the window is a trusted overlay. 3618 * @hide 3619 */ 3620 public static final int PRIVATE_FLAG_TRUSTED_OVERLAY = 1 << 29; 3621 3622 /** 3623 * Flag to indicate that the parent frame of a window should be inset by IME. 3624 * @hide 3625 */ 3626 public static final int PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME = 1 << 30; 3627 3628 /** 3629 * Flag to indicate that we want to intercept and handle global drag and drop for all users. 3630 * This flag allows a window to considered for drag events even if not visible, and will 3631 * receive drags for all active users in the system. 3632 * 3633 * Additional data is provided to windows with this flag, including the {@link ClipData} 3634 * including all items with the {@link DragEvent#ACTION_DRAG_STARTED} event, and the 3635 * actual drag surface with the {@link DragEvent#ACTION_DROP} event. If the window consumes, 3636 * the drop, then the cleanup of the drag surface (provided as a part of 3637 * {@link DragEvent#ACTION_DROP}) will be relinquished to the window. 3638 * @hide 3639 */ 3640 @RequiresPermission(permission.MANAGE_ACTIVITY_TASKS) 3641 public static final int PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP = 1 << 31; 3642 3643 /** 3644 * An internal annotation for flags that can be specified to {@link #softInputMode}. 3645 * 3646 * @removed mistakenly exposed as system-api previously 3647 */ 3648 @Retention(RetentionPolicy.SOURCE) 3649 @IntDef(flag = true, prefix = { "SYSTEM_FLAG_" }, value = { 3650 SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, 3651 SYSTEM_FLAG_SHOW_FOR_ALL_USERS, 3652 }) 3653 public @interface SystemFlags {} 3654 3655 /** 3656 * @hide 3657 */ 3658 @IntDef(flag = true, prefix="PRIVATE_FLAG_", value = { 3659 PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED, 3660 PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS, 3661 SYSTEM_FLAG_SHOW_FOR_ALL_USERS, 3662 PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION, 3663 PRIVATE_FLAG_NO_MOVE_ANIMATION, 3664 PRIVATE_FLAG_APP_PROGRESS_GENERATION_ALLOWED, 3665 PRIVATE_FLAG_SYSTEM_ERROR, 3666 PRIVATE_FLAG_OPTIMIZE_MEASURE, 3667 PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS, 3668 PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED, 3669 PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT, 3670 PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY, 3671 PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME, 3672 PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS, 3673 PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, 3674 PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, 3675 PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE, 3676 SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, 3677 PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY, 3678 PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION, 3679 PRIVATE_FLAG_NOT_MAGNIFIABLE, 3680 PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC, 3681 PRIVATE_FLAG_CONSUME_IME_INSETS, 3682 PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE, 3683 PRIVATE_FLAG_FIT_INSETS_CONTROLLED, 3684 PRIVATE_FLAG_TRUSTED_OVERLAY, 3685 PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME, 3686 PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP, 3687 PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY, 3688 }) 3689 @Retention(RetentionPolicy.SOURCE) 3690 public @interface PrivateFlags {} 3691 3692 /** 3693 * Control flags that are private to the platform. 3694 * @hide 3695 */ 3696 @UnsupportedAppUsage 3697 @ViewDebug.ExportedProperty(flagMapping = { 3698 @ViewDebug.FlagToString( 3699 mask = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED, 3700 equals = PRIVATE_FLAG_FORCE_HARDWARE_ACCELERATED, 3701 name = "FORCE_HARDWARE_ACCELERATED"), 3702 @ViewDebug.FlagToString( 3703 mask = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS, 3704 equals = PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS, 3705 name = "WANTS_OFFSET_NOTIFICATIONS"), 3706 @ViewDebug.FlagToString( 3707 mask = SYSTEM_FLAG_SHOW_FOR_ALL_USERS, 3708 equals = SYSTEM_FLAG_SHOW_FOR_ALL_USERS, 3709 name = "SHOW_FOR_ALL_USERS"), 3710 @ViewDebug.FlagToString( 3711 mask = PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION, 3712 equals = PRIVATE_FLAG_UNRESTRICTED_GESTURE_EXCLUSION, 3713 name = "UNRESTRICTED_GESTURE_EXCLUSION"), 3714 @ViewDebug.FlagToString( 3715 mask = PRIVATE_FLAG_NO_MOVE_ANIMATION, 3716 equals = PRIVATE_FLAG_NO_MOVE_ANIMATION, 3717 name = "NO_MOVE_ANIMATION"), 3718 @ViewDebug.FlagToString( 3719 mask = PRIVATE_FLAG_SYSTEM_ERROR, 3720 equals = PRIVATE_FLAG_SYSTEM_ERROR, 3721 name = "SYSTEM_ERROR"), 3722 @ViewDebug.FlagToString( 3723 mask = PRIVATE_FLAG_OPTIMIZE_MEASURE, 3724 equals = PRIVATE_FLAG_OPTIMIZE_MEASURE, 3725 name = "OPTIMIZE_MEASURE"), 3726 @ViewDebug.FlagToString( 3727 mask = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS, 3728 equals = PRIVATE_FLAG_DISABLE_WALLPAPER_TOUCH_EVENTS, 3729 name = "DISABLE_WALLPAPER_TOUCH_EVENTS"), 3730 @ViewDebug.FlagToString( 3731 mask = PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED, 3732 equals = PRIVATE_FLAG_EDGE_TO_EDGE_ENFORCED, 3733 name = "EDGE_TO_EDGE_ENFORCED"), 3734 @ViewDebug.FlagToString( 3735 mask = PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT, 3736 equals = PRIVATE_FLAG_LAYOUT_SIZE_EXTENDED_BY_CUTOUT, 3737 name = "LAYOUT_SIZE_EXTENDED_BY_CUTOUT"), 3738 @ViewDebug.FlagToString( 3739 mask = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY, 3740 equals = PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY, 3741 name = "FORCE_DECOR_VIEW_VISIBILITY"), 3742 @ViewDebug.FlagToString( 3743 mask = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME, 3744 equals = PRIVATE_FLAG_LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME, 3745 name = "LAYOUT_CHILD_WINDOW_IN_PARENT_FRAME"), 3746 @ViewDebug.FlagToString( 3747 mask = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS, 3748 equals = PRIVATE_FLAG_FORCE_DRAW_BAR_BACKGROUNDS, 3749 name = "FORCE_DRAW_STATUS_BAR_BACKGROUND"), 3750 @ViewDebug.FlagToString( 3751 mask = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, 3752 equals = PRIVATE_FLAG_SUSTAINED_PERFORMANCE_MODE, 3753 name = "SUSTAINED_PERFORMANCE_MODE"), 3754 @ViewDebug.FlagToString( 3755 mask = PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, 3756 equals = PRIVATE_FLAG_IMMERSIVE_CONFIRMATION_WINDOW, 3757 name = "IMMERSIVE_CONFIRMATION_WINDOW"), 3758 @ViewDebug.FlagToString( 3759 mask = PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE, 3760 equals = PRIVATE_FLAG_OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE, 3761 name = "OVERRIDE_LAYOUT_IN_DISPLAY_CUTOUT_MODE"), 3762 @ViewDebug.FlagToString( 3763 mask = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, 3764 equals = SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS, 3765 name = "HIDE_NON_SYSTEM_OVERLAY_WINDOWS"), 3766 @ViewDebug.FlagToString( 3767 mask = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY, 3768 equals = PRIVATE_FLAG_IS_ROUNDED_CORNERS_OVERLAY, 3769 name = "IS_ROUNDED_CORNERS_OVERLAY"), 3770 @ViewDebug.FlagToString( 3771 mask = PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION, 3772 equals = PRIVATE_FLAG_EXCLUDE_FROM_SCREEN_MAGNIFICATION, 3773 name = "EXCLUDE_FROM_SCREEN_MAGNIFICATION"), 3774 @ViewDebug.FlagToString( 3775 mask = PRIVATE_FLAG_NOT_MAGNIFIABLE, 3776 equals = PRIVATE_FLAG_NOT_MAGNIFIABLE, 3777 name = "NOT_MAGNIFIABLE"), 3778 @ViewDebug.FlagToString( 3779 mask = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC, 3780 equals = PRIVATE_FLAG_COLOR_SPACE_AGNOSTIC, 3781 name = "COLOR_SPACE_AGNOSTIC"), 3782 @ViewDebug.FlagToString( 3783 mask = PRIVATE_FLAG_CONSUME_IME_INSETS, 3784 equals = PRIVATE_FLAG_CONSUME_IME_INSETS, 3785 name = "CONSUME_IME_INSETS"), 3786 @ViewDebug.FlagToString( 3787 mask = PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE, 3788 equals = PRIVATE_FLAG_OPT_OUT_EDGE_TO_EDGE, 3789 name = "OPTOUT_EDGE_TO_EDGE"), 3790 @ViewDebug.FlagToString( 3791 mask = PRIVATE_FLAG_FIT_INSETS_CONTROLLED, 3792 equals = PRIVATE_FLAG_FIT_INSETS_CONTROLLED, 3793 name = "FIT_INSETS_CONTROLLED"), 3794 @ViewDebug.FlagToString( 3795 mask = PRIVATE_FLAG_TRUSTED_OVERLAY, 3796 equals = PRIVATE_FLAG_TRUSTED_OVERLAY, 3797 name = "TRUSTED_OVERLAY"), 3798 @ViewDebug.FlagToString( 3799 mask = PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME, 3800 equals = PRIVATE_FLAG_INSET_PARENT_FRAME_BY_IME, 3801 name = "INSET_PARENT_FRAME_BY_IME"), 3802 @ViewDebug.FlagToString( 3803 mask = PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP, 3804 equals = PRIVATE_FLAG_INTERCEPT_GLOBAL_DRAG_AND_DROP, 3805 name = "INTERCEPT_GLOBAL_DRAG_AND_DROP"), 3806 @ViewDebug.FlagToString( 3807 mask = PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY, 3808 equals = PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY, 3809 name = "SYSTEM_APPLICATION_OVERLAY") 3810 }) 3811 @PrivateFlags 3812 @TestApi 3813 public int privateFlags; 3814 3815 /** 3816 * Given a particular set of window manager flags, determine whether 3817 * such a window may be a target for an input method when it has 3818 * focus. In particular, this checks the 3819 * {@link #FLAG_NOT_FOCUSABLE} and {@link #FLAG_ALT_FOCUSABLE_IM} 3820 * flags and returns true if the combination of the two corresponds 3821 * to a window that can use the input method. 3822 * 3823 * @param flags The current window manager flags. 3824 * 3825 * @return Returns {@code true} if a window with the given flags would be able to 3826 * use the input method, {@code false} if not. 3827 */ mayUseInputMethod(int flags)3828 public static boolean mayUseInputMethod(int flags) { 3829 return (flags & FLAG_NOT_FOCUSABLE) != FLAG_NOT_FOCUSABLE 3830 && (flags & FLAG_ALT_FOCUSABLE_IM) != FLAG_ALT_FOCUSABLE_IM; 3831 } 3832 3833 /** 3834 * Mask for {@link #softInputMode} of the bits that determine the 3835 * desired visibility state of the soft input area for this window. 3836 */ 3837 public static final int SOFT_INPUT_MASK_STATE = 0x0f; 3838 3839 /** 3840 * Visibility state for {@link #softInputMode}: no state has been specified. The system may 3841 * show or hide the software keyboard for better user experience when the window gains 3842 * focus. 3843 */ 3844 public static final int SOFT_INPUT_STATE_UNSPECIFIED = 0; 3845 3846 /** 3847 * Visibility state for {@link #softInputMode}: please don't change the state of 3848 * the soft input area. 3849 */ 3850 public static final int SOFT_INPUT_STATE_UNCHANGED = 1; 3851 3852 /** 3853 * Visibility state for {@link #softInputMode}: please hide any soft input 3854 * area when normally appropriate (when the user is navigating 3855 * forward to your window). 3856 */ 3857 public static final int SOFT_INPUT_STATE_HIDDEN = 2; 3858 3859 /** 3860 * Visibility state for {@link #softInputMode}: please always hide any 3861 * soft input area when this window receives focus. 3862 */ 3863 public static final int SOFT_INPUT_STATE_ALWAYS_HIDDEN = 3; 3864 3865 /** 3866 * Visibility state for {@link #softInputMode}: please show the soft 3867 * input area when normally appropriate (when the user is navigating 3868 * forward to your window). 3869 * 3870 * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag 3871 * is ignored unless there is a focused view that returns {@code true} from 3872 * {@link View#onCheckIsTextEditor()} when the window is focused.</p> 3873 */ 3874 public static final int SOFT_INPUT_STATE_VISIBLE = 4; 3875 3876 /** 3877 * Visibility state for {@link #softInputMode}: please always make the 3878 * soft input area visible when this window receives input focus. 3879 * 3880 * <p>Applications that target {@link android.os.Build.VERSION_CODES#P} and later, this flag 3881 * is ignored unless there is a focused view that returns {@code true} from 3882 * {@link View#onCheckIsTextEditor()} when the window is focused.</p> 3883 */ 3884 public static final int SOFT_INPUT_STATE_ALWAYS_VISIBLE = 5; 3885 3886 /** 3887 * Mask for {@link #softInputMode} of the bits that determine the 3888 * way that the window should be adjusted to accommodate the soft 3889 * input window. 3890 */ 3891 public static final int SOFT_INPUT_MASK_ADJUST = 0xf0; 3892 3893 /** Adjustment option for {@link #softInputMode}: nothing specified. 3894 * The system will try to pick one or 3895 * the other depending on the contents of the window. 3896 */ 3897 public static final int SOFT_INPUT_ADJUST_UNSPECIFIED = 0x00; 3898 3899 /** Adjustment option for {@link #softInputMode}: set to allow the 3900 * window to be resized when an input 3901 * method is shown, so that its contents are not covered by the input 3902 * method. This can <em>not</em> be combined with 3903 * {@link #SOFT_INPUT_ADJUST_PAN}; if 3904 * neither of these are set, then the system will try to pick one or 3905 * the other depending on the contents of the window. If the window's 3906 * layout parameter flags include {@link #FLAG_FULLSCREEN}, this 3907 * value for {@link #softInputMode} will be ignored; the window will 3908 * not resize, but will stay fullscreen. 3909 * 3910 * @deprecated Call {@link Window#setDecorFitsSystemWindows(boolean)} with {@code false} and 3911 * install an {@link OnApplyWindowInsetsListener} on your root content view that fits insets 3912 * of type {@link Type#ime()}. 3913 */ 3914 @Deprecated 3915 public static final int SOFT_INPUT_ADJUST_RESIZE = 0x10; 3916 3917 /** Adjustment option for {@link #softInputMode}: set to have a window 3918 * pan when an input method is 3919 * shown, so it doesn't need to deal with resizing but just panned 3920 * by the framework to ensure the current input focus is visible. This 3921 * can <em>not</em> be combined with {@link #SOFT_INPUT_ADJUST_RESIZE}; if 3922 * neither of these are set, then the system will try to pick one or 3923 * the other depending on the contents of the window. 3924 */ 3925 public static final int SOFT_INPUT_ADJUST_PAN = 0x20; 3926 3927 /** Adjustment option for {@link #softInputMode}: set to have a window 3928 * not adjust for a shown input method. The window will not be resized, 3929 * and it will not be panned to make its focus visible. 3930 */ 3931 public static final int SOFT_INPUT_ADJUST_NOTHING = 0x30; 3932 3933 /** 3934 * Bit for {@link #softInputMode}: set when the user has navigated 3935 * forward to the window. This is normally set automatically for 3936 * you by the system, though you may want to set it in certain cases 3937 * when you are displaying a window yourself. This flag will always 3938 * be cleared automatically after the window is displayed. 3939 */ 3940 public static final int SOFT_INPUT_IS_FORWARD_NAVIGATION = 0x100; 3941 3942 /** 3943 * An internal annotation for flags that can be specified to {@link #softInputMode}. 3944 * 3945 * @hide 3946 */ 3947 @Retention(RetentionPolicy.SOURCE) 3948 @IntDef(flag = true, prefix = { "SOFT_INPUT_" }, value = { 3949 SOFT_INPUT_STATE_UNSPECIFIED, 3950 SOFT_INPUT_STATE_UNCHANGED, 3951 SOFT_INPUT_STATE_HIDDEN, 3952 SOFT_INPUT_STATE_ALWAYS_HIDDEN, 3953 SOFT_INPUT_STATE_VISIBLE, 3954 SOFT_INPUT_STATE_ALWAYS_VISIBLE, 3955 SOFT_INPUT_ADJUST_UNSPECIFIED, 3956 SOFT_INPUT_ADJUST_RESIZE, 3957 SOFT_INPUT_ADJUST_PAN, 3958 SOFT_INPUT_ADJUST_NOTHING, 3959 SOFT_INPUT_IS_FORWARD_NAVIGATION, 3960 }) 3961 public @interface SoftInputModeFlags {} 3962 3963 /** 3964 * Desired operating mode for any soft input area. May be any combination 3965 * of: 3966 * 3967 * <ul> 3968 * <li> One of the visibility states 3969 * {@link #SOFT_INPUT_STATE_UNSPECIFIED}, {@link #SOFT_INPUT_STATE_UNCHANGED}, 3970 * {@link #SOFT_INPUT_STATE_HIDDEN}, {@link #SOFT_INPUT_STATE_ALWAYS_HIDDEN}, 3971 * {@link #SOFT_INPUT_STATE_VISIBLE}, or {@link #SOFT_INPUT_STATE_ALWAYS_VISIBLE}. 3972 * <li> One of the adjustment options 3973 * {@link #SOFT_INPUT_ADJUST_UNSPECIFIED}, {@link #SOFT_INPUT_ADJUST_RESIZE}, 3974 * {@link #SOFT_INPUT_ADJUST_PAN}, or {@link #SOFT_INPUT_ADJUST_NOTHING}. 3975 * </ul> 3976 * 3977 * 3978 * <p>This flag can be controlled in your theme through the 3979 * {@link android.R.attr#windowSoftInputMode} attribute.</p> 3980 */ 3981 @SoftInputModeFlags 3982 public int softInputMode; 3983 3984 /** 3985 * Placement of window within the screen as per {@link Gravity}. Both 3986 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 3987 * android.graphics.Rect) Gravity.apply} and 3988 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 3989 * Gravity.applyDisplay} are used during window layout, with this value 3990 * given as the desired gravity. For example you can specify 3991 * {@link Gravity#DISPLAY_CLIP_HORIZONTAL Gravity.DISPLAY_CLIP_HORIZONTAL} and 3992 * {@link Gravity#DISPLAY_CLIP_VERTICAL Gravity.DISPLAY_CLIP_VERTICAL} here 3993 * to control the behavior of 3994 * {@link Gravity#applyDisplay(int, android.graphics.Rect, android.graphics.Rect) 3995 * Gravity.applyDisplay}. 3996 * 3997 * @see Gravity 3998 */ 3999 @GravityFlags 4000 public int gravity; 4001 4002 /** 4003 * The horizontal margin, as a percentage of the container's width, 4004 * between the container and the widget. See 4005 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 4006 * android.graphics.Rect) Gravity.apply} for how this is used. This 4007 * field is added with {@link #x} to supply the <var>xAdj</var> parameter. 4008 */ 4009 public float horizontalMargin; 4010 4011 /** 4012 * The vertical margin, as a percentage of the container's height, 4013 * between the container and the widget. See 4014 * {@link Gravity#apply(int, int, int, android.graphics.Rect, int, int, 4015 * android.graphics.Rect) Gravity.apply} for how this is used. This 4016 * field is added with {@link #y} to supply the <var>yAdj</var> parameter. 4017 */ 4018 public float verticalMargin; 4019 4020 /** 4021 * Positive insets between the drawing surface and window content. 4022 * 4023 * @hide 4024 */ 4025 public final Rect surfaceInsets = new Rect(); 4026 4027 /** 4028 * Whether the surface insets have been manually set. When set to 4029 * {@code false}, the view root will automatically determine the 4030 * appropriate surface insets. 4031 * 4032 * @see #surfaceInsets 4033 * @hide 4034 */ 4035 public boolean hasManualSurfaceInsets; 4036 4037 /** 4038 * Whether we should use global insets state when report insets to the window. When set to 4039 * {@code true}, all the insets will be reported to the window regardless of the z-order. 4040 * Otherwise, only the insets above the given window will be reported. 4041 * 4042 * @hide 4043 */ 4044 public boolean receiveInsetsIgnoringZOrder; 4045 4046 /** 4047 * Whether the previous surface insets should be used vs. what is currently set. When set 4048 * to {@code true}, the view root will ignore surfaces insets in this object and use what 4049 * it currently has. 4050 * 4051 * @see #surfaceInsets 4052 * @hide 4053 */ 4054 public boolean preservePreviousSurfaceInsets = true; 4055 4056 /** 4057 * The desired bitmap format. May be one of the constants in 4058 * {@link android.graphics.PixelFormat}. The choice of format 4059 * might be overridden by {@link #setColorMode(int)}. Default is OPAQUE. 4060 */ 4061 public int format; 4062 4063 /** 4064 * A style resource defining the animations to use for this window. 4065 * This must be a system resource; it can not be an application resource 4066 * because the window manager does not have access to applications. 4067 */ 4068 public int windowAnimations; 4069 4070 /** 4071 * An alpha value to apply to this entire window. 4072 * An alpha of 1.0 means fully opaque and 0.0 means fully transparent 4073 */ 4074 public float alpha = 1.0f; 4075 4076 /** 4077 * When {@link #FLAG_DIM_BEHIND} is set, this is the amount of dimming 4078 * to apply. Range is from 1.0 for completely opaque to 0.0 for no 4079 * dim. 4080 */ 4081 public float dimAmount = 1.0f; 4082 4083 /** 4084 * Default value for {@link #screenBrightness} and {@link #buttonBrightness} 4085 * indicating that the brightness value is not overridden for this window 4086 * and normal brightness policy should be used. 4087 */ 4088 public static final float BRIGHTNESS_OVERRIDE_NONE = -1.0f; 4089 4090 /** 4091 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 4092 * indicating that the screen or button backlight brightness should be set 4093 * to the lowest value when this window is in front. 4094 */ 4095 public static final float BRIGHTNESS_OVERRIDE_OFF = 0.0f; 4096 4097 /** 4098 * Value for {@link #screenBrightness} and {@link #buttonBrightness} 4099 * indicating that the screen or button backlight brightness should be set 4100 * to the hightest value when this window is in front. 4101 */ 4102 public static final float BRIGHTNESS_OVERRIDE_FULL = 1.0f; 4103 4104 /** 4105 * This can be used to override the user's preferred brightness of 4106 * the screen. A value of less than 0, the default, means to use the 4107 * preferred screen brightness. 0 to 1 adjusts the brightness from 4108 * dark to full bright. 4109 */ 4110 public float screenBrightness = BRIGHTNESS_OVERRIDE_NONE; 4111 4112 /** 4113 * This can be used to override the standard behavior of the button and 4114 * keyboard backlights. A value of less than 0, the default, means to 4115 * use the standard backlight behavior. 0 to 1 adjusts the brightness 4116 * from dark to full bright. 4117 */ 4118 public float buttonBrightness = BRIGHTNESS_OVERRIDE_NONE; 4119 4120 /** 4121 * Unspecified value for {@link #rotationAnimation} indicating 4122 * a lack of preference. 4123 * @hide 4124 */ 4125 public static final int ROTATION_ANIMATION_UNSPECIFIED = -1; 4126 4127 /** 4128 * Value for {@link #rotationAnimation} which specifies that this 4129 * window will visually rotate in or out following a rotation. 4130 */ 4131 public static final int ROTATION_ANIMATION_ROTATE = 0; 4132 4133 /** 4134 * Value for {@link #rotationAnimation} which specifies that this 4135 * window will fade in or out following a rotation. 4136 */ 4137 public static final int ROTATION_ANIMATION_CROSSFADE = 1; 4138 4139 /** 4140 * Value for {@link #rotationAnimation} which specifies that this window 4141 * will immediately disappear or appear following a rotation. 4142 */ 4143 public static final int ROTATION_ANIMATION_JUMPCUT = 2; 4144 4145 /** 4146 * Value for {@link #rotationAnimation} to specify seamless rotation mode. 4147 * This works like JUMPCUT but will fall back to CROSSFADE if rotation 4148 * can't be applied without pausing the screen. For example, this is ideal 4149 * for Camera apps which don't want the viewfinder contents to ever rotate 4150 * or fade (and rather to be seamless) but also don't want ROTATION_ANIMATION_JUMPCUT 4151 * during app transition scenarios where seamless rotation can't be applied. 4152 */ 4153 public static final int ROTATION_ANIMATION_SEAMLESS = 3; 4154 4155 /** 4156 * Define the exit and entry animations used on this window when the device is rotated. 4157 * This only has an affect if the incoming and outgoing topmost 4158 * opaque windows have the #FLAG_FULLSCREEN bit set and are not covered 4159 * by other windows. All other situations default to the 4160 * {@link #ROTATION_ANIMATION_ROTATE} behavior. 4161 * 4162 * @see #ROTATION_ANIMATION_ROTATE 4163 * @see #ROTATION_ANIMATION_CROSSFADE 4164 * @see #ROTATION_ANIMATION_JUMPCUT 4165 * @see #ROTATION_ANIMATION_SEAMLESS 4166 */ 4167 public int rotationAnimation = ROTATION_ANIMATION_ROTATE; 4168 4169 /** 4170 * Identifier for this window. This will usually be filled in for 4171 * you. 4172 */ 4173 public IBinder token = null; 4174 4175 /** 4176 * The token of {@link android.window.WindowContext}. It is usually a 4177 * {@link android.app.WindowTokenClient} and is used for associating the params with an 4178 * existing node in the WindowManager hierarchy and getting the corresponding 4179 * {@link Configuration} and {@link android.content.res.Resources} values with updates 4180 * propagated from the server side. 4181 * 4182 * @hide 4183 */ 4184 @Nullable 4185 public IBinder mWindowContextToken = null; 4186 4187 /** 4188 * Name of the package owning this window. 4189 */ 4190 public String packageName = null; 4191 4192 /** 4193 * Specific orientation value for a window. 4194 * May be any of the same values allowed 4195 * for {@link android.content.pm.ActivityInfo#screenOrientation}. 4196 * If not set, a default value of 4197 * {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED} 4198 * will be used. 4199 */ 4200 @ActivityInfo.ScreenOrientation 4201 public int screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; 4202 4203 /** 4204 * The preferred refresh rate for the window. 4205 * <p> 4206 * Before API 34, this must be one of the supported refresh rates obtained 4207 * for the display(s) the window is on. The selected refresh rate will be 4208 * applied to the display's default mode. 4209 * <p> 4210 * Starting API 34, this value is not limited to the supported refresh rates 4211 * obtained from the display(s) for the window: it can be any refresh rate 4212 * the window intends to run at. Any refresh rate can be provided as the 4213 * preferred window refresh rate. The OS will select the refresh rate that 4214 * best matches the {@link #preferredRefreshRate}. 4215 * <p> 4216 * Setting this value is the equivalent of calling {@link Surface#setFrameRate} with ( 4217 * preferred_frame_rate, 4218 * {@link Surface#FRAME_RATE_COMPATIBILITY_DEFAULT}, 4219 * {@link Surface#CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS}). 4220 * This should be used in favor of {@link LayoutParams#preferredDisplayModeId} for 4221 * applications that want to specify the refresh rate, but do not want to specify a 4222 * preference for any other displayMode properties (e.g., resolution). 4223 * <p> 4224 * This value is ignored if {@link #preferredDisplayModeId} is set. 4225 * 4226 * @see Display#getSupportedRefreshRates() 4227 */ 4228 public float preferredRefreshRate; 4229 4230 /** 4231 * Id of the preferred display mode for the window. 4232 * <p> 4233 * This must be one of the supported modes obtained for the display(s) the window is on. 4234 * A value of {@code 0} means no preference. 4235 * 4236 * @see Display#getSupportedModes() 4237 * @see Display.Mode#getModeId() 4238 */ 4239 public int preferredDisplayModeId; 4240 4241 /** 4242 * The min display refresh rate while the window is in focus. 4243 * 4244 * This value is ignored if {@link #preferredDisplayModeId} is set. 4245 * @hide 4246 */ 4247 @SuppressLint("UnflaggedApi") // @TestApi without associated feature. 4248 @TestApi 4249 public float preferredMinDisplayRefreshRate; 4250 4251 /** 4252 * The max display refresh rate while the window is in focus. 4253 * 4254 * This value is ignored if {@link #preferredDisplayModeId} is set. 4255 * @hide 4256 */ 4257 @SuppressLint("UnflaggedApi") // @TestApi without associated feature. 4258 @TestApi 4259 public float preferredMaxDisplayRefreshRate; 4260 4261 /** Indicates whether this window wants the HDR conversion is disabled. */ 4262 public static final int DISPLAY_FLAG_DISABLE_HDR_CONVERSION = 1 << 0; 4263 4264 /** 4265 * Flags that can be used to set display properties. 4266 * 4267 * @hide 4268 */ 4269 @IntDef(flag = true, prefix = "DISPLAY_FLAG_", value = { 4270 DISPLAY_FLAG_DISABLE_HDR_CONVERSION, 4271 }) 4272 public @interface DisplayFlags {} 4273 4274 @DisplayFlags 4275 private int mDisplayFlags; 4276 4277 /** 4278 * An internal annotation for flags that can be specified to {@link #systemUiVisibility} 4279 * and {@link #subtreeSystemUiVisibility}. 4280 * 4281 * @hide 4282 */ 4283 @Retention(RetentionPolicy.SOURCE) 4284 @IntDef(flag = true, prefix = { "" }, value = { 4285 SYSTEM_UI_FLAG_VISIBLE, 4286 SYSTEM_UI_FLAG_LOW_PROFILE, 4287 SYSTEM_UI_FLAG_HIDE_NAVIGATION, 4288 SYSTEM_UI_FLAG_FULLSCREEN, 4289 SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, 4290 SYSTEM_UI_FLAG_LAYOUT_STABLE, 4291 SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, 4292 SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, 4293 SYSTEM_UI_FLAG_IMMERSIVE, 4294 SYSTEM_UI_FLAG_IMMERSIVE_STICKY, 4295 SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, 4296 STATUS_BAR_DISABLE_EXPAND, 4297 STATUS_BAR_DISABLE_NOTIFICATION_ICONS, 4298 STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, 4299 STATUS_BAR_DISABLE_NOTIFICATION_TICKER, 4300 STATUS_BAR_DISABLE_SYSTEM_INFO, 4301 STATUS_BAR_DISABLE_HOME, 4302 STATUS_BAR_DISABLE_BACK, 4303 STATUS_BAR_DISABLE_CLOCK, 4304 STATUS_BAR_DISABLE_RECENT, 4305 STATUS_BAR_DISABLE_SEARCH, 4306 }) 4307 public @interface SystemUiVisibilityFlags {} 4308 4309 /** 4310 * Control the visibility of the status bar. 4311 * 4312 * @see View#STATUS_BAR_VISIBLE 4313 * @see View#STATUS_BAR_HIDDEN 4314 * 4315 * @deprecated SystemUiVisibility flags are deprecated. Use {@link WindowInsetsController} 4316 * instead. 4317 */ 4318 @SystemUiVisibilityFlags 4319 @Deprecated 4320 public int systemUiVisibility; 4321 4322 /** 4323 * @hide 4324 * The ui visibility as requested by the views in this hierarchy. 4325 * the combined value should be systemUiVisibility | subtreeSystemUiVisibility. 4326 */ 4327 @SystemUiVisibilityFlags 4328 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 4329 public int subtreeSystemUiVisibility; 4330 4331 /** 4332 * Get callbacks about the system ui visibility changing. 4333 * 4334 * TODO: Maybe there should be a bitfield of optional callbacks that we need. 4335 * 4336 * @hide 4337 */ 4338 @UnsupportedAppUsage 4339 public boolean hasSystemUiListeners; 4340 4341 /** @hide */ 4342 @Retention(RetentionPolicy.SOURCE) 4343 @IntDef( 4344 value = {LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT, 4345 LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES, 4346 LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER, 4347 LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS}) 4348 @interface LayoutInDisplayCutoutMode {} 4349 4350 /** 4351 * Controls how the window is laid out if there is a {@link DisplayCutout}. 4352 * 4353 * <p> 4354 * Defaults to {@link #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT}. 4355 * 4356 * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT 4357 * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES 4358 * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER 4359 * @see #LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS 4360 * @see DisplayCutout 4361 * @see android.R.attr#windowLayoutInDisplayCutoutMode 4362 * android:windowLayoutInDisplayCutoutMode 4363 */ 4364 @LayoutInDisplayCutoutMode 4365 public int layoutInDisplayCutoutMode = LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT; 4366 4367 /** 4368 * The window is allowed to extend into the {@link DisplayCutout} area, only if the 4369 * {@link DisplayCutout} is fully contained within a system bar or the {@link DisplayCutout} 4370 * is not deeper than 16 dp, but this depends on the OEM choice. Otherwise, the window is 4371 * laid out such that it does not overlap with the {@link DisplayCutout} area. 4372 * 4373 * <p> 4374 * In practice, this means that if the window did not set {@link #FLAG_FULLSCREEN} or 4375 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN}, it can extend into the cutout area in portrait 4376 * if the cutout is at the top edge. Similarly for 4377 * {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} and a cutout at the bottom of the screen. 4378 * Otherwise (i.e. fullscreen or landscape) it is laid out such that it does not overlap the 4379 * cutout area. 4380 * 4381 * <p> 4382 * The usual precautions for not overlapping with the status and navigation bar are 4383 * sufficient for ensuring that no important content overlaps with the DisplayCutout. 4384 * 4385 * <p> 4386 * Note: OEMs can have an option to allow the window to always extend into the 4387 * {@link DisplayCutout} area, no matter the cutout flag set, when the {@link DisplayCutout} 4388 * is on the different side from system bars, only if the {@link DisplayCutout} overlaps at 4389 * most 16dp with the windows. 4390 * In such case, OEMs must provide an opt-in/out affordance for users. 4391 * 4392 * @see DisplayCutout 4393 * @see WindowInsets 4394 * @see #layoutInDisplayCutoutMode 4395 * @see android.R.attr#windowLayoutInDisplayCutoutMode 4396 * android:windowLayoutInDisplayCutoutMode 4397 */ 4398 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT = 0; 4399 4400 /** 4401 * The window is always allowed to extend into the {@link DisplayCutout} areas on the short 4402 * edges of the screen. 4403 * 4404 * <p> 4405 * The window will never extend into a {@link DisplayCutout} area on the long edges of the 4406 * screen, unless the {@link DisplayCutout} is not deeper than 16 dp, but this depends on 4407 * the OEM choice. 4408 * 4409 * <p> 4410 * Note: OEMs can have an option to allow the window to extend into the 4411 * {@link DisplayCutout} area on the long edge side, only if the cutout overlaps at most 4412 * 16dp with the windows. In such case, OEMs must provide an opt-in/out affordance for 4413 * users. 4414 * 4415 * <p> 4416 * The window must make sure that no important content overlaps with the 4417 * {@link DisplayCutout}. 4418 * 4419 * <p> 4420 * In this mode, the window extends under cutouts on the short edge of the display in both 4421 * portrait and landscape, regardless of whether the window is hiding the system bars:<br/> 4422 * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/fullscreen_top_no_letterbox.png" 4423 * height="720" 4424 * alt="Screenshot of a fullscreen activity on a display with a cutout at the top edge in 4425 * portrait, no letterbox is applied."/> 4426 * 4427 * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/landscape_top_no_letterbox.png" 4428 * width="720" 4429 * alt="Screenshot of an activity on a display with a cutout at the top edge in landscape, 4430 * no letterbox is applied."/> 4431 * 4432 * <p> 4433 * A cutout in the corner can be considered to be on different edge in different device 4434 * rotations. This behavior may vary from device to device. Use this flag is possible to 4435 * letterbox your app if the display cutout is at corner. 4436 * 4437 * <p> 4438 * On the other hand, should the cutout be on the long edge of the display, a letterbox will 4439 * be applied such that the window does not extend into the cutout on either long edge: 4440 * <br/> 4441 * <img src="{@docRoot}reference/android/images/display_cutout/short_edge/portrait_side_letterbox.png" 4442 * height="720" 4443 * alt="Screenshot of an activity on a display with a cutout on the long edge in portrait, 4444 * letterbox is applied."/> 4445 * 4446 * <p> 4447 * Note: Android might not allow the content view to overlap the system bars in view level. 4448 * To override this behavior and allow content to be able to extend into the cutout area, 4449 * call {@link Window#setDecorFitsSystemWindows(boolean)} with {@code false}. 4450 * 4451 * @see DisplayCutout 4452 * @see WindowInsets#getDisplayCutout() 4453 * @see #layoutInDisplayCutoutMode 4454 * @see android.R.attr#windowLayoutInDisplayCutoutMode 4455 * android:windowLayoutInDisplayCutoutMode 4456 */ 4457 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES = 1; 4458 4459 /** 4460 * The window is never allowed to overlap with the DisplayCutout area. 4461 * 4462 * <p> 4463 * This should be used with windows that transiently set 4464 * {@link View#SYSTEM_UI_FLAG_FULLSCREEN} or {@link View#SYSTEM_UI_FLAG_HIDE_NAVIGATION} 4465 * to avoid a relayout of the window when the respective flag is set or cleared. 4466 * 4467 * @see DisplayCutout 4468 * @see #layoutInDisplayCutoutMode 4469 * @see android.R.attr#windowLayoutInDisplayCutoutMode 4470 * android:windowLayoutInDisplayCutoutMode 4471 */ 4472 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER = 2; 4473 4474 /** 4475 * The window is always allowed to extend into the {@link DisplayCutout} areas on the all 4476 * edges of the screen. 4477 * 4478 * <p> 4479 * The window must make sure that no important content overlaps with the 4480 * {@link DisplayCutout}. 4481 * 4482 * <p> 4483 * In this mode, the window extends under cutouts on the all edges of the display in both 4484 * portrait and landscape, regardless of whether the window is hiding the system bars. 4485 * 4486 * <p> 4487 * Note: Android might not allow the content view to overlap the system bars in view level. 4488 * To override this behavior and allow content to be able to extend into the cutout area, 4489 * call {@link Window#setDecorFitsSystemWindows(boolean)} with {@code false}. 4490 * 4491 * @see DisplayCutout 4492 * @see WindowInsets#getDisplayCutout() 4493 * @see #layoutInDisplayCutoutMode 4494 * @see android.R.attr#windowLayoutInDisplayCutoutMode 4495 * android:windowLayoutInDisplayCutoutMode 4496 */ 4497 public static final int LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS = 3; 4498 4499 /** 4500 * Does not construct an input channel for this window. The channel will therefore 4501 * be incapable of receiving input. 4502 * 4503 * @hide 4504 */ 4505 public static final int INPUT_FEATURE_NO_INPUT_CHANNEL = 1 << 0; 4506 4507 /** 4508 * When this window has focus, does not call user activity for all input events so 4509 * the application will have to do it itself. Should only be used by 4510 * the keyguard and phone app. 4511 * <p> 4512 * Should only be used by the keyguard and phone app. 4513 * </p> 4514 * 4515 * @hide 4516 */ 4517 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 4518 public static final int INPUT_FEATURE_DISABLE_USER_ACTIVITY = 1 << 1; 4519 4520 /** 4521 * An input spy window. This window will receive all pointer events within its touchable 4522 * area, but will not stop events from being sent to other windows below it in z-order. 4523 * An input event will be dispatched to all spy windows above the top non-spy window at the 4524 * event's coordinates. 4525 * 4526 * @hide 4527 */ 4528 @RequiresPermission(permission.MONITOR_INPUT) 4529 public static final int INPUT_FEATURE_SPY = 1 << 2; 4530 4531 /** 4532 * Input feature used to indicate that this window is privacy sensitive. This may be used 4533 * to redact input interactions from tracing or screen mirroring. 4534 * <p> 4535 * A window that uses {@link LayoutParams#FLAG_SECURE} will automatically be treated as 4536 * a sensitive for input tracing, but this input feature can be set on windows that don't 4537 * set FLAG_SECURE. The tracing configuration will determine how these sensitive events 4538 * are eventually traced. 4539 * <p> 4540 * This can only be set for trusted system overlays. 4541 * <p> 4542 * Note: Input tracing is only available on userdebug and eng builds. 4543 * 4544 * @hide 4545 */ 4546 public static final int INPUT_FEATURE_SENSITIVE_FOR_PRIVACY = 1 << 3; 4547 4548 /** 4549 * An internal annotation for flags that can be specified to {@link #inputFeatures}. 4550 * 4551 * NOTE: These are not the same as {@link android.os.InputConfig} flags. 4552 * 4553 * @hide 4554 */ 4555 @Retention(RetentionPolicy.SOURCE) 4556 @IntDef(flag = true, prefix = {"INPUT_FEATURE_"}, value = { 4557 INPUT_FEATURE_NO_INPUT_CHANNEL, 4558 INPUT_FEATURE_DISABLE_USER_ACTIVITY, 4559 INPUT_FEATURE_SPY, 4560 INPUT_FEATURE_SENSITIVE_FOR_PRIVACY 4561 }) 4562 public @interface InputFeatureFlags { 4563 } 4564 4565 /** 4566 * Control a set of features of the input subsystem that are exposed to the app process. 4567 * 4568 * WARNING: Do NOT use {@link android.os.InputConfig} flags! This must be set to flag values 4569 * included in {@link InputFeatureFlags}. 4570 * 4571 * @hide 4572 * @see InputFeatureFlags 4573 */ 4574 @InputFeatureFlags 4575 @UnsupportedAppUsage 4576 public int inputFeatures; 4577 4578 /** 4579 * Sets the number of milliseconds before the user activity timeout occurs 4580 * when this window has focus. A value of -1 uses the standard timeout. 4581 * A value of 0 uses the minimum support display timeout. 4582 * <p> 4583 * This property can only be used to reduce the user specified display timeout; 4584 * it can never make the timeout longer than it normally would be. 4585 * </p><p> 4586 * Should only be used by the keyguard and phone app. 4587 * </p> 4588 * 4589 * @hide 4590 */ 4591 @UnsupportedAppUsage 4592 public long userActivityTimeout = -1; 4593 4594 /** 4595 * For windows with an anchor (e.g. PopupWindow), keeps track of the View that anchors the 4596 * window. 4597 * 4598 * @hide 4599 */ 4600 public long accessibilityIdOfAnchor = AccessibilityNodeInfo.UNDEFINED_NODE_ID; 4601 4602 /** 4603 * The window title isn't kept in sync with what is displayed in the title bar, so we 4604 * separately track the currently shown title to provide to accessibility. 4605 * 4606 * @hide 4607 */ 4608 @TestApi 4609 public CharSequence accessibilityTitle; 4610 4611 /** 4612 * Sets a timeout in milliseconds before which the window will be hidden 4613 * by the window manager. Useful for transient notifications like toasts 4614 * so we don't have to rely on client cooperation to ensure the window 4615 * is hidden. Must be specified at window creation time. Note that apps 4616 * are not prepared to handle their windows being removed without their 4617 * explicit request and may try to interact with the removed window 4618 * resulting in undefined behavior and crashes. Therefore, we do hide 4619 * such windows to prevent them from overlaying other apps. 4620 * 4621 * @hide 4622 */ 4623 @UnsupportedAppUsage 4624 public long hideTimeoutMilliseconds = -1; 4625 4626 /** 4627 * Indicates whether this window wants the connected display to do minimal post processing 4628 * on the produced image or video frames. This will only be requested if the window is 4629 * visible on the screen. 4630 * 4631 * <p>This setting should be used when low latency has a higher priority than image 4632 * enhancement processing (e.g. for games or video conferencing). 4633 * 4634 * <p>If the Display sink is connected via HDMI, the device will begin to send infoframes 4635 * with Auto Low Latency Mode enabled and Game Content Type. This will switch the connected 4636 * display to a minimal image processing mode (if available), which reduces latency, 4637 * improving the user experience for gaming or video conferencing applications. For more 4638 * information, see HDMI 2.1 specification. 4639 * 4640 * <p>If the Display sink has an internal connection or uses some other protocol than HDMI, 4641 * effects may be similar but implementation-defined. 4642 * 4643 * <p>The ability to switch to a mode with minimal post proessing may be disabled by a user 4644 * setting in the system settings menu. In that case, this field is ignored and the display 4645 * will remain in its current mode. 4646 * 4647 * @see android.content.pm.ActivityInfo#FLAG_PREFER_MINIMAL_POST_PROCESSING 4648 * @see android.view.Display#isMinimalPostProcessingSupported 4649 * @see android.view.Window#setPreferMinimalPostProcessing 4650 */ 4651 public boolean preferMinimalPostProcessing = false; 4652 4653 /** 4654 * Specifies the amount of blur to be used to blur everything behind the window. 4655 * The effect is similar to the dimAmount, but instead of dimming, the content behind 4656 * will be blurred. 4657 * 4658 * The blur behind radius range starts at 0, which means no blur, and increases until 150 4659 * for the densest blur. 4660 * 4661 * @see #setBlurBehindRadius 4662 */ 4663 private int mBlurBehindRadius = 0; 4664 4665 /** 4666 * The color mode requested by this window. The target display may 4667 * not be able to honor the request. When the color mode is not set 4668 * to {@link ActivityInfo#COLOR_MODE_DEFAULT}, it might override the 4669 * pixel format specified in {@link #format}. 4670 * 4671 * @hide 4672 */ 4673 @ActivityInfo.ColorMode 4674 private int mColorMode = COLOR_MODE_DEFAULT; 4675 4676 /** @hide */ 4677 private float mDesiredHdrHeadroom = 0; 4678 4679 /** 4680 * For variable refresh rate project. 4681 */ 4682 private boolean mFrameRateBoostOnTouch = true; 4683 private boolean mIsFrameRatePowerSavingsBalanced = true; 4684 private static boolean sToolkitSetFrameRateReadOnlyFlagValue = 4685 android.view.flags.Flags.toolkitSetFrameRateReadOnly(); 4686 4687 /** 4688 * Carries the requests about {@link WindowInsetsController.Appearance} and 4689 * {@link WindowInsetsController.Behavior} to the system windows which can produce insets. 4690 * 4691 * @hide 4692 */ 4693 public final InsetsFlags insetsFlags = new InsetsFlags(); 4694 4695 @ViewDebug.ExportedProperty(flagMapping = { 4696 @ViewDebug.FlagToString( 4697 mask = STATUS_BARS, 4698 equals = STATUS_BARS, 4699 name = "STATUS_BARS"), 4700 @ViewDebug.FlagToString( 4701 mask = NAVIGATION_BARS, 4702 equals = NAVIGATION_BARS, 4703 name = "NAVIGATION_BARS"), 4704 @ViewDebug.FlagToString( 4705 mask = CAPTION_BAR, 4706 equals = CAPTION_BAR, 4707 name = "CAPTION_BAR"), 4708 @ViewDebug.FlagToString( 4709 mask = IME, 4710 equals = IME, 4711 name = "IME"), 4712 @ViewDebug.FlagToString( 4713 mask = SYSTEM_GESTURES, 4714 equals = SYSTEM_GESTURES, 4715 name = "SYSTEM_GESTURES"), 4716 @ViewDebug.FlagToString( 4717 mask = MANDATORY_SYSTEM_GESTURES, 4718 equals = MANDATORY_SYSTEM_GESTURES, 4719 name = "MANDATORY_SYSTEM_GESTURES"), 4720 @ViewDebug.FlagToString( 4721 mask = TAPPABLE_ELEMENT, 4722 equals = TAPPABLE_ELEMENT, 4723 name = "TAPPABLE_ELEMENT"), 4724 @ViewDebug.FlagToString( 4725 mask = WINDOW_DECOR, 4726 equals = WINDOW_DECOR, 4727 name = "WINDOW_DECOR") 4728 }) 4729 private @InsetsType int mFitInsetsTypes = Type.systemBars(); 4730 4731 @ViewDebug.ExportedProperty(flagMapping = { 4732 @ViewDebug.FlagToString( 4733 mask = LEFT, 4734 equals = LEFT, 4735 name = "LEFT"), 4736 @ViewDebug.FlagToString( 4737 mask = TOP, 4738 equals = TOP, 4739 name = "TOP"), 4740 @ViewDebug.FlagToString( 4741 mask = RIGHT, 4742 equals = RIGHT, 4743 name = "RIGHT"), 4744 @ViewDebug.FlagToString( 4745 mask = BOTTOM, 4746 equals = BOTTOM, 4747 name = "BOTTOM") 4748 }) 4749 private @InsetsSide int mFitInsetsSides = Side.all(); 4750 4751 private boolean mFitInsetsIgnoringVisibility = false; 4752 4753 /** 4754 * If set, the specified insets types will be provided by the window and the insets frame 4755 * will be calculated based on the provider's parameters. The insets types and the array 4756 * should not be modified after the window is added. If multiple layout parameters are 4757 * provided for different rotations in {@link LayoutParams#paramsForRotation}, the types in 4758 * the providedInsets array should be the same in all rotations, including the base one. 4759 * All other params can be adjusted at runtime. 4760 * See {@link InsetsFrameProvider}. 4761 * 4762 * @hide 4763 */ 4764 public InsetsFrameProvider[] providedInsets; 4765 4766 /** 4767 * Sets the insets to be provided by the window. 4768 * 4769 * @param insetsParams The parameters for the insets to be provided by the window. 4770 * 4771 * @hide 4772 */ 4773 @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_STATUS_BAR_AND_INSETS) 4774 @SystemApi setInsetsParams(@onNull List<InsetsParams> insetsParams)4775 public void setInsetsParams(@NonNull List<InsetsParams> insetsParams) { 4776 if (insetsParams.isEmpty()) { 4777 providedInsets = null; 4778 } else { 4779 providedInsets = new InsetsFrameProvider[insetsParams.size()]; 4780 for (int i = 0; i < insetsParams.size(); ++i) { 4781 final InsetsParams params = insetsParams.get(i); 4782 providedInsets[i] = 4783 new InsetsFrameProvider(/* owner= */ this, /* index= */ i, 4784 params.getType()) 4785 .setInsetsSize(params.getInsetsSize()); 4786 } 4787 } 4788 } 4789 4790 /** 4791 * Specifies which {@link InsetsType}s should be forcibly shown. The types shown by this 4792 * method won't affect the app's layout. This field only takes effects if the caller has 4793 * {@link android.Manifest.permission#STATUS_BAR_SERVICE} or the caller has the same uid as 4794 * the recents component. 4795 * 4796 * @hide 4797 */ 4798 public @InsetsType int forciblyShownTypes; 4799 4800 /** 4801 * {@link LayoutParams} to be applied to the window when layout with a assigned rotation. 4802 * This will make layout during rotation change smoothly. 4803 * 4804 * @hide 4805 */ 4806 public LayoutParams[] paramsForRotation; 4807 4808 /** 4809 * Specifies whether to send touch events to wallpaper, if the window shows wallpaper in the 4810 * background. By default, this is set to {@code true} i.e. if any window shows wallpaper 4811 * in the background, the wallpaper will receive touch events, unless specified otherwise. 4812 * 4813 * @see android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER 4814 */ 4815 private boolean mWallpaperTouchEventsEnabled = true; 4816 4817 /** 4818 * Specifies types of insets that this window should avoid overlapping during layout. 4819 * 4820 * @param types which {@link WindowInsets.Type}s of insets that this window should avoid. 4821 * The initial value of this object includes all system bars. 4822 */ setFitInsetsTypes(@nsetsType int types)4823 public void setFitInsetsTypes(@InsetsType int types) { 4824 mFitInsetsTypes = types; 4825 privateFlags |= PRIVATE_FLAG_FIT_INSETS_CONTROLLED; 4826 } 4827 4828 /** 4829 * Specifies sides of insets that this window should avoid overlapping during layout. 4830 * 4831 * @param sides which sides that this window should avoid overlapping with the types 4832 * specified. The initial value of this object includes all sides. 4833 */ setFitInsetsSides(@nsetsSide int sides)4834 public void setFitInsetsSides(@InsetsSide int sides) { 4835 mFitInsetsSides = sides; 4836 privateFlags |= PRIVATE_FLAG_FIT_INSETS_CONTROLLED; 4837 } 4838 4839 /** 4840 * Specifies if this window should fit the window insets no matter they are visible or not. 4841 * 4842 * @param ignore if true, this window will fit the given types even if they are not visible. 4843 */ setFitInsetsIgnoringVisibility(boolean ignore)4844 public void setFitInsetsIgnoringVisibility(boolean ignore) { 4845 mFitInsetsIgnoringVisibility = ignore; 4846 privateFlags |= PRIVATE_FLAG_FIT_INSETS_CONTROLLED; 4847 } 4848 4849 /** 4850 * Specifies that the window should be considered a trusted system overlay. Trusted system 4851 * overlays are ignored when considering whether windows are obscured during input 4852 * dispatch. Requires the {@link android.Manifest.permission#INTERNAL_SYSTEM_WINDOW} 4853 * permission. 4854 * 4855 * {@see android.view.MotionEvent#FLAG_WINDOW_IS_OBSCURED} 4856 * {@see android.view.MotionEvent#FLAG_WINDOW_IS_PARTIALLY_OBSCURED} 4857 * @hide 4858 */ setTrustedOverlay()4859 public void setTrustedOverlay() { 4860 privateFlags |= PRIVATE_FLAG_TRUSTED_OVERLAY; 4861 } 4862 4863 /** 4864 * When set on {@link LayoutParams#TYPE_APPLICATION_OVERLAY} windows they stay visible, 4865 * even if {@link LayoutParams#SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS} is set for 4866 * another visible window. 4867 * @hide 4868 */ 4869 @SystemApi 4870 @RequiresPermission(permission.SYSTEM_APPLICATION_OVERLAY) setSystemApplicationOverlay(boolean isSystemApplicationOverlay)4871 public void setSystemApplicationOverlay(boolean isSystemApplicationOverlay) { 4872 if (isSystemApplicationOverlay) { 4873 privateFlags |= PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY; 4874 } else { 4875 privateFlags &= ~PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY; 4876 } 4877 } 4878 4879 /** 4880 * Returns if this window is marked as being a system application overlay. 4881 * @see LayoutParams#setSystemApplicationOverlay(boolean) 4882 * 4883 * <p>Note: the owner of the window must hold 4884 * {@link android.Manifest.permission#SYSTEM_APPLICATION_OVERLAY} for this to have any 4885 * effect. 4886 * @hide 4887 */ 4888 @SystemApi isSystemApplicationOverlay()4889 public boolean isSystemApplicationOverlay() { 4890 return (privateFlags & PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY) 4891 == PRIVATE_FLAG_SYSTEM_APPLICATION_OVERLAY; 4892 } 4893 4894 /** 4895 * Set whether sending touch events to the system wallpaper (which can be provided by a 4896 * third-party application) should be enabled for windows that show wallpaper in 4897 * background. By default, this is set to {@code true}. 4898 * Check {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER} for more 4899 * information on showing system wallpaper behind the window. 4900 * 4901 * @param enable whether to enable sending touch events to the system wallpaper. 4902 */ setWallpaperTouchEventsEnabled(boolean enable)4903 public void setWallpaperTouchEventsEnabled(boolean enable) { 4904 mWallpaperTouchEventsEnabled = enable; 4905 } 4906 4907 /** 4908 * Returns whether sending touch events to the system wallpaper (which can be provided by a 4909 * third-party application) is enabled for windows that show wallpaper in background. 4910 * Check {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER} for more 4911 * information on showing system wallpaper behind the window. 4912 * 4913 * @return whether sending touch events to the system wallpaper is enabled. 4914 */ areWallpaperTouchEventsEnabled()4915 public boolean areWallpaperTouchEventsEnabled() { 4916 return mWallpaperTouchEventsEnabled; 4917 } 4918 4919 /** 4920 * Set whether animations can be played for position changes on this window. If disabled, 4921 * the window will move to its new position instantly without animating. 4922 * 4923 * @attr ref android.R.styleable#Window_windowNoMoveAnimation 4924 */ setCanPlayMoveAnimation(boolean enable)4925 public void setCanPlayMoveAnimation(boolean enable) { 4926 if (enable) { 4927 privateFlags &= ~PRIVATE_FLAG_NO_MOVE_ANIMATION; 4928 } else { 4929 privateFlags |= PRIVATE_FLAG_NO_MOVE_ANIMATION; 4930 } 4931 } 4932 4933 /** 4934 * @return whether playing an animation during a position change is allowed on this window. 4935 * This does not guarantee that an animation will be played in all such situations. For 4936 * example, drag-resizing may move the window but not play an animation. 4937 * 4938 * @attr ref android.R.styleable#Window_windowNoMoveAnimation 4939 */ canPlayMoveAnimation()4940 public boolean canPlayMoveAnimation() { 4941 return (privateFlags & PRIVATE_FLAG_NO_MOVE_ANIMATION) == 0; 4942 } 4943 4944 /** 4945 * @return the {@link WindowInsets.Type}s that this window is avoiding overlapping. 4946 */ getFitInsetsTypes()4947 public @InsetsType int getFitInsetsTypes() { 4948 return mFitInsetsTypes; 4949 } 4950 4951 /** 4952 * @return the sides that this window is avoiding overlapping. 4953 */ getFitInsetsSides()4954 public @InsetsSide int getFitInsetsSides() { 4955 return mFitInsetsSides; 4956 } 4957 4958 /** 4959 * @return {@code true} if this window fits the window insets no matter they are visible or 4960 * not. 4961 */ isFitInsetsIgnoringVisibility()4962 public boolean isFitInsetsIgnoringVisibility() { 4963 return mFitInsetsIgnoringVisibility; 4964 } 4965 checkNonRecursiveParams()4966 private void checkNonRecursiveParams() { 4967 if (paramsForRotation == null) { 4968 return; 4969 } 4970 for (int i = paramsForRotation.length - 1; i >= 0; i--) { 4971 if (paramsForRotation[i].paramsForRotation != null) { 4972 throw new IllegalArgumentException( 4973 "Params cannot contain params recursively."); 4974 } 4975 } 4976 } 4977 4978 /** 4979 * @see #paramsForRotation 4980 * @hide 4981 */ forRotation(int rotation)4982 public LayoutParams forRotation(int rotation) { 4983 if (paramsForRotation == null || paramsForRotation.length <= rotation 4984 || paramsForRotation[rotation] == null) { 4985 return this; 4986 } 4987 return paramsForRotation[rotation]; 4988 } 4989 LayoutParams()4990 public LayoutParams() { 4991 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 4992 type = TYPE_APPLICATION; 4993 format = PixelFormat.OPAQUE; 4994 } 4995 LayoutParams(int _type)4996 public LayoutParams(int _type) { 4997 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 4998 type = _type; 4999 format = PixelFormat.OPAQUE; 5000 } 5001 LayoutParams(int _type, int _flags)5002 public LayoutParams(int _type, int _flags) { 5003 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 5004 type = _type; 5005 flags = _flags; 5006 format = PixelFormat.OPAQUE; 5007 } 5008 LayoutParams(int _type, int _flags, int _format)5009 public LayoutParams(int _type, int _flags, int _format) { 5010 super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); 5011 type = _type; 5012 flags = _flags; 5013 format = _format; 5014 } 5015 LayoutParams(int w, int h, int _type, int _flags, int _format)5016 public LayoutParams(int w, int h, int _type, int _flags, int _format) { 5017 super(w, h); 5018 type = _type; 5019 flags = _flags; 5020 format = _format; 5021 } 5022 LayoutParams(int w, int h, int xpos, int ypos, int _type, int _flags, int _format)5023 public LayoutParams(int w, int h, int xpos, int ypos, int _type, 5024 int _flags, int _format) { 5025 super(w, h); 5026 x = xpos; 5027 y = ypos; 5028 type = _type; 5029 flags = _flags; 5030 format = _format; 5031 } 5032 5033 /** 5034 * Sets a title for the window. 5035 * <p> 5036 * This title will be used primarily for debugging, and may be exposed via {@link 5037 * android.view.accessibility.AccessibilityWindowInfo#getTitle} if no {@link Window#setTitle 5038 * user-facing title} has been set. 5039 * 5040 * @see Window#setTitle 5041 */ setTitle(CharSequence title)5042 public final void setTitle(CharSequence title) { 5043 if (null == title) 5044 title = ""; 5045 5046 mTitle = TextUtils.stringOrSpannedString(title); 5047 } 5048 getTitle()5049 public final CharSequence getTitle() { 5050 return mTitle != null ? mTitle : ""; 5051 } 5052 5053 /** 5054 * Sets the surface insets based on the elevation (visual z position) of the input view. 5055 * @hide 5056 */ setSurfaceInsets(View view, boolean manual, boolean preservePrevious)5057 public final void setSurfaceInsets(View view, boolean manual, boolean preservePrevious) { 5058 final int surfaceInset = (int) Math.ceil(view.getZ() * 2); 5059 // Partial workaround for b/28318973. Every inset change causes a freeform window 5060 // to jump a little for a few frames. If we never allow surface insets to decrease, 5061 // they will stabilize quickly (often from the very beginning, as most windows start 5062 // as focused). 5063 // TODO(b/22668382) to fix this properly. 5064 if (surfaceInset == 0) { 5065 // OK to have 0 (this is the case for non-freeform windows). 5066 surfaceInsets.set(0, 0, 0, 0); 5067 } else { 5068 surfaceInsets.set( 5069 Math.max(surfaceInset, surfaceInsets.left), 5070 Math.max(surfaceInset, surfaceInsets.top), 5071 Math.max(surfaceInset, surfaceInsets.right), 5072 Math.max(surfaceInset, surfaceInsets.bottom)); 5073 } 5074 hasManualSurfaceInsets = manual; 5075 preservePreviousSurfaceInsets = preservePrevious; 5076 } 5077 5078 /** Returns whether the HDR conversion is enabled for the window */ isHdrConversionEnabled()5079 public boolean isHdrConversionEnabled() { 5080 return ((mDisplayFlags & DISPLAY_FLAG_DISABLE_HDR_CONVERSION) == 0); 5081 } 5082 5083 /** 5084 * Enables/disables the HDR conversion for the window. 5085 * 5086 * By default, the HDR conversion is enabled for the window. 5087 */ setHdrConversionEnabled(boolean enabled)5088 public void setHdrConversionEnabled(boolean enabled) { 5089 if (!enabled) { 5090 mDisplayFlags |= DISPLAY_FLAG_DISABLE_HDR_CONVERSION; 5091 } else { 5092 mDisplayFlags &= ~DISPLAY_FLAG_DISABLE_HDR_CONVERSION; 5093 } 5094 } 5095 5096 /** 5097 * <p>Set the color mode of the window. Setting the color mode might 5098 * override the window's pixel {@link WindowManager.LayoutParams#format format}.</p> 5099 * 5100 * <p>The color mode must be one of {@link ActivityInfo#COLOR_MODE_DEFAULT}, 5101 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or 5102 * {@link ActivityInfo#COLOR_MODE_HDR}.</p> 5103 * 5104 * @see #getColorMode() 5105 */ setColorMode(@ctivityInfo.ColorMode int colorMode)5106 public void setColorMode(@ActivityInfo.ColorMode int colorMode) { 5107 mColorMode = colorMode; 5108 } 5109 5110 /** 5111 * Returns the color mode of the window, one of {@link ActivityInfo#COLOR_MODE_DEFAULT}, 5112 * {@link ActivityInfo#COLOR_MODE_WIDE_COLOR_GAMUT} or {@link ActivityInfo#COLOR_MODE_HDR}. 5113 * 5114 * @see #setColorMode(int) 5115 */ 5116 @ActivityInfo.ColorMode getColorMode()5117 public int getColorMode() { 5118 return mColorMode; 5119 } 5120 5121 /** 5122 * <p>Sets the desired about of HDR headroom to be used when rendering as a ratio of 5123 * targetHdrPeakBrightnessInNits / targetSdrWhitePointInNits. Only applies when 5124 * {@link #setColorMode(int)} is {@link ActivityInfo#COLOR_MODE_HDR}</p> 5125 * 5126 * @see Window#setDesiredHdrHeadroom(float) 5127 * @param desiredHeadroom Desired amount of HDR headroom. Must be in the range of 1.0 (SDR) 5128 * to 10,000.0, or 0.0 to reset to default. 5129 */ 5130 @FlaggedApi(com.android.graphics.hwui.flags.Flags.FLAG_LIMITED_HDR) setDesiredHdrHeadroom( @loatRangefrom = 0.0f, to = 10000.0f) float desiredHeadroom)5131 public void setDesiredHdrHeadroom( 5132 @FloatRange(from = 0.0f, to = 10000.0f) float desiredHeadroom) { 5133 if (!Float.isFinite(desiredHeadroom)) { 5134 throw new IllegalArgumentException("desiredHeadroom must be finite: " 5135 + desiredHeadroom); 5136 } 5137 if (desiredHeadroom != 0 && (desiredHeadroom < 1.0f || desiredHeadroom > 10000.0f)) { 5138 throw new IllegalArgumentException( 5139 "desiredHeadroom must be 0.0 or in the range [1.0, 10000.0f], received: " 5140 + desiredHeadroom); 5141 } 5142 mDesiredHdrHeadroom = desiredHeadroom; 5143 } 5144 5145 /** 5146 * Get the desired amount of HDR headroom as set by {@link #setDesiredHdrHeadroom(float)} 5147 * @return The amount of HDR headroom set, or 0 for automatic/default behavior. 5148 */ 5149 @FlaggedApi(com.android.graphics.hwui.flags.Flags.FLAG_LIMITED_HDR) getDesiredHdrHeadroom()5150 public float getDesiredHdrHeadroom() { 5151 return mDesiredHdrHeadroom; 5152 } 5153 5154 /** 5155 * Set the value whether we should enable Touch Boost 5156 * 5157 * @param enabled Whether we should enable Touch Boost 5158 */ 5159 @FlaggedApi(android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) setFrameRateBoostOnTouchEnabled(boolean enabled)5160 public void setFrameRateBoostOnTouchEnabled(boolean enabled) { 5161 if (sToolkitSetFrameRateReadOnlyFlagValue) { 5162 mFrameRateBoostOnTouch = enabled; 5163 } 5164 } 5165 5166 /** 5167 * Get the value whether we should enable touch boost as set 5168 * by {@link #setFrameRateBoostOnTouchEnabled(boolean)} 5169 * 5170 * @return A boolean value to indicate whether we should enable touch boost 5171 */ 5172 @FlaggedApi(android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) getFrameRateBoostOnTouchEnabled()5173 public boolean getFrameRateBoostOnTouchEnabled() { 5174 if (sToolkitSetFrameRateReadOnlyFlagValue) { 5175 return mFrameRateBoostOnTouch; 5176 } 5177 return true; 5178 } 5179 5180 /** 5181 * Set the value whether frameratepowersavingsbalance is enabled for this Window. 5182 * This allows device to adjust refresh rate 5183 * as needed and can be useful for power saving. 5184 * 5185 * @param enabled Whether we should enable frameratepowersavingsbalance. 5186 */ 5187 @FlaggedApi(android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) setFrameRatePowerSavingsBalanced(boolean enabled)5188 public void setFrameRatePowerSavingsBalanced(boolean enabled) { 5189 if (sToolkitSetFrameRateReadOnlyFlagValue) { 5190 mIsFrameRatePowerSavingsBalanced = enabled; 5191 } 5192 } 5193 5194 /** 5195 * Get the value whether frameratepowersavingsbalance is enabled for this Window. 5196 * This allows device to adjust refresh rate 5197 * as needed and can be useful for power saving. 5198 * by {@link #setFrameRatePowerSavingsBalanced(boolean)} 5199 * 5200 * @return Whether we should enable frameratepowersavingsbalance. 5201 */ 5202 @FlaggedApi(android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY) isFrameRatePowerSavingsBalanced()5203 public boolean isFrameRatePowerSavingsBalanced() { 5204 if (sToolkitSetFrameRateReadOnlyFlagValue) { 5205 return mIsFrameRatePowerSavingsBalanced; 5206 } 5207 return true; 5208 } 5209 5210 /** 5211 * <p> 5212 * Blurs the screen behind the window. The effect is similar to that of {@link #dimAmount}, 5213 * but instead of dimmed, the content behind the window will be blurred (or combined with 5214 * the dim amount, if such is specified). 5215 * </p><p> 5216 * The density of the blur is set by the blur radius. The radius defines the size 5217 * of the neighbouring area, from which pixels will be averaged to form the final 5218 * color for each pixel. The operation approximates a Gaussian blur. 5219 * A radius of 0 means no blur. The higher the radius, the denser the blur. 5220 * </p><p> 5221 * Note the difference with {@link android.view.Window#setBackgroundBlurRadius}, 5222 * which blurs only within the bounds of the window. Blur behind blurs the whole screen 5223 * behind the window. 5224 * </p><p> 5225 * Requires {@link #FLAG_BLUR_BEHIND} to be set. 5226 * </p><p> 5227 * Cross-window blur might not be supported by some devices due to GPU limitations. It can 5228 * also be disabled at runtime, e.g. during battery saving mode, when multimedia tunneling 5229 * is used or when minimal post processing is requested. In such situations, no blur will 5230 * be computed or drawn, resulting in there being no depth separation between the window 5231 * and the content behind it. To avoid this, the app might want to use more 5232 * {@link #dimAmount} on its window. To listen for cross-window blur enabled/disabled 5233 * events, use {@link #addCrossWindowBlurEnabledListener}. 5234 * </p> 5235 * @param blurBehindRadius The blur radius to use for blur behind in pixels 5236 * 5237 * @see #FLAG_BLUR_BEHIND 5238 * @see #getBlurBehindRadius 5239 * @see WindowManager#addCrossWindowBlurEnabledListener 5240 * @see Window#setBackgroundBlurRadius 5241 */ setBlurBehindRadius(@ntRangefrom = 0) int blurBehindRadius)5242 public void setBlurBehindRadius(@IntRange(from = 0) int blurBehindRadius) { 5243 mBlurBehindRadius = blurBehindRadius; 5244 } 5245 5246 /** 5247 * Returns the blur behind radius of the window. 5248 * 5249 * @see #setBlurBehindRadius 5250 */ getBlurBehindRadius()5251 public int getBlurBehindRadius() { 5252 return mBlurBehindRadius; 5253 } 5254 5255 /** @hide */ 5256 @SystemApi setUserActivityTimeout(long timeout)5257 public final void setUserActivityTimeout(long timeout) { 5258 userActivityTimeout = timeout; 5259 } 5260 5261 /** @hide */ 5262 @SystemApi getUserActivityTimeout()5263 public final long getUserActivityTimeout() { 5264 return userActivityTimeout; 5265 } 5266 5267 /** 5268 * Sets the {@link android.app.WindowContext} token. 5269 * 5270 * @see #getWindowContextToken() 5271 * 5272 * @hide 5273 */ 5274 @TestApi setWindowContextToken(@onNull IBinder token)5275 public final void setWindowContextToken(@NonNull IBinder token) { 5276 mWindowContextToken = token; 5277 } 5278 5279 /** 5280 * Gets the {@link android.app.WindowContext} token. 5281 * 5282 * The token is usually a {@link android.app.WindowTokenClient} and is used for associating 5283 * the params with an existing node in the WindowManager hierarchy and getting the 5284 * corresponding {@link Configuration} and {@link android.content.res.Resources} values with 5285 * updates propagated from the server side. 5286 * 5287 * @see android.app.WindowTokenClient 5288 * @see Context#createWindowContext(Display, int, Bundle) 5289 * 5290 * @hide 5291 */ 5292 @TestApi 5293 @Nullable getWindowContextToken()5294 public final IBinder getWindowContextToken() { 5295 return mWindowContextToken; 5296 } 5297 describeContents()5298 public int describeContents() { 5299 return 0; 5300 } 5301 writeToParcel(Parcel out, int parcelableFlags)5302 public void writeToParcel(Parcel out, int parcelableFlags) { 5303 out.writeInt(width); 5304 out.writeInt(height); 5305 out.writeInt(x); 5306 out.writeInt(y); 5307 out.writeInt(type); 5308 out.writeInt(flags); 5309 out.writeInt(privateFlags); 5310 out.writeInt(softInputMode); 5311 out.writeInt(layoutInDisplayCutoutMode); 5312 out.writeInt(gravity); 5313 out.writeFloat(horizontalMargin); 5314 out.writeFloat(verticalMargin); 5315 out.writeInt(format); 5316 out.writeInt(windowAnimations); 5317 out.writeFloat(alpha); 5318 out.writeFloat(dimAmount); 5319 out.writeFloat(screenBrightness); 5320 out.writeFloat(buttonBrightness); 5321 out.writeInt(rotationAnimation); 5322 out.writeStrongBinder(token); 5323 out.writeStrongBinder(mWindowContextToken); 5324 out.writeString(packageName); 5325 TextUtils.writeToParcel(mTitle, out, parcelableFlags); 5326 out.writeInt(screenOrientation); 5327 out.writeFloat(preferredRefreshRate); 5328 out.writeInt(preferredDisplayModeId); 5329 out.writeFloat(preferredMinDisplayRefreshRate); 5330 out.writeFloat(preferredMaxDisplayRefreshRate); 5331 out.writeInt(systemUiVisibility); 5332 out.writeInt(subtreeSystemUiVisibility); 5333 out.writeBoolean(hasSystemUiListeners); 5334 out.writeInt(inputFeatures); 5335 out.writeLong(userActivityTimeout); 5336 out.writeInt(surfaceInsets.left); 5337 out.writeInt(surfaceInsets.top); 5338 out.writeInt(surfaceInsets.right); 5339 out.writeInt(surfaceInsets.bottom); 5340 out.writeBoolean(hasManualSurfaceInsets); 5341 out.writeBoolean(receiveInsetsIgnoringZOrder); 5342 out.writeBoolean(preservePreviousSurfaceInsets); 5343 out.writeLong(accessibilityIdOfAnchor); 5344 TextUtils.writeToParcel(accessibilityTitle, out, parcelableFlags); 5345 out.writeInt(mColorMode); 5346 out.writeLong(hideTimeoutMilliseconds); 5347 out.writeInt(insetsFlags.appearance); 5348 out.writeInt(insetsFlags.behavior); 5349 out.writeInt(mFitInsetsTypes); 5350 out.writeInt(mFitInsetsSides); 5351 out.writeBoolean(mFitInsetsIgnoringVisibility); 5352 out.writeBoolean(preferMinimalPostProcessing); 5353 out.writeInt(mBlurBehindRadius); 5354 out.writeBoolean(mWallpaperTouchEventsEnabled); 5355 out.writeTypedArray(providedInsets, 0 /* parcelableFlags */); 5356 out.writeInt(forciblyShownTypes); 5357 checkNonRecursiveParams(); 5358 out.writeTypedArray(paramsForRotation, 0 /* parcelableFlags */); 5359 out.writeInt(mDisplayFlags); 5360 out.writeFloat(mDesiredHdrHeadroom); 5361 if (sToolkitSetFrameRateReadOnlyFlagValue) { 5362 out.writeBoolean(mFrameRateBoostOnTouch); 5363 out.writeBoolean(mIsFrameRatePowerSavingsBalanced); 5364 } 5365 } 5366 5367 public static final @android.annotation.NonNull Parcelable.Creator<LayoutParams> CREATOR 5368 = new Parcelable.Creator<LayoutParams>() { 5369 public LayoutParams createFromParcel(Parcel in) { 5370 return new LayoutParams(in); 5371 } 5372 5373 public LayoutParams[] newArray(int size) { 5374 return new LayoutParams[size]; 5375 } 5376 }; 5377 5378 LayoutParams(Parcel in)5379 public LayoutParams(Parcel in) { 5380 width = in.readInt(); 5381 height = in.readInt(); 5382 x = in.readInt(); 5383 y = in.readInt(); 5384 type = in.readInt(); 5385 flags = in.readInt(); 5386 privateFlags = in.readInt(); 5387 softInputMode = in.readInt(); 5388 layoutInDisplayCutoutMode = in.readInt(); 5389 gravity = in.readInt(); 5390 horizontalMargin = in.readFloat(); 5391 verticalMargin = in.readFloat(); 5392 format = in.readInt(); 5393 windowAnimations = in.readInt(); 5394 alpha = in.readFloat(); 5395 dimAmount = in.readFloat(); 5396 screenBrightness = in.readFloat(); 5397 buttonBrightness = in.readFloat(); 5398 rotationAnimation = in.readInt(); 5399 token = in.readStrongBinder(); 5400 mWindowContextToken = in.readStrongBinder(); 5401 packageName = in.readString(); 5402 mTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 5403 screenOrientation = in.readInt(); 5404 preferredRefreshRate = in.readFloat(); 5405 preferredDisplayModeId = in.readInt(); 5406 preferredMinDisplayRefreshRate = in.readFloat(); 5407 preferredMaxDisplayRefreshRate = in.readFloat(); 5408 systemUiVisibility = in.readInt(); 5409 subtreeSystemUiVisibility = in.readInt(); 5410 hasSystemUiListeners = in.readBoolean(); 5411 inputFeatures = in.readInt(); 5412 userActivityTimeout = in.readLong(); 5413 surfaceInsets.left = in.readInt(); 5414 surfaceInsets.top = in.readInt(); 5415 surfaceInsets.right = in.readInt(); 5416 surfaceInsets.bottom = in.readInt(); 5417 hasManualSurfaceInsets = in.readBoolean(); 5418 receiveInsetsIgnoringZOrder = in.readBoolean(); 5419 preservePreviousSurfaceInsets = in.readBoolean(); 5420 accessibilityIdOfAnchor = in.readLong(); 5421 accessibilityTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in); 5422 mColorMode = in.readInt(); 5423 hideTimeoutMilliseconds = in.readLong(); 5424 insetsFlags.appearance = in.readInt(); 5425 insetsFlags.behavior = in.readInt(); 5426 mFitInsetsTypes = in.readInt(); 5427 mFitInsetsSides = in.readInt(); 5428 mFitInsetsIgnoringVisibility = in.readBoolean(); 5429 preferMinimalPostProcessing = in.readBoolean(); 5430 mBlurBehindRadius = in.readInt(); 5431 mWallpaperTouchEventsEnabled = in.readBoolean(); 5432 providedInsets = in.createTypedArray(InsetsFrameProvider.CREATOR); 5433 forciblyShownTypes = in.readInt(); 5434 paramsForRotation = in.createTypedArray(LayoutParams.CREATOR); 5435 mDisplayFlags = in.readInt(); 5436 mDesiredHdrHeadroom = in.readFloat(); 5437 if (sToolkitSetFrameRateReadOnlyFlagValue) { 5438 mFrameRateBoostOnTouch = in.readBoolean(); 5439 mIsFrameRatePowerSavingsBalanced = in.readBoolean(); 5440 } 5441 } 5442 5443 @SuppressWarnings({"PointlessBitwiseExpression"}) 5444 public static final int LAYOUT_CHANGED = 1<<0; 5445 public static final int TYPE_CHANGED = 1<<1; 5446 public static final int FLAGS_CHANGED = 1<<2; 5447 public static final int FORMAT_CHANGED = 1<<3; 5448 public static final int ANIMATION_CHANGED = 1<<4; 5449 public static final int DIM_AMOUNT_CHANGED = 1<<5; 5450 public static final int TITLE_CHANGED = 1<<6; 5451 public static final int ALPHA_CHANGED = 1<<7; 5452 public static final int MEMORY_TYPE_CHANGED = 1<<8; 5453 public static final int SOFT_INPUT_MODE_CHANGED = 1<<9; 5454 public static final int SCREEN_ORIENTATION_CHANGED = 1<<10; 5455 public static final int SCREEN_BRIGHTNESS_CHANGED = 1<<11; 5456 public static final int ROTATION_ANIMATION_CHANGED = 1<<12; 5457 /** {@hide} */ 5458 public static final int BUTTON_BRIGHTNESS_CHANGED = 1<<13; 5459 /** {@hide} */ 5460 public static final int SYSTEM_UI_VISIBILITY_CHANGED = 1<<14; 5461 /** {@hide} */ 5462 public static final int SYSTEM_UI_LISTENER_CHANGED = 1<<15; 5463 /** {@hide} */ 5464 public static final int INPUT_FEATURES_CHANGED = 1<<16; 5465 /** {@hide} */ 5466 public static final int PRIVATE_FLAGS_CHANGED = 1<<17; 5467 /** {@hide} */ 5468 public static final int USER_ACTIVITY_TIMEOUT_CHANGED = 1<<18; 5469 /** {@hide} */ 5470 public static final int TRANSLUCENT_FLAGS_CHANGED = 1<<19; 5471 /** {@hide} */ 5472 public static final int SURFACE_INSETS_CHANGED = 1<<20; 5473 /** {@hide} */ 5474 public static final int PREFERRED_REFRESH_RATE_CHANGED = 1 << 21; 5475 /** {@hide} */ 5476 public static final int DISPLAY_FLAGS_CHANGED = 1 << 22; 5477 /** {@hide} */ 5478 public static final int PREFERRED_DISPLAY_MODE_ID = 1 << 23; 5479 /** {@hide} */ 5480 public static final int ACCESSIBILITY_ANCHOR_CHANGED = 1 << 24; 5481 /** {@hide} */ 5482 @TestApi 5483 public static final int ACCESSIBILITY_TITLE_CHANGED = 1 << 25; 5484 /** {@hide} */ 5485 public static final int COLOR_MODE_CHANGED = 1 << 26; 5486 /** {@hide} */ 5487 public static final int INSET_FLAGS_CHANGED = 1 << 27; 5488 /** {@hide} */ 5489 public static final int MINIMAL_POST_PROCESSING_PREFERENCE_CHANGED = 1 << 28; 5490 /** {@hide} */ 5491 public static final int BLUR_BEHIND_RADIUS_CHANGED = 1 << 29; 5492 /** {@hide} */ 5493 public static final int PREFERRED_MIN_DISPLAY_REFRESH_RATE = 1 << 30; 5494 /** {@hide} */ 5495 public static final int PREFERRED_MAX_DISPLAY_REFRESH_RATE = 1 << 31; 5496 5497 // internal buffer to backup/restore parameters under compatibility mode. 5498 private int[] mCompatibilityParamsBackup = null; 5499 copyFrom(LayoutParams o)5500 public final int copyFrom(LayoutParams o) { 5501 int changes = 0; 5502 5503 if (width != o.width) { 5504 width = o.width; 5505 changes |= LAYOUT_CHANGED; 5506 } 5507 if (height != o.height) { 5508 height = o.height; 5509 changes |= LAYOUT_CHANGED; 5510 } 5511 if (x != o.x) { 5512 x = o.x; 5513 changes |= LAYOUT_CHANGED; 5514 } 5515 if (y != o.y) { 5516 y = o.y; 5517 changes |= LAYOUT_CHANGED; 5518 } 5519 if (horizontalWeight != o.horizontalWeight) { 5520 horizontalWeight = o.horizontalWeight; 5521 changes |= LAYOUT_CHANGED; 5522 } 5523 if (verticalWeight != o.verticalWeight) { 5524 verticalWeight = o.verticalWeight; 5525 changes |= LAYOUT_CHANGED; 5526 } 5527 if (horizontalMargin != o.horizontalMargin) { 5528 horizontalMargin = o.horizontalMargin; 5529 changes |= LAYOUT_CHANGED; 5530 } 5531 if (verticalMargin != o.verticalMargin) { 5532 verticalMargin = o.verticalMargin; 5533 changes |= LAYOUT_CHANGED; 5534 } 5535 if (type != o.type) { 5536 type = o.type; 5537 changes |= TYPE_CHANGED; 5538 } 5539 if (flags != o.flags) { 5540 final int diff = flags ^ o.flags; 5541 if ((diff & (FLAG_TRANSLUCENT_STATUS | FLAG_TRANSLUCENT_NAVIGATION)) != 0) { 5542 changes |= TRANSLUCENT_FLAGS_CHANGED; 5543 } 5544 flags = o.flags; 5545 changes |= FLAGS_CHANGED; 5546 } 5547 if (privateFlags != o.privateFlags) { 5548 privateFlags = o.privateFlags; 5549 changes |= PRIVATE_FLAGS_CHANGED; 5550 } 5551 if (softInputMode != o.softInputMode) { 5552 softInputMode = o.softInputMode; 5553 changes |= SOFT_INPUT_MODE_CHANGED; 5554 } 5555 if (layoutInDisplayCutoutMode != o.layoutInDisplayCutoutMode) { 5556 layoutInDisplayCutoutMode = o.layoutInDisplayCutoutMode; 5557 changes |= LAYOUT_CHANGED; 5558 } 5559 if (gravity != o.gravity) { 5560 gravity = o.gravity; 5561 changes |= LAYOUT_CHANGED; 5562 } 5563 if (format != o.format) { 5564 format = o.format; 5565 changes |= FORMAT_CHANGED; 5566 } 5567 if (windowAnimations != o.windowAnimations) { 5568 windowAnimations = o.windowAnimations; 5569 changes |= ANIMATION_CHANGED; 5570 } 5571 if (token == null) { 5572 // NOTE: token only copied if the recipient doesn't 5573 // already have one. 5574 token = o.token; 5575 } 5576 if (mWindowContextToken == null) { 5577 // NOTE: token only copied if the recipient doesn't 5578 // already have one. 5579 mWindowContextToken = o.mWindowContextToken; 5580 } 5581 if (packageName == null) { 5582 // NOTE: packageName only copied if the recipient doesn't 5583 // already have one. 5584 packageName = o.packageName; 5585 } 5586 if (!Objects.equals(mTitle, o.mTitle) && o.mTitle != null) { 5587 // NOTE: mTitle only copied if the originator set one. 5588 mTitle = o.mTitle; 5589 changes |= TITLE_CHANGED; 5590 } 5591 if (alpha != o.alpha) { 5592 alpha = o.alpha; 5593 changes |= ALPHA_CHANGED; 5594 } 5595 if (dimAmount != o.dimAmount) { 5596 dimAmount = o.dimAmount; 5597 changes |= DIM_AMOUNT_CHANGED; 5598 } 5599 if (screenBrightness != o.screenBrightness) { 5600 screenBrightness = o.screenBrightness; 5601 changes |= SCREEN_BRIGHTNESS_CHANGED; 5602 } 5603 if (buttonBrightness != o.buttonBrightness) { 5604 buttonBrightness = o.buttonBrightness; 5605 changes |= BUTTON_BRIGHTNESS_CHANGED; 5606 } 5607 if (rotationAnimation != o.rotationAnimation) { 5608 rotationAnimation = o.rotationAnimation; 5609 changes |= ROTATION_ANIMATION_CHANGED; 5610 } 5611 5612 if (screenOrientation != o.screenOrientation) { 5613 screenOrientation = o.screenOrientation; 5614 changes |= SCREEN_ORIENTATION_CHANGED; 5615 } 5616 5617 if (preferredRefreshRate != o.preferredRefreshRate) { 5618 preferredRefreshRate = o.preferredRefreshRate; 5619 changes |= PREFERRED_REFRESH_RATE_CHANGED; 5620 } 5621 5622 if (preferredDisplayModeId != o.preferredDisplayModeId) { 5623 preferredDisplayModeId = o.preferredDisplayModeId; 5624 changes |= PREFERRED_DISPLAY_MODE_ID; 5625 } 5626 5627 if (preferredMinDisplayRefreshRate != o.preferredMinDisplayRefreshRate) { 5628 preferredMinDisplayRefreshRate = o.preferredMinDisplayRefreshRate; 5629 changes |= PREFERRED_MIN_DISPLAY_REFRESH_RATE; 5630 } 5631 5632 if (preferredMaxDisplayRefreshRate != o.preferredMaxDisplayRefreshRate) { 5633 preferredMaxDisplayRefreshRate = o.preferredMaxDisplayRefreshRate; 5634 changes |= PREFERRED_MAX_DISPLAY_REFRESH_RATE; 5635 } 5636 5637 if (mDisplayFlags != o.mDisplayFlags) { 5638 mDisplayFlags = o.mDisplayFlags; 5639 changes |= DISPLAY_FLAGS_CHANGED; 5640 } 5641 5642 if (systemUiVisibility != o.systemUiVisibility 5643 || subtreeSystemUiVisibility != o.subtreeSystemUiVisibility) { 5644 systemUiVisibility = o.systemUiVisibility; 5645 subtreeSystemUiVisibility = o.subtreeSystemUiVisibility; 5646 changes |= SYSTEM_UI_VISIBILITY_CHANGED; 5647 } 5648 5649 if (hasSystemUiListeners != o.hasSystemUiListeners) { 5650 hasSystemUiListeners = o.hasSystemUiListeners; 5651 changes |= SYSTEM_UI_LISTENER_CHANGED; 5652 } 5653 5654 if (inputFeatures != o.inputFeatures) { 5655 inputFeatures = o.inputFeatures; 5656 changes |= INPUT_FEATURES_CHANGED; 5657 } 5658 5659 if (userActivityTimeout != o.userActivityTimeout) { 5660 userActivityTimeout = o.userActivityTimeout; 5661 changes |= USER_ACTIVITY_TIMEOUT_CHANGED; 5662 } 5663 5664 if (!surfaceInsets.equals(o.surfaceInsets)) { 5665 surfaceInsets.set(o.surfaceInsets); 5666 changes |= SURFACE_INSETS_CHANGED; 5667 } 5668 5669 if (hasManualSurfaceInsets != o.hasManualSurfaceInsets) { 5670 hasManualSurfaceInsets = o.hasManualSurfaceInsets; 5671 changes |= SURFACE_INSETS_CHANGED; 5672 } 5673 5674 if (receiveInsetsIgnoringZOrder != o.receiveInsetsIgnoringZOrder) { 5675 receiveInsetsIgnoringZOrder = o.receiveInsetsIgnoringZOrder; 5676 changes |= SURFACE_INSETS_CHANGED; 5677 } 5678 5679 if (preservePreviousSurfaceInsets != o.preservePreviousSurfaceInsets) { 5680 preservePreviousSurfaceInsets = o.preservePreviousSurfaceInsets; 5681 changes |= SURFACE_INSETS_CHANGED; 5682 } 5683 5684 if (accessibilityIdOfAnchor != o.accessibilityIdOfAnchor) { 5685 accessibilityIdOfAnchor = o.accessibilityIdOfAnchor; 5686 changes |= ACCESSIBILITY_ANCHOR_CHANGED; 5687 } 5688 5689 if (!Objects.equals(accessibilityTitle, o.accessibilityTitle) 5690 && o.accessibilityTitle != null) { 5691 // NOTE: accessibilityTitle only copied if the originator set one. 5692 accessibilityTitle = o.accessibilityTitle; 5693 changes |= ACCESSIBILITY_TITLE_CHANGED; 5694 } 5695 5696 if (mColorMode != o.mColorMode) { 5697 mColorMode = o.mColorMode; 5698 changes |= COLOR_MODE_CHANGED; 5699 } 5700 5701 if (mDesiredHdrHeadroom != o.mDesiredHdrHeadroom) { 5702 mDesiredHdrHeadroom = o.mDesiredHdrHeadroom; 5703 changes |= COLOR_MODE_CHANGED; 5704 } 5705 5706 if (preferMinimalPostProcessing != o.preferMinimalPostProcessing) { 5707 preferMinimalPostProcessing = o.preferMinimalPostProcessing; 5708 changes |= MINIMAL_POST_PROCESSING_PREFERENCE_CHANGED; 5709 } 5710 5711 if (mBlurBehindRadius != o.mBlurBehindRadius) { 5712 mBlurBehindRadius = o.mBlurBehindRadius; 5713 changes |= BLUR_BEHIND_RADIUS_CHANGED; 5714 } 5715 5716 // This can't change, it's only set at window creation time. 5717 hideTimeoutMilliseconds = o.hideTimeoutMilliseconds; 5718 5719 if (insetsFlags.appearance != o.insetsFlags.appearance) { 5720 insetsFlags.appearance = o.insetsFlags.appearance; 5721 changes |= INSET_FLAGS_CHANGED; 5722 } 5723 5724 if (insetsFlags.behavior != o.insetsFlags.behavior) { 5725 insetsFlags.behavior = o.insetsFlags.behavior; 5726 changes |= INSET_FLAGS_CHANGED; 5727 } 5728 5729 if (mFitInsetsTypes != o.mFitInsetsTypes) { 5730 mFitInsetsTypes = o.mFitInsetsTypes; 5731 changes |= LAYOUT_CHANGED; 5732 } 5733 5734 if (mFitInsetsSides != o.mFitInsetsSides) { 5735 mFitInsetsSides = o.mFitInsetsSides; 5736 changes |= LAYOUT_CHANGED; 5737 } 5738 5739 if (mFitInsetsIgnoringVisibility != o.mFitInsetsIgnoringVisibility) { 5740 mFitInsetsIgnoringVisibility = o.mFitInsetsIgnoringVisibility; 5741 changes |= LAYOUT_CHANGED; 5742 } 5743 5744 if (!Arrays.equals(providedInsets, o.providedInsets)) { 5745 providedInsets = o.providedInsets; 5746 changes |= LAYOUT_CHANGED; 5747 } 5748 5749 if (forciblyShownTypes != o.forciblyShownTypes) { 5750 forciblyShownTypes = o.forciblyShownTypes; 5751 changes |= PRIVATE_FLAGS_CHANGED; 5752 } 5753 5754 if (paramsForRotation != o.paramsForRotation) { 5755 if ((changes & LAYOUT_CHANGED) == 0) { 5756 if (paramsForRotation != null && o.paramsForRotation != null 5757 && paramsForRotation.length == o.paramsForRotation.length) { 5758 for (int i = paramsForRotation.length - 1; i >= 0; i--) { 5759 if (hasLayoutDiff(paramsForRotation[i], o.paramsForRotation[i])) { 5760 changes |= LAYOUT_CHANGED; 5761 break; 5762 } 5763 } 5764 } else { 5765 changes |= LAYOUT_CHANGED; 5766 } 5767 } 5768 paramsForRotation = o.paramsForRotation; 5769 checkNonRecursiveParams(); 5770 } 5771 5772 if (mWallpaperTouchEventsEnabled != o.mWallpaperTouchEventsEnabled) { 5773 mWallpaperTouchEventsEnabled = o.mWallpaperTouchEventsEnabled; 5774 changes |= LAYOUT_CHANGED; 5775 } 5776 5777 if (sToolkitSetFrameRateReadOnlyFlagValue 5778 && mFrameRateBoostOnTouch != o.mFrameRateBoostOnTouch) { 5779 mFrameRateBoostOnTouch = o.mFrameRateBoostOnTouch; 5780 changes |= LAYOUT_CHANGED; 5781 } 5782 5783 if (sToolkitSetFrameRateReadOnlyFlagValue 5784 && mIsFrameRatePowerSavingsBalanced != o.mIsFrameRatePowerSavingsBalanced) { 5785 mIsFrameRatePowerSavingsBalanced = o.mIsFrameRatePowerSavingsBalanced; 5786 changes |= LAYOUT_CHANGED; 5787 } 5788 5789 return changes; 5790 } 5791 5792 /** 5793 * Returns {@code true} if the 2 params may have difference results of 5794 * {@link WindowLayout#computeFrames}. 5795 */ hasLayoutDiff(LayoutParams a, LayoutParams b)5796 private static boolean hasLayoutDiff(LayoutParams a, LayoutParams b) { 5797 return a.width != b.width || a.height != b.height || a.x != b.x || a.y != b.y 5798 || a.horizontalMargin != b.horizontalMargin 5799 || a.verticalMargin != b.verticalMargin 5800 || a.layoutInDisplayCutoutMode != b.layoutInDisplayCutoutMode 5801 || a.gravity != b.gravity || !Arrays.equals(a.providedInsets, b.providedInsets) 5802 || a.mFitInsetsTypes != b.mFitInsetsTypes 5803 || a.mFitInsetsSides != b.mFitInsetsSides 5804 || a.mFitInsetsIgnoringVisibility != b.mFitInsetsIgnoringVisibility; 5805 } 5806 5807 @Override debug(String output)5808 public String debug(String output) { 5809 output += "Contents of " + this + ":"; 5810 Log.d("Debug", output); 5811 output = super.debug(""); 5812 Log.d("Debug", output); 5813 Log.d("Debug", ""); 5814 Log.d("Debug", "WindowManager.LayoutParams={title=" + mTitle + "}"); 5815 return ""; 5816 } 5817 5818 @Override toString()5819 public String toString() { 5820 return toString(""); 5821 } 5822 5823 /** 5824 * @hide 5825 */ dumpDimensions(StringBuilder sb)5826 public void dumpDimensions(StringBuilder sb) { 5827 sb.append('('); 5828 sb.append(x); 5829 sb.append(','); 5830 sb.append(y); 5831 sb.append(")("); 5832 sb.append((width == MATCH_PARENT ? "fill" : (width == WRAP_CONTENT 5833 ? "wrap" : String.valueOf(width)))); 5834 sb.append('x'); 5835 sb.append((height == MATCH_PARENT ? "fill" : (height == WRAP_CONTENT 5836 ? "wrap" : String.valueOf(height)))); 5837 sb.append(")"); 5838 } 5839 5840 /** 5841 * @hide 5842 */ toString(String prefix)5843 public String toString(String prefix) { 5844 StringBuilder sb = new StringBuilder(256); 5845 sb.append('{'); 5846 dumpDimensions(sb); 5847 if (horizontalMargin != 0) { 5848 sb.append(" hm="); 5849 sb.append(horizontalMargin); 5850 } 5851 if (verticalMargin != 0) { 5852 sb.append(" vm="); 5853 sb.append(verticalMargin); 5854 } 5855 if (gravity != 0) { 5856 sb.append(" gr="); 5857 sb.append(Gravity.toString(gravity)); 5858 } 5859 if (softInputMode != 0) { 5860 sb.append(" sim={"); 5861 sb.append(softInputModeToString(softInputMode)); 5862 sb.append('}'); 5863 } 5864 if (layoutInDisplayCutoutMode != 0) { 5865 sb.append(" layoutInDisplayCutoutMode="); 5866 sb.append(layoutInDisplayCutoutModeToString(layoutInDisplayCutoutMode)); 5867 } 5868 sb.append(" ty="); 5869 sb.append(ViewDebug.intToString(LayoutParams.class, "type", type)); 5870 if (format != PixelFormat.OPAQUE) { 5871 sb.append(" fmt="); 5872 sb.append(PixelFormat.formatToString(format)); 5873 } 5874 if (windowAnimations != 0) { 5875 sb.append(" wanim=0x"); 5876 sb.append(Integer.toHexString(windowAnimations)); 5877 } 5878 if (screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { 5879 sb.append(" or="); 5880 sb.append(ActivityInfo.screenOrientationToString(screenOrientation)); 5881 } 5882 if (alpha != 1.0f) { 5883 sb.append(" alpha="); 5884 sb.append(alpha); 5885 } 5886 if (screenBrightness != BRIGHTNESS_OVERRIDE_NONE) { 5887 sb.append(" sbrt="); 5888 sb.append(screenBrightness); 5889 } 5890 if (buttonBrightness != BRIGHTNESS_OVERRIDE_NONE) { 5891 sb.append(" bbrt="); 5892 sb.append(buttonBrightness); 5893 } 5894 if (rotationAnimation != ROTATION_ANIMATION_ROTATE) { 5895 sb.append(" rotAnim="); 5896 sb.append(rotationAnimationToString(rotationAnimation)); 5897 } 5898 if (preferredRefreshRate != 0) { 5899 sb.append(" preferredRefreshRate="); 5900 sb.append(preferredRefreshRate); 5901 } 5902 if (preferredDisplayModeId != 0) { 5903 sb.append(" preferredDisplayMode="); 5904 sb.append(preferredDisplayModeId); 5905 } 5906 if (preferredMinDisplayRefreshRate != 0) { 5907 sb.append(" preferredMinDisplayRefreshRate="); 5908 sb.append(preferredMinDisplayRefreshRate); 5909 } 5910 if (preferredMaxDisplayRefreshRate != 0) { 5911 sb.append(" preferredMaxDisplayRefreshRate="); 5912 sb.append(preferredMaxDisplayRefreshRate); 5913 } 5914 if (mDisplayFlags != 0) { 5915 sb.append(" displayFlags=0x"); 5916 sb.append(Integer.toHexString(mDisplayFlags)); 5917 } 5918 if (hasSystemUiListeners) { 5919 sb.append(" sysuil="); 5920 sb.append(hasSystemUiListeners); 5921 } 5922 if (inputFeatures != 0) { 5923 sb.append(" if=").append(inputFeaturesToString(inputFeatures)); 5924 } 5925 if (userActivityTimeout >= 0) { 5926 sb.append(" userActivityTimeout=").append(userActivityTimeout); 5927 } 5928 if (surfaceInsets.left != 0 || surfaceInsets.top != 0 || surfaceInsets.right != 0 || 5929 surfaceInsets.bottom != 0 || hasManualSurfaceInsets 5930 || !preservePreviousSurfaceInsets) { 5931 sb.append(" surfaceInsets=").append(surfaceInsets); 5932 if (hasManualSurfaceInsets) { 5933 sb.append(" (manual)"); 5934 } 5935 if (!preservePreviousSurfaceInsets) { 5936 sb.append(" (!preservePreviousSurfaceInsets)"); 5937 } 5938 } 5939 if (receiveInsetsIgnoringZOrder) { 5940 sb.append(" receive insets ignoring z-order"); 5941 } 5942 if (mColorMode != COLOR_MODE_DEFAULT) { 5943 sb.append(" colorMode=").append(ActivityInfo.colorModeToString(mColorMode)); 5944 } 5945 if (mDesiredHdrHeadroom != 0) { 5946 sb.append(" desiredHdrHeadroom=").append(mDesiredHdrHeadroom); 5947 } 5948 if (preferMinimalPostProcessing) { 5949 sb.append(" preferMinimalPostProcessing="); 5950 sb.append(preferMinimalPostProcessing); 5951 } 5952 if (mBlurBehindRadius != 0) { 5953 sb.append(" blurBehindRadius="); 5954 sb.append(mBlurBehindRadius); 5955 } 5956 sb.append(System.lineSeparator()); 5957 sb.append(prefix).append(" fl=").append( 5958 ViewDebug.flagsToString(LayoutParams.class, "flags", flags)); 5959 if (privateFlags != 0) { 5960 sb.append(System.lineSeparator()); 5961 sb.append(prefix).append(" pfl=").append(ViewDebug.flagsToString( 5962 LayoutParams.class, "privateFlags", privateFlags)); 5963 } 5964 if (systemUiVisibility != 0) { 5965 sb.append(System.lineSeparator()); 5966 sb.append(prefix).append(" sysui=").append(ViewDebug.flagsToString( 5967 View.class, "mSystemUiVisibility", systemUiVisibility)); 5968 } 5969 if (subtreeSystemUiVisibility != 0) { 5970 sb.append(System.lineSeparator()); 5971 sb.append(prefix).append(" vsysui=").append(ViewDebug.flagsToString( 5972 View.class, "mSystemUiVisibility", subtreeSystemUiVisibility)); 5973 } 5974 if (insetsFlags.appearance != 0) { 5975 sb.append(System.lineSeparator()); 5976 sb.append(prefix).append(" apr=").append(ViewDebug.flagsToString( 5977 InsetsFlags.class, "appearance", insetsFlags.appearance)); 5978 } 5979 if (insetsFlags.behavior != 0) { 5980 sb.append(System.lineSeparator()); 5981 sb.append(prefix).append(" bhv=").append(ViewDebug.flagsToString( 5982 InsetsFlags.class, "behavior", insetsFlags.behavior)); 5983 } 5984 if (mFitInsetsTypes != 0) { 5985 sb.append(System.lineSeparator()); 5986 sb.append(prefix).append(" fitTypes=").append(ViewDebug.flagsToString( 5987 LayoutParams.class, "mFitInsetsTypes", mFitInsetsTypes)); 5988 } 5989 if (mFitInsetsSides != Side.all()) { 5990 sb.append(System.lineSeparator()); 5991 sb.append(prefix).append(" fitSides=").append(ViewDebug.flagsToString( 5992 LayoutParams.class, "mFitInsetsSides", mFitInsetsSides)); 5993 } 5994 if (mFitInsetsIgnoringVisibility) { 5995 sb.append(System.lineSeparator()); 5996 sb.append(prefix).append(" fitIgnoreVis"); 5997 } 5998 if (providedInsets != null) { 5999 sb.append(System.lineSeparator()); 6000 sb.append(prefix).append(" providedInsets:"); 6001 for (int i = 0; i < providedInsets.length; ++i) { 6002 sb.append(System.lineSeparator()); 6003 sb.append(prefix).append(" ").append(providedInsets[i]); 6004 } 6005 } 6006 if (forciblyShownTypes != 0) { 6007 sb.append(System.lineSeparator()); 6008 sb.append(prefix).append(" forciblyShownTypes=").append( 6009 WindowInsets.Type.toString(forciblyShownTypes)); 6010 } 6011 if (sToolkitSetFrameRateReadOnlyFlagValue && mFrameRateBoostOnTouch) { 6012 sb.append(System.lineSeparator()); 6013 sb.append(prefix).append(" frameRateBoostOnTouch="); 6014 sb.append(mFrameRateBoostOnTouch); 6015 } 6016 if (sToolkitSetFrameRateReadOnlyFlagValue && mIsFrameRatePowerSavingsBalanced) { 6017 sb.append(System.lineSeparator()); 6018 sb.append(prefix).append(" dvrrWindowFrameRateHint="); 6019 sb.append(mIsFrameRatePowerSavingsBalanced); 6020 } 6021 if (paramsForRotation != null && paramsForRotation.length != 0) { 6022 sb.append(System.lineSeparator()); 6023 sb.append(prefix).append(" paramsForRotation:"); 6024 for (int i = 0; i < paramsForRotation.length; ++i) { 6025 // Additional prefix needed for the beginning of the params of the new rotation. 6026 sb.append(System.lineSeparator()).append(prefix).append(" "); 6027 sb.append(Surface.rotationToString(i)).append("="); 6028 sb.append(paramsForRotation[i].toString(prefix + " ")); 6029 } 6030 } 6031 6032 sb.append('}'); 6033 return sb.toString(); 6034 } 6035 6036 /** 6037 * @hide 6038 */ dumpDebug(ProtoOutputStream proto, long fieldId)6039 public void dumpDebug(ProtoOutputStream proto, long fieldId) { 6040 final long token = proto.start(fieldId); 6041 proto.write(TYPE, type); 6042 proto.write(X, x); 6043 proto.write(Y, y); 6044 proto.write(WIDTH, width); 6045 proto.write(HEIGHT, height); 6046 proto.write(HORIZONTAL_MARGIN, horizontalMargin); 6047 proto.write(VERTICAL_MARGIN, verticalMargin); 6048 proto.write(GRAVITY, gravity); 6049 proto.write(SOFT_INPUT_MODE, softInputMode); 6050 proto.write(FORMAT, format); 6051 proto.write(WINDOW_ANIMATIONS, windowAnimations); 6052 proto.write(ALPHA, alpha); 6053 proto.write(SCREEN_BRIGHTNESS, screenBrightness); 6054 proto.write(BUTTON_BRIGHTNESS, buttonBrightness); 6055 proto.write(ROTATION_ANIMATION, rotationAnimation); 6056 proto.write(PREFERRED_REFRESH_RATE, preferredRefreshRate); 6057 proto.write(WindowLayoutParamsProto.PREFERRED_DISPLAY_MODE_ID, preferredDisplayModeId); 6058 proto.write(HAS_SYSTEM_UI_LISTENERS, hasSystemUiListeners); 6059 proto.write(INPUT_FEATURE_FLAGS, inputFeatures); 6060 proto.write(USER_ACTIVITY_TIMEOUT, userActivityTimeout); 6061 proto.write(COLOR_MODE, mColorMode); 6062 proto.write(FLAGS, flags); 6063 proto.write(PRIVATE_FLAGS, privateFlags); 6064 proto.write(SYSTEM_UI_VISIBILITY_FLAGS, systemUiVisibility); 6065 proto.write(SUBTREE_SYSTEM_UI_VISIBILITY_FLAGS, subtreeSystemUiVisibility); 6066 proto.write(APPEARANCE, insetsFlags.appearance); 6067 proto.write(BEHAVIOR, insetsFlags.behavior); 6068 proto.write(FIT_INSETS_TYPES, mFitInsetsTypes); 6069 proto.write(FIT_INSETS_SIDES, mFitInsetsSides); 6070 proto.write(FIT_IGNORE_VISIBILITY, mFitInsetsIgnoringVisibility); 6071 proto.end(token); 6072 } 6073 6074 /** 6075 * Scale the layout params' coordinates and size. 6076 * @hide 6077 */ scale(float scale)6078 public void scale(float scale) { 6079 x = (int) (x * scale + 0.5f); 6080 y = (int) (y * scale + 0.5f); 6081 if (width > 0) { 6082 width = (int) (width * scale + 0.5f); 6083 } 6084 if (height > 0) { 6085 height = (int) (height * scale + 0.5f); 6086 } 6087 } 6088 6089 /** 6090 * Backup the layout parameters used in compatibility mode. 6091 * @see LayoutParams#restore() 6092 */ 6093 @UnsupportedAppUsage backup()6094 void backup() { 6095 int[] backup = mCompatibilityParamsBackup; 6096 if (backup == null) { 6097 // we backup 4 elements, x, y, width, height 6098 backup = mCompatibilityParamsBackup = new int[4]; 6099 } 6100 backup[0] = x; 6101 backup[1] = y; 6102 backup[2] = width; 6103 backup[3] = height; 6104 } 6105 6106 /** 6107 * Restore the layout params' coordinates, size and gravity 6108 * @see LayoutParams#backup() 6109 */ 6110 @UnsupportedAppUsage restore()6111 void restore() { 6112 int[] backup = mCompatibilityParamsBackup; 6113 if (backup != null) { 6114 x = backup[0]; 6115 y = backup[1]; 6116 width = backup[2]; 6117 height = backup[3]; 6118 } 6119 } 6120 6121 private CharSequence mTitle = null; 6122 6123 /** @hide */ 6124 @Override encodeProperties(@onNull ViewHierarchyEncoder encoder)6125 protected void encodeProperties(@NonNull ViewHierarchyEncoder encoder) { 6126 super.encodeProperties(encoder); 6127 6128 encoder.addProperty("x", x); 6129 encoder.addProperty("y", y); 6130 encoder.addProperty("horizontalWeight", horizontalWeight); 6131 encoder.addProperty("verticalWeight", verticalWeight); 6132 encoder.addProperty("type", type); 6133 encoder.addProperty("flags", flags); 6134 } 6135 6136 /** 6137 * @hide 6138 * @return True if the layout parameters will cause the window to cover the full screen; 6139 * false otherwise. 6140 */ isFullscreen()6141 public boolean isFullscreen() { 6142 return x == 0 && y == 0 6143 && width == WindowManager.LayoutParams.MATCH_PARENT 6144 && height == WindowManager.LayoutParams.MATCH_PARENT; 6145 } 6146 6147 /** 6148 * @hide 6149 */ layoutInDisplayCutoutModeToString( @ayoutInDisplayCutoutMode int mode)6150 public static String layoutInDisplayCutoutModeToString( 6151 @LayoutInDisplayCutoutMode int mode) { 6152 switch (mode) { 6153 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT: 6154 return "default"; 6155 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS: 6156 return "always"; 6157 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER: 6158 return "never"; 6159 case LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES: 6160 return "shortEdges"; 6161 default: 6162 return "unknown(" + mode + ")"; 6163 } 6164 } 6165 softInputModeToString(@oftInputModeFlags int softInputMode)6166 private static String softInputModeToString(@SoftInputModeFlags int softInputMode) { 6167 final StringBuilder result = new StringBuilder(); 6168 final int state = softInputMode & SOFT_INPUT_MASK_STATE; 6169 if (state != 0) { 6170 result.append("state="); 6171 switch (state) { 6172 case SOFT_INPUT_STATE_UNCHANGED: 6173 result.append("unchanged"); 6174 break; 6175 case SOFT_INPUT_STATE_HIDDEN: 6176 result.append("hidden"); 6177 break; 6178 case SOFT_INPUT_STATE_ALWAYS_HIDDEN: 6179 result.append("always_hidden"); 6180 break; 6181 case SOFT_INPUT_STATE_VISIBLE: 6182 result.append("visible"); 6183 break; 6184 case SOFT_INPUT_STATE_ALWAYS_VISIBLE: 6185 result.append("always_visible"); 6186 break; 6187 default: 6188 result.append(state); 6189 break; 6190 } 6191 result.append(' '); 6192 } 6193 final int adjust = softInputMode & SOFT_INPUT_MASK_ADJUST; 6194 if (adjust != 0) { 6195 result.append("adjust="); 6196 switch (adjust) { 6197 case SOFT_INPUT_ADJUST_RESIZE: 6198 result.append("resize"); 6199 break; 6200 case SOFT_INPUT_ADJUST_PAN: 6201 result.append("pan"); 6202 break; 6203 case SOFT_INPUT_ADJUST_NOTHING: 6204 result.append("nothing"); 6205 break; 6206 default: 6207 result.append(adjust); 6208 break; 6209 } 6210 result.append(' '); 6211 } 6212 if ((softInputMode & SOFT_INPUT_IS_FORWARD_NAVIGATION) != 0) { 6213 result.append("forwardNavigation").append(' '); 6214 } 6215 result.deleteCharAt(result.length() - 1); 6216 return result.toString(); 6217 } 6218 rotationAnimationToString(int rotationAnimation)6219 private static String rotationAnimationToString(int rotationAnimation) { 6220 switch (rotationAnimation) { 6221 case ROTATION_ANIMATION_UNSPECIFIED: 6222 return "UNSPECIFIED"; 6223 case ROTATION_ANIMATION_ROTATE: 6224 return "ROTATE"; 6225 case ROTATION_ANIMATION_CROSSFADE: 6226 return "CROSSFADE"; 6227 case ROTATION_ANIMATION_JUMPCUT: 6228 return "JUMPCUT"; 6229 case ROTATION_ANIMATION_SEAMLESS: 6230 return "SEAMLESS"; 6231 default: 6232 return Integer.toString(rotationAnimation); 6233 } 6234 } 6235 inputFeaturesToString(int inputFeatures)6236 private static String inputFeaturesToString(int inputFeatures) { 6237 final List<String> features = new ArrayList<>(); 6238 if ((inputFeatures & INPUT_FEATURE_NO_INPUT_CHANNEL) != 0) { 6239 inputFeatures &= ~INPUT_FEATURE_NO_INPUT_CHANNEL; 6240 features.add("INPUT_FEATURE_NO_INPUT_CHANNEL"); 6241 } 6242 if ((inputFeatures & INPUT_FEATURE_DISABLE_USER_ACTIVITY) != 0) { 6243 inputFeatures &= ~INPUT_FEATURE_DISABLE_USER_ACTIVITY; 6244 features.add("INPUT_FEATURE_DISABLE_USER_ACTIVITY"); 6245 } 6246 if ((inputFeatures & INPUT_FEATURE_SPY) != 0) { 6247 inputFeatures &= ~INPUT_FEATURE_SPY; 6248 features.add("INPUT_FEATURE_SPY"); 6249 } 6250 if (inputFeatures != 0) { 6251 features.add(Integer.toHexString(inputFeatures)); 6252 } 6253 return String.join(" | ", features); 6254 } 6255 6256 /** 6257 * True if the window should consume all pointer events itself, regardless of whether they 6258 * are inside of the window. If the window is modal, its touchable region will expand to the 6259 * size of its task. 6260 * @hide 6261 */ isModal()6262 public boolean isModal() { 6263 return (flags & (FLAG_NOT_TOUCH_MODAL | FLAG_NOT_FOCUSABLE)) == 0; 6264 } 6265 } 6266 6267 /** 6268 * Specifies the parameters of the insets provided by a window. 6269 * 6270 * @see WindowManager.LayoutParams#setInsetsParams(List) 6271 * @see android.graphics.Insets 6272 * 6273 * @hide 6274 */ 6275 @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_STATUS_BAR_AND_INSETS) 6276 @SystemApi 6277 public static class InsetsParams { 6278 6279 private final @InsetsType int mType; 6280 private @Nullable Insets mInsets; 6281 6282 /** 6283 * Creates an instance of InsetsParams. 6284 * 6285 * @param type the type of insets to provide, e.g. {@link WindowInsets.Type#statusBars()}. 6286 * @see WindowInsets.Type 6287 */ InsetsParams(@nsetsType int type)6288 public InsetsParams(@InsetsType int type) { 6289 mType = type; 6290 } 6291 6292 /** 6293 * Sets the size of the provided insets. If {@code null}, then the provided insets will 6294 * have the same size as the window frame. 6295 */ setInsetsSize(@ullable Insets insets)6296 public @NonNull InsetsParams setInsetsSize(@Nullable Insets insets) { 6297 mInsets = insets; 6298 return this; 6299 } 6300 6301 /** 6302 * Returns the type of provided insets. 6303 */ getType()6304 public @InsetsType int getType() { 6305 return mType; 6306 } 6307 6308 /** 6309 * Returns the size of the provided insets. May be {@code null} if the provided insets have 6310 * the same size as the window frame. 6311 */ getInsetsSize()6312 public @Nullable Insets getInsetsSize() { 6313 return mInsets; 6314 } 6315 } 6316 6317 /** 6318 * Holds the WM lock for the specified amount of milliseconds. 6319 * Intended for use by the tests that need to imitate lock contention. 6320 * The token should be obtained by 6321 * {@link android.content.pm.PackageManager#getHoldLockToken()}. 6322 * @hide 6323 */ 6324 @TestApi holdLock(IBinder token, int durationMs)6325 default void holdLock(IBinder token, int durationMs) { 6326 throw new UnsupportedOperationException(); 6327 } 6328 6329 /** 6330 * Used for testing to check if the system supports TaskSnapshot mechanism. 6331 * @hide 6332 */ 6333 @TestApi isTaskSnapshotSupported()6334 default boolean isTaskSnapshotSupported() { 6335 return false; 6336 } 6337 6338 /** 6339 * Registers the frame rate per second count callback for one given task ID. 6340 * Each callback can only register for receiving FPS callback for one task id until unregister 6341 * is called. If there's no task associated with the given task id, 6342 * {@link IllegalArgumentException} will be thrown. Registered callbacks should always be 6343 * unregistered via {@link #unregisterTaskFpsCallback(TaskFpsCallback)} 6344 * even when the task id has been destroyed. 6345 * 6346 * @param taskId task id of the task. 6347 * @param executor Executor to execute the callback. 6348 * @param callback callback to be registered. 6349 * 6350 * @hide 6351 */ 6352 @SystemApi registerTaskFpsCallback(@ntRangefrom = 0) int taskId, @NonNull Executor executor, @NonNull TaskFpsCallback callback)6353 default void registerTaskFpsCallback(@IntRange(from = 0) int taskId, 6354 @NonNull Executor executor, 6355 @NonNull TaskFpsCallback callback) {} 6356 6357 /** 6358 * Unregisters the frame rate per second count callback which was registered with 6359 * {@link #registerTaskFpsCallback(Executor, int, TaskFpsCallback)}. 6360 * 6361 * @param callback callback to be unregistered. 6362 * 6363 * @hide 6364 */ 6365 @SystemApi unregisterTaskFpsCallback(@onNull TaskFpsCallback callback)6366 default void unregisterTaskFpsCallback(@NonNull TaskFpsCallback callback) {} 6367 6368 /** 6369 * Take a snapshot using the same path that's used for Recents. This is used for Testing only. 6370 * 6371 * @param taskId to take the snapshot of 6372 * 6373 * @return a bitmap of the screenshot or {@code null} if it was unable to screenshot. The 6374 * screenshot can fail if the taskId is invalid or if there's no SurfaceControl associated with 6375 * that task. 6376 * 6377 * @hide 6378 */ 6379 @TestApi 6380 @Nullable snapshotTaskForRecents(@ntRangefrom = 0) int taskId)6381 default Bitmap snapshotTaskForRecents(@IntRange(from = 0) int taskId) { 6382 return null; 6383 } 6384 6385 /** 6386 * Invoked when a screenshot is taken of the default display to notify registered listeners. 6387 * 6388 * Should be invoked only by SysUI. 6389 * 6390 * @param displayId id of the display screenshot. 6391 * @return List of ComponentNames corresponding to the activities that were notified. 6392 * @hide 6393 */ 6394 @SystemApi notifyScreenshotListeners(int displayId)6395 default @NonNull List<ComponentName> notifyScreenshotListeners(int displayId) { 6396 throw new UnsupportedOperationException(); 6397 } 6398 6399 /** 6400 * @param displayId The displayId to that should have its content replaced. 6401 * @param window The window that should get mirrored and the mirrored content rendered on 6402 * displayId passed in. 6403 * 6404 * @return Whether it successfully created a mirror SurfaceControl and replaced the display 6405 * content with the mirror of the Window. 6406 * 6407 * @hide 6408 */ 6409 @SuppressLint("UnflaggedApi") // The API is only used for tests. 6410 @TestApi 6411 @RequiresPermission(permission.ACCESS_SURFACE_FLINGER) replaceContentOnDisplayWithMirror(int displayId, @NonNull Window window)6412 default boolean replaceContentOnDisplayWithMirror(int displayId, @NonNull Window window) { 6413 throw new UnsupportedOperationException(); 6414 } 6415 6416 /** 6417 * @param displayId The displayId to that should have its content replaced. 6418 * @param sc The SurfaceControl that should get rendered onto the displayId passed in. 6419 * 6420 * @return Whether it successfully created a mirror SurfaceControl and replaced the display 6421 * content with the mirror of the Window. 6422 * 6423 * @hide 6424 */ 6425 @SuppressLint("UnflaggedApi") // The API is only used for tests. 6426 @TestApi 6427 @RequiresPermission(permission.ACCESS_SURFACE_FLINGER) replaceContentOnDisplayWithSc(int displayId, @NonNull SurfaceControl sc)6428 default boolean replaceContentOnDisplayWithSc(int displayId, @NonNull SurfaceControl sc) { 6429 throw new UnsupportedOperationException(); 6430 } 6431 6432 /** 6433 * Sets a callback to receive feedback about the presentation of a {@link Window}. 6434 * When the {@link Window} is presented according to the passed in 6435 * {@link TrustedPresentationThresholds}, it is said to "enter the state", and receives the 6436 * callback with {@code true}. When the conditions fall out of thresholds, it is then 6437 * said to leave the state and the caller will receive a callback with {@code false}. The 6438 * callbacks be sent for every state transition thereafter. 6439 * <p> 6440 * There are a few simple thresholds: 6441 * <ul> 6442 * <li>minAlpha: Lower bound on computed alpha</li> 6443 * <li>minFractionRendered: Lower bounds on fraction of pixels that were rendered</li> 6444 * <li>stabilityThresholdMs: A time that alpha and fraction rendered must remain within 6445 * bounds before we can "enter the state" </li> 6446 * </ul> 6447 * <p> 6448 * The fraction of pixels rendered is a computation based on scale, crop 6449 * and occlusion. The calculation may be somewhat counterintuitive, so we 6450 * can work through an example. Imagine we have a Window with a 100x100 buffer 6451 * which is occluded by (10x100) pixels on the left, and cropped by (100x10) pixels 6452 * on the top. Furthermore imagine this Window is scaled by 0.9 in both dimensions. 6453 * (c=crop,o=occluded,b=both,x=none) 6454 * 6455 * <blockquote> 6456 * <table> 6457 * <caption></caption> 6458 * <tr><td>b</td><td>c</td><td>c</td><td>c</td></tr> 6459 * <tr><td>o</td><td>x</td><td>x</td><td>x</td></tr> 6460 * <tr><td>o</td><td>x</td><td>x</td><td>x</td></tr> 6461 * <tr><td>o</td><td>x</td><td>x</td><td>x</td></tr> 6462 * </table> 6463 * </blockquote> 6464 * 6465 *<p> 6466 * We first start by computing fr=xscale*yscale=0.9*0.9=0.81, indicating 6467 * that "81%" of the pixels were rendered. This corresponds to what was 100 6468 * pixels being displayed in 81 pixels. This is somewhat of an abuse of 6469 * language, as the information of merged pixels isn't totally lost, but 6470 * we err on the conservative side. 6471 * <p> 6472 * We then repeat a similar process for the crop and covered regions and 6473 * accumulate the results: fr = fr * (fractionNotCropped) * (fractionNotCovered) 6474 * So for this example we would get 0.9*0.9*0.9*0.9=0.65... 6475 * <p> 6476 * Notice that this is not completely accurate, as we have double counted 6477 * the region marked as b. However we only wanted a "lower bound" and so it 6478 * is ok to err in this direction. Selection of the threshold will ultimately 6479 * be somewhat arbitrary, and so there are some somewhat arbitrary decisions in 6480 * this API as well. 6481 * <p> 6482 * @param window The Window to add the trusted presentation listener for. This can be 6483 * retrieved from {@link View#getWindowToken()}. 6484 * @param thresholds The {@link TrustedPresentationThresholds} that will specify when the to 6485 * invoke the callback. 6486 * @param executor The {@link Executor} where the callback will be invoked on. 6487 * @param listener The {@link Consumer} that will receive the callbacks 6488 * when entered or exited trusted presentation per the thresholds. 6489 * @see TrustedPresentationThresholds 6490 */ 6491 @FlaggedApi(Flags.FLAG_TRUSTED_PRESENTATION_LISTENER_FOR_WINDOW) registerTrustedPresentationListener(@onNull IBinder window, @NonNull TrustedPresentationThresholds thresholds, @NonNull Executor executor, @NonNull Consumer<Boolean> listener)6492 default void registerTrustedPresentationListener(@NonNull IBinder window, 6493 @NonNull TrustedPresentationThresholds thresholds, @NonNull Executor executor, 6494 @NonNull Consumer<Boolean> listener) { 6495 throw new UnsupportedOperationException(); 6496 } 6497 6498 /** 6499 * Removes a presentation listener associated with a window. If the listener was not previously 6500 * registered, the call will be a noop. 6501 * 6502 * @see WindowManager#registerTrustedPresentationListener(IBinder, TrustedPresentationThresholds, Executor, Consumer) 6503 */ 6504 @FlaggedApi(Flags.FLAG_TRUSTED_PRESENTATION_LISTENER_FOR_WINDOW) unregisterTrustedPresentationListener(@onNull Consumer<Boolean> listener)6505 default void unregisterTrustedPresentationListener(@NonNull Consumer<Boolean> listener) { 6506 throw new UnsupportedOperationException(); 6507 } 6508 6509 /** 6510 * Registers a {@link SurfaceControlInputReceiver} for a {@link SurfaceControl} that will 6511 * receive batched input event. For those events that are batched, the invocation will happen 6512 * once per {@link Choreographer} frame, and other input events will be delivered immediately. 6513 * This is different from 6514 * {@link #registerUnbatchedSurfaceControlInputReceiver(int, InputTransferToken, SurfaceControl, 6515 * Looper, SurfaceControlInputReceiver)} in that the input events are received batched. The 6516 * caller must invoke {@link #unregisterSurfaceControlInputReceiver(SurfaceControl)} to clean up 6517 * the resources when no longer needing to use the {@link SurfaceControlInputReceiver} 6518 * 6519 * @param surfaceControl The SurfaceControl to register the InputChannel for 6520 * @param hostInputTransferToken The host token to link the embedded. This is used to handle 6521 * transferring touch gesture from host to embedded and for ANRs 6522 * to ensure the host receives the ANR if any issues with 6523 * touch on the embedded. 6524 * @param choreographer The Choreographer used for batching. This should match the 6525 * rendering Choreographer. 6526 * @param receiver The SurfaceControlInputReceiver that will receive the input 6527 * events 6528 * @return Returns the {@link InputTransferToken} that can be used to transfer touch gesture 6529 * to or from other windows. 6530 */ 6531 @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER) 6532 @NonNull registerBatchedSurfaceControlInputReceiver( @onNull InputTransferToken hostInputTransferToken, @NonNull SurfaceControl surfaceControl, @NonNull Choreographer choreographer, @NonNull SurfaceControlInputReceiver receiver)6533 default InputTransferToken registerBatchedSurfaceControlInputReceiver( 6534 @NonNull InputTransferToken hostInputTransferToken, 6535 @NonNull SurfaceControl surfaceControl, @NonNull Choreographer choreographer, 6536 @NonNull SurfaceControlInputReceiver receiver) { 6537 throw new UnsupportedOperationException( 6538 "registerBatchedSurfaceControlInputReceiver is not implemented"); 6539 } 6540 6541 /** 6542 * Registers a {@link SurfaceControlInputReceiver} for a {@link SurfaceControl} that will 6543 * receive every input event. This is different than calling 6544 * {@link #registerBatchedSurfaceControlInputReceiver(InputTransferToken, SurfaceControl, 6545 * Choreographer, SurfaceControlInputReceiver)} in that the input events are received 6546 * unbatched. 6547 * The caller must invoke {@link #unregisterSurfaceControlInputReceiver(SurfaceControl)} to 6548 * clean up the resources when no longer needing to use the {@link SurfaceControlInputReceiver} 6549 * 6550 * @param surfaceControl The SurfaceControl to register the InputChannel for 6551 * @param hostInputTransferToken The host token to link the embedded. This is used to handle 6552 * transferring touch gesture from host to embedded and for ANRs 6553 * to ensure the host receives the ANR if any issues with 6554 * touch on the embedded. 6555 * @param looper The looper to use when invoking callbacks. 6556 * @param receiver The SurfaceControlInputReceiver that will receive the input 6557 * events. 6558 * @return Returns the {@link InputTransferToken} that can be used to transfer touch gesture 6559 * to or from other windows. 6560 */ 6561 @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER) 6562 @NonNull registerUnbatchedSurfaceControlInputReceiver( @onNull InputTransferToken hostInputTransferToken, @NonNull SurfaceControl surfaceControl, @NonNull Looper looper, @NonNull SurfaceControlInputReceiver receiver)6563 default InputTransferToken registerUnbatchedSurfaceControlInputReceiver( 6564 @NonNull InputTransferToken hostInputTransferToken, 6565 @NonNull SurfaceControl surfaceControl, @NonNull Looper looper, 6566 @NonNull SurfaceControlInputReceiver receiver) { 6567 throw new UnsupportedOperationException( 6568 "registerUnbatchedSurfaceControlInputReceiver is not implemented"); 6569 } 6570 6571 /** 6572 * Unregisters and cleans up the registered {@link SurfaceControlInputReceiver} for the 6573 * specified token. 6574 * <p> 6575 * Must be called on the same {@link Looper} thread to which was passed to the 6576 * {@link #registerBatchedSurfaceControlInputReceiver(InputTransferToken, SurfaceControl, 6577 * Choreographer, SurfaceControlInputReceiver)} or 6578 * {@link #registerUnbatchedSurfaceControlInputReceiver(InputTransferToken, SurfaceControl, 6579 * Looper, SurfaceControlInputReceiver)} 6580 * 6581 * @param surfaceControl The SurfaceControl to remove and unregister the input channel for. 6582 */ 6583 @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER) unregisterSurfaceControlInputReceiver(@onNull SurfaceControl surfaceControl)6584 default void unregisterSurfaceControlInputReceiver(@NonNull SurfaceControl surfaceControl) { 6585 throw new UnsupportedOperationException( 6586 "unregisterSurfaceControlInputReceiver is not implemented"); 6587 } 6588 6589 /** 6590 * Returns the input client token for the {@link SurfaceControl}. This will only return non 6591 * null if the SurfaceControl was registered for input via 6592 * {@link #registerBatchedSurfaceControlInputReceiver(InputTransferToken, SurfaceControl, 6593 * Choreographer, SurfaceControlInputReceiver)} or 6594 * {@link #registerUnbatchedSurfaceControlInputReceiver(InputTransferToken, 6595 * SurfaceControl, Looper, SurfaceControlInputReceiver)}. 6596 * <p> 6597 * This is helpful for testing to ensure the test waits for the layer to be registered with 6598 * SurfaceFlinger and Input before proceeding with the test. 6599 * 6600 * @hide 6601 */ 6602 @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER) 6603 @TestApi 6604 @Nullable getSurfaceControlInputClientToken(@onNull SurfaceControl surfaceControl)6605 default IBinder getSurfaceControlInputClientToken(@NonNull SurfaceControl surfaceControl) { 6606 throw new UnsupportedOperationException( 6607 "getSurfaceControlInputClientToken is not implemented"); 6608 } 6609 6610 /** 6611 * Transfer the currently in progress touch gesture from the transferFromToken to the 6612 * transferToToken. 6613 * <p><br> 6614 * This requires that the fromToken and toToken are associated with each other. The association 6615 * can be done different ways, depending on how the embedded window is created. 6616 * <ul> 6617 * <li> 6618 * Creating a {@link SurfaceControlViewHost} and passing the host's 6619 * {@link InputTransferToken} for 6620 * {@link SurfaceControlViewHost#SurfaceControlViewHost(Context, Display, InputTransferToken)}. 6621 * </li> 6622 * <li> 6623 * Registering a SurfaceControl for input and passing the host's token to either 6624 * {@link #registerBatchedSurfaceControlInputReceiver(InputTransferToken, SurfaceControl, 6625 * Choreographer, SurfaceControlInputReceiver)} or 6626 * {@link #registerUnbatchedSurfaceControlInputReceiver(InputTransferToken, 6627 * SurfaceControl, Looper, SurfaceControlInputReceiver)}. 6628 * </li> 6629 * </ul> 6630 * <p> 6631 * The host is likely to be an {@link AttachedSurfaceControl} so the host token can be 6632 * retrieved via {@link AttachedSurfaceControl#getInputTransferToken()}. 6633 * <p><br> 6634 * When the host wants to transfer touch gesture to the embedded, it can retrieve the embedded 6635 * token via {@link SurfaceControlViewHost.SurfacePackage#getInputTransferToken()} or use the 6636 * value returned from either 6637 * {@link #registerBatchedSurfaceControlInputReceiver(InputTransferToken, SurfaceControl, 6638 * Choreographer, SurfaceControlInputReceiver)} or 6639 * {@link #registerUnbatchedSurfaceControlInputReceiver(InputTransferToken, SurfaceControl, 6640 * Looper, SurfaceControlInputReceiver)} and pass its own token as the transferFromToken. 6641 * <p> 6642 * When the embedded wants to transfer touch gesture to the host, it can pass in its own 6643 * token as the transferFromToken and use the associated host's {@link InputTransferToken} as 6644 * the transferToToken 6645 * <p><br> 6646 * When the touch is transferred, the window currently receiving touch gets an ACTION_CANCEL 6647 * and does not receive any further input events for this gesture. 6648 * <p> 6649 * The transferred-to window receives an ACTION_DOWN event and then the remainder of the input 6650 * events for this gesture. It does not receive any of the previous events of this gesture that 6651 * the originating window received. 6652 * <p> 6653 * The transferTouchGesture API only works for the current gesture. When a new gesture 6654 * arrives, input dispatcher will do a new round of hit testing. So, if the host window is 6655 * still the first thing that's being touched, then it will receive the new gesture again. It 6656 * will again be up to the host to transfer this new gesture to the embedded. 6657 * <p><br> 6658 * The call can fail for the following reasons: 6659 * <ul> 6660 * <li> 6661 * Caller attempts to transfer touch gesture from a token that doesn't have an active gesture. 6662 * </li> 6663 * <li> 6664 * The gesture is transferred to a token that is not associated with the transferFromToken. For 6665 * example, if the caller transfers to a {@link SurfaceControlViewHost} not attached to the 6666 * host window via {@link SurfaceView#setChildSurfacePackage(SurfacePackage)}. 6667 * </li> 6668 * <li> 6669 * The active gesture completes before the transfer is complete, such as in the case of a 6670 * fling. 6671 * </li> 6672 * </ul> 6673 * <p> 6674 * 6675 * @param transferFromToken the InputTransferToken for the currently active gesture 6676 * @param transferToToken the InputTransferToken to transfer the gesture to. 6677 * @return Whether the touch stream was transferred. 6678 * @see android.view.SurfaceControlViewHost.SurfacePackage#getInputTransferToken() 6679 * @see AttachedSurfaceControl#getInputTransferToken() 6680 */ 6681 @FlaggedApi(Flags.FLAG_SURFACE_CONTROL_INPUT_RECEIVER) transferTouchGesture(@onNull InputTransferToken transferFromToken, @NonNull InputTransferToken transferToToken)6682 default boolean transferTouchGesture(@NonNull InputTransferToken transferFromToken, 6683 @NonNull InputTransferToken transferToToken) { 6684 throw new UnsupportedOperationException("transferTouchGesture is not implemented"); 6685 } 6686 6687 /** 6688 * @hide 6689 */ getDefaultToken()6690 default @NonNull IBinder getDefaultToken() { 6691 throw new UnsupportedOperationException( 6692 "getDefaultToken is not implemented"); 6693 } 6694 6695 /** @hide */ 6696 @Target(ElementType.TYPE_USE) 6697 @IntDef( 6698 prefix = {"SCREEN_RECORDING_STATE"}, 6699 value = {SCREEN_RECORDING_STATE_NOT_VISIBLE, SCREEN_RECORDING_STATE_VISIBLE}) 6700 @Retention(RetentionPolicy.SOURCE) 6701 @interface ScreenRecordingState {} 6702 6703 /** Indicates the app that registered the callback is not visible in screen recording. */ 6704 @FlaggedApi(com.android.window.flags.Flags.FLAG_SCREEN_RECORDING_CALLBACKS) 6705 int SCREEN_RECORDING_STATE_NOT_VISIBLE = 0; 6706 6707 /** Indicates the app that registered the callback is visible in screen recording. */ 6708 @FlaggedApi(com.android.window.flags.Flags.FLAG_SCREEN_RECORDING_CALLBACKS) 6709 int SCREEN_RECORDING_STATE_VISIBLE = 1; 6710 6711 /** 6712 * Adds a screen recording callback. The callback will be invoked whenever the app becomes 6713 * visible in screen recording or was visible in screen recording and becomes invisible in 6714 * screen recording. 6715 * 6716 * <p>An app is considered visible in screen recording if any activities owned by the 6717 * registering process's UID are being recorded. 6718 * 6719 * <p>Example: 6720 * 6721 * <pre> 6722 * windowManager.addScreenRecordingCallback(state -> { 6723 * // handle change in screen recording state 6724 * }); 6725 * </pre> 6726 * 6727 * @param executor The executor on which callback method will be invoked. 6728 * @param callback The callback that will be invoked when screen recording visibility changes. 6729 * @return the current screen recording state. 6730 * @see #SCREEN_RECORDING_STATE_NOT_VISIBLE 6731 * @see #SCREEN_RECORDING_STATE_VISIBLE 6732 */ 6733 @SuppressLint("AndroidFrameworkRequiresPermission") 6734 @RequiresPermission(permission.DETECT_SCREEN_RECORDING) 6735 @FlaggedApi(com.android.window.flags.Flags.FLAG_SCREEN_RECORDING_CALLBACKS) addScreenRecordingCallback( @onNull @allbackExecutor Executor executor, @NonNull Consumer<@ScreenRecordingState Integer> callback)6736 default @ScreenRecordingState int addScreenRecordingCallback( 6737 @NonNull @CallbackExecutor Executor executor, 6738 @NonNull Consumer<@ScreenRecordingState Integer> callback) { 6739 throw new UnsupportedOperationException(); 6740 } 6741 6742 /** 6743 * Removes a screen recording callback. 6744 * 6745 * @param callback The callback to remove. 6746 * @see #addScreenRecordingCallback(Executor, Consumer) 6747 */ 6748 @SuppressLint("AndroidFrameworkRequiresPermission") 6749 @RequiresPermission(permission.DETECT_SCREEN_RECORDING) 6750 @FlaggedApi(com.android.window.flags.Flags.FLAG_SCREEN_RECORDING_CALLBACKS) removeScreenRecordingCallback( @onNull Consumer<@ScreenRecordingState Integer> callback)6751 default void removeScreenRecordingCallback( 6752 @NonNull Consumer<@ScreenRecordingState Integer> callback) { 6753 throw new UnsupportedOperationException(); 6754 } 6755 } 6756