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