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