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