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