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