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.FlaggedApi;
20 import android.annotation.FloatRange;
21 import android.annotation.IntDef;
22 import android.annotation.NonNull;
23 import android.annotation.Nullable;
24 import android.annotation.TestApi;
25 import android.app.Activity;
26 import android.compat.annotation.ChangeId;
27 import android.compat.annotation.Disabled;
28 import android.compat.annotation.EnabledSince;
29 import android.compat.annotation.Overridable;
30 import android.compat.annotation.UnsupportedAppUsage;
31 import android.content.ComponentName;
32 import android.content.Intent;
33 import android.content.res.Configuration;
34 import android.content.res.Configuration.NativeConfig;
35 import android.content.res.TypedArray;
36 import android.os.Build;
37 import android.os.Parcel;
38 import android.os.Parcelable;
39 import android.util.ArraySet;
40 import android.util.Printer;
41 import android.window.OnBackInvokedCallback;
42 
43 import com.android.internal.util.Parcelling;
44 import com.android.window.flags.Flags;
45 
46 import java.lang.annotation.Retention;
47 import java.lang.annotation.RetentionPolicy;
48 import java.util.Collections;
49 import java.util.Locale;
50 import java.util.Set;
51 
52 /**
53  * Information you can retrieve about a particular application
54  * activity or receiver. This corresponds to information collected
55  * from the AndroidManifest.xml's <activity> and
56  * <receiver> tags.
57  */
58 @android.ravenwood.annotation.RavenwoodKeepWholeClass
59 public class ActivityInfo extends ComponentInfo implements Parcelable {
60 
61     private static final Parcelling.BuiltIn.ForStringSet sForStringSet =
62             Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForStringSet.class);
63 
64      // NOTE: When adding new data members be sure to update the copy-constructor, Parcel
65      // constructor, and writeToParcel.
66 
67     /**
68      * A style resource identifier (in the package's resources) of this
69      * activity's theme.  From the "theme" attribute or, if not set, 0.
70      */
71     public int theme;
72 
73     /**
74      * Constant corresponding to <code>standard</code> in
75      * the {@link android.R.attr#launchMode} attribute.
76      */
77     public static final int LAUNCH_MULTIPLE = 0;
78     /**
79      * Constant corresponding to <code>singleTop</code> in
80      * the {@link android.R.attr#launchMode} attribute.
81      */
82     public static final int LAUNCH_SINGLE_TOP = 1;
83     /**
84      * Constant corresponding to <code>singleTask</code> in
85      * the {@link android.R.attr#launchMode} attribute.
86      */
87     public static final int LAUNCH_SINGLE_TASK = 2;
88     /**
89      * Constant corresponding to <code>singleInstance</code> in
90      * the {@link android.R.attr#launchMode} attribute.
91      */
92     public static final int LAUNCH_SINGLE_INSTANCE = 3;
93     /**
94      * Constant corresponding to <code>singleInstancePerTask</code> in
95      * the {@link android.R.attr#launchMode} attribute.
96      */
97     public static final int LAUNCH_SINGLE_INSTANCE_PER_TASK = 4;
98 
99     /** @hide */
100     @IntDef(prefix = "LAUNCH_", value = {
101             LAUNCH_MULTIPLE,
102             LAUNCH_SINGLE_TOP,
103             LAUNCH_SINGLE_TASK,
104             LAUNCH_SINGLE_INSTANCE,
105             LAUNCH_SINGLE_INSTANCE_PER_TASK
106     })
107     @Retention(RetentionPolicy.SOURCE)
108     public @interface LaunchMode {
109     }
110 
111     /** @hide */
launchModeToString(@aunchMode int launchMode)112     public static String launchModeToString(@LaunchMode int launchMode) {
113         switch(launchMode) {
114             case LAUNCH_MULTIPLE:
115                 return "LAUNCH_MULTIPLE";
116             case LAUNCH_SINGLE_TOP:
117                 return "LAUNCH_SINGLE_TOP";
118             case LAUNCH_SINGLE_TASK:
119                 return "LAUNCH_SINGLE_TASK";
120             case LAUNCH_SINGLE_INSTANCE:
121                 return "LAUNCH_SINGLE_INSTANCE";
122             case LAUNCH_SINGLE_INSTANCE_PER_TASK:
123                 return "LAUNCH_SINGLE_INSTANCE_PER_TASK";
124             default:
125                 return "unknown=" + launchMode;
126         }
127     }
128 
129     /**
130      * The launch mode style requested by the activity.  From the
131      * {@link android.R.attr#launchMode} attribute.
132      */
133     @LaunchMode
134     public int launchMode;
135 
136     /**
137      * Constant corresponding to <code>none</code> in
138      * the {@link android.R.attr#documentLaunchMode} attribute.
139      */
140     public static final int DOCUMENT_LAUNCH_NONE = 0;
141     /**
142      * Constant corresponding to <code>intoExisting</code> in
143      * the {@link android.R.attr#documentLaunchMode} attribute.
144      */
145     public static final int DOCUMENT_LAUNCH_INTO_EXISTING = 1;
146     /**
147      * Constant corresponding to <code>always</code> in
148      * the {@link android.R.attr#documentLaunchMode} attribute.
149      */
150     public static final int DOCUMENT_LAUNCH_ALWAYS = 2;
151     /**
152      * Constant corresponding to <code>never</code> in
153      * the {@link android.R.attr#documentLaunchMode} attribute.
154      */
155     public static final int DOCUMENT_LAUNCH_NEVER = 3;
156     /**
157      * The document launch mode style requested by the activity. From the
158      * {@link android.R.attr#documentLaunchMode} attribute, one of
159      * {@link #DOCUMENT_LAUNCH_NONE}, {@link #DOCUMENT_LAUNCH_INTO_EXISTING},
160      * {@link #DOCUMENT_LAUNCH_ALWAYS}.
161      *
162      * <p>Modes DOCUMENT_LAUNCH_ALWAYS
163      * and DOCUMENT_LAUNCH_INTO_EXISTING are equivalent to {@link
164      * android.content.Intent#FLAG_ACTIVITY_NEW_DOCUMENT
165      * Intent.FLAG_ACTIVITY_NEW_DOCUMENT} with and without {@link
166      * android.content.Intent#FLAG_ACTIVITY_MULTIPLE_TASK
167      * Intent.FLAG_ACTIVITY_MULTIPLE_TASK} respectively.
168      */
169     public int documentLaunchMode;
170 
171     /**
172      * Constant corresponding to <code>persistRootOnly</code> in
173      * the {@link android.R.attr#persistableMode} attribute.
174      */
175     public static final int PERSIST_ROOT_ONLY = 0;
176     /**
177      * Constant corresponding to <code>doNotPersist</code> in
178      * the {@link android.R.attr#persistableMode} attribute.
179      */
180     public static final int PERSIST_NEVER = 1;
181     /**
182      * Constant corresponding to <code>persistAcrossReboots</code> in
183      * the {@link android.R.attr#persistableMode} attribute.
184      */
185     public static final int PERSIST_ACROSS_REBOOTS = 2;
186     /**
187      * Value indicating how this activity is to be persisted across
188      * reboots for restoring in the Recents list.
189      * {@link android.R.attr#persistableMode}
190      */
191     public int persistableMode;
192 
193     /**
194      * The maximum number of tasks rooted at this activity that can be in the recent task list.
195      * Refer to {@link android.R.attr#maxRecents}.
196      */
197     public int maxRecents;
198 
199     /**
200      * Optional name of a permission required to be able to access this
201      * Activity.  From the "permission" attribute.
202      */
203     public String permission;
204 
205     /**
206      * The affinity this activity has for another task in the system.  The
207      * string here is the name of the task, often the package name of the
208      * overall package.  If null, the activity has no affinity.  Set from the
209      * {@link android.R.attr#taskAffinity} attribute.
210      */
211     public String taskAffinity;
212 
213     /**
214      * If this is an activity alias, this is the real activity class to run
215      * for it.  Otherwise, this is null.
216      */
217     public String targetActivity;
218 
219     /**
220      * Token used to string together multiple events within a single launch action.
221      * @hide
222      */
223     public String launchToken;
224 
225     /**
226      * Specifies the required display category of the activity. Set from the
227      * {@link android.R.attr#requiredDisplayCategory} attribute. Upon creation, a display can
228      * specify which display categories it supports and one of the category must be present
229      * in the {@code <activity>} element to allow this activity to run. The default value is
230      * {@code null}, which indicates the activity does not have a required display category and
231      * thus can only run on a display that didn't specify any display categories. Each activity
232      * can only specify one required category but a display can support multiple display categories.
233      * <p>
234      * This field should be formatted as a Java-language-style free form string(for example,
235      * com.google.automotive_entertainment), which may contain uppercase or lowercase letters ('A'
236      * through 'Z'), numbers, and underscores ('_') but may only start with letters.
237      */
238     @Nullable
239     public String requiredDisplayCategory;
240 
241     /**
242      * Constant corresponding to {@code none} in the
243      * {@link android.R.attr#requireContentUriPermissionFromCaller} attribute.
244      * @hide
245      */
246     public static final int CONTENT_URI_PERMISSION_NONE = 0;
247 
248     /**
249      * Constant corresponding to {@code read} in the
250      * {@link android.R.attr#requireContentUriPermissionFromCaller} attribute.
251      * @hide
252      */
253     public static final int CONTENT_URI_PERMISSION_READ = 1;
254 
255     /**
256      * Constant corresponding to {@code write} in the
257      * {@link android.R.attr#requireContentUriPermissionFromCaller} attribute.
258      * @hide
259      */
260     public static final int CONTENT_URI_PERMISSION_WRITE = 2;
261 
262     /**
263      * Constant corresponding to {@code readOrWrite} in the
264      * {@link android.R.attr#requireContentUriPermissionFromCaller} attribute.
265      * @hide
266      */
267     public static final int CONTENT_URI_PERMISSION_READ_OR_WRITE = 3;
268 
269     /**
270      * Constant corresponding to {@code readAndWrite} in the
271      * {@link android.R.attr#requireContentUriPermissionFromCaller} attribute.
272      * @hide
273      */
274     public static final int CONTENT_URI_PERMISSION_READ_AND_WRITE = 4;
275 
276     /** @hide */
277     @SuppressWarnings("SwitchIntDef")
isRequiredContentUriPermissionRead( @equiredContentUriPermission int permission)278     public static boolean isRequiredContentUriPermissionRead(
279             @RequiredContentUriPermission int permission) {
280         return switch (permission) {
281             case CONTENT_URI_PERMISSION_READ_AND_WRITE, CONTENT_URI_PERMISSION_READ_OR_WRITE,
282                     CONTENT_URI_PERMISSION_READ -> true;
283             default -> false;
284         };
285     }
286 
287     /** @hide */
288     @SuppressWarnings("SwitchIntDef")
isRequiredContentUriPermissionWrite( @equiredContentUriPermission int permission)289     public static boolean isRequiredContentUriPermissionWrite(
290             @RequiredContentUriPermission int permission) {
291         return switch (permission) {
292             case CONTENT_URI_PERMISSION_READ_AND_WRITE, CONTENT_URI_PERMISSION_READ_OR_WRITE,
293                     CONTENT_URI_PERMISSION_WRITE -> true;
294             default -> false;
295         };
296     }
297 
298     /** @hide */
299     @IntDef(prefix = "CONTENT_URI_PERMISSION_", value = {
300             CONTENT_URI_PERMISSION_NONE,
301             CONTENT_URI_PERMISSION_READ,
302             CONTENT_URI_PERMISSION_WRITE,
303             CONTENT_URI_PERMISSION_READ_OR_WRITE,
304             CONTENT_URI_PERMISSION_READ_AND_WRITE
305     })
306     @Retention(RetentionPolicy.SOURCE)
307     public @interface RequiredContentUriPermission {
308     }
309 
310     private String requiredContentUriPermissionToFullString(
311             @RequiredContentUriPermission int permission) {
312         return switch (permission) {
313             case CONTENT_URI_PERMISSION_NONE -> "CONTENT_URI_PERMISSION_NONE";
314             case CONTENT_URI_PERMISSION_READ -> "CONTENT_URI_PERMISSION_READ";
315             case CONTENT_URI_PERMISSION_WRITE -> "CONTENT_URI_PERMISSION_WRITE";
316             case CONTENT_URI_PERMISSION_READ_OR_WRITE -> "CONTENT_URI_PERMISSION_READ_OR_WRITE";
317             case CONTENT_URI_PERMISSION_READ_AND_WRITE -> "CONTENT_URI_PERMISSION_READ_AND_WRITE";
318             default -> "unknown=" + permission;
319         };
320     }
321 
322     /** @hide */
323     public static String requiredContentUriPermissionToShortString(
324             @RequiredContentUriPermission int permission) {
325         return switch (permission) {
326             case CONTENT_URI_PERMISSION_NONE -> "none";
327             case CONTENT_URI_PERMISSION_READ -> "read";
328             case CONTENT_URI_PERMISSION_WRITE -> "write";
329             case CONTENT_URI_PERMISSION_READ_OR_WRITE -> "read or write";
330             case CONTENT_URI_PERMISSION_READ_AND_WRITE -> "read and write";
331             default -> "unknown=" + permission;
332         };
333     }
334 
335     /**
336      * Specifies permissions necessary to launch this activity when passing content URIs. The
337      * default value is {@code none}, meaning no specific permissions are required. Setting this
338      * attribute restricts activity invocation based on the invoker's permissions.
339      * @hide
340      */
341     @RequiredContentUriPermission
342     public int requireContentUriPermissionFromCaller;
343 
344     /**
345      * Activity can not be resized and always occupies the fullscreen area with all windows fully
346      * visible.
347      * @hide
348      */
349     public static final int RESIZE_MODE_UNRESIZEABLE = 0;
350     /**
351      * Activity didn't explicitly request to be resizeable, but we are making it resizeable because
352      * of the SDK version it targets. Only affects apps with target SDK >= N where the app is
353      * implied to be resizeable if it doesn't explicitly set the attribute to any value.
354      * @hide
355      */
356     public static final int RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION = 1;
357     /**
358      * Activity explicitly requested to be resizeable.
359      * @hide
360      */
361     @TestApi
362     public static final int RESIZE_MODE_RESIZEABLE = 2;
363     /**
364      * Activity is resizeable and supported picture-in-picture mode.  This flag is now deprecated
365      * since activities do not need to be resizeable to support picture-in-picture.
366      * See {@link #FLAG_SUPPORTS_PICTURE_IN_PICTURE}.
367      *
368      * @hide
369      * @deprecated
370      */
371     public static final int RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED = 3;
372     /**
373      * Activity does not support resizing, but we are forcing it to be resizeable. Only affects
374      * certain pre-N apps where we force them to be resizeable.
375      * @hide
376      */
377     public static final int RESIZE_MODE_FORCE_RESIZEABLE = 4;
378     /**
379      * Activity does not support resizing, but we are forcing it to be resizeable as long
380      * as the size remains landscape.
381      * @hide
382      */
383     public static final int RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY = 5;
384     /**
385      * Activity does not support resizing, but we are forcing it to be resizeable as long
386      * as the size remains portrait.
387      * @hide
388      */
389     public static final int RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY = 6;
390     /**
391      * Activity does not support resizing, but we are forcing it to be resizeable as long
392      * as the bounds remain in the same orientation as they are.
393      * @hide
394      */
395     public static final int RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION = 7;
396     /**
397      * Value indicating if the resizing mode the activity supports.
398      * See {@link android.R.attr#resizeableActivity}.
399      * @hide
400      */
401     @UnsupportedAppUsage
402     public int resizeMode = RESIZE_MODE_RESIZEABLE;
403 
404     /**
405      * Value indicating the maximum aspect ratio the activity supports.
406      * <p>
407      * 0 means unset.
408      * @See {@link android.R.attr#maxAspectRatio}.
409      * @hide
410      */
411     private float mMaxAspectRatio;
412 
413     /**
414      * Value indicating the minimum aspect ratio the activity supports.
415      * <p>
416      * 0 means unset.
417      * @See {@link android.R.attr#minAspectRatio}.
418      * @hide
419      */
420     private float mMinAspectRatio;
421 
422     /**
423      * Indicates that the activity works well with size changes like display changing size.
424      *
425      * @hide
426      */
427     public boolean supportsSizeChanges;
428 
429     /**
430      * Name of the VrListenerService component to run for this activity.
431      * @see android.R.attr#enableVrMode
432      * @hide
433      */
434     public String requestedVrComponent;
435 
436     /**
437      * Value for {@link #colorMode} indicating that the activity should use the
438      * default color mode (sRGB, low dynamic range).
439      *
440      * @see android.R.attr#colorMode
441      */
442     public static final int COLOR_MODE_DEFAULT = 0;
443     /**
444      * Value of {@link #colorMode} indicating that the activity should use a
445      * wide color gamut if the presentation display supports it.
446      *
447      * @see android.R.attr#colorMode
448      */
449     public static final int COLOR_MODE_WIDE_COLOR_GAMUT = 1;
450     /**
451      * Value of {@link #colorMode} indicating that the activity should use a
452      * high dynamic range if the presentation display supports it.
453      *
454      * @see android.R.attr#colorMode
455      */
456     public static final int COLOR_MODE_HDR = 2;
457 
458     /**
459      * Comparison point against COLOR_MODE_HDR that uses 1010102
460      * Only for internal test usages
461      * @hide
462      */
463     public static final int COLOR_MODE_HDR10 = 3;
464 
465     /**
466      * Value of {@link #colorMode} indicating that the activity should use an
467      * 8 bit alpha buffer if the presentation display supports it.
468      *
469      * @see android.R.attr#colorMode
470      * @hide
471      */
472     public static final int COLOR_MODE_A8 = 4;
473 
474 
475     /** @hide */
476     @IntDef(prefix = { "COLOR_MODE_" }, value = {
477             COLOR_MODE_DEFAULT,
478             COLOR_MODE_WIDE_COLOR_GAMUT,
479             COLOR_MODE_HDR,
480             COLOR_MODE_A8,
481     })
482     @Retention(RetentionPolicy.SOURCE)
483     public @interface ColorMode {}
484 
485     /**
486      * The color mode requested by this activity. The target display may not be
487      * able to honor the request.
488      */
489     @ColorMode
490     public int colorMode = COLOR_MODE_DEFAULT;
491 
492     /**
493      * Bit in {@link #flags} indicating whether this activity is able to
494      * run in multiple processes.  If
495      * true, the system may instantiate it in the some process as the
496      * process starting it in order to conserve resources.  If false, the
497      * default, it always runs in {@link #processName}.  Set from the
498      * {@link android.R.attr#multiprocess} attribute.
499      */
500     public static final int FLAG_MULTIPROCESS = 0x0001;
501     /**
502      * Bit in {@link #flags} indicating that, when the activity's task is
503      * relaunched from home, this activity should be finished.
504      * Set from the
505      * {@link android.R.attr#finishOnTaskLaunch} attribute.
506      */
507     public static final int FLAG_FINISH_ON_TASK_LAUNCH = 0x0002;
508     /**
509      * Bit in {@link #flags} indicating that, when the activity is the root
510      * of a task, that task's stack should be cleared each time the user
511      * re-launches it from home.  As a result, the user will always
512      * return to the original activity at the top of the task.
513      * This flag only applies to activities that
514      * are used to start the root of a new task.  Set from the
515      * {@link android.R.attr#clearTaskOnLaunch} attribute.
516      */
517     public static final int FLAG_CLEAR_TASK_ON_LAUNCH = 0x0004;
518     /**
519      * Bit in {@link #flags} indicating that, when the activity is the root
520      * of a task, that task's stack should never be cleared when it is
521      * relaunched from home.  Set from the
522      * {@link android.R.attr#alwaysRetainTaskState} attribute.
523      */
524     public static final int FLAG_ALWAYS_RETAIN_TASK_STATE = 0x0008;
525     /**
526      * Bit in {@link #flags} indicating that the activity's state
527      * is not required to be saved, so that if there is a failure the
528      * activity will not be removed from the activity stack.  Set from the
529      * {@link android.R.attr#stateNotNeeded} attribute.
530      */
531     public static final int FLAG_STATE_NOT_NEEDED = 0x0010;
532     /**
533      * Bit in {@link #flags} that indicates that the activity should not
534      * appear in the list of recently launched activities.  Set from the
535      * {@link android.R.attr#excludeFromRecents} attribute.
536      */
537     public static final int FLAG_EXCLUDE_FROM_RECENTS = 0x0020;
538     /**
539      * Bit in {@link #flags} that indicates that the activity can be moved
540      * between tasks based on its task affinity.  Set from the
541      * {@link android.R.attr#allowTaskReparenting} attribute.
542      */
543     public static final int FLAG_ALLOW_TASK_REPARENTING = 0x0040;
544     /**
545      * Bit in {@link #flags} indicating that, when the user navigates away
546      * from an activity, it should be finished.
547      * Set from the
548      * {@link android.R.attr#noHistory} attribute.
549      */
550     public static final int FLAG_NO_HISTORY = 0x0080;
551     /**
552      * Bit in {@link #flags} indicating that, when a request to close system
553      * windows happens, this activity is finished.
554      * Set from the
555      * {@link android.R.attr#finishOnCloseSystemDialogs} attribute.
556      */
557     public static final int FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS = 0x0100;
558     /**
559      * Value for {@link #flags}: true when the application's rendering should
560      * be hardware accelerated.
561      */
562     public static final int FLAG_HARDWARE_ACCELERATED = 0x0200;
563     /**
564      * Value for {@link #flags}: true when the application can be displayed for all users
565      * regardless of if the user of the application is the current user. Set from the
566      * {@link android.R.attr#showForAllUsers} attribute.
567      * @hide
568      */
569     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
570     public static final int FLAG_SHOW_FOR_ALL_USERS = 0x0400;
571     /**
572      * Bit in {@link #flags} corresponding to an immersive activity
573      * that wishes not to be interrupted by notifications.
574      * Applications that hide the system notification bar with
575      * {@link android.view.WindowManager.LayoutParams#FLAG_FULLSCREEN}
576      * may still be interrupted by high-priority notifications; for example, an
577      * incoming phone call may use
578      * {@link android.app.Notification#fullScreenIntent fullScreenIntent}
579      * to present a full-screen in-call activity to the user, pausing the
580      * current activity as a side-effect. An activity with
581      * {@link #FLAG_IMMERSIVE} set, however, will not be interrupted; the
582      * notification may be shown in some other way (such as a small floating
583      * "toast" window).
584      *
585      * Note that this flag will always reflect the Activity's
586      * <code>android:immersive</code> manifest definition, even if the Activity's
587      * immersive state is changed at runtime via
588      * {@link android.app.Activity#setImmersive(boolean)}.
589      *
590      * @see android.app.Notification#FLAG_HIGH_PRIORITY
591      * @see android.app.Activity#setImmersive(boolean)
592      */
593     public static final int FLAG_IMMERSIVE = 0x0800;
594     /**
595      * Bit in {@link #flags}: If set, a task rooted at this activity will have its
596      * baseIntent replaced by the activity immediately above this. Each activity may further
597      * relinquish its identity to the activity above it using this flag. Set from the
598      * {@link android.R.attr#relinquishTaskIdentity} attribute.
599      */
600     public static final int FLAG_RELINQUISH_TASK_IDENTITY = 0x1000;
601     /**
602      * Bit in {@link #flags} indicating that tasks started with this activity are to be
603      * removed from the recent list of tasks when the last activity in the task is finished.
604      * Corresponds to {@link android.R.attr#autoRemoveFromRecents}
605      */
606     public static final int FLAG_AUTO_REMOVE_FROM_RECENTS = 0x2000;
607     /**
608      * Bit in {@link #flags} indicating that this activity can start is creation/resume
609      * while the previous activity is still pausing.  Corresponds to
610      * {@link android.R.attr#resumeWhilePausing}
611      */
612     public static final int FLAG_RESUME_WHILE_PAUSING = 0x4000;
613     /**
614      * Bit in {@link #flags} indicating that this activity should be run with VR mode enabled.
615      *
616      * @see android.app.Activity#setVrModeEnabled(boolean, ComponentName)
617      */
618     public static final int FLAG_ENABLE_VR_MODE = 0x8000;
619     /**
620      * Bit in {@link #flags} indicating if the activity can be displayed on a remote device.
621      * Corresponds to {@link android.R.attr#canDisplayOnRemoteDevices}
622      * @hide
623      */
624     public static final int FLAG_CAN_DISPLAY_ON_REMOTE_DEVICES = 0x10000;
625 
626     /**
627      * Bit in {@link #flags} indicating if the activity is always focusable regardless of if it is
628      * in a task/stack whose activities are normally not focusable.
629      * See android.R.attr#alwaysFocusable.
630      * @hide
631      */
632     public static final int FLAG_ALWAYS_FOCUSABLE = 0x40000;
633 
634     /**
635      * Bit in {@link #flags} indicating if the activity is visible to instant
636      * applications. The activity is visible if it's either implicitly or
637      * explicitly exposed.
638      * @hide
639      */
640     public static final int FLAG_VISIBLE_TO_INSTANT_APP = 0x100000;
641 
642     /**
643      * Bit in {@link #flags} indicating if the activity is implicitly visible
644      * to instant applications. Implicitly visible activities are those that
645      * implement certain intent-filters:
646      * <ul>
647      * <li>action {@link Intent#CATEGORY_BROWSABLE}</li>
648      * <li>action {@link Intent#ACTION_SEND}</li>
649      * <li>action {@link Intent#ACTION_SENDTO}</li>
650      * <li>action {@link Intent#ACTION_SEND_MULTIPLE}</li>
651      * </ul>
652      * @hide
653      */
654     public static final int FLAG_IMPLICITLY_VISIBLE_TO_INSTANT_APP = 0x200000;
655 
656     /**
657      * Bit in {@link #flags} indicating if the activity supports picture-in-picture mode.
658      * See {@link android.R.attr#supportsPictureInPicture}.
659      * @hide
660      */
661     public static final int FLAG_SUPPORTS_PICTURE_IN_PICTURE = 0x400000;
662 
663     /**
664      * Bit in {@link #flags} indicating if the activity should be shown when locked.
665      * See {@link android.R.attr#showWhenLocked}
666      * @hide
667      */
668     public static final int FLAG_SHOW_WHEN_LOCKED = 0x800000;
669 
670     /**
671      * Bit in {@link #flags} indicating if the screen should turn on when starting the activity.
672      * See {@link android.R.attr#turnScreenOn}
673      * @hide
674      */
675     public static final int FLAG_TURN_SCREEN_ON = 0x1000000;
676 
677     /**
678      * Bit in {@link #flags} indicating whether the display should preferably be switched to a
679      * minimal post processing mode.
680      * See {@link android.R.attr#preferMinimalPostProcessing}
681      */
682     public static final int FLAG_PREFER_MINIMAL_POST_PROCESSING = 0x2000000;
683 
684     /**
685      * Bit in {@link #flags}: If set, indicates that the activity can be embedded by untrusted
686      * hosts. In this case the interactions with and visibility of the embedded activity may be
687      * limited. Set from the {@link android.R.attr#allowUntrustedActivityEmbedding} attribute.
688      */
689     public static final int FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING = 0x10000000;
690 
691     /**
692      * @hide Bit in {@link #flags}: If set, this component will only be seen
693      * by the system user.  Only works with broadcast receivers.  Set from the
694      * android.R.attr#systemUserOnly attribute.
695      */
696     public static final int FLAG_SYSTEM_USER_ONLY = 0x20000000;
697     /**
698      * Bit in {@link #flags}: If set, a single instance of the receiver will
699      * run for all users on the device.  Set from the
700      * {@link android.R.attr#singleUser} attribute.  Note that this flag is
701      * only relevant for ActivityInfo structures that are describing receiver
702      * components; it is not applied to activities.
703      */
704     public static final int FLAG_SINGLE_USER = 0x40000000;
705     /**
706      * @hide Bit in {@link #flags}: If set, this activity may be launched into an
707      * owned ActivityContainer such as that within an ActivityView. If not set and
708      * this activity is launched into such a container a SecurityException will be
709      * thrown. Set from the {@link android.R.attr#allowEmbedded} attribute.
710      *
711      * @deprecated this flag is no longer needed since ActivityView is now fully removed
712      * TODO(b/191165536): delete this flag since is no longer used
713      */
714     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
715     @Deprecated
716     public static final int FLAG_ALLOW_EMBEDDED = 0x80000000;
717 
718     /**
719      * Options that have been set in the activity declaration in the
720      * manifest.
721      * These include:
722      * {@link #FLAG_MULTIPROCESS},
723      * {@link #FLAG_FINISH_ON_TASK_LAUNCH}, {@link #FLAG_CLEAR_TASK_ON_LAUNCH},
724      * {@link #FLAG_ALWAYS_RETAIN_TASK_STATE},
725      * {@link #FLAG_STATE_NOT_NEEDED}, {@link #FLAG_EXCLUDE_FROM_RECENTS},
726      * {@link #FLAG_ALLOW_TASK_REPARENTING}, {@link #FLAG_NO_HISTORY},
727      * {@link #FLAG_FINISH_ON_CLOSE_SYSTEM_DIALOGS},
728      * {@link #FLAG_HARDWARE_ACCELERATED}, {@link #FLAG_SINGLE_USER},
729      * {@link #FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING}.
730      */
731     public int flags;
732 
733     /**
734      * Bit in {@link #privateFlags} indicating if the activity should be shown when locked in case
735      * an activity behind this can also be shown when locked.
736      * See {@link android.R.attr#inheritShowWhenLocked}.
737      * @hide
738      */
739     public static final int FLAG_INHERIT_SHOW_WHEN_LOCKED = 1 << 0;
740 
741     /**
742      * Bit in {@link #privateFlags} indicating whether a home sound effect should be played if the
743      * home app moves to front after the activity with this flag set.
744      * Set from the {@link android.R.attr#playHomeTransitionSound} attribute.
745      * @hide
746      */
747     public static final int PRIVATE_FLAG_HOME_TRANSITION_SOUND = 1 << 1;
748 
749     /**
750      * Bit in {@link #privateFlags} indicating {@link android.view.KeyEvent#KEYCODE_BACK} related
751      * events will be replaced by a call to {@link OnBackInvokedCallback#onBackInvoked()} on the
752      * focused window.
753      * @hide
754      * @see android.R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback
755      */
756     public static final int PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK = 1 << 2;
757 
758     /**
759      * Bit in {@link #privateFlags} indicating {@link android.view.KeyEvent#KEYCODE_BACK} related
760      * events will be forwarded to the Activity and its dialogs and views and
761      * the {@link android.app.Activity#onBackPressed()}, {@link android.app.Dialog#onBackPressed}
762      * will be called.
763      * @hide
764      * @see android.R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback
765      */
766     public static final int PRIVATE_FLAG_DISABLE_ON_BACK_INVOKED_CALLBACK = 1 << 3;
767 
768     /**
769      * Options that have been set in the activity declaration in the manifest.
770      * These include:
771      * {@link #FLAG_INHERIT_SHOW_WHEN_LOCKED},
772      * {@link #PRIVATE_FLAG_HOME_TRANSITION_SOUND}.
773      * {@link #PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK}
774      * {@link #PRIVATE_FLAG_DISABLE_ON_BACK_INVOKED_CALLBACK}
775      * @hide
776      */
777     public int privateFlags;
778 
779     /** @hide */
780     @IntDef(prefix = { "SCREEN_ORIENTATION_" }, value = {
781             SCREEN_ORIENTATION_UNSET,
782             SCREEN_ORIENTATION_UNSPECIFIED,
783             SCREEN_ORIENTATION_LANDSCAPE,
784             SCREEN_ORIENTATION_PORTRAIT,
785             SCREEN_ORIENTATION_USER,
786             SCREEN_ORIENTATION_BEHIND,
787             SCREEN_ORIENTATION_SENSOR,
788             SCREEN_ORIENTATION_NOSENSOR,
789             SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
790             SCREEN_ORIENTATION_SENSOR_PORTRAIT,
791             SCREEN_ORIENTATION_REVERSE_LANDSCAPE,
792             SCREEN_ORIENTATION_REVERSE_PORTRAIT,
793             SCREEN_ORIENTATION_FULL_SENSOR,
794             SCREEN_ORIENTATION_USER_LANDSCAPE,
795             SCREEN_ORIENTATION_USER_PORTRAIT,
796             SCREEN_ORIENTATION_FULL_USER,
797             SCREEN_ORIENTATION_LOCKED
798     })
799     @Retention(RetentionPolicy.SOURCE)
800     public @interface ScreenOrientation {}
801 
802     /**
803      * Internal constant used to indicate that the app didn't set a specific orientation value.
804      * Different from {@link #SCREEN_ORIENTATION_UNSPECIFIED} below as the app can set its
805      * orientation to {@link #SCREEN_ORIENTATION_UNSPECIFIED} while this means that the app didn't
806      * set anything. The system will mostly treat this similar to
807      * {@link #SCREEN_ORIENTATION_UNSPECIFIED}.
808      * @hide
809      */
810     public static final int SCREEN_ORIENTATION_UNSET = -2;
811     /**
812      * Constant corresponding to <code>unspecified</code> in
813      * the {@link android.R.attr#screenOrientation} attribute.
814      */
815     public static final int SCREEN_ORIENTATION_UNSPECIFIED = -1;
816     /**
817      * Constant corresponding to <code>landscape</code> in
818      * the {@link android.R.attr#screenOrientation} attribute.
819      */
820     public static final int SCREEN_ORIENTATION_LANDSCAPE = 0;
821     /**
822      * Constant corresponding to <code>portrait</code> in
823      * the {@link android.R.attr#screenOrientation} attribute.
824      */
825     public static final int SCREEN_ORIENTATION_PORTRAIT = 1;
826     /**
827      * Constant corresponding to <code>user</code> in
828      * the {@link android.R.attr#screenOrientation} attribute.
829      */
830     public static final int SCREEN_ORIENTATION_USER = 2;
831     /**
832      * Constant corresponding to <code>behind</code> in
833      * the {@link android.R.attr#screenOrientation} attribute.
834      */
835     public static final int SCREEN_ORIENTATION_BEHIND = 3;
836     /**
837      * Constant corresponding to <code>sensor</code> in
838      * the {@link android.R.attr#screenOrientation} attribute.
839      */
840     public static final int SCREEN_ORIENTATION_SENSOR = 4;
841 
842     /**
843      * Constant corresponding to <code>nosensor</code> in
844      * the {@link android.R.attr#screenOrientation} attribute.
845      */
846     public static final int SCREEN_ORIENTATION_NOSENSOR = 5;
847 
848     /**
849      * Constant corresponding to <code>sensorLandscape</code> in
850      * the {@link android.R.attr#screenOrientation} attribute.
851      */
852     public static final int SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6;
853 
854     /**
855      * Constant corresponding to <code>sensorPortrait</code> in
856      * the {@link android.R.attr#screenOrientation} attribute.
857      */
858     public static final int SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7;
859 
860     /**
861      * Constant corresponding to <code>reverseLandscape</code> in
862      * the {@link android.R.attr#screenOrientation} attribute.
863      */
864     public static final int SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8;
865 
866     /**
867      * Constant corresponding to <code>reversePortrait</code> in
868      * the {@link android.R.attr#screenOrientation} attribute.
869      */
870     public static final int SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9;
871 
872     /**
873      * Constant corresponding to <code>fullSensor</code> in
874      * the {@link android.R.attr#screenOrientation} attribute.
875      */
876     public static final int SCREEN_ORIENTATION_FULL_SENSOR = 10;
877 
878     /**
879      * Constant corresponding to <code>userLandscape</code> in
880      * the {@link android.R.attr#screenOrientation} attribute.
881      */
882     public static final int SCREEN_ORIENTATION_USER_LANDSCAPE = 11;
883 
884     /**
885      * Constant corresponding to <code>userPortrait</code> in
886      * the {@link android.R.attr#screenOrientation} attribute.
887      */
888     public static final int SCREEN_ORIENTATION_USER_PORTRAIT = 12;
889 
890     /**
891      * Constant corresponding to <code>fullUser</code> in
892      * the {@link android.R.attr#screenOrientation} attribute.
893      */
894     public static final int SCREEN_ORIENTATION_FULL_USER = 13;
895 
896     /**
897      * Constant corresponding to <code>locked</code> in
898      * the {@link android.R.attr#screenOrientation} attribute.
899      */
900     public static final int SCREEN_ORIENTATION_LOCKED = 14;
901 
902     /**
903      * The preferred screen orientation this activity would like to run in.
904      * From the {@link android.R.attr#screenOrientation} attribute, one of
905      * {@link #SCREEN_ORIENTATION_UNSPECIFIED},
906      * {@link #SCREEN_ORIENTATION_LANDSCAPE},
907      * {@link #SCREEN_ORIENTATION_PORTRAIT},
908      * {@link #SCREEN_ORIENTATION_USER},
909      * {@link #SCREEN_ORIENTATION_BEHIND},
910      * {@link #SCREEN_ORIENTATION_SENSOR},
911      * {@link #SCREEN_ORIENTATION_NOSENSOR},
912      * {@link #SCREEN_ORIENTATION_SENSOR_LANDSCAPE},
913      * {@link #SCREEN_ORIENTATION_SENSOR_PORTRAIT},
914      * {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE},
915      * {@link #SCREEN_ORIENTATION_REVERSE_PORTRAIT},
916      * {@link #SCREEN_ORIENTATION_FULL_SENSOR},
917      * {@link #SCREEN_ORIENTATION_USER_LANDSCAPE},
918      * {@link #SCREEN_ORIENTATION_USER_PORTRAIT},
919      * {@link #SCREEN_ORIENTATION_FULL_USER},
920      * {@link #SCREEN_ORIENTATION_LOCKED},
921      */
922     @ScreenOrientation
923     public int screenOrientation = SCREEN_ORIENTATION_UNSPECIFIED;
924 
925     /** @hide */
926     @IntDef(flag = true, prefix = { "CONFIG_" }, value = {
927             CONFIG_MCC,
928             CONFIG_MNC,
929             CONFIG_LOCALE,
930             CONFIG_TOUCHSCREEN,
931             CONFIG_KEYBOARD,
932             CONFIG_KEYBOARD_HIDDEN,
933             CONFIG_NAVIGATION,
934             CONFIG_ORIENTATION,
935             CONFIG_SCREEN_LAYOUT,
936             CONFIG_UI_MODE,
937             CONFIG_SCREEN_SIZE,
938             CONFIG_SMALLEST_SCREEN_SIZE,
939             CONFIG_DENSITY,
940             CONFIG_LAYOUT_DIRECTION,
941             CONFIG_COLOR_MODE,
942             CONFIG_FONT_SCALE,
943             CONFIG_GRAMMATICAL_GENDER,
944     })
945     @Retention(RetentionPolicy.SOURCE)
946     public @interface Config {}
947 
948     /**
949      * Bit in {@link #configChanges} that indicates that the activity
950      * can itself handle changes to the IMSI MCC.  Set from the
951      * {@link android.R.attr#configChanges} attribute.
952      */
953     public static final int CONFIG_MCC = 0x0001;
954     /**
955      * Bit in {@link #configChanges} that indicates that the activity
956      * can itself handle changes to the IMSI MNC.  Set from the
957      * {@link android.R.attr#configChanges} attribute.
958      */
959     public static final int CONFIG_MNC = 0x0002;
960     /**
961      * Bit in {@link #configChanges} that indicates that the activity
962      * can itself handle changes to the locale.  Set from the
963      * {@link android.R.attr#configChanges} attribute.
964      */
965     public static final int CONFIG_LOCALE = 0x0004;
966     /**
967      * Bit in {@link #configChanges} that indicates that the activity
968      * can itself handle changes to the touchscreen type.  Set from the
969      * {@link android.R.attr#configChanges} attribute.
970      */
971     public static final int CONFIG_TOUCHSCREEN = 0x0008;
972     /**
973      * Bit in {@link #configChanges} that indicates that the activity
974      * can itself handle changes to the keyboard type.  Set from the
975      * {@link android.R.attr#configChanges} attribute.
976      */
977     public static final int CONFIG_KEYBOARD = 0x0010;
978     /**
979      * Bit in {@link #configChanges} that indicates that the activity
980      * can itself handle changes to the keyboard or navigation being hidden/exposed.
981      * Note that inspite of the name, this applies to the changes to any
982      * hidden states: keyboard or navigation.
983      * Set from the {@link android.R.attr#configChanges} attribute.
984      */
985     public static final int CONFIG_KEYBOARD_HIDDEN = 0x0020;
986     /**
987      * Bit in {@link #configChanges} that indicates that the activity
988      * can itself handle changes to the navigation type.  Set from the
989      * {@link android.R.attr#configChanges} attribute.
990      */
991     public static final int CONFIG_NAVIGATION = 0x0040;
992     /**
993      * Bit in {@link #configChanges} that indicates that the activity
994      * can itself handle changes to the screen orientation.  Set from the
995      * {@link android.R.attr#configChanges} attribute.
996      */
997     public static final int CONFIG_ORIENTATION = 0x0080;
998     /**
999      * Bit in {@link #configChanges} that indicates that the activity
1000      * can itself handle changes to the screen layout.  Set from the
1001      * {@link android.R.attr#configChanges} attribute.
1002      */
1003     public static final int CONFIG_SCREEN_LAYOUT = 0x0100;
1004     /**
1005      * Bit in {@link #configChanges} that indicates that the activity
1006      * can itself handle the ui mode. Set from the
1007      * {@link android.R.attr#configChanges} attribute.
1008      */
1009     public static final int CONFIG_UI_MODE = 0x0200;
1010     /**
1011      * Bit in {@link #configChanges} that indicates that the activity
1012      * can itself handle the screen size. Set from the
1013      * {@link android.R.attr#configChanges} attribute.  This will be
1014      * set by default for applications that target an earlier version
1015      * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
1016      * <b>however</b>, you will not see the bit set here becomes some
1017      * applications incorrectly compare {@link #configChanges} against
1018      * an absolute value rather than correctly masking out the bits
1019      * they are interested in.  Please don't do that, thanks.
1020      */
1021     public static final int CONFIG_SCREEN_SIZE = 0x0400;
1022     /**
1023      * Bit in {@link #configChanges} that indicates that the activity
1024      * can itself handle the smallest screen size. Set from the
1025      * {@link android.R.attr#configChanges} attribute.  This will be
1026      * set by default for applications that target an earlier version
1027      * than {@link android.os.Build.VERSION_CODES#HONEYCOMB_MR2}...
1028      * <b>however</b>, you will not see the bit set here becomes some
1029      * applications incorrectly compare {@link #configChanges} against
1030      * an absolute value rather than correctly masking out the bits
1031      * they are interested in.  Please don't do that, thanks.
1032      */
1033     public static final int CONFIG_SMALLEST_SCREEN_SIZE = 0x0800;
1034     /**
1035      * Bit in {@link #configChanges} that indicates that the activity
1036      * can itself handle density changes. Set from the
1037      * {@link android.R.attr#configChanges} attribute.
1038      */
1039     public static final int CONFIG_DENSITY = 0x1000;
1040     /**
1041      * Bit in {@link #configChanges} that indicates that the activity
1042      * can itself handle the change to layout direction. Set from the
1043      * {@link android.R.attr#configChanges} attribute.
1044      */
1045     public static final int CONFIG_LAYOUT_DIRECTION = 0x2000;
1046     /**
1047      * Bit in {@link #configChanges} that indicates that the activity
1048      * can itself handle the change to the display color gamut or dynamic
1049      * range. Set from the {@link android.R.attr#configChanges} attribute.
1050      */
1051     public static final int CONFIG_COLOR_MODE = 0x4000;
1052     /**
1053      * Bit in {@link #configChanges} that indicates that the activity
1054      * can itself handle the change to gender. Set from the
1055      * {@link android.R.attr#configChanges} attribute.
1056      */
1057     public static final int CONFIG_GRAMMATICAL_GENDER = 0x8000;
1058     /**
1059      * Bit in {@link #configChanges} that indicates that the activity
1060      * can itself handle asset path changes.  Set from the {@link android.R.attr#configChanges}
1061      * attribute. This is not a core resource configuration, but a higher-level value, so its
1062      * constant starts at the high bits.
1063      * @hide We do not want apps handling this yet, but we do need some kind of bit for diffs.
1064      */
1065     public static final int CONFIG_ASSETS_PATHS = 0x80000000;
1066     /**
1067      * Bit in {@link #configChanges} that indicates that the activity
1068      * can itself handle changes to the font scaling factor.  Set from the
1069      * {@link android.R.attr#configChanges} attribute.  This is
1070      * not a core resource configuration, but a higher-level value, so its
1071      * constant starts at the high bits.
1072      */
1073     public static final int CONFIG_FONT_SCALE = 0x40000000;
1074     /**
1075      * Bit indicating changes to window configuration that isn't exposed to apps.
1076      * This is for internal use only and apps don't handle it.
1077      * @hide
1078      * {@link Configuration}.
1079      */
1080     public static final int CONFIG_WINDOW_CONFIGURATION = 0x20000000;
1081 
1082     /**
1083      * Bit in {@link #configChanges} that indicates that the activity
1084      * can itself handle changes to font weight.  Set from the
1085      * {@link android.R.attr#configChanges} attribute.  This is
1086      * not a core resource configuration, but a higher-level value, so its
1087      * constant starts at the high bits.
1088      */
1089     public static final int CONFIG_FONT_WEIGHT_ADJUSTMENT = 0x10000000;
1090 
1091     /** @hide
1092      * Unfortunately the constants for config changes in native code are
1093      * different from ActivityInfo. :(  Here are the values we should use for the
1094      * native side given the bit we have assigned in ActivityInfo.
1095      */
1096     public static int[] CONFIG_NATIVE_BITS = new int[] {
1097         Configuration.NATIVE_CONFIG_MNC,                    // MNC
1098         Configuration.NATIVE_CONFIG_MCC,                    // MCC
1099         Configuration.NATIVE_CONFIG_LOCALE,                 // LOCALE
1100         Configuration.NATIVE_CONFIG_TOUCHSCREEN,            // TOUCH SCREEN
1101         Configuration.NATIVE_CONFIG_KEYBOARD,               // KEYBOARD
1102         Configuration.NATIVE_CONFIG_KEYBOARD_HIDDEN,        // KEYBOARD HIDDEN
1103         Configuration.NATIVE_CONFIG_NAVIGATION,             // NAVIGATION
1104         Configuration.NATIVE_CONFIG_ORIENTATION,            // ORIENTATION
1105         Configuration.NATIVE_CONFIG_SCREEN_LAYOUT,          // SCREEN LAYOUT
1106         Configuration.NATIVE_CONFIG_UI_MODE,                // UI MODE
1107         Configuration.NATIVE_CONFIG_SCREEN_SIZE,            // SCREEN SIZE
1108         Configuration.NATIVE_CONFIG_SMALLEST_SCREEN_SIZE,   // SMALLEST SCREEN SIZE
1109         Configuration.NATIVE_CONFIG_DENSITY,                // DENSITY
1110         Configuration.NATIVE_CONFIG_LAYOUTDIR,              // LAYOUT DIRECTION
1111         Configuration.NATIVE_CONFIG_COLOR_MODE,             // COLOR_MODE
1112         Configuration.NATIVE_CONFIG_GRAMMATICAL_GENDER,
1113     };
1114 
1115     /**
1116      * This change id forces the packages it is applied to be resizable. It won't change whether
1117      * the app can be put into multi-windowing mode, but allow the app to resize when the window
1118      * container resizes, such as display size change.
1119      * @hide
1120      */
1121     @ChangeId
1122     @Overridable
1123     @Disabled
1124     @TestApi
1125     public static final long FORCE_RESIZE_APP = 174042936L; // buganizer id
1126 
1127     /**
1128      * This change id forces the packages it is applied to to be non-resizable.
1129      * @hide
1130      */
1131     @ChangeId
1132     @Overridable
1133     @Disabled
1134     @TestApi
1135     public static final long FORCE_NON_RESIZE_APP = 181136395L; // buganizer id
1136 
1137     /**
1138      * Return value for {@link #supportsSizeChanges()} indicating that this activity does not
1139      * support size changes due to the android.supports_size_changes metadata flag either being
1140      * unset or set to {@code false} on application or activity level.
1141      *
1142      * @hide
1143      */
1144     public static final int SIZE_CHANGES_UNSUPPORTED_METADATA = 0;
1145 
1146     /**
1147      * Return value for {@link #supportsSizeChanges()} indicating that this activity has been
1148      * overridden to not support size changes through the compat framework change id
1149      * {@link #FORCE_NON_RESIZE_APP}.
1150      * @hide
1151      */
1152     public static final int SIZE_CHANGES_UNSUPPORTED_OVERRIDE = 1;
1153 
1154     /**
1155      * Return value for {@link #supportsSizeChanges()} indicating that this activity supports size
1156      * changes due to the android.supports_size_changes metadata flag being set to {@code true}
1157      * either on application or activity level.
1158      * @hide
1159      */
1160     public static final int SIZE_CHANGES_SUPPORTED_METADATA = 2;
1161 
1162     /**
1163      * Return value for {@link #supportsSizeChanges()} indicating that this activity has been
1164      * overridden to support size changes through the compat framework change id
1165      * {@link #FORCE_RESIZE_APP}.
1166      * @hide
1167      */
1168     public static final int SIZE_CHANGES_SUPPORTED_OVERRIDE = 3;
1169 
1170     /** @hide */
1171     @IntDef(prefix = { "SIZE_CHANGES_" }, value = {
1172             SIZE_CHANGES_UNSUPPORTED_METADATA,
1173             SIZE_CHANGES_UNSUPPORTED_OVERRIDE,
1174             SIZE_CHANGES_SUPPORTED_METADATA,
1175             SIZE_CHANGES_SUPPORTED_OVERRIDE,
1176     })
1177     @Retention(RetentionPolicy.SOURCE)
1178     public @interface SizeChangesSupportMode {}
1179 
1180     /**
1181      * This change id enables compat policy that ignores app requested orientation in
1182      * response to an app calling {@link android.app.Activity#setRequestedOrientation}. See
1183      * com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation for
1184      * details.
1185      * @hide
1186      */
1187     @ChangeId
1188     @Overridable
1189     @Disabled
1190     @TestApi
1191     public static final long OVERRIDE_ENABLE_COMPAT_IGNORE_REQUESTED_ORIENTATION =
1192             254631730L; // buganizer id
1193 
1194     /**
1195      * This change id enables compat policy that ignores app requested orientation in
1196      * response to an app calling {@link android.app.Activity#setRequestedOrientation} more
1197      * than twice in one second if an activity is not letterboxed for fixed orientation.
1198      * See com.android.server.wm.LetterboxUiController#shouldIgnoreRequestedOrientation
1199      * for details.
1200      * @hide
1201      */
1202     @ChangeId
1203     @Overridable
1204     @Disabled
1205     @TestApi
1206     @FlaggedApi(Flags.FLAG_APP_COMPAT_PROPERTIES_API)
1207     public static final long OVERRIDE_ENABLE_COMPAT_IGNORE_ORIENTATION_REQUEST_WHEN_LOOP_DETECTED =
1208             273509367L; // buganizer id
1209 
1210     /**
1211      * This change id forces the packages it is applied to never have Display API sandboxing
1212      * applied for a letterbox or SCM activity. The Display APIs will continue to provide
1213      * DisplayArea bounds.
1214      * @hide
1215      */
1216     @ChangeId
1217     @Overridable
1218     @Disabled
1219     @TestApi
1220     public static final long NEVER_SANDBOX_DISPLAY_APIS = 184838306L; // buganizer id
1221 
1222     /**
1223      * This change id forces the packages it is applied to always have Display API sandboxing
1224      * applied, regardless of windowing mode. The Display APIs will always provide the app bounds.
1225      * @hide
1226      */
1227     @ChangeId
1228     @Overridable
1229     @Disabled
1230     @TestApi
1231     public static final long ALWAYS_SANDBOX_DISPLAY_APIS = 185004937L; // buganizer id
1232 
1233     /**
1234      * This change id excludes the packages it is applied to from ignoreOrientationRequest behaviour
1235      * that can be enabled by the device manufacturers for the com.android.server.wm.DisplayArea
1236      * or for the whole display.
1237      * @hide
1238      */
1239     @ChangeId
1240     @Overridable
1241     @Disabled
1242     public static final long OVERRIDE_RESPECT_REQUESTED_ORIENTATION = 236283604L; // buganizer id
1243 
1244     /**
1245      * This change id excludes the packages it is applied to from the camera compat force rotation
1246      * treatment. See com.android.server.wm.DisplayRotationCompatPolicy for context.
1247      * @hide
1248      */
1249     @ChangeId
1250     @Overridable
1251     @Disabled
1252     @TestApi
1253     public static final long OVERRIDE_CAMERA_COMPAT_DISABLE_FORCE_ROTATION =
1254             263959004L; // buganizer id
1255 
1256     /**
1257      * This change id excludes the packages it is applied to from activity refresh after camera
1258      * compat force rotation treatment. See com.android.server.wm.DisplayRotationCompatPolicy for
1259      * context.
1260      * @hide
1261      */
1262     @ChangeId
1263     @Overridable
1264     @Disabled
1265     @TestApi
1266     public static final long OVERRIDE_CAMERA_COMPAT_DISABLE_REFRESH = 264304459L; // buganizer id
1267 
1268     /**
1269      * This change id makes the packages it is applied to do activity refresh after camera compat
1270      * force rotation treatment using "resumed -> paused -> resumed" cycle rather than "resumed ->
1271      * ... -> stopped -> ... -> resumed" cycle. See
1272      * com.android.server.wm.DisplayRotationCompatPolicy for context.
1273      * @hide
1274      */
1275     @ChangeId
1276     @Overridable
1277     @Disabled
1278     @TestApi
1279     public static final long OVERRIDE_CAMERA_COMPAT_ENABLE_REFRESH_VIA_PAUSE =
1280             264301586L; // buganizer id
1281 
1282     /**
1283      * Excludes the packages the override is applied to from the camera compatibility treatment
1284      * in free-form windowing mode for fixed-orientation apps.
1285      *
1286      * <p>In free-form windowing mode, the compatibility treatment emulates running on a portrait
1287      * device by letterboxing the app window and changing the camera characteristics to what apps
1288      * commonly expect in a portrait device: 90 and 270 degree sensor rotation for back and front
1289      * cameras, respectively, and setting display rotation to 0.
1290      *
1291      * <p>Use this flag to disable the compatibility treatment for apps that do not respond well to
1292      * the treatment.
1293      *
1294      * @hide
1295      */
1296     @ChangeId
1297     @Overridable
1298     @Disabled
1299     public static final long OVERRIDE_CAMERA_COMPAT_DISABLE_FREEFORM_WINDOWING_TREATMENT =
1300             314961188L;
1301 
1302     /**
1303      * This change id forces the packages it is applied to sandbox {@link android.view.View} API to
1304      * an activity bounds for:
1305      *
1306      * <p>{@link android.view.View#getLocationOnScreen},
1307      * {@link android.view.View#getWindowVisibleDisplayFrame},
1308      * {@link android.view.View}#getWindowDisplayFrame,
1309      * {@link android.view.View}#getBoundsOnScreen.
1310      *
1311      * <p>For {@link android.view.View#getWindowVisibleDisplayFrame} and
1312      * {@link android.view.View}#getWindowDisplayFrame this sandboxing is happening indirectly
1313      * through
1314      * {@code android.view.ViewRootImpl#getWindowVisibleDisplayFrame},
1315      * {@code android.view.ViewRootImpl#getDisplayFrame} respectively.
1316      *
1317      * <p>Some applications assume that they occupy the whole screen and therefore use the display
1318      * coordinates in their calculations as if an activity is  positioned in the top-left corner of
1319      * the screen, with left coordinate equal to 0. This may not be the case of applications in
1320      * multi-window and in letterbox modes. This can lead to shifted or out of bounds UI elements in
1321      * case the activity is Letterboxed or is in multi-window mode.
1322      * @hide
1323      */
1324     @ChangeId
1325     @Overridable
1326     @Disabled
1327     @TestApi
1328     public static final long OVERRIDE_SANDBOX_VIEW_BOUNDS_APIS = 237531167L; // buganizer id
1329 
1330     /**
1331      * This change id is the gatekeeper for all treatments that force a given min aspect ratio.
1332      * Enabling this change will allow the following min aspect ratio treatments to be applied:
1333      * <ul>
1334      *  <li>OVERRIDE_MIN_ASPECT_RATIO_MEDIUM
1335      *  <li>OVERRIDE_MIN_ASPECT_RATIO_LARGE
1336      * </ul>
1337      *
1338      * If OVERRIDE_MIN_ASPECT_RATIO is applied, the min aspect ratio given in the app's manifest
1339      * will be overridden to the largest enabled aspect ratio treatment unless the app's manifest
1340      * value is higher. By default, this will only apply to activities with fixed portrait
1341      * orientation if OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY is not explicitly disabled.
1342      * @hide
1343      */
1344     @ChangeId
1345     @Overridable
1346     @Disabled
1347     @TestApi
1348     public static final long OVERRIDE_MIN_ASPECT_RATIO = 174042980L; // buganizer id
1349 
1350     /**
1351      * This change id restricts treatments that force a given min aspect ratio to
1352      * only when an app is connected to the camera
1353      *
1354      * @hide
1355      */
1356     @ChangeId
1357     @Overridable
1358     @Disabled
1359     public static final long OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA = 325586858L; // buganizer id
1360 
1361     /**
1362      * This change id restricts treatments that force a given min aspect ratio to activities
1363      * whose orientation is fixed to portrait.
1364      *
1365      * This treatment is enabled by default and only takes effect if OVERRIDE_MIN_ASPECT_RATIO is
1366      * also enabled.
1367      * @hide
1368      */
1369     @ChangeId
1370     @Overridable
1371     @TestApi
1372     public static final long OVERRIDE_MIN_ASPECT_RATIO_PORTRAIT_ONLY = 203647190L; // buganizer id
1373 
1374     /**
1375      * This change id sets the activity's min aspect ratio to a medium value as defined by
1376      * OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE.
1377      *
1378      * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled.
1379      * @hide
1380      */
1381     @ChangeId
1382     @Overridable
1383     @Disabled
1384     @TestApi
1385     public static final long OVERRIDE_MIN_ASPECT_RATIO_MEDIUM = 180326845L; // buganizer id
1386 
1387     /** @hide Medium override aspect ratio, currently 3:2.  */
1388     @TestApi
1389     public static final float OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE = 3 / 2f;
1390 
1391     /**
1392      * This change id sets the activity's min aspect ratio to a large value as defined by
1393      * OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE.
1394      *
1395      * This treatment only takes effect if OVERRIDE_MIN_ASPECT_RATIO is also enabled.
1396      * @hide
1397      */
1398     @ChangeId
1399     @Overridable
1400     @Disabled
1401     @TestApi
1402     public static final long OVERRIDE_MIN_ASPECT_RATIO_LARGE = 180326787L; // buganizer id
1403 
1404     /** @hide Large override aspect ratio, currently 16:9 */
1405     @TestApi
1406     public static final float OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE = 16 / 9f;
1407 
1408     /**
1409      * Enables the use of split screen aspect ratio. This allows an app to use all the available
1410      * space in split mode avoiding letterboxing.
1411      * @hide
1412      */
1413     @ChangeId
1414     @Disabled
1415     @Overridable
1416     @TestApi
1417     public static final long OVERRIDE_MIN_ASPECT_RATIO_TO_ALIGN_WITH_SPLIT_SCREEN = 208648326L;
1418 
1419     /**
1420      * Overrides the min aspect ratio restriction in portrait fullscreen in order to use all
1421      * available screen space.
1422      * @hide
1423      */
1424     @ChangeId
1425     @Disabled
1426     @Overridable
1427     @TestApi
1428     public static final long OVERRIDE_MIN_ASPECT_RATIO_EXCLUDE_PORTRAIT_FULLSCREEN = 218959984L;
1429 
1430     /**
1431      * Enables sending fake focus for unfocused apps in splitscreen. Some game engines
1432      * wait to get focus before drawing the content of the app so fake focus helps them to avoid
1433      * staying blacked out when they are resumed and do not have focus yet.
1434      * @hide
1435      */
1436     @ChangeId
1437     @Disabled
1438     @Overridable
1439     @TestApi
1440     public static final long OVERRIDE_ENABLE_COMPAT_FAKE_FOCUS = 263259275L;
1441 
1442     // Compat framework that per-app overrides rely on only supports booleans. That's why we have
1443     // multiple OVERRIDE_*_ORIENTATION_* change ids below instead of just one override with
1444     // the integer value.
1445 
1446     /**
1447      * Enables {@link #SCREEN_ORIENTATION_PORTRAIT}. Unless OVERRIDE_ANY_ORIENTATION
1448      * is enabled, this override is used only when no other fixed orientation was specified by the
1449      * activity.
1450      * @hide
1451      */
1452     @ChangeId
1453     @Disabled
1454     @Overridable
1455     @TestApi
1456     public static final long OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT = 265452344L;
1457 
1458     /**
1459      * Enables {@link #SCREEN_ORIENTATION_NOSENSOR}. Unless OVERRIDE_ANY_ORIENTATION
1460      * is enabled, this override is used only when no other fixed orientation was specified by the
1461      * activity.
1462      * @hide
1463      */
1464     @ChangeId
1465     @Disabled
1466     @Overridable
1467     @TestApi
1468     public static final long OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR = 265451093L;
1469 
1470     /**
1471      * Enables {@link #SCREEN_ORIENTATION_REVERSE_LANDSCAPE}. Unless OVERRIDE_ANY_ORIENTATION
1472      * is enabled, this override is used only when activity specify landscape orientation.
1473      * This can help apps that assume that landscape display orientation corresponds to {@link
1474      * android.view.Surface#ROTATION_90}, while on some devices it can be {@link
1475      * android.view.Surface#ROTATION_270}.
1476      * @hide
1477      */
1478     @ChangeId
1479     @Disabled
1480     @Overridable
1481     @TestApi
1482     public static final long OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE = 266124927L;
1483 
1484     /**
1485      * When enabled, allows OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE,
1486      * OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR and OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT
1487      * to override any orientation requested by the activity.
1488      * @hide
1489      */
1490     @ChangeId
1491     @Disabled
1492     @Overridable
1493     public static final long OVERRIDE_ANY_ORIENTATION = 265464455L;
1494 
1495     /**
1496      * When enabled, activates OVERRIDE_LANDSCAPE_ORIENTATION_TO_REVERSE_LANDSCAPE,
1497      * OVERRIDE_UNDEFINED_ORIENTATION_TO_NOSENSOR and OVERRIDE_UNDEFINED_ORIENTATION_TO_PORTRAIT
1498      * only when an app is connected to the camera. See
1499      * com.android.server.wm.DisplayRotationCompatPolicy for more context.
1500      * @hide
1501      */
1502     @ChangeId
1503     @Disabled
1504     @Overridable
1505     public static final long OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA = 265456536L;
1506 
1507     /**
1508      * This override fixes display orientation to landscape natural orientation when a task is
1509      * fullscreen. While display rotation is fixed to landscape, the orientation requested by the
1510      * activity will be still respected by bounds resolution logic. For instance, if an activity
1511      * requests portrait orientation and this override is set, then activity will appear in the
1512      * letterbox mode for fixed orientation with the display rotated to the lanscape natural
1513      * orientation.
1514      *
1515      * <p>This override is applicable only when natural orientation of the device is
1516      * landscape and display ignores orientation requestes.
1517      *
1518      * <p>Main use case for this override are camera-using activities that are portrait-only and
1519      * assume alignment with natural device orientation. Such activities can automatically be
1520      * rotated with com.android.server.wm.DisplayRotationCompatPolicy but not all of them can
1521      * handle dynamic rotation and thus can benefit from this override.
1522      *
1523      * @hide
1524      */
1525     @ChangeId
1526     @Disabled
1527     @Overridable
1528     @TestApi
1529     public static final long OVERRIDE_USE_DISPLAY_LANDSCAPE_NATURAL_ORIENTATION = 255940284L;
1530 
1531     /**
1532      * Enables {@link #SCREEN_ORIENTATION_USER} which overrides any orientation requested
1533      * by the activity. Fixed orientation apps can be overridden to fullscreen on large
1534      * screen devices with ignoreOrientationRequest enabled with this override.
1535      *
1536      * @hide
1537      */
1538     @ChangeId
1539     @Overridable
1540     @Disabled
1541     public static final long OVERRIDE_ANY_ORIENTATION_TO_USER = 310816437L;
1542 
1543     /**
1544      * Compares activity window layout min width/height with require space for multi window to
1545      * determine if it can be put into multi window mode.
1546      */
1547     @ChangeId
1548     @EnabledSince(targetSdkVersion = Build.VERSION_CODES.S)
1549     private static final long CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW = 197654537L;
1550 
1551     /**
1552      * The activity is targeting a SDK version that should receive the changed behavior of
1553      * configuration insets decouple.
1554      *
1555      * @hide
1556      */
1557     @ChangeId
1558     @EnabledSince(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
1559     public static final long INSETS_DECOUPLED_CONFIGURATION_ENFORCED = 151861875L;
1560 
1561     /**
1562      * When enabled, the activity will receive configuration decoupled from system bar insets.
1563      *
1564      * <p>This will only apply if the activity is targeting SDK level 34 or earlier versions.
1565      *
1566      * <p>This will only in effect if the device is trying to provide a different value by default
1567      * other than the legacy value, i.e., the
1568      * {@code Flags.allowsScreenSizeDecoupledFromStatusBarAndCutout()} is set to true.
1569      *
1570      * <p>If the {@code Flags.insetsDecoupledConfiguration()} is also set to true, all apps
1571      * targeting SDK level 35 or later, and apps with this override flag will receive the insets
1572      * decoupled configuration.
1573      *
1574      * @hide
1575      */
1576     @ChangeId
1577     @Disabled
1578     @Overridable
1579     public static final long OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION = 327313645L;
1580 
1581     /**
1582      * Optional set of a certificates identifying apps that are allowed to embed this activity. From
1583      * the "knownActivityEmbeddingCerts" attribute.
1584      */
1585     @Nullable
1586     private Set<String> mKnownActivityEmbeddingCerts;
1587 
1588     /**
1589      * Convert Java change bits to native.
1590      *
1591      * @hide
1592      */
1593     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
1594     public static @NativeConfig int activityInfoConfigJavaToNative(@Config int input) {
1595         int output = 0;
1596         for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) {
1597             if ((input & (1 << i)) != 0) {
1598                 output |= CONFIG_NATIVE_BITS[i];
1599             }
1600         }
1601         return output;
1602     }
1603 
1604     /**
1605      * Convert native change bits to Java.
1606      *
1607      * @hide
1608      */
1609     public static @Config int activityInfoConfigNativeToJava(@NativeConfig int input) {
1610         int output = 0;
1611         for (int i = 0; i < CONFIG_NATIVE_BITS.length; i++) {
1612             if ((input & CONFIG_NATIVE_BITS[i]) != 0) {
1613                 output |= (1 << i);
1614             }
1615         }
1616         return output;
1617     }
1618 
1619     /**
1620      * @hide
1621      * Unfortunately some developers (OpenFeint I am looking at you) have
1622      * compared the configChanges bit field against absolute values, so if we
1623      * introduce a new bit they break.  To deal with that, we will make sure
1624      * the public field will not have a value that breaks them, and let the
1625      * framework call here to get the real value.
1626      */
1627     public int getRealConfigChanged() {
1628         return applicationInfo.targetSdkVersion < android.os.Build.VERSION_CODES.HONEYCOMB_MR2
1629                 ? (configChanges | ActivityInfo.CONFIG_SCREEN_SIZE
1630                         | ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE)
1631                 : configChanges;
1632     }
1633 
1634     /**
1635      * Bit mask of kinds of configuration changes that this activity
1636      * can handle itself (without being restarted by the system).
1637      * Contains any combination of {@link #CONFIG_FONT_SCALE},
1638      * {@link #CONFIG_MCC}, {@link #CONFIG_MNC},
1639      * {@link #CONFIG_LOCALE}, {@link #CONFIG_TOUCHSCREEN},
1640      * {@link #CONFIG_KEYBOARD}, {@link #CONFIG_NAVIGATION},
1641      * {@link #CONFIG_ORIENTATION}, {@link #CONFIG_SCREEN_LAYOUT},
1642      * {@link #CONFIG_DENSITY}, {@link #CONFIG_LAYOUT_DIRECTION},
1643      * {@link #CONFIG_COLOR_MODE}, and {link #CONFIG_GRAMMATICAL_GENDER}.
1644      * Set from the {@link android.R.attr#configChanges} attribute.
1645      */
1646     public int configChanges;
1647 
1648     /**
1649      * The desired soft input mode for this activity's main window.
1650      * Set from the {@link android.R.attr#windowSoftInputMode} attribute
1651      * in the activity's manifest.  May be any of the same values allowed
1652      * for {@link android.view.WindowManager.LayoutParams#softInputMode
1653      * WindowManager.LayoutParams.softInputMode}.  If 0 (unspecified),
1654      * the mode from the theme will be used.
1655      */
1656     @android.view.WindowManager.LayoutParams.SoftInputModeFlags
1657     public int softInputMode;
1658 
1659     /**
1660      * The desired extra UI options for this activity and its main window.
1661      * Set from the {@link android.R.attr#uiOptions} attribute in the
1662      * activity's manifest.
1663      */
1664     public int uiOptions = 0;
1665 
1666     /**
1667      * Flag for use with {@link #uiOptions}.
1668      * Indicates that the action bar should put all action items in a separate bar when
1669      * the screen is narrow.
1670      * <p>This value corresponds to "splitActionBarWhenNarrow" for the {@link #uiOptions} XML
1671      * attribute.
1672      */
1673     public static final int UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW = 1;
1674 
1675     /**
1676      * If defined, the activity named here is the logical parent of this activity.
1677      */
1678     public String parentActivityName;
1679 
1680     /**
1681      * Screen rotation animation desired by the activity, with values as defined
1682      * for {@link android.view.WindowManager.LayoutParams#rotationAnimation}.
1683      *
1684      * -1 means to use the system default.
1685      *
1686      * @hide
1687      */
1688     public int rotationAnimation = -1;
1689 
1690     /** @hide */
1691     public static final int LOCK_TASK_LAUNCH_MODE_DEFAULT = 0;
1692     /** @hide */
1693     public static final int LOCK_TASK_LAUNCH_MODE_NEVER = 1;
1694     /** @hide */
1695     public static final int LOCK_TASK_LAUNCH_MODE_ALWAYS = 2;
1696     /** @hide */
1697     public static final int LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED = 3;
1698 
1699     /** @hide */
1700     public static final String lockTaskLaunchModeToString(int lockTaskLaunchMode) {
1701         switch (lockTaskLaunchMode) {
1702             case LOCK_TASK_LAUNCH_MODE_DEFAULT:
1703                 return "LOCK_TASK_LAUNCH_MODE_DEFAULT";
1704             case LOCK_TASK_LAUNCH_MODE_NEVER:
1705                 return "LOCK_TASK_LAUNCH_MODE_NEVER";
1706             case LOCK_TASK_LAUNCH_MODE_ALWAYS:
1707                 return "LOCK_TASK_LAUNCH_MODE_ALWAYS";
1708             case LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED:
1709                 return "LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED";
1710             default:
1711                 return "unknown=" + lockTaskLaunchMode;
1712         }
1713     }
1714     /**
1715      * Value indicating if the activity is to be locked at startup. Takes on the values from
1716      * {@link android.R.attr#lockTaskMode}.
1717      * @hide
1718      */
1719     public int lockTaskLaunchMode;
1720 
1721     /**
1722      * Information about desired position and size of activity on the display when
1723      * it is first started.
1724      */
1725     public WindowLayout windowLayout;
1726 
1727     public ActivityInfo() {
1728     }
1729 
1730     public ActivityInfo(ActivityInfo orig) {
1731         super(orig);
1732         theme = orig.theme;
1733         launchMode = orig.launchMode;
1734         documentLaunchMode = orig.documentLaunchMode;
1735         permission = orig.permission;
1736         mKnownActivityEmbeddingCerts = orig.mKnownActivityEmbeddingCerts;
1737         taskAffinity = orig.taskAffinity;
1738         targetActivity = orig.targetActivity;
1739         flags = orig.flags;
1740         privateFlags = orig.privateFlags;
1741         screenOrientation = orig.screenOrientation;
1742         configChanges = orig.configChanges;
1743         softInputMode = orig.softInputMode;
1744         uiOptions = orig.uiOptions;
1745         parentActivityName = orig.parentActivityName;
1746         maxRecents = orig.maxRecents;
1747         lockTaskLaunchMode = orig.lockTaskLaunchMode;
1748         windowLayout = orig.windowLayout;
1749         resizeMode = orig.resizeMode;
1750         requestedVrComponent = orig.requestedVrComponent;
1751         rotationAnimation = orig.rotationAnimation;
1752         colorMode = orig.colorMode;
1753         mMaxAspectRatio = orig.mMaxAspectRatio;
1754         mMinAspectRatio = orig.mMinAspectRatio;
1755         supportsSizeChanges = orig.supportsSizeChanges;
1756         requiredDisplayCategory = orig.requiredDisplayCategory;
1757         requireContentUriPermissionFromCaller = orig.requireContentUriPermissionFromCaller;
1758     }
1759 
1760     /**
1761      * Return the theme resource identifier to use for this activity.  If
1762      * the activity defines a theme, that is used; else, the application
1763      * theme is used.
1764      *
1765      * @return The theme associated with this activity.
1766      */
1767     public final int getThemeResource() {
1768         return theme != 0 ? theme : applicationInfo.theme;
1769     }
1770 
1771     private String persistableModeToString() {
1772         switch(persistableMode) {
1773             case PERSIST_ROOT_ONLY: return "PERSIST_ROOT_ONLY";
1774             case PERSIST_NEVER: return "PERSIST_NEVER";
1775             case PERSIST_ACROSS_REBOOTS: return "PERSIST_ACROSS_REBOOTS";
1776             default: return "UNKNOWN=" + persistableMode;
1777         }
1778     }
1779 
1780     /**
1781      * Returns true if the activity has maximum or minimum aspect ratio.
1782      * @hide
1783      */
1784     public boolean hasFixedAspectRatio() {
1785         return getMaxAspectRatio() != 0 || getMinAspectRatio() != 0;
1786     }
1787 
1788     /**
1789      * Returns true if the activity's orientation is fixed.
1790      * @hide
1791      */
1792     public boolean isFixedOrientation() {
1793         return isFixedOrientation(screenOrientation);
1794     }
1795 
1796     /**
1797      * Returns true if the passed activity's orientation is fixed.
1798      * @hide
1799      */
1800     public static boolean isFixedOrientation(@ScreenOrientation int orientation) {
1801         return orientation == SCREEN_ORIENTATION_LOCKED
1802                 // Orientation is fixed to natural display orientation
1803                 || orientation == SCREEN_ORIENTATION_NOSENSOR
1804                 || isFixedOrientationLandscape(orientation)
1805                 || isFixedOrientationPortrait(orientation);
1806     }
1807 
1808     /**
1809      * Returns true if the activity's orientation is fixed to landscape.
1810      * @hide
1811      */
1812     boolean isFixedOrientationLandscape() {
1813         return isFixedOrientationLandscape(screenOrientation);
1814     }
1815 
1816     /**
1817      * Returns true if the activity's orientation is fixed to landscape.
1818      * @hide
1819      */
1820     public static boolean isFixedOrientationLandscape(@ScreenOrientation int orientation) {
1821         return orientation == SCREEN_ORIENTATION_LANDSCAPE
1822                 || orientation == SCREEN_ORIENTATION_SENSOR_LANDSCAPE
1823                 || orientation == SCREEN_ORIENTATION_REVERSE_LANDSCAPE
1824                 || orientation == SCREEN_ORIENTATION_USER_LANDSCAPE;
1825     }
1826 
1827     /**
1828      * Returns true if the activity's orientation is fixed to portrait.
1829      * @hide
1830      */
1831     boolean isFixedOrientationPortrait() {
1832         return isFixedOrientationPortrait(screenOrientation);
1833     }
1834 
1835     /**
1836      * Returns true if the activity's orientation is fixed to portrait.
1837      * @hide
1838      */
1839     public static boolean isFixedOrientationPortrait(@ScreenOrientation int orientation) {
1840         return orientation == SCREEN_ORIENTATION_PORTRAIT
1841                 || orientation == SCREEN_ORIENTATION_SENSOR_PORTRAIT
1842                 || orientation == SCREEN_ORIENTATION_REVERSE_PORTRAIT
1843                 || orientation == SCREEN_ORIENTATION_USER_PORTRAIT;
1844     }
1845 
1846     /**
1847      * Returns the reversed orientation.
1848      * @hide
1849      */
1850     @ActivityInfo.ScreenOrientation
1851     public static int reverseOrientation(@ActivityInfo.ScreenOrientation int orientation) {
1852         switch (orientation) {
1853             case SCREEN_ORIENTATION_LANDSCAPE:
1854                 return SCREEN_ORIENTATION_PORTRAIT;
1855             case SCREEN_ORIENTATION_PORTRAIT:
1856                 return SCREEN_ORIENTATION_LANDSCAPE;
1857             case SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
1858                 return SCREEN_ORIENTATION_SENSOR_PORTRAIT;
1859             case SCREEN_ORIENTATION_SENSOR_PORTRAIT:
1860                 return SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
1861             case SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
1862                 return SCREEN_ORIENTATION_REVERSE_PORTRAIT;
1863             case SCREEN_ORIENTATION_REVERSE_PORTRAIT:
1864                 return SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
1865             case SCREEN_ORIENTATION_USER_LANDSCAPE:
1866                 return SCREEN_ORIENTATION_USER_PORTRAIT;
1867             case SCREEN_ORIENTATION_USER_PORTRAIT:
1868                 return SCREEN_ORIENTATION_USER_LANDSCAPE;
1869             default:
1870                 return orientation;
1871         }
1872     }
1873 
1874     /**
1875      * Returns true if the activity supports picture-in-picture.
1876      * @hide
1877      */
1878     @UnsupportedAppUsage
1879     public boolean supportsPictureInPicture() {
1880         return (flags & FLAG_SUPPORTS_PICTURE_IN_PICTURE) != 0;
1881     }
1882 
1883     /**
1884      * Returns if the activity should never be sandboxed to the activity window bounds.
1885      * @hide
1886      */
1887     public boolean neverSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig) {
1888         return isChangeEnabled(NEVER_SANDBOX_DISPLAY_APIS)
1889                 || constrainDisplayApisConfig.getNeverConstrainDisplayApis(applicationInfo);
1890     }
1891 
1892     /**
1893      * Returns if the activity should always be sandboxed to the activity window bounds.
1894      * @hide
1895      */
1896     public boolean alwaysSandboxDisplayApis(ConstrainDisplayApisConfig constrainDisplayApisConfig) {
1897         return isChangeEnabled(ALWAYS_SANDBOX_DISPLAY_APIS)
1898                 || constrainDisplayApisConfig.getAlwaysConstrainDisplayApis(applicationInfo);
1899     }
1900 
1901     /** @hide */
1902     public void setMaxAspectRatio(@FloatRange(from = 0f) float maxAspectRatio) {
1903         this.mMaxAspectRatio = maxAspectRatio >= 0f ? maxAspectRatio : 0f;
1904     }
1905 
1906     /** @hide */
1907     public float getMaxAspectRatio() {
1908         return mMaxAspectRatio;
1909     }
1910 
1911     /** @hide */
1912     public void setMinAspectRatio(@FloatRange(from = 0f) float minAspectRatio) {
1913         this.mMinAspectRatio = minAspectRatio >= 0f ? minAspectRatio : 0f;
1914     }
1915 
1916     /**
1917      * Returns the min aspect ratio of this activity as defined in the manifest file.
1918      * @hide
1919      */
1920     public float getMinAspectRatio() {
1921         return mMinAspectRatio;
1922     }
1923 
1924     /**
1925      * Gets the trusted host certificate digests of apps that are allowed to embed this activity.
1926      * The digests are computed using the SHA-256 digest algorithm.
1927      * @see android.R.attr#knownActivityEmbeddingCerts
1928      */
1929     @NonNull
1930     public Set<String> getKnownActivityEmbeddingCerts() {
1931         return mKnownActivityEmbeddingCerts == null ? Collections.emptySet()
1932                 : mKnownActivityEmbeddingCerts;
1933     }
1934 
1935     /**
1936      * Sets the trusted host certificates of apps that are allowed to embed this activity.
1937      * @see #getKnownActivityEmbeddingCerts()
1938      * @hide
1939      */
1940     public void setKnownActivityEmbeddingCerts(@NonNull Set<String> knownActivityEmbeddingCerts) {
1941         // Convert the provided digest to upper case for consistent Set membership
1942         // checks when verifying the signing certificate digests of requesting apps.
1943         mKnownActivityEmbeddingCerts = new ArraySet<>();
1944         for (String knownCert : knownActivityEmbeddingCerts) {
1945             mKnownActivityEmbeddingCerts.add(knownCert.toUpperCase(Locale.US));
1946         }
1947     }
1948 
1949     /**
1950      * Checks if a changeId is enabled for the current user
1951      * @param changeId The changeId to verify
1952      * @return True of the changeId is enabled
1953      * @hide
1954      */
1955     public boolean isChangeEnabled(long changeId) {
1956         return applicationInfo.isChangeEnabled(changeId);
1957     }
1958 
1959     /** @hide */
1960     public float getManifestMinAspectRatio() {
1961         return mMinAspectRatio;
1962     }
1963 
1964     /** @hide */
1965     @UnsupportedAppUsage
1966     public static boolean isResizeableMode(int mode) {
1967         return mode == RESIZE_MODE_RESIZEABLE
1968                 || mode == RESIZE_MODE_FORCE_RESIZEABLE
1969                 || mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY
1970                 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY
1971                 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION
1972                 || mode == RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
1973     }
1974 
1975     /** @hide */
1976     public static boolean isPreserveOrientationMode(int mode) {
1977         return mode == RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY
1978                 || mode == RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY
1979                 || mode == RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION;
1980     }
1981 
1982     /** @hide */
1983     public static String resizeModeToString(int mode) {
1984         switch (mode) {
1985             case RESIZE_MODE_UNRESIZEABLE:
1986                 return "RESIZE_MODE_UNRESIZEABLE";
1987             case RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION:
1988                 return "RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION";
1989             case RESIZE_MODE_RESIZEABLE:
1990                 return "RESIZE_MODE_RESIZEABLE";
1991             case RESIZE_MODE_FORCE_RESIZEABLE:
1992                 return "RESIZE_MODE_FORCE_RESIZEABLE";
1993             case RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY:
1994                 return "RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY";
1995             case RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY:
1996                 return "RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY";
1997             case RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION:
1998                 return "RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION";
1999             default:
2000                 return "unknown=" + mode;
2001         }
2002     }
2003 
2004     /** @hide */
2005     public static String sizeChangesSupportModeToString(@SizeChangesSupportMode int mode) {
2006         switch (mode) {
2007             case SIZE_CHANGES_UNSUPPORTED_METADATA:
2008                 return "SIZE_CHANGES_UNSUPPORTED_METADATA";
2009             case SIZE_CHANGES_UNSUPPORTED_OVERRIDE:
2010                 return "SIZE_CHANGES_UNSUPPORTED_OVERRIDE";
2011             case SIZE_CHANGES_SUPPORTED_METADATA:
2012                 return "SIZE_CHANGES_SUPPORTED_METADATA";
2013             case SIZE_CHANGES_SUPPORTED_OVERRIDE:
2014                 return "SIZE_CHANGES_SUPPORTED_OVERRIDE";
2015             default:
2016                 return "unknown=" + mode;
2017         }
2018     }
2019 
2020     /**
2021      * Whether we should compare activity window layout min width/height with require space for
2022      * multi window to determine if it can be put into multi window mode.
2023      * @hide
2024      */
2025     public boolean shouldCheckMinWidthHeightForMultiWindow() {
2026         return isChangeEnabled(CHECK_MIN_WIDTH_HEIGHT_FOR_MULTI_WINDOW);
2027     }
2028 
2029     /**
2030      * Returns whether the activity will set the
2031      * {@link R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback} attribute.
2032      *
2033      * @hide
2034      */
2035     public boolean hasOnBackInvokedCallbackEnabled() {
2036         return (privateFlags & (PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK
2037                 | PRIVATE_FLAG_DISABLE_ON_BACK_INVOKED_CALLBACK)) != 0;
2038     }
2039 
2040     /**
2041      * Returns whether the activity will use the {@link android.window.OnBackInvokedCallback}
2042      * navigation system instead of the {@link android.view.KeyEvent#KEYCODE_BACK} and related
2043      * callbacks.
2044      *
2045      * Valid when the {@link R.styleable.AndroidManifestActivity_enableOnBackInvokedCallback}
2046      * attribute has been set, or it won't indicate if the activity should use the
2047      * navigation system and the {@link hasOnBackInvokedCallbackEnabled} will return false.
2048      * @hide
2049      */
2050     public boolean isOnBackInvokedCallbackEnabled() {
2051         return hasOnBackInvokedCallbackEnabled()
2052                 && (privateFlags & PRIVATE_FLAG_ENABLE_ON_BACK_INVOKED_CALLBACK) != 0;
2053     }
2054 
2055     public void dump(Printer pw, String prefix) {
2056         dump(pw, prefix, DUMP_FLAG_ALL);
2057     }
2058 
2059     /** @hide */
2060     public void dump(Printer pw, String prefix, int dumpFlags) {
2061         super.dumpFront(pw, prefix);
2062         if (permission != null) {
2063             pw.println(prefix + "permission=" + permission);
2064         }
2065         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
2066             pw.println(prefix + "taskAffinity=" + taskAffinity
2067                     + " targetActivity=" + targetActivity
2068                     + " persistableMode=" + persistableModeToString());
2069         }
2070         if (launchMode != 0 || flags != 0 || privateFlags != 0 || theme != 0) {
2071             pw.println(prefix + "launchMode=" + launchModeToString(launchMode)
2072                     + " flags=0x" + Integer.toHexString(flags)
2073                     + " privateFlags=0x" + Integer.toHexString(privateFlags)
2074                     + " theme=0x" + Integer.toHexString(theme));
2075         }
2076         if (screenOrientation != SCREEN_ORIENTATION_UNSPECIFIED
2077                 || configChanges != 0 || softInputMode != 0) {
2078             pw.println(prefix + "screenOrientation=" + screenOrientation
2079                     + " configChanges=0x" + Integer.toHexString(configChanges)
2080                     + " softInputMode=0x" + Integer.toHexString(softInputMode));
2081         }
2082         if (uiOptions != 0) {
2083             pw.println(prefix + " uiOptions=0x" + Integer.toHexString(uiOptions));
2084         }
2085         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
2086             pw.println(prefix + "lockTaskLaunchMode="
2087                     + lockTaskLaunchModeToString(lockTaskLaunchMode));
2088         }
2089         if (windowLayout != null) {
2090             pw.println(prefix + "windowLayout=" + windowLayout.width + "|"
2091                     + windowLayout.widthFraction + ", " + windowLayout.height + "|"
2092                     + windowLayout.heightFraction + ", " + windowLayout.gravity);
2093         }
2094         pw.println(prefix + "resizeMode=" + resizeModeToString(resizeMode));
2095         if (requestedVrComponent != null) {
2096             pw.println(prefix + "requestedVrComponent=" + requestedVrComponent);
2097         }
2098         if (getMaxAspectRatio() != 0) {
2099             pw.println(prefix + "maxAspectRatio=" + getMaxAspectRatio());
2100         }
2101         final float minAspectRatio = getMinAspectRatio();
2102         if (minAspectRatio != 0) {
2103             pw.println(prefix + "minAspectRatio=" + minAspectRatio);
2104         }
2105         if (supportsSizeChanges) {
2106             pw.println(prefix + "supportsSizeChanges=true");
2107         }
2108         if (mKnownActivityEmbeddingCerts != null) {
2109             pw.println(prefix + "knownActivityEmbeddingCerts=" + mKnownActivityEmbeddingCerts);
2110         }
2111         if (requiredDisplayCategory != null) {
2112             pw.println(prefix + "requiredDisplayCategory=" + requiredDisplayCategory);
2113         }
2114         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
2115             pw.println(prefix + "requireContentUriPermissionFromCaller="
2116                     + requiredContentUriPermissionToFullString(
2117                             requireContentUriPermissionFromCaller));
2118         }
2119         super.dumpBack(pw, prefix, dumpFlags);
2120     }
2121 
2122     public String toString() {
2123         return "ActivityInfo{"
2124             + Integer.toHexString(System.identityHashCode(this))
2125             + " " + name + "}";
2126     }
2127 
2128     public int describeContents() {
2129         return 0;
2130     }
2131 
2132     public void writeToParcel(Parcel dest, int parcelableFlags) {
2133         super.writeToParcel(dest, parcelableFlags);
2134         dest.writeInt(theme);
2135         dest.writeInt(launchMode);
2136         dest.writeInt(documentLaunchMode);
2137         dest.writeString8(permission);
2138         dest.writeString8(taskAffinity);
2139         dest.writeString8(targetActivity);
2140         dest.writeString8(launchToken);
2141         dest.writeInt(flags);
2142         dest.writeInt(privateFlags);
2143         dest.writeInt(screenOrientation);
2144         dest.writeInt(configChanges);
2145         dest.writeInt(softInputMode);
2146         dest.writeInt(uiOptions);
2147         dest.writeString8(parentActivityName);
2148         dest.writeInt(persistableMode);
2149         dest.writeInt(maxRecents);
2150         dest.writeInt(lockTaskLaunchMode);
2151         if (windowLayout != null) {
2152             dest.writeInt(1);
2153             windowLayout.writeToParcel(dest);
2154         } else {
2155             dest.writeInt(0);
2156         }
2157         dest.writeInt(resizeMode);
2158         dest.writeString8(requestedVrComponent);
2159         dest.writeInt(rotationAnimation);
2160         dest.writeInt(colorMode);
2161         dest.writeFloat(mMaxAspectRatio);
2162         dest.writeFloat(mMinAspectRatio);
2163         dest.writeBoolean(supportsSizeChanges);
2164         sForStringSet.parcel(mKnownActivityEmbeddingCerts, dest, flags);
2165         dest.writeString8(requiredDisplayCategory);
2166         dest.writeInt(requireContentUriPermissionFromCaller);
2167     }
2168 
2169     /**
2170      * Determines whether the {@link Activity} is considered translucent or floating.
2171      * @hide
2172      */
2173     @UnsupportedAppUsage
2174     @TestApi
2175     public static boolean isTranslucentOrFloating(TypedArray attributes) {
2176         final boolean isTranslucent =
2177                 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsTranslucent,
2178                         false);
2179         final boolean isFloating =
2180                 attributes.getBoolean(com.android.internal.R.styleable.Window_windowIsFloating,
2181                         false);
2182 
2183         return isFloating || isTranslucent;
2184     }
2185 
2186     /**
2187      * Convert the screen orientation constant to a human readable format.
2188      * @hide
2189      */
2190     public static String screenOrientationToString(int orientation) {
2191         switch (orientation) {
2192             case SCREEN_ORIENTATION_UNSET:
2193                 return "SCREEN_ORIENTATION_UNSET";
2194             case SCREEN_ORIENTATION_UNSPECIFIED:
2195                 return "SCREEN_ORIENTATION_UNSPECIFIED";
2196             case SCREEN_ORIENTATION_LANDSCAPE:
2197                 return "SCREEN_ORIENTATION_LANDSCAPE";
2198             case SCREEN_ORIENTATION_PORTRAIT:
2199                 return "SCREEN_ORIENTATION_PORTRAIT";
2200             case SCREEN_ORIENTATION_USER:
2201                 return "SCREEN_ORIENTATION_USER";
2202             case SCREEN_ORIENTATION_BEHIND:
2203                 return "SCREEN_ORIENTATION_BEHIND";
2204             case SCREEN_ORIENTATION_SENSOR:
2205                 return "SCREEN_ORIENTATION_SENSOR";
2206             case SCREEN_ORIENTATION_NOSENSOR:
2207                 return "SCREEN_ORIENTATION_NOSENSOR";
2208             case SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
2209                 return "SCREEN_ORIENTATION_SENSOR_LANDSCAPE";
2210             case SCREEN_ORIENTATION_SENSOR_PORTRAIT:
2211                 return "SCREEN_ORIENTATION_SENSOR_PORTRAIT";
2212             case SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
2213                 return "SCREEN_ORIENTATION_REVERSE_LANDSCAPE";
2214             case SCREEN_ORIENTATION_REVERSE_PORTRAIT:
2215                 return "SCREEN_ORIENTATION_REVERSE_PORTRAIT";
2216             case SCREEN_ORIENTATION_FULL_SENSOR:
2217                 return "SCREEN_ORIENTATION_FULL_SENSOR";
2218             case SCREEN_ORIENTATION_USER_LANDSCAPE:
2219                 return "SCREEN_ORIENTATION_USER_LANDSCAPE";
2220             case SCREEN_ORIENTATION_USER_PORTRAIT:
2221                 return "SCREEN_ORIENTATION_USER_PORTRAIT";
2222             case SCREEN_ORIENTATION_FULL_USER:
2223                 return "SCREEN_ORIENTATION_FULL_USER";
2224             case SCREEN_ORIENTATION_LOCKED:
2225                 return "SCREEN_ORIENTATION_LOCKED";
2226             default:
2227                 return Integer.toString(orientation);
2228         }
2229     }
2230 
2231     /**
2232      * @hide
2233      */
2234     public static String colorModeToString(@ColorMode int colorMode) {
2235         switch (colorMode) {
2236             case COLOR_MODE_DEFAULT:
2237                 return "COLOR_MODE_DEFAULT";
2238             case COLOR_MODE_WIDE_COLOR_GAMUT:
2239                 return "COLOR_MODE_WIDE_COLOR_GAMUT";
2240             case COLOR_MODE_HDR:
2241                 return "COLOR_MODE_HDR";
2242             case COLOR_MODE_A8:
2243                 return "COLOR_MODE_A8";
2244             default:
2245                 return Integer.toString(colorMode);
2246         }
2247     }
2248 
2249     public static final @android.annotation.NonNull Parcelable.Creator<ActivityInfo> CREATOR
2250             = new Parcelable.Creator<ActivityInfo>() {
2251         public ActivityInfo createFromParcel(Parcel source) {
2252             return new ActivityInfo(source);
2253         }
2254         public ActivityInfo[] newArray(int size) {
2255             return new ActivityInfo[size];
2256         }
2257     };
2258 
2259     private ActivityInfo(Parcel source) {
2260         super(source);
2261         theme = source.readInt();
2262         launchMode = source.readInt();
2263         documentLaunchMode = source.readInt();
2264         permission = source.readString8();
2265         taskAffinity = source.readString8();
2266         targetActivity = source.readString8();
2267         launchToken = source.readString8();
2268         flags = source.readInt();
2269         privateFlags = source.readInt();
2270         screenOrientation = source.readInt();
2271         configChanges = source.readInt();
2272         softInputMode = source.readInt();
2273         uiOptions = source.readInt();
2274         parentActivityName = source.readString8();
2275         persistableMode = source.readInt();
2276         maxRecents = source.readInt();
2277         lockTaskLaunchMode = source.readInt();
2278         if (source.readInt() == 1) {
2279             windowLayout = new WindowLayout(source);
2280         }
2281         resizeMode = source.readInt();
2282         requestedVrComponent = source.readString8();
2283         rotationAnimation = source.readInt();
2284         colorMode = source.readInt();
2285         mMaxAspectRatio = source.readFloat();
2286         mMinAspectRatio = source.readFloat();
2287         supportsSizeChanges = source.readBoolean();
2288         mKnownActivityEmbeddingCerts = sForStringSet.unparcel(source);
2289         if (mKnownActivityEmbeddingCerts.isEmpty()) {
2290             mKnownActivityEmbeddingCerts = null;
2291         }
2292         requiredDisplayCategory = source.readString8();
2293         requireContentUriPermissionFromCaller = source.readInt();
2294     }
2295 
2296     /**
2297      * Contains information about position and size of the activity on the display.
2298      *
2299      * Used in freeform mode to set desired position when activity is first launched.
2300      * It describes how big the activity wants to be in both width and height,
2301      * the minimal allowed size, and the gravity to be applied.
2302      *
2303      * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth
2304      * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight
2305      * @attr ref android.R.styleable#AndroidManifestLayout_gravity
2306      * @attr ref android.R.styleable#AndroidManifestLayout_minWidth
2307      * @attr ref android.R.styleable#AndroidManifestLayout_minHeight
2308      */
2309     public static final class WindowLayout {
2310         public WindowLayout(int width, float widthFraction, int height, float heightFraction,
2311                 int gravity, int minWidth, int minHeight) {
2312             this(width, widthFraction, height, heightFraction, gravity, minWidth, minHeight,
2313                     null /* windowLayoutAffinity */);
2314         }
2315 
2316         /** @hide */
2317         public WindowLayout(int width, float widthFraction, int height, float heightFraction,
2318                 int gravity, int minWidth, int minHeight, String windowLayoutAffinity) {
2319             this.width = width;
2320             this.widthFraction = widthFraction;
2321             this.height = height;
2322             this.heightFraction = heightFraction;
2323             this.gravity = gravity;
2324             this.minWidth = minWidth;
2325             this.minHeight = minHeight;
2326             this.windowLayoutAffinity = windowLayoutAffinity;
2327         }
2328 
2329         /** @hide */
2330         public WindowLayout(Parcel source) {
2331             width = source.readInt();
2332             widthFraction = source.readFloat();
2333             height = source.readInt();
2334             heightFraction = source.readFloat();
2335             gravity = source.readInt();
2336             minWidth = source.readInt();
2337             minHeight = source.readInt();
2338             windowLayoutAffinity = source.readString8();
2339         }
2340 
2341         /**
2342          * Width of activity in pixels.
2343          *
2344          * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth
2345          */
2346         public final int width;
2347 
2348         /**
2349          * Width of activity as a fraction of available display width.
2350          * If both {@link #width} and this value are set this one will be preferred.
2351          *
2352          * @attr ref android.R.styleable#AndroidManifestLayout_defaultWidth
2353          */
2354         public final float widthFraction;
2355 
2356         /**
2357          * Height of activity in pixels.
2358          *
2359          * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight
2360          */
2361         public final int height;
2362 
2363         /**
2364          * Height of activity as a fraction of available display height.
2365          * If both {@link #height} and this value are set this one will be preferred.
2366          *
2367          * @attr ref android.R.styleable#AndroidManifestLayout_defaultHeight
2368          */
2369         public final float heightFraction;
2370 
2371         /**
2372          * Gravity of activity.
2373          * Currently {@link android.view.Gravity#TOP}, {@link android.view.Gravity#BOTTOM},
2374          * {@link android.view.Gravity#LEFT} and {@link android.view.Gravity#RIGHT} are supported.
2375          *
2376          * @attr ref android.R.styleable#AndroidManifestLayout_gravity
2377          */
2378         public final int gravity;
2379 
2380         /**
2381          * Minimal width of activity in pixels to be able to display its content.
2382          *
2383          * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional
2384          * activities launched in the task. That is if the root activity of a task set minimal
2385          * width, then the system will set the same minimal width on all other activities in the
2386          * task. It will also ignore any other minimal width attributes of non-root activities.
2387          *
2388          * @attr ref android.R.styleable#AndroidManifestLayout_minWidth
2389          */
2390         public final int minWidth;
2391 
2392         /**
2393          * Minimal height of activity in pixels to be able to display its content.
2394          *
2395          * <p><strong>NOTE:</strong> A task's root activity value is applied to all additional
2396          * activities launched in the task. That is if the root activity of a task set minimal
2397          * height, then the system will set the same minimal height on all other activities in the
2398          * task. It will also ignore any other minimal height attributes of non-root activities.
2399          *
2400          * @attr ref android.R.styleable#AndroidManifestLayout_minHeight
2401          */
2402         public final int minHeight;
2403 
2404         /**
2405          * Affinity of window layout parameters. Activities with the same UID and window layout
2406          * affinity will share the same window dimension record.
2407          *
2408          * @attr ref android.R.styleable#AndroidManifestLayout_windowLayoutAffinity
2409          * @hide
2410          */
2411         public String windowLayoutAffinity;
2412 
2413         /**
2414          * Returns if this {@link WindowLayout} has specified bounds.
2415          * @hide
2416          */
2417         public boolean hasSpecifiedSize() {
2418             return width >= 0 || height >= 0 || widthFraction >= 0 || heightFraction >= 0;
2419         }
2420 
2421         /** @hide */
2422         public void writeToParcel(Parcel dest) {
2423             dest.writeInt(width);
2424             dest.writeFloat(widthFraction);
2425             dest.writeInt(height);
2426             dest.writeFloat(heightFraction);
2427             dest.writeInt(gravity);
2428             dest.writeInt(minWidth);
2429             dest.writeInt(minHeight);
2430             dest.writeString8(windowLayoutAffinity);
2431         }
2432     }
2433 }
2434