1 /* 2 * Copyright (C) 2007 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.content.pm; 18 19 import android.annotation.FloatRange; 20 import android.annotation.IntDef; 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.annotation.TestApi; 24 import android.app.Activity; 25 import android.app.compat.CompatChanges; 26 import android.compat.annotation.ChangeId; 27 import android.compat.annotation.Disabled; 28 import android.compat.annotation.EnabledSince; 29 import android.compat.annotation.Overridable; 30 import android.compat.annotation.UnsupportedAppUsage; 31 import android.content.ComponentName; 32 import android.content.Intent; 33 import android.content.res.Configuration; 34 import android.content.res.Configuration.NativeConfig; 35 import android.content.res.TypedArray; 36 import android.os.Build; 37 import android.os.Parcel; 38 import android.os.Parcelable; 39 import android.os.UserHandle; 40 import android.util.ArraySet; 41 import android.util.Printer; 42 import android.window.OnBackInvokedCallback; 43 44 import com.android.internal.util.Parcelling; 45 46 import java.lang.annotation.Retention; 47 import java.lang.annotation.RetentionPolicy; 48 import java.util.Collections; 49 import java.util.Locale; 50 import java.util.Set; 51 52 /** 53 * Information you can retrieve about a particular application 54 * activity or receiver. This corresponds to information collected 55 * from the AndroidManifest.xml's <activity> and 56 * <receiver> tags. 57 */ 58 public class ActivityInfo extends ComponentInfo implements Parcelable { 59 60 private static final Parcelling.BuiltIn.ForStringSet sForStringSet = 61 Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForStringSet.class); 62 63 // NOTE: When adding new data members be sure to update the copy-constructor, Parcel 64 // constructor, and writeToParcel. 65 66 /** 67 * A style resource identifier (in the package's resources) of this 68 * activity's theme. From the "theme" attribute or, if not set, 0. 69 */ 70 public int theme; 71 72 /** 73 * Constant corresponding to <code>standard</code> in 74 * the {@link android.R.attr#launchMode} attribute. 75 */ 76 public static final int LAUNCH_MULTIPLE = 0; 77 /** 78 * Constant corresponding to <code>singleTop</code> in 79 * the {@link android.R.attr#launchMode} attribute. 80 */ 81 public static final int LAUNCH_SINGLE_TOP = 1; 82 /** 83 * Constant corresponding to <code>singleTask</code> in 84 * the {@link android.R.attr#launchMode} attribute. 85 */ 86 public static final int LAUNCH_SINGLE_TASK = 2; 87 /** 88 * Constant corresponding to <code>singleInstance</code> in 89 * the {@link android.R.attr#launchMode} attribute. 90 */ 91 public static final int LAUNCH_SINGLE_INSTANCE = 3; 92 /** 93 * Constant corresponding to <code>singleInstancePerTask</code> in 94 * the {@link android.R.attr#launchMode} attribute. 95 */ 96 public static final int LAUNCH_SINGLE_INSTANCE_PER_TASK = 4; 97 98 /** @hide */ 99 @IntDef(prefix = "LAUNCH_", value = { 100 LAUNCH_MULTIPLE, 101 LAUNCH_SINGLE_TOP, 102 LAUNCH_SINGLE_TASK, 103 LAUNCH_SINGLE_INSTANCE, 104 LAUNCH_SINGLE_INSTANCE_PER_TASK 105 }) 106 @Retention(RetentionPolicy.SOURCE) 107 public @interface LaunchMode { 108 } 109 110 /** @hide */ launchModeToString(@aunchMode int launchMode)111 public static String launchModeToString(@LaunchMode int launchMode) { 112 switch(launchMode) { 113 case LAUNCH_MULTIPLE: 114 return "LAUNCH_MULTIPLE"; 115 case LAUNCH_SINGLE_TOP: 116 return "LAUNCH_SINGLE_TOP"; 117 case LAUNCH_SINGLE_TASK: 118 return "LAUNCH_SINGLE_TASK"; 119 case LAUNCH_SINGLE_INSTANCE: 120 return "LAUNCH_SINGLE_INSTANCE"; 121 case LAUNCH_SINGLE_INSTANCE_PER_TASK: 122 return "LAUNCH_SINGLE_INSTANCE_PER_TASK"; 123 default: 124 return "unknown=" + launchMode; 125 } 126 } 127 128 /** 129 * The launch mode style requested by the activity. From the 130 * {@link android.R.attr#launchMode} attribute. 131 */ 132 @LaunchMode 133 public int launchMode; 134 135 /** 136 * Constant corresponding to <code>none</code> in 137 * the {@link android.R.attr#documentLaunchMode} attribute. 138 */ 139 public static final int DOCUMENT_LAUNCH_NONE = 0; 140 /** 141 * Constant corresponding to <code>intoExisting</code> in 142 * the {@link android.R.attr#documentLaunchMode} attribute. 143 */ 144 public static final int DOCUMENT_LAUNCH_INTO_EXISTING = 1; 145 /** 146 * Constant corresponding to <code>always</code> in 147 * the {@link android.R.attr#documentLaunchMode} attribute. 148 */ 149 public static final int DOCUMENT_LAUNCH_ALWAYS = 2; 150 /** 151 * Constant corresponding to <code>never</code> in 152 * the {@link android.R.attr#documentLaunchMode} attribute. 153 */ 154 public static final int DOCUMENT_LAUNCH_NEVER = 3; 155 /** 156 * The document launch mode style requested by the activity. From the 157 * {@link android.R.attr#documentLaunchMode} attribute, one of 158 * {@link #DOCUMENT_LAUNCH_NONE}, {@link #DOCUMENT_LAUNCH_INTO_EXISTING}, 159 * {@link #DOCUMENT_LAUNCH_ALWAYS}. 160 * 161 * <p>Modes DOCUMENT_LAUNCH_ALWAYS 162 * and DOCUMENT_LAUNCH_INTO_EXISTING are equivalent to {@link 163 * android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT 164 * Intent.FLAG_ACTIVITY_NEW_DOCUMENT} with and without {@link 165 * android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK 166 * Intent.FLAG_ACTIVITY_MULTIPLE_TASK} respectively. 167 */ 168 public int documentLaunchMode; 169 170 /** 171 * Constant corresponding to <code>persistRootOnly</code> in 172 * the {@link android.R.attr#persistableMode} attribute. 173 */ 174 public static final int PERSIST_ROOT_ONLY = 0; 175 /** 176 * Constant corresponding to <code>doNotPersist</code> in 177 * the {@link android.R.attr#persistableMode} attribute. 178 */ 179 public static final int PERSIST_NEVER = 1; 180 /** 181 * Constant corresponding to <code>persistAcrossReboots</code> in 182 * the {@link android.R.attr#persistableMode} attribute. 183 */ 184 public static final int PERSIST_ACROSS_REBOOTS = 2; 185 /** 186 * Value indicating how this activity is to be persisted across 187 * reboots for restoring in the Recents list. 188 * {@link android.R.attr#persistableMode} 189 */ 190 public int persistableMode; 191 192 /** 193 * The maximum number of tasks rooted at this activity that can be in the recent task list. 194 * Refer to {@link android.R.attr#maxRecents}. 195 */ 196 public int maxRecents; 197 198 /** 199 * Optional name of a permission required to be able to access this 200 * Activity. From the "permission" attribute. 201 */ 202 public String permission; 203 204 /** 205 * The affinity this activity has for another task in the system. The 206 * string here is the name of the task, often the package name of the 207 * overall package. If null, the activity has no affinity. Set from the 208 * {@link android.R.attr#taskAffinity} attribute. 209 */ 210 public String taskAffinity; 211 212 /** 213 * If this is an activity alias, this is the real activity class to run 214 * for it. Otherwise, this is null. 215 */ 216 public String targetActivity; 217 218 /** 219 * Token used to string together multiple events within a single launch action. 220 * @hide 221 */ 222 public String launchToken; 223 224 /** 225 * Specifies the required display category of the activity. Set from the 226 * {@link android.R.attr#requiredDisplayCategory} attribute. Upon creation, a display can 227 * specify which display categories it supports and one of the category must be present 228 * in the {@code <activity>} element to allow this activity to run. The default value is 229 * {@code null}, which indicates the activity does not have a required display category and 230 * thus can only run on a display that didn't specify any display categories. Each activity 231 * can only specify one required category but a display can support multiple display categories. 232 * <p> 233 * This field should be formatted as a Java-language-style free form string(for example, 234 * com.google.automotive_entertainment), which may contain uppercase or lowercase letters ('A' 235 * through 'Z'), numbers, and underscores ('_') but may only start with letters. 236 */ 237 @Nullable 238 public String requiredDisplayCategory; 239 240 /** 241 * Activity can not be resized and always occupies the fullscreen area with all windows fully 242 * visible. 243 * @hide 244 */ 245 public static final int RESIZE_MODE_UNRESIZEABLE = 0; 246 /** 247 * Activity didn't explicitly request to be resizeable, but we are making it resizeable because 248 * of the SDK version it targets. Only affects apps with target SDK >= N where the app is 249 * implied to be resizeable if it doesn't explicitly set the attribute to any value. 250 * @hide 251 */ 252 public static final int RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION = 1; 253 /** 254 * Activity explicitly requested to be resizeable. 255 * @hide 256 */ 257 @TestApi 258 public static final int RESIZE_MODE_RESIZEABLE = 2; 259 /** 260 * Activity is resizeable and supported picture-in-picture mode. This flag is now deprecated 261 * since activities do not need to be resizeable to support picture-in-picture. 262 * See {@link #FLAG_SUPPORTS_PICTURE_IN_PICTURE}. 263 * 264 * @hide 265 * @deprecated 266 */ 267 public static final int RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED = 3; 268 /** 269 * Activity does not support resizing, but we are forcing it to be resizeable. Only affects 270 * certain pre-N apps where we force them to be resizeable. 271 * @hide 272 */ 273 public static final int RESIZE_MODE_FORCE_RESIZEABLE = 4; 274 /** 275 * Activity does not support resizing, but we are forcing it to be resizeable as long 276 * as the size remains landscape. 277 * @hide 278 */ 279 public static final int RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY = 5; 280 /** 281 * Activity does not support resizing, but we are forcing it to be resizeable as long 282 * as the size remains portrait. 283 * @hide 284 */ 285 public static final int RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY = 6; 286 /** 287 * Activity does not support resizing, but we are forcing it to be resizeable as long 288 * as the bounds remain in the same orientation as they are. 289 * @hide 290 */ 291 public static final int RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION = 7; 292 /** 293 * Value indicating if the resizing mode the activity supports. 294 * See {@link android.R.attr#resizeableActivity}. 295 * @hide 296 */ 297 @UnsupportedAppUsage 298 public int resizeMode = RESIZE_MODE_RESIZEABLE; 299 300 /** 301 * Value indicating the maximum aspect ratio the activity supports. 302 * <p> 303 * 0 means unset. 304 * @See {@link android.R.attr#maxAspectRatio}. 305 * @hide 306 */ 307 private float mMaxAspectRatio; 308 309 /** 310 * Value indicating the minimum aspect ratio the activity supports. 311 * <p> 312 * 0 means unset. 313 * @See {@link android.R.attr#minAspectRatio}. 314 * @hide 315 */ 316 private float mMinAspectRatio; 317 318 /** 319 * Indicates that the activity works well with size changes like display changing size. 320 * 321 * @hide 322 */ 323 public boolean supportsSizeChanges; 324 325 /** 326 * Name of the VrListenerService component to run for this activity. 327 * @see android.R.attr#enableVrMode 328 * @hide 329 */ 330 public String requestedVrComponent; 331 332 /** 333 * Value for {@link #colorMode} indicating that the activity should use the 334 * default color mode (sRGB, low dynamic range). 335 * 336 * @see android.R.attr#colorMode 337 */ 338 public static final int COLOR_MODE_DEFAULT = 0; 339 /** 340 * Value of {@link #colorMode} indicating that the activity should use a 341 * wide color gamut if the presentation display supports it. 342 * 343 * @see android.R.attr#colorMode 344 */ 345 public static final int COLOR_MODE_WIDE_COLOR_GAMUT = 1; 346 /** 347 * Value of {@link #colorMode} indicating that the activity should use a 348 * high dynamic range if the presentation display supports it. 349 * 350 * @see android.R.attr#colorMode 351 */ 352 public static final int COLOR_MODE_HDR = 2; 353 354 /** 355 * Comparison point against COLOR_MODE_HDR that uses 1010102 356 * Only for internal test usages 357 * @hide 358 */ 359 public static final int COLOR_MODE_HDR10 = 3; 360 361 /** 362 * Value of {@link #colorMode} indicating that the activity should use an 363 * 8 bit alpha buffer if the presentation display supports it. 364 * 365 * @see android.R.attr#colorMode 366 * @hide 367 */ 368 public static final int COLOR_MODE_A8 = 4; 369 370 371 /** @hide */ 372 @IntDef(prefix = { "COLOR_MODE_" }, value = { 373 COLOR_MODE_DEFAULT, 374 COLOR_MODE_WIDE_COLOR_GAMUT, 375 COLOR_MODE_HDR, 376 COLOR_MODE_A8, 377 }) 378 @Retention(RetentionPolicy.SOURCE) 379 public @interface ColorMode {} 380 381 /** 382 * The color mode requested by this activity. The target display may not be 383 * able to honor the request. 384 */ 385 @ColorMode 386 public int colorMode = COLOR_MODE_DEFAULT; 387 388 /** 389 * Bit in {@link #flags} indicating whether this activity is able to 390 * run in multiple processes. If 391 * true, the system may instantiate it in the some process as the 392 * process starting it in order to conserve resources. If false, the 393 * default, it always runs in {@link #processName}. Set from the 394 * {@link android.R.attr#multiprocess} attribute. 395 */ 396 public static final int FLAG_MULTIPROCESS = 0x0001; 397 /** 398 * Bit in {@link #flags} indicating that, when the activity's task is 399 * relaunched from home, this activity should be finished. 400 * Set from the 401 * {@link android.R.attr#finishOnTaskLaunch} attribute. 402 */ 403 public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002; 404 /** 405 * Bit in {@link #flags} indicating that, when the activity is the root 406 * of a task, that task's stack should be cleared each time the user 407 * re-launches it from home. As a result, the user will always 408 * return to the original activity at the top of the task. 409 * This flag only applies to activities that 410 * are used to start the root of a new task. Set from the 411 * {@link android.R.attr#clearTaskOnLaunch} attribute. 412 */ 413 public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004; 414 /** 415 * Bit in {@link #flags} indicating that, when the activity is the root 416 * of a task, that task's stack should never be cleared when it is 417 * relaunched from home. Set from the 418 * {@link android.R.attr#alwaysRetainTaskState} attribute. 419 */ 420 public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008; 421 /** 422 * Bit in {@link #flags} indicating that the activity's state 423 * is not required to be saved, so that if there is a failure the 424 * activity will not be removed from the activity stack. Set from the 425 * {@link android.R.attr#stateNotNeeded} attribute. 426 */ 427 public static final int FLAG_STATE_NOT_NEEDED = 0x0010; 428 /** 429 * Bit in {@link #flags} that indicates that the activity should not 430 * appear in the list of recently launched activities. Set from the 431 * {@link android.R.attr#excludeFromRecents} attribute. 432 */ 433 public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020; 434 /** 435 * Bit in {@link #flags} that indicates that the activity can be moved 436 * between tasks based on its task affinity. Set from the 437 * {@link android.R.attr#allowTaskReparenting} attribute. 438 */ 439 public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040; 440 /** 441 * Bit in {@link #flags} indicating that, when the user navigates away 442 * from an activity, it should be finished. 443 * Set from the 444 * {@link android.R.attr#noHistory} attribute. 445 */ 446 public static final int FLAG_NO_HISTORY = 0x0080; 447 /** 448 * Bit in {@link #flags} indicating that, when a request to close system 449 * windows happens, this activity is finished. 450 * Set from the 451 * {@link android.R.attr#finishOnCloseSystemDialogs} attribute. 452 */ 453 public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100; 454 /** 455 * Value for {@link #flags}: true when the application's rendering should 456 * be hardware accelerated. 457 */ 458 public static final int FLAG_HARDWARE_ACCELERATED = 0x0200; 459 /** 460 * Value for {@link #flags}: true when the application can be displayed for all users 461 * regardless of if the user of the application is the current user. Set from the 462 * {@link android.R.attr#showForAllUsers} attribute. 463 * @hide 464 */ 465 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 466 public static final int FLAG_SHOW_FOR_ALL_USERS = 0x0400; 467 /** 468 * Bit in {@link #flags} corresponding to an immersive activity 469 * that wishes not to be interrupted by notifications. 470 * Applications that hide the system notification bar with 471 * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN} 472 * may still be interrupted by high-priority notifications; for example, an 473 * incoming phone call may use 474 * {@link android.app.Notification#fullScreenIntent fullScreenIntent} 475 * to present a full-screen in-call activity to the user, pausing the 476 * current activity as a side-effect. An activity with 477 * {@link #FLAG_IMMERSIVE} set, however, will not be interrupted; the 478 * notification may be shown in some other way (such as a small floating 479 * "toast" window). 480 * 481 * Note that this flag will always reflect the Activity's 482 * <code>android:immersive</code> manifest definition, even if the Activity's 483 * immersive state is changed at runtime via 484 * {@link android.app.Activity#setImmersive(boolean)}. 485 * 486 * @see android.app.Notification#FLAG_HIGH_PRIORITY 487 * @see android.app.Activity#setImmersive(boolean) 488 */ 489 public static final int FLAG_IMMERSIVE = 0x0800; 490 /** 491 * Bit in {@link #flags}: If set, a task rooted at this activity will have its 492 * baseIntent replaced by the activity immediately above this. Each activity may further 493 * relinquish its identity to the activity above it using this flag. Set from the 494 * {@link android.R.attr#relinquishTaskIdentity} attribute. 495 */ 496 public static final int FLAG_RELINQUISH_TASK_IDENTITY = 0x1000; 497 /** 498 * Bit in {@link #flags} indicating that tasks started with this activity are to be 499 * removed from the recent list of tasks when the last activity in the task is finished. 500 * Corresponds to {@link android.R.attr#autoRemoveFromRecents} 501 */ 502 public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 0x2000; 503 /** 504 * Bit in {@link #flags} indicating that this activity can start is creation/resume 505 * while the previous activity is still pausing. Corresponds to 506 * {@link android.R.attr#resumeWhilePausing} 507 */ 508 public static final int FLAG_RESUME_WHILE_PAUSING = 0x4000; 509 /** 510 * Bit in {@link #flags} indicating that this activity should be run with VR mode enabled. 511 * 512 * @see android.app.Activity#setVrModeEnabled(boolean, ComponentName) 513 */ 514 public static final int FLAG_ENABLE_VR_MODE = 0x8000; 515 /** 516 * Bit in {@link #flags} indicating if the activity can be displayed on a remote device. 517 * Corresponds to {@link android.R.attr#canDisplayOnRemoteDevices} 518 * @hide 519 */ 520 public static final int FLAG_CAN_DISPLAY_ON_REMOTE_DEVICES = 0x10000; 521 522 /** 523 * Bit in {@link #flags} indicating if the activity is always focusable regardless of if it is 524 * in a task/stack whose activities are normally not focusable. 525 * See android.R.attr#alwaysFocusable. 526 * @hide 527 */ 528 public static final int FLAG_ALWAYS_FOCUSABLE = 0x40000; 529 530 /** 531 * Bit in {@link #flags} indicating if the activity is visible to instant 532 * applications. The activity is visible if it's either implicitly or 533 * explicitly exposed. 534 * @hide 535 */ 536 public static final int FLAG_VISIBLE_TO_INSTANT_APP = 0x100000; 537 538 /** 539 * Bit in {@link #flags} indicating if the activity is implicitly visible 540 * to instant applications. Implicitly visible activities are those that 541 * implement certain intent-filters: 542 * <ul> 543 * <li>action {@link Intent#CATEGORY_BROWSABLE}</li> 544 * <li>action {@link Intent#ACTION_SEND}</li> 545 * <li>action {@link Intent#ACTION_SENDTO}</li> 546 * <li>action {@link Intent#ACTION_SEND_MULTIPLE}</li> 547 * </ul> 548 * @hide 549 */ 550 public static final int FLAG_IMPLICITLY_VISIBLE_TO_INSTANT_APP = 0x200000; 551 552 /** 553 * Bit in {@link #flags} indicating if the activity supports picture-in-picture mode. 554 * See {@link android.R.attr#supportsPictureInPicture}. 555 * @hide 556 */ 557 public static final int FLAG_SUPPORTS_PICTURE_IN_PICTURE = 0x400000; 558 559 /** 560 * Bit in {@link #flags} indicating if the activity should be shown when locked. 561 * See {@link android.R.attr#showWhenLocked} 562 * @hide 563 */ 564 public static final int FLAG_SHOW_WHEN_LOCKED = 0x800000; 565 566 /** 567 * Bit in {@link #flags} indicating if the screen should turn on when starting the activity. 568 * See {@link android.R.attr#turnScreenOn} 569 * @hide 570 */ 571 public static final int FLAG_TURN_SCREEN_ON = 0x1000000; 572 573 /** 574 * Bit in {@link #flags} indicating whether the display should preferably be switched to a 575 * minimal post processing mode. 576 * See {@link android.R.attr#preferMinimalPostProcessing} 577 */ 578 public static final int FLAG_PREFER_MINIMAL_POST_PROCESSING = 0x2000000; 579 580 /** 581 * Bit in {@link #flags}: If set, indicates that the activity can be embedded by untrusted 582 * hosts. In this case the interactions with and visibility of the embedded activity may be 583 * limited. Set from the {@link android.R.attr#allowUntrustedActivityEmbedding} attribute. 584 */ 585 public static final int FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING = 0x10000000; 586 587 /** 588 * @hide Bit in {@link #flags}: If set, this component will only be seen 589 * by the system user. Only works with broadcast receivers. Set from the 590 * android.R.attr#systemUserOnly attribute. 591 */ 592 public static final int FLAG_SYSTEM_USER_ONLY = 0x20000000; 593 /** 594 * Bit in {@link #flags}: If set, a single instance of the receiver will 595 * run for all users on the device. Set from the 596 * {@link android.R.attr#singleUser} attribute. Note that this flag is 597 * only relevant for ActivityInfo structures that are describing receiver 598 * components; it is not applied to activities. 599 */ 600 public static final int FLAG_SINGLE_USER = 0x40000000; 601 /** 602 * @hide Bit in {@link #flags}: If set, this activity may be launched into an 603 * owned ActivityContainer such as that within an ActivityView. If not set and 604 * this activity is launched into such a container a SecurityException will be 605 * thrown. Set from the {@link android.R.attr#allowEmbedded} attribute. 606 * 607 * @deprecated this flag is no longer needed since ActivityView is now fully removed 608 * TODO(b/191165536): delete this flag since is no longer used 609 */ 610 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 611 @Deprecated 612 public static final int FLAG_ALLOW_EMBEDDED = 0x80000000; 613 614 /** 615 * Options that have been set in the activity declaration in the 616 * manifest. 617 * These include: 618 * {@link #FLAG_MULTIPROCESS}, 619 * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH}, 620 * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE}, 621 * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS}, 622 * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY}, 623 * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS}, 624 * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER}, 625 * {@link #FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING}. 626 */ 627 public int flags; 628 629 /** 630 * Bit in {@link #privateFlags} indicating if the activity should be shown when locked in case 631 * an activity behind this can also be shown when locked. 632 * See {@link android.R.attr#inheritShowWhenLocked}. 633 * @hide 634 */ 635 public static final int FLAG_INHERIT_SHOW_WHEN_LOCKED = 1 << 0; 636 637 /** 638 * Bit in {@link #privateFlags} indicating whether a home sound effect should be played if the 639 * home app moves to front after the activity with this flag set. 640 * Set from the {@link android.R.attr#playHomeTransitionSound} attribute. 641 * @hide 642 */ 643 public static final int PRIVATE_FLAG_HOME_TRANSITION_SOUND = 1 << 1; 644 645 /** 646 * Bit in {@link #privateFlags} indicating {@link android.view.KeyEvent#KEYCODE_BACK} related 647 * events will be replaced by a call to {@link OnBackInvokedCallback#onBackInvoked()} on the 648 * focused window. 649 * @hide 650 * @see android.R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback 651 */ 652 public static final int PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK = 1 << 2; 653 654 /** 655 * Bit in {@link #privateFlags} indicating {@link android.view.KeyEvent#KEYCODE_BACK} related 656 * events will be forwarded to the Activity and its dialogs and views and 657 * the {@link android.app.Activity#onBackPressed()}, {@link android.app.Dialog#onBackPressed} 658 * will be called. 659 * @hide 660 * @see android.R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback 661 */ 662 public static final int PRIVATE_FLAG_DISABLE_ON_BACK_INVOKED_CALLBACK = 1 << 3; 663 664 /** 665 * Options that have been set in the activity declaration in the manifest. 666 * These include: 667 * {@link #FLAG_INHERIT_SHOW_WHEN_LOCKED}, 668 * {@link #PRIVATE_FLAG_HOME_TRANSITION_SOUND}. 669 * {@link #PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK} 670 * {@link #PRIVATE_FLAG_DISABLE_ON_BACK_INVOKED_CALLBACK} 671 * @hide 672 */ 673 public int privateFlags; 674 675 /** @hide */ 676 @IntDef(prefix = { "SCREEN_ORIENTATION_" }, value = { 677 SCREEN_ORIENTATION_UNSET, 678 SCREEN_ORIENTATION_UNSPECIFIED, 679 SCREEN_ORIENTATION_LANDSCAPE, 680 SCREEN_ORIENTATION_PORTRAIT, 681 SCREEN_ORIENTATION_USER, 682 SCREEN_ORIENTATION_BEHIND, 683 SCREEN_ORIENTATION_SENSOR, 684 SCREEN_ORIENTATION_NOSENSOR, 685 SCREEN_ORIENTATION_SENSOR_LANDSCAPE, 686 SCREEN_ORIENTATION_SENSOR_PORTRAIT, 687 SCREEN_ORIENTATION_REVERSE_LANDSCAPE, 688 SCREEN_ORIENTATION_REVERSE_PORTRAIT, 689 SCREEN_ORIENTATION_FULL_SENSOR, 690 SCREEN_ORIENTATION_USER_LANDSCAPE, 691 SCREEN_ORIENTATION_USER_PORTRAIT, 692 SCREEN_ORIENTATION_FULL_USER, 693 SCREEN_ORIENTATION_LOCKED 694 }) 695 @Retention(RetentionPolicy.SOURCE) 696 public @interface ScreenOrientation {} 697 698 /** 699 * Internal constant used to indicate that the app didn't set a specific orientation value. 700 * Different from {@link #SCREEN_ORIENTATION_UNSPECIFIED} below as the app can set its 701 * orientation to {@link #SCREEN_ORIENTATION_UNSPECIFIED} while this means that the app didn't 702 * set anything. The system will mostly treat this similar to 703 * {@link #SCREEN_ORIENTATION_UNSPECIFIED}. 704 * @hide 705 */ 706 public static final int SCREEN_ORIENTATION_UNSET = -2; 707 /** 708 * Constant corresponding to <code>unspecified</code> in 709 * the {@link android.R.attr#screenOrientation} attribute. 710 */ 711 public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1; 712 /** 713 * Constant corresponding to <code>landscape</code> in 714 * the {@link android.R.attr#screenOrientation} attribute. 715 */ 716 public static final int SCREEN_ORIENTATION_LANDSCAPE = 0; 717 /** 718 * Constant corresponding to <code>portrait</code> in 719 * the {@link android.R.attr#screenOrientation} attribute. 720 */ 721 public static final int SCREEN_ORIENTATION_PORTRAIT = 1; 722 /** 723 * Constant corresponding to <code>user</code> in 724 * the {@link android.R.attr#screenOrientation} attribute. 725 */ 726 public static final int SCREEN_ORIENTATION_USER = 2; 727 /** 728 * Constant corresponding to <code>behind</code> in 729 * the {@link android.R.attr#screenOrientation} attribute. 730 */ 731 public static final int SCREEN_ORIENTATION_BEHIND = 3; 732 /** 733 * Constant corresponding to <code>sensor</code> in 734 * the {@link android.R.attr#screenOrientation} attribute. 735 */ 736 public static final int SCREEN_ORIENTATION_SENSOR = 4; 737 738 /** 739 * Constant corresponding to <code>nosensor</code> in 740 * the {@link android.R.attr#screenOrientation} attribute. 741 */ 742 public static final int SCREEN_ORIENTATION_NOSENSOR = 5; 743 744 /** 745 * Constant corresponding to <code>sensorLandscape</code> in 746 * the {@link android.R.attr#screenOrientation} attribute. 747 */ 748 public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6; 749 750 /** 751 * Constant corresponding to <code>sensorPortrait</code> in 752 * the {@link android.R.attr#screenOrientation} attribute. 753 */ 754 public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7; 755 756 /** 757 * Constant corresponding to <code>reverseLandscape</code> in 758 * the {@link android.R.attr#screenOrientation} attribute. 759 */ 760 public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8; 761 762 /** 763 * Constant corresponding to <code>reversePortrait</code> in 764 * the {@link android.R.attr#screenOrientation} attribute. 765 */ 766 public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9; 767 768 /** 769 * Constant corresponding to <code>fullSensor</code> in 770 * the {@link android.R.attr#screenOrientation} attribute. 771 */ 772 public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10; 773 774 /** 775 * Constant corresponding to <code>userLandscape</code> in 776 * the {@link android.R.attr#screenOrientation} attribute. 777 */ 778 public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11; 779 780 /** 781 * Constant corresponding to <code>userPortrait</code> in 782 * the {@link android.R.attr#screenOrientation} attribute. 783 */ 784 public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12; 785 786 /** 787 * Constant corresponding to <code>fullUser</code> in 788 * the {@link android.R.attr#screenOrientation} attribute. 789 */ 790 public static final int SCREEN_ORIENTATION_FULL_USER = 13; 791 792 /** 793 * Constant corresponding to <code>locked</code> in 794 * the {@link android.R.attr#screenOrientation} attribute. 795 */ 796 public static final int SCREEN_ORIENTATION_LOCKED = 14; 797 798 /** 799 * The preferred screen orientation this activity would like to run in. 800 * From the {@link android.R.attr#screenOrientation} attribute, one of 801 * {@link #SCREEN_ORIENTATION_UNSPECIFIED}, 802 * {@link #SCREEN_ORIENTATION_LANDSCAPE}, 803 * {@link #SCREEN_ORIENTATION_PORTRAIT}, 804 * {@link #SCREEN_ORIENTATION_USER}, 805 * {@link #SCREEN_ORIENTATION_BEHIND}, 806 * {@link #SCREEN_ORIENTATION_SENSOR}, 807 * {@link #SCREEN_ORIENTATION_NOSENSOR}, 808 * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE}, 809 * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT}, 810 * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE}, 811 * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT}, 812 * {@link #SCREEN_ORIENTATION_FULL_SENSOR}, 813 * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE}, 814 * {@link #SCREEN_ORIENTATION_USER_PORTRAIT}, 815 * {@link #SCREEN_ORIENTATION_FULL_USER}, 816 * {@link #SCREEN_ORIENTATION_LOCKED}, 817 */ 818 @ScreenOrientation 819 public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; 820 821 /** @hide */ 822 @IntDef(flag = true, prefix = { "CONFIG_" }, value = { 823 CONFIG_MCC, 824 CONFIG_MNC, 825 CONFIG_LOCALE, 826 CONFIG_TOUCHSCREEN, 827 CONFIG_KEYBOARD, 828 CONFIG_KEYBOARD_HIDDEN, 829 CONFIG_NAVIGATION, 830 CONFIG_ORIENTATION, 831 CONFIG_SCREEN_LAYOUT, 832 CONFIG_UI_MODE, 833 CONFIG_SCREEN_SIZE, 834 CONFIG_SMALLEST_SCREEN_SIZE, 835 CONFIG_DENSITY, 836 CONFIG_LAYOUT_DIRECTION, 837 CONFIG_COLOR_MODE, 838 CONFIG_FONT_SCALE, 839 CONFIG_GRAMMATICAL_GENDER, 840 }) 841 @Retention(RetentionPolicy.SOURCE) 842 public @interface Config {} 843 844 /** 845 * Bit in {@link #configChanges} that indicates that the activity 846 * can itself handle changes to the IMSI MCC. Set from the 847 * {@link android.R.attr#configChanges} attribute. 848 */ 849 public static final int CONFIG_MCC = 0x0001; 850 /** 851 * Bit in {@link #configChanges} that indicates that the activity 852 * can itself handle changes to the IMSI MNC. Set from the 853 * {@link android.R.attr#configChanges} attribute. 854 */ 855 public static final int CONFIG_MNC = 0x0002; 856 /** 857 * Bit in {@link #configChanges} that indicates that the activity 858 * can itself handle changes to the locale. Set from the 859 * {@link android.R.attr#configChanges} attribute. 860 */ 861 public static final int CONFIG_LOCALE = 0x0004; 862 /** 863 * Bit in {@link #configChanges} that indicates that the activity 864 * can itself handle changes to the touchscreen type. Set from the 865 * {@link android.R.attr#configChanges} attribute. 866 */ 867 public static final int CONFIG_TOUCHSCREEN = 0x0008; 868 /** 869 * Bit in {@link #configChanges} that indicates that the activity 870 * can itself handle changes to the keyboard type. Set from the 871 * {@link android.R.attr#configChanges} attribute. 872 */ 873 public static final int CONFIG_KEYBOARD = 0x0010; 874 /** 875 * Bit in {@link #configChanges} that indicates that the activity 876 * can itself handle changes to the keyboard or navigation being hidden/exposed. 877 * Note that inspite of the name, this applies to the changes to any 878 * hidden states: keyboard or navigation. 879 * Set from the {@link android.R.attr#configChanges} attribute. 880 */ 881 public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020; 882 /** 883 * Bit in {@link #configChanges} that indicates that the activity 884 * can itself handle changes to the navigation type. Set from the 885 * {@link android.R.attr#configChanges} attribute. 886 */ 887 public static final int CONFIG_NAVIGATION = 0x0040; 888 /** 889 * Bit in {@link #configChanges} that indicates that the activity 890 * can itself handle changes to the screen orientation. Set from the 891 * {@link android.R.attr#configChanges} attribute. 892 */ 893 public static final int CONFIG_ORIENTATION = 0x0080; 894 /** 895 * Bit in {@link #configChanges} that indicates that the activity 896 * can itself handle changes to the screen layout. Set from the 897 * {@link android.R.attr#configChanges} attribute. 898 */ 899 public static final int CONFIG_SCREEN_LAYOUT = 0x0100; 900 /** 901 * Bit in {@link #configChanges} that indicates that the activity 902 * can itself handle the ui mode. Set from the 903 * {@link android.R.attr#configChanges} attribute. 904 */ 905 public static final int CONFIG_UI_MODE = 0x0200; 906 /** 907 * Bit in {@link #configChanges} that indicates that the activity 908 * can itself handle the screen size. Set from the 909 * {@link android.R.attr#configChanges} attribute. This will be 910 * set by default for applications that target an earlier version 911 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}... 912 * <b>however</b>, you will not see the bit set here becomes some 913 * applications incorrectly compare {@link #configChanges} against 914 * an absolute value rather than correctly masking out the bits 915 * they are interested in. Please don't do that, thanks. 916 */ 917 public static final int CONFIG_SCREEN_SIZE = 0x0400; 918 /** 919 * Bit in {@link #configChanges} that indicates that the activity 920 * can itself handle the smallest screen size. Set from the 921 * {@link android.R.attr#configChanges} attribute. This will be 922 * set by default for applications that target an earlier version 923 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}... 924 * <b>however</b>, you will not see the bit set here becomes some 925 * applications incorrectly compare {@link #configChanges} against 926 * an absolute value rather than correctly masking out the bits 927 * they are interested in. Please don't do that, thanks. 928 */ 929 public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800; 930 /** 931 * Bit in {@link #configChanges} that indicates that the activity 932 * can itself handle density changes. Set from the 933 * {@link android.R.attr#configChanges} attribute. 934 */ 935 public static final int CONFIG_DENSITY = 0x1000; 936 /** 937 * Bit in {@link #configChanges} that indicates that the activity 938 * can itself handle the change to layout direction. Set from the 939 * {@link android.R.attr#configChanges} attribute. 940 */ 941 public static final int CONFIG_LAYOUT_DIRECTION = 0x2000; 942 /** 943 * Bit in {@link #configChanges} that indicates that the activity 944 * can itself handle the change to the display color gamut or dynamic 945 * range. Set from the {@link android.R.attr#configChanges} attribute. 946 */ 947 public static final int CONFIG_COLOR_MODE = 0x4000; 948 /** 949 * Bit in {@link #configChanges} that indicates that the activity 950 * can itself handle the change to gender. Set from the 951 * {@link android.R.attr#configChanges} attribute. 952 */ 953 public static final int CONFIG_GRAMMATICAL_GENDER = 0x8000; 954 /** 955 * Bit in {@link #configChanges} that indicates that the activity 956 * can itself handle asset path changes. Set from the {@link android.R.attr#configChanges} 957 * attribute. This is not a core resource configuration, but a higher-level value, so its 958 * constant starts at the high bits. 959 * @hide We do not want apps handling this yet, but we do need some kind of bit for diffs. 960 */ 961 public static final int CONFIG_ASSETS_PATHS = 0x80000000; 962 /** 963 * Bit in {@link #configChanges} that indicates that the activity 964 * can itself handle changes to the font scaling factor. Set from the 965 * {@link android.R.attr#configChanges} attribute. This is 966 * not a core resource configuration, but a higher-level value, so its 967 * constant starts at the high bits. 968 */ 969 public static final int CONFIG_FONT_SCALE = 0x40000000; 970 /** 971 * Bit indicating changes to window configuration that isn't exposed to apps. 972 * This is for internal use only and apps don't handle it. 973 * @hide 974 * {@link Configuration}. 975 */ 976 public static final int CONFIG_WINDOW_CONFIGURATION = 0x20000000; 977 978 /** 979 * Bit in {@link #configChanges} that indicates that the activity 980 * can itself handle changes to font weight. Set from the 981 * {@link android.R.attr#configChanges} attribute. This is 982 * not a core resource configuration, but a higher-level value, so its 983 * constant starts at the high bits. 984 */ 985 public static final int CONFIG_FONT_WEIGHT_ADJUSTMENT = 0x10000000; 986 987 /** @hide 988 * Unfortunately the constants for config changes in native code are 989 * different from ActivityInfo. :( Here are the values we should use for the 990 * native side given the bit we have assigned in ActivityInfo. 991 */ 992 public static int[] CONFIG_NATIVE_BITS = new int[] { 993 Configuration.NATIVE_CONFIG_MNC, // MNC 994 Configuration.NATIVE_CONFIG_MCC, // MCC 995 Configuration.NATIVE_CONFIG_LOCALE, // LOCALE 996 Configuration.NATIVE_CONFIG_TOUCHSCREEN, // TOUCH SCREEN 997 Configuration.NATIVE_CONFIG_KEYBOARD, // KEYBOARD 998 Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN, // KEYBOARD HIDDEN 999 Configuration.NATIVE_CONFIG_NAVIGATION, // NAVIGATION 1000 Configuration.NATIVE_CONFIG_ORIENTATION, // ORIENTATION 1001 Configuration.NATIVE_CONFIG_SCREEN_LAYOUT, // SCREEN LAYOUT 1002 Configuration.NATIVE_CONFIG_UI_MODE, // UI MODE 1003 Configuration.NATIVE_CONFIG_SCREEN_SIZE, // SCREEN SIZE 1004 Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE, // SMALLEST SCREEN SIZE 1005 Configuration.NATIVE_CONFIG_DENSITY, // DENSITY 1006 Configuration.NATIVE_CONFIG_LAYOUTDIR, // LAYOUT DIRECTION 1007 Configuration.NATIVE_CONFIG_COLOR_MODE, // COLOR_MODE 1008 Configuration.NATIVE_CONFIG_GRAMMATICAL_GENDER, 1009 }; 1010 1011 /** 1012 * This change id forces the packages it is applied to be resizable. It won't change whether 1013 * the app can be put into multi-windowing mode, but allow the app to resize when the window 1014 * container resizes, such as display size change. 1015 * @hide 1016 */ 1017 @ChangeId 1018 @Overridable 1019 @Disabled 1020 @TestApi 1021 public static final long FORCE_RESIZE_APP = 174042936L; // buganizer id 1022 1023 /** 1024 * This change id forces the packages it is applied to to be non-resizable. 1025 * @hide 1026 */ 1027 @ChangeId 1028 @Overridable 1029 @Disabled 1030 @TestApi 1031 public static final long FORCE_NON_RESIZE_APP = 181136395L; // buganizer id 1032 1033 /** 1034 * Return value for {@link #supportsSizeChanges()} indicating that this activity does not 1035 * support size changes due to the android.supports_size_changes metadata flag either being 1036 * unset or set to {@code false} on application or activity level. 1037 * 1038 * @hide 1039 */ 1040 public static final int SIZE_CHANGES_UNSUPPORTED_METADATA = 0; 1041 1042 /** 1043 * Return value for {@link #supportsSizeChanges()} indicating that this activity has been 1044 * overridden to not support size changes through the compat framework change id 1045 * {@link #FORCE_NON_RESIZE_APP}. 1046 * @hide 1047 */ 1048 public static final int SIZE_CHANGES_UNSUPPORTED_OVERRIDE = 1; 1049 1050 /** 1051 * Return value for {@link #supportsSizeChanges()} indicating that this activity supports size 1052 * changes due to the android.supports_size_changes metadata flag being set to {@code true} 1053 * either on application or activity level. 1054 * @hide 1055 */ 1056 public static final int SIZE_CHANGES_SUPPORTED_METADATA = 2; 1057 1058 /** 1059 * Return value for {@link #supportsSizeChanges()} indicating that this activity has been 1060 * overridden to support size changes through the compat framework change id 1061 * {@link #FORCE_RESIZE_APP}. 1062 * @hide 1063 */ 1064 public static final int SIZE_CHANGES_SUPPORTED_OVERRIDE = 3; 1065 1066 /** @hide */ 1067 @IntDef(prefix = { "SIZE_CHANGES_" }, value = { 1068 SIZE_CHANGES_UNSUPPORTED_METADATA, 1069 SIZE_CHANGES_UNSUPPORTED_OVERRIDE, 1070 SIZE_CHANGES_SUPPORTED_METADATA, 1071 SIZE_CHANGES_SUPPORTED_OVERRIDE, 1072 }) 1073 @Retention(RetentionPolicy.SOURCE) 1074 public @interface SizeChangesSupportMode {} 1075 1076 /** 1077 * This change id enables compat policy that ignores app requested orientation in 1078 * response to an app calling {@link android.app.Activity#setRequestedOrientation}. See 1079 * com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation for 1080 * details. 1081 * @hide 1082 */ 1083 @ChangeId 1084 @Overridable 1085 @Disabled 1086 @TestApi 1087 public static final long OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION = 1088 254631730L; // buganizer id 1089 1090 /** 1091 * This change id enables compat policy that ignores app requested orientation in 1092 * response to an app calling {@link android.app.Activity#setRequestedOrientation} more 1093 * than twice in one second if an activity is not letterboxed for fixed orientation. 1094 * See com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation 1095 * for details. 1096 * @hide 1097 */ 1098 @ChangeId 1099 @Overridable 1100 @Disabled 1101 public static final long OVERRIDE_ENABLE_COMPAT_IGNORE_ORIENTATION_REQUEST_WHEN_LOOP_DETECTED = 1102 273509367L; // buganizer id 1103 1104 /** 1105 * This change id forces the packages it is applied to never have Display API sandboxing 1106 * applied for a letterbox or SCM activity. The Display APIs will continue to provide 1107 * DisplayArea bounds. 1108 * @hide 1109 */ 1110 @ChangeId 1111 @Overridable 1112 @Disabled 1113 @TestApi 1114 public static final long NEVER_SANDBOX_DISPLAY_APIS = 184838306L; // buganizer id 1115 1116 /** 1117 * This change id forces the packages it is applied to always have Display API sandboxing 1118 * applied, regardless of windowing mode. The Display APIs will always provide the app bounds. 1119 * @hide 1120 */ 1121 @ChangeId 1122 @Overridable 1123 @Disabled 1124 @TestApi 1125 public static final long ALWAYS_SANDBOX_DISPLAY_APIS = 185004937L; // buganizer id 1126 1127 /** 1128 * This change id excludes the packages it is applied to from ignoreOrientationRequest behaviour 1129 * that can be enabled by the device manufacturers for the com.android.server.wm.DisplayArea 1130 * or for the whole display. 1131 * @hide 1132 */ 1133 @ChangeId 1134 @Overridable 1135 @Disabled 1136 public static final long OVERRIDE_RESPECT_REQUESTED_ORIENTATION = 236283604L; // buganizer id 1137 1138 /** 1139 * This change id excludes the packages it is applied to from the camera compat force rotation 1140 * treatment. See com.android.server.wm.DisplayRotationCompatPolicy for context. 1141 * @hide 1142 */ 1143 @ChangeId 1144 @Overridable 1145 @Disabled 1146 @TestApi 1147 public static final long OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION = 1148 263959004L; // buganizer id 1149 1150 /** 1151 * This change id excludes the packages it is applied to from activity refresh after camera 1152 * compat force rotation treatment. See com.android.server.wm.DisplayRotationCompatPolicy for 1153 * context. 1154 * @hide 1155 */ 1156 @ChangeId 1157 @Overridable 1158 @Disabled 1159 @TestApi 1160 public static final long OVERRIDE_CAMERA_COMPAT_DISABLE_REFRESH = 264304459L; // buganizer id 1161 1162 /** 1163 * This change id makes the packages it is applied to do activity refresh after camera compat 1164 * force rotation treatment using "resumed -> paused -> resumed" cycle rather than "resumed -> 1165 * ... -> stopped -> ... -> resumed" cycle. See 1166 * com.android.server.wm.DisplayRotationCompatPolicy for context. 1167 * @hide 1168 */ 1169 @ChangeId 1170 @Overridable 1171 @Disabled 1172 @TestApi 1173 public static final long OVERRIDE_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE = 1174 264301586L; // buganizer id 1175 1176 /** 1177 * This change id forces the packages it is applied to sandbox {@link android.view.View} API to 1178 * an activity bounds for: 1179 * 1180 * <p>{@link android.view.View#getLocationOnScreen}, 1181 * {@link android.view.View#getWindowVisibleDisplayFrame}, 1182 * {@link android.view.View}#getWindowDisplayFrame, 1183 * {@link android.view.View}#getBoundsOnScreen. 1184 * 1185 * <p>For {@link android.view.View#getWindowVisibleDisplayFrame} and 1186 * {@link android.view.View}#getWindowDisplayFrame this sandboxing is happening indirectly 1187 * through 1188 * {@link android.view.ViewRootImpl}#getWindowVisibleDisplayFrame, 1189 * {@link android.view.ViewRootImpl}#getDisplayFrame respectively. 1190 * 1191 * <p>Some applications assume that they occupy the whole screen and therefore use the display 1192 * coordinates in their calculations as if an activity is positioned in the top-left corner of 1193 * the screen, with left coordinate equal to 0. This may not be the case of applications in 1194 * multi-window and in letterbox modes. This can lead to shifted or out of bounds UI elements in 1195 * case the activity is Letterboxed or is in multi-window mode. 1196 * @hide 1197 */ 1198 @ChangeId 1199 @Overridable 1200 @Disabled 1201 @TestApi 1202 public static final long OVERRIDE_SANDBOX_VIEW_BOUNDS_APIS = 237531167L; // buganizer id 1203 1204 /** 1205 * This change id is the gatekeeper for all treatments that force a given min aspect ratio. 1206 * Enabling this change will allow the following min aspect ratio treatments to be applied: 1207 * OVERRIDE_MIN_ASPECT_RATIO_MEDIUM 1208 * OVERRIDE_MIN_ASPECT_RATIO_LARGE 1209 * 1210 * If OVERRIDE_MIN_ASPECT_RATIO is applied, the min aspect ratio given in the app's manifest 1211 * will be overridden to the largest enabled aspect ratio treatment unless the app's manifest 1212 * value is higher. 1213 * @hide 1214 */ 1215 @ChangeId 1216 @Overridable 1217 @Disabled 1218 @TestApi 1219 public static final long OVERRIDE_MIN_ASPECT_RATIO = 174042980L; // buganizer id 1220 1221 /** 1222 * This change id restricts treatments that force a given min aspect ratio to activities 1223 * whose orientation is fixed to portrait. 1224 * 1225 * This treatment is enabled by default and only takes effect if OVERRIDE_MIN_ASPECT_RATIO is 1226 * also enabled. 1227 * @hide 1228 */ 1229 @ChangeId 1230 @Overridable 1231 @TestApi 1232 public static final long OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY = 203647190L; // buganizer id 1233 1234 /** 1235 * This change id sets the activity's min aspect ratio to a medium value as defined by 1236 * OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE. 1237 * 1238 * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled. 1239 * @hide 1240 */ 1241 @ChangeId 1242 @Overridable 1243 @Disabled 1244 @TestApi 1245 public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // buganizer id 1246 1247 /** @hide Medium override aspect ratio, currently 3:2. */ 1248 @TestApi 1249 public static final float OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE = 3 / 2f; 1250 1251 /** 1252 * This change id sets the activity's min aspect ratio to a large value as defined by 1253 * OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE. 1254 * 1255 * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled. 1256 * @hide 1257 */ 1258 @ChangeId 1259 @Overridable 1260 @Disabled 1261 @TestApi 1262 public static final long OVERRIDE_MIN_ASPECT_RATIO_LARGE = 180326787L; // buganizer id 1263 1264 /** @hide Large override aspect ratio, currently 16:9 */ 1265 @TestApi 1266 public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 16 / 9f; 1267 1268 /** 1269 * Enables the use of split screen aspect ratio. This allows an app to use all the available 1270 * space in split mode avoiding letterboxing. 1271 * @hide 1272 */ 1273 @ChangeId 1274 @Disabled 1275 @Overridable 1276 @TestApi 1277 public static final long OVERRIDE_MIN_ASPECT_RATIO_TO_ALIGN_WITH_SPLIT_SCREEN = 208648326L; 1278 1279 /** 1280 * Overrides the min aspect ratio restriction in portrait fullscreen in order to use all 1281 * available screen space. 1282 * @hide 1283 */ 1284 @ChangeId 1285 @Disabled 1286 @Overridable 1287 @TestApi 1288 public static final long OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN = 218959984L; 1289 1290 /** 1291 * Enables sending fake focus for unfocused apps in splitscreen. Some game engines 1292 * wait to get focus before drawing the content of the app so fake focus helps them to avoid 1293 * staying blacked out when they are resumed and do not have focus yet. 1294 * @hide 1295 */ 1296 @ChangeId 1297 @Disabled 1298 @Overridable 1299 @TestApi 1300 public static final long OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS = 263259275L; 1301 1302 // Compat framework that per-app overrides rely on only supports booleans. That's why we have 1303 // multiple OVERRIDE_*_ORIENTATION_* change ids below instead of just one override with 1304 // the integer value. 1305 1306 /** 1307 * Enables {@link #SCREEN_ORIENTATION_PORTRAIT}. Unless OVERRIDE_ANY_ORIENTATION 1308 * is enabled, this override is used only when no other fixed orientation was specified by the 1309 * activity. 1310 * @hide 1311 */ 1312 @ChangeId 1313 @Disabled 1314 @Overridable 1315 @TestApi 1316 public static final long OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT = 265452344L; 1317 1318 /** 1319 * Enables {@link #SCREEN_ORIENTATION_NOSENSOR}. Unless OVERRIDE_ANY_ORIENTATION 1320 * is enabled, this override is used only when no other fixed orientation was specified by the 1321 * activity. 1322 * @hide 1323 */ 1324 @ChangeId 1325 @Disabled 1326 @Overridable 1327 @TestApi 1328 public static final long OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR = 265451093L; 1329 1330 /** 1331 * Enables {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE}. Unless OVERRIDE_ANY_ORIENTATION 1332 * is enabled, this override is used only when activity specify landscape orientation. 1333 * This can help apps that assume that landscape display orientation corresponds to {@link 1334 * android.view.Surface#ROTATION_90}, while on some devices it can be {@link 1335 * android.view.Surface#ROTATION_270}. 1336 * @hide 1337 */ 1338 @ChangeId 1339 @Disabled 1340 @Overridable 1341 @TestApi 1342 public static final long OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE = 266124927L; 1343 1344 /** 1345 * When enabled, allows OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE, 1346 * OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR and OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT 1347 * to override any orientation requested by the activity. 1348 * @hide 1349 */ 1350 @ChangeId 1351 @Disabled 1352 @Overridable 1353 public static final long OVERRIDE_ANY_ORIENTATION = 265464455L; 1354 1355 /** 1356 * When enabled, activates OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE, 1357 * OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR and OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT 1358 * only when an app is connected to the camera. See 1359 * com.android.server.wm.DisplayRotationCompatPolicy for more context. 1360 * @hide 1361 */ 1362 @ChangeId 1363 @Disabled 1364 @Overridable 1365 public static final long OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA = 265456536L; 1366 1367 /** 1368 * This override fixes display orientation to landscape natural orientation when a task is 1369 * fullscreen. While display rotation is fixed to landscape, the orientation requested by the 1370 * activity will be still respected by bounds resolution logic. For instance, if an activity 1371 * requests portrait orientation and this override is set, then activity will appear in the 1372 * letterbox mode for fixed orientation with the display rotated to the lanscape natural 1373 * orientation. 1374 * 1375 * <p>This override is applicable only when natural orientation of the device is 1376 * landscape and display ignores orientation requestes. 1377 * 1378 * <p>Main use case for this override are camera-using activities that are portrait-only and 1379 * assume alignment with natural device orientation. Such activities can automatically be 1380 * rotated with com.android.server.wm.DisplayRotationCompatPolicy but not all of them can 1381 * handle dynamic rotation and thus can benefit from this override. 1382 * 1383 * @hide 1384 */ 1385 @ChangeId 1386 @Disabled 1387 @Overridable 1388 @TestApi 1389 public static final long OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION = 255940284L; 1390 1391 /** 1392 * Compares activity window layout min width/height with require space for multi window to 1393 * determine if it can be put into multi window mode. 1394 */ 1395 @ChangeId 1396 @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S) 1397 private static final long CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW = 197654537L; 1398 1399 /** 1400 * Optional set of a certificates identifying apps that are allowed to embed this activity. From 1401 * the "knownActivityEmbeddingCerts" attribute. 1402 */ 1403 @Nullable 1404 private Set<String> mKnownActivityEmbeddingCerts; 1405 1406 /** 1407 * Convert Java change bits to native. 1408 * 1409 * @hide 1410 */ 1411 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) activityInfoConfigJavaToNative(@onfig int input)1412 public static @NativeConfig int activityInfoConfigJavaToNative(@Config int input) { 1413 int output = 0; 1414 for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { 1415 if ((input & (1 << i)) != 0) { 1416 output |= CONFIG_NATIVE_BITS[i]; 1417 } 1418 } 1419 return output; 1420 } 1421 1422 /** 1423 * Convert native change bits to Java. 1424 * 1425 * @hide 1426 */ activityInfoConfigNativeToJava(@ativeConfig int input)1427 public static @Config int activityInfoConfigNativeToJava(@NativeConfig int input) { 1428 int output = 0; 1429 for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { 1430 if ((input & CONFIG_NATIVE_BITS[i]) != 0) { 1431 output |= (1 << i); 1432 } 1433 } 1434 return output; 1435 } 1436 1437 /** 1438 * @hide 1439 * Unfortunately some developers (OpenFeint I am looking at you) have 1440 * compared the configChanges bit field against absolute values, so if we 1441 * introduce a new bit they break. To deal with that, we will make sure 1442 * the public field will not have a value that breaks them, and let the 1443 * framework call here to get the real value. 1444 */ getRealConfigChanged()1445 public int getRealConfigChanged() { 1446 return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2 1447 ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE 1448 | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) 1449 : configChanges; 1450 } 1451 1452 /** 1453 * Bit mask of kinds of configuration changes that this activity 1454 * can handle itself (without being restarted by the system). 1455 * Contains any combination of {@link #CONFIG_FONT_SCALE}, 1456 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, 1457 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, 1458 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, 1459 * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT}, 1460 * {@link #CONFIG_DENSITY}, {@link #CONFIG_LAYOUT_DIRECTION}, 1461 * {@link #CONFIG_COLOR_MODE}, and {link #CONFIG_GRAMMATICAL_GENDER}. 1462 * Set from the {@link android.R.attr#configChanges} attribute. 1463 */ 1464 public int configChanges; 1465 1466 /** 1467 * The desired soft input mode for this activity's main window. 1468 * Set from the {@link android.R.attr#windowSoftInputMode} attribute 1469 * in the activity's manifest. May be any of the same values allowed 1470 * for {@link android.view.WindowManager.LayoutParams#softInputMode 1471 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified), 1472 * the mode from the theme will be used. 1473 */ 1474 @android.view.WindowManager.LayoutParams.SoftInputModeFlags 1475 public int softInputMode; 1476 1477 /** 1478 * The desired extra UI options for this activity and its main window. 1479 * Set from the {@link android.R.attr#uiOptions} attribute in the 1480 * activity's manifest. 1481 */ 1482 public int uiOptions = 0; 1483 1484 /** 1485 * Flag for use with {@link #uiOptions}. 1486 * Indicates that the action bar should put all action items in a separate bar when 1487 * the screen is narrow. 1488 * <p>This value corresponds to "splitActionBarWhenNarrow" for the {@link #uiOptions} XML 1489 * attribute. 1490 */ 1491 public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1; 1492 1493 /** 1494 * If defined, the activity named here is the logical parent of this activity. 1495 */ 1496 public String parentActivityName; 1497 1498 /** 1499 * Screen rotation animation desired by the activity, with values as defined 1500 * for {@link android.view.WindowManager.LayoutParams#rotationAnimation}. 1501 * 1502 * -1 means to use the system default. 1503 * 1504 * @hide 1505 */ 1506 public int rotationAnimation = -1; 1507 1508 /** @hide */ 1509 public static final int LOCK_TASK_LAUNCH_MODE_DEFAULT = 0; 1510 /** @hide */ 1511 public static final int LOCK_TASK_LAUNCH_MODE_NEVER = 1; 1512 /** @hide */ 1513 public static final int LOCK_TASK_LAUNCH_MODE_ALWAYS = 2; 1514 /** @hide */ 1515 public static final int LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED = 3; 1516 1517 /** @hide */ lockTaskLaunchModeToString(int lockTaskLaunchMode)1518 public static final String lockTaskLaunchModeToString(int lockTaskLaunchMode) { 1519 switch (lockTaskLaunchMode) { 1520 case LOCK_TASK_LAUNCH_MODE_DEFAULT: 1521 return "LOCK_TASK_LAUNCH_MODE_DEFAULT"; 1522 case LOCK_TASK_LAUNCH_MODE_NEVER: 1523 return "LOCK_TASK_LAUNCH_MODE_NEVER"; 1524 case LOCK_TASK_LAUNCH_MODE_ALWAYS: 1525 return "LOCK_TASK_LAUNCH_MODE_ALWAYS"; 1526 case LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED: 1527 return "LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED"; 1528 default: 1529 return "unknown=" + lockTaskLaunchMode; 1530 } 1531 } 1532 /** 1533 * Value indicating if the activity is to be locked at startup. Takes on the values from 1534 * {@link android.R.attr#lockTaskMode}. 1535 * @hide 1536 */ 1537 public int lockTaskLaunchMode; 1538 1539 /** 1540 * Information about desired position and size of activity on the display when 1541 * it is first started. 1542 */ 1543 public WindowLayout windowLayout; 1544 ActivityInfo()1545 public ActivityInfo() { 1546 } 1547 ActivityInfo(ActivityInfo orig)1548 public ActivityInfo(ActivityInfo orig) { 1549 super(orig); 1550 theme = orig.theme; 1551 launchMode = orig.launchMode; 1552 documentLaunchMode = orig.documentLaunchMode; 1553 permission = orig.permission; 1554 mKnownActivityEmbeddingCerts = orig.mKnownActivityEmbeddingCerts; 1555 taskAffinity = orig.taskAffinity; 1556 targetActivity = orig.targetActivity; 1557 flags = orig.flags; 1558 privateFlags = orig.privateFlags; 1559 screenOrientation = orig.screenOrientation; 1560 configChanges = orig.configChanges; 1561 softInputMode = orig.softInputMode; 1562 uiOptions = orig.uiOptions; 1563 parentActivityName = orig.parentActivityName; 1564 maxRecents = orig.maxRecents; 1565 lockTaskLaunchMode = orig.lockTaskLaunchMode; 1566 windowLayout = orig.windowLayout; 1567 resizeMode = orig.resizeMode; 1568 requestedVrComponent = orig.requestedVrComponent; 1569 rotationAnimation = orig.rotationAnimation; 1570 colorMode = orig.colorMode; 1571 mMaxAspectRatio = orig.mMaxAspectRatio; 1572 mMinAspectRatio = orig.mMinAspectRatio; 1573 supportsSizeChanges = orig.supportsSizeChanges; 1574 requiredDisplayCategory = orig.requiredDisplayCategory; 1575 } 1576 1577 /** 1578 * Return the theme resource identifier to use for this activity. If 1579 * the activity defines a theme, that is used; else, the application 1580 * theme is used. 1581 * 1582 * @return The theme associated with this activity. 1583 */ getThemeResource()1584 public final int getThemeResource() { 1585 return theme != 0 ? theme : applicationInfo.theme; 1586 } 1587 persistableModeToString()1588 private String persistableModeToString() { 1589 switch(persistableMode) { 1590 case PERSIST_ROOT_ONLY: return "PERSIST_ROOT_ONLY"; 1591 case PERSIST_NEVER: return "PERSIST_NEVER"; 1592 case PERSIST_ACROSS_REBOOTS: return "PERSIST_ACROSS_REBOOTS"; 1593 default: return "UNKNOWN=" + persistableMode; 1594 } 1595 } 1596 1597 /** 1598 * Returns true if the activity has maximum or minimum aspect ratio. 1599 * @hide 1600 */ hasFixedAspectRatio()1601 public boolean hasFixedAspectRatio() { 1602 return getMaxAspectRatio() != 0 || getMinAspectRatio() != 0; 1603 } 1604 1605 /** 1606 * Returns true if the activity's orientation is fixed. 1607 * @hide 1608 */ isFixedOrientation()1609 public boolean isFixedOrientation() { 1610 return isFixedOrientation(screenOrientation); 1611 } 1612 1613 /** 1614 * Returns true if the passed activity's orientation is fixed. 1615 * @hide 1616 */ isFixedOrientation(@creenOrientation int orientation)1617 public static boolean isFixedOrientation(@ScreenOrientation int orientation) { 1618 return orientation == SCREEN_ORIENTATION_LOCKED 1619 // Orientation is fixed to natural display orientation 1620 || orientation == SCREEN_ORIENTATION_NOSENSOR 1621 || isFixedOrientationLandscape(orientation) 1622 || isFixedOrientationPortrait(orientation); 1623 } 1624 1625 /** 1626 * Returns true if the activity's orientation is fixed to landscape. 1627 * @hide 1628 */ isFixedOrientationLandscape()1629 boolean isFixedOrientationLandscape() { 1630 return isFixedOrientationLandscape(screenOrientation); 1631 } 1632 1633 /** 1634 * Returns true if the activity's orientation is fixed to landscape. 1635 * @hide 1636 */ isFixedOrientationLandscape(@creenOrientation int orientation)1637 public static boolean isFixedOrientationLandscape(@ScreenOrientation int orientation) { 1638 return orientation == SCREEN_ORIENTATION_LANDSCAPE 1639 || orientation == SCREEN_ORIENTATION_SENSOR_LANDSCAPE 1640 || orientation == SCREEN_ORIENTATION_REVERSE_LANDSCAPE 1641 || orientation == SCREEN_ORIENTATION_USER_LANDSCAPE; 1642 } 1643 1644 /** 1645 * Returns true if the activity's orientation is fixed to portrait. 1646 * @hide 1647 */ isFixedOrientationPortrait()1648 boolean isFixedOrientationPortrait() { 1649 return isFixedOrientationPortrait(screenOrientation); 1650 } 1651 1652 /** 1653 * Returns true if the activity's orientation is fixed to portrait. 1654 * @hide 1655 */ isFixedOrientationPortrait(@creenOrientation int orientation)1656 public static boolean isFixedOrientationPortrait(@ScreenOrientation int orientation) { 1657 return orientation == SCREEN_ORIENTATION_PORTRAIT 1658 || orientation == SCREEN_ORIENTATION_SENSOR_PORTRAIT 1659 || orientation == SCREEN_ORIENTATION_REVERSE_PORTRAIT 1660 || orientation == SCREEN_ORIENTATION_USER_PORTRAIT; 1661 } 1662 1663 /** 1664 * Returns the reversed orientation. 1665 * @hide 1666 */ 1667 @ActivityInfo.ScreenOrientation reverseOrientation(@ctivityInfo.ScreenOrientation int orientation)1668 public static int reverseOrientation(@ActivityInfo.ScreenOrientation int orientation) { 1669 switch (orientation) { 1670 case SCREEN_ORIENTATION_LANDSCAPE: 1671 return SCREEN_ORIENTATION_PORTRAIT; 1672 case SCREEN_ORIENTATION_PORTRAIT: 1673 return SCREEN_ORIENTATION_LANDSCAPE; 1674 case SCREEN_ORIENTATION_SENSOR_LANDSCAPE: 1675 return SCREEN_ORIENTATION_SENSOR_PORTRAIT; 1676 case SCREEN_ORIENTATION_SENSOR_PORTRAIT: 1677 return SCREEN_ORIENTATION_SENSOR_LANDSCAPE; 1678 case SCREEN_ORIENTATION_REVERSE_LANDSCAPE: 1679 return SCREEN_ORIENTATION_REVERSE_PORTRAIT; 1680 case SCREEN_ORIENTATION_REVERSE_PORTRAIT: 1681 return SCREEN_ORIENTATION_REVERSE_LANDSCAPE; 1682 case SCREEN_ORIENTATION_USER_LANDSCAPE: 1683 return SCREEN_ORIENTATION_USER_PORTRAIT; 1684 case SCREEN_ORIENTATION_USER_PORTRAIT: 1685 return SCREEN_ORIENTATION_USER_LANDSCAPE; 1686 default: 1687 return orientation; 1688 } 1689 } 1690 1691 /** 1692 * Returns true if the activity supports picture-in-picture. 1693 * @hide 1694 */ 1695 @UnsupportedAppUsage supportsPictureInPicture()1696 public boolean supportsPictureInPicture() { 1697 return (flags & FLAG_SUPPORTS_PICTURE_IN_PICTURE) != 0; 1698 } 1699 1700 /** 1701 * Returns if the activity should never be sandboxed to the activity window bounds. 1702 * @hide 1703 */ neverSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig)1704 public boolean neverSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig) { 1705 return isChangeEnabled(NEVER_SANDBOX_DISPLAY_APIS) 1706 || constrainDisplayApisConfig.getNeverConstrainDisplayApis(applicationInfo); 1707 } 1708 1709 /** 1710 * Returns if the activity should always be sandboxed to the activity window bounds. 1711 * @hide 1712 */ alwaysSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig)1713 public boolean alwaysSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig) { 1714 return isChangeEnabled(ALWAYS_SANDBOX_DISPLAY_APIS) 1715 || constrainDisplayApisConfig.getAlwaysConstrainDisplayApis(applicationInfo); 1716 } 1717 1718 /** @hide */ setMaxAspectRatio(@loatRangefrom = 0f) float maxAspectRatio)1719 public void setMaxAspectRatio(@FloatRange(from = 0f) float maxAspectRatio) { 1720 this.mMaxAspectRatio = maxAspectRatio >= 0f ? maxAspectRatio : 0f; 1721 } 1722 1723 /** @hide */ getMaxAspectRatio()1724 public float getMaxAspectRatio() { 1725 return mMaxAspectRatio; 1726 } 1727 1728 /** @hide */ setMinAspectRatio(@loatRangefrom = 0f) float minAspectRatio)1729 public void setMinAspectRatio(@FloatRange(from = 0f) float minAspectRatio) { 1730 this.mMinAspectRatio = minAspectRatio >= 0f ? minAspectRatio : 0f; 1731 } 1732 1733 /** 1734 * Returns the min aspect ratio of this activity as defined in the manifest file. 1735 * @hide 1736 */ getMinAspectRatio()1737 public float getMinAspectRatio() { 1738 return mMinAspectRatio; 1739 } 1740 1741 /** 1742 * Gets the trusted host certificate digests of apps that are allowed to embed this activity. 1743 * The digests are computed using the SHA-256 digest algorithm. 1744 * @see android.R.attr#knownActivityEmbeddingCerts 1745 */ 1746 @NonNull getKnownActivityEmbeddingCerts()1747 public Set<String> getKnownActivityEmbeddingCerts() { 1748 return mKnownActivityEmbeddingCerts == null ? Collections.emptySet() 1749 : mKnownActivityEmbeddingCerts; 1750 } 1751 1752 /** 1753 * Sets the trusted host certificates of apps that are allowed to embed this activity. 1754 * @see #getKnownActivityEmbeddingCerts() 1755 * @hide 1756 */ setKnownActivityEmbeddingCerts(@onNull Set<String> knownActivityEmbeddingCerts)1757 public void setKnownActivityEmbeddingCerts(@NonNull Set<String> knownActivityEmbeddingCerts) { 1758 // Convert the provided digest to upper case for consistent Set membership 1759 // checks when verifying the signing certificate digests of requesting apps. 1760 mKnownActivityEmbeddingCerts = new ArraySet<>(); 1761 for (String knownCert : knownActivityEmbeddingCerts) { 1762 mKnownActivityEmbeddingCerts.add(knownCert.toUpperCase(Locale.US)); 1763 } 1764 } 1765 1766 /** 1767 * Checks if a changeId is enabled for the current user 1768 * @param changeId The changeId to verify 1769 * @return True of the changeId is enabled 1770 * @hide 1771 */ isChangeEnabled(long changeId)1772 public boolean isChangeEnabled(long changeId) { 1773 return CompatChanges.isChangeEnabled(changeId, applicationInfo.packageName, 1774 UserHandle.getUserHandleForUid(applicationInfo.uid)); 1775 } 1776 1777 /** @hide */ getManifestMinAspectRatio()1778 public float getManifestMinAspectRatio() { 1779 return mMinAspectRatio; 1780 } 1781 1782 /** @hide */ 1783 @UnsupportedAppUsage isResizeableMode(int mode)1784 public static boolean isResizeableMode(int mode) { 1785 return mode == RESIZE_MODE_RESIZEABLE 1786 || mode == RESIZE_MODE_FORCE_RESIZEABLE 1787 || mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY 1788 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY 1789 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION 1790 || mode == RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION; 1791 } 1792 1793 /** @hide */ isPreserveOrientationMode(int mode)1794 public static boolean isPreserveOrientationMode(int mode) { 1795 return mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY 1796 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY 1797 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION; 1798 } 1799 1800 /** @hide */ resizeModeToString(int mode)1801 public static String resizeModeToString(int mode) { 1802 switch (mode) { 1803 case RESIZE_MODE_UNRESIZEABLE: 1804 return "RESIZE_MODE_UNRESIZEABLE"; 1805 case RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION: 1806 return "RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION"; 1807 case RESIZE_MODE_RESIZEABLE: 1808 return "RESIZE_MODE_RESIZEABLE"; 1809 case RESIZE_MODE_FORCE_RESIZEABLE: 1810 return "RESIZE_MODE_FORCE_RESIZEABLE"; 1811 case RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY: 1812 return "RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY"; 1813 case RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY: 1814 return "RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY"; 1815 case RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION: 1816 return "RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION"; 1817 default: 1818 return "unknown=" + mode; 1819 } 1820 } 1821 1822 /** @hide */ sizeChangesSupportModeToString(@izeChangesSupportMode int mode)1823 public static String sizeChangesSupportModeToString(@SizeChangesSupportMode int mode) { 1824 switch (mode) { 1825 case SIZE_CHANGES_UNSUPPORTED_METADATA: 1826 return "SIZE_CHANGES_UNSUPPORTED_METADATA"; 1827 case SIZE_CHANGES_UNSUPPORTED_OVERRIDE: 1828 return "SIZE_CHANGES_UNSUPPORTED_OVERRIDE"; 1829 case SIZE_CHANGES_SUPPORTED_METADATA: 1830 return "SIZE_CHANGES_SUPPORTED_METADATA"; 1831 case SIZE_CHANGES_SUPPORTED_OVERRIDE: 1832 return "SIZE_CHANGES_SUPPORTED_OVERRIDE"; 1833 default: 1834 return "unknown=" + mode; 1835 } 1836 } 1837 1838 /** 1839 * Whether we should compare activity window layout min width/height with require space for 1840 * multi window to determine if it can be put into multi window mode. 1841 * @hide 1842 */ shouldCheckMinWidthHeightForMultiWindow()1843 public boolean shouldCheckMinWidthHeightForMultiWindow() { 1844 return isChangeEnabled(CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW); 1845 } 1846 1847 /** 1848 * Returns whether the activity will set the 1849 * {@link R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback} attribute. 1850 * 1851 * @hide 1852 */ hasOnBackInvokedCallbackEnabled()1853 public boolean hasOnBackInvokedCallbackEnabled() { 1854 return (privateFlags & (PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK 1855 | PRIVATE_FLAG_DISABLE_ON_BACK_INVOKED_CALLBACK)) != 0; 1856 } 1857 1858 /** 1859 * Returns whether the activity will use the {@link android.window.OnBackInvokedCallback} 1860 * navigation system instead of the {@link android.view.KeyEvent#KEYCODE_BACK} and related 1861 * callbacks. 1862 * 1863 * Valid when the {@link R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback} 1864 * attribute has been set, or it won't indicate if the activity should use the 1865 * navigation system and the {@link hasOnBackInvokedCallbackEnabled} will return false. 1866 * @hide 1867 */ isOnBackInvokedCallbackEnabled()1868 public boolean isOnBackInvokedCallbackEnabled() { 1869 return hasOnBackInvokedCallbackEnabled() 1870 && (privateFlags & PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK) != 0; 1871 } 1872 dump(Printer pw, String prefix)1873 public void dump(Printer pw, String prefix) { 1874 dump(pw, prefix, DUMP_FLAG_ALL); 1875 } 1876 1877 /** @hide */ dump(Printer pw, String prefix, int dumpFlags)1878 public void dump(Printer pw, String prefix, int dumpFlags) { 1879 super.dumpFront(pw, prefix); 1880 if (permission != null) { 1881 pw.println(prefix + "permission=" + permission); 1882 } 1883 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) { 1884 pw.println(prefix + "taskAffinity=" + taskAffinity 1885 + " targetActivity=" + targetActivity 1886 + " persistableMode=" + persistableModeToString()); 1887 } 1888 if (launchMode != 0 || flags != 0 || privateFlags != 0 || theme != 0) { 1889 pw.println(prefix + "launchMode=" + launchModeToString(launchMode) 1890 + " flags=0x" + Integer.toHexString(flags) 1891 + " privateFlags=0x" + Integer.toHexString(privateFlags) 1892 + " theme=0x" + Integer.toHexString(theme)); 1893 } 1894 if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED 1895 || configChanges != 0 || softInputMode != 0) { 1896 pw.println(prefix + "screenOrientation=" + screenOrientation 1897 + " configChanges=0x" + Integer.toHexString(configChanges) 1898 + " softInputMode=0x" + Integer.toHexString(softInputMode)); 1899 } 1900 if (uiOptions != 0) { 1901 pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions)); 1902 } 1903 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) { 1904 pw.println(prefix + "lockTaskLaunchMode=" 1905 + lockTaskLaunchModeToString(lockTaskLaunchMode)); 1906 } 1907 if (windowLayout != null) { 1908 pw.println(prefix + "windowLayout=" + windowLayout.width + "|" 1909 + windowLayout.widthFraction + ", " + windowLayout.height + "|" 1910 + windowLayout.heightFraction + ", " + windowLayout.gravity); 1911 } 1912 pw.println(prefix + "resizeMode=" + resizeModeToString(resizeMode)); 1913 if (requestedVrComponent != null) { 1914 pw.println(prefix + "requestedVrComponent=" + requestedVrComponent); 1915 } 1916 if (getMaxAspectRatio() != 0) { 1917 pw.println(prefix + "maxAspectRatio=" + getMaxAspectRatio()); 1918 } 1919 final float minAspectRatio = getMinAspectRatio(); 1920 if (minAspectRatio != 0) { 1921 pw.println(prefix + "minAspectRatio=" + minAspectRatio); 1922 } 1923 if (supportsSizeChanges) { 1924 pw.println(prefix + "supportsSizeChanges=true"); 1925 } 1926 if (mKnownActivityEmbeddingCerts != null) { 1927 pw.println(prefix + "knownActivityEmbeddingCerts=" + mKnownActivityEmbeddingCerts); 1928 } 1929 if (requiredDisplayCategory != null) { 1930 pw.println(prefix + "requiredDisplayCategory=" + requiredDisplayCategory); 1931 } 1932 super.dumpBack(pw, prefix, dumpFlags); 1933 } 1934 toString()1935 public String toString() { 1936 return "ActivityInfo{" 1937 + Integer.toHexString(System.identityHashCode(this)) 1938 + " " + name + "}"; 1939 } 1940 describeContents()1941 public int describeContents() { 1942 return 0; 1943 } 1944 writeToParcel(Parcel dest, int parcelableFlags)1945 public void writeToParcel(Parcel dest, int parcelableFlags) { 1946 super.writeToParcel(dest, parcelableFlags); 1947 dest.writeInt(theme); 1948 dest.writeInt(launchMode); 1949 dest.writeInt(documentLaunchMode); 1950 dest.writeString8(permission); 1951 dest.writeString8(taskAffinity); 1952 dest.writeString8(targetActivity); 1953 dest.writeString8(launchToken); 1954 dest.writeInt(flags); 1955 dest.writeInt(privateFlags); 1956 dest.writeInt(screenOrientation); 1957 dest.writeInt(configChanges); 1958 dest.writeInt(softInputMode); 1959 dest.writeInt(uiOptions); 1960 dest.writeString8(parentActivityName); 1961 dest.writeInt(persistableMode); 1962 dest.writeInt(maxRecents); 1963 dest.writeInt(lockTaskLaunchMode); 1964 if (windowLayout != null) { 1965 dest.writeInt(1); 1966 windowLayout.writeToParcel(dest); 1967 } else { 1968 dest.writeInt(0); 1969 } 1970 dest.writeInt(resizeMode); 1971 dest.writeString8(requestedVrComponent); 1972 dest.writeInt(rotationAnimation); 1973 dest.writeInt(colorMode); 1974 dest.writeFloat(mMaxAspectRatio); 1975 dest.writeFloat(mMinAspectRatio); 1976 dest.writeBoolean(supportsSizeChanges); 1977 sForStringSet.parcel(mKnownActivityEmbeddingCerts, dest, flags); 1978 dest.writeString8(requiredDisplayCategory); 1979 } 1980 1981 /** 1982 * Determines whether the {@link Activity} is considered translucent or floating. 1983 * @hide 1984 */ 1985 @UnsupportedAppUsage 1986 @TestApi isTranslucentOrFloating(TypedArray attributes)1987 public static boolean isTranslucentOrFloating(TypedArray attributes) { 1988 final boolean isTranslucent = 1989 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent, 1990 false); 1991 final boolean isFloating = 1992 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating, 1993 false); 1994 1995 return isFloating || isTranslucent; 1996 } 1997 1998 /** 1999 * Convert the screen orientation constant to a human readable format. 2000 * @hide 2001 */ screenOrientationToString(int orientation)2002 public static String screenOrientationToString(int orientation) { 2003 switch (orientation) { 2004 case SCREEN_ORIENTATION_UNSET: 2005 return "SCREEN_ORIENTATION_UNSET"; 2006 case SCREEN_ORIENTATION_UNSPECIFIED: 2007 return "SCREEN_ORIENTATION_UNSPECIFIED"; 2008 case SCREEN_ORIENTATION_LANDSCAPE: 2009 return "SCREEN_ORIENTATION_LANDSCAPE"; 2010 case SCREEN_ORIENTATION_PORTRAIT: 2011 return "SCREEN_ORIENTATION_PORTRAIT"; 2012 case SCREEN_ORIENTATION_USER: 2013 return "SCREEN_ORIENTATION_USER"; 2014 case SCREEN_ORIENTATION_BEHIND: 2015 return "SCREEN_ORIENTATION_BEHIND"; 2016 case SCREEN_ORIENTATION_SENSOR: 2017 return "SCREEN_ORIENTATION_SENSOR"; 2018 case SCREEN_ORIENTATION_NOSENSOR: 2019 return "SCREEN_ORIENTATION_NOSENSOR"; 2020 case SCREEN_ORIENTATION_SENSOR_LANDSCAPE: 2021 return "SCREEN_ORIENTATION_SENSOR_LANDSCAPE"; 2022 case SCREEN_ORIENTATION_SENSOR_PORTRAIT: 2023 return "SCREEN_ORIENTATION_SENSOR_PORTRAIT"; 2024 case SCREEN_ORIENTATION_REVERSE_LANDSCAPE: 2025 return "SCREEN_ORIENTATION_REVERSE_LANDSCAPE"; 2026 case SCREEN_ORIENTATION_REVERSE_PORTRAIT: 2027 return "SCREEN_ORIENTATION_REVERSE_PORTRAIT"; 2028 case SCREEN_ORIENTATION_FULL_SENSOR: 2029 return "SCREEN_ORIENTATION_FULL_SENSOR"; 2030 case SCREEN_ORIENTATION_USER_LANDSCAPE: 2031 return "SCREEN_ORIENTATION_USER_LANDSCAPE"; 2032 case SCREEN_ORIENTATION_USER_PORTRAIT: 2033 return "SCREEN_ORIENTATION_USER_PORTRAIT"; 2034 case SCREEN_ORIENTATION_FULL_USER: 2035 return "SCREEN_ORIENTATION_FULL_USER"; 2036 case SCREEN_ORIENTATION_LOCKED: 2037 return "SCREEN_ORIENTATION_LOCKED"; 2038 default: 2039 return Integer.toString(orientation); 2040 } 2041 } 2042 2043 /** 2044 * @hide 2045 */ colorModeToString(@olorMode int colorMode)2046 public static String colorModeToString(@ColorMode int colorMode) { 2047 switch (colorMode) { 2048 case COLOR_MODE_DEFAULT: 2049 return "COLOR_MODE_DEFAULT"; 2050 case COLOR_MODE_WIDE_COLOR_GAMUT: 2051 return "COLOR_MODE_WIDE_COLOR_GAMUT"; 2052 case COLOR_MODE_HDR: 2053 return "COLOR_MODE_HDR"; 2054 case COLOR_MODE_A8: 2055 return "COLOR_MODE_A8"; 2056 default: 2057 return Integer.toString(colorMode); 2058 } 2059 } 2060 2061 public static final @android.annotation.NonNull Parcelable.Creator<ActivityInfo> CREATOR 2062 = new Parcelable.Creator<ActivityInfo>() { 2063 public ActivityInfo createFromParcel(Parcel source) { 2064 return new ActivityInfo(source); 2065 } 2066 public ActivityInfo[] newArray(int size) { 2067 return new ActivityInfo[size]; 2068 } 2069 }; 2070 ActivityInfo(Parcel source)2071 private ActivityInfo(Parcel source) { 2072 super(source); 2073 theme = source.readInt(); 2074 launchMode = source.readInt(); 2075 documentLaunchMode = source.readInt(); 2076 permission = source.readString8(); 2077 taskAffinity = source.readString8(); 2078 targetActivity = source.readString8(); 2079 launchToken = source.readString8(); 2080 flags = source.readInt(); 2081 privateFlags = source.readInt(); 2082 screenOrientation = source.readInt(); 2083 configChanges = source.readInt(); 2084 softInputMode = source.readInt(); 2085 uiOptions = source.readInt(); 2086 parentActivityName = source.readString8(); 2087 persistableMode = source.readInt(); 2088 maxRecents = source.readInt(); 2089 lockTaskLaunchMode = source.readInt(); 2090 if (source.readInt() == 1) { 2091 windowLayout = new WindowLayout(source); 2092 } 2093 resizeMode = source.readInt(); 2094 requestedVrComponent = source.readString8(); 2095 rotationAnimation = source.readInt(); 2096 colorMode = source.readInt(); 2097 mMaxAspectRatio = source.readFloat(); 2098 mMinAspectRatio = source.readFloat(); 2099 supportsSizeChanges = source.readBoolean(); 2100 mKnownActivityEmbeddingCerts = sForStringSet.unparcel(source); 2101 if (mKnownActivityEmbeddingCerts.isEmpty()) { 2102 mKnownActivityEmbeddingCerts = null; 2103 } 2104 requiredDisplayCategory = source.readString8(); 2105 } 2106 2107 /** 2108 * Contains information about position and size of the activity on the display. 2109 * 2110 * Used in freeform mode to set desired position when activity is first launched. 2111 * It describes how big the activity wants to be in both width and height, 2112 * the minimal allowed size, and the gravity to be applied. 2113 * 2114 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth 2115 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight 2116 * @attr ref android.R.styleable#AndroidManifestLayout_gravity 2117 * @attr ref android.R.styleable#AndroidManifestLayout_minWidth 2118 * @attr ref android.R.styleable#AndroidManifestLayout_minHeight 2119 */ 2120 public static final class WindowLayout { WindowLayout(int width, float widthFraction, int height, float heightFraction, int gravity, int minWidth, int minHeight)2121 public WindowLayout(int width, float widthFraction, int height, float heightFraction, 2122 int gravity, int minWidth, int minHeight) { 2123 this(width, widthFraction, height, heightFraction, gravity, minWidth, minHeight, 2124 null /* windowLayoutAffinity */); 2125 } 2126 2127 /** @hide */ WindowLayout(int width, float widthFraction, int height, float heightFraction, int gravity, int minWidth, int minHeight, String windowLayoutAffinity)2128 public WindowLayout(int width, float widthFraction, int height, float heightFraction, 2129 int gravity, int minWidth, int minHeight, String windowLayoutAffinity) { 2130 this.width = width; 2131 this.widthFraction = widthFraction; 2132 this.height = height; 2133 this.heightFraction = heightFraction; 2134 this.gravity = gravity; 2135 this.minWidth = minWidth; 2136 this.minHeight = minHeight; 2137 this.windowLayoutAffinity = windowLayoutAffinity; 2138 } 2139 2140 /** @hide */ WindowLayout(Parcel source)2141 public WindowLayout(Parcel source) { 2142 width = source.readInt(); 2143 widthFraction = source.readFloat(); 2144 height = source.readInt(); 2145 heightFraction = source.readFloat(); 2146 gravity = source.readInt(); 2147 minWidth = source.readInt(); 2148 minHeight = source.readInt(); 2149 windowLayoutAffinity = source.readString8(); 2150 } 2151 2152 /** 2153 * Width of activity in pixels. 2154 * 2155 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth 2156 */ 2157 public final int width; 2158 2159 /** 2160 * Width of activity as a fraction of available display width. 2161 * If both {@link #width} and this value are set this one will be preferred. 2162 * 2163 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth 2164 */ 2165 public final float widthFraction; 2166 2167 /** 2168 * Height of activity in pixels. 2169 * 2170 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight 2171 */ 2172 public final int height; 2173 2174 /** 2175 * Height of activity as a fraction of available display height. 2176 * If both {@link #height} and this value are set this one will be preferred. 2177 * 2178 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight 2179 */ 2180 public final float heightFraction; 2181 2182 /** 2183 * Gravity of activity. 2184 * Currently {@link android.view.Gravity#TOP}, {@link android.view.Gravity#BOTTOM}, 2185 * {@link android.view.Gravity#LEFT} and {@link android.view.Gravity#RIGHT} are supported. 2186 * 2187 * @attr ref android.R.styleable#AndroidManifestLayout_gravity 2188 */ 2189 public final int gravity; 2190 2191 /** 2192 * Minimal width of activity in pixels to be able to display its content. 2193 * 2194 * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional 2195 * activities launched in the task. That is if the root activity of a task set minimal 2196 * width, then the system will set the same minimal width on all other activities in the 2197 * task. It will also ignore any other minimal width attributes of non-root activities. 2198 * 2199 * @attr ref android.R.styleable#AndroidManifestLayout_minWidth 2200 */ 2201 public final int minWidth; 2202 2203 /** 2204 * Minimal height of activity in pixels to be able to display its content. 2205 * 2206 * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional 2207 * activities launched in the task. That is if the root activity of a task set minimal 2208 * height, then the system will set the same minimal height on all other activities in the 2209 * task. It will also ignore any other minimal height attributes of non-root activities. 2210 * 2211 * @attr ref android.R.styleable#AndroidManifestLayout_minHeight 2212 */ 2213 public final int minHeight; 2214 2215 /** 2216 * Affinity of window layout parameters. Activities with the same UID and window layout 2217 * affinity will share the same window dimension record. 2218 * 2219 * @attr ref android.R.styleable#AndroidManifestLayout_windowLayoutAffinity 2220 * @hide 2221 */ 2222 public String windowLayoutAffinity; 2223 2224 /** 2225 * Returns if this {@link WindowLayout} has specified bounds. 2226 * @hide 2227 */ hasSpecifiedSize()2228 public boolean hasSpecifiedSize() { 2229 return width >= 0 || height >= 0 || widthFraction >= 0 || heightFraction >= 0; 2230 } 2231 2232 /** @hide */ writeToParcel(Parcel dest)2233 public void writeToParcel(Parcel dest) { 2234 dest.writeInt(width); 2235 dest.writeFloat(widthFraction); 2236 dest.writeInt(height); 2237 dest.writeFloat(heightFraction); 2238 dest.writeInt(gravity); 2239 dest.writeInt(minWidth); 2240 dest.writeInt(minHeight); 2241 dest.writeString8(windowLayoutAffinity); 2242 } 2243 } 2244 } 2245