ActivityInfo.java revision 9d4e9bcebbd97ad51daa0ef15cfba5aabb399bbb
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     * 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 DO_NOT_PERSIST = 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 over the lockscreen
227     * and consequently over all users' windows.
228     * @hide
229     */
230    public static final int FLAG_SHOW_ON_LOCK_SCREEN = 0x0400;
231    /**
232     * Bit in {@link #flags} corresponding to an immersive activity
233     * that wishes not to be interrupted by notifications.
234     * Applications that hide the system notification bar with
235     * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN}
236     * may still be interrupted by high-priority notifications; for example, an
237     * incoming phone call may use
238     * {@link android.app.Notification#fullScreenIntent fullScreenIntent}
239     * to present a full-screen in-call activity to the user, pausing the
240     * current activity as a side-effect. An activity with
241     * {@link #FLAG_IMMERSIVE} set, however, will not be interrupted; the
242     * notification may be shown in some other way (such as a small floating
243     * "toast" window).
244     *
245     * Note that this flag will always reflect the Activity's
246     * <code>android:immersive</code> manifest definition, even if the Activity's
247     * immersive state is changed at runtime via
248     * {@link android.app.Activity#setImmersive(boolean)}.
249     *
250     * @see android.app.Notification#FLAG_HIGH_PRIORITY
251     * @see android.app.Activity#setImmersive(boolean)
252     */
253    public static final int FLAG_IMMERSIVE = 0x0800;
254    /**
255     * Bit in {@link #flags}: If set, a task rooted at this activity will have its
256     * baseIntent replaced by the activity immediately above this. Each activity may further
257     * relinquish its identity to the activity above it using this flag. Set from the
258     * android.R.attr#relinquishTaskIdentity attribute.
259     */
260    public static final int FLAG_RELINQUISH_TASK_IDENTITY = 0x1000;
261    /**
262     * Bit in {@link #flags} indicating that tasks started with this activity are to be
263     * removed from the recent list of tasks when the last activity in the task is finished.
264     * {@link android.R.attr#autoRemoveFromRecents}
265     */
266    public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 0x2000;
267    /**
268     * @hide Bit in {@link #flags}: If set, this component will only be seen
269     * by the primary user.  Only works with broadcast receivers.  Set from the
270     * android.R.attr#primaryUserOnly attribute.
271     */
272    public static final int FLAG_PRIMARY_USER_ONLY = 0x20000000;
273    /**
274     * Bit in {@link #flags}: If set, a single instance of the receiver will
275     * run for all users on the device.  Set from the
276     * {@link android.R.attr#singleUser} attribute.  Note that this flag is
277     * only relevant for ActivityInfo structures that are describing receiver
278     * components; it is not applied to activities.
279     */
280    public static final int FLAG_SINGLE_USER = 0x40000000;
281    /**
282     * @hide Bit in {@link #flags}: If set, this activity may be launched into an
283     * owned ActivityContainer such as that within an ActivityView. If not set and
284     * this activity is launched into such a container a SecurityExcception will be
285     * thrown. Set from the {@link android.R.attr#allowEmbedded} attribute.
286     */
287    public static final int FLAG_ALLOW_EMBEDDED = 0x80000000;
288    /**
289     * Options that have been set in the activity declaration in the
290     * manifest.
291     * These include:
292     * {@link #FLAG_MULTIPROCESS},
293     * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH},
294     * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE},
295     * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS},
296     * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY},
297     * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS},
298     * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER}.
299     */
300    public int flags;
301
302    /** @hide */
303    @IntDef({
304            SCREEN_ORIENTATION_UNSPECIFIED,
305            SCREEN_ORIENTATION_LANDSCAPE,
306            SCREEN_ORIENTATION_PORTRAIT,
307            SCREEN_ORIENTATION_USER,
308            SCREEN_ORIENTATION_BEHIND,
309            SCREEN_ORIENTATION_SENSOR,
310            SCREEN_ORIENTATION_NOSENSOR,
311            SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
312            SCREEN_ORIENTATION_SENSOR_PORTRAIT,
313            SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
314            SCREEN_ORIENTATION_REVERSE_PORTRAIT,
315            SCREEN_ORIENTATION_FULL_SENSOR,
316            SCREEN_ORIENTATION_USER_LANDSCAPE,
317            SCREEN_ORIENTATION_USER_PORTRAIT,
318            SCREEN_ORIENTATION_FULL_USER,
319            SCREEN_ORIENTATION_LOCKED
320    })
321    @Retention(RetentionPolicy.SOURCE)
322    public @interface ScreenOrientation {}
323
324    /**
325     * Constant corresponding to <code>unspecified</code> in
326     * the {@link android.R.attr#screenOrientation} attribute.
327     */
328    public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1;
329    /**
330     * Constant corresponding to <code>landscape</code> in
331     * the {@link android.R.attr#screenOrientation} attribute.
332     */
333    public static final int SCREEN_ORIENTATION_LANDSCAPE = 0;
334    /**
335     * Constant corresponding to <code>portrait</code> in
336     * the {@link android.R.attr#screenOrientation} attribute.
337     */
338    public static final int SCREEN_ORIENTATION_PORTRAIT = 1;
339    /**
340     * Constant corresponding to <code>user</code> in
341     * the {@link android.R.attr#screenOrientation} attribute.
342     */
343    public static final int SCREEN_ORIENTATION_USER = 2;
344    /**
345     * Constant corresponding to <code>behind</code> in
346     * the {@link android.R.attr#screenOrientation} attribute.
347     */
348    public static final int SCREEN_ORIENTATION_BEHIND = 3;
349    /**
350     * Constant corresponding to <code>sensor</code> in
351     * the {@link android.R.attr#screenOrientation} attribute.
352     */
353    public static final int SCREEN_ORIENTATION_SENSOR = 4;
354
355    /**
356     * Constant corresponding to <code>nosensor</code> in
357     * the {@link android.R.attr#screenOrientation} attribute.
358     */
359    public static final int SCREEN_ORIENTATION_NOSENSOR = 5;
360
361    /**
362     * Constant corresponding to <code>sensorLandscape</code> in
363     * the {@link android.R.attr#screenOrientation} attribute.
364     */
365    public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6;
366
367    /**
368     * Constant corresponding to <code>sensorPortrait</code> in
369     * the {@link android.R.attr#screenOrientation} attribute.
370     */
371    public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7;
372
373    /**
374     * Constant corresponding to <code>reverseLandscape</code> in
375     * the {@link android.R.attr#screenOrientation} attribute.
376     */
377    public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8;
378
379    /**
380     * Constant corresponding to <code>reversePortrait</code> in
381     * the {@link android.R.attr#screenOrientation} attribute.
382     */
383    public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9;
384
385    /**
386     * Constant corresponding to <code>fullSensor</code> in
387     * the {@link android.R.attr#screenOrientation} attribute.
388     */
389    public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10;
390
391    /**
392     * Constant corresponding to <code>userLandscape</code> in
393     * the {@link android.R.attr#screenOrientation} attribute.
394     */
395    public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11;
396
397    /**
398     * Constant corresponding to <code>userPortrait</code> in
399     * the {@link android.R.attr#screenOrientation} attribute.
400     */
401    public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12;
402
403    /**
404     * Constant corresponding to <code>fullUser</code> in
405     * the {@link android.R.attr#screenOrientation} attribute.
406     */
407    public static final int SCREEN_ORIENTATION_FULL_USER = 13;
408
409    /**
410     * Constant corresponding to <code>locked</code> in
411     * the {@link android.R.attr#screenOrientation} attribute.
412     */
413    public static final int SCREEN_ORIENTATION_LOCKED = 14;
414
415    /**
416     * The preferred screen orientation this activity would like to run in.
417     * From the {@link android.R.attr#screenOrientation} attribute, one of
418     * {@link #SCREEN_ORIENTATION_UNSPECIFIED},
419     * {@link #SCREEN_ORIENTATION_LANDSCAPE},
420     * {@link #SCREEN_ORIENTATION_PORTRAIT},
421     * {@link #SCREEN_ORIENTATION_USER},
422     * {@link #SCREEN_ORIENTATION_BEHIND},
423     * {@link #SCREEN_ORIENTATION_SENSOR},
424     * {@link #SCREEN_ORIENTATION_NOSENSOR},
425     * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE},
426     * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT},
427     * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE},
428     * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT},
429     * {@link #SCREEN_ORIENTATION_FULL_SENSOR},
430     * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE},
431     * {@link #SCREEN_ORIENTATION_USER_PORTRAIT},
432     * {@link #SCREEN_ORIENTATION_FULL_USER},
433     * {@link #SCREEN_ORIENTATION_LOCKED},
434     */
435    @ScreenOrientation
436    public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
437
438    /**
439     * Bit in {@link #configChanges} that indicates that the activity
440     * can itself handle changes to the IMSI MCC.  Set from the
441     * {@link android.R.attr#configChanges} attribute.
442     */
443    public static final int CONFIG_MCC = 0x0001;
444    /**
445     * Bit in {@link #configChanges} that indicates that the activity
446     * can itself handle changes to the IMSI MNC.  Set from the
447     * {@link android.R.attr#configChanges} attribute.
448     */
449    public static final int CONFIG_MNC = 0x0002;
450    /**
451     * Bit in {@link #configChanges} that indicates that the activity
452     * can itself handle changes to the locale.  Set from the
453     * {@link android.R.attr#configChanges} attribute.
454     */
455    public static final int CONFIG_LOCALE = 0x0004;
456    /**
457     * Bit in {@link #configChanges} that indicates that the activity
458     * can itself handle changes to the touchscreen type.  Set from the
459     * {@link android.R.attr#configChanges} attribute.
460     */
461    public static final int CONFIG_TOUCHSCREEN = 0x0008;
462    /**
463     * Bit in {@link #configChanges} that indicates that the activity
464     * can itself handle changes to the keyboard type.  Set from the
465     * {@link android.R.attr#configChanges} attribute.
466     */
467    public static final int CONFIG_KEYBOARD = 0x0010;
468    /**
469     * Bit in {@link #configChanges} that indicates that the activity
470     * can itself handle changes to the keyboard or navigation being hidden/exposed.
471     * Note that inspite of the name, this applies to the changes to any
472     * hidden states: keyboard or navigation.
473     * Set from the {@link android.R.attr#configChanges} attribute.
474     */
475    public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020;
476    /**
477     * Bit in {@link #configChanges} that indicates that the activity
478     * can itself handle changes to the navigation type.  Set from the
479     * {@link android.R.attr#configChanges} attribute.
480     */
481    public static final int CONFIG_NAVIGATION = 0x0040;
482    /**
483     * Bit in {@link #configChanges} that indicates that the activity
484     * can itself handle changes to the screen orientation.  Set from the
485     * {@link android.R.attr#configChanges} attribute.
486     */
487    public static final int CONFIG_ORIENTATION = 0x0080;
488    /**
489     * Bit in {@link #configChanges} that indicates that the activity
490     * can itself handle changes to the screen layout.  Set from the
491     * {@link android.R.attr#configChanges} attribute.
492     */
493    public static final int CONFIG_SCREEN_LAYOUT = 0x0100;
494    /**
495     * Bit in {@link #configChanges} that indicates that the activity
496     * can itself handle the ui mode. Set from the
497     * {@link android.R.attr#configChanges} attribute.
498     */
499    public static final int CONFIG_UI_MODE = 0x0200;
500    /**
501     * Bit in {@link #configChanges} that indicates that the activity
502     * can itself handle the screen size. Set from the
503     * {@link android.R.attr#configChanges} attribute.  This will be
504     * set by default for applications that target an earlier version
505     * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
506     * <b>however</b>, you will not see the bit set here becomes some
507     * applications incorrectly compare {@link #configChanges} against
508     * an absolute value rather than correctly masking out the bits
509     * they are interested in.  Please don't do that, thanks.
510     */
511    public static final int CONFIG_SCREEN_SIZE = 0x0400;
512    /**
513     * Bit in {@link #configChanges} that indicates that the activity
514     * can itself handle the smallest screen size. Set from the
515     * {@link android.R.attr#configChanges} attribute.  This will be
516     * set by default for applications that target an earlier version
517     * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
518     * <b>however</b>, you will not see the bit set here becomes some
519     * applications incorrectly compare {@link #configChanges} against
520     * an absolute value rather than correctly masking out the bits
521     * they are interested in.  Please don't do that, thanks.
522     */
523    public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800;
524    /**
525     * Bit in {@link #configChanges} that indicates that the activity
526     * can itself handle density changes. Set from the
527     * {@link android.R.attr#configChanges} attribute.
528     */
529    public static final int CONFIG_DENSITY = 0x1000;
530    /**
531     * Bit in {@link #configChanges} that indicates that the activity
532     * can itself handle the change to layout direction. Set from the
533     * {@link android.R.attr#configChanges} attribute.
534     */
535    public static final int CONFIG_LAYOUT_DIRECTION = 0x2000;
536    /**
537     * Bit in {@link #configChanges} that indicates that the activity
538     * can itself handle changes to the font scaling factor.  Set from the
539     * {@link android.R.attr#configChanges} attribute.  This is
540     * not a core resource configuration, but a higher-level value, so its
541     * constant starts at the high bits.
542     */
543    public static final int CONFIG_FONT_SCALE = 0x40000000;
544
545    /** @hide
546     * Unfortunately the constants for config changes in native code are
547     * different from ActivityInfo. :(  Here are the values we should use for the
548     * native side given the bit we have assigned in ActivityInfo.
549     */
550    public static int[] CONFIG_NATIVE_BITS = new int[] {
551        Configuration.NATIVE_CONFIG_MNC,                    // MNC
552        Configuration.NATIVE_CONFIG_MCC,                    // MCC
553        Configuration.NATIVE_CONFIG_LOCALE,                 // LOCALE
554        Configuration.NATIVE_CONFIG_TOUCHSCREEN,            // TOUCH SCREEN
555        Configuration.NATIVE_CONFIG_KEYBOARD,               // KEYBOARD
556        Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN,        // KEYBOARD HIDDEN
557        Configuration.NATIVE_CONFIG_NAVIGATION,             // NAVIGATION
558        Configuration.NATIVE_CONFIG_ORIENTATION,            // ORIENTATION
559        Configuration.NATIVE_CONFIG_SCREEN_LAYOUT,          // SCREEN LAYOUT
560        Configuration.NATIVE_CONFIG_UI_MODE,                // UI MODE
561        Configuration.NATIVE_CONFIG_SCREEN_SIZE,            // SCREEN SIZE
562        Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE,   // SMALLEST SCREEN SIZE
563        Configuration.NATIVE_CONFIG_DENSITY,                // DENSITY
564        Configuration.NATIVE_CONFIG_LAYOUTDIR,              // LAYOUT DIRECTION
565    };
566    /** @hide
567     * Convert Java change bits to native.
568     */
569    public static int activityInfoConfigToNative(int input) {
570        int output = 0;
571        for (int i=0; i<CONFIG_NATIVE_BITS.length; i++) {
572            if ((input&(1<<i)) != 0) {
573                output |= CONFIG_NATIVE_BITS[i];
574            }
575        }
576        return output;
577    }
578
579    /**
580     * @hide
581     * Unfortunately some developers (OpenFeint I am looking at you) have
582     * compared the configChanges bit field against absolute values, so if we
583     * introduce a new bit they break.  To deal with that, we will make sure
584     * the public field will not have a value that breaks them, and let the
585     * framework call here to get the real value.
586     */
587    public int getRealConfigChanged() {
588        return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2
589                ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE
590                        | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE)
591                : configChanges;
592    }
593
594    /**
595     * Bit mask of kinds of configuration changes that this activity
596     * can handle itself (without being restarted by the system).
597     * Contains any combination of {@link #CONFIG_FONT_SCALE},
598     * {@link #CONFIG_MCC}, {@link #CONFIG_MNC},
599     * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN},
600     * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION},
601     * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT} and
602     * {@link #CONFIG_LAYOUT_DIRECTION}.  Set from the {@link android.R.attr#configChanges}
603     * attribute.
604     */
605    public int configChanges;
606
607    /**
608     * The desired soft input mode for this activity's main window.
609     * Set from the {@link android.R.attr#windowSoftInputMode} attribute
610     * in the activity's manifest.  May be any of the same values allowed
611     * for {@link android.view.WindowManager.LayoutParams#softInputMode
612     * WindowManager.LayoutParams.softInputMode}.  If 0 (unspecified),
613     * the mode from the theme will be used.
614     */
615    public int softInputMode;
616
617    /**
618     * The desired extra UI options for this activity and its main window.
619     * Set from the {@link android.R.attr#uiOptions} attribute in the
620     * activity's manifest.
621     */
622    public int uiOptions = 0;
623
624    /**
625     * Flag for use with {@link #uiOptions}.
626     * Indicates that the action bar should put all action items in a separate bar when
627     * the screen is narrow.
628     * <p>This value corresponds to "splitActionBarWhenNarrow" for the {@link #uiOptions} XML
629     * attribute.
630     */
631    public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1;
632
633    /**
634     * If defined, the activity named here is the logical parent of this activity.
635     */
636    public String parentActivityName;
637
638    public ActivityInfo() {
639    }
640
641    public ActivityInfo(ActivityInfo orig) {
642        super(orig);
643        theme = orig.theme;
644        launchMode = orig.launchMode;
645        permission = orig.permission;
646        taskAffinity = orig.taskAffinity;
647        targetActivity = orig.targetActivity;
648        flags = orig.flags;
649        screenOrientation = orig.screenOrientation;
650        configChanges = orig.configChanges;
651        softInputMode = orig.softInputMode;
652        uiOptions = orig.uiOptions;
653        parentActivityName = orig.parentActivityName;
654    }
655
656    /**
657     * Return the theme resource identifier to use for this activity.  If
658     * the activity defines a theme, that is used; else, the application
659     * theme is used.
660     *
661     * @return The theme associated with this activity.
662     */
663    public final int getThemeResource() {
664        return theme != 0 ? theme : applicationInfo.theme;
665    }
666
667    private String persistableModeToString() {
668        switch(persistableMode) {
669            case PERSIST_ROOT_ONLY: return "PERSIST_ROOT_ONLY";
670            case DO_NOT_PERSIST: return "DO_NOT_PERSIST";
671            case PERSIST_ACROSS_REBOOTS: return "PERSIST_ACROSS_REBOOTS";
672            default: return "UNKNOWN=" + persistableMode;
673        }
674    }
675
676    public void dump(Printer pw, String prefix) {
677        super.dumpFront(pw, prefix);
678        if (permission != null) {
679            pw.println(prefix + "permission=" + permission);
680        }
681        pw.println(prefix + "taskAffinity=" + taskAffinity
682                + " targetActivity=" + targetActivity
683                + " persistableMode=" + persistableModeToString());
684        if (launchMode != 0 || flags != 0 || theme != 0) {
685            pw.println(prefix + "launchMode=" + launchMode
686                    + " flags=0x" + Integer.toHexString(flags)
687                    + " theme=0x" + Integer.toHexString(theme));
688        }
689        if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED
690                || configChanges != 0 || softInputMode != 0) {
691            pw.println(prefix + "screenOrientation=" + screenOrientation
692                    + " configChanges=0x" + Integer.toHexString(configChanges)
693                    + " softInputMode=0x" + Integer.toHexString(softInputMode));
694        }
695        if (uiOptions != 0) {
696            pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions));
697        }
698        super.dumpBack(pw, prefix);
699    }
700
701    public String toString() {
702        return "ActivityInfo{"
703            + Integer.toHexString(System.identityHashCode(this))
704            + " " + name + "}";
705    }
706
707    public int describeContents() {
708        return 0;
709    }
710
711    public void writeToParcel(Parcel dest, int parcelableFlags) {
712        super.writeToParcel(dest, parcelableFlags);
713        dest.writeInt(theme);
714        dest.writeInt(launchMode);
715        dest.writeString(permission);
716        dest.writeString(taskAffinity);
717        dest.writeString(targetActivity);
718        dest.writeInt(flags);
719        dest.writeInt(screenOrientation);
720        dest.writeInt(configChanges);
721        dest.writeInt(softInputMode);
722        dest.writeInt(uiOptions);
723        dest.writeString(parentActivityName);
724        dest.writeInt(persistableMode);
725    }
726
727    public static final Parcelable.Creator<ActivityInfo> CREATOR
728            = new Parcelable.Creator<ActivityInfo>() {
729        public ActivityInfo createFromParcel(Parcel source) {
730            return new ActivityInfo(source);
731        }
732        public ActivityInfo[] newArray(int size) {
733            return new ActivityInfo[size];
734        }
735    };
736
737    private ActivityInfo(Parcel source) {
738        super(source);
739        theme = source.readInt();
740        launchMode = source.readInt();
741        permission = source.readString();
742        taskAffinity = source.readString();
743        targetActivity = source.readString();
744        flags = source.readInt();
745        screenOrientation = source.readInt();
746        configChanges = source.readInt();
747        softInputMode = source.readInt();
748        uiOptions = source.readInt();
749        parentActivityName = source.readString();
750        persistableMode = source.readInt();
751    }
752}
753