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