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