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.content.Intent; 22 import android.content.res.Configuration; 23 import android.content.res.Configuration.NativeConfig; 24 import android.content.res.TypedArray; 25 import android.os.Parcel; 26 import android.os.Parcelable; 27 import android.util.Printer; 28 29 import java.lang.annotation.Retention; 30 import java.lang.annotation.RetentionPolicy; 31 32 /** 33 * Information you can retrieve about a particular application 34 * activity or receiver. This corresponds to information collected 35 * from the AndroidManifest.xml's <activity> and 36 * <receiver> tags. 37 */ 38 public class ActivityInfo extends ComponentInfo implements Parcelable { 39 40 // NOTE: When adding new data members be sure to update the copy-constructor, Parcel 41 // constructor, and writeToParcel. 42 43 /** 44 * A style resource identifier (in the package's resources) of this 45 * activity's theme. From the "theme" attribute or, if not set, 0. 46 */ 47 public int theme; 48 49 /** 50 * Constant corresponding to <code>standard</code> in 51 * the {@link android.R.attr#launchMode} attribute. 52 */ 53 public static final int LAUNCH_MULTIPLE = 0; 54 /** 55 * Constant corresponding to <code>singleTop</code> in 56 * the {@link android.R.attr#launchMode} attribute. 57 */ 58 public static final int LAUNCH_SINGLE_TOP = 1; 59 /** 60 * Constant corresponding to <code>singleTask</code> in 61 * the {@link android.R.attr#launchMode} attribute. 62 */ 63 public static final int LAUNCH_SINGLE_TASK = 2; 64 /** 65 * Constant corresponding to <code>singleInstance</code> in 66 * the {@link android.R.attr#launchMode} attribute. 67 */ 68 public static final int LAUNCH_SINGLE_INSTANCE = 3; 69 /** 70 * The launch mode style requested by the activity. From the 71 * {@link android.R.attr#launchMode} attribute, one of 72 * {@link #LAUNCH_MULTIPLE}, 73 * {@link #LAUNCH_SINGLE_TOP}, {@link #LAUNCH_SINGLE_TASK}, or 74 * {@link #LAUNCH_SINGLE_INSTANCE}. 75 */ 76 public int launchMode; 77 78 /** 79 * Constant corresponding to <code>none</code> in 80 * the {@link android.R.attr#documentLaunchMode} attribute. 81 */ 82 public static final int DOCUMENT_LAUNCH_NONE = 0; 83 /** 84 * Constant corresponding to <code>intoExisting</code> in 85 * the {@link android.R.attr#documentLaunchMode} attribute. 86 */ 87 public static final int DOCUMENT_LAUNCH_INTO_EXISTING = 1; 88 /** 89 * Constant corresponding to <code>always</code> in 90 * the {@link android.R.attr#documentLaunchMode} attribute. 91 */ 92 public static final int DOCUMENT_LAUNCH_ALWAYS = 2; 93 /** 94 * Constant corresponding to <code>never</code> in 95 * the {@link android.R.attr#documentLaunchMode} attribute. 96 */ 97 public static final int DOCUMENT_LAUNCH_NEVER = 3; 98 /** 99 * The document launch mode style requested by the activity. From the 100 * {@link android.R.attr#documentLaunchMode} attribute, one of 101 * {@link #DOCUMENT_LAUNCH_NONE}, {@link #DOCUMENT_LAUNCH_INTO_EXISTING}, 102 * {@link #DOCUMENT_LAUNCH_ALWAYS}. 103 * 104 * <p>Modes DOCUMENT_LAUNCH_ALWAYS 105 * and DOCUMENT_LAUNCH_INTO_EXISTING are equivalent to {@link 106 * android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT 107 * Intent.FLAG_ACTIVITY_NEW_DOCUMENT} with and without {@link 108 * android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK 109 * Intent.FLAG_ACTIVITY_MULTIPLE_TASK} respectively. 110 */ 111 public int documentLaunchMode; 112 113 /** 114 * Constant corresponding to <code>persistRootOnly</code> in 115 * the {@link android.R.attr#persistableMode} attribute. 116 */ 117 public static final int PERSIST_ROOT_ONLY = 0; 118 /** 119 * Constant corresponding to <code>doNotPersist</code> in 120 * the {@link android.R.attr#persistableMode} attribute. 121 */ 122 public static final int PERSIST_NEVER = 1; 123 /** 124 * Constant corresponding to <code>persistAcrossReboots</code> in 125 * the {@link android.R.attr#persistableMode} attribute. 126 */ 127 public static final int PERSIST_ACROSS_REBOOTS = 2; 128 /** 129 * Value indicating how this activity is to be persisted across 130 * reboots for restoring in the Recents list. 131 * {@link android.R.attr#persistableMode} 132 */ 133 public int persistableMode; 134 135 /** 136 * The maximum number of tasks rooted at this activity that can be in the recent task list. 137 * Refer to {@link android.R.attr#maxRecents}. 138 */ 139 public int maxRecents; 140 141 /** 142 * Optional name of a permission required to be able to access this 143 * Activity. From the "permission" attribute. 144 */ 145 public String permission; 146 147 /** 148 * The affinity this activity has for another task in the system. The 149 * string here is the name of the task, often the package name of the 150 * overall package. If null, the activity has no affinity. Set from the 151 * {@link android.R.attr#taskAffinity} attribute. 152 */ 153 public String taskAffinity; 154 155 /** 156 * If this is an activity alias, this is the real activity class to run 157 * for it. Otherwise, this is null. 158 */ 159 public String targetActivity; 160 161 /** 162 * Token used to string together multiple events within a single launch action. 163 * @hide 164 */ 165 public String launchToken; 166 167 /** 168 * Activity can not be resized and always occupies the fullscreen area with all windows fully 169 * visible. 170 * @hide 171 */ 172 public static final int RESIZE_MODE_UNRESIZEABLE = 0; 173 /** 174 * Activity didn't explicitly request to be resizeable, but we are making it resizeable because 175 * of the SDK version it targets. Only affects apps with target SDK >= N where the app is 176 * implied to be resizeable if it doesn't explicitly set the attribute to any value. 177 * @hide 178 */ 179 public static final int RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION = 1; 180 /** 181 * Activity explicitly requested to be resizeable. 182 * @hide 183 */ 184 @TestApi 185 public static final int RESIZE_MODE_RESIZEABLE = 2; 186 /** 187 * Activity is resizeable and supported picture-in-picture mode. This flag is now deprecated 188 * since activities do not need to be resizeable to support picture-in-picture. 189 * See {@link #FLAG_SUPPORTS_PICTURE_IN_PICTURE}. 190 * 191 * @hide 192 * @deprecated 193 */ 194 public static final int RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED = 3; 195 /** 196 * Activity does not support resizing, but we are forcing it to be resizeable. Only affects 197 * certain pre-N apps where we force them to be resizeable. 198 * @hide 199 */ 200 public static final int RESIZE_MODE_FORCE_RESIZEABLE = 4; 201 /** 202 * Activity does not support resizing, but we are forcing it to be resizeable as long 203 * as the size remains landscape. 204 * @hide 205 */ 206 public static final int RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY = 5; 207 /** 208 * Activity does not support resizing, but we are forcing it to be resizeable as long 209 * as the size remains portrait. 210 * @hide 211 */ 212 public static final int RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY = 6; 213 /** 214 * Activity does not support resizing, but we are forcing it to be resizeable as long 215 * as the bounds remain in the same orientation as they are. 216 * @hide 217 */ 218 public static final int RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION = 7; 219 /** 220 * Value indicating if the resizing mode the activity supports. 221 * See {@link android.R.attr#resizeableActivity}. 222 * @hide 223 */ 224 public int resizeMode = RESIZE_MODE_RESIZEABLE; 225 226 /** 227 * Value indicating the maximum aspect ratio the activity supports. 228 * <p> 229 * 0 means unset. 230 * @See {@link android.R.attr#maxAspectRatio}. 231 * @hide 232 */ 233 public float maxAspectRatio; 234 235 /** 236 * Name of the VrListenerService component to run for this activity. 237 * @see android.R.attr#enableVrMode 238 * @hide 239 */ 240 public String requestedVrComponent; 241 242 /** 243 * Value for {@link #colorMode} indicating that the activity should use the 244 * default color mode (sRGB, low dynamic range). 245 * 246 * @see android.R.attr#colorMode 247 */ 248 public static final int COLOR_MODE_DEFAULT = 0; 249 /** 250 * Value of {@link #colorMode} indicating that the activity should use a 251 * wide color gamut if the presentation display supports it. 252 * 253 * @see android.R.attr#colorMode 254 */ 255 public static final int COLOR_MODE_WIDE_COLOR_GAMUT = 1; 256 /** 257 * Value of {@link #colorMode} indicating that the activity should use a 258 * high dynamic range if the presentation display supports it. 259 * 260 * @see android.R.attr#colorMode 261 */ 262 public static final int COLOR_MODE_HDR = 2; 263 264 /** @hide */ 265 @IntDef(prefix = { "COLOR_MODE_" }, value = { 266 COLOR_MODE_DEFAULT, 267 COLOR_MODE_WIDE_COLOR_GAMUT, 268 COLOR_MODE_HDR, 269 }) 270 @Retention(RetentionPolicy.SOURCE) 271 public @interface ColorMode {} 272 273 /** 274 * The color mode requested by this activity. The target display may not be 275 * able to honor the request. 276 */ 277 @ColorMode 278 public int colorMode = COLOR_MODE_DEFAULT; 279 280 /** 281 * Bit in {@link #flags} indicating whether this activity is able to 282 * run in multiple processes. If 283 * true, the system may instantiate it in the some process as the 284 * process starting it in order to conserve resources. If false, the 285 * default, it always runs in {@link #processName}. Set from the 286 * {@link android.R.attr#multiprocess} attribute. 287 */ 288 public static final int FLAG_MULTIPROCESS = 0x0001; 289 /** 290 * Bit in {@link #flags} indicating that, when the activity's task is 291 * relaunched from home, this activity should be finished. 292 * Set from the 293 * {@link android.R.attr#finishOnTaskLaunch} attribute. 294 */ 295 public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002; 296 /** 297 * Bit in {@link #flags} indicating that, when the activity is the root 298 * of a task, that task's stack should be cleared each time the user 299 * re-launches it from home. As a result, the user will always 300 * return to the original activity at the top of the task. 301 * This flag only applies to activities that 302 * are used to start the root of a new task. Set from the 303 * {@link android.R.attr#clearTaskOnLaunch} attribute. 304 */ 305 public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004; 306 /** 307 * Bit in {@link #flags} indicating that, when the activity is the root 308 * of a task, that task's stack should never be cleared when it is 309 * relaunched from home. Set from the 310 * {@link android.R.attr#alwaysRetainTaskState} attribute. 311 */ 312 public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008; 313 /** 314 * Bit in {@link #flags} indicating that the activity's state 315 * is not required to be saved, so that if there is a failure the 316 * activity will not be removed from the activity stack. Set from the 317 * {@link android.R.attr#stateNotNeeded} attribute. 318 */ 319 public static final int FLAG_STATE_NOT_NEEDED = 0x0010; 320 /** 321 * Bit in {@link #flags} that indicates that the activity should not 322 * appear in the list of recently launched activities. Set from the 323 * {@link android.R.attr#excludeFromRecents} attribute. 324 */ 325 public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020; 326 /** 327 * Bit in {@link #flags} that indicates that the activity can be moved 328 * between tasks based on its task affinity. Set from the 329 * {@link android.R.attr#allowTaskReparenting} attribute. 330 */ 331 public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040; 332 /** 333 * Bit in {@link #flags} indicating that, when the user navigates away 334 * from an activity, it should be finished. 335 * Set from the 336 * {@link android.R.attr#noHistory} attribute. 337 */ 338 public static final int FLAG_NO_HISTORY = 0x0080; 339 /** 340 * Bit in {@link #flags} indicating that, when a request to close system 341 * windows happens, this activity is finished. 342 * Set from the 343 * {@link android.R.attr#finishOnCloseSystemDialogs} attribute. 344 */ 345 public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100; 346 /** 347 * Value for {@link #flags}: true when the application's rendering should 348 * be hardware accelerated. 349 */ 350 public static final int FLAG_HARDWARE_ACCELERATED = 0x0200; 351 /** 352 * Value for {@link #flags}: true when the application can be displayed for all users 353 * regardless of if the user of the application is the current user. Set from the 354 * {@link android.R.attr#showForAllUsers} attribute. 355 * @hide 356 */ 357 public static final int FLAG_SHOW_FOR_ALL_USERS = 0x0400; 358 /** 359 * Bit in {@link #flags} corresponding to an immersive activity 360 * that wishes not to be interrupted by notifications. 361 * Applications that hide the system notification bar with 362 * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN} 363 * may still be interrupted by high-priority notifications; for example, an 364 * incoming phone call may use 365 * {@link android.app.Notification#fullScreenIntent fullScreenIntent} 366 * to present a full-screen in-call activity to the user, pausing the 367 * current activity as a side-effect. An activity with 368 * {@link #FLAG_IMMERSIVE} set, however, will not be interrupted; the 369 * notification may be shown in some other way (such as a small floating 370 * "toast" window). 371 * 372 * Note that this flag will always reflect the Activity's 373 * <code>android:immersive</code> manifest definition, even if the Activity's 374 * immersive state is changed at runtime via 375 * {@link android.app.Activity#setImmersive(boolean)}. 376 * 377 * @see android.app.Notification#FLAG_HIGH_PRIORITY 378 * @see android.app.Activity#setImmersive(boolean) 379 */ 380 public static final int FLAG_IMMERSIVE = 0x0800; 381 /** 382 * Bit in {@link #flags}: If set, a task rooted at this activity will have its 383 * baseIntent replaced by the activity immediately above this. Each activity may further 384 * relinquish its identity to the activity above it using this flag. Set from the 385 * {@link android.R.attr#relinquishTaskIdentity} attribute. 386 */ 387 public static final int FLAG_RELINQUISH_TASK_IDENTITY = 0x1000; 388 /** 389 * Bit in {@link #flags} indicating that tasks started with this activity are to be 390 * removed from the recent list of tasks when the last activity in the task is finished. 391 * Corresponds to {@link android.R.attr#autoRemoveFromRecents} 392 */ 393 public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 0x2000; 394 /** 395 * Bit in {@link #flags} indicating that this activity can start is creation/resume 396 * while the previous activity is still pausing. Corresponds to 397 * {@link android.R.attr#resumeWhilePausing} 398 */ 399 public static final int FLAG_RESUME_WHILE_PAUSING = 0x4000; 400 /** 401 * Bit in {@link #flags} indicating that this activity should be run with VR mode enabled. 402 * 403 * {@see android.app.Activity#setVrMode(boolean)}. 404 */ 405 public static final int FLAG_ENABLE_VR_MODE = 0x8000; 406 407 /** 408 * Bit in {@link #flags} indicating if the activity is always focusable regardless of if it is 409 * in a task/stack whose activities are normally not focusable. 410 * See android.R.attr#alwaysFocusable. 411 * @hide 412 */ 413 public static final int FLAG_ALWAYS_FOCUSABLE = 0x40000; 414 415 /** 416 * Bit in {@link #flags} indicating if the activity is visible to instant 417 * applications. The activity is visible if it's either implicitly or 418 * explicitly exposed. 419 * @hide 420 */ 421 public static final int FLAG_VISIBLE_TO_INSTANT_APP = 0x100000; 422 423 /** 424 * Bit in {@link #flags} indicating if the activity is implicitly visible 425 * to instant applications. Implicitly visible activities are those that 426 * implement certain intent-filters: 427 * <ul> 428 * <li>action {@link Intent#CATEGORY_BROWSABLE}</li> 429 * <li>action {@link Intent#ACTION_SEND}</li> 430 * <li>action {@link Intent#ACTION_SENDTO}</li> 431 * <li>action {@link Intent#ACTION_SEND_MULTIPLE}</li> 432 * </ul> 433 * @hide 434 */ 435 public static final int FLAG_IMPLICITLY_VISIBLE_TO_INSTANT_APP = 0x200000; 436 437 /** 438 * Bit in {@link #flags} indicating if the activity supports picture-in-picture mode. 439 * See {@link android.R.attr#supportsPictureInPicture}. 440 * @hide 441 */ 442 public static final int FLAG_SUPPORTS_PICTURE_IN_PICTURE = 0x400000; 443 444 /** 445 * Bit in {@link #flags} indicating if the activity should be shown when locked. 446 * See {@link android.R.attr#showWhenLocked} 447 * @hide 448 */ 449 public static final int FLAG_SHOW_WHEN_LOCKED = 0x800000; 450 451 /** 452 * Bit in {@link #flags} indicating if the screen should turn on when starting the activity. 453 * See {@link android.R.attr#turnScreenOn} 454 * @hide 455 */ 456 public static final int FLAG_TURN_SCREEN_ON = 0x1000000; 457 458 /** 459 * @hide Bit in {@link #flags}: If set, this component will only be seen 460 * by the system user. Only works with broadcast receivers. Set from the 461 * android.R.attr#systemUserOnly attribute. 462 */ 463 public static final int FLAG_SYSTEM_USER_ONLY = 0x20000000; 464 /** 465 * Bit in {@link #flags}: If set, a single instance of the receiver will 466 * run for all users on the device. Set from the 467 * {@link android.R.attr#singleUser} attribute. Note that this flag is 468 * only relevant for ActivityInfo structures that are describing receiver 469 * components; it is not applied to activities. 470 */ 471 public static final int FLAG_SINGLE_USER = 0x40000000; 472 /** 473 * @hide Bit in {@link #flags}: If set, this activity may be launched into an 474 * owned ActivityContainer such as that within an ActivityView. If not set and 475 * this activity is launched into such a container a SecurityException will be 476 * thrown. Set from the {@link android.R.attr#allowEmbedded} attribute. 477 */ 478 public static final int FLAG_ALLOW_EMBEDDED = 0x80000000; 479 480 /** 481 * Options that have been set in the activity declaration in the 482 * manifest. 483 * These include: 484 * {@link #FLAG_MULTIPROCESS}, 485 * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH}, 486 * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE}, 487 * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS}, 488 * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY}, 489 * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS}, 490 * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER}. 491 */ 492 public int flags; 493 494 /** @hide */ 495 @IntDef(prefix = { "SCREEN_ORIENTATION_" }, value = { 496 SCREEN_ORIENTATION_UNSET, 497 SCREEN_ORIENTATION_UNSPECIFIED, 498 SCREEN_ORIENTATION_LANDSCAPE, 499 SCREEN_ORIENTATION_PORTRAIT, 500 SCREEN_ORIENTATION_USER, 501 SCREEN_ORIENTATION_BEHIND, 502 SCREEN_ORIENTATION_SENSOR, 503 SCREEN_ORIENTATION_NOSENSOR, 504 SCREEN_ORIENTATION_SENSOR_LANDSCAPE, 505 SCREEN_ORIENTATION_SENSOR_PORTRAIT, 506 SCREEN_ORIENTATION_REVERSE_LANDSCAPE, 507 SCREEN_ORIENTATION_REVERSE_PORTRAIT, 508 SCREEN_ORIENTATION_FULL_SENSOR, 509 SCREEN_ORIENTATION_USER_LANDSCAPE, 510 SCREEN_ORIENTATION_USER_PORTRAIT, 511 SCREEN_ORIENTATION_FULL_USER, 512 SCREEN_ORIENTATION_LOCKED 513 }) 514 @Retention(RetentionPolicy.SOURCE) 515 public @interface ScreenOrientation {} 516 517 /** 518 * Internal constant used to indicate that the app didn't set a specific orientation value. 519 * Different from {@link #SCREEN_ORIENTATION_UNSPECIFIED} below as the app can set its 520 * orientation to {@link #SCREEN_ORIENTATION_UNSPECIFIED} while this means that the app didn't 521 * set anything. The system will mostly treat this similar to 522 * {@link #SCREEN_ORIENTATION_UNSPECIFIED}. 523 * @hide 524 */ 525 public static final int SCREEN_ORIENTATION_UNSET = -2; 526 /** 527 * Constant corresponding to <code>unspecified</code> in 528 * the {@link android.R.attr#screenOrientation} attribute. 529 */ 530 public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1; 531 /** 532 * Constant corresponding to <code>landscape</code> in 533 * the {@link android.R.attr#screenOrientation} attribute. 534 */ 535 public static final int SCREEN_ORIENTATION_LANDSCAPE = 0; 536 /** 537 * Constant corresponding to <code>portrait</code> in 538 * the {@link android.R.attr#screenOrientation} attribute. 539 */ 540 public static final int SCREEN_ORIENTATION_PORTRAIT = 1; 541 /** 542 * Constant corresponding to <code>user</code> in 543 * the {@link android.R.attr#screenOrientation} attribute. 544 */ 545 public static final int SCREEN_ORIENTATION_USER = 2; 546 /** 547 * Constant corresponding to <code>behind</code> in 548 * the {@link android.R.attr#screenOrientation} attribute. 549 */ 550 public static final int SCREEN_ORIENTATION_BEHIND = 3; 551 /** 552 * Constant corresponding to <code>sensor</code> in 553 * the {@link android.R.attr#screenOrientation} attribute. 554 */ 555 public static final int SCREEN_ORIENTATION_SENSOR = 4; 556 557 /** 558 * Constant corresponding to <code>nosensor</code> in 559 * the {@link android.R.attr#screenOrientation} attribute. 560 */ 561 public static final int SCREEN_ORIENTATION_NOSENSOR = 5; 562 563 /** 564 * Constant corresponding to <code>sensorLandscape</code> in 565 * the {@link android.R.attr#screenOrientation} attribute. 566 */ 567 public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6; 568 569 /** 570 * Constant corresponding to <code>sensorPortrait</code> in 571 * the {@link android.R.attr#screenOrientation} attribute. 572 */ 573 public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7; 574 575 /** 576 * Constant corresponding to <code>reverseLandscape</code> in 577 * the {@link android.R.attr#screenOrientation} attribute. 578 */ 579 public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8; 580 581 /** 582 * Constant corresponding to <code>reversePortrait</code> in 583 * the {@link android.R.attr#screenOrientation} attribute. 584 */ 585 public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9; 586 587 /** 588 * Constant corresponding to <code>fullSensor</code> in 589 * the {@link android.R.attr#screenOrientation} attribute. 590 */ 591 public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10; 592 593 /** 594 * Constant corresponding to <code>userLandscape</code> in 595 * the {@link android.R.attr#screenOrientation} attribute. 596 */ 597 public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11; 598 599 /** 600 * Constant corresponding to <code>userPortrait</code> in 601 * the {@link android.R.attr#screenOrientation} attribute. 602 */ 603 public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12; 604 605 /** 606 * Constant corresponding to <code>fullUser</code> in 607 * the {@link android.R.attr#screenOrientation} attribute. 608 */ 609 public static final int SCREEN_ORIENTATION_FULL_USER = 13; 610 611 /** 612 * Constant corresponding to <code>locked</code> in 613 * the {@link android.R.attr#screenOrientation} attribute. 614 */ 615 public static final int SCREEN_ORIENTATION_LOCKED = 14; 616 617 /** 618 * The preferred screen orientation this activity would like to run in. 619 * From the {@link android.R.attr#screenOrientation} attribute, one of 620 * {@link #SCREEN_ORIENTATION_UNSPECIFIED}, 621 * {@link #SCREEN_ORIENTATION_LANDSCAPE}, 622 * {@link #SCREEN_ORIENTATION_PORTRAIT}, 623 * {@link #SCREEN_ORIENTATION_USER}, 624 * {@link #SCREEN_ORIENTATION_BEHIND}, 625 * {@link #SCREEN_ORIENTATION_SENSOR}, 626 * {@link #SCREEN_ORIENTATION_NOSENSOR}, 627 * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE}, 628 * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT}, 629 * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE}, 630 * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT}, 631 * {@link #SCREEN_ORIENTATION_FULL_SENSOR}, 632 * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE}, 633 * {@link #SCREEN_ORIENTATION_USER_PORTRAIT}, 634 * {@link #SCREEN_ORIENTATION_FULL_USER}, 635 * {@link #SCREEN_ORIENTATION_LOCKED}, 636 */ 637 @ScreenOrientation 638 public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED; 639 640 /** @hide */ 641 @IntDef(flag = true, prefix = { "CONFIG_" }, value = { 642 CONFIG_MCC, 643 CONFIG_MNC, 644 CONFIG_LOCALE, 645 CONFIG_TOUCHSCREEN, 646 CONFIG_KEYBOARD, 647 CONFIG_KEYBOARD_HIDDEN, 648 CONFIG_NAVIGATION, 649 CONFIG_ORIENTATION, 650 CONFIG_SCREEN_LAYOUT, 651 CONFIG_UI_MODE, 652 CONFIG_SCREEN_SIZE, 653 CONFIG_SMALLEST_SCREEN_SIZE, 654 CONFIG_DENSITY, 655 CONFIG_LAYOUT_DIRECTION, 656 CONFIG_COLOR_MODE, 657 CONFIG_FONT_SCALE, 658 }) 659 @Retention(RetentionPolicy.SOURCE) 660 public @interface Config {} 661 662 /** 663 * Bit in {@link #configChanges} that indicates that the activity 664 * can itself handle changes to the IMSI MCC. Set from the 665 * {@link android.R.attr#configChanges} attribute. 666 */ 667 public static final int CONFIG_MCC = 0x0001; 668 /** 669 * Bit in {@link #configChanges} that indicates that the activity 670 * can itself handle changes to the IMSI MNC. Set from the 671 * {@link android.R.attr#configChanges} attribute. 672 */ 673 public static final int CONFIG_MNC = 0x0002; 674 /** 675 * Bit in {@link #configChanges} that indicates that the activity 676 * can itself handle changes to the locale. Set from the 677 * {@link android.R.attr#configChanges} attribute. 678 */ 679 public static final int CONFIG_LOCALE = 0x0004; 680 /** 681 * Bit in {@link #configChanges} that indicates that the activity 682 * can itself handle changes to the touchscreen type. Set from the 683 * {@link android.R.attr#configChanges} attribute. 684 */ 685 public static final int CONFIG_TOUCHSCREEN = 0x0008; 686 /** 687 * Bit in {@link #configChanges} that indicates that the activity 688 * can itself handle changes to the keyboard type. Set from the 689 * {@link android.R.attr#configChanges} attribute. 690 */ 691 public static final int CONFIG_KEYBOARD = 0x0010; 692 /** 693 * Bit in {@link #configChanges} that indicates that the activity 694 * can itself handle changes to the keyboard or navigation being hidden/exposed. 695 * Note that inspite of the name, this applies to the changes to any 696 * hidden states: keyboard or navigation. 697 * Set from the {@link android.R.attr#configChanges} attribute. 698 */ 699 public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020; 700 /** 701 * Bit in {@link #configChanges} that indicates that the activity 702 * can itself handle changes to the navigation type. Set from the 703 * {@link android.R.attr#configChanges} attribute. 704 */ 705 public static final int CONFIG_NAVIGATION = 0x0040; 706 /** 707 * Bit in {@link #configChanges} that indicates that the activity 708 * can itself handle changes to the screen orientation. Set from the 709 * {@link android.R.attr#configChanges} attribute. 710 */ 711 public static final int CONFIG_ORIENTATION = 0x0080; 712 /** 713 * Bit in {@link #configChanges} that indicates that the activity 714 * can itself handle changes to the screen layout. Set from the 715 * {@link android.R.attr#configChanges} attribute. 716 */ 717 public static final int CONFIG_SCREEN_LAYOUT = 0x0100; 718 /** 719 * Bit in {@link #configChanges} that indicates that the activity 720 * can itself handle the ui mode. Set from the 721 * {@link android.R.attr#configChanges} attribute. 722 */ 723 public static final int CONFIG_UI_MODE = 0x0200; 724 /** 725 * Bit in {@link #configChanges} that indicates that the activity 726 * can itself handle the screen size. Set from the 727 * {@link android.R.attr#configChanges} attribute. This will be 728 * set by default for applications that target an earlier version 729 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}... 730 * <b>however</b>, you will not see the bit set here becomes some 731 * applications incorrectly compare {@link #configChanges} against 732 * an absolute value rather than correctly masking out the bits 733 * they are interested in. Please don't do that, thanks. 734 */ 735 public static final int CONFIG_SCREEN_SIZE = 0x0400; 736 /** 737 * Bit in {@link #configChanges} that indicates that the activity 738 * can itself handle the smallest screen size. Set from the 739 * {@link android.R.attr#configChanges} attribute. This will be 740 * set by default for applications that target an earlier version 741 * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}... 742 * <b>however</b>, you will not see the bit set here becomes some 743 * applications incorrectly compare {@link #configChanges} against 744 * an absolute value rather than correctly masking out the bits 745 * they are interested in. Please don't do that, thanks. 746 */ 747 public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800; 748 /** 749 * Bit in {@link #configChanges} that indicates that the activity 750 * can itself handle density changes. Set from the 751 * {@link android.R.attr#configChanges} attribute. 752 */ 753 public static final int CONFIG_DENSITY = 0x1000; 754 /** 755 * Bit in {@link #configChanges} that indicates that the activity 756 * can itself handle the change to layout direction. Set from the 757 * {@link android.R.attr#configChanges} attribute. 758 */ 759 public static final int CONFIG_LAYOUT_DIRECTION = 0x2000; 760 /** 761 * Bit in {@link #configChanges} that indicates that the activity 762 * can itself handle the change to the display color gamut or dynamic 763 * range. Set from the {@link android.R.attr#configChanges} attribute. 764 */ 765 public static final int CONFIG_COLOR_MODE = 0x4000; 766 /** 767 * Bit in {@link #configChanges} that indicates that the activity 768 * can itself handle asset path changes. Set from the {@link android.R.attr#configChanges} 769 * attribute. This is not a core resource configuration, but a higher-level value, so its 770 * constant starts at the high bits. 771 * @hide We do not want apps handling this yet, but we do need some kind of bit for diffs. 772 */ 773 public static final int CONFIG_ASSETS_PATHS = 0x80000000; 774 /** 775 * Bit in {@link #configChanges} that indicates that the activity 776 * can itself handle changes to the font scaling factor. Set from the 777 * {@link android.R.attr#configChanges} attribute. This is 778 * not a core resource configuration, but a higher-level value, so its 779 * constant starts at the high bits. 780 */ 781 public static final int CONFIG_FONT_SCALE = 0x40000000; 782 /** 783 * Bit indicating changes to window configuration that isn't exposed to apps. 784 * This is for internal use only and apps don't handle it. 785 * @hide 786 * {@link Configuration}. 787 */ 788 public static final int CONFIG_WINDOW_CONFIGURATION = 0x20000000; 789 790 /** @hide 791 * Unfortunately the constants for config changes in native code are 792 * different from ActivityInfo. :( Here are the values we should use for the 793 * native side given the bit we have assigned in ActivityInfo. 794 */ 795 public static int[] CONFIG_NATIVE_BITS = new int[] { 796 Configuration.NATIVE_CONFIG_MNC, // MNC 797 Configuration.NATIVE_CONFIG_MCC, // MCC 798 Configuration.NATIVE_CONFIG_LOCALE, // LOCALE 799 Configuration.NATIVE_CONFIG_TOUCHSCREEN, // TOUCH SCREEN 800 Configuration.NATIVE_CONFIG_KEYBOARD, // KEYBOARD 801 Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN, // KEYBOARD HIDDEN 802 Configuration.NATIVE_CONFIG_NAVIGATION, // NAVIGATION 803 Configuration.NATIVE_CONFIG_ORIENTATION, // ORIENTATION 804 Configuration.NATIVE_CONFIG_SCREEN_LAYOUT, // SCREEN LAYOUT 805 Configuration.NATIVE_CONFIG_UI_MODE, // UI MODE 806 Configuration.NATIVE_CONFIG_SCREEN_SIZE, // SCREEN SIZE 807 Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE, // SMALLEST SCREEN SIZE 808 Configuration.NATIVE_CONFIG_DENSITY, // DENSITY 809 Configuration.NATIVE_CONFIG_LAYOUTDIR, // LAYOUT DIRECTION 810 Configuration.NATIVE_CONFIG_COLOR_MODE, // COLOR_MODE 811 }; 812 813 /** 814 * Convert Java change bits to native. 815 * 816 * @hide 817 */ activityInfoConfigJavaToNative(@onfig int input)818 public static @NativeConfig int activityInfoConfigJavaToNative(@Config int input) { 819 int output = 0; 820 for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { 821 if ((input & (1 << i)) != 0) { 822 output |= CONFIG_NATIVE_BITS[i]; 823 } 824 } 825 return output; 826 } 827 828 /** 829 * Convert native change bits to Java. 830 * 831 * @hide 832 */ activityInfoConfigNativeToJava(@ativeConfig int input)833 public static @Config int activityInfoConfigNativeToJava(@NativeConfig int input) { 834 int output = 0; 835 for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) { 836 if ((input & CONFIG_NATIVE_BITS[i]) != 0) { 837 output |= (1 << i); 838 } 839 } 840 return output; 841 } 842 843 /** 844 * @hide 845 * Unfortunately some developers (OpenFeint I am looking at you) have 846 * compared the configChanges bit field against absolute values, so if we 847 * introduce a new bit they break. To deal with that, we will make sure 848 * the public field will not have a value that breaks them, and let the 849 * framework call here to get the real value. 850 */ getRealConfigChanged()851 public int getRealConfigChanged() { 852 return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2 853 ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE 854 | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) 855 : configChanges; 856 } 857 858 /** 859 * Bit mask of kinds of configuration changes that this activity 860 * can handle itself (without being restarted by the system). 861 * Contains any combination of {@link #CONFIG_FONT_SCALE}, 862 * {@link #CONFIG_MCC}, {@link #CONFIG_MNC}, 863 * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN}, 864 * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION}, 865 * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT}, 866 * {@link #CONFIG_DENSITY}, {@link #CONFIG_LAYOUT_DIRECTION} and 867 * {@link #CONFIG_COLOR_MODE}. 868 * Set from the {@link android.R.attr#configChanges} attribute. 869 */ 870 public int configChanges; 871 872 /** 873 * The desired soft input mode for this activity's main window. 874 * Set from the {@link android.R.attr#windowSoftInputMode} attribute 875 * in the activity's manifest. May be any of the same values allowed 876 * for {@link android.view.WindowManager.LayoutParams#softInputMode 877 * WindowManager.LayoutParams.softInputMode}. If 0 (unspecified), 878 * the mode from the theme will be used. 879 */ 880 @android.view.WindowManager.LayoutParams.SoftInputModeFlags 881 public int softInputMode; 882 883 /** 884 * The desired extra UI options for this activity and its main window. 885 * Set from the {@link android.R.attr#uiOptions} attribute in the 886 * activity's manifest. 887 */ 888 public int uiOptions = 0; 889 890 /** 891 * Flag for use with {@link #uiOptions}. 892 * Indicates that the action bar should put all action items in a separate bar when 893 * the screen is narrow. 894 * <p>This value corresponds to "splitActionBarWhenNarrow" for the {@link #uiOptions} XML 895 * attribute. 896 */ 897 public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1; 898 899 /** 900 * If defined, the activity named here is the logical parent of this activity. 901 */ 902 public String parentActivityName; 903 904 /** 905 * Screen rotation animation desired by the activity, with values as defined 906 * for {@link android.view.WindowManager.LayoutParams#rotationAnimation}. 907 * 908 * -1 means to use the system default. 909 * 910 * @hide 911 */ 912 public int rotationAnimation = -1; 913 914 /** @hide */ 915 public static final int LOCK_TASK_LAUNCH_MODE_DEFAULT = 0; 916 /** @hide */ 917 public static final int LOCK_TASK_LAUNCH_MODE_NEVER = 1; 918 /** @hide */ 919 public static final int LOCK_TASK_LAUNCH_MODE_ALWAYS = 2; 920 /** @hide */ 921 public static final int LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED = 3; 922 923 /** @hide */ lockTaskLaunchModeToString(int lockTaskLaunchMode)924 public static final String lockTaskLaunchModeToString(int lockTaskLaunchMode) { 925 switch (lockTaskLaunchMode) { 926 case LOCK_TASK_LAUNCH_MODE_DEFAULT: 927 return "LOCK_TASK_LAUNCH_MODE_DEFAULT"; 928 case LOCK_TASK_LAUNCH_MODE_NEVER: 929 return "LOCK_TASK_LAUNCH_MODE_NEVER"; 930 case LOCK_TASK_LAUNCH_MODE_ALWAYS: 931 return "LOCK_TASK_LAUNCH_MODE_ALWAYS"; 932 case LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED: 933 return "LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED"; 934 default: 935 return "unknown=" + lockTaskLaunchMode; 936 } 937 } 938 /** 939 * Value indicating if the activity is to be locked at startup. Takes on the values from 940 * {@link android.R.attr#lockTaskMode}. 941 * @hide 942 */ 943 public int lockTaskLaunchMode; 944 945 /** 946 * Information about desired position and size of activity on the display when 947 * it is first started. 948 */ 949 public WindowLayout windowLayout; 950 ActivityInfo()951 public ActivityInfo() { 952 } 953 ActivityInfo(ActivityInfo orig)954 public ActivityInfo(ActivityInfo orig) { 955 super(orig); 956 theme = orig.theme; 957 launchMode = orig.launchMode; 958 documentLaunchMode = orig.documentLaunchMode; 959 permission = orig.permission; 960 taskAffinity = orig.taskAffinity; 961 targetActivity = orig.targetActivity; 962 flags = orig.flags; 963 screenOrientation = orig.screenOrientation; 964 configChanges = orig.configChanges; 965 softInputMode = orig.softInputMode; 966 uiOptions = orig.uiOptions; 967 parentActivityName = orig.parentActivityName; 968 maxRecents = orig.maxRecents; 969 lockTaskLaunchMode = orig.lockTaskLaunchMode; 970 windowLayout = orig.windowLayout; 971 resizeMode = orig.resizeMode; 972 requestedVrComponent = orig.requestedVrComponent; 973 rotationAnimation = orig.rotationAnimation; 974 colorMode = orig.colorMode; 975 maxAspectRatio = orig.maxAspectRatio; 976 } 977 978 /** 979 * Return the theme resource identifier to use for this activity. If 980 * the activity defines a theme, that is used; else, the application 981 * theme is used. 982 * 983 * @return The theme associated with this activity. 984 */ getThemeResource()985 public final int getThemeResource() { 986 return theme != 0 ? theme : applicationInfo.theme; 987 } 988 persistableModeToString()989 private String persistableModeToString() { 990 switch(persistableMode) { 991 case PERSIST_ROOT_ONLY: return "PERSIST_ROOT_ONLY"; 992 case PERSIST_NEVER: return "PERSIST_NEVER"; 993 case PERSIST_ACROSS_REBOOTS: return "PERSIST_ACROSS_REBOOTS"; 994 default: return "UNKNOWN=" + persistableMode; 995 } 996 } 997 998 /** 999 * Returns true if the activity's orientation is fixed. 1000 * @hide 1001 */ isFixedOrientation()1002 boolean isFixedOrientation() { 1003 return isFixedOrientationLandscape() || isFixedOrientationPortrait() 1004 || screenOrientation == SCREEN_ORIENTATION_LOCKED; 1005 } 1006 1007 /** 1008 * Returns true if the activity's orientation is fixed to landscape. 1009 * @hide 1010 */ isFixedOrientationLandscape()1011 boolean isFixedOrientationLandscape() { 1012 return isFixedOrientationLandscape(screenOrientation); 1013 } 1014 1015 /** 1016 * Returns true if the activity's orientation is fixed to landscape. 1017 * @hide 1018 */ isFixedOrientationLandscape(@creenOrientation int orientation)1019 public static boolean isFixedOrientationLandscape(@ScreenOrientation int orientation) { 1020 return orientation == SCREEN_ORIENTATION_LANDSCAPE 1021 || orientation == SCREEN_ORIENTATION_SENSOR_LANDSCAPE 1022 || orientation == SCREEN_ORIENTATION_REVERSE_LANDSCAPE 1023 || orientation == SCREEN_ORIENTATION_USER_LANDSCAPE; 1024 } 1025 1026 /** 1027 * Returns true if the activity's orientation is fixed to portrait. 1028 * @hide 1029 */ isFixedOrientationPortrait()1030 boolean isFixedOrientationPortrait() { 1031 return isFixedOrientationPortrait(screenOrientation); 1032 } 1033 1034 /** 1035 * Returns true if the activity's orientation is fixed to portrait. 1036 * @hide 1037 */ isFixedOrientationPortrait(@creenOrientation int orientation)1038 public static boolean isFixedOrientationPortrait(@ScreenOrientation int orientation) { 1039 return orientation == SCREEN_ORIENTATION_PORTRAIT 1040 || orientation == SCREEN_ORIENTATION_SENSOR_PORTRAIT 1041 || orientation == SCREEN_ORIENTATION_REVERSE_PORTRAIT 1042 || orientation == SCREEN_ORIENTATION_USER_PORTRAIT; 1043 } 1044 1045 /** 1046 * Returns true if the activity supports picture-in-picture. 1047 * @hide 1048 */ supportsPictureInPicture()1049 public boolean supportsPictureInPicture() { 1050 return (flags & FLAG_SUPPORTS_PICTURE_IN_PICTURE) != 0; 1051 } 1052 1053 /** @hide */ isResizeableMode(int mode)1054 public static boolean isResizeableMode(int mode) { 1055 return mode == RESIZE_MODE_RESIZEABLE 1056 || mode == RESIZE_MODE_FORCE_RESIZEABLE 1057 || mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY 1058 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY 1059 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION 1060 || mode == RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION; 1061 } 1062 1063 /** @hide */ isPreserveOrientationMode(int mode)1064 public static boolean isPreserveOrientationMode(int mode) { 1065 return mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY 1066 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY 1067 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION; 1068 } 1069 1070 /** @hide */ resizeModeToString(int mode)1071 public static String resizeModeToString(int mode) { 1072 switch (mode) { 1073 case RESIZE_MODE_UNRESIZEABLE: 1074 return "RESIZE_MODE_UNRESIZEABLE"; 1075 case RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION: 1076 return "RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION"; 1077 case RESIZE_MODE_RESIZEABLE: 1078 return "RESIZE_MODE_RESIZEABLE"; 1079 case RESIZE_MODE_FORCE_RESIZEABLE: 1080 return "RESIZE_MODE_FORCE_RESIZEABLE"; 1081 case RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY: 1082 return "RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY"; 1083 case RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY: 1084 return "RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY"; 1085 case RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION: 1086 return "RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION"; 1087 default: 1088 return "unknown=" + mode; 1089 } 1090 } 1091 dump(Printer pw, String prefix)1092 public void dump(Printer pw, String prefix) { 1093 dump(pw, prefix, DUMP_FLAG_ALL); 1094 } 1095 1096 /** @hide */ dump(Printer pw, String prefix, int dumpFlags)1097 public void dump(Printer pw, String prefix, int dumpFlags) { 1098 super.dumpFront(pw, prefix); 1099 if (permission != null) { 1100 pw.println(prefix + "permission=" + permission); 1101 } 1102 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) { 1103 pw.println(prefix + "taskAffinity=" + taskAffinity 1104 + " targetActivity=" + targetActivity 1105 + " persistableMode=" + persistableModeToString()); 1106 } 1107 if (launchMode != 0 || flags != 0 || theme != 0) { 1108 pw.println(prefix + "launchMode=" + launchMode 1109 + " flags=0x" + Integer.toHexString(flags) 1110 + " theme=0x" + Integer.toHexString(theme)); 1111 } 1112 if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED 1113 || configChanges != 0 || softInputMode != 0) { 1114 pw.println(prefix + "screenOrientation=" + screenOrientation 1115 + " configChanges=0x" + Integer.toHexString(configChanges) 1116 + " softInputMode=0x" + Integer.toHexString(softInputMode)); 1117 } 1118 if (uiOptions != 0) { 1119 pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions)); 1120 } 1121 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) { 1122 pw.println(prefix + "lockTaskLaunchMode=" 1123 + lockTaskLaunchModeToString(lockTaskLaunchMode)); 1124 } 1125 if (windowLayout != null) { 1126 pw.println(prefix + "windowLayout=" + windowLayout.width + "|" 1127 + windowLayout.widthFraction + ", " + windowLayout.height + "|" 1128 + windowLayout.heightFraction + ", " + windowLayout.gravity); 1129 } 1130 pw.println(prefix + "resizeMode=" + resizeModeToString(resizeMode)); 1131 if (requestedVrComponent != null) { 1132 pw.println(prefix + "requestedVrComponent=" + requestedVrComponent); 1133 } 1134 if (maxAspectRatio != 0) { 1135 pw.println(prefix + "maxAspectRatio=" + maxAspectRatio); 1136 } 1137 super.dumpBack(pw, prefix, dumpFlags); 1138 } 1139 toString()1140 public String toString() { 1141 return "ActivityInfo{" 1142 + Integer.toHexString(System.identityHashCode(this)) 1143 + " " + name + "}"; 1144 } 1145 describeContents()1146 public int describeContents() { 1147 return 0; 1148 } 1149 writeToParcel(Parcel dest, int parcelableFlags)1150 public void writeToParcel(Parcel dest, int parcelableFlags) { 1151 super.writeToParcel(dest, parcelableFlags); 1152 dest.writeInt(theme); 1153 dest.writeInt(launchMode); 1154 dest.writeInt(documentLaunchMode); 1155 dest.writeString(permission); 1156 dest.writeString(taskAffinity); 1157 dest.writeString(targetActivity); 1158 dest.writeString(launchToken); 1159 dest.writeInt(flags); 1160 dest.writeInt(screenOrientation); 1161 dest.writeInt(configChanges); 1162 dest.writeInt(softInputMode); 1163 dest.writeInt(uiOptions); 1164 dest.writeString(parentActivityName); 1165 dest.writeInt(persistableMode); 1166 dest.writeInt(maxRecents); 1167 dest.writeInt(lockTaskLaunchMode); 1168 if (windowLayout != null) { 1169 dest.writeInt(1); 1170 dest.writeInt(windowLayout.width); 1171 dest.writeFloat(windowLayout.widthFraction); 1172 dest.writeInt(windowLayout.height); 1173 dest.writeFloat(windowLayout.heightFraction); 1174 dest.writeInt(windowLayout.gravity); 1175 dest.writeInt(windowLayout.minWidth); 1176 dest.writeInt(windowLayout.minHeight); 1177 } else { 1178 dest.writeInt(0); 1179 } 1180 dest.writeInt(resizeMode); 1181 dest.writeString(requestedVrComponent); 1182 dest.writeInt(rotationAnimation); 1183 dest.writeInt(colorMode); 1184 dest.writeFloat(maxAspectRatio); 1185 } 1186 1187 /** 1188 * Determines whether the {@link Activity} is considered translucent or floating. 1189 * @hide 1190 */ 1191 @TestApi isTranslucentOrFloating(TypedArray attributes)1192 public static boolean isTranslucentOrFloating(TypedArray attributes) { 1193 final boolean isTranslucent = 1194 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent, 1195 false); 1196 final boolean isSwipeToDismiss = !attributes.hasValue( 1197 com.android.internal.R.styleable.Window_windowIsTranslucent) 1198 && attributes.getBoolean( 1199 com.android.internal.R.styleable.Window_windowSwipeToDismiss, false); 1200 final boolean isFloating = 1201 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating, 1202 false); 1203 1204 return isFloating || isTranslucent || isSwipeToDismiss; 1205 } 1206 1207 /** 1208 * Convert the screen orientation constant to a human readable format. 1209 * @hide 1210 */ screenOrientationToString(int orientation)1211 public static String screenOrientationToString(int orientation) { 1212 switch (orientation) { 1213 case SCREEN_ORIENTATION_UNSET: 1214 return "SCREEN_ORIENTATION_UNSET"; 1215 case SCREEN_ORIENTATION_UNSPECIFIED: 1216 return "SCREEN_ORIENTATION_UNSPECIFIED"; 1217 case SCREEN_ORIENTATION_LANDSCAPE: 1218 return "SCREEN_ORIENTATION_LANDSCAPE"; 1219 case SCREEN_ORIENTATION_PORTRAIT: 1220 return "SCREEN_ORIENTATION_PORTRAIT"; 1221 case SCREEN_ORIENTATION_USER: 1222 return "SCREEN_ORIENTATION_USER"; 1223 case SCREEN_ORIENTATION_BEHIND: 1224 return "SCREEN_ORIENTATION_BEHIND"; 1225 case SCREEN_ORIENTATION_SENSOR: 1226 return "SCREEN_ORIENTATION_SENSOR"; 1227 case SCREEN_ORIENTATION_NOSENSOR: 1228 return "SCREEN_ORIENTATION_NOSENSOR"; 1229 case SCREEN_ORIENTATION_SENSOR_LANDSCAPE: 1230 return "SCREEN_ORIENTATION_SENSOR_LANDSCAPE"; 1231 case SCREEN_ORIENTATION_SENSOR_PORTRAIT: 1232 return "SCREEN_ORIENTATION_SENSOR_PORTRAIT"; 1233 case SCREEN_ORIENTATION_REVERSE_LANDSCAPE: 1234 return "SCREEN_ORIENTATION_REVERSE_LANDSCAPE"; 1235 case SCREEN_ORIENTATION_REVERSE_PORTRAIT: 1236 return "SCREEN_ORIENTATION_REVERSE_PORTRAIT"; 1237 case SCREEN_ORIENTATION_FULL_SENSOR: 1238 return "SCREEN_ORIENTATION_FULL_SENSOR"; 1239 case SCREEN_ORIENTATION_USER_LANDSCAPE: 1240 return "SCREEN_ORIENTATION_USER_LANDSCAPE"; 1241 case SCREEN_ORIENTATION_USER_PORTRAIT: 1242 return "SCREEN_ORIENTATION_USER_PORTRAIT"; 1243 case SCREEN_ORIENTATION_FULL_USER: 1244 return "SCREEN_ORIENTATION_FULL_USER"; 1245 case SCREEN_ORIENTATION_LOCKED: 1246 return "SCREEN_ORIENTATION_LOCKED"; 1247 default: 1248 return Integer.toString(orientation); 1249 } 1250 } 1251 1252 /** 1253 * @hide 1254 */ colorModeToString(@olorMode int colorMode)1255 public static String colorModeToString(@ColorMode int colorMode) { 1256 switch (colorMode) { 1257 case COLOR_MODE_DEFAULT: 1258 return "COLOR_MODE_DEFAULT"; 1259 case COLOR_MODE_WIDE_COLOR_GAMUT: 1260 return "COLOR_MODE_WIDE_COLOR_GAMUT"; 1261 case COLOR_MODE_HDR: 1262 return "COLOR_MODE_HDR"; 1263 default: 1264 return Integer.toString(colorMode); 1265 } 1266 } 1267 1268 public static final Parcelable.Creator<ActivityInfo> CREATOR 1269 = new Parcelable.Creator<ActivityInfo>() { 1270 public ActivityInfo createFromParcel(Parcel source) { 1271 return new ActivityInfo(source); 1272 } 1273 public ActivityInfo[] newArray(int size) { 1274 return new ActivityInfo[size]; 1275 } 1276 }; 1277 ActivityInfo(Parcel source)1278 private ActivityInfo(Parcel source) { 1279 super(source); 1280 theme = source.readInt(); 1281 launchMode = source.readInt(); 1282 documentLaunchMode = source.readInt(); 1283 permission = source.readString(); 1284 taskAffinity = source.readString(); 1285 targetActivity = source.readString(); 1286 launchToken = source.readString(); 1287 flags = source.readInt(); 1288 screenOrientation = source.readInt(); 1289 configChanges = source.readInt(); 1290 softInputMode = source.readInt(); 1291 uiOptions = source.readInt(); 1292 parentActivityName = source.readString(); 1293 persistableMode = source.readInt(); 1294 maxRecents = source.readInt(); 1295 lockTaskLaunchMode = source.readInt(); 1296 if (source.readInt() == 1) { 1297 windowLayout = new WindowLayout(source); 1298 } 1299 resizeMode = source.readInt(); 1300 requestedVrComponent = source.readString(); 1301 rotationAnimation = source.readInt(); 1302 colorMode = source.readInt(); 1303 maxAspectRatio = source.readFloat(); 1304 } 1305 1306 /** 1307 * Contains information about position and size of the activity on the display. 1308 * 1309 * Used in freeform mode to set desired position when activity is first launched. 1310 * It describes how big the activity wants to be in both width and height, 1311 * the minimal allowed size, and the gravity to be applied. 1312 * 1313 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth 1314 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight 1315 * @attr ref android.R.styleable#AndroidManifestLayout_gravity 1316 * @attr ref android.R.styleable#AndroidManifestLayout_minWidth 1317 * @attr ref android.R.styleable#AndroidManifestLayout_minHeight 1318 */ 1319 public static final class WindowLayout { WindowLayout(int width, float widthFraction, int height, float heightFraction, int gravity, int minWidth, int minHeight)1320 public WindowLayout(int width, float widthFraction, int height, float heightFraction, int gravity, 1321 int minWidth, int minHeight) { 1322 this.width = width; 1323 this.widthFraction = widthFraction; 1324 this.height = height; 1325 this.heightFraction = heightFraction; 1326 this.gravity = gravity; 1327 this.minWidth = minWidth; 1328 this.minHeight = minHeight; 1329 } 1330 WindowLayout(Parcel source)1331 WindowLayout(Parcel source) { 1332 width = source.readInt(); 1333 widthFraction = source.readFloat(); 1334 height = source.readInt(); 1335 heightFraction = source.readFloat(); 1336 gravity = source.readInt(); 1337 minWidth = source.readInt(); 1338 minHeight = source.readInt(); 1339 } 1340 1341 /** 1342 * Width of activity in pixels. 1343 * 1344 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth 1345 */ 1346 public final int width; 1347 1348 /** 1349 * Width of activity as a fraction of available display width. 1350 * If both {@link #width} and this value are set this one will be preferred. 1351 * 1352 * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth 1353 */ 1354 public final float widthFraction; 1355 1356 /** 1357 * Height of activity in pixels. 1358 * 1359 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight 1360 */ 1361 public final int height; 1362 1363 /** 1364 * Height of activity as a fraction of available display height. 1365 * If both {@link #height} and this value are set this one will be preferred. 1366 * 1367 * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight 1368 */ 1369 public final float heightFraction; 1370 1371 /** 1372 * Gravity of activity. 1373 * Currently {@link android.view.Gravity#TOP}, {@link android.view.Gravity#BOTTOM}, 1374 * {@link android.view.Gravity#LEFT} and {@link android.view.Gravity#RIGHT} are supported. 1375 * 1376 * @attr ref android.R.styleable#AndroidManifestLayout_gravity 1377 */ 1378 public final int gravity; 1379 1380 /** 1381 * Minimal width of activity in pixels to be able to display its content. 1382 * 1383 * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional 1384 * activities launched in the task. That is if the root activity of a task set minimal 1385 * width, then the system will set the same minimal width on all other activities in the 1386 * task. It will also ignore any other minimal width attributes of non-root activities. 1387 * 1388 * @attr ref android.R.styleable#AndroidManifestLayout_minWidth 1389 */ 1390 public final int minWidth; 1391 1392 /** 1393 * Minimal height of activity in pixels to be able to display its content. 1394 * 1395 * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional 1396 * activities launched in the task. That is if the root activity of a task set minimal 1397 * height, then the system will set the same minimal height on all other activities in the 1398 * task. It will also ignore any other minimal height attributes of non-root activities. 1399 * 1400 * @attr ref android.R.styleable#AndroidManifestLayout_minHeight 1401 */ 1402 public final int minHeight; 1403 } 1404 } 1405