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