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