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