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