• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     /**
853      * Whether the app has been previously not launched
854      * @hide
855      */
856     public static final int PRIVATE_FLAG_EXT_NOT_LAUNCHED = 1 << 6;
857 
858     /** @hide */
859     @IntDef(flag = true, prefix = { "PRIVATE_FLAG_EXT_" }, value = {
860             PRIVATE_FLAG_EXT_PROFILEABLE,
861             PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION,
862             PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE,
863             PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK,
864             PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS,
865             PRIVATE_FLAG_EXT_CPU_OVERRIDE,
866             PRIVATE_FLAG_EXT_NOT_LAUNCHED,
867     })
868     @Retention(RetentionPolicy.SOURCE)
869     public @interface ApplicationInfoPrivateFlagsExt {}
870     /**
871      * Constant corresponding to <code>allowed</code> in the
872      * {@link android.R.attr#autoRevokePermissions} attribute.
873      *
874      * @hide
875      */
876     public static final int AUTO_REVOKE_ALLOWED = 0;
877 
878     /**
879      * Constant corresponding to <code>discouraged</code> in the
880      * {@link android.R.attr#autoRevokePermissions} attribute.
881      *
882      * @hide
883      */
884     public static final int AUTO_REVOKE_DISCOURAGED = 1;
885 
886     /**
887      * Constant corresponding to <code>disallowed</code> in the
888      * {@link android.R.attr#autoRevokePermissions} attribute.
889      *
890      * @hide
891      */
892     public static final int AUTO_REVOKE_DISALLOWED = 2;
893 
894     /**
895      * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
896      * @hide
897      */
898     @UnsupportedAppUsage
899     @TestApi
900     public @ApplicationInfoPrivateFlags int privateFlags;
901 
902     /**
903      * More private/hidden flags. See {@code PRIVATE_FLAG_EXT_...} constants.
904      * @hide
905      */
906     public @ApplicationInfoPrivateFlagsExt int privateFlagsExt;
907 
908     /**
909      * @hide
910      */
911     public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
912 
913     /**
914      * The required smallest screen width the application can run on.  If 0,
915      * nothing has been specified.  Comes from
916      * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
917      * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
918      */
919     public int requiresSmallestWidthDp = 0;
920 
921     /**
922      * The maximum smallest screen width the application is designed for.  If 0,
923      * nothing has been specified.  Comes from
924      * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
925      * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
926      */
927     public int compatibleWidthLimitDp = 0;
928 
929     /**
930      * The maximum smallest screen width the application will work on.  If 0,
931      * nothing has been specified.  Comes from
932      * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
933      * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
934      */
935     public int largestWidthLimitDp = 0;
936 
937     /**
938      * Value indicating the maximum aspect ratio the application supports.
939      * <p>
940      * 0 means unset.
941      * @See {@link android.R.attr#maxAspectRatio}.
942      * @hide
943      */
944     public float maxAspectRatio;
945 
946     /**
947      * Value indicating the minimum aspect ratio the application supports.
948      * <p>
949      * 0 means unset.
950      * @see {@link android.R.attr#minAspectRatio}.
951      * @hide
952      */
953     public float minAspectRatio;
954 
955     /** @hide */
956     public String volumeUuid;
957 
958     /**
959      * UUID of the storage volume on which this application is being hosted. For
960      * apps hosted on the default internal storage at
961      * {@link Environment#getDataDirectory()}, the UUID value is
962      * {@link StorageManager#UUID_DEFAULT}.
963      */
964     public UUID storageUuid;
965 
966     /** {@hide} */
967     @UnsupportedAppUsage
968     public String scanSourceDir;
969     /** {@hide} */
970     @UnsupportedAppUsage
971     public String scanPublicSourceDir;
972 
973     /**
974      * Full path to the base APK for this application.
975      */
976     public String sourceDir;
977 
978     /**
979      * Full path to the publicly available parts of {@link #sourceDir},
980      * including resources and manifest. This may be different from
981      * {@link #sourceDir} if an application is forward locked.
982      */
983     public String publicSourceDir;
984 
985     /**
986      * The names of all installed split APKs, ordered lexicographically.
987      * May be null if no splits are installed.
988      */
989     @Nullable
990     public String[] splitNames;
991 
992     /**
993      * Full paths to split APKs, indexed by the same order as {@link #splitNames}.
994      * May be null if no splits are installed.
995      */
996     @Nullable
997     public String[] splitSourceDirs;
998 
999     /**
1000      * Full path to the publicly available parts of {@link #splitSourceDirs},
1001      * including resources and manifest. This may be different from
1002      * {@link #splitSourceDirs} if an application is forward locked.
1003      * May be null if no splits are installed.
1004      *
1005      * @see #splitSourceDirs
1006      */
1007     @Nullable
1008     public String[] splitPublicSourceDirs;
1009 
1010     /**
1011      * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
1012      *
1013      * Available since platform version O.
1014      *
1015      * Only populated if the application opts in to isolated split loading via the
1016      * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
1017      * AndroidManifest.xml.
1018      *
1019      * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
1020      * and {@link #splitPublicSourceDirs} arrays.
1021      * Each key represents a split and its value is an array of splits. The first element of this
1022      * array is the parent split, and the rest are configuration splits. These configuration splits
1023      * have no dependencies themselves.
1024      * Cycles do not exist because they are illegal and screened for during installation.
1025      *
1026      * May be null if no splits are installed, or if no dependencies exist between them.
1027      *
1028      * NOTE: Any change to the way split dependencies are stored must update the logic that
1029      *       creates the class loader context for dexopt (DexoptUtils#getClassLoaderContexts).
1030      *
1031      * @hide
1032      */
1033     public SparseArray<int[]> splitDependencies;
1034 
1035     /**
1036      * Full paths to the locations of extra resource packages (runtime overlays)
1037      * this application uses. This field is only used if there are extra resource
1038      * packages, otherwise it is null.
1039      *
1040      * {@hide}
1041      */
1042     @UnsupportedAppUsage
1043     public String[] resourceDirs;
1044 
1045     /**
1046      * Contains the contents of {@link #resourceDirs} and along with paths for overlays that may or
1047      * may not be APK packages.
1048      *
1049      * {@hide}
1050      */
1051     public String[] overlayPaths;
1052 
1053     /**
1054      * String retrieved from the seinfo tag found in selinux policy. This value can be set through
1055      * the mac_permissions.xml policy construct. This value is used for setting an SELinux security
1056      * context on the process as well as its data directory.
1057      *
1058      * {@hide}
1059      */
1060     public String seInfo;
1061 
1062     /**
1063      * The seinfo tag generated per-user. This value may change based upon the
1064      * user's configuration. For example, when an instant app is installed for
1065      * a user. It is an error if this field is ever {@code null} when trying to
1066      * start a new process.
1067      * <p>NOTE: We need to separate this out because we modify per-user values
1068      * multiple times. This needs to be refactored since we're performing more
1069      * work than necessary and these values should only be set once. When that
1070      * happens, we can merge the per-user value with the seInfo state above.
1071      *
1072      * {@hide}
1073      */
1074     public String seInfoUser;
1075 
1076     /**
1077      * Paths to all shared libraries this application is linked against.  This
1078      * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
1079      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
1080      * the structure.
1081      */
1082     public String[] sharedLibraryFiles;
1083 
1084     /**
1085      * List of all shared libraries this application is linked against.  This
1086      * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
1087      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
1088      * the structure.
1089      *
1090      * NOTE: the list also contains the result of {@link #getOptionalSharedLibraryInfos}.
1091      *
1092      * {@hide}
1093      */
1094     @Nullable
1095     public List<SharedLibraryInfo> sharedLibraryInfos;
1096 
1097     /**
1098      * List of all shared libraries this application is optionally linked against.
1099      * This field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
1100      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
1101      * the structure.
1102      *
1103      * @hide
1104      */
1105     @Nullable
1106     public List<SharedLibraryInfo> optionalSharedLibraryInfos;
1107 
1108     /**
1109      * Full path to the default directory assigned to the package for its
1110      * persistent data.
1111      */
1112     public String dataDir;
1113 
1114     /**
1115      * Full path to the device-protected directory assigned to the package for
1116      * its persistent data.
1117      *
1118      * @see Context#createDeviceProtectedStorageContext()
1119      */
1120     public String deviceProtectedDataDir;
1121 
1122     /**
1123      * Full path to the credential-protected directory assigned to the package
1124      * for its persistent data.
1125      *
1126      * @hide
1127      */
1128     @SystemApi
1129     public String credentialProtectedDataDir;
1130 
1131     /**
1132      * Full path to the directory where native JNI libraries are stored.
1133      */
1134     public String nativeLibraryDir;
1135 
1136     /**
1137      * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
1138      * are stored, if present.
1139      *
1140      * The main reason this exists is for bundled multi-arch apps, where
1141      * it's not trivial to calculate the location of libs for the secondary abi
1142      * given the location of the primary.
1143      *
1144      * TODO: Change the layout of bundled installs so that we can use
1145      * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
1146      * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
1147      * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
1148      *
1149      * @hide
1150      */
1151     @UnsupportedAppUsage
1152     public String secondaryNativeLibraryDir;
1153 
1154     /**
1155      * The root path where unpacked native libraries are stored.
1156      * <p>
1157      * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
1158      * placed in ISA-specific subdirectories under this path, otherwise the
1159      * libraries are placed directly at this path.
1160      *
1161      * @hide
1162      */
1163     @UnsupportedAppUsage
1164     public String nativeLibraryRootDir;
1165 
1166     /**
1167      * Flag indicating that ISA must be appended to
1168      * {@link #nativeLibraryRootDir} to be useful.
1169      *
1170      * @hide
1171      */
1172     public boolean nativeLibraryRootRequiresIsa;
1173 
1174     /**
1175      * The primary ABI that this application requires, This is inferred from the ABIs
1176      * of the native JNI libraries the application bundles. Will be {@code null}
1177      * if this application does not require any particular ABI.
1178      *
1179      * If non-null, the application will always be launched with this ABI.
1180      *
1181      * {@hide}
1182      */
1183     @UnsupportedAppUsage
1184     public String primaryCpuAbi;
1185 
1186     /**
1187      * The secondary ABI for this application. Might be non-null for multi-arch
1188      * installs. The application itself never uses this ABI, but other applications that
1189      * use its code might.
1190      *
1191      * {@hide}
1192      */
1193     @UnsupportedAppUsage
1194     public String secondaryCpuAbi;
1195 
1196     /**
1197      * The kernel user-ID that has been assigned to this application;
1198      * currently this is not a unique ID (multiple applications can have
1199      * the same uid).
1200      */
1201     public int uid;
1202 
1203     /**
1204      * The minimum SDK version this application can run on. It will not run
1205      * on earlier versions.
1206      */
1207     public int minSdkVersion;
1208 
1209     /**
1210      * The minimum SDK version this application targets.  It may run on earlier
1211      * versions, but it knows how to work with any new behavior added at this
1212      * version.  Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
1213      * if this is a development build and the app is targeting that.  You should
1214      * compare that this number is >= the SDK version number at which your
1215      * behavior was introduced.
1216      */
1217     public int targetSdkVersion;
1218 
1219     /**
1220      * The app's declared version code.
1221      * @hide
1222      */
1223     public long longVersionCode;
1224 
1225     /**
1226      * An integer representation of the app's declared version code. This is being left in place as
1227      * some apps were using reflection to access it before the move to long in
1228      * {@link android.os.Build.VERSION_CODES#P}
1229      * @deprecated Use {@link #longVersionCode} instead.
1230      * @hide
1231      */
1232     @Deprecated
1233     @UnsupportedAppUsage
1234     public int versionCode;
1235 
1236     /**
1237      * The timestamp of when this ApplicationInfo was created.
1238      * @hide
1239      */
1240     public long createTimestamp;
1241 
1242     /**
1243      * The user-visible SDK version (ex. 26) of the framework against which the application claims
1244      * to have been compiled, or {@code 0} if not specified.
1245      * <p>
1246      * This property is the compile-time equivalent of
1247      * {@link android.os.Build.VERSION#CODENAME Build.VERSION.SDK_INT}.
1248      */
1249     public int compileSdkVersion;
1250 
1251     /**
1252      * The development codename (ex. "S", "REL") of the framework against which the application
1253      * claims to have been compiled, or {@code null} if not specified.
1254      * <p>
1255      * This property is the compile-time equivalent of
1256      * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
1257      */
1258     @Nullable
1259     public String compileSdkVersionCodename;
1260 
1261     /**
1262      * When false, indicates that all components within this application are
1263      * considered disabled, regardless of their individually set enabled status.
1264      */
1265     public boolean enabled = true;
1266 
1267     /**
1268      * For convenient access to the current enabled setting of this app.
1269      * @hide
1270      */
1271     @UnsupportedAppUsage
1272     public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
1273 
1274     /**
1275      * For convenient access to package's install location.
1276      * @hide
1277      */
1278     @UnsupportedAppUsage
1279     public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
1280 
1281     /**
1282      * Resource file providing the application's Network Security Config.
1283      * @hide
1284      */
1285     public int networkSecurityConfigRes;
1286 
1287     /**
1288      * Version of the sandbox the application wants to run in.
1289      * @hide
1290      */
1291     @SystemApi
1292     public int targetSandboxVersion;
1293 
1294     /**
1295      * The factory of this package, as specified by the &lt;manifest&gt;
1296      * tag's {@link android.R.styleable#AndroidManifestApplication_appComponentFactory}
1297      * attribute.
1298      */
1299     public String appComponentFactory;
1300 
1301     /**
1302      * Resource id of {@link com.android.internal.R.styleable.AndroidManifestProvider_icon}
1303      * @hide
1304      */
1305     public int iconRes;
1306 
1307     /**
1308      * Resource id of {@link com.android.internal.R.styleable.AndroidManifestProvider_roundIcon}
1309      * @hide
1310      */
1311     public int roundIconRes;
1312 
1313     /**
1314      * The category of this app. Categories are used to cluster multiple apps
1315      * together into meaningful groups, such as when summarizing battery,
1316      * network, or disk usage. Apps should only define this value when they fit
1317      * well into one of the specific categories.
1318      * <p>
1319      * Set from the {@link android.R.attr#appCategory} attribute in the
1320      * manifest. If the manifest doesn't define a category, this value may have
1321      * been provided by the installer via
1322      * {@link PackageManager#setApplicationCategoryHint(String, int)}.
1323      */
1324     public @Category int category = CATEGORY_UNDEFINED;
1325 
1326     /** {@hide} */
1327     @IntDef(prefix = { "CATEGORY_" }, value = {
1328             CATEGORY_UNDEFINED,
1329             CATEGORY_GAME,
1330             CATEGORY_AUDIO,
1331             CATEGORY_VIDEO,
1332             CATEGORY_IMAGE,
1333             CATEGORY_SOCIAL,
1334             CATEGORY_NEWS,
1335             CATEGORY_MAPS,
1336             CATEGORY_PRODUCTIVITY,
1337             CATEGORY_ACCESSIBILITY
1338     })
1339     @Retention(RetentionPolicy.SOURCE)
1340     public @interface Category {
1341     }
1342 
1343     /**
1344      * Value when category is undefined.
1345      *
1346      * @see #category
1347      */
1348     public static final int CATEGORY_UNDEFINED = -1;
1349 
1350     /**
1351      * Category for apps which are primarily games.
1352      *
1353      * @see #category
1354      */
1355     public static final int CATEGORY_GAME = 0;
1356 
1357     /**
1358      * Category for apps which primarily work with audio or music, such as music
1359      * players.
1360      *
1361      * @see #category
1362      */
1363     public static final int CATEGORY_AUDIO = 1;
1364 
1365     /**
1366      * Category for apps which primarily work with video or movies, such as
1367      * streaming video apps.
1368      *
1369      * @see #category
1370      */
1371     public static final int CATEGORY_VIDEO = 2;
1372 
1373     /**
1374      * Category for apps which primarily work with images or photos, such as
1375      * camera or gallery apps.
1376      *
1377      * @see #category
1378      */
1379     public static final int CATEGORY_IMAGE = 3;
1380 
1381     /**
1382      * Category for apps which are primarily social apps, such as messaging,
1383      * communication, email, or social network apps.
1384      *
1385      * @see #category
1386      */
1387     public static final int CATEGORY_SOCIAL = 4;
1388 
1389     /**
1390      * Category for apps which are primarily news apps, such as newspapers,
1391      * magazines, or sports apps.
1392      *
1393      * @see #category
1394      */
1395     public static final int CATEGORY_NEWS = 5;
1396 
1397     /**
1398      * Category for apps which are primarily maps apps, such as navigation apps.
1399      *
1400      * @see #category
1401      */
1402     public static final int CATEGORY_MAPS = 6;
1403 
1404     /**
1405      * Category for apps which are primarily productivity apps, such as cloud
1406      * storage or workplace apps.
1407      *
1408      * @see #category
1409      */
1410     public static final int CATEGORY_PRODUCTIVITY = 7;
1411 
1412     /**
1413      * Category for apps which are primarily accessibility apps, such as screen-readers.
1414      *
1415      * @see #category
1416      */
1417     public static final int CATEGORY_ACCESSIBILITY = 8;
1418 
1419     /**
1420      * Return a concise, localized title for the given
1421      * {@link ApplicationInfo#category} value, or {@code null} for unknown
1422      * values such as {@link #CATEGORY_UNDEFINED}.
1423      *
1424      * @see #category
1425      */
1426     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = android.content.res.Resources.class)
getCategoryTitle(Context context, @Category int category)1427     public static CharSequence getCategoryTitle(Context context, @Category int category) {
1428         switch (category) {
1429             case ApplicationInfo.CATEGORY_GAME:
1430                 return context.getText(com.android.internal.R.string.app_category_game);
1431             case ApplicationInfo.CATEGORY_AUDIO:
1432                 return context.getText(com.android.internal.R.string.app_category_audio);
1433             case ApplicationInfo.CATEGORY_VIDEO:
1434                 return context.getText(com.android.internal.R.string.app_category_video);
1435             case ApplicationInfo.CATEGORY_IMAGE:
1436                 return context.getText(com.android.internal.R.string.app_category_image);
1437             case ApplicationInfo.CATEGORY_SOCIAL:
1438                 return context.getText(com.android.internal.R.string.app_category_social);
1439             case ApplicationInfo.CATEGORY_NEWS:
1440                 return context.getText(com.android.internal.R.string.app_category_news);
1441             case ApplicationInfo.CATEGORY_MAPS:
1442                 return context.getText(com.android.internal.R.string.app_category_maps);
1443             case ApplicationInfo.CATEGORY_PRODUCTIVITY:
1444                 return context.getText(com.android.internal.R.string.app_category_productivity);
1445             case ApplicationInfo.CATEGORY_ACCESSIBILITY:
1446                 return context.getText(com.android.internal.R.string.app_category_accessibility);
1447             default:
1448                 return null;
1449         }
1450     }
1451 
1452     /**
1453      * Use this to report any errors during alignment checks
1454      *
1455      * @hide
1456      */
1457     public static final int PAGE_SIZE_APP_COMPAT_FLAG_ERROR = -1;
1458 
1459     /**
1460      * Initial value for mPageSizeAppCompatFlags
1461      *
1462      * @hide
1463      */
1464     public static final int PAGE_SIZE_APP_COMPAT_FLAG_UNDEFINED = 0;
1465 
1466     /**
1467      * if set, extract libs forcefully for 16 KB device and show warning dialog.
1468      *
1469      * @hide
1470      */
1471     public static final int PAGE_SIZE_APP_COMPAT_FLAG_UNCOMPRESSED_LIBS_NOT_ALIGNED = 1 << 1;
1472 
1473     /**
1474      * if set, load 4 KB aligned ELFs on 16 KB device in compat mode and show warning dialog.
1475      *
1476      * @hide
1477      */
1478     public static final int PAGE_SIZE_APP_COMPAT_FLAG_ELF_NOT_ALIGNED = 1 << 2;
1479 
1480     /**
1481      * Run in 16 KB app compat mode. This flag will be set explicitly through settings. If set, 16
1482      * KB app compat warning dialogs will still show up.
1483      *
1484      * @hide
1485      */
1486     public static final int PAGE_SIZE_APP_COMPAT_FLAG_SETTINGS_OVERRIDE_ENABLED = 1 << 3;
1487 
1488     /**
1489      * Disable 16 KB app compat mode through settings. It should only affect ELF loading as app is
1490      * already installed.
1491      *
1492      * @hide
1493      */
1494     public static final int PAGE_SIZE_APP_COMPAT_FLAG_SETTINGS_OVERRIDE_DISABLED = 1 << 4;
1495 
1496     /**
1497      * Run in 16 KB app compat mode. This flag will be set explicitly through manifest. If set, hide
1498      * the 16 KB app compat warning dialogs. This has the highest priority to enable compat mode.
1499      *
1500      * @hide
1501      */
1502     public static final int PAGE_SIZE_APP_COMPAT_FLAG_MANIFEST_OVERRIDE_ENABLED = 1 << 5;
1503 
1504     /**
1505      * Disable 16 KB app compat mode. This has the highest priority to disable compat mode.
1506      *
1507      * @hide
1508      */
1509     public static final int PAGE_SIZE_APP_COMPAT_FLAG_MANIFEST_OVERRIDE_DISABLED = 1 << 6;
1510 
1511     /**
1512      * Max value for page size app compat
1513      *
1514      * @hide
1515      */
1516     public static final int PAGE_SIZE_APP_COMPAT_FLAG_MAX = 1 << 7;
1517 
1518     /**
1519      * 16 KB app compat status for the app. App can have native shared libs which are not page
1520      * aligned, LOAD segments inside the shared libs have to be page aligned. Apps can specify the
1521      * override in manifest file as well.
1522      */
1523     private @PageSizeAppCompatFlags int mPageSizeAppCompatFlags =
1524             ApplicationInfo.PAGE_SIZE_APP_COMPAT_FLAG_UNDEFINED;
1525 
1526     /** {@hide} */
1527     @IntDef(
1528             prefix = {"PAGE_SIZE_APP_COMPAT_FLAG_"},
1529             value = {
1530                 PAGE_SIZE_APP_COMPAT_FLAG_ERROR,
1531                 PAGE_SIZE_APP_COMPAT_FLAG_UNDEFINED,
1532                 PAGE_SIZE_APP_COMPAT_FLAG_UNCOMPRESSED_LIBS_NOT_ALIGNED,
1533                 PAGE_SIZE_APP_COMPAT_FLAG_ELF_NOT_ALIGNED,
1534                 PAGE_SIZE_APP_COMPAT_FLAG_MANIFEST_OVERRIDE_ENABLED,
1535                 PAGE_SIZE_APP_COMPAT_FLAG_MANIFEST_OVERRIDE_DISABLED,
1536                 PAGE_SIZE_APP_COMPAT_FLAG_SETTINGS_OVERRIDE_ENABLED,
1537                 PAGE_SIZE_APP_COMPAT_FLAG_SETTINGS_OVERRIDE_DISABLED,
1538                 PAGE_SIZE_APP_COMPAT_FLAG_MAX,
1539             })
1540     @Retention(RetentionPolicy.SOURCE)
1541     public @interface PageSizeAppCompatFlags {}
1542 
1543     /** @hide */
1544     public String classLoaderName;
1545 
1546     /** @hide */
1547     public String[] splitClassLoaderNames;
1548 
1549     /** @hide */
1550     public boolean hiddenUntilInstalled;
1551 
1552     /** @hide */
1553     public String zygotePreloadName;
1554 
1555     /**
1556      * Default (unspecified) setting of GWP-ASan.
1557      */
1558     public static final int GWP_ASAN_DEFAULT = -1;
1559 
1560     /**
1561      * Never enable GWP-ASan in this application or process.
1562      */
1563     public static final int GWP_ASAN_NEVER = 0;
1564 
1565     /**
1566      * Always enable GWP-ASan in this application or process.
1567      */
1568     public static final int GWP_ASAN_ALWAYS = 1;
1569 
1570     /**
1571      * These constants need to match the values of gwpAsanMode in application manifest.
1572      * @hide
1573      */
1574     @IntDef(prefix = {"GWP_ASAN_"}, value = {
1575             GWP_ASAN_DEFAULT,
1576             GWP_ASAN_NEVER,
1577             GWP_ASAN_ALWAYS,
1578     })
1579     @Retention(RetentionPolicy.SOURCE)
1580     public @interface GwpAsanMode {}
1581 
1582     /**
1583      * Indicates if the application has requested GWP-ASan to be enabled, disabled, or left
1584      * unspecified. Processes can override this setting.
1585      */
1586     private @GwpAsanMode int gwpAsanMode = GWP_ASAN_DEFAULT;
1587 
1588     /**
1589      * Default (unspecified) setting of Memtag.
1590      */
1591     public static final int MEMTAG_DEFAULT = -1;
1592 
1593     /**
1594      * Do not enable Memtag in this application or process.
1595      */
1596     public static final int MEMTAG_OFF = 0;
1597 
1598     /**
1599      * Enable Memtag in Async mode in this application or process.
1600      */
1601     public static final int MEMTAG_ASYNC = 1;
1602 
1603     /**
1604      * Enable Memtag in Sync mode in this application or process.
1605      */
1606     public static final int MEMTAG_SYNC = 2;
1607 
1608     /**
1609      * These constants need to match the values of memtagMode in application manifest.
1610      * @hide
1611      */
1612     @IntDef(prefix = {"MEMTAG_"}, value = {
1613             MEMTAG_DEFAULT,
1614             MEMTAG_OFF,
1615             MEMTAG_ASYNC,
1616             MEMTAG_SYNC,
1617     })
1618     @Retention(RetentionPolicy.SOURCE)
1619     public @interface MemtagMode {}
1620 
1621     /**
1622      * Indicates if the application has requested Memtag to be enabled, disabled, or left
1623      * unspecified. Processes can override this setting.
1624      */
1625     private @MemtagMode int memtagMode = MEMTAG_DEFAULT;
1626 
1627     /**
1628      * Default (unspecified) setting of nativeHeapZeroInitialized.
1629      */
1630     public static final int ZEROINIT_DEFAULT = -1;
1631 
1632     /**
1633      * Disable zero-initialization of the native heap in this application or process.
1634      */
1635     public static final int ZEROINIT_DISABLED = 0;
1636 
1637     /**
1638      * Enable zero-initialization of the native heap in this application or process.
1639      */
1640     public static final int ZEROINIT_ENABLED = 1;
1641 
1642     /**
1643      * @hide
1644      */
1645     @IntDef(prefix = {"ZEROINIT_"}, value = {
1646             ZEROINIT_DEFAULT,
1647             ZEROINIT_DISABLED,
1648             ZEROINIT_ENABLED,
1649     })
1650     @Retention(RetentionPolicy.SOURCE)
1651     public @interface NativeHeapZeroInitialized {}
1652 
1653     /**
1654      * Enable automatic zero-initialization of native heap memory allocations.
1655      */
1656     private @NativeHeapZeroInitialized int nativeHeapZeroInitialized = ZEROINIT_DEFAULT;
1657 
1658     /**
1659      * If {@code true} this app requests raw external storage access.
1660      * The request may not be honored due to policy or other reasons.
1661      */
1662     @Nullable
1663     private Boolean requestRawExternalStorageAccess;
1664 
1665     /**
1666      * If {@code false}, this app does not allow its activities to be replaced by another app.
1667      * Is set from application manifest application tag's allowCrossUidActivitySwitchFromBelow
1668      * attribute.
1669      * @hide
1670      */
1671     public boolean allowCrossUidActivitySwitchFromBelow = true;
1672 
1673     /**
1674      * Represents the default policy. The actual policy used will depend on other properties of
1675      * the application, e.g. the target SDK version.
1676      * @hide
1677      */
1678     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1679     public static final int HIDDEN_API_ENFORCEMENT_DEFAULT = -1;
1680     /**
1681      * No API enforcement; the app can access the entire internal private API. Only for use by
1682      * system apps.
1683      * @hide
1684      */
1685     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1686     public static final int HIDDEN_API_ENFORCEMENT_DISABLED = 0;
1687     /**
1688      * No API enforcement, but enable the detection logic and warnings. Observed behaviour is the
1689      * same as {@link #HIDDEN_API_ENFORCEMENT_DISABLED} but you may see warnings in the log when
1690      * APIs are accessed.
1691      * @hide
1692      * */
1693     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1694     public static final int HIDDEN_API_ENFORCEMENT_JUST_WARN = 1;
1695     /**
1696      * Dark grey list enforcement. Enforces the dark grey and black lists
1697      * @hide
1698      */
1699     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
1700     public static final int HIDDEN_API_ENFORCEMENT_ENABLED = 2;
1701 
1702     private static final int HIDDEN_API_ENFORCEMENT_MIN = HIDDEN_API_ENFORCEMENT_DEFAULT;
1703     private static final int HIDDEN_API_ENFORCEMENT_MAX = HIDDEN_API_ENFORCEMENT_ENABLED;
1704 
1705     /**
1706      * Values in this IntDef MUST be kept in sync with enum hiddenapi::EnforcementPolicy in
1707      * art/runtime/hidden_api.h
1708      * @hide
1709      */
1710     @IntDef(prefix = { "HIDDEN_API_ENFORCEMENT_" }, value = {
1711             HIDDEN_API_ENFORCEMENT_DEFAULT,
1712             HIDDEN_API_ENFORCEMENT_DISABLED,
1713             HIDDEN_API_ENFORCEMENT_JUST_WARN,
1714             HIDDEN_API_ENFORCEMENT_ENABLED,
1715     })
1716     @Retention(RetentionPolicy.SOURCE)
1717     public @interface HiddenApiEnforcementPolicy {}
1718 
1719     /** @hide */
isValidHiddenApiEnforcementPolicy(int policy)1720     public static boolean isValidHiddenApiEnforcementPolicy(int policy) {
1721         return policy >= HIDDEN_API_ENFORCEMENT_MIN && policy <= HIDDEN_API_ENFORCEMENT_MAX;
1722     }
1723 
1724     private int mHiddenApiPolicy = HIDDEN_API_ENFORCEMENT_DEFAULT;
1725 
1726     /**
1727      * A map from a process name to an (custom) application class name in this package, derived
1728      * from the <processes> tag in the app's manifest. This map may not contain all the process
1729      * names. Processses not in this map will use the default app class name,
1730      * which is {@link #className}, or the default class {@link android.app.Application}.
1731      */
1732     @Nullable
1733     private ArrayMap<String, String> mAppClassNamesByProcess;
1734 
1735     /**
1736      * Resource file providing the application's locales configuration.
1737      */
1738     private int localeConfigRes;
1739 
1740     /**
1741      * Optional set of a certificates identifying apps that are allowed to embed activities of this
1742      * application. From the "knownActivityEmbeddingCerts" attribute.
1743      */
1744     @Nullable
1745     private Set<String> mKnownActivityEmbeddingCerts;
1746 
dump(Printer pw, String prefix)1747     public void dump(Printer pw, String prefix) {
1748         dump(pw, prefix, DUMP_FLAG_ALL);
1749     }
1750 
1751     /** @hide */
dump(Printer pw, String prefix, int dumpFlags)1752     public void dump(Printer pw, String prefix, int dumpFlags) {
1753         super.dumpFront(pw, prefix);
1754         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1755             if (className != null) {
1756                 pw.println(prefix + "className=" + className);
1757             }
1758             for (int i = 0; i < ArrayUtils.size(mAppClassNamesByProcess); i++) {
1759                 pw.println(prefix + "  process=" + mAppClassNamesByProcess.keyAt(i)
1760                         + " className=" + mAppClassNamesByProcess.valueAt(i));
1761             }
1762         }
1763         if (permission != null) {
1764             pw.println(prefix + "permission=" + permission);
1765         }
1766         pw.println(prefix + "processName=" + processName);
1767         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1768             pw.println(prefix + "taskAffinity=" + taskAffinity);
1769         }
1770         pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
1771                 + " privateFlags=0x" + Integer.toHexString(privateFlags)
1772                 + " theme=0x" + Integer.toHexString(theme));
1773         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1774             pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1775                     + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1776                     + " largestWidthLimitDp=" + largestWidthLimitDp);
1777         }
1778         pw.println(prefix + "sourceDir=" + sourceDir);
1779         if (!Objects.equals(sourceDir, publicSourceDir)) {
1780             pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1781         }
1782         if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1783             pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1784         }
1785         if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1786                 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1787             pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1788         }
1789         if (resourceDirs != null) {
1790             pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
1791         }
1792         if (overlayPaths != null) {
1793             pw.println(prefix + "overlayPaths=" + Arrays.toString(overlayPaths));
1794         }
1795         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
1796             pw.println(prefix + "seinfo=" + seInfo);
1797             pw.println(prefix + "seinfoUser=" + seInfoUser);
1798         }
1799         pw.println(prefix + "dataDir=" + dataDir);
1800         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1801             pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1802             pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
1803             if (sharedLibraryFiles != null) {
1804                 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1805             }
1806         }
1807         if (classLoaderName != null) {
1808             pw.println(prefix + "classLoaderName=" + classLoaderName);
1809         }
1810         if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1811             pw.println(prefix + "splitClassLoaderNames=" + Arrays.toString(splitClassLoaderNames));
1812         }
1813 
1814         pw.println(prefix + "enabled=" + enabled
1815                 + " minSdkVersion=" + minSdkVersion
1816                 + " targetSdkVersion=" + targetSdkVersion
1817                 + " versionCode=" + longVersionCode
1818                 + " targetSandboxVersion=" + targetSandboxVersion);
1819         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1820             if (manageSpaceActivityName != null) {
1821                 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1822             }
1823             if (descriptionRes != 0) {
1824                 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1825             }
1826             if (uiOptions != 0) {
1827                 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1828             }
1829             pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1830             if (fullBackupContent > 0) {
1831                 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1832             } else {
1833                 pw.println(prefix + "fullBackupContent="
1834                         + (fullBackupContent < 0 ? "false" : "true"));
1835             }
1836             if (dataExtractionRulesRes != 0) {
1837                 pw.println(prefix + "dataExtractionRules=@xml/" + dataExtractionRulesRes);
1838             }
1839             pw.println(prefix + "crossProfile=" + (crossProfile ? "true" : "false"));
1840             if (networkSecurityConfigRes != 0) {
1841                 pw.println(prefix + "networkSecurityConfigRes=0x"
1842                         + Integer.toHexString(networkSecurityConfigRes));
1843             }
1844             if (category != CATEGORY_UNDEFINED) {
1845                 pw.println(prefix + "category=" + category);
1846             }
1847             pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
1848             pw.println(prefix + "usesNonSdkApi=" + usesNonSdkApi());
1849             pw.println(prefix + "allowsPlaybackCapture="
1850                         + (isAudioPlaybackCaptureAllowed() ? "true" : "false"));
1851             if (gwpAsanMode != GWP_ASAN_DEFAULT) {
1852                 pw.println(prefix + "gwpAsanMode=" + gwpAsanMode);
1853             }
1854             if (memtagMode != MEMTAG_DEFAULT) {
1855                 pw.println(prefix + "memtagMode=" + memtagMode);
1856             }
1857             if (nativeHeapZeroInitialized != ZEROINIT_DEFAULT) {
1858                 pw.println(prefix + "nativeHeapZeroInitialized=" + nativeHeapZeroInitialized);
1859             }
1860             if (requestRawExternalStorageAccess != null) {
1861                 pw.println(prefix + "requestRawExternalStorageAccess="
1862                         + requestRawExternalStorageAccess);
1863             }
1864             if (localeConfigRes != 0) {
1865                 pw.println(prefix + "localeConfigRes=0x"
1866                         + Integer.toHexString(localeConfigRes));
1867             }
1868             pw.println(prefix + "enableOnBackInvokedCallback=" + isOnBackInvokedCallbackEnabled());
1869             pw.println(prefix + "allowCrossUidActivitySwitchFromBelow="
1870                     + allowCrossUidActivitySwitchFromBelow);
1871             pw.println(prefix + "mPageSizeAppCompatFlags=" + mPageSizeAppCompatFlags);
1872         }
1873         pw.println(prefix + "createTimestamp=" + createTimestamp);
1874         if (mKnownActivityEmbeddingCerts != null) {
1875             pw.println(prefix + "knownActivityEmbeddingCerts=" + mKnownActivityEmbeddingCerts);
1876         }
1877         super.dumpBack(pw, prefix);
1878     }
1879 
1880     /** {@hide} */
dumpDebug(ProtoOutputStream proto, long fieldId, int dumpFlags)1881     public void dumpDebug(ProtoOutputStream proto, long fieldId, int dumpFlags) {
1882         long token = proto.start(fieldId);
1883         super.dumpDebug(proto, ApplicationInfoProto.PACKAGE, dumpFlags);
1884         proto.write(ApplicationInfoProto.PERMISSION, permission);
1885         proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
1886         proto.write(ApplicationInfoProto.UID, uid);
1887         proto.write(ApplicationInfoProto.FLAGS, flags);
1888         proto.write(ApplicationInfoProto.PRIVATE_FLAGS, privateFlags);
1889         proto.write(ApplicationInfoProto.THEME, theme);
1890         proto.write(ApplicationInfoProto.SOURCE_DIR, sourceDir);
1891         if (!Objects.equals(sourceDir, publicSourceDir)) {
1892             proto.write(ApplicationInfoProto.PUBLIC_SOURCE_DIR, publicSourceDir);
1893         }
1894         if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1895             for (String dir : splitSourceDirs) {
1896                 proto.write(ApplicationInfoProto.SPLIT_SOURCE_DIRS, dir);
1897             }
1898         }
1899         if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1900                 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1901             for (String dir : splitPublicSourceDirs) {
1902                 proto.write(ApplicationInfoProto.SPLIT_PUBLIC_SOURCE_DIRS, dir);
1903             }
1904         }
1905         if (resourceDirs != null) {
1906             for (String dir : resourceDirs) {
1907                 proto.write(ApplicationInfoProto.RESOURCE_DIRS, dir);
1908             }
1909         }
1910         if (overlayPaths != null) {
1911             for (String dir : overlayPaths) {
1912                 proto.write(ApplicationInfoProto.OVERLAY_PATHS, dir);
1913             }
1914         }
1915         proto.write(ApplicationInfoProto.DATA_DIR, dataDir);
1916         proto.write(ApplicationInfoProto.CLASS_LOADER_NAME, classLoaderName);
1917         if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1918             for (String name : splitClassLoaderNames) {
1919                 proto.write(ApplicationInfoProto.SPLIT_CLASS_LOADER_NAMES, name);
1920             }
1921         }
1922 
1923         long versionToken = proto.start(ApplicationInfoProto.VERSION);
1924         proto.write(ApplicationInfoProto.Version.ENABLED, enabled);
1925         proto.write(ApplicationInfoProto.Version.MIN_SDK_VERSION, minSdkVersion);
1926         proto.write(ApplicationInfoProto.Version.TARGET_SDK_VERSION, targetSdkVersion);
1927         proto.write(ApplicationInfoProto.Version.VERSION_CODE, longVersionCode);
1928         proto.write(ApplicationInfoProto.Version.TARGET_SANDBOX_VERSION, targetSandboxVersion);
1929         proto.end(versionToken);
1930 
1931         if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1932             long detailToken = proto.start(ApplicationInfoProto.DETAIL);
1933             if (className != null) {
1934                 proto.write(ApplicationInfoProto.Detail.CLASS_NAME, className);
1935             }
1936             proto.write(ApplicationInfoProto.Detail.TASK_AFFINITY, taskAffinity);
1937             proto.write(ApplicationInfoProto.Detail.REQUIRES_SMALLEST_WIDTH_DP,
1938                     requiresSmallestWidthDp);
1939             proto.write(ApplicationInfoProto.Detail.COMPATIBLE_WIDTH_LIMIT_DP,
1940                     compatibleWidthLimitDp);
1941             proto.write(ApplicationInfoProto.Detail.LARGEST_WIDTH_LIMIT_DP,
1942                     largestWidthLimitDp);
1943             if (seInfo != null) {
1944                 proto.write(ApplicationInfoProto.Detail.SEINFO, seInfo);
1945                 proto.write(ApplicationInfoProto.Detail.SEINFO_USER, seInfoUser);
1946             }
1947             proto.write(ApplicationInfoProto.Detail.DEVICE_PROTECTED_DATA_DIR,
1948                     deviceProtectedDataDir);
1949             proto.write(ApplicationInfoProto.Detail.CREDENTIAL_PROTECTED_DATA_DIR,
1950                     credentialProtectedDataDir);
1951             if (sharedLibraryFiles != null) {
1952                 for (String f : sharedLibraryFiles) {
1953                     proto.write(ApplicationInfoProto.Detail.SHARED_LIBRARY_FILES, f);
1954                 }
1955             }
1956             if (manageSpaceActivityName != null) {
1957                 proto.write(ApplicationInfoProto.Detail.MANAGE_SPACE_ACTIVITY_NAME,
1958                         manageSpaceActivityName);
1959             }
1960             if (descriptionRes != 0) {
1961                 proto.write(ApplicationInfoProto.Detail.DESCRIPTION_RES, descriptionRes);
1962             }
1963             if (uiOptions != 0) {
1964                 proto.write(ApplicationInfoProto.Detail.UI_OPTIONS, uiOptions);
1965             }
1966             proto.write(ApplicationInfoProto.Detail.SUPPORTS_RTL, hasRtlSupport());
1967             if (fullBackupContent > 0) {
1968                 proto.write(ApplicationInfoProto.Detail.CONTENT, "@xml/" + fullBackupContent);
1969             } else {
1970                 proto.write(ApplicationInfoProto.Detail.IS_FULL_BACKUP, fullBackupContent == 0);
1971             }
1972             if (networkSecurityConfigRes != 0) {
1973                 proto.write(ApplicationInfoProto.Detail.NETWORK_SECURITY_CONFIG_RES,
1974                         networkSecurityConfigRes);
1975             }
1976             if (category != CATEGORY_UNDEFINED) {
1977                 proto.write(ApplicationInfoProto.Detail.CATEGORY, category);
1978             }
1979             if (gwpAsanMode != GWP_ASAN_DEFAULT) {
1980                 proto.write(ApplicationInfoProto.Detail.ENABLE_GWP_ASAN, gwpAsanMode);
1981             }
1982             if (memtagMode != MEMTAG_DEFAULT) {
1983                 proto.write(ApplicationInfoProto.Detail.ENABLE_MEMTAG, memtagMode);
1984             }
1985             if (nativeHeapZeroInitialized != ZEROINIT_DEFAULT) {
1986                 proto.write(ApplicationInfoProto.Detail.NATIVE_HEAP_ZERO_INIT,
1987                         nativeHeapZeroInitialized);
1988             }
1989             proto.write(ApplicationInfoProto.Detail.ALLOW_CROSS_UID_ACTIVITY_SWITCH_FROM_BELOW,
1990                     allowCrossUidActivitySwitchFromBelow);
1991 
1992             proto.write(ApplicationInfoProto.Detail.ENABLE_PAGE_SIZE_APP_COMPAT,
1993                         mPageSizeAppCompatFlags);
1994 
1995             proto.end(detailToken);
1996         }
1997         if (!ArrayUtils.isEmpty(mKnownActivityEmbeddingCerts)) {
1998             for (String knownCert : mKnownActivityEmbeddingCerts) {
1999                 proto.write(ApplicationInfoProto.KNOWN_ACTIVITY_EMBEDDING_CERTS, knownCert);
2000             }
2001         }
2002         proto.end(token);
2003     }
2004 
2005     /**
2006      * @return true if "supportsRtl" has been set to true in the AndroidManifest
2007      * @hide
2008      */
2009     @UnsupportedAppUsage
hasRtlSupport()2010     public boolean hasRtlSupport() {
2011         return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
2012     }
2013 
2014     /** {@hide} */
hasCode()2015     public boolean hasCode() {
2016         return (flags & FLAG_HAS_CODE) != 0;
2017     }
2018 
2019     public static class DisplayNameComparator
2020             implements Comparator<ApplicationInfo> {
DisplayNameComparator(PackageManager pm)2021         public DisplayNameComparator(PackageManager pm) {
2022             mPM = pm;
2023         }
2024 
compare(ApplicationInfo aa, ApplicationInfo ab)2025         public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
2026             CharSequence  sa = mPM.getApplicationLabel(aa);
2027             if (sa == null) {
2028                 sa = aa.packageName;
2029             }
2030             CharSequence  sb = mPM.getApplicationLabel(ab);
2031             if (sb == null) {
2032                 sb = ab.packageName;
2033             }
2034 
2035             return sCollator.compare(sa.toString(), sb.toString());
2036         }
2037 
2038         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
2039         private final Collator   sCollator = Collator.getInstance();
2040         @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
2041         private final PackageManager mPM;
2042     }
2043 
ApplicationInfo()2044     public ApplicationInfo() {
2045         createTimestamp = SystemClock.uptimeMillis();
2046     }
2047 
ApplicationInfo(ApplicationInfo orig)2048     public ApplicationInfo(ApplicationInfo orig) {
2049         super(orig);
2050         taskAffinity = orig.taskAffinity;
2051         permission = orig.permission;
2052         mKnownActivityEmbeddingCerts = orig.mKnownActivityEmbeddingCerts;
2053         processName = orig.processName;
2054         className = orig.className;
2055         theme = orig.theme;
2056         flags = orig.flags;
2057         privateFlags = orig.privateFlags;
2058         privateFlagsExt = orig.privateFlagsExt;
2059         requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
2060         compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
2061         largestWidthLimitDp = orig.largestWidthLimitDp;
2062         volumeUuid = orig.volumeUuid;
2063         storageUuid = orig.storageUuid;
2064         scanSourceDir = orig.scanSourceDir;
2065         scanPublicSourceDir = orig.scanPublicSourceDir;
2066         sourceDir = orig.sourceDir;
2067         publicSourceDir = orig.publicSourceDir;
2068         splitNames = orig.splitNames;
2069         splitSourceDirs = orig.splitSourceDirs;
2070         splitPublicSourceDirs = orig.splitPublicSourceDirs;
2071         splitDependencies = orig.splitDependencies;
2072         nativeLibraryDir = orig.nativeLibraryDir;
2073         secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
2074         nativeLibraryRootDir = orig.nativeLibraryRootDir;
2075         nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
2076         primaryCpuAbi = orig.primaryCpuAbi;
2077         secondaryCpuAbi = orig.secondaryCpuAbi;
2078         resourceDirs = orig.resourceDirs;
2079         overlayPaths = orig.overlayPaths;
2080         seInfo = orig.seInfo;
2081         seInfoUser = orig.seInfoUser;
2082         sharedLibraryFiles = orig.sharedLibraryFiles;
2083         sharedLibraryInfos = orig.sharedLibraryInfos;
2084         optionalSharedLibraryInfos = orig.optionalSharedLibraryInfos;
2085         dataDir = orig.dataDir;
2086         deviceProtectedDataDir = orig.deviceProtectedDataDir;
2087         credentialProtectedDataDir = orig.credentialProtectedDataDir;
2088         uid = orig.uid;
2089         minSdkVersion = orig.minSdkVersion;
2090         targetSdkVersion = orig.targetSdkVersion;
2091         setVersionCode(orig.longVersionCode);
2092         enabled = orig.enabled;
2093         enabledSetting = orig.enabledSetting;
2094         installLocation = orig.installLocation;
2095         manageSpaceActivityName = orig.manageSpaceActivityName;
2096         descriptionRes = orig.descriptionRes;
2097         uiOptions = orig.uiOptions;
2098         backupAgentName = orig.backupAgentName;
2099         fullBackupContent = orig.fullBackupContent;
2100         dataExtractionRulesRes = orig.dataExtractionRulesRes;
2101         crossProfile = orig.crossProfile;
2102         networkSecurityConfigRes = orig.networkSecurityConfigRes;
2103         category = orig.category;
2104         targetSandboxVersion = orig.targetSandboxVersion;
2105         classLoaderName = orig.classLoaderName;
2106         splitClassLoaderNames = orig.splitClassLoaderNames;
2107         appComponentFactory = orig.appComponentFactory;
2108         iconRes = orig.iconRes;
2109         roundIconRes = orig.roundIconRes;
2110         compileSdkVersion = orig.compileSdkVersion;
2111         compileSdkVersionCodename = orig.compileSdkVersionCodename;
2112         mHiddenApiPolicy = orig.mHiddenApiPolicy;
2113         hiddenUntilInstalled = orig.hiddenUntilInstalled;
2114         zygotePreloadName = orig.zygotePreloadName;
2115         gwpAsanMode = orig.gwpAsanMode;
2116         memtagMode = orig.memtagMode;
2117         nativeHeapZeroInitialized = orig.nativeHeapZeroInitialized;
2118         requestRawExternalStorageAccess = orig.requestRawExternalStorageAccess;
2119         localeConfigRes = orig.localeConfigRes;
2120         allowCrossUidActivitySwitchFromBelow = orig.allowCrossUidActivitySwitchFromBelow;
2121         createTimestamp = SystemClock.uptimeMillis();
2122         mPageSizeAppCompatFlags = orig.mPageSizeAppCompatFlags;
2123     }
2124 
toString()2125     public String toString() {
2126         return "ApplicationInfo{"
2127             + Integer.toHexString(System.identityHashCode(this))
2128             + " " + packageName + "}";
2129     }
2130 
describeContents()2131     public int describeContents() {
2132         return 0;
2133     }
2134 
2135     @SuppressWarnings("unchecked")
writeToParcel(Parcel dest, int parcelableFlags)2136     public void writeToParcel(Parcel dest, int parcelableFlags) {
2137         if (dest.maybeWriteSquashed(this)) {
2138             return;
2139         }
2140         super.writeToParcel(dest, parcelableFlags);
2141         dest.writeString8(taskAffinity);
2142         dest.writeString8(permission);
2143         dest.writeString8(processName);
2144         dest.writeString8(className);
2145         dest.writeInt(theme);
2146         dest.writeInt(flags);
2147         dest.writeInt(privateFlags);
2148         dest.writeInt(privateFlagsExt);
2149         dest.writeInt(requiresSmallestWidthDp);
2150         dest.writeInt(compatibleWidthLimitDp);
2151         dest.writeInt(largestWidthLimitDp);
2152         if (storageUuid != null) {
2153             dest.writeInt(1);
2154             dest.writeLong(storageUuid.getMostSignificantBits());
2155             dest.writeLong(storageUuid.getLeastSignificantBits());
2156         } else {
2157             dest.writeInt(0);
2158         }
2159         dest.writeString8(scanSourceDir);
2160         dest.writeString8(scanPublicSourceDir);
2161         dest.writeString8(sourceDir);
2162         dest.writeString8(publicSourceDir);
2163         dest.writeString8Array(splitNames);
2164         dest.writeString8Array(splitSourceDirs);
2165         dest.writeString8Array(splitPublicSourceDirs);
2166         dest.writeSparseArray((SparseArray) splitDependencies);
2167         dest.writeString8(nativeLibraryDir);
2168         dest.writeString8(secondaryNativeLibraryDir);
2169         dest.writeString8(nativeLibraryRootDir);
2170         dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
2171         dest.writeString8(primaryCpuAbi);
2172         dest.writeString8(secondaryCpuAbi);
2173         dest.writeString8Array(resourceDirs);
2174         dest.writeString8Array(overlayPaths);
2175         dest.writeString8(seInfo);
2176         dest.writeString8(seInfoUser);
2177         dest.writeString8Array(sharedLibraryFiles);
2178         dest.writeTypedList(sharedLibraryInfos);
2179         dest.writeTypedList(optionalSharedLibraryInfos);
2180         dest.writeString8(dataDir);
2181         dest.writeString8(deviceProtectedDataDir);
2182         dest.writeString8(credentialProtectedDataDir);
2183         dest.writeInt(uid);
2184         dest.writeInt(minSdkVersion);
2185         dest.writeInt(targetSdkVersion);
2186         dest.writeLong(longVersionCode);
2187         dest.writeInt(enabled ? 1 : 0);
2188         dest.writeInt(enabledSetting);
2189         dest.writeInt(installLocation);
2190         dest.writeString8(manageSpaceActivityName);
2191         dest.writeString8(backupAgentName);
2192         dest.writeInt(descriptionRes);
2193         dest.writeInt(uiOptions);
2194         dest.writeInt(fullBackupContent);
2195         dest.writeInt(dataExtractionRulesRes);
2196         dest.writeBoolean(crossProfile);
2197         dest.writeInt(networkSecurityConfigRes);
2198         dest.writeInt(category);
2199         dest.writeInt(targetSandboxVersion);
2200         dest.writeString8(classLoaderName);
2201         dest.writeString8Array(splitClassLoaderNames);
2202         dest.writeInt(compileSdkVersion);
2203         dest.writeString8(compileSdkVersionCodename);
2204         dest.writeString8(appComponentFactory);
2205         dest.writeInt(iconRes);
2206         dest.writeInt(roundIconRes);
2207         dest.writeInt(mHiddenApiPolicy);
2208         dest.writeInt(hiddenUntilInstalled ? 1 : 0);
2209         dest.writeString8(zygotePreloadName);
2210         dest.writeInt(gwpAsanMode);
2211         dest.writeInt(memtagMode);
2212         dest.writeInt(nativeHeapZeroInitialized);
2213         sForBoolean.parcel(requestRawExternalStorageAccess, dest, parcelableFlags);
2214         dest.writeLong(createTimestamp);
2215         if (mAppClassNamesByProcess == null) {
2216             dest.writeInt(0);
2217         } else {
2218             final int size = mAppClassNamesByProcess.size();
2219             dest.writeInt(size);
2220             for (int i = 0; i < size; i++) {
2221                 dest.writeString(mAppClassNamesByProcess.keyAt(i));
2222                 dest.writeString(mAppClassNamesByProcess.valueAt(i));
2223             }
2224         }
2225         dest.writeInt(localeConfigRes);
2226         dest.writeInt(allowCrossUidActivitySwitchFromBelow ? 1 : 0);
2227         dest.writeInt(mPageSizeAppCompatFlags);
2228 
2229         sForStringSet.parcel(mKnownActivityEmbeddingCerts, dest, flags);
2230     }
2231 
2232     public static final @android.annotation.NonNull Parcelable.Creator<ApplicationInfo> CREATOR
2233             = new Parcelable.Creator<ApplicationInfo>() {
2234         @Override
2235         public ApplicationInfo createFromParcel(Parcel source) {
2236             return source.readSquashed(ApplicationInfo::new);
2237         }
2238 
2239         @Override
2240         public ApplicationInfo[] newArray(int size) {
2241             return new ApplicationInfo[size];
2242         }
2243     };
2244 
2245     @SuppressWarnings("unchecked")
ApplicationInfo(Parcel source)2246     private ApplicationInfo(Parcel source) {
2247         super(source);
2248         taskAffinity = source.readString8();
2249         permission = source.readString8();
2250         processName = source.readString8();
2251         className = source.readString8();
2252         theme = source.readInt();
2253         flags = source.readInt();
2254         privateFlags = source.readInt();
2255         privateFlagsExt = source.readInt();
2256         requiresSmallestWidthDp = source.readInt();
2257         compatibleWidthLimitDp = source.readInt();
2258         largestWidthLimitDp = source.readInt();
2259         if (source.readInt() != 0) {
2260             storageUuid = new UUID(source.readLong(), source.readLong());
2261             volumeUuid = StorageManager.convert(storageUuid);
2262         }
2263         scanSourceDir = source.readString8();
2264         scanPublicSourceDir = source.readString8();
2265         sourceDir = source.readString8();
2266         publicSourceDir = source.readString8();
2267         splitNames = source.createString8Array();
2268         splitSourceDirs = source.createString8Array();
2269         splitPublicSourceDirs = source.createString8Array();
2270         splitDependencies = source.readSparseArray(null, int[].class);
2271         nativeLibraryDir = source.readString8();
2272         secondaryNativeLibraryDir = source.readString8();
2273         nativeLibraryRootDir = source.readString8();
2274         nativeLibraryRootRequiresIsa = source.readInt() != 0;
2275         primaryCpuAbi = source.readString8();
2276         secondaryCpuAbi = source.readString8();
2277         resourceDirs = source.createString8Array();
2278         overlayPaths = source.createString8Array();
2279         seInfo = source.readString8();
2280         seInfoUser = source.readString8();
2281         sharedLibraryFiles = source.createString8Array();
2282         sharedLibraryInfos = source.createTypedArrayList(SharedLibraryInfo.CREATOR);
2283         optionalSharedLibraryInfos = source.createTypedArrayList(SharedLibraryInfo.CREATOR);
2284         dataDir = source.readString8();
2285         deviceProtectedDataDir = source.readString8();
2286         credentialProtectedDataDir = source.readString8();
2287         uid = source.readInt();
2288         minSdkVersion = source.readInt();
2289         targetSdkVersion = source.readInt();
2290         setVersionCode(source.readLong());
2291         enabled = source.readInt() != 0;
2292         enabledSetting = source.readInt();
2293         installLocation = source.readInt();
2294         manageSpaceActivityName = source.readString8();
2295         backupAgentName = source.readString8();
2296         descriptionRes = source.readInt();
2297         uiOptions = source.readInt();
2298         fullBackupContent = source.readInt();
2299         dataExtractionRulesRes = source.readInt();
2300         crossProfile = source.readBoolean();
2301         networkSecurityConfigRes = source.readInt();
2302         category = source.readInt();
2303         targetSandboxVersion = source.readInt();
2304         classLoaderName = source.readString8();
2305         splitClassLoaderNames = source.createString8Array();
2306         compileSdkVersion = source.readInt();
2307         compileSdkVersionCodename = source.readString8();
2308         appComponentFactory = source.readString8();
2309         iconRes = source.readInt();
2310         roundIconRes = source.readInt();
2311         mHiddenApiPolicy = source.readInt();
2312         hiddenUntilInstalled = source.readInt() != 0;
2313         zygotePreloadName = source.readString8();
2314         gwpAsanMode = source.readInt();
2315         memtagMode = source.readInt();
2316         nativeHeapZeroInitialized = source.readInt();
2317         requestRawExternalStorageAccess = sForBoolean.unparcel(source);
2318         createTimestamp = source.readLong();
2319         final int allClassesSize = source.readInt();
2320         if (allClassesSize > 0) {
2321             mAppClassNamesByProcess = new ArrayMap<>(allClassesSize);
2322             for (int i = 0; i < allClassesSize; i++) {
2323                 mAppClassNamesByProcess.put(source.readString(), source.readString());
2324             }
2325         }
2326         localeConfigRes = source.readInt();
2327         allowCrossUidActivitySwitchFromBelow = source.readInt() != 0;
2328         mPageSizeAppCompatFlags = source.readInt();
2329 
2330         mKnownActivityEmbeddingCerts = sForStringSet.unparcel(source);
2331         if (mKnownActivityEmbeddingCerts.isEmpty()) {
2332             mKnownActivityEmbeddingCerts = null;
2333         }
2334     }
2335 
2336     /**
2337      * Retrieve the textual description of the application.  This
2338      * will call back on the given PackageManager to load the description from
2339      * the application.
2340      *
2341      * @param pm A PackageManager from which the label can be loaded; usually
2342      * the PackageManager from which you originally retrieved this item.
2343      *
2344      * @return Returns a CharSequence containing the application's description.
2345      * If there is no description, null is returned.
2346      */
2347     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = android.content.res.Resources.class)
loadDescription(PackageManager pm)2348     public CharSequence loadDescription(PackageManager pm) {
2349         if (descriptionRes != 0) {
2350             CharSequence label = pm.getText(packageName, descriptionRes, this);
2351             if (label != null) {
2352                 return label;
2353             }
2354         }
2355         return null;
2356     }
2357 
2358     /**
2359      * Disable compatibility mode
2360      *
2361      * @hide
2362      */
2363     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
disableCompatibilityMode()2364     public void disableCompatibilityMode() {
2365         flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
2366                 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
2367                 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
2368     }
2369 
2370     /**
2371      * Is using compatibility mode for non densty aware legacy applications.
2372      *
2373      * @hide
2374      */
usesCompatibilityMode()2375     public boolean usesCompatibilityMode() {
2376         return targetSdkVersion < DONUT ||
2377                 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
2378                  FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
2379                  FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
2380     }
2381 
2382     /** {@hide} */
2383     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = Environment.class)
initForUser(int userId)2384     public void initForUser(int userId) {
2385         uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
2386 
2387         if ("android".equals(packageName)) {
2388             dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
2389             return;
2390         }
2391 
2392         deviceProtectedDataDir = Environment
2393                 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
2394                 .getAbsolutePath();
2395         credentialProtectedDataDir = Environment
2396                 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
2397                 .getAbsolutePath();
2398 
2399         if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
2400                 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
2401             dataDir = deviceProtectedDataDir;
2402         } else {
2403             dataDir = credentialProtectedDataDir;
2404         }
2405     }
2406 
isPackageWhitelistedForHiddenApis()2407     private boolean isPackageWhitelistedForHiddenApis() {
2408         return (privateFlagsExt & PRIVATE_FLAG_EXT_ALLOWLISTED_FOR_HIDDEN_APIS) != 0;
2409     }
2410 
2411     /**
2412      * @hide
2413      */
usesNonSdkApi()2414     public boolean usesNonSdkApi() {
2415         return (privateFlags & PRIVATE_FLAG_USES_NON_SDK_API) != 0;
2416     }
2417 
2418     /**
2419      * Whether an app needs to keep the app data on uninstall.
2420      *
2421      * @return {@code true} if the app indicates that it needs to keep the app data
2422      *
2423      * @hide
2424      */
2425     @SystemApi
2426     @RequiresPermission(Manifest.permission.DELETE_PACKAGES)
hasFragileUserData()2427     public boolean hasFragileUserData() {
2428         return (privateFlags & PRIVATE_FLAG_HAS_FRAGILE_USER_DATA) != 0;
2429     }
2430 
2431     /**
2432      * Whether an app allows its playback audio to be captured by other apps.
2433      *
2434      * @return {@code true} if the app indicates that its audio can be captured by other apps.
2435      */
2436     @FlaggedApi(Flags.FLAG_AUDIO_PLAYBACK_CAPTURE_ALLOWANCE)
isAudioPlaybackCaptureAllowed()2437     public boolean isAudioPlaybackCaptureAllowed() {
2438         return (privateFlags & PRIVATE_FLAG_ALLOW_AUDIO_PLAYBACK_CAPTURE) != 0;
2439     }
2440 
2441     /**
2442      * If {@code true} this app requested to run in the legacy storage mode.
2443      *
2444      * @hide
2445      */
hasRequestedLegacyExternalStorage()2446     public boolean hasRequestedLegacyExternalStorage() {
2447         return (privateFlags & PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE) != 0;
2448     }
2449 
2450     /**
2451      * Use default value for
2452      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}.
2453      */
2454     public static final int RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT = 0;
2455 
2456     /**
2457      * Raw external storage was requested by this app.
2458      */
2459     public static final int RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED = 1;
2460 
2461     /**
2462      * Raw external storage was not requested by this app.
2463      */
2464     public static final int RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED = 2;
2465 
2466     /**
2467      * These constants need to match the value of
2468      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}.
2469      * in application manifest.
2470      * @hide
2471      */
2472     @IntDef(prefix = {"RAW_EXTERNAL_STORAGE_"}, value = {
2473             RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT,
2474             RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED,
2475             RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED,
2476     })
2477     @Retention(RetentionPolicy.SOURCE)
2478     public @interface RawExternalStorage {}
2479 
2480     /**
2481      * @return
2482      * <ul>
2483      * <li>{@link ApplicationInfo#RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT} if app didn't specify
2484      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}
2485      * attribute in the manifest.
2486      * <li>{@link ApplicationInfo#RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED} if this app requested raw
2487      * external storage access.
2488      * <li>{@link ApplicationInfo#RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED} if this app requests to
2489      * disable raw external storage access
2490      * </ul
2491      * <p>
2492      * Note that this doesn't give any hints on whether the app gets raw external storage access or
2493      * not. Also, apps may get raw external storage access by default in some cases, see
2494      * {@link android.R.styleable#AndroidManifestApplication_requestRawExternalStorageAccess}.
2495      */
getRequestRawExternalStorageAccess()2496     public @RawExternalStorage int getRequestRawExternalStorageAccess() {
2497         if (requestRawExternalStorageAccess == null) {
2498             return RAW_EXTERNAL_STORAGE_ACCESS_DEFAULT;
2499         }
2500         return requestRawExternalStorageAccess ? RAW_EXTERNAL_STORAGE_ACCESS_REQUESTED
2501                 : RAW_EXTERNAL_STORAGE_ACCESS_NOT_REQUESTED;
2502     }
2503 
2504     /**
2505      * If {@code true} this app allows heap pointer tagging.
2506      *
2507      * @hide
2508      */
allowsNativeHeapPointerTagging()2509     public boolean allowsNativeHeapPointerTagging() {
2510         return (privateFlags & PRIVATE_FLAG_ALLOW_NATIVE_HEAP_POINTER_TAGGING) != 0;
2511     }
2512 
isAllowedToUseHiddenApis()2513     private boolean isAllowedToUseHiddenApis() {
2514         if (isSignedWithPlatformKey()) {
2515             return true;
2516         } else if (isSystemApp() || isUpdatedSystemApp()) {
2517             return usesNonSdkApi() || isPackageWhitelistedForHiddenApis();
2518         } else {
2519             return false;
2520         }
2521     }
2522 
2523     /**
2524      * @hide
2525      */
getHiddenApiEnforcementPolicy()2526     public @HiddenApiEnforcementPolicy int getHiddenApiEnforcementPolicy() {
2527         if (isAllowedToUseHiddenApis()) {
2528             return HIDDEN_API_ENFORCEMENT_DISABLED;
2529         }
2530         if (mHiddenApiPolicy != HIDDEN_API_ENFORCEMENT_DEFAULT) {
2531             return mHiddenApiPolicy;
2532         }
2533         return HIDDEN_API_ENFORCEMENT_ENABLED;
2534     }
2535 
2536     /**
2537      * @hide
2538      */
setHiddenApiEnforcementPolicy(@iddenApiEnforcementPolicy int policy)2539     public void setHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
2540         if (!isValidHiddenApiEnforcementPolicy(policy)) {
2541             throw new IllegalArgumentException("Invalid API enforcement policy: " + policy);
2542         }
2543         mHiddenApiPolicy = policy;
2544     }
2545 
2546     /**
2547      * Updates the hidden API enforcement policy for this app from the given values, if appropriate.
2548      *
2549      * This will have no effect if this app is not subject to hidden API enforcement, i.e. if it
2550      * is on the package allowlist.
2551      *
2552      * @param policy configured policy for this app, or {@link #HIDDEN_API_ENFORCEMENT_DEFAULT}
2553      *        if nothing configured.
2554      * @hide
2555      */
maybeUpdateHiddenApiEnforcementPolicy(@iddenApiEnforcementPolicy int policy)2556     public void maybeUpdateHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
2557         if (isPackageWhitelistedForHiddenApis()) {
2558             return;
2559         }
2560         setHiddenApiEnforcementPolicy(policy);
2561     }
2562 
2563     /**
2564      * @hide
2565      */
setVersionCode(long newVersionCode)2566     public void setVersionCode(long newVersionCode) {
2567         longVersionCode = newVersionCode;
2568         versionCode = (int) newVersionCode;
2569     }
2570 
2571     /**
2572      * @hide
2573      */
2574     @Override
2575     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = android.content.res.Resources.class)
loadDefaultIcon(PackageManager pm)2576     public Drawable loadDefaultIcon(PackageManager pm) {
2577         if ((flags & FLAG_EXTERNAL_STORAGE) != 0
2578                 && isPackageUnavailable(pm)) {
2579             return Resources.getSystem().getDrawable(
2580                     com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
2581         }
2582         return pm.getDefaultActivityIcon();
2583     }
2584 
2585     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
2586     @android.ravenwood.annotation.RavenwoodThrow(blockedBy = PackageManager.class)
isPackageUnavailable(PackageManager pm)2587     private boolean isPackageUnavailable(PackageManager pm) {
2588         try {
2589             return pm.getPackageInfo(packageName, 0) == null;
2590         } catch (NameNotFoundException ex) {
2591             return true;
2592         }
2593     }
2594 
2595     /** @hide */
isDefaultToDeviceProtectedStorage()2596     public boolean isDefaultToDeviceProtectedStorage() {
2597         return (privateFlags
2598                 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
2599     }
2600 
2601     /** @hide */
isDirectBootAware()2602     public boolean isDirectBootAware() {
2603         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
2604     }
2605 
2606     /**
2607      * Check whether the application is encryption aware.
2608      *
2609      * @see #isDirectBootAware()
2610      * @see #isPartiallyDirectBootAware()
2611      *
2612      * @hide
2613      */
2614     @SystemApi
isEncryptionAware()2615     public boolean isEncryptionAware() {
2616         return isDirectBootAware() || isPartiallyDirectBootAware();
2617     }
2618 
2619     /** @hide */
isExternal()2620     public boolean isExternal() {
2621         return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
2622     }
2623 
2624     /**
2625      * True if the application is installed as an instant app.
2626      * @hide
2627      */
2628     @SystemApi
isInstantApp()2629     public boolean isInstantApp() {
2630         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
2631     }
2632 
2633     /** @hide */
isInternal()2634     public boolean isInternal() {
2635         return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
2636     }
2637 
2638     /**
2639      * True if the application is pre-installed on the OEM partition of the system image.
2640      * @hide
2641      */
2642     @SystemApi
isOem()2643     public boolean isOem() {
2644         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
2645     }
2646 
2647     /** @hide */
isOdm()2648     public boolean isOdm() {
2649         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ODM) != 0;
2650     }
2651 
2652     /** @hide */
isPartiallyDirectBootAware()2653     public boolean isPartiallyDirectBootAware() {
2654         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
2655     }
2656 
2657     /** @hide */
isSignedWithPlatformKey()2658     public boolean isSignedWithPlatformKey() {
2659         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY) != 0;
2660     }
2661 
2662     /**
2663      * @return {@code true} if the application is permitted to hold privileged permissions.
2664      *
2665      * @hide */
2666     @TestApi
2667     @SystemApi
2668     @RequiresPermission(Manifest.permission.INSTALL_PACKAGES)
isPrivilegedApp()2669     public boolean isPrivilegedApp() {
2670         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
2671     }
2672 
2673     /** @hide */
isRequiredForSystemUser()2674     public boolean isRequiredForSystemUser() {
2675         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
2676     }
2677 
2678     /** @hide */
isStaticSharedLibrary()2679     public boolean isStaticSharedLibrary() {
2680         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
2681     }
2682 
2683     /** @hide */
2684     @TestApi
isSystemApp()2685     public boolean isSystemApp() {
2686         return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
2687     }
2688 
2689     /** @hide */
isUpdatedSystemApp()2690     public boolean isUpdatedSystemApp() {
2691         return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
2692     }
2693 
2694     /**
2695      * True if the application is pre-installed on the vendor partition of the system image.
2696      * @hide
2697      */
2698     @SystemApi
isVendor()2699     public boolean isVendor() {
2700         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0;
2701     }
2702 
2703     /**
2704      * True if the application is pre-installed on the product partition of the system image.
2705      * @hide
2706      */
2707     @SystemApi
isProduct()2708     public boolean isProduct() {
2709         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRODUCT) != 0;
2710     }
2711 
2712     /** @hide */
isSystemExt()2713     public boolean isSystemExt() {
2714         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_SYSTEM_EXT) != 0;
2715     }
2716 
2717     /** @hide */
isEmbeddedDexUsed()2718     public boolean isEmbeddedDexUsed() {
2719         return (privateFlags & PRIVATE_FLAG_USE_EMBEDDED_DEX) != 0;
2720     }
2721 
2722     /**
2723      * Returns whether or not this application was installed as a virtual preload.
2724      */
isVirtualPreload()2725     public boolean isVirtualPreload() {
2726         return (privateFlags & PRIVATE_FLAG_VIRTUAL_PRELOAD) != 0;
2727     }
2728 
2729     /**
2730      * Returns whether or not this application can be profiled by the shell user,
2731      * even when running on a device that is running in user mode.
2732      */
isProfileableByShell()2733     public boolean isProfileableByShell() {
2734         return (privateFlags & PRIVATE_FLAG_PROFILEABLE_BY_SHELL) != 0;
2735     }
2736 
2737     /**
2738      * Returns whether this application can be profiled, either by the shell user or the system.
2739      */
isProfileable()2740     public boolean isProfileable() {
2741         return (privateFlagsExt & PRIVATE_FLAG_EXT_PROFILEABLE) != 0;
2742     }
2743 
2744     /**
2745      * Returns whether attributions provided by the application are meant to be user-visible.
2746      * Defaults to false if application info is retrieved without
2747      * {@link PackageManager#GET_ATTRIBUTIONS_LONG}.
2748      */
areAttributionsUserVisible()2749     public boolean areAttributionsUserVisible() {
2750         return (privateFlagsExt & PRIVATE_FLAG_EXT_ATTRIBUTIONS_ARE_USER_VISIBLE) != 0;
2751     }
2752 
2753     /**
2754      * Returns true if the app has declared in its manifest that it wants its split APKs to be
2755      * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
2756      * @hide
2757      */
requestsIsolatedSplitLoading()2758     public boolean requestsIsolatedSplitLoading() {
2759         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
2760     }
2761 
2762     /**
2763      * Returns true if the package has declared in its manifest that it is a
2764      * runtime resource overlay.
2765      */
isResourceOverlay()2766     public boolean isResourceOverlay() {
2767         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_IS_RESOURCE_OVERLAY) != 0;
2768     }
2769 
2770     /**
2771      * Returns whether the app in the STOPPED state.
2772      * @hide
2773      */
isStopped()2774     public boolean isStopped() {
2775         return (flags & ApplicationInfo.FLAG_STOPPED) != 0;
2776     }
2777 
2778     /**
2779      * Returns whether the app was never launched (any process started) before.
2780      * @hide
2781      */
isNotLaunched()2782     public boolean isNotLaunched() {
2783         return (privateFlagsExt & ApplicationInfo.PRIVATE_FLAG_EXT_NOT_LAUNCHED) != 0;
2784     }
2785 
2786     /**
2787      * Checks if a changeId is enabled for the current user
2788      * @param changeId The changeId to verify
2789      * @return True of the changeId is enabled
2790      * @hide
2791      */
isChangeEnabled(long changeId)2792     public boolean isChangeEnabled(long changeId) {
2793         return CompatChanges.isChangeEnabled(changeId, packageName,
2794                 UserHandle.getUserHandleForUid(uid));
2795     }
2796 
2797     /**
2798      * @return whether the app has requested exemption from the foreground service restrictions.
2799      * This does not take any affect for now.
2800      * @hide
2801      */
2802     @TestApi
hasRequestForegroundServiceExemption()2803     public boolean hasRequestForegroundServiceExemption() {
2804         return (privateFlagsExt
2805                 & ApplicationInfo.PRIVATE_FLAG_EXT_REQUEST_FOREGROUND_SERVICE_EXEMPTION) != 0;
2806     }
2807 
2808     /**
2809      * Returns whether the application will use the {@link android.window.OnBackInvokedCallback}
2810      * navigation system instead of the {@link android.view.KeyEvent#KEYCODE_BACK} and related
2811      * callbacks.
2812      *
2813      * @hide
2814      */
2815     @TestApi
isOnBackInvokedCallbackEnabled()2816     public boolean isOnBackInvokedCallbackEnabled() {
2817         return ((privateFlagsExt & PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK)) != 0;
2818     }
2819 
2820     /**
2821      * @hide
2822      */
getApplicationInfo()2823     @Override public ApplicationInfo getApplicationInfo() {
2824         return this;
2825     }
2826 
2827     /**
2828      * Return all the APK paths that may be required to load this application, including all
2829      * splits, shared libraries, and resource overlays.
2830      * @hide
2831      */
getAllApkPaths()2832     public String[] getAllApkPaths() {
2833         final String[][] inputLists = {
2834                 splitSourceDirs, sharedLibraryFiles, resourceDirs, overlayPaths
2835         };
2836         final List<String> output = new ArrayList<>(10);
2837         if (sourceDir != null) {
2838             output.add(sourceDir);
2839         }
2840         for (String[] inputList : inputLists) {
2841             if (inputList != null) {
2842                 for (String input : inputList) {
2843                     output.add(input);
2844                 }
2845             }
2846         }
2847         return output.toArray(new String[output.size()]);
2848     }
2849 
setCodePath(String codePath)2850     /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
setBaseCodePath(String baseCodePath)2851     /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
setSplitCodePaths(String[] splitCodePaths)2852     /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
setResourcePath(String resourcePath)2853     /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
setBaseResourcePath(String baseResourcePath)2854     /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
setSplitResourcePaths(String[] splitResourcePaths)2855     /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
setGwpAsanMode(@wpAsanMode int value)2856     /** {@hide} */ public void setGwpAsanMode(@GwpAsanMode int value) { gwpAsanMode = value; }
setMemtagMode(@emtagMode int value)2857     /** {@hide} */ public void setMemtagMode(@MemtagMode int value) { memtagMode = value; }
setNativeHeapZeroInitialized(@ativeHeapZeroInitialized int value)2858     /** {@hide} */ public void setNativeHeapZeroInitialized(@NativeHeapZeroInitialized int value) {
2859         nativeHeapZeroInitialized = value;
2860     }
2861     /** {@hide} */
setRequestRawExternalStorageAccess(@ullable Boolean value)2862     public void setRequestRawExternalStorageAccess(@Nullable Boolean value) {
2863         requestRawExternalStorageAccess = value;
2864     }
2865 
2866     /** {@hide} */
setPageSizeAppCompatFlags(@ageSizeAppCompatFlags int value)2867     public void setPageSizeAppCompatFlags(@PageSizeAppCompatFlags int value) {
2868         mPageSizeAppCompatFlags |= value;
2869     }
2870 
2871     /**
2872      * Replaces {@link #mAppClassNamesByProcess}. This takes over the ownership of the passed map.
2873      * Do not modify the argument at the callsite.
2874      * {@hide}
2875      */
setAppClassNamesByProcess(@ullable ArrayMap<String, String> value)2876     public void setAppClassNamesByProcess(@Nullable ArrayMap<String, String> value) {
2877         if (ArrayUtils.size(value) == 0) {
2878             mAppClassNamesByProcess = null;
2879         } else {
2880             mAppClassNamesByProcess = value;
2881         }
2882     }
2883 
2884     /** {@hide} */
2885     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
getCodePath()2886     public String getCodePath() { return scanSourceDir; }
getBaseCodePath()2887     /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
getSplitCodePaths()2888     /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
getResourcePath()2889     /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
2890     /** {@hide} */
2891     @UnsupportedAppUsage
getBaseResourcePath()2892     public String getBaseResourcePath() { return publicSourceDir; }
getSplitResourcePaths()2893     /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
2894     @GwpAsanMode
getGwpAsanMode()2895     public int getGwpAsanMode() { return gwpAsanMode; }
2896 
2897     /**
2898      * Returns whether the application has requested Memtag to be enabled, disabled, or left
2899      * unspecified. Processes can override this setting.
2900      */
2901     @MemtagMode
getMemtagMode()2902     public int getMemtagMode() {
2903         return memtagMode;
2904     }
2905 
2906     /**
2907      * Returns whether the application has requested automatic zero-initialization of native heap
2908      * memory allocations to be enabled or disabled.
2909      */
2910     @NativeHeapZeroInitialized
getNativeHeapZeroInitialized()2911     public int getNativeHeapZeroInitialized() {
2912         return nativeHeapZeroInitialized;
2913     }
2914 
2915     /**
2916      * Return the application class name defined in the manifest. The class name set in the
2917      * <processes> tag for this process, then return it. Otherwise it'll return the class
2918      * name set in the <application> tag. If neither is set, it'll return null.
2919      * @hide
2920      */
2921     @Nullable
getCustomApplicationClassNameForProcess(String processName)2922     public String getCustomApplicationClassNameForProcess(String processName) {
2923         if (mAppClassNamesByProcess != null) {
2924             String byProcess = mAppClassNamesByProcess.get(processName);
2925             if (byProcess != null) {
2926                 return byProcess;
2927             }
2928         }
2929         return className;
2930     }
2931 
setLocaleConfigRes(int value)2932     /** @hide */ public void setLocaleConfigRes(int value) { localeConfigRes = value; }
2933 
2934     /**
2935      * Return the resource id pointing to the resource file that provides the application's locales
2936      * configuration.
2937      *
2938      * @hide
2939      */
getLocaleConfigRes()2940     public int getLocaleConfigRes() {
2941         return localeConfigRes;
2942     }
2943 
2944     /**
2945      *  List of all shared libraries this application is linked against. This
2946      *  list will only be set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
2947      *  PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving the structure.
2948      *
2949      *  NOTE: the list also contains the result of {@link #getOptionalSharedLibraryInfos}.
2950      *
2951      * @hide
2952      */
2953     @NonNull
2954     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
getSharedLibraryInfos()2955     public List<SharedLibraryInfo> getSharedLibraryInfos() {
2956         if (sharedLibraryInfos == null) {
2957             return Collections.EMPTY_LIST;
2958         }
2959         return sharedLibraryInfos;
2960     }
2961 
2962     /**
2963      *  List of all shared libraries this application is optionally linked against. This
2964      *  list will only be set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
2965      *  PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving the structure.
2966      *
2967      * @hide
2968      */
2969     @NonNull
2970     @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
2971     @FlaggedApi(Flags.FLAG_SDK_LIB_INDEPENDENCE)
getOptionalSharedLibraryInfos()2972     public List<SharedLibraryInfo> getOptionalSharedLibraryInfos() {
2973         if (optionalSharedLibraryInfos == null) {
2974             return Collections.EMPTY_LIST;
2975         }
2976         return optionalSharedLibraryInfos;
2977     }
2978 
2979     /**
2980      * Gets the trusted host certificate digests of apps that are allowed to embed activities of
2981      * this application. The digests are computed using the SHA-256 digest algorithm.
2982      * @see android.R.attr#knownActivityEmbeddingCerts
2983      */
2984     @NonNull
getKnownActivityEmbeddingCerts()2985     public Set<String> getKnownActivityEmbeddingCerts() {
2986         return mKnownActivityEmbeddingCerts == null ? Collections.emptySet()
2987                 : mKnownActivityEmbeddingCerts;
2988     }
2989 
2990     /**
2991      * Sets the trusted host certificates of apps that are allowed to embed activities of this
2992      * application.
2993      * @see #getKnownActivityEmbeddingCerts()
2994      * @hide
2995      */
setKnownActivityEmbeddingCerts(@onNull Set<String> knownActivityEmbeddingCerts)2996     public void setKnownActivityEmbeddingCerts(@NonNull Set<String> knownActivityEmbeddingCerts) {
2997         // Convert the provided digest to upper case for consistent Set membership
2998         // checks when verifying the signing certificate digests of requesting apps.
2999         mKnownActivityEmbeddingCerts = new ArraySet<>();
3000         for (String knownCert : knownActivityEmbeddingCerts) {
3001             mKnownActivityEmbeddingCerts.add(knownCert.toUpperCase(Locale.US));
3002         }
3003     }
3004 
3005     /**
3006      * Sets whether the application will use the {@link android.window.OnBackInvokedCallback}
3007      * navigation system instead of the {@link android.view.KeyEvent#KEYCODE_BACK} and related
3008      * callbacks. Intended to be used from tests only.
3009      *
3010      * @see #isOnBackInvokedCallbackEnabled()
3011      * @hide
3012      */
3013     @TestApi
setEnableOnBackInvokedCallback(boolean isEnable)3014     public void setEnableOnBackInvokedCallback(boolean isEnable) {
3015         if (isEnable) {
3016             privateFlagsExt |= PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK;
3017         } else {
3018             privateFlagsExt &= ~PRIVATE_FLAG_EXT_ENABLE_ON_BACK_INVOKED_CALLBACK;
3019         }
3020     }
3021 }
3022