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 static android.os.Build.VERSION_CODES.DONUT;
20 
21 import android.Manifest;
22 import android.annotation.FlaggedApi;
23 import android.annotation.IntDef;
24 import android.annotation.NonNull;
25 import android.annotation.Nullable;
26 import android.annotation.RequiresPermission;
27 import android.annotation.SystemApi;
28 import android.annotation.TestApi;
29 import android.app.compat.CompatChanges;
30 import android.compat.annotation.UnsupportedAppUsage;
31 import android.content.Context;
32 import android.content.pm.PackageManager.NameNotFoundException;
33 import android.content.res.Resources;
34 import android.graphics.drawable.Drawable;
35 import android.os.Build;
36 import android.os.Environment;
37 import android.os.Parcel;
38 import android.os.Parcelable;
39 import android.os.SystemClock;
40 import android.os.UserHandle;
41 import android.os.storage.StorageManager;
42 import android.util.ArrayMap;
43 import android.util.ArraySet;
44 import android.util.Printer;
45 import android.util.SparseArray;
46 import android.util.proto.ProtoOutputStream;
47 import android.window.OnBackInvokedCallback;
48 
49 import com.android.internal.util.ArrayUtils;
50 import com.android.internal.util.Parcelling;
51 import com.android.internal.util.Parcelling.BuiltIn.ForBoolean;
52 
53 import java.lang.annotation.Retention;
54 import java.lang.annotation.RetentionPolicy;
55 import java.text.Collator;
56 import java.util.ArrayList;
57 import java.util.Arrays;
58 import java.util.Collections;
59 import java.util.Comparator;
60 import java.util.List;
61 import java.util.Locale;
62 import java.util.Objects;
63 import java.util.Set;
64 import java.util.UUID;
65 
66 /**
67  * Information you can retrieve about a particular application.  This
68  * corresponds to information collected from the AndroidManifest.xml's
69  * <application> tag.
70  */
71 @android.ravenwood.annotation.RavenwoodKeepWholeClass
72 public class ApplicationInfo extends PackageItemInfo implements Parcelable {
73     private static final ForBoolean sForBoolean = Parcelling.Cache.getOrCreate(ForBoolean.class);
74     private static final Parcelling.BuiltIn.ForStringSet sForStringSet =
75             Parcelling.Cache.getOrCreate(Parcelling.BuiltIn.ForStringSet.class);
76 
77     /**
78      * Default task affinity of all activities in this application. See
79      * {@link ActivityInfo#taskAffinity} for more information.  This comes
80      * from the "taskAffinity" attribute.
81      */
82     public String taskAffinity;
83 
84     /**
85      * Optional name of a permission required to be able to access this
86      * application's components.  From the "permission" attribute.
87      */
88     public String permission;
89 
90     /**
91      * The name of the process this application should run in.  From the
92      * "process" attribute or, if not set, the same as
93      * <var>packageName</var>.
94      */
95     public String processName;
96 
97     /**
98      * Class implementing the Application object.  From the "class"
99      * attribute.
100      */
101     public String className;
102 
103     /**
104      * A style resource identifier (in the package's resources) of the
105      * description of an application.  From the "description" attribute
106      * or, if not set, 0.
107      */
108     public int descriptionRes;
109 
110     /**
111      * A style resource identifier (in the package's resources) of the
112      * default visual theme of the application.  From the "theme" attribute
113      * or, if not set, 0.
114      */
115     public int theme;
116 
117     /**
118      * Class implementing the Application's manage space
119      * functionality.  From the "manageSpaceActivity"
120      * attribute. This is an optional attribute and will be null if
121      * applications don't specify it in their manifest
122      */
123     public String manageSpaceActivityName;
124 
125     /**
126      * Class implementing the Application's backup functionality.  From
127      * the "backupAgent" attribute.  This is an optional attribute and
128      * will be null if the application does not specify it in its manifest.
129      *
130      * <p>If android:allowBackup is set to false, this attribute is ignored.
131      */
132     public String backupAgentName;
133 
134     /**
135      * An optional attribute that indicates the app supports automatic backup of app data.
136      * <p>0 is the default and means the app's entire data folder + managed external storage will
137      * be backed up;
138      * Any negative value indicates the app does not support full-data backup, though it may still
139      * want to participate via the traditional key/value backup API;
140      * A positive number specifies an xml resource in which the application has defined its backup
141      * include/exclude criteria.
142      * <p>If android:allowBackup is set to false, this attribute is ignored.
143      *
144      * @see android.content.Context#getNoBackupFilesDir()
145      * @see #FLAG_ALLOW_BACKUP
146      *
147      * @hide
148      */
149     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
150     public int fullBackupContent = 0;
151 
152     /**
153      * Applications can set this attribute to an xml resource within their app where they specified
154      * the rules determining which files and directories can be copied from the device as part of
155      * backup or transfer operations.
156      *<p>
157      * Set from the {@link android.R.styleable#AndroidManifestApplication_dataExtractionRules}
158      * attribute in the manifest.
159      *
160      * @hide
161      */
162     public int dataExtractionRulesRes = 0;
163 
164     /**
165      * <code>true</code> if the package is capable of presenting a unified interface representing
166      * multiple profiles.
167      * @hide
168      */
169     public boolean crossProfile;
170 
171     /**
172      * The default extra UI options for activities in this application.
173      * Set from the {@link android.R.attr#uiOptions} attribute in the
174      * activity's manifest.
175      */
176     public int uiOptions = 0;
177 
178     /**
179      * Value for {@link #flags}: if set, this application is installed in the device's system image.
180      * This should not be used to make security decisions. Instead, rely on
181      * {@linkplain android.content.pm.PackageManager#checkSignatures(java.lang.String,java.lang.String)
182      * signature checks} or
183      * <a href="https://developer.android.com/training/articles/security-tips#Permissions">permissions</a>.
184      *
185      * <p><b>Warning:</b> Note that this flag does not behave the same as
186      * {@link android.R.attr#protectionLevel android:protectionLevel} {@code system} or
187      * {@code signatureOrSystem}.
188      */
189     public static final int FLAG_SYSTEM = 1<<0;
190 
191     /**
192      * Value for {@link #flags}: set to true if this application would like to
193      * allow debugging of its
194      * code, even when installed on a non-development system.  Comes
195      * from {@link android.R.styleable#AndroidManifestApplication_debuggable
196      * android:debuggable} of the &lt;application&gt; tag.
197      */
198     public static final int FLAG_DEBUGGABLE = 1<<1;
199 
200     /**
201      * Value for {@link #flags}: set to true if this application has code
202      * associated with it.  Comes
203      * from {@link android.R.styleable#AndroidManifestApplication_hasCode
204      * android:hasCode} of the &lt;application&gt; tag.
205      */
206     public static final int FLAG_HAS_CODE = 1<<2;
207 
208     /**
209      * Value for {@link #flags}: set to true if this application is persistent.
210      * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
211      * android:persistent} of the &lt;application&gt; tag.
212      */
213     public static final int FLAG_PERSISTENT = 1<<3;
214 
215     /**
216      * Value for {@link #flags}: set to true if this application holds the
217      * {@link android.Manifest.permission#FACTORY_TEST} permission and the
218      * device is running in factory test mode.
219      */
220     public static final int FLAG_FACTORY_TEST = 1<<4;
221 
222     /**
223      * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
224      * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
225      * android:allowTaskReparenting} of the &lt;application&gt; tag.
226      */
227     public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
228 
229     /**
230      * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
231      * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
232      * android:allowClearUserData} of the &lt;application&gt; tag.
233      */
234     public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
235 
236     /**
237      * Value for {@link #flags}: this is set if this application has been
238      * installed as an update to a built-in system application.
239      */
240     public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
241 
242     /**
243      * Value for {@link #flags}: this is set if the application has specified
244      * {@link android.R.styleable#AndroidManifestApplication_testOnly
245      * android:testOnly} to be true.
246      */
247     public static final int FLAG_TEST_ONLY = 1<<8;
248 
249     /**
250      * Value for {@link #flags}: true when the application's window can be
251      * reduced in size for smaller screens.  Corresponds to
252      * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
253      * android:smallScreens}.
254      */
255     public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
256 
257     /**
258      * Value for {@link #flags}: true when the application's window can be
259      * displayed on normal screens.  Corresponds to
260      * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
261      * android:normalScreens}.
262      */
263     public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
264 
265     /**
266      * Value for {@link #flags}: true when the application's window can be
267      * increased in size for larger screens.  Corresponds to
268      * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
269      * android:largeScreens}.
270      */
271     public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
272 
273     /**
274      * Value for {@link #flags}: true when the application knows how to adjust
275      * its UI for different screen sizes.  Corresponds to
276      * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
277      * android:resizeable}.
278      */
279     public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
280 
281     /**
282      * Value for {@link #flags}: true when the application knows how to
283      * accommodate different screen densities.  Corresponds to
284      * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
285      * android:anyDensity}.
286      *
287      * @deprecated Set by default when targeting API 4 or higher and apps
288      *             should not set this to false.
289      */
290     @Deprecated
291     public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
292 
293     /**
294      * Value for {@link #flags}: set to true if this application would like to
295      * request the VM to operate under the safe mode. Comes from
296      * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
297      * android:vmSafeMode} of the &lt;application&gt; tag.
298      */
299     public static final int FLAG_VM_SAFE_MODE = 1<<14;
300 
301     /**
302      * Value for {@link #flags}: set to <code>false</code> if the application does not wish
303      * to permit any OS-driven backups of its data; <code>true</code> otherwise.
304      *
305      * <p>Comes from the
306      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
307      * attribute of the &lt;application&gt; tag.
308      */
309     public static final int FLAG_ALLOW_BACKUP = 1<<15;
310 
311     /**
312      * Value for {@link #flags}: set to <code>false</code> if the application must be kept
313      * in memory following a full-system restore operation; <code>true</code> otherwise.
314      * Ordinarily, during a full system restore operation each application is shut down
315      * following execution of its agent's onRestore() method.  Setting this attribute to
316      * <code>false</code> prevents this.  Most applications will not need to set this attribute.
317      *
318      * <p>If
319      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
320      * is set to <code>false</code> or no
321      * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
322      * is specified, this flag will be ignored.
323      *
324      * <p>Comes from the
325      * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
326      * attribute of the &lt;application&gt; tag.
327      */
328     public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
329 
330     /**
331      * Value for {@link #flags}: Set to <code>true</code> if the application's backup
332      * agent claims to be able to handle restore data even "from the future,"
333      * i.e. from versions of the application with a versionCode greater than
334      * the one currently installed on the device.  <i>Use with caution!</i>  By default
335      * this attribute is <code>false</code> and the Backup Manager will ensure that data
336      * from "future" versions of the application are never supplied during a restore operation.
337      *
338      * <p>If
339      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
340      * is set to <code>false</code> or no
341      * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
342      * is specified, this flag will be ignored.
343      *
344      * <p>Comes from the
345      * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
346      * attribute of the &lt;application&gt; tag.
347      */
348     public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
349 
350     /**
351      * Value for {@link #flags}: Set to true if the application is
352      * currently installed on external/removable/unprotected storage.  Such
353      * applications may not be available if their storage is not currently
354      * mounted.  When the storage it is on is not available, it will look like
355      * the application has been uninstalled (its .apk is no longer available)
356      * but its persistent data is not removed.
357      */
358     public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
359 
360     /**
361      * Value for {@link #flags}: true when the application's window can be
362      * increased in size for extra large screens.  Corresponds to
363      * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
364      * android:xlargeScreens}.
365      */
366     public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
367 
368     /**
369      * Value for {@link #flags}: true when the application has requested a
370      * large heap for its processes.  Corresponds to
371      * {@link android.R.styleable#AndroidManifestApplication_largeHeap
372      * android:largeHeap}.
373      */
374     public static final int FLAG_LARGE_HEAP = 1<<20;
375 
376     /**
377      * Value for {@link #flags}: true if this application's package is in
378      * the stopped state.
379      *
380      * <p>Stopped is the initial state after an app is installed, before it is launched
381      * or otherwise directly interacted with by the user. The system tries not to
382      * start it unless initiated by a user interaction (typically launching its icon
383      * from the launcher, could also include user actions like adding it as an app widget,
384      * selecting it as a live wallpaper, selecting it as a keyboard, etc). Stopped
385      * applications will not receive implicit broadcasts unless the sender specifies
386      * {@link android.content.Intent#FLAG_INCLUDE_STOPPED_PACKAGES}.
387      *
388      * <p>Applications should avoid launching activities, binding to or starting services, or
389      * otherwise causing a stopped application to run unless initiated by the user.
390      *
391      * <p>An app can also return to the stopped state by a "force stop".
392      */
393     public static final int FLAG_STOPPED = 1<<21;
394 
395     /**
396      * Value for {@link #flags}: true  when the application is willing to support
397      * RTL (right to left). All activities will inherit this value.
398      *
399      * Set from the {@link android.R.attr#supportsRtl} attribute in the
400      * activity's manifest.
401      *
402      * Default value is false (no support for RTL).
403      */
404     public static final int FLAG_SUPPORTS_RTL = 1<<22;
405 
406     /**
407      * Value for {@link #flags}: true if the application is currently
408      * installed for the calling user.
409      */
410     public static final int FLAG_INSTALLED = 1<<23;
411 
412     /**
413      * Value for {@link #flags}: true if the application only has its
414      * data installed; the application package itself does not currently
415      * exist on the device.
416      */
417     public static final int FLAG_IS_DATA_ONLY = 1<<24;
418 
419     /**
420      * Value for {@link #flags}: true if the application was declared to be a
421      * game, or false if it is a non-game application.
422      *
423      * @deprecated use {@link #CATEGORY_GAME} instead.
424      */
425     @Deprecated
426     public static final int FLAG_IS_GAME = 1<<25;
427 
428     /**
429      * Value for {@link #flags}: {@code true} if the application asks that only
430      * full-data streaming backups of its data be performed even though it defines
431      * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
432      * indicates that the app will manage its backed-up data via incremental
433      * key/value updates.
434      */
435     public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
436 
437     /**
438      * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
439      * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, SMTP
440      * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
441      * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
442      * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
443      * traffic. Third-party libraries are encouraged to honor this flag as well.
444      *
445      * <p>NOTE: {@code WebView} honors this flag for applications targeting API level 26 and up.
446      *
447      * <p>This flag is ignored on Android N and above if an Android Network Security Config is
448      * present.
449      *
450      * <p>This flag comes from
451      * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
452      * android:usesCleartextTraffic} of the &lt;application&gt; tag.
453      */
454     public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
455 
456     /**
457      * When set installer extracts native libs from .apk files.
458      */
459     public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
460 
461     /**
462      * Value for {@link #flags}: {@code true} when the application's rendering
463      * should be hardware accelerated.
464      */
465     public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
466 
467     /**
468      * Value for {@link #flags}: true if this application's package is in
469      * the suspended state.
470      */
471     public static final int FLAG_SUSPENDED = 1<<30;
472 
473     /**
474      * Value for {@link #flags}: true if code from this application will need to be
475      * loaded into other applications' processes. On devices that support multiple
476      * instruction sets, this implies the code might be loaded into a process that's
477      * using any of the devices supported instruction sets.
478      *
479      * <p> The system might treat such applications specially, for eg., by
480      * extracting the application's native libraries for all supported instruction
481      * sets or by compiling the application's dex code for all supported instruction
482      * sets.
483      */
484     public static final int FLAG_MULTIARCH  = 1 << 31;
485 
486     /**
487      * Flags associated with the application.  Any combination of
488      * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
489      * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
490      * {@link #FLAG_ALLOW_TASK_REPARENTING}
491      * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
492      * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
493      * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
494      * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
495      * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
496      * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
497      * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
498      * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
499      * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
500      * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
501      * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
502      * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
503      * {@link #FLAG_MULTIARCH}.
504      */
505     public int flags = 0;
506 
507     /**
508      * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
509      * most purposes is considered as not installed.
510      * {@hide}
511      */
512     public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
513 
514     /**
515      * Value for {@link #privateFlags}: set to <code>true</code> if the application
516      * has reported that it is heavy-weight, and thus can not participate in
517      * the normal application lifecycle.
518      *
519      * <p>Comes from the
520      * android.R.styleable#AndroidManifestApplication_cantSaveState
521      * attribute of the &lt;application&gt; tag.
522      *
523      * {@hide}
524      */
525     public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
526 
527     /**
528      * Value for {@link #privateFlags}: set to {@code true} if the application
529      * is permitted to hold privileged permissions.
530      *
531      * {@hide}
532      */
533     @UnsupportedAppUsage
534     @TestApi
535     public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
536 
537     /**
538      * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
539      * with some data URI using HTTP or HTTPS with an associated VIEW action.
540      *
541      * {@hide}
542      */
543     public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
544 
545     /**
546      * When set, the default data storage directory for this app is pointed at
547      * the device-protected location.
548      *
549      * @hide
550      */
551     public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
552 
553     /**
554      * When set, assume that all components under the given app are direct boot
555      * aware, unless otherwise specified.
556      *
557      * @hide
558      */
559     public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
560 
561     /**
562      * Value for {@link #privateFlags}: {@code true} if the application is installed
563      * as instant app.
564      *
565      * @hide
566      */
567     public static final int PRIVATE_FLAG_INSTANT = 1 << 7;
568 
569     /**
570      * When set, at least one component inside this application is direct boot
571      * aware.
572      *
573      * @hide
574      */
575     public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
576 
577 
578     /**
579      * When set, signals that the application is required for the system user and should not be
580      * uninstalled.
581      *
582      * @hide
583      */
584     public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
585 
586     /**
587      * When set, the application explicitly requested that its activities be resizeable by default.
588      * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
589      *
590      * @hide
591      */
592     public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE = 1 << 10;
593 
594     /**
595      * When set, the application explicitly requested that its activities *not* be resizeable by
596      * default.
597      * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
598      *
599      * @hide
600      */
601     public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE = 1 << 11;
602 
603     /**
604      * The application isn't requesting explicitly requesting for its activities to be resizeable or
605      * non-resizeable by default. So, we are making it activities resizeable by default based on the
606      * target SDK version of the app.
607      * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
608      *
609      * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
610      * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
611      * where certain pre-N apps are forced to the resizeable.
612      *
613      * @hide
614      */
615     public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION =
616             1 << 12;
617 
618     /**
619      * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
620      * run full-data backup operations for the app even when it is in a
621      * foreground-equivalent run state.  Defaults to {@code false} if unspecified.
622      * @hide
623      */
624     public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 13;
625 
626     /**
627      * Value for {@link #privateFlags}: {@code true} means this application
628      * contains a static shared library. Defaults to {@code false} if unspecified.
629      * @hide
630      */
631     public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 14;
632 
633     /**
634      * Value for {@link #privateFlags}: When set, the application will only have its splits loaded
635      * if they are required to load a component. Splits can be loaded on demand using the
636      * {@link Context#createContextForSplit(String)} API.
637      * @hide
638      */
639     public static final int PRIVATE_FLAG_ISOLATED_SPLIT_LOADING = 1 << 15;
640 
641     /**
642      * Value for {@link #privateFlags}: When set, the application was installed as
643      * a virtual preload.
644      * @hide
645      */
646     public static final int PRIVATE_FLAG_VIRTUAL_PRELOAD = 1 << 16;
647 
648     /**
649      * Value for {@link #privateFlags}: whether this app is pre-installed on the
650      * OEM partition of the system image.
651      * @hide
652      */
653     public static final int PRIVATE_FLAG_OEM = 1 << 17;
654 
655     /**
656      * Value for {@link #privateFlags}: whether this app is pre-installed on the
657      * vendor partition of the system image.
658      * @hide
659      */
660     public static final int PRIVATE_FLAG_VENDOR = 1 << 18;
661 
662     /**
663      * Value for {@link #privateFlags}: whether this app is pre-installed on the
664      * product partition of the system image.
665      * @hide
666      */
667     public static final int PRIVATE_FLAG_PRODUCT = 1 << 19;
668 
669     /**
670      * Value for {@link #privateFlags}: whether this app is signed with the
671      * platform key.
672      * @hide
673      */
674     public static final int PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY = 1 << 20;
675 
676     /**
677      * Value for {@link #privateFlags}: whether this app is pre-installed on the
678      * system_ext partition of the system image.
679      * @hide
680      */
681     public static final int PRIVATE_FLAG_SYSTEM_EXT = 1 << 21;
682 
683     /**
684      * Indicates whether this package requires access to non-SDK APIs.
685      * Only system apps and tests are allowed to use this property.
686      * @hide
687      */
688     public static final int PRIVATE_FLAG_USES_NON_SDK_API = 1 << 22;
689 
690     /**
691      * Indicates whether this application can be profiled by the shell user,
692      * even when running on a device that is running in user mode.
693      * @hide
694      */
695     public static final int PRIVATE_FLAG_PROFILEABLE_BY_SHELL = 1 << 23;
696 
697     /**
698      * Indicates whether this application has declared its user data as fragile,
699      * causing the system to prompt the user on whether to keep the user data
700      * on uninstall.
701      * @hide
702      */
703     public static final int PRIVATE_FLAG_HAS_FRAGILE_USER_DATA = 1 << 24;
704 
705     /**
706      * Indicates whether this application wants to use the embedded dex in the APK, rather than
707      * extracted or locally compiled variants. This keeps the dex code protected by the APK
708      * signature. Such apps will always run in JIT mode (same when they are first installed), and
709      * the system will never generate ahead-of-time compiled code for them. Depending on the app's
710      * workload, there may be some run time performance change, noteably the cold start time.
711      *
712      * @hide
713      */
714     public static final int PRIVATE_FLAG_USE_EMBEDDED_DEX = 1 << 25;
715 
716     /**
717      * Value for {@link #privateFlags}: indicates whether this application's data will be cleared
718      * on a failed restore.
719      *
720      * <p>Comes from the
721      * android.R.styleable#AndroidManifestApplication_allowClearUserDataOnFailedRestore attribute
722      * of the &lt;application&gt; tag.
723      *
724      * @hide
725      */
726     public static final int PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE = 1 << 26;
727 
728     /**
729      * Value for {@link #privateFlags}: true if the application allows its audio playback
730      * to be captured by other apps.
731      *
732      * @hide
733      */
734     public static final int PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE  = 1 << 27;
735 
736     /**
737      * Indicates whether this package is in fact a runtime resource overlay.
738      *
739      * @hide
740      */
741     public static final int PRIVATE_FLAG_IS_RESOURCE_OVERLAY = 1 << 28;
742 
743     /**
744      * Value for {@link #privateFlags}: If {@code true} this app requests
745      * full external storage access. The request may not be honored due to
746      * policy or other reasons.
747      *
748      * @hide
749      */
750     public static final int PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE = 1 << 29;
751 
752     /**
753      * Value for {@link #privateFlags}: whether this app is pre-installed on the
754      * ODM partition of the system image.
755      * @hide
756      */
757     public static final int PRIVATE_FLAG_ODM = 1 << 30;
758 
759     /**
760      * Value for {@link #privateFlags}: If {@code true} this app allows heap tagging.
761      * {@link com.android.server.am.ProcessList#NATIVE_HEAP_POINTER_TAGGING}
762      * @hide
763      */
764     public static final int PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING = 1 << 31;
765 
766     /** @hide */
767     @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
768             PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
769             PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION,
770             PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE,
771             PRIVATE_FLAG_BACKUP_IN_FOREGROUND,
772             PRIVATE_FLAG_CANT_SAVE_STATE,
773             PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE,
774             PRIVATE_FLAG_DIRECT_BOOT_AWARE,
775             PRIVATE_FLAG_HAS_DOMAIN_URLS,
776             PRIVATE_FLAG_HIDDEN,
777             PRIVATE_FLAG_INSTANT,
778             PRIVATE_FLAG_IS_RESOURCE_OVERLAY,
779             PRIVATE_FLAG_ISOLATED_SPLIT_LOADING,
780             PRIVATE_FLAG_OEM,
781             PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE,
782             PRIVATE_FLAG_USE_EMBEDDED_DEX,
783             PRIVATE_FLAG_PRIVILEGED,
784             PRIVATE_FLAG_PRODUCT,
785             PRIVATE_FLAG_SYSTEM_EXT,
786             PRIVATE_FLAG_PROFILEABLE_BY_SHELL,
787             PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER,
788             PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY,
789             PRIVATE_FLAG_STATIC_SHARED_LIBRARY,
790             PRIVATE_FLAG_VENDOR,
791             PRIVATE_FLAG_VIRTUAL_PRELOAD,
792             PRIVATE_FLAG_HAS_FRAGILE_USER_DATA,
793             PRIVATE_FLAG_ALLOW_CLEAR_USER_DATA_ON_FAILED_RESTORE,
794             PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE,
795             PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE,
796             PRIVATE_FLAG_ODM,
797             PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING,
798     })
799     @Retention(RetentionPolicy.SOURCE)
800     public @interface ApplicationInfoPrivateFlags {}
801 
802     /**
803      * Value for {@link #privateFlagsExt}: whether this application can be profiled, either by the
804      * shell user or the system.
805      * @hide
806      */
807     public static final int PRIVATE_FLAG_EXT_PROFILEABLE = 1 << 0;
808 
809     /**
810      * Value for {@link #privateFlagsExt}: whether this application has requested
811      * exemption from the foreground service restriction introduced in S
812      * (https://developer.android.com/about/versions/12/foreground-services).
813      * @hide
814      */
815     public static final int PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION = 1 << 1;
816 
817     /**
818      * Value for {@link #privateFlagsExt}: whether attributions provided by the application are
819      * meant to be user-visible.
820      * @hide
821      */
822     public static final int PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE = 1 << 2;
823 
824     /**
825      * If false, {@link android.view.KeyEvent#KEYCODE_BACK} related events will be forwarded to
826      * the Activities, Dialogs and Views and {@link android.app.Activity#onBackPressed()},
827      * {@link android.app.Dialog#onBackPressed} will be called. Otherwise, those events will be
828      * replaced by a call to {@link OnBackInvokedCallback#onBackInvoked()} on the focused window.
829      *
830      * @hide
831      * @see android.R.styleable.AndroidManifestApplication_enableOnBackInvokedCallback
832      */
833     public static final int PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK = 1 << 3;
834 
835     /**
836      * Whether or not this package is allowed to access hidden APIs. Replacement for legacy
837      * implementation of {@link #isPackageWhitelistedForHiddenApis()}.
838      *
839      * This is an internal flag and should never be used outside of this class. The real API for
840      * the hidden API enforcement policy is {@link #getHiddenApiEnforcementPolicy()}.
841      *
842      * @hide
843      */
844     public static final int PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS = 1 << 4;
845 
846     /**
847      * Whether AbiOverride was used when installing this application.
848      * @hide
849      */
850     public static final int PRIVATE_FLAG_EXT_CPU_OVERRIDE = 1 << 5;
851 
852     /** @hide */
853     @IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = {
854             PRIVATE_FLAG_EXT_PROFILEABLE,
855             PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION,
856             PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE,
857             PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK,
858             PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS,
859             PRIVATE_FLAG_EXT_CPU_OVERRIDE,
860     })
861     @Retention(RetentionPolicy.SOURCE)
862     public @interface ApplicationInfoPrivateFlagsExt {}
863     /**
864      * Constant corresponding to <code>allowed</code> in the
865      * {@link android.R.attr#autoRevokePermissions} attribute.
866      *
867      * @hide
868      */
869     public static final int AUTO_REVOKE_ALLOWED = 0;
870 
871     /**
872      * Constant corresponding to <code>discouraged</code> in the
873      * {@link android.R.attr#autoRevokePermissions} attribute.
874      *
875      * @hide
876      */
877     public static final int AUTO_REVOKE_DISCOURAGED = 1;
878 
879     /**
880      * Constant corresponding to <code>disallowed</code> in the
881      * {@link android.R.attr#autoRevokePermissions} attribute.
882      *
883      * @hide
884      */
885     public static final int AUTO_REVOKE_DISALLOWED = 2;
886 
887     /**
888      * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
889      * @hide
890      */
891     @UnsupportedAppUsage
892     @TestApi
893     public @ApplicationInfoPrivateFlags int privateFlags;
894 
895     /**
896      * More private/hidden flags. See {@code PRIVATE_FLAG_EXT_...} constants.
897      * @hide
898      */
899     public @ApplicationInfoPrivateFlagsExt int privateFlagsExt;
900 
901     /**
902      * @hide
903      */
904     public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
905 
906     /**
907      * The required smallest screen width the application can run on.  If 0,
908      * nothing has been specified.  Comes from
909      * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
910      * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
911      */
912     public int requiresSmallestWidthDp = 0;
913 
914     /**
915      * The maximum smallest screen width the application is designed for.  If 0,
916      * nothing has been specified.  Comes from
917      * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
918      * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
919      */
920     public int compatibleWidthLimitDp = 0;
921 
922     /**
923      * The maximum smallest screen width the application will work on.  If 0,
924      * nothing has been specified.  Comes from
925      * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
926      * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
927      */
928     public int largestWidthLimitDp = 0;
929 
930     /**
931      * Value indicating the maximum aspect ratio the application supports.
932      * <p>
933      * 0 means unset.
934      * @See {@link android.R.attr#maxAspectRatio}.
935      * @hide
936      */
937     public float maxAspectRatio;
938 
939     /**
940      * Value indicating the minimum aspect ratio the application supports.
941      * <p>
942      * 0 means unset.
943      * @see {@link android.R.attr#minAspectRatio}.
944      * @hide
945      */
946     public float minAspectRatio;
947 
948     /** @hide */
949     public String volumeUuid;
950 
951     /**
952      * UUID of the storage volume on which this application is being hosted. For
953      * apps hosted on the default internal storage at
954      * {@link Environment#getDataDirectory()}, the UUID value is
955      * {@link StorageManager#UUID_DEFAULT}.
956      */
957     public UUID storageUuid;
958 
959     /** {@hide} */
960     @UnsupportedAppUsage
961     public String scanSourceDir;
962     /** {@hide} */
963     @UnsupportedAppUsage
964     public String scanPublicSourceDir;
965 
966     /**
967      * Full path to the base APK for this application.
968      */
969     public String sourceDir;
970 
971     /**
972      * Full path to the publicly available parts of {@link #sourceDir},
973      * including resources and manifest. This may be different from
974      * {@link #sourceDir} if an application is forward locked.
975      */
976     public String publicSourceDir;
977 
978     /**
979      * The names of all installed split APKs, ordered lexicographically.
980      * May be null if no splits are installed.
981      */
982     @Nullable
983     public String[] splitNames;
984 
985     /**
986      * Full paths to split APKs, indexed by the same order as {@link #splitNames}.
987      * May be null if no splits are installed.
988      */
989     @Nullable
990     public String[] splitSourceDirs;
991 
992     /**
993      * Full path to the publicly available parts of {@link #splitSourceDirs},
994      * including resources and manifest. This may be different from
995      * {@link #splitSourceDirs} if an application is forward locked.
996      * May be null if no splits are installed.
997      *
998      * @see #splitSourceDirs
999      */
1000     @Nullable
1001     public String[] splitPublicSourceDirs;
1002 
1003     /**
1004      * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
1005      *
1006      * Available since platform version O.
1007      *
1008      * Only populated if the application opts in to isolated split loading via the
1009      * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
1010      * AndroidManifest.xml.
1011      *
1012      * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
1013      * and {@link #splitPublicSourceDirs} arrays.
1014      * Each key represents a split and its value is an array of splits. The first element of this
1015      * array is the parent split, and the rest are configuration splits. These configuration splits
1016      * have no dependencies themselves.
1017      * Cycles do not exist because they are illegal and screened for during installation.
1018      *
1019      * May be null if no splits are installed, or if no dependencies exist between them.
1020      *
1021      * NOTE: Any change to the way split dependencies are stored must update the logic that
1022      *       creates the class loader context for dexopt (DexoptUtils#getClassLoaderContexts).
1023      *
1024      * @hide
1025      */
1026     public SparseArray<int[]> splitDependencies;
1027 
1028     /**
1029      * Full paths to the locations of extra resource packages (runtime overlays)
1030      * this application uses. This field is only used if there are extra resource
1031      * packages, otherwise it is null.
1032      *
1033      * {@hide}
1034      */
1035     @UnsupportedAppUsage
1036     public String[] resourceDirs;
1037 
1038     /**
1039      * Contains the contents of {@link #resourceDirs} and along with paths for overlays that may or
1040      * may not be APK packages.
1041      *
1042      * {@hide}
1043      */
1044     public String[] overlayPaths;
1045 
1046     /**
1047      * String retrieved from the seinfo tag found in selinux policy. This value can be set through
1048      * the mac_permissions.xml policy construct. This value is used for setting an SELinux security
1049      * context on the process as well as its data directory.
1050      *
1051      * {@hide}
1052      */
1053     public String seInfo;
1054 
1055     /**
1056      * The seinfo tag generated per-user. This value may change based upon the
1057      * user's configuration. For example, when an instant app is installed for
1058      * a user. It is an error if this field is ever {@code null} when trying to
1059      * start a new process.
1060      * <p>NOTE: We need to separate this out because we modify per-user values
1061      * multiple times. This needs to be refactored since we're performing more
1062      * work than necessary and these values should only be set once. When that
1063      * happens, we can merge the per-user value with the seInfo state above.
1064      *
1065      * {@hide}
1066      */
1067     public String seInfoUser;
1068 
1069     /**
1070      * Paths to all shared libraries this application is linked against.  This
1071      * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
1072      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
1073      * the structure.
1074      */
1075     public String[] sharedLibraryFiles;
1076 
1077     /**
1078      * List of all shared libraries this application is linked against.  This
1079      * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
1080      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
1081      * the structure.
1082      *
1083      * NOTE: the list also contains the result of {@link #getOptionalSharedLibraryInfos}.
1084      *
1085      * {@hide}
1086      */
1087     @Nullable
1088     public List<SharedLibraryInfo> sharedLibraryInfos;
1089 
1090     /**
1091      * List of all shared libraries this application is optionally linked against.
1092      * This field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
1093      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
1094      * the structure.
1095      *
1096      * @hide
1097      */
1098     @Nullable
1099     public List<SharedLibraryInfo> optionalSharedLibraryInfos;
1100 
1101     /**
1102      * Full path to the default directory assigned to the package for its
1103      * persistent data.
1104      */
1105     public String dataDir;
1106 
1107     /**
1108      * Full path to the device-protected directory assigned to the package for
1109      * its persistent data.
1110      *
1111      * @see Context#createDeviceProtectedStorageContext()
1112      */
1113     public String deviceProtectedDataDir;
1114 
1115     /**
1116      * Full path to the credential-protected directory assigned to the package
1117      * for its persistent data.
1118      *
1119      * @hide
1120      */
1121     @SystemApi
1122     public String credentialProtectedDataDir;
1123 
1124     /**
1125      * Full path to the directory where native JNI libraries are stored.
1126      */
1127     public String nativeLibraryDir;
1128 
1129     /**
1130      * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
1131      * are stored, if present.
1132      *
1133      * The main reason this exists is for bundled multi-arch apps, where
1134      * it's not trivial to calculate the location of libs for the secondary abi
1135      * given the location of the primary.
1136      *
1137      * TODO: Change the layout of bundled installs so that we can use
1138      * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
1139      * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
1140      * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
1141      *
1142      * @hide
1143      */
1144     @UnsupportedAppUsage
1145     public String secondaryNativeLibraryDir;
1146 
1147     /**
1148      * The root path where unpacked native libraries are stored.
1149      * <p>
1150      * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
1151      * placed in ISA-specific subdirectories under this path, otherwise the
1152      * libraries are placed directly at this path.
1153      *
1154      * @hide
1155      */
1156     @UnsupportedAppUsage
1157     public String nativeLibraryRootDir;
1158 
1159     /**
1160      * Flag indicating that ISA must be appended to
1161      * {@link #nativeLibraryRootDir} to be useful.
1162      *
1163      * @hide
1164      */
1165     public boolean nativeLibraryRootRequiresIsa;
1166 
1167     /**
1168      * The primary ABI that this application requires, This is inferred from the ABIs
1169      * of the native JNI libraries the application bundles. Will be {@code null}
1170      * if this application does not require any particular ABI.
1171      *
1172      * If non-null, the application will always be launched with this ABI.
1173      *
1174      * {@hide}
1175      */
1176     @UnsupportedAppUsage
1177     public String primaryCpuAbi;
1178 
1179     /**
1180      * The secondary ABI for this application. Might be non-null for multi-arch
1181      * installs. The application itself never uses this ABI, but other applications that
1182      * use its code might.
1183      *
1184      * {@hide}
1185      */
1186     @UnsupportedAppUsage
1187     public String secondaryCpuAbi;
1188 
1189     /**
1190      * The kernel user-ID that has been assigned to this application;
1191      * currently this is not a unique ID (multiple applications can have
1192      * the same uid).
1193      */
1194     public int uid;
1195 
1196     /**
1197      * The minimum SDK version this application can run on. It will not run
1198      * on earlier versions.
1199      */
1200     public int minSdkVersion;
1201 
1202     /**
1203      * The minimum SDK version this application targets.  It may run on earlier
1204      * versions, but it knows how to work with any new behavior added at this
1205      * version.  Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
1206      * if this is a development build and the app is targeting that.  You should
1207      * compare that this number is >= the SDK version number at which your
1208      * behavior was introduced.
1209      */
1210     public int targetSdkVersion;
1211 
1212     /**
1213      * The app's declared version code.
1214      * @hide
1215      */
1216     public long longVersionCode;
1217 
1218     /**
1219      * An integer representation of the app's declared version code. This is being left in place as
1220      * some apps were using reflection to access it before the move to long in
1221      * {@link android.os.Build.VERSION_CODES#P}
1222      * @deprecated Use {@link #longVersionCode} instead.
1223      * @hide
1224      */
1225     @Deprecated
1226     @UnsupportedAppUsage
1227     public int versionCode;
1228 
1229     /**
1230      * The timestamp of when this ApplicationInfo was created.
1231      * @hide
1232      */
1233     public long createTimestamp;
1234 
1235     /**
1236      * The user-visible SDK version (ex. 26) of the framework against which the application claims
1237      * to have been compiled, or {@code 0} if not specified.
1238      * <p>
1239      * This property is the compile-time equivalent of
1240      * {@link android.os.Build.VERSION#CODENAME Build.VERSION.SDK_INT}.
1241      */
1242     public int compileSdkVersion;
1243 
1244     /**
1245      * The development codename (ex. "S", "REL") of the framework against which the application
1246      * claims to have been compiled, or {@code null} if not specified.
1247      * <p>
1248      * This property is the compile-time equivalent of
1249      * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
1250      */
1251     @Nullable
1252     public String compileSdkVersionCodename;
1253 
1254     /**
1255      * When false, indicates that all components within this application are
1256      * considered disabled, regardless of their individually set enabled status.
1257      */
1258     public boolean enabled = true;
1259 
1260     /**
1261      * For convenient access to the current enabled setting of this app.
1262      * @hide
1263      */
1264     @UnsupportedAppUsage
1265     public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
1266 
1267     /**
1268      * For convenient access to package's install location.
1269      * @hide
1270      */
1271     @UnsupportedAppUsage
1272     public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
1273 
1274     /**
1275      * Resource file providing the application's Network Security Config.
1276      * @hide
1277      */
1278     public int networkSecurityConfigRes;
1279 
1280     /**
1281      * Version of the sandbox the application wants to run in.
1282      * @hide
1283      */
1284     @SystemApi
1285     public int targetSandboxVersion;
1286 
1287     /**
1288      * The factory of this package, as specified by the &lt;manifest&gt;
1289      * tag's {@link android.R.styleable#AndroidManifestApplication_appComponentFactory}
1290      * attribute.
1291      */
1292     public String appComponentFactory;
1293 
1294     /**
1295      * Resource id of {@link com.android.internal.R.styleable.AndroidManifestProvider_icon}
1296      * @hide
1297      */
1298     public int iconRes;
1299 
1300     /**
1301      * Resource id of {@link com.android.internal.R.styleable.AndroidManifestProvider_roundIcon}
1302      * @hide
1303      */
1304     public int roundIconRes;
1305 
1306     /**
1307      * The category of this app. Categories are used to cluster multiple apps
1308      * together into meaningful groups, such as when summarizing battery,
1309      * network, or disk usage. Apps should only define this value when they fit
1310      * well into one of the specific categories.
1311      * <p>
1312      * Set from the {@link android.R.attr#appCategory} attribute in the
1313      * manifest. If the manifest doesn't define a category, this value may have
1314      * been provided by the installer via
1315      * {@link PackageManager#setApplicationCategoryHint(String, int)}.
1316      */
1317     public @Category int category = CATEGORY_UNDEFINED;
1318 
1319     /** {@hide} */
1320     @IntDef(prefix = { "CATEGORY_" }, value = {
1321             CATEGORY_UNDEFINED,
1322             CATEGORY_GAME,
1323             CATEGORY_AUDIO,
1324             CATEGORY_VIDEO,
1325             CATEGORY_IMAGE,
1326             CATEGORY_SOCIAL,
1327             CATEGORY_NEWS,
1328             CATEGORY_MAPS,
1329             CATEGORY_PRODUCTIVITY,
1330             CATEGORY_ACCESSIBILITY
1331     })
1332     @Retention(RetentionPolicy.SOURCE)
1333     public @interface Category {
1334     }
1335 
1336     /**
1337      * Value when category is undefined.
1338      *
1339      * @see #category
1340      */
1341     public static final int CATEGORY_UNDEFINED = -1;
1342 
1343     /**
1344      * Category for apps which are primarily games.
1345      *
1346      * @see #category
1347      */
1348     public static final int CATEGORY_GAME = 0;
1349 
1350     /**
1351      * Category for apps which primarily work with audio or music, such as music
1352      * players.
1353      *
1354      * @see #category
1355      */
1356     public static final int CATEGORY_AUDIO = 1;
1357 
1358     /**
1359      * Category for apps which primarily work with video or movies, such as
1360      * streaming video apps.
1361      *
1362      * @see #category
1363      */
1364     public static final int CATEGORY_VIDEO = 2;
1365 
1366     /**
1367      * Category for apps which primarily work with images or photos, such as
1368      * camera or gallery apps.
1369      *
1370      * @see #category
1371      */
1372     public static final int CATEGORY_IMAGE = 3;
1373 
1374     /**
1375      * Category for apps which are primarily social apps, such as messaging,
1376      * communication, email, or social network apps.
1377      *
1378      * @see #category
1379      */
1380     public static final int CATEGORY_SOCIAL = 4;
1381 
1382     /**
1383      * Category for apps which are primarily news apps, such as newspapers,
1384      * magazines, or sports apps.
1385      *
1386      * @see #category
1387      */
1388     public static final int CATEGORY_NEWS = 5;
1389 
1390     /**
1391      * Category for apps which are primarily maps apps, such as navigation apps.
1392      *
1393      * @see #category
1394      */
1395     public static final int CATEGORY_MAPS = 6;
1396 
1397     /**
1398      * Category for apps which are primarily productivity apps, such as cloud
1399      * storage or workplace apps.
1400      *
1401      * @see #category
1402      */
1403     public static final int CATEGORY_PRODUCTIVITY = 7;
1404 
1405     /**
1406      * Category for apps which are primarily accessibility apps, such as screen-readers.
1407      *
1408      * @see #category
1409      */
1410     public static final int CATEGORY_ACCESSIBILITY = 8;
1411 
1412     /**
1413      * Return a concise, localized title for the given
1414      * {@link ApplicationInfo#category} value, or {@code null} for unknown
1415      * values such as {@link #CATEGORY_UNDEFINED}.
1416      *
1417      * @see #category
1418      */
1419     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = android.content.res.Resources.class)
getCategoryTitle(Context context, @Category int category)1420     public static CharSequence getCategoryTitle(Context context, @Category int category) {
1421         switch (category) {
1422             case ApplicationInfo.CATEGORY_GAME:
1423                 return context.getText(com.android.internal.R.string.app_category_game);
1424             case ApplicationInfo.CATEGORY_AUDIO:
1425                 return context.getText(com.android.internal.R.string.app_category_audio);
1426             case ApplicationInfo.CATEGORY_VIDEO:
1427                 return context.getText(com.android.internal.R.string.app_category_video);
1428             case ApplicationInfo.CATEGORY_IMAGE:
1429                 return context.getText(com.android.internal.R.string.app_category_image);
1430             case ApplicationInfo.CATEGORY_SOCIAL:
1431                 return context.getText(com.android.internal.R.string.app_category_social);
1432             case ApplicationInfo.CATEGORY_NEWS:
1433                 return context.getText(com.android.internal.R.string.app_category_news);
1434             case ApplicationInfo.CATEGORY_MAPS:
1435                 return context.getText(com.android.internal.R.string.app_category_maps);
1436             case ApplicationInfo.CATEGORY_PRODUCTIVITY:
1437                 return context.getText(com.android.internal.R.string.app_category_productivity);
1438             case ApplicationInfo.CATEGORY_ACCESSIBILITY:
1439                 return context.getText(com.android.internal.R.string.app_category_accessibility);
1440             default:
1441                 return null;
1442         }
1443     }
1444 
1445     /** @hide */
1446     public String classLoaderName;
1447 
1448     /** @hide */
1449     public String[] splitClassLoaderNames;
1450 
1451     /** @hide */
1452     public boolean hiddenUntilInstalled;
1453 
1454     /** @hide */
1455     public String zygotePreloadName;
1456 
1457     /**
1458      * Default (unspecified) setting of GWP-ASan.
1459      */
1460     public static final int GWP_ASAN_DEFAULT = -1;
1461 
1462     /**
1463      * Never enable GWP-ASan in this application or process.
1464      */
1465     public static final int GWP_ASAN_NEVER = 0;
1466 
1467     /**
1468      * Always enable GWP-ASan in this application or process.
1469      */
1470     public static final int GWP_ASAN_ALWAYS = 1;
1471 
1472     /**
1473      * These constants need to match the values of gwpAsanMode in application manifest.
1474      * @hide
1475      */
1476     @IntDef(prefix = {"GWP_ASAN_"}, value = {
1477             GWP_ASAN_DEFAULT,
1478             GWP_ASAN_NEVER,
1479             GWP_ASAN_ALWAYS,
1480     })
1481     @Retention(RetentionPolicy.SOURCE)
1482     public @interface GwpAsanMode {}
1483 
1484     /**
1485      * Indicates if the application has requested GWP-ASan to be enabled, disabled, or left
1486      * unspecified. Processes can override this setting.
1487      */
1488     private @GwpAsanMode int gwpAsanMode = GWP_ASAN_DEFAULT;
1489 
1490     /**
1491      * Default (unspecified) setting of Memtag.
1492      */
1493     public static final int MEMTAG_DEFAULT = -1;
1494 
1495     /**
1496      * Do not enable Memtag in this application or process.
1497      */
1498     public static final int MEMTAG_OFF = 0;
1499 
1500     /**
1501      * Enable Memtag in Async mode in this application or process.
1502      */
1503     public static final int MEMTAG_ASYNC = 1;
1504 
1505     /**
1506      * Enable Memtag in Sync mode in this application or process.
1507      */
1508     public static final int MEMTAG_SYNC = 2;
1509 
1510     /**
1511      * These constants need to match the values of memtagMode in application manifest.
1512      * @hide
1513      */
1514     @IntDef(prefix = {"MEMTAG_"}, value = {
1515             MEMTAG_DEFAULT,
1516             MEMTAG_OFF,
1517             MEMTAG_ASYNC,
1518             MEMTAG_SYNC,
1519     })
1520     @Retention(RetentionPolicy.SOURCE)
1521     public @interface MemtagMode {}
1522 
1523     /**
1524      * Indicates if the application has requested Memtag to be enabled, disabled, or left
1525      * unspecified. Processes can override this setting.
1526      */
1527     private @MemtagMode int memtagMode = MEMTAG_DEFAULT;
1528 
1529     /**
1530      * Default (unspecified) setting of nativeHeapZeroInitialized.
1531      */
1532     public static final int ZEROINIT_DEFAULT = -1;
1533 
1534     /**
1535      * Disable zero-initialization of the native heap in this application or process.
1536      */
1537     public static final int ZEROINIT_DISABLED = 0;
1538 
1539     /**
1540      * Enable zero-initialization of the native heap in this application or process.
1541      */
1542     public static final int ZEROINIT_ENABLED = 1;
1543 
1544     /**
1545      * @hide
1546      */
1547     @IntDef(prefix = {"ZEROINIT_"}, value = {
1548             ZEROINIT_DEFAULT,
1549             ZEROINIT_DISABLED,
1550             ZEROINIT_ENABLED,
1551     })
1552     @Retention(RetentionPolicy.SOURCE)
1553     public @interface NativeHeapZeroInitialized {}
1554 
1555     /**
1556      * Enable automatic zero-initialization of native heap memory allocations.
1557      */
1558     private @NativeHeapZeroInitialized int nativeHeapZeroInitialized = ZEROINIT_DEFAULT;
1559 
1560     /**
1561      * If {@code true} this app requests raw external storage access.
1562      * The request may not be honored due to policy or other reasons.
1563      */
1564     @Nullable
1565     private Boolean requestRawExternalStorageAccess;
1566 
1567     /**
1568      * If {@code false}, this app does not allow its activities to be replaced by another app.
1569      * Is set from application manifest application tag's allowCrossUidActivitySwitchFromBelow
1570      * attribute.
1571      * @hide
1572      */
1573     public boolean allowCrossUidActivitySwitchFromBelow = true;
1574 
1575     /**
1576      * Represents the default policy. The actual policy used will depend on other properties of
1577      * the application, e.g. the target SDK version.
1578      * @hide
1579      */
1580     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1581     public static final int HIDDEN_API_ENFORCEMENT_DEFAULT = -1;
1582     /**
1583      * No API enforcement; the app can access the entire internal private API. Only for use by
1584      * system apps.
1585      * @hide
1586      */
1587     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1588     public static final int HIDDEN_API_ENFORCEMENT_DISABLED = 0;
1589     /**
1590      * No API enforcement, but enable the detection logic and warnings. Observed behaviour is the
1591      * same as {@link #HIDDEN_API_ENFORCEMENT_DISABLED} but you may see warnings in the log when
1592      * APIs are accessed.
1593      * @hide
1594      * */
1595     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1596     public static final int HIDDEN_API_ENFORCEMENT_JUST_WARN = 1;
1597     /**
1598      * Dark grey list enforcement. Enforces the dark grey and black lists
1599      * @hide
1600      */
1601     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1602     public static final int HIDDEN_API_ENFORCEMENT_ENABLED = 2;
1603 
1604     private static final int HIDDEN_API_ENFORCEMENT_MIN = HIDDEN_API_ENFORCEMENT_DEFAULT;
1605     private static final int HIDDEN_API_ENFORCEMENT_MAX = HIDDEN_API_ENFORCEMENT_ENABLED;
1606 
1607     /**
1608      * Values in this IntDef MUST be kept in sync with enum hiddenapi::EnforcementPolicy in
1609      * art/runtime/hidden_api.h
1610      * @hide
1611      */
1612     @IntDef(prefix = { "HIDDEN_API_ENFORCEMENT_" }, value = {
1613             HIDDEN_API_ENFORCEMENT_DEFAULT,
1614             HIDDEN_API_ENFORCEMENT_DISABLED,
1615             HIDDEN_API_ENFORCEMENT_JUST_WARN,
1616             HIDDEN_API_ENFORCEMENT_ENABLED,
1617     })
1618     @Retention(RetentionPolicy.SOURCE)
1619     public @interface HiddenApiEnforcementPolicy {}
1620 
1621     /** @hide */
isValidHiddenApiEnforcementPolicy(int policy)1622     public static boolean isValidHiddenApiEnforcementPolicy(int policy) {
1623         return policy >= HIDDEN_API_ENFORCEMENT_MIN && policy <= HIDDEN_API_ENFORCEMENT_MAX;
1624     }
1625 
1626     private int mHiddenApiPolicy = HIDDEN_API_ENFORCEMENT_DEFAULT;
1627 
1628     /**
1629      * A map from a process name to an (custom) application class name in this package, derived
1630      * from the <processes> tag in the app's manifest. This map may not contain all the process
1631      * names. Processses not in this map will use the default app class name,
1632      * which is {@link #className}, or the default class {@link android.app.Application}.
1633      */
1634     @Nullable
1635     private ArrayMap<String, String> mAppClassNamesByProcess;
1636 
1637     /**
1638      * Resource file providing the application's locales configuration.
1639      */
1640     private int localeConfigRes;
1641 
1642     /**
1643      * Optional set of a certificates identifying apps that are allowed to embed activities of this
1644      * application. From the "knownActivityEmbeddingCerts" attribute.
1645      */
1646     @Nullable
1647     private Set<String> mKnownActivityEmbeddingCerts;
1648 
dump(Printer pw, String prefix)1649     public void dump(Printer pw, String prefix) {
1650         dump(pw, prefix, DUMP_FLAG_ALL);
1651     }
1652 
1653     /** @hide */
dump(Printer pw, String prefix, int dumpFlags)1654     public void dump(Printer pw, String prefix, int dumpFlags) {
1655         super.dumpFront(pw, prefix);
1656         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1657             if (className != null) {
1658                 pw.println(prefix + "className=" + className);
1659             }
1660             for (int i = 0; i < ArrayUtils.size(mAppClassNamesByProcess); i++) {
1661                 pw.println(prefix + "  process=" + mAppClassNamesByProcess.keyAt(i)
1662                         + " className=" + mAppClassNamesByProcess.valueAt(i));
1663             }
1664         }
1665         if (permission != null) {
1666             pw.println(prefix + "permission=" + permission);
1667         }
1668         pw.println(prefix + "processName=" + processName);
1669         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1670             pw.println(prefix + "taskAffinity=" + taskAffinity);
1671         }
1672         pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
1673                 + " privateFlags=0x" + Integer.toHexString(privateFlags)
1674                 + " theme=0x" + Integer.toHexString(theme));
1675         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1676             pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1677                     + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1678                     + " largestWidthLimitDp=" + largestWidthLimitDp);
1679         }
1680         pw.println(prefix + "sourceDir=" + sourceDir);
1681         if (!Objects.equals(sourceDir, publicSourceDir)) {
1682             pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1683         }
1684         if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1685             pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1686         }
1687         if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1688                 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1689             pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1690         }
1691         if (resourceDirs != null) {
1692             pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
1693         }
1694         if (overlayPaths != null) {
1695             pw.println(prefix + "overlayPaths=" + Arrays.toString(overlayPaths));
1696         }
1697         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
1698             pw.println(prefix + "seinfo=" + seInfo);
1699             pw.println(prefix + "seinfoUser=" + seInfoUser);
1700         }
1701         pw.println(prefix + "dataDir=" + dataDir);
1702         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1703             pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1704             pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
1705             if (sharedLibraryFiles != null) {
1706                 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1707             }
1708         }
1709         if (classLoaderName != null) {
1710             pw.println(prefix + "classLoaderName=" + classLoaderName);
1711         }
1712         if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1713             pw.println(prefix + "splitClassLoaderNames=" + Arrays.toString(splitClassLoaderNames));
1714         }
1715 
1716         pw.println(prefix + "enabled=" + enabled
1717                 + " minSdkVersion=" + minSdkVersion
1718                 + " targetSdkVersion=" + targetSdkVersion
1719                 + " versionCode=" + longVersionCode
1720                 + " targetSandboxVersion=" + targetSandboxVersion);
1721         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1722             if (manageSpaceActivityName != null) {
1723                 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1724             }
1725             if (descriptionRes != 0) {
1726                 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1727             }
1728             if (uiOptions != 0) {
1729                 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1730             }
1731             pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1732             if (fullBackupContent > 0) {
1733                 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1734             } else {
1735                 pw.println(prefix + "fullBackupContent="
1736                         + (fullBackupContent < 0 ? "false" : "true"));
1737             }
1738             if (dataExtractionRulesRes != 0) {
1739                 pw.println(prefix + "dataExtractionRules=@xml/" + dataExtractionRulesRes);
1740             }
1741             pw.println(prefix + "crossProfile=" + (crossProfile ? "true" : "false"));
1742             if (networkSecurityConfigRes != 0) {
1743                 pw.println(prefix + "networkSecurityConfigRes=0x"
1744                         + Integer.toHexString(networkSecurityConfigRes));
1745             }
1746             if (category != CATEGORY_UNDEFINED) {
1747                 pw.println(prefix + "category=" + category);
1748             }
1749             pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
1750             pw.println(prefix + "usesNonSdkApi=" + usesNonSdkApi());
1751             pw.println(prefix + "allowsPlaybackCapture="
1752                         + (isAudioPlaybackCaptureAllowed() ? "true" : "false"));
1753             if (gwpAsanMode != GWP_ASAN_DEFAULT) {
1754                 pw.println(prefix + "gwpAsanMode=" + gwpAsanMode);
1755             }
1756             if (memtagMode != MEMTAG_DEFAULT) {
1757                 pw.println(prefix + "memtagMode=" + memtagMode);
1758             }
1759             if (nativeHeapZeroInitialized != ZEROINIT_DEFAULT) {
1760                 pw.println(prefix + "nativeHeapZeroInitialized=" + nativeHeapZeroInitialized);
1761             }
1762             if (requestRawExternalStorageAccess != null) {
1763                 pw.println(prefix + "requestRawExternalStorageAccess="
1764                         + requestRawExternalStorageAccess);
1765             }
1766             if (localeConfigRes != 0) {
1767                 pw.println(prefix + "localeConfigRes=0x"
1768                         + Integer.toHexString(localeConfigRes));
1769             }
1770             pw.println(prefix + "enableOnBackInvokedCallback=" + isOnBackInvokedCallbackEnabled());
1771             pw.println(prefix + "allowCrossUidActivitySwitchFromBelow="
1772                     + allowCrossUidActivitySwitchFromBelow);
1773 
1774         }
1775         pw.println(prefix + "createTimestamp=" + createTimestamp);
1776         if (mKnownActivityEmbeddingCerts != null) {
1777             pw.println(prefix + "knownActivityEmbeddingCerts=" + mKnownActivityEmbeddingCerts);
1778         }
1779         super.dumpBack(pw, prefix);
1780     }
1781 
1782     /** {@hide} */
dumpDebug(ProtoOutputStream proto, long fieldId, int dumpFlags)1783     public void dumpDebug(ProtoOutputStream proto, long fieldId, int dumpFlags) {
1784         long token = proto.start(fieldId);
1785         super.dumpDebug(proto, ApplicationInfoProto.PACKAGE, dumpFlags);
1786         proto.write(ApplicationInfoProto.PERMISSION, permission);
1787         proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
1788         proto.write(ApplicationInfoProto.UID, uid);
1789         proto.write(ApplicationInfoProto.FLAGS, flags);
1790         proto.write(ApplicationInfoProto.PRIVATE_FLAGS, privateFlags);
1791         proto.write(ApplicationInfoProto.THEME, theme);
1792         proto.write(ApplicationInfoProto.SOURCE_DIR, sourceDir);
1793         if (!Objects.equals(sourceDir, publicSourceDir)) {
1794             proto.write(ApplicationInfoProto.PUBLIC_SOURCE_DIR, publicSourceDir);
1795         }
1796         if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1797             for (String dir : splitSourceDirs) {
1798                 proto.write(ApplicationInfoProto.SPLIT_SOURCE_DIRS, dir);
1799             }
1800         }
1801         if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1802                 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1803             for (String dir : splitPublicSourceDirs) {
1804                 proto.write(ApplicationInfoProto.SPLIT_PUBLIC_SOURCE_DIRS, dir);
1805             }
1806         }
1807         if (resourceDirs != null) {
1808             for (String dir : resourceDirs) {
1809                 proto.write(ApplicationInfoProto.RESOURCE_DIRS, dir);
1810             }
1811         }
1812         if (overlayPaths != null) {
1813             for (String dir : overlayPaths) {
1814                 proto.write(ApplicationInfoProto.OVERLAY_PATHS, dir);
1815             }
1816         }
1817         proto.write(ApplicationInfoProto.DATA_DIR, dataDir);
1818         proto.write(ApplicationInfoProto.CLASS_LOADER_NAME, classLoaderName);
1819         if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1820             for (String name : splitClassLoaderNames) {
1821                 proto.write(ApplicationInfoProto.SPLIT_CLASS_LOADER_NAMES, name);
1822             }
1823         }
1824 
1825         long versionToken = proto.start(ApplicationInfoProto.VERSION);
1826         proto.write(ApplicationInfoProto.Version.ENABLED, enabled);
1827         proto.write(ApplicationInfoProto.Version.MIN_SDK_VERSION, minSdkVersion);
1828         proto.write(ApplicationInfoProto.Version.TARGET_SDK_VERSION, targetSdkVersion);
1829         proto.write(ApplicationInfoProto.Version.VERSION_CODE, longVersionCode);
1830         proto.write(ApplicationInfoProto.Version.TARGET_SANDBOX_VERSION, targetSandboxVersion);
1831         proto.end(versionToken);
1832 
1833         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1834             long detailToken = proto.start(ApplicationInfoProto.DETAIL);
1835             if (className != null) {
1836                 proto.write(ApplicationInfoProto.Detail.CLASS_NAME, className);
1837             }
1838             proto.write(ApplicationInfoProto.Detail.TASK_AFFINITY, taskAffinity);
1839             proto.write(ApplicationInfoProto.Detail.REQUIRES_SMALLEST_WIDTH_DP,
1840                     requiresSmallestWidthDp);
1841             proto.write(ApplicationInfoProto.Detail.COMPATIBLE_WIDTH_LIMIT_DP,
1842                     compatibleWidthLimitDp);
1843             proto.write(ApplicationInfoProto.Detail.LARGEST_WIDTH_LIMIT_DP,
1844                     largestWidthLimitDp);
1845             if (seInfo != null) {
1846                 proto.write(ApplicationInfoProto.Detail.SEINFO, seInfo);
1847                 proto.write(ApplicationInfoProto.Detail.SEINFO_USER, seInfoUser);
1848             }
1849             proto.write(ApplicationInfoProto.Detail.DEVICE_PROTECTED_DATA_DIR,
1850                     deviceProtectedDataDir);
1851             proto.write(ApplicationInfoProto.Detail.CREDENTIAL_PROTECTED_DATA_DIR,
1852                     credentialProtectedDataDir);
1853             if (sharedLibraryFiles != null) {
1854                 for (String f : sharedLibraryFiles) {
1855                     proto.write(ApplicationInfoProto.Detail.SHARED_LIBRARY_FILES, f);
1856                 }
1857             }
1858             if (manageSpaceActivityName != null) {
1859                 proto.write(ApplicationInfoProto.Detail.MANAGE_SPACE_ACTIVITY_NAME,
1860                         manageSpaceActivityName);
1861             }
1862             if (descriptionRes != 0) {
1863                 proto.write(ApplicationInfoProto.Detail.DESCRIPTION_RES, descriptionRes);
1864             }
1865             if (uiOptions != 0) {
1866                 proto.write(ApplicationInfoProto.Detail.UI_OPTIONS, uiOptions);
1867             }
1868             proto.write(ApplicationInfoProto.Detail.SUPPORTS_RTL, hasRtlSupport());
1869             if (fullBackupContent > 0) {
1870                 proto.write(ApplicationInfoProto.Detail.CONTENT, "@xml/" + fullBackupContent);
1871             } else {
1872                 proto.write(ApplicationInfoProto.Detail.IS_FULL_BACKUP, fullBackupContent == 0);
1873             }
1874             if (networkSecurityConfigRes != 0) {
1875                 proto.write(ApplicationInfoProto.Detail.NETWORK_SECURITY_CONFIG_RES,
1876                         networkSecurityConfigRes);
1877             }
1878             if (category != CATEGORY_UNDEFINED) {
1879                 proto.write(ApplicationInfoProto.Detail.CATEGORY, category);
1880             }
1881             if (gwpAsanMode != GWP_ASAN_DEFAULT) {
1882                 proto.write(ApplicationInfoProto.Detail.ENABLE_GWP_ASAN, gwpAsanMode);
1883             }
1884             if (memtagMode != MEMTAG_DEFAULT) {
1885                 proto.write(ApplicationInfoProto.Detail.ENABLE_MEMTAG, memtagMode);
1886             }
1887             if (nativeHeapZeroInitialized != ZEROINIT_DEFAULT) {
1888                 proto.write(ApplicationInfoProto.Detail.NATIVE_HEAP_ZERO_INIT,
1889                         nativeHeapZeroInitialized);
1890             }
1891             proto.write(ApplicationInfoProto.Detail.ALLOW_CROSS_UID_ACTIVITY_SWITCH_FROM_BELOW,
1892                     allowCrossUidActivitySwitchFromBelow);
1893             proto.end(detailToken);
1894         }
1895         if (!ArrayUtils.isEmpty(mKnownActivityEmbeddingCerts)) {
1896             for (String knownCert : mKnownActivityEmbeddingCerts) {
1897                 proto.write(ApplicationInfoProto.KNOWN_ACTIVITY_EMBEDDING_CERTS, knownCert);
1898             }
1899         }
1900         proto.end(token);
1901     }
1902 
1903     /**
1904      * @return true if "supportsRtl" has been set to true in the AndroidManifest
1905      * @hide
1906      */
1907     @UnsupportedAppUsage
hasRtlSupport()1908     public boolean hasRtlSupport() {
1909         return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1910     }
1911 
1912     /** {@hide} */
hasCode()1913     public boolean hasCode() {
1914         return (flags & FLAG_HAS_CODE) != 0;
1915     }
1916 
1917     public static class DisplayNameComparator
1918             implements Comparator<ApplicationInfo> {
DisplayNameComparator(PackageManager pm)1919         public DisplayNameComparator(PackageManager pm) {
1920             mPM = pm;
1921         }
1922 
compare(ApplicationInfo aa, ApplicationInfo ab)1923         public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1924             CharSequence  sa = mPM.getApplicationLabel(aa);
1925             if (sa == null) {
1926                 sa = aa.packageName;
1927             }
1928             CharSequence  sb = mPM.getApplicationLabel(ab);
1929             if (sb == null) {
1930                 sb = ab.packageName;
1931             }
1932 
1933             return sCollator.compare(sa.toString(), sb.toString());
1934         }
1935 
1936         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
1937         private final Collator   sCollator = Collator.getInstance();
1938         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
1939         private final PackageManager mPM;
1940     }
1941 
ApplicationInfo()1942     public ApplicationInfo() {
1943         createTimestamp = SystemClock.uptimeMillis();
1944     }
1945 
ApplicationInfo(ApplicationInfo orig)1946     public ApplicationInfo(ApplicationInfo orig) {
1947         super(orig);
1948         taskAffinity = orig.taskAffinity;
1949         permission = orig.permission;
1950         mKnownActivityEmbeddingCerts = orig.mKnownActivityEmbeddingCerts;
1951         processName = orig.processName;
1952         className = orig.className;
1953         theme = orig.theme;
1954         flags = orig.flags;
1955         privateFlags = orig.privateFlags;
1956         privateFlagsExt = orig.privateFlagsExt;
1957         requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1958         compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
1959         largestWidthLimitDp = orig.largestWidthLimitDp;
1960         volumeUuid = orig.volumeUuid;
1961         storageUuid = orig.storageUuid;
1962         scanSourceDir = orig.scanSourceDir;
1963         scanPublicSourceDir = orig.scanPublicSourceDir;
1964         sourceDir = orig.sourceDir;
1965         publicSourceDir = orig.publicSourceDir;
1966         splitNames = orig.splitNames;
1967         splitSourceDirs = orig.splitSourceDirs;
1968         splitPublicSourceDirs = orig.splitPublicSourceDirs;
1969         splitDependencies = orig.splitDependencies;
1970         nativeLibraryDir = orig.nativeLibraryDir;
1971         secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
1972         nativeLibraryRootDir = orig.nativeLibraryRootDir;
1973         nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
1974         primaryCpuAbi = orig.primaryCpuAbi;
1975         secondaryCpuAbi = orig.secondaryCpuAbi;
1976         resourceDirs = orig.resourceDirs;
1977         overlayPaths = orig.overlayPaths;
1978         seInfo = orig.seInfo;
1979         seInfoUser = orig.seInfoUser;
1980         sharedLibraryFiles = orig.sharedLibraryFiles;
1981         sharedLibraryInfos = orig.sharedLibraryInfos;
1982         optionalSharedLibraryInfos = orig.optionalSharedLibraryInfos;
1983         dataDir = orig.dataDir;
1984         deviceProtectedDataDir = orig.deviceProtectedDataDir;
1985         credentialProtectedDataDir = orig.credentialProtectedDataDir;
1986         uid = orig.uid;
1987         minSdkVersion = orig.minSdkVersion;
1988         targetSdkVersion = orig.targetSdkVersion;
1989         setVersionCode(orig.longVersionCode);
1990         enabled = orig.enabled;
1991         enabledSetting = orig.enabledSetting;
1992         installLocation = orig.installLocation;
1993         manageSpaceActivityName = orig.manageSpaceActivityName;
1994         descriptionRes = orig.descriptionRes;
1995         uiOptions = orig.uiOptions;
1996         backupAgentName = orig.backupAgentName;
1997         fullBackupContent = orig.fullBackupContent;
1998         dataExtractionRulesRes = orig.dataExtractionRulesRes;
1999         crossProfile = orig.crossProfile;
2000         networkSecurityConfigRes = orig.networkSecurityConfigRes;
2001         category = orig.category;
2002         targetSandboxVersion = orig.targetSandboxVersion;
2003         classLoaderName = orig.classLoaderName;
2004         splitClassLoaderNames = orig.splitClassLoaderNames;
2005         appComponentFactory = orig.appComponentFactory;
2006         iconRes = orig.iconRes;
2007         roundIconRes = orig.roundIconRes;
2008         compileSdkVersion = orig.compileSdkVersion;
2009         compileSdkVersionCodename = orig.compileSdkVersionCodename;
2010         mHiddenApiPolicy = orig.mHiddenApiPolicy;
2011         hiddenUntilInstalled = orig.hiddenUntilInstalled;
2012         zygotePreloadName = orig.zygotePreloadName;
2013         gwpAsanMode = orig.gwpAsanMode;
2014         memtagMode = orig.memtagMode;
2015         nativeHeapZeroInitialized = orig.nativeHeapZeroInitialized;
2016         requestRawExternalStorageAccess = orig.requestRawExternalStorageAccess;
2017         localeConfigRes = orig.localeConfigRes;
2018         allowCrossUidActivitySwitchFromBelow = orig.allowCrossUidActivitySwitchFromBelow;
2019         createTimestamp = SystemClock.uptimeMillis();
2020     }
2021 
toString()2022     public String toString() {
2023         return "ApplicationInfo{"
2024             + Integer.toHexString(System.identityHashCode(this))
2025             + " " + packageName + "}";
2026     }
2027 
describeContents()2028     public int describeContents() {
2029         return 0;
2030     }
2031 
2032     @SuppressWarnings("unchecked")
writeToParcel(Parcel dest, int parcelableFlags)2033     public void writeToParcel(Parcel dest, int parcelableFlags) {
2034         if (dest.maybeWriteSquashed(this)) {
2035             return;
2036         }
2037         super.writeToParcel(dest, parcelableFlags);
2038         dest.writeString8(taskAffinity);
2039         dest.writeString8(permission);
2040         dest.writeString8(processName);
2041         dest.writeString8(className);
2042         dest.writeInt(theme);
2043         dest.writeInt(flags);
2044         dest.writeInt(privateFlags);
2045         dest.writeInt(privateFlagsExt);
2046         dest.writeInt(requiresSmallestWidthDp);
2047         dest.writeInt(compatibleWidthLimitDp);
2048         dest.writeInt(largestWidthLimitDp);
2049         if (storageUuid != null) {
2050             dest.writeInt(1);
2051             dest.writeLong(storageUuid.getMostSignificantBits());
2052             dest.writeLong(storageUuid.getLeastSignificantBits());
2053         } else {
2054             dest.writeInt(0);
2055         }
2056         dest.writeString8(scanSourceDir);
2057         dest.writeString8(scanPublicSourceDir);
2058         dest.writeString8(sourceDir);
2059         dest.writeString8(publicSourceDir);
2060         dest.writeString8Array(splitNames);
2061         dest.writeString8Array(splitSourceDirs);
2062         dest.writeString8Array(splitPublicSourceDirs);
2063         dest.writeSparseArray((SparseArray) splitDependencies);
2064         dest.writeString8(nativeLibraryDir);
2065         dest.writeString8(secondaryNativeLibraryDir);
2066         dest.writeString8(nativeLibraryRootDir);
2067         dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
2068         dest.writeString8(primaryCpuAbi);
2069         dest.writeString8(secondaryCpuAbi);
2070         dest.writeString8Array(resourceDirs);
2071         dest.writeString8Array(overlayPaths);
2072         dest.writeString8(seInfo);
2073         dest.writeString8(seInfoUser);
2074         dest.writeString8Array(sharedLibraryFiles);
2075         dest.writeTypedList(sharedLibraryInfos);
2076         dest.writeTypedList(optionalSharedLibraryInfos);
2077         dest.writeString8(dataDir);
2078         dest.writeString8(deviceProtectedDataDir);
2079         dest.writeString8(credentialProtectedDataDir);
2080         dest.writeInt(uid);
2081         dest.writeInt(minSdkVersion);
2082         dest.writeInt(targetSdkVersion);
2083         dest.writeLong(longVersionCode);
2084         dest.writeInt(enabled ? 1 : 0);
2085         dest.writeInt(enabledSetting);
2086         dest.writeInt(installLocation);
2087         dest.writeString8(manageSpaceActivityName);
2088         dest.writeString8(backupAgentName);
2089         dest.writeInt(descriptionRes);
2090         dest.writeInt(uiOptions);
2091         dest.writeInt(fullBackupContent);
2092         dest.writeInt(dataExtractionRulesRes);
2093         dest.writeBoolean(crossProfile);
2094         dest.writeInt(networkSecurityConfigRes);
2095         dest.writeInt(category);
2096         dest.writeInt(targetSandboxVersion);
2097         dest.writeString8(classLoaderName);
2098         dest.writeString8Array(splitClassLoaderNames);
2099         dest.writeInt(compileSdkVersion);
2100         dest.writeString8(compileSdkVersionCodename);
2101         dest.writeString8(appComponentFactory);
2102         dest.writeInt(iconRes);
2103         dest.writeInt(roundIconRes);
2104         dest.writeInt(mHiddenApiPolicy);
2105         dest.writeInt(hiddenUntilInstalled ? 1 : 0);
2106         dest.writeString8(zygotePreloadName);
2107         dest.writeInt(gwpAsanMode);
2108         dest.writeInt(memtagMode);
2109         dest.writeInt(nativeHeapZeroInitialized);
2110         sForBoolean.parcel(requestRawExternalStorageAccess, dest, parcelableFlags);
2111         dest.writeLong(createTimestamp);
2112         if (mAppClassNamesByProcess == null) {
2113             dest.writeInt(0);
2114         } else {
2115             final int size = mAppClassNamesByProcess.size();
2116             dest.writeInt(size);
2117             for (int i = 0; i < size; i++) {
2118                 dest.writeString(mAppClassNamesByProcess.keyAt(i));
2119                 dest.writeString(mAppClassNamesByProcess.valueAt(i));
2120             }
2121         }
2122         dest.writeInt(localeConfigRes);
2123         dest.writeInt(allowCrossUidActivitySwitchFromBelow ? 1 : 0);
2124 
2125         sForStringSet.parcel(mKnownActivityEmbeddingCerts, dest, flags);
2126     }
2127 
2128     public static final @android.annotation.NonNull Parcelable.Creator<ApplicationInfo> CREATOR
2129             = new Parcelable.Creator<ApplicationInfo>() {
2130         @Override
2131         public ApplicationInfo createFromParcel(Parcel source) {
2132             return source.readSquashed(ApplicationInfo::new);
2133         }
2134 
2135         @Override
2136         public ApplicationInfo[] newArray(int size) {
2137             return new ApplicationInfo[size];
2138         }
2139     };
2140 
2141     @SuppressWarnings("unchecked")
ApplicationInfo(Parcel source)2142     private ApplicationInfo(Parcel source) {
2143         super(source);
2144         taskAffinity = source.readString8();
2145         permission = source.readString8();
2146         processName = source.readString8();
2147         className = source.readString8();
2148         theme = source.readInt();
2149         flags = source.readInt();
2150         privateFlags = source.readInt();
2151         privateFlagsExt = source.readInt();
2152         requiresSmallestWidthDp = source.readInt();
2153         compatibleWidthLimitDp = source.readInt();
2154         largestWidthLimitDp = source.readInt();
2155         if (source.readInt() != 0) {
2156             storageUuid = new UUID(source.readLong(), source.readLong());
2157             volumeUuid = StorageManager.convert(storageUuid);
2158         }
2159         scanSourceDir = source.readString8();
2160         scanPublicSourceDir = source.readString8();
2161         sourceDir = source.readString8();
2162         publicSourceDir = source.readString8();
2163         splitNames = source.createString8Array();
2164         splitSourceDirs = source.createString8Array();
2165         splitPublicSourceDirs = source.createString8Array();
2166         splitDependencies = source.readSparseArray(null, int[].class);
2167         nativeLibraryDir = source.readString8();
2168         secondaryNativeLibraryDir = source.readString8();
2169         nativeLibraryRootDir = source.readString8();
2170         nativeLibraryRootRequiresIsa = source.readInt() != 0;
2171         primaryCpuAbi = source.readString8();
2172         secondaryCpuAbi = source.readString8();
2173         resourceDirs = source.createString8Array();
2174         overlayPaths = source.createString8Array();
2175         seInfo = source.readString8();
2176         seInfoUser = source.readString8();
2177         sharedLibraryFiles = source.createString8Array();
2178         sharedLibraryInfos = source.createTypedArrayList(SharedLibraryInfo.CREATOR);
2179         optionalSharedLibraryInfos = source.createTypedArrayList(SharedLibraryInfo.CREATOR);
2180         dataDir = source.readString8();
2181         deviceProtectedDataDir = source.readString8();
2182         credentialProtectedDataDir = source.readString8();
2183         uid = source.readInt();
2184         minSdkVersion = source.readInt();
2185         targetSdkVersion = source.readInt();
2186         setVersionCode(source.readLong());
2187         enabled = source.readInt() != 0;
2188         enabledSetting = source.readInt();
2189         installLocation = source.readInt();
2190         manageSpaceActivityName = source.readString8();
2191         backupAgentName = source.readString8();
2192         descriptionRes = source.readInt();
2193         uiOptions = source.readInt();
2194         fullBackupContent = source.readInt();
2195         dataExtractionRulesRes = source.readInt();
2196         crossProfile = source.readBoolean();
2197         networkSecurityConfigRes = source.readInt();
2198         category = source.readInt();
2199         targetSandboxVersion = source.readInt();
2200         classLoaderName = source.readString8();
2201         splitClassLoaderNames = source.createString8Array();
2202         compileSdkVersion = source.readInt();
2203         compileSdkVersionCodename = source.readString8();
2204         appComponentFactory = source.readString8();
2205         iconRes = source.readInt();
2206         roundIconRes = source.readInt();
2207         mHiddenApiPolicy = source.readInt();
2208         hiddenUntilInstalled = source.readInt() != 0;
2209         zygotePreloadName = source.readString8();
2210         gwpAsanMode = source.readInt();
2211         memtagMode = source.readInt();
2212         nativeHeapZeroInitialized = source.readInt();
2213         requestRawExternalStorageAccess = sForBoolean.unparcel(source);
2214         createTimestamp = source.readLong();
2215         final int allClassesSize = source.readInt();
2216         if (allClassesSize > 0) {
2217             mAppClassNamesByProcess = new ArrayMap<>(allClassesSize);
2218             for (int i = 0; i < allClassesSize; i++) {
2219                 mAppClassNamesByProcess.put(source.readString(), source.readString());
2220             }
2221         }
2222         localeConfigRes = source.readInt();
2223         allowCrossUidActivitySwitchFromBelow = source.readInt() != 0;
2224 
2225         mKnownActivityEmbeddingCerts = sForStringSet.unparcel(source);
2226         if (mKnownActivityEmbeddingCerts.isEmpty()) {
2227             mKnownActivityEmbeddingCerts = null;
2228         }
2229     }
2230 
2231     /**
2232      * Retrieve the textual description of the application.  This
2233      * will call back on the given PackageManager to load the description from
2234      * the application.
2235      *
2236      * @param pm A PackageManager from which the label can be loaded; usually
2237      * the PackageManager from which you originally retrieved this item.
2238      *
2239      * @return Returns a CharSequence containing the application's description.
2240      * If there is no description, null is returned.
2241      */
2242     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = android.content.res.Resources.class)
loadDescription(PackageManager pm)2243     public CharSequence loadDescription(PackageManager pm) {
2244         if (descriptionRes != 0) {
2245             CharSequence label = pm.getText(packageName, descriptionRes, this);
2246             if (label != null) {
2247                 return label;
2248             }
2249         }
2250         return null;
2251     }
2252 
2253     /**
2254      * Disable compatibility mode
2255      *
2256      * @hide
2257      */
2258     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
disableCompatibilityMode()2259     public void disableCompatibilityMode() {
2260         flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
2261                 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
2262                 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
2263     }
2264 
2265     /**
2266      * Is using compatibility mode for non densty aware legacy applications.
2267      *
2268      * @hide
2269      */
usesCompatibilityMode()2270     public boolean usesCompatibilityMode() {
2271         return targetSdkVersion < DONUT ||
2272                 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
2273                  FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
2274                  FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
2275     }
2276 
2277     /** {@hide} */
2278     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = Environment.class)
initForUser(int userId)2279     public void initForUser(int userId) {
2280         uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
2281 
2282         if ("android".equals(packageName)) {
2283             dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
2284             return;
2285         }
2286 
2287         deviceProtectedDataDir = Environment
2288                 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
2289                 .getAbsolutePath();
2290         credentialProtectedDataDir = Environment
2291                 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
2292                 .getAbsolutePath();
2293 
2294         if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
2295                 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
2296             dataDir = deviceProtectedDataDir;
2297         } else {
2298             dataDir = credentialProtectedDataDir;
2299         }
2300     }
2301 
isPackageWhitelistedForHiddenApis()2302     private boolean isPackageWhitelistedForHiddenApis() {
2303         return (privateFlagsExt & PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS) != 0;
2304     }
2305 
2306     /**
2307      * @hide
2308      */
usesNonSdkApi()2309     public boolean usesNonSdkApi() {
2310         return (privateFlags & PRIVATE_FLAG_USES_NON_SDK_API) != 0;
2311     }
2312 
2313     /**
2314      * Whether an app needs to keep the app data on uninstall.
2315      *
2316      * @return {@code true} if the app indicates that it needs to keep the app data
2317      *
2318      * @hide
2319      */
2320     @SystemApi
2321     @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
hasFragileUserData()2322     public boolean hasFragileUserData() {
2323         return (privateFlags & PRIVATE_FLAG_HAS_FRAGILE_USER_DATA) != 0;
2324     }
2325 
2326     /**
2327      * Whether an app allows its playback audio to be captured by other apps.
2328      *
2329      * @return {@code true} if the app indicates that its audio can be captured by other apps.
2330      *
2331      * @hide
2332      */
isAudioPlaybackCaptureAllowed()2333     public boolean isAudioPlaybackCaptureAllowed() {
2334         return (privateFlags & PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE) != 0;
2335     }
2336 
2337     /**
2338      * If {@code true} this app requested to run in the legacy storage mode.
2339      *
2340      * @hide
2341      */
hasRequestedLegacyExternalStorage()2342     public boolean hasRequestedLegacyExternalStorage() {
2343         return (privateFlags & PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE) != 0;
2344     }
2345 
2346     /**
2347      * Use default value for
2348      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}.
2349      */
2350     public static final int RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT = 0;
2351 
2352     /**
2353      * Raw external storage was requested by this app.
2354      */
2355     public static final int RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED = 1;
2356 
2357     /**
2358      * Raw external storage was not requested by this app.
2359      */
2360     public static final int RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED = 2;
2361 
2362     /**
2363      * These constants need to match the value of
2364      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}.
2365      * in application manifest.
2366      * @hide
2367      */
2368     @IntDef(prefix = {"RAW_EXTERNAL_STORAGE_"}, value = {
2369             RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT,
2370             RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED,
2371             RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED,
2372     })
2373     @Retention(RetentionPolicy.SOURCE)
2374     public @interface RawExternalStorage {}
2375 
2376     /**
2377      * @return
2378      * <ul>
2379      * <li>{@link ApplicationInfo#RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT} if app didn't specify
2380      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}
2381      * attribute in the manifest.
2382      * <li>{@link ApplicationInfo#RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED} if this app requested raw
2383      * external storage access.
2384      * <li>{@link ApplicationInfo#RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED} if this app requests to
2385      * disable raw external storage access
2386      * </ul
2387      * <p>
2388      * Note that this doesn't give any hints on whether the app gets raw external storage access or
2389      * not. Also, apps may get raw external storage access by default in some cases, see
2390      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}.
2391      */
getRequestRawExternalStorageAccess()2392     public @RawExternalStorage int getRequestRawExternalStorageAccess() {
2393         if (requestRawExternalStorageAccess == null) {
2394             return RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT;
2395         }
2396         return requestRawExternalStorageAccess ? RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED
2397                 : RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED;
2398     }
2399 
2400     /**
2401      * If {@code true} this app allows heap pointer tagging.
2402      *
2403      * @hide
2404      */
allowsNativeHeapPointerTagging()2405     public boolean allowsNativeHeapPointerTagging() {
2406         return (privateFlags & PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING) != 0;
2407     }
2408 
isAllowedToUseHiddenApis()2409     private boolean isAllowedToUseHiddenApis() {
2410         if (isSignedWithPlatformKey()) {
2411             return true;
2412         } else if (isSystemApp() || isUpdatedSystemApp()) {
2413             return usesNonSdkApi() || isPackageWhitelistedForHiddenApis();
2414         } else {
2415             return false;
2416         }
2417     }
2418 
2419     /**
2420      * @hide
2421      */
getHiddenApiEnforcementPolicy()2422     public @HiddenApiEnforcementPolicy int getHiddenApiEnforcementPolicy() {
2423         if (isAllowedToUseHiddenApis()) {
2424             return HIDDEN_API_ENFORCEMENT_DISABLED;
2425         }
2426         if (mHiddenApiPolicy != HIDDEN_API_ENFORCEMENT_DEFAULT) {
2427             return mHiddenApiPolicy;
2428         }
2429         return HIDDEN_API_ENFORCEMENT_ENABLED;
2430     }
2431 
2432     /**
2433      * @hide
2434      */
setHiddenApiEnforcementPolicy(@iddenApiEnforcementPolicy int policy)2435     public void setHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
2436         if (!isValidHiddenApiEnforcementPolicy(policy)) {
2437             throw new IllegalArgumentException("Invalid API enforcement policy: " + policy);
2438         }
2439         mHiddenApiPolicy = policy;
2440     }
2441 
2442     /**
2443      * Updates the hidden API enforcement policy for this app from the given values, if appropriate.
2444      *
2445      * This will have no effect if this app is not subject to hidden API enforcement, i.e. if it
2446      * is on the package allowlist.
2447      *
2448      * @param policy configured policy for this app, or {@link #HIDDEN_API_ENFORCEMENT_DEFAULT}
2449      *        if nothing configured.
2450      * @hide
2451      */
maybeUpdateHiddenApiEnforcementPolicy(@iddenApiEnforcementPolicy int policy)2452     public void maybeUpdateHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
2453         if (isPackageWhitelistedForHiddenApis()) {
2454             return;
2455         }
2456         setHiddenApiEnforcementPolicy(policy);
2457     }
2458 
2459     /**
2460      * @hide
2461      */
setVersionCode(long newVersionCode)2462     public void setVersionCode(long newVersionCode) {
2463         longVersionCode = newVersionCode;
2464         versionCode = (int) newVersionCode;
2465     }
2466 
2467     /**
2468      * @hide
2469      */
2470     @Override
2471     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = android.content.res.Resources.class)
loadDefaultIcon(PackageManager pm)2472     public Drawable loadDefaultIcon(PackageManager pm) {
2473         if ((flags & FLAG_EXTERNAL_STORAGE) != 0
2474                 && isPackageUnavailable(pm)) {
2475             return Resources.getSystem().getDrawable(
2476                     com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
2477         }
2478         return pm.getDefaultActivityIcon();
2479     }
2480 
2481     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
2482     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = PackageManager.class)
isPackageUnavailable(PackageManager pm)2483     private boolean isPackageUnavailable(PackageManager pm) {
2484         try {
2485             return pm.getPackageInfo(packageName, 0) == null;
2486         } catch (NameNotFoundException ex) {
2487             return true;
2488         }
2489     }
2490 
2491     /** @hide */
isDefaultToDeviceProtectedStorage()2492     public boolean isDefaultToDeviceProtectedStorage() {
2493         return (privateFlags
2494                 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
2495     }
2496 
2497     /** @hide */
isDirectBootAware()2498     public boolean isDirectBootAware() {
2499         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
2500     }
2501 
2502     /**
2503      * Check whether the application is encryption aware.
2504      *
2505      * @see #isDirectBootAware()
2506      * @see #isPartiallyDirectBootAware()
2507      *
2508      * @hide
2509      */
2510     @SystemApi
isEncryptionAware()2511     public boolean isEncryptionAware() {
2512         return isDirectBootAware() || isPartiallyDirectBootAware();
2513     }
2514 
2515     /** @hide */
isExternal()2516     public boolean isExternal() {
2517         return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
2518     }
2519 
2520     /**
2521      * True if the application is installed as an instant app.
2522      * @hide
2523      */
2524     @SystemApi
isInstantApp()2525     public boolean isInstantApp() {
2526         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
2527     }
2528 
2529     /** @hide */
isInternal()2530     public boolean isInternal() {
2531         return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
2532     }
2533 
2534     /**
2535      * True if the application is pre-installed on the OEM partition of the system image.
2536      * @hide
2537      */
2538     @SystemApi
isOem()2539     public boolean isOem() {
2540         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
2541     }
2542 
2543     /** @hide */
isOdm()2544     public boolean isOdm() {
2545         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ODM) != 0;
2546     }
2547 
2548     /** @hide */
isPartiallyDirectBootAware()2549     public boolean isPartiallyDirectBootAware() {
2550         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
2551     }
2552 
2553     /** @hide */
isSignedWithPlatformKey()2554     public boolean isSignedWithPlatformKey() {
2555         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY) != 0;
2556     }
2557 
2558     /**
2559      * @return {@code true} if the application is permitted to hold privileged permissions.
2560      *
2561      * @hide */
2562     @TestApi
2563     @SystemApi
2564     @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
isPrivilegedApp()2565     public boolean isPrivilegedApp() {
2566         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
2567     }
2568 
2569     /** @hide */
isRequiredForSystemUser()2570     public boolean isRequiredForSystemUser() {
2571         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
2572     }
2573 
2574     /** @hide */
isStaticSharedLibrary()2575     public boolean isStaticSharedLibrary() {
2576         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
2577     }
2578 
2579     /** @hide */
2580     @TestApi
isSystemApp()2581     public boolean isSystemApp() {
2582         return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
2583     }
2584 
2585     /** @hide */
isUpdatedSystemApp()2586     public boolean isUpdatedSystemApp() {
2587         return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
2588     }
2589 
2590     /**
2591      * True if the application is pre-installed on the vendor partition of the system image.
2592      * @hide
2593      */
2594     @SystemApi
isVendor()2595     public boolean isVendor() {
2596         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0;
2597     }
2598 
2599     /**
2600      * True if the application is pre-installed on the product partition of the system image.
2601      * @hide
2602      */
2603     @SystemApi
isProduct()2604     public boolean isProduct() {
2605         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRODUCT) != 0;
2606     }
2607 
2608     /** @hide */
isSystemExt()2609     public boolean isSystemExt() {
2610         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_SYSTEM_EXT) != 0;
2611     }
2612 
2613     /** @hide */
isEmbeddedDexUsed()2614     public boolean isEmbeddedDexUsed() {
2615         return (privateFlags & PRIVATE_FLAG_USE_EMBEDDED_DEX) != 0;
2616     }
2617 
2618     /**
2619      * Returns whether or not this application was installed as a virtual preload.
2620      */
isVirtualPreload()2621     public boolean isVirtualPreload() {
2622         return (privateFlags & PRIVATE_FLAG_VIRTUAL_PRELOAD) != 0;
2623     }
2624 
2625     /**
2626      * Returns whether or not this application can be profiled by the shell user,
2627      * even when running on a device that is running in user mode.
2628      */
isProfileableByShell()2629     public boolean isProfileableByShell() {
2630         return (privateFlags & PRIVATE_FLAG_PROFILEABLE_BY_SHELL) != 0;
2631     }
2632 
2633     /**
2634      * Returns whether this application can be profiled, either by the shell user or the system.
2635      */
isProfileable()2636     public boolean isProfileable() {
2637         return (privateFlagsExt & PRIVATE_FLAG_EXT_PROFILEABLE) != 0;
2638     }
2639 
2640     /**
2641      * Returns whether attributions provided by the application are meant to be user-visible.
2642      * Defaults to false if application info is retrieved without
2643      * {@link PackageManager#GET_ATTRIBUTIONS_LONG}.
2644      */
areAttributionsUserVisible()2645     public boolean areAttributionsUserVisible() {
2646         return (privateFlagsExt & PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE) != 0;
2647     }
2648 
2649     /**
2650      * Returns true if the app has declared in its manifest that it wants its split APKs to be
2651      * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
2652      * @hide
2653      */
requestsIsolatedSplitLoading()2654     public boolean requestsIsolatedSplitLoading() {
2655         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
2656     }
2657 
2658     /**
2659      * Returns true if the package has declared in its manifest that it is a
2660      * runtime resource overlay.
2661      */
isResourceOverlay()2662     public boolean isResourceOverlay() {
2663         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_IS_RESOURCE_OVERLAY) != 0;
2664     }
2665 
2666     /**
2667      * Checks if a changeId is enabled for the current user
2668      * @param changeId The changeId to verify
2669      * @return True of the changeId is enabled
2670      * @hide
2671      */
isChangeEnabled(long changeId)2672     public boolean isChangeEnabled(long changeId) {
2673         return CompatChanges.isChangeEnabled(changeId, packageName,
2674                 UserHandle.getUserHandleForUid(uid));
2675     }
2676 
2677     /**
2678      * @return whether the app has requested exemption from the foreground service restrictions.
2679      * This does not take any affect for now.
2680      * @hide
2681      */
2682     @TestApi
hasRequestForegroundServiceExemption()2683     public boolean hasRequestForegroundServiceExemption() {
2684         return (privateFlagsExt
2685                 & ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION) != 0;
2686     }
2687 
2688     /**
2689      * Returns whether the application will use the {@link android.window.OnBackInvokedCallback}
2690      * navigation system instead of the {@link android.view.KeyEvent#KEYCODE_BACK} and related
2691      * callbacks.
2692      *
2693      * @hide
2694      */
2695     @TestApi
isOnBackInvokedCallbackEnabled()2696     public boolean isOnBackInvokedCallbackEnabled() {
2697         return ((privateFlagsExt & PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK)) != 0;
2698     }
2699 
2700     /**
2701      * @hide
2702      */
getApplicationInfo()2703     @Override public ApplicationInfo getApplicationInfo() {
2704         return this;
2705     }
2706 
2707     /**
2708      * Return all the APK paths that may be required to load this application, including all
2709      * splits, shared libraries, and resource overlays.
2710      * @hide
2711      */
getAllApkPaths()2712     public String[] getAllApkPaths() {
2713         final String[][] inputLists = {
2714                 splitSourceDirs, sharedLibraryFiles, resourceDirs, overlayPaths
2715         };
2716         final List<String> output = new ArrayList<>(10);
2717         if (sourceDir != null) {
2718             output.add(sourceDir);
2719         }
2720         for (String[] inputList : inputLists) {
2721             if (inputList != null) {
2722                 for (String input : inputList) {
2723                     output.add(input);
2724                 }
2725             }
2726         }
2727         return output.toArray(new String[output.size()]);
2728     }
2729 
setCodePath(String codePath)2730     /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
setBaseCodePath(String baseCodePath)2731     /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
setSplitCodePaths(String[] splitCodePaths)2732     /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
setResourcePath(String resourcePath)2733     /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
setBaseResourcePath(String baseResourcePath)2734     /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
setSplitResourcePaths(String[] splitResourcePaths)2735     /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
setGwpAsanMode(@wpAsanMode int value)2736     /** {@hide} */ public void setGwpAsanMode(@GwpAsanMode int value) { gwpAsanMode = value; }
setMemtagMode(@emtagMode int value)2737     /** {@hide} */ public void setMemtagMode(@MemtagMode int value) { memtagMode = value; }
setNativeHeapZeroInitialized(@ativeHeapZeroInitialized int value)2738     /** {@hide} */ public void setNativeHeapZeroInitialized(@NativeHeapZeroInitialized int value) {
2739         nativeHeapZeroInitialized = value;
2740     }
2741     /** {@hide} */
setRequestRawExternalStorageAccess(@ullable Boolean value)2742     public void setRequestRawExternalStorageAccess(@Nullable Boolean value) {
2743         requestRawExternalStorageAccess = value;
2744     }
2745 
2746     /**
2747      * Replaces {@link #mAppClassNamesByProcess}. This takes over the ownership of the passed map.
2748      * Do not modify the argument at the callsite.
2749      * {@hide}
2750      */
setAppClassNamesByProcess(@ullable ArrayMap<String, String> value)2751     public void setAppClassNamesByProcess(@Nullable ArrayMap<String, String> value) {
2752         if (ArrayUtils.size(value) == 0) {
2753             mAppClassNamesByProcess = null;
2754         } else {
2755             mAppClassNamesByProcess = value;
2756         }
2757     }
2758 
2759     /** {@hide} */
2760     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
getCodePath()2761     public String getCodePath() { return scanSourceDir; }
getBaseCodePath()2762     /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
getSplitCodePaths()2763     /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
getResourcePath()2764     /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
2765     /** {@hide} */
2766     @UnsupportedAppUsage
getBaseResourcePath()2767     public String getBaseResourcePath() { return publicSourceDir; }
getSplitResourcePaths()2768     /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
2769     @GwpAsanMode
getGwpAsanMode()2770     public int getGwpAsanMode() { return gwpAsanMode; }
2771 
2772     /**
2773      * Returns whether the application has requested Memtag to be enabled, disabled, or left
2774      * unspecified. Processes can override this setting.
2775      */
2776     @MemtagMode
getMemtagMode()2777     public int getMemtagMode() {
2778         return memtagMode;
2779     }
2780 
2781     /**
2782      * Returns whether the application has requested automatic zero-initialization of native heap
2783      * memory allocations to be enabled or disabled.
2784      */
2785     @NativeHeapZeroInitialized
getNativeHeapZeroInitialized()2786     public int getNativeHeapZeroInitialized() {
2787         return nativeHeapZeroInitialized;
2788     }
2789 
2790     /**
2791      * Return the application class name defined in the manifest. The class name set in the
2792      * <processes> tag for this process, then return it. Otherwise it'll return the class
2793      * name set in the <application> tag. If neither is set, it'll return null.
2794      * @hide
2795      */
2796     @Nullable
getCustomApplicationClassNameForProcess(String processName)2797     public String getCustomApplicationClassNameForProcess(String processName) {
2798         if (mAppClassNamesByProcess != null) {
2799             String byProcess = mAppClassNamesByProcess.get(processName);
2800             if (byProcess != null) {
2801                 return byProcess;
2802             }
2803         }
2804         return className;
2805     }
2806 
setLocaleConfigRes(int value)2807     /** @hide */ public void setLocaleConfigRes(int value) { localeConfigRes = value; }
2808 
2809     /**
2810      * Return the resource id pointing to the resource file that provides the application's locales
2811      * configuration.
2812      *
2813      * @hide
2814      */
getLocaleConfigRes()2815     public int getLocaleConfigRes() {
2816         return localeConfigRes;
2817     }
2818 
2819     /**
2820      *  List of all shared libraries this application is linked against. This
2821      *  list will only be set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
2822      *  PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving the structure.
2823      *
2824      *  NOTE: the list also contains the result of {@link #getOptionalSharedLibraryInfos}.
2825      *
2826      * @hide
2827      */
2828     @NonNull
2829     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
getSharedLibraryInfos()2830     public List<SharedLibraryInfo> getSharedLibraryInfos() {
2831         if (sharedLibraryInfos == null) {
2832             return Collections.EMPTY_LIST;
2833         }
2834         return sharedLibraryInfos;
2835     }
2836 
2837     /**
2838      *  List of all shared libraries this application is optionally linked against. This
2839      *  list will only be set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
2840      *  PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving the structure.
2841      *
2842      * @hide
2843      */
2844     @NonNull
2845     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
2846     @FlaggedApi(Flags.FLAG_SDK_LIB_INDEPENDENCE)
getOptionalSharedLibraryInfos()2847     public List<SharedLibraryInfo> getOptionalSharedLibraryInfos() {
2848         if (optionalSharedLibraryInfos == null) {
2849             return Collections.EMPTY_LIST;
2850         }
2851         return optionalSharedLibraryInfos;
2852     }
2853 
2854     /**
2855      * Gets the trusted host certificate digests of apps that are allowed to embed activities of
2856      * this application. The digests are computed using the SHA-256 digest algorithm.
2857      * @see android.R.attr#knownActivityEmbeddingCerts
2858      */
2859     @NonNull
getKnownActivityEmbeddingCerts()2860     public Set<String> getKnownActivityEmbeddingCerts() {
2861         return mKnownActivityEmbeddingCerts == null ? Collections.emptySet()
2862                 : mKnownActivityEmbeddingCerts;
2863     }
2864 
2865     /**
2866      * Sets the trusted host certificates of apps that are allowed to embed activities of this
2867      * application.
2868      * @see #getKnownActivityEmbeddingCerts()
2869      * @hide
2870      */
setKnownActivityEmbeddingCerts(@onNull Set<String> knownActivityEmbeddingCerts)2871     public void setKnownActivityEmbeddingCerts(@NonNull Set<String> knownActivityEmbeddingCerts) {
2872         // Convert the provided digest to upper case for consistent Set membership
2873         // checks when verifying the signing certificate digests of requesting apps.
2874         mKnownActivityEmbeddingCerts = new ArraySet<>();
2875         for (String knownCert : knownActivityEmbeddingCerts) {
2876             mKnownActivityEmbeddingCerts.add(knownCert.toUpperCase(Locale.US));
2877         }
2878     }
2879 
2880     /**
2881      * Sets whether the application will use the {@link android.window.OnBackInvokedCallback}
2882      * navigation system instead of the {@link android.view.KeyEvent#KEYCODE_BACK} and related
2883      * callbacks. Intended to be used from tests only.
2884      *
2885      * @see #isOnBackInvokedCallbackEnabled()
2886      * @hide
2887      */
2888     @TestApi
setEnableOnBackInvokedCallback(boolean isEnable)2889     public void setEnableOnBackInvokedCallback(boolean isEnable) {
2890         if (isEnable) {
2891             privateFlagsExt |= PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK;
2892         } else {
2893             privateFlagsExt &= ~PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK;
2894         }
2895     }
2896 }
2897