ApplicationInfo.java revision aa1a911d9a0f797748b001c41bd8df2f517b318c
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
17package android.content.pm;
18
19import static android.os.Build.VERSION_CODES.DONUT;
20
21import android.annotation.IntDef;
22import android.annotation.Nullable;
23import android.annotation.SystemApi;
24import android.annotation.TestApi;
25import android.content.Context;
26import android.content.pm.PackageManager.NameNotFoundException;
27import android.content.res.Resources;
28import android.graphics.drawable.Drawable;
29import android.os.Build;
30import android.os.Environment;
31import android.os.Parcel;
32import android.os.Parcelable;
33import android.os.UserHandle;
34import android.os.storage.StorageManager;
35import android.text.TextUtils;
36import android.util.Printer;
37import android.util.SparseArray;
38import android.util.proto.ProtoOutputStream;
39
40import com.android.internal.util.ArrayUtils;
41import com.android.server.SystemConfig;
42
43import java.lang.annotation.Retention;
44import java.lang.annotation.RetentionPolicy;
45import java.text.Collator;
46import java.util.Arrays;
47import java.util.Comparator;
48import java.util.Objects;
49import java.util.UUID;
50
51/**
52 * Information you can retrieve about a particular application.  This
53 * corresponds to information collected from the AndroidManifest.xml's
54 * <application> tag.
55 */
56public class ApplicationInfo extends PackageItemInfo implements Parcelable {
57
58    /**
59     * Default task affinity of all activities in this application. See
60     * {@link ActivityInfo#taskAffinity} for more information.  This comes
61     * from the "taskAffinity" attribute.
62     */
63    public String taskAffinity;
64
65    /**
66     * Optional name of a permission required to be able to access this
67     * application's components.  From the "permission" attribute.
68     */
69    public String permission;
70
71    /**
72     * The name of the process this application should run in.  From the
73     * "process" attribute or, if not set, the same as
74     * <var>packageName</var>.
75     */
76    public String processName;
77
78    /**
79     * Class implementing the Application object.  From the "class"
80     * attribute.
81     */
82    public String className;
83
84    /**
85     * A style resource identifier (in the package's resources) of the
86     * description of an application.  From the "description" attribute
87     * or, if not set, 0.
88     */
89    public int descriptionRes;
90
91    /**
92     * A style resource identifier (in the package's resources) of the
93     * default visual theme of the application.  From the "theme" attribute
94     * or, if not set, 0.
95     */
96    public int theme;
97
98    /**
99     * Class implementing the Application's manage space
100     * functionality.  From the "manageSpaceActivity"
101     * attribute. This is an optional attribute and will be null if
102     * applications don't specify it in their manifest
103     */
104    public String manageSpaceActivityName;
105
106    /**
107     * Class implementing the Application's backup functionality.  From
108     * the "backupAgent" attribute.  This is an optional attribute and
109     * will be null if the application does not specify it in its manifest.
110     *
111     * <p>If android:allowBackup is set to false, this attribute is ignored.
112     */
113    public String backupAgentName;
114
115    /**
116     * An optional attribute that indicates the app supports automatic backup of app data.
117     * <p>0 is the default and means the app's entire data folder + managed external storage will
118     * be backed up;
119     * Any negative value indicates the app does not support full-data backup, though it may still
120     * want to participate via the traditional key/value backup API;
121     * A positive number specifies an xml resource in which the application has defined its backup
122     * include/exclude criteria.
123     * <p>If android:allowBackup is set to false, this attribute is ignored.
124     *
125     * @see android.content.Context#getNoBackupFilesDir()
126     * @see #FLAG_ALLOW_BACKUP
127     *
128     * @hide
129     */
130    public int fullBackupContent = 0;
131
132    /**
133     * The default extra UI options for activities in this application.
134     * Set from the {@link android.R.attr#uiOptions} attribute in the
135     * activity's manifest.
136     */
137    public int uiOptions = 0;
138
139    /**
140     * Value for {@link #flags}: if set, this application is installed in the
141     * device's system image.
142     */
143    public static final int FLAG_SYSTEM = 1<<0;
144
145    /**
146     * Value for {@link #flags}: set to true if this application would like to
147     * allow debugging of its
148     * code, even when installed on a non-development system.  Comes
149     * from {@link android.R.styleable#AndroidManifestApplication_debuggable
150     * android:debuggable} of the &lt;application&gt; tag.
151     */
152    public static final int FLAG_DEBUGGABLE = 1<<1;
153
154    /**
155     * Value for {@link #flags}: set to true if this application has code
156     * associated with it.  Comes
157     * from {@link android.R.styleable#AndroidManifestApplication_hasCode
158     * android:hasCode} of the &lt;application&gt; tag.
159     */
160    public static final int FLAG_HAS_CODE = 1<<2;
161
162    /**
163     * Value for {@link #flags}: set to true if this application is persistent.
164     * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
165     * android:persistent} of the &lt;application&gt; tag.
166     */
167    public static final int FLAG_PERSISTENT = 1<<3;
168
169    /**
170     * Value for {@link #flags}: set to true if this application holds the
171     * {@link android.Manifest.permission#FACTORY_TEST} permission and the
172     * device is running in factory test mode.
173     */
174    public static final int FLAG_FACTORY_TEST = 1<<4;
175
176    /**
177     * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
178     * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
179     * android:allowTaskReparenting} of the &lt;application&gt; tag.
180     */
181    public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
182
183    /**
184     * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
185     * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
186     * android:allowClearUserData} of the &lt;application&gt; tag.
187     */
188    public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
189
190    /**
191     * Value for {@link #flags}: this is set if this application has been
192     * installed as an update to a built-in system application.
193     */
194    public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
195
196    /**
197     * Value for {@link #flags}: this is set if the application has specified
198     * {@link android.R.styleable#AndroidManifestApplication_testOnly
199     * android:testOnly} to be true.
200     */
201    public static final int FLAG_TEST_ONLY = 1<<8;
202
203    /**
204     * Value for {@link #flags}: true when the application's window can be
205     * reduced in size for smaller screens.  Corresponds to
206     * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
207     * android:smallScreens}.
208     */
209    public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
210
211    /**
212     * Value for {@link #flags}: true when the application's window can be
213     * displayed on normal screens.  Corresponds to
214     * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
215     * android:normalScreens}.
216     */
217    public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
218
219    /**
220     * Value for {@link #flags}: true when the application's window can be
221     * increased in size for larger screens.  Corresponds to
222     * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
223     * android:largeScreens}.
224     */
225    public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
226
227    /**
228     * Value for {@link #flags}: true when the application knows how to adjust
229     * its UI for different screen sizes.  Corresponds to
230     * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
231     * android:resizeable}.
232     */
233    public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
234
235    /**
236     * Value for {@link #flags}: true when the application knows how to
237     * accomodate different screen densities.  Corresponds to
238     * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
239     * android:anyDensity}.
240     */
241    public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
242
243    /**
244     * Value for {@link #flags}: set to true if this application would like to
245     * request the VM to operate under the safe mode. Comes from
246     * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
247     * android:vmSafeMode} of the &lt;application&gt; tag.
248     */
249    public static final int FLAG_VM_SAFE_MODE = 1<<14;
250
251    /**
252     * Value for {@link #flags}: set to <code>false</code> if the application does not wish
253     * to permit any OS-driven backups of its data; <code>true</code> otherwise.
254     *
255     * <p>Comes from the
256     * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
257     * attribute of the &lt;application&gt; tag.
258     */
259    public static final int FLAG_ALLOW_BACKUP = 1<<15;
260
261    /**
262     * Value for {@link #flags}: set to <code>false</code> if the application must be kept
263     * in memory following a full-system restore operation; <code>true</code> otherwise.
264     * Ordinarily, during a full system restore operation each application is shut down
265     * following execution of its agent's onRestore() method.  Setting this attribute to
266     * <code>false</code> prevents this.  Most applications will not need to set this attribute.
267     *
268     * <p>If
269     * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
270     * is set to <code>false</code> or no
271     * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
272     * is specified, this flag will be ignored.
273     *
274     * <p>Comes from the
275     * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
276     * attribute of the &lt;application&gt; tag.
277     */
278    public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
279
280    /**
281     * Value for {@link #flags}: Set to <code>true</code> if the application's backup
282     * agent claims to be able to handle restore data even "from the future,"
283     * i.e. from versions of the application with a versionCode greater than
284     * the one currently installed on the device.  <i>Use with caution!</i>  By default
285     * this attribute is <code>false</code> and the Backup Manager will ensure that data
286     * from "future" versions of the application are never supplied during a restore operation.
287     *
288     * <p>If
289     * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
290     * is set to <code>false</code> or no
291     * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
292     * is specified, this flag will be ignored.
293     *
294     * <p>Comes from the
295     * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
296     * attribute of the &lt;application&gt; tag.
297     */
298    public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
299
300    /**
301     * Value for {@link #flags}: Set to true if the application is
302     * currently installed on external/removable/unprotected storage.  Such
303     * applications may not be available if their storage is not currently
304     * mounted.  When the storage it is on is not available, it will look like
305     * the application has been uninstalled (its .apk is no longer available)
306     * but its persistent data is not removed.
307     */
308    public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
309
310    /**
311     * Value for {@link #flags}: true when the application's window can be
312     * increased in size for extra large screens.  Corresponds to
313     * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
314     * android:xlargeScreens}.
315     */
316    public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
317
318    /**
319     * Value for {@link #flags}: true when the application has requested a
320     * large heap for its processes.  Corresponds to
321     * {@link android.R.styleable#AndroidManifestApplication_largeHeap
322     * android:largeHeap}.
323     */
324    public static final int FLAG_LARGE_HEAP = 1<<20;
325
326    /**
327     * Value for {@link #flags}: true if this application's package is in
328     * the stopped state.
329     */
330    public static final int FLAG_STOPPED = 1<<21;
331
332    /**
333     * Value for {@link #flags}: true  when the application is willing to support
334     * RTL (right to left). All activities will inherit this value.
335     *
336     * Set from the {@link android.R.attr#supportsRtl} attribute in the
337     * activity's manifest.
338     *
339     * Default value is false (no support for RTL).
340     */
341    public static final int FLAG_SUPPORTS_RTL = 1<<22;
342
343    /**
344     * Value for {@link #flags}: true if the application is currently
345     * installed for the calling user.
346     */
347    public static final int FLAG_INSTALLED = 1<<23;
348
349    /**
350     * Value for {@link #flags}: true if the application only has its
351     * data installed; the application package itself does not currently
352     * exist on the device.
353     */
354    public static final int FLAG_IS_DATA_ONLY = 1<<24;
355
356    /**
357     * Value for {@link #flags}: true if the application was declared to be a
358     * game, or false if it is a non-game application.
359     *
360     * @deprecated use {@link #CATEGORY_GAME} instead.
361     */
362    @Deprecated
363    public static final int FLAG_IS_GAME = 1<<25;
364
365    /**
366     * Value for {@link #flags}: {@code true} if the application asks that only
367     * full-data streaming backups of its data be performed even though it defines
368     * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
369     * indicates that the app will manage its backed-up data via incremental
370     * key/value updates.
371     */
372    public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
373
374    /**
375     * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
376     * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
377     * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
378     * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
379     * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
380     * traffic. Third-party libraries are encouraged to honor this flag as well.
381     *
382     * <p>NOTE: {@code WebView} honors this flag for applications targeting API level 26 and up.
383     *
384     * <p>This flag is ignored on Android N and above if an Android Network Security Config is
385     * present.
386     *
387     * <p>This flag comes from
388     * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
389     * android:usesCleartextTraffic} of the &lt;application&gt; tag.
390     */
391    public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
392
393    /**
394     * When set installer extracts native libs from .apk files.
395     */
396    public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
397
398    /**
399     * Value for {@link #flags}: {@code true} when the application's rendering
400     * should be hardware accelerated.
401     */
402    public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
403
404    /**
405     * Value for {@link #flags}: true if this application's package is in
406     * the suspended state.
407     */
408    public static final int FLAG_SUSPENDED = 1<<30;
409
410    /**
411     * Value for {@link #flags}: true if code from this application will need to be
412     * loaded into other applications' processes. On devices that support multiple
413     * instruction sets, this implies the code might be loaded into a process that's
414     * using any of the devices supported instruction sets.
415     *
416     * <p> The system might treat such applications specially, for eg., by
417     * extracting the application's native libraries for all supported instruction
418     * sets or by compiling the application's dex code for all supported instruction
419     * sets.
420     */
421    public static final int FLAG_MULTIARCH  = 1 << 31;
422
423    /**
424     * Flags associated with the application.  Any combination of
425     * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
426     * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
427     * {@link #FLAG_ALLOW_TASK_REPARENTING}
428     * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
429     * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
430     * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
431     * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
432     * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
433     * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
434     * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
435     * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
436     * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
437     * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
438     * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
439     * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
440     * {@link #FLAG_MULTIARCH}.
441     */
442    public int flags = 0;
443
444    /**
445     * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
446     * most purposes is considered as not installed.
447     * {@hide}
448     */
449    public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
450
451    /**
452     * Value for {@link #privateFlags}: set to <code>true</code> if the application
453     * has reported that it is heavy-weight, and thus can not participate in
454     * the normal application lifecycle.
455     *
456     * <p>Comes from the
457     * android.R.styleable#AndroidManifestApplication_cantSaveState
458     * attribute of the &lt;application&gt; tag.
459     *
460     * {@hide}
461     */
462    public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
463
464    /**
465     * Value for {@link #privateFlags}: Set to true if the application has been
466     * installed using the forward lock option.
467     *
468     * NOTE: DO NOT CHANGE THIS VALUE!  It is saved in packages.xml.
469     *
470     * {@hide}
471     */
472    public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
473
474    /**
475     * Value for {@link #privateFlags}: set to {@code true} if the application
476     * is permitted to hold privileged permissions.
477     *
478     * {@hide}
479     */
480    public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
481
482    /**
483     * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
484     * with some data URI using HTTP or HTTPS with an associated VIEW action.
485     *
486     * {@hide}
487     */
488    public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
489
490    /**
491     * When set, the default data storage directory for this app is pointed at
492     * the device-protected location.
493     *
494     * @hide
495     */
496    public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
497
498    /**
499     * When set, assume that all components under the given app are direct boot
500     * aware, unless otherwise specified.
501     *
502     * @hide
503     */
504    public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
505
506    /**
507     * Value for {@link #privateFlags}: {@code true} if the application is installed
508     * as instant app.
509     *
510     * @hide
511     */
512    public static final int PRIVATE_FLAG_INSTANT = 1 << 7;
513
514    /**
515     * When set, at least one component inside this application is direct boot
516     * aware.
517     *
518     * @hide
519     */
520    public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
521
522
523    /**
524     * When set, signals that the application is required for the system user and should not be
525     * uninstalled.
526     *
527     * @hide
528     */
529    public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
530
531    /**
532     * When set, the application explicitly requested that its activities be resizeable by default.
533     * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
534     *
535     * @hide
536     */
537    public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE = 1 << 10;
538
539    /**
540     * When set, the application explicitly requested that its activities *not* be resizeable by
541     * default.
542     * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
543     *
544     * @hide
545     */
546    public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE = 1 << 11;
547
548    /**
549     * The application isn't requesting explicitly requesting for its activities to be resizeable or
550     * non-resizeable by default. So, we are making it activities resizeable by default based on the
551     * target SDK version of the app.
552     * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
553     *
554     * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
555     * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
556     * where certain pre-N apps are forced to the resizeable.
557     *
558     * @hide
559     */
560    public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION =
561            1 << 12;
562
563    /**
564     * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
565     * run full-data backup operations for the app even when it is in a
566     * foreground-equivalent run state.  Defaults to {@code false} if unspecified.
567     * @hide
568     */
569    public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 13;
570
571    /**
572     * Value for {@link #privateFlags}: {@code true} means this application
573     * contains a static shared library. Defaults to {@code false} if unspecified.
574     * @hide
575     */
576    public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 14;
577
578    /**
579     * Value for {@link #privateFlags}: When set, the application will only have its splits loaded
580     * if they are required to load a component. Splits can be loaded on demand using the
581     * {@link Context#createContextForSplit(String)} API.
582     * @hide
583     */
584    public static final int PRIVATE_FLAG_ISOLATED_SPLIT_LOADING = 1 << 15;
585
586    /**
587     * Value for {@link #privateFlags}: When set, the application was installed as
588     * a virtual preload.
589     * @hide
590     */
591    public static final int PRIVATE_FLAG_VIRTUAL_PRELOAD = 1 << 16;
592
593    /**
594     * Value for {@link #privateFlags}: whether this app is pre-installed on the
595     * OEM partition of the system image.
596     * @hide
597     */
598    public static final int PRIVATE_FLAG_OEM = 1 << 17;
599
600    /**
601     * Value for {@link #privateFlags}: whether this app is pre-installed on the
602     * vendor partition of the system image.
603     * @hide
604     */
605    public static final int PRIVATE_FLAG_VENDOR = 1 << 18;
606
607    /**
608     * Value for {@link #privateFlags}: whether this app is pre-installed on the
609     * product partition of the system image.
610     * @hide
611     */
612    public static final int PRIVATE_FLAG_PRODUCT = 1 << 19;
613
614    /**
615     * Value for {@link #privateFlags}: whether this app is signed with the
616     * platform key.
617     * @hide
618     */
619    public static final int PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY = 1 << 20;
620
621    /** @hide */
622    @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
623            PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
624            PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION,
625            PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE,
626            PRIVATE_FLAG_BACKUP_IN_FOREGROUND,
627            PRIVATE_FLAG_CANT_SAVE_STATE,
628            PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE,
629            PRIVATE_FLAG_DIRECT_BOOT_AWARE,
630            PRIVATE_FLAG_FORWARD_LOCK,
631            PRIVATE_FLAG_HAS_DOMAIN_URLS,
632            PRIVATE_FLAG_HIDDEN,
633            PRIVATE_FLAG_INSTANT,
634            PRIVATE_FLAG_ISOLATED_SPLIT_LOADING,
635            PRIVATE_FLAG_OEM,
636            PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE,
637            PRIVATE_FLAG_PRIVILEGED,
638            PRIVATE_FLAG_PRODUCT,
639            PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER,
640            PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY,
641            PRIVATE_FLAG_STATIC_SHARED_LIBRARY,
642            PRIVATE_FLAG_VENDOR,
643            PRIVATE_FLAG_VIRTUAL_PRELOAD,
644    })
645    @Retention(RetentionPolicy.SOURCE)
646    public @interface ApplicationInfoPrivateFlags {}
647
648    /**
649     * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
650     * @hide
651     */
652    public @ApplicationInfoPrivateFlags int privateFlags;
653
654    /**
655     * @hide
656     */
657    public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
658
659    /**
660     * The required smallest screen width the application can run on.  If 0,
661     * nothing has been specified.  Comes from
662     * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
663     * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
664     */
665    public int requiresSmallestWidthDp = 0;
666
667    /**
668     * The maximum smallest screen width the application is designed for.  If 0,
669     * nothing has been specified.  Comes from
670     * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
671     * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
672     */
673    public int compatibleWidthLimitDp = 0;
674
675    /**
676     * The maximum smallest screen width the application will work on.  If 0,
677     * nothing has been specified.  Comes from
678     * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
679     * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
680     */
681    public int largestWidthLimitDp = 0;
682
683    /**
684     * Value indicating the maximum aspect ratio the application supports.
685     * <p>
686     * 0 means unset.
687     * @See {@link android.R.attr#maxAspectRatio}.
688     * @hide
689     */
690    public float maxAspectRatio;
691
692    /** @removed */
693    @Deprecated
694    public String volumeUuid;
695
696    /**
697     * UUID of the storage volume on which this application is being hosted. For
698     * apps hosted on the default internal storage at
699     * {@link Environment#getDataDirectory()}, the UUID value is
700     * {@link StorageManager#UUID_DEFAULT}.
701     */
702    public UUID storageUuid;
703
704    /** {@hide} */
705    public String scanSourceDir;
706    /** {@hide} */
707    public String scanPublicSourceDir;
708
709    /**
710     * Full path to the base APK for this application.
711     */
712    public String sourceDir;
713
714    /**
715     * Full path to the publicly available parts of {@link #sourceDir},
716     * including resources and manifest. This may be different from
717     * {@link #sourceDir} if an application is forward locked.
718     */
719    public String publicSourceDir;
720
721    /**
722     * The names of all installed split APKs, ordered lexicographically.
723     */
724    public String[] splitNames;
725
726    /**
727     * Full paths to zero or more split APKs, indexed by the same order as {@link #splitNames}.
728     */
729    public String[] splitSourceDirs;
730
731    /**
732     * Full path to the publicly available parts of {@link #splitSourceDirs},
733     * including resources and manifest. This may be different from
734     * {@link #splitSourceDirs} if an application is forward locked.
735     *
736     * @see #splitSourceDirs
737     */
738    public String[] splitPublicSourceDirs;
739
740    /**
741     * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
742     *
743     * Available since platform version O.
744     *
745     * Only populated if the application opts in to isolated split loading via the
746     * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
747     * AndroidManifest.xml.
748     *
749     * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
750     * and {@link #splitPublicSourceDirs} arrays.
751     * Each key represents a split and its value is an array of splits. The first element of this
752     * array is the parent split, and the rest are configuration splits. These configuration splits
753     * have no dependencies themselves.
754     * Cycles do not exist because they are illegal and screened for during installation.
755     *
756     * May be null if no splits are installed, or if no dependencies exist between them.
757     *
758     * NOTE: Any change to the way split dependencies are stored must update the logic that
759     *       creates the class loader context for dexopt (DexoptUtils#getClassLoaderContexts).
760     *
761     * @hide
762     */
763    public SparseArray<int[]> splitDependencies;
764
765    /**
766     * Full paths to the locations of extra resource packages (runtime overlays)
767     * this application uses. This field is only used if there are extra resource
768     * packages, otherwise it is null.
769     *
770     * {@hide}
771     */
772    public String[] resourceDirs;
773
774    /**
775     * String retrieved from the seinfo tag found in selinux policy. This value can be set through
776     * the mac_permissions.xml policy construct. This value is used for setting an SELinux security
777     * context on the process as well as its data directory.
778     *
779     * {@hide}
780     */
781    public String seInfo;
782
783    /**
784     * The seinfo tag generated per-user. This value may change based upon the
785     * user's configuration. For example, when an instant app is installed for
786     * a user. It is an error if this field is ever {@code null} when trying to
787     * start a new process.
788     * <p>NOTE: We need to separate this out because we modify per-user values
789     * multiple times. This needs to be refactored since we're performing more
790     * work than necessary and these values should only be set once. When that
791     * happens, we can merge the per-user value with the seInfo state above.
792     *
793     * {@hide}
794     */
795    public String seInfoUser;
796
797    /**
798     * Paths to all shared libraries this application is linked against.  This
799     * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
800     * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
801     * the structure.
802     */
803    public String[] sharedLibraryFiles;
804
805    /**
806     * Full path to the default directory assigned to the package for its
807     * persistent data.
808     */
809    public String dataDir;
810
811    /**
812     * Full path to the device-protected directory assigned to the package for
813     * its persistent data.
814     *
815     * @see Context#createDeviceProtectedStorageContext()
816     */
817    public String deviceProtectedDataDir;
818
819    /**
820     * Full path to the credential-protected directory assigned to the package
821     * for its persistent data.
822     *
823     * @hide
824     */
825    @SystemApi
826    public String credentialProtectedDataDir;
827
828    /**
829     * Full path to the directory where native JNI libraries are stored.
830     */
831    public String nativeLibraryDir;
832
833    /**
834     * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
835     * are stored, if present.
836     *
837     * The main reason this exists is for bundled multi-arch apps, where
838     * it's not trivial to calculate the location of libs for the secondary abi
839     * given the location of the primary.
840     *
841     * TODO: Change the layout of bundled installs so that we can use
842     * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
843     * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
844     * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
845     *
846     * @hide
847     */
848    public String secondaryNativeLibraryDir;
849
850    /**
851     * The root path where unpacked native libraries are stored.
852     * <p>
853     * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
854     * placed in ISA-specific subdirectories under this path, otherwise the
855     * libraries are placed directly at this path.
856     *
857     * @hide
858     */
859    public String nativeLibraryRootDir;
860
861    /**
862     * Flag indicating that ISA must be appended to
863     * {@link #nativeLibraryRootDir} to be useful.
864     *
865     * @hide
866     */
867    public boolean nativeLibraryRootRequiresIsa;
868
869    /**
870     * The primary ABI that this application requires, This is inferred from the ABIs
871     * of the native JNI libraries the application bundles. Will be {@code null}
872     * if this application does not require any particular ABI.
873     *
874     * If non-null, the application will always be launched with this ABI.
875     *
876     * {@hide}
877     */
878    public String primaryCpuAbi;
879
880    /**
881     * The secondary ABI for this application. Might be non-null for multi-arch
882     * installs. The application itself never uses this ABI, but other applications that
883     * use its code might.
884     *
885     * {@hide}
886     */
887    public String secondaryCpuAbi;
888
889    /**
890     * The kernel user-ID that has been assigned to this application;
891     * currently this is not a unique ID (multiple applications can have
892     * the same uid).
893     */
894    public int uid;
895
896    /**
897     * The minimum SDK version this application can run on. It will not run
898     * on earlier versions.
899     */
900    public int minSdkVersion;
901
902    /**
903     * The minimum SDK version this application targets.  It may run on earlier
904     * versions, but it knows how to work with any new behavior added at this
905     * version.  Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
906     * if this is a development build and the app is targeting that.  You should
907     * compare that this number is >= the SDK version number at which your
908     * behavior was introduced.
909     */
910    public int targetSdkVersion;
911
912    /**
913     * The app's declared version code.
914     * @hide
915     */
916    public long longVersionCode;
917
918    /**
919     * An integer representation of the app's declared version code. This is being left in place as
920     * some apps were using reflection to access it before the move to long in
921     * {@link android.os.Build.VERSION_CODES#P}
922     * @deprecated Use {@link #longVersionCode} instead.
923     * @hide
924     */
925    @Deprecated
926    public int versionCode;
927
928    /**
929     * The user-visible SDK version (ex. 26) of the framework against which the application claims
930     * to have been compiled, or {@code 0} if not specified.
931     * <p>
932     * This property is the compile-time equivalent of
933     * {@link android.os.Build.VERSION#CODENAME Build.VERSION.SDK_INT}.
934     *
935     * @hide For platform use only; we don't expect developers to need to read this value.
936     */
937    public int compileSdkVersion;
938
939    /**
940     * The development codename (ex. "O", "REL") of the framework against which the application
941     * claims to have been compiled, or {@code null} if not specified.
942     * <p>
943     * This property is the compile-time equivalent of
944     * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
945     *
946     * @hide For platform use only; we don't expect developers to need to read this value.
947     */
948    @Nullable
949    public String compileSdkVersionCodename;
950
951    /**
952     * When false, indicates that all components within this application are
953     * considered disabled, regardless of their individually set enabled status.
954     */
955    public boolean enabled = true;
956
957    /**
958     * For convenient access to the current enabled setting of this app.
959     * @hide
960     */
961    public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
962
963    /**
964     * For convenient access to package's install location.
965     * @hide
966     */
967    public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
968
969    /**
970     * Resource file providing the application's Network Security Config.
971     * @hide
972     */
973    public int networkSecurityConfigRes;
974
975    /**
976     * Version of the sandbox the application wants to run in.
977     * @hide
978     */
979    @SystemApi
980    public int targetSandboxVersion;
981
982    /**
983     * The factory of this package, as specified by the &lt;manifest&gt;
984     * tag's {@link android.R.styleable#AndroidManifestApplication_appComponentFactory}
985     * attribute.
986     */
987    public String appComponentFactory;
988
989    /**
990     * The category of this app. Categories are used to cluster multiple apps
991     * together into meaningful groups, such as when summarizing battery,
992     * network, or disk usage. Apps should only define this value when they fit
993     * well into one of the specific categories.
994     * <p>
995     * Set from the {@link android.R.attr#appCategory} attribute in the
996     * manifest. If the manifest doesn't define a category, this value may have
997     * been provided by the installer via
998     * {@link PackageManager#setApplicationCategoryHint(String, int)}.
999     */
1000    public @Category int category = CATEGORY_UNDEFINED;
1001
1002    /** {@hide} */
1003    @IntDef(prefix = { "CATEGORY_" }, value = {
1004            CATEGORY_UNDEFINED,
1005            CATEGORY_GAME,
1006            CATEGORY_AUDIO,
1007            CATEGORY_VIDEO,
1008            CATEGORY_IMAGE,
1009            CATEGORY_SOCIAL,
1010            CATEGORY_NEWS,
1011            CATEGORY_MAPS,
1012            CATEGORY_PRODUCTIVITY
1013    })
1014    @Retention(RetentionPolicy.SOURCE)
1015    public @interface Category {
1016    }
1017
1018    /**
1019     * Value when category is undefined.
1020     *
1021     * @see #category
1022     */
1023    public static final int CATEGORY_UNDEFINED = -1;
1024
1025    /**
1026     * Category for apps which are primarily games.
1027     *
1028     * @see #category
1029     */
1030    public static final int CATEGORY_GAME = 0;
1031
1032    /**
1033     * Category for apps which primarily work with audio or music, such as music
1034     * players.
1035     *
1036     * @see #category
1037     */
1038    public static final int CATEGORY_AUDIO = 1;
1039
1040    /**
1041     * Category for apps which primarily work with video or movies, such as
1042     * streaming video apps.
1043     *
1044     * @see #category
1045     */
1046    public static final int CATEGORY_VIDEO = 2;
1047
1048    /**
1049     * Category for apps which primarily work with images or photos, such as
1050     * camera or gallery apps.
1051     *
1052     * @see #category
1053     */
1054    public static final int CATEGORY_IMAGE = 3;
1055
1056    /**
1057     * Category for apps which are primarily social apps, such as messaging,
1058     * communication, email, or social network apps.
1059     *
1060     * @see #category
1061     */
1062    public static final int CATEGORY_SOCIAL = 4;
1063
1064    /**
1065     * Category for apps which are primarily news apps, such as newspapers,
1066     * magazines, or sports apps.
1067     *
1068     * @see #category
1069     */
1070    public static final int CATEGORY_NEWS = 5;
1071
1072    /**
1073     * Category for apps which are primarily maps apps, such as navigation apps.
1074     *
1075     * @see #category
1076     */
1077    public static final int CATEGORY_MAPS = 6;
1078
1079    /**
1080     * Category for apps which are primarily productivity apps, such as cloud
1081     * storage or workplace apps.
1082     *
1083     * @see #category
1084     */
1085    public static final int CATEGORY_PRODUCTIVITY = 7;
1086
1087    /**
1088     * Return a concise, localized title for the given
1089     * {@link ApplicationInfo#category} value, or {@code null} for unknown
1090     * values such as {@link #CATEGORY_UNDEFINED}.
1091     *
1092     * @see #category
1093     */
1094    public static CharSequence getCategoryTitle(Context context, @Category int category) {
1095        switch (category) {
1096            case ApplicationInfo.CATEGORY_GAME:
1097                return context.getText(com.android.internal.R.string.app_category_game);
1098            case ApplicationInfo.CATEGORY_AUDIO:
1099                return context.getText(com.android.internal.R.string.app_category_audio);
1100            case ApplicationInfo.CATEGORY_VIDEO:
1101                return context.getText(com.android.internal.R.string.app_category_video);
1102            case ApplicationInfo.CATEGORY_IMAGE:
1103                return context.getText(com.android.internal.R.string.app_category_image);
1104            case ApplicationInfo.CATEGORY_SOCIAL:
1105                return context.getText(com.android.internal.R.string.app_category_social);
1106            case ApplicationInfo.CATEGORY_NEWS:
1107                return context.getText(com.android.internal.R.string.app_category_news);
1108            case ApplicationInfo.CATEGORY_MAPS:
1109                return context.getText(com.android.internal.R.string.app_category_maps);
1110            case ApplicationInfo.CATEGORY_PRODUCTIVITY:
1111                return context.getText(com.android.internal.R.string.app_category_productivity);
1112            default:
1113                return null;
1114        }
1115    }
1116
1117    /** @hide */
1118    public String classLoaderName;
1119
1120    /** @hide */
1121    public String[] splitClassLoaderNames;
1122
1123    /**
1124     * Represents the default policy. The actual policy used will depend on other properties of
1125     * the application, e.g. the target SDK version.
1126     * @hide
1127     */
1128    public static final int HIDDEN_API_ENFORCEMENT_DEFAULT = -1;
1129    /**
1130     * No API enforcement; the app can access the entire internal private API. Only for use by
1131     * system apps.
1132     * @hide
1133     */
1134    public static final int HIDDEN_API_ENFORCEMENT_NONE = 0;
1135    /**
1136     * No API enforcement, but enable the detection logic and warnings. Observed behaviour is the
1137     * same as {@link #HIDDEN_API_ENFORCEMENT_NONE} but you may see warnings in the log when APIs
1138     * are accessed.
1139     * @hide
1140     * */
1141    public static final int HIDDEN_API_ENFORCEMENT_JUST_WARN = 1;
1142    /**
1143     * Dark grey list enforcement. Enforces the dark grey and black lists
1144     * @hide
1145     */
1146    public static final int HIDDEN_API_ENFORCEMENT_DARK_GREY_AND_BLACK = 2;
1147    /**
1148     * Blacklist enforcement only.
1149     * @hide
1150     */
1151    public static final int HIDDEN_API_ENFORCEMENT_BLACK = 3;
1152
1153    private static final int HIDDEN_API_ENFORCEMENT_MAX = HIDDEN_API_ENFORCEMENT_BLACK;
1154
1155    /**
1156     * Values in this IntDef MUST be kept in sync with enum hiddenapi::EnforcementPolicy in
1157     * art/runtime/hidden_api.h
1158     * @hide
1159     */
1160    @IntDef(prefix = { "HIDDEN_API_ENFORCEMENT_" }, value = {
1161            HIDDEN_API_ENFORCEMENT_DEFAULT,
1162            HIDDEN_API_ENFORCEMENT_NONE,
1163            HIDDEN_API_ENFORCEMENT_JUST_WARN,
1164            HIDDEN_API_ENFORCEMENT_DARK_GREY_AND_BLACK,
1165            HIDDEN_API_ENFORCEMENT_BLACK,
1166    })
1167    @Retention(RetentionPolicy.SOURCE)
1168    public @interface HiddenApiEnforcementPolicy {}
1169
1170    /** @hide */
1171    public static boolean isValidHiddenApiEnforcementPolicy(int policy) {
1172        return policy >= HIDDEN_API_ENFORCEMENT_DEFAULT && policy <= HIDDEN_API_ENFORCEMENT_MAX;
1173    }
1174
1175    private int mHiddenApiPolicy = HIDDEN_API_ENFORCEMENT_DEFAULT;
1176
1177    public void dump(Printer pw, String prefix) {
1178        dump(pw, prefix, DUMP_FLAG_ALL);
1179    }
1180
1181    /** @hide */
1182    public void dump(Printer pw, String prefix, int dumpFlags) {
1183        super.dumpFront(pw, prefix);
1184        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && className != null) {
1185            pw.println(prefix + "className=" + className);
1186        }
1187        if (permission != null) {
1188            pw.println(prefix + "permission=" + permission);
1189        }
1190        pw.println(prefix + "processName=" + processName);
1191        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1192            pw.println(prefix + "taskAffinity=" + taskAffinity);
1193        }
1194        pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
1195                + " privateFlags=0x" + Integer.toHexString(privateFlags)
1196                + " theme=0x" + Integer.toHexString(theme));
1197        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1198            pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1199                    + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1200                    + " largestWidthLimitDp=" + largestWidthLimitDp);
1201        }
1202        pw.println(prefix + "sourceDir=" + sourceDir);
1203        if (!Objects.equals(sourceDir, publicSourceDir)) {
1204            pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1205        }
1206        if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1207            pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1208        }
1209        if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1210                && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1211            pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1212        }
1213        if (resourceDirs != null) {
1214            pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
1215        }
1216        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
1217            pw.println(prefix + "seinfo=" + seInfo);
1218            pw.println(prefix + "seinfoUser=" + seInfoUser);
1219        }
1220        pw.println(prefix + "dataDir=" + dataDir);
1221        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1222            pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1223            pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
1224            if (sharedLibraryFiles != null) {
1225                pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1226            }
1227        }
1228        if (classLoaderName != null) {
1229            pw.println(prefix + "classLoaderName=" + classLoaderName);
1230        }
1231        if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1232            pw.println(prefix + "splitClassLoaderNames=" + Arrays.toString(splitClassLoaderNames));
1233        }
1234
1235        pw.println(prefix + "enabled=" + enabled
1236                + " minSdkVersion=" + minSdkVersion
1237                + " targetSdkVersion=" + targetSdkVersion
1238                + " versionCode=" + longVersionCode
1239                + " targetSandboxVersion=" + targetSandboxVersion);
1240        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1241            if (manageSpaceActivityName != null) {
1242                pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1243            }
1244            if (descriptionRes != 0) {
1245                pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1246            }
1247            if (uiOptions != 0) {
1248                pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1249            }
1250            pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1251            if (fullBackupContent > 0) {
1252                pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1253            } else {
1254                pw.println(prefix + "fullBackupContent="
1255                        + (fullBackupContent < 0 ? "false" : "true"));
1256            }
1257            if (networkSecurityConfigRes != 0) {
1258                pw.println(prefix + "networkSecurityConfigRes=0x"
1259                        + Integer.toHexString(networkSecurityConfigRes));
1260            }
1261            if (category != CATEGORY_UNDEFINED) {
1262                pw.println(prefix + "category=" + category);
1263            }
1264            pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
1265        }
1266        super.dumpBack(pw, prefix);
1267    }
1268
1269    /** {@hide} */
1270    public void writeToProto(ProtoOutputStream proto, long fieldId, int dumpFlags) {
1271        long token = proto.start(fieldId);
1272        super.writeToProto(proto, ApplicationInfoProto.PACKAGE);
1273        proto.write(ApplicationInfoProto.PERMISSION, permission);
1274        proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
1275        proto.write(ApplicationInfoProto.UID, uid);
1276        proto.write(ApplicationInfoProto.FLAGS, flags);
1277        proto.write(ApplicationInfoProto.PRIVATE_FLAGS, privateFlags);
1278        proto.write(ApplicationInfoProto.THEME, theme);
1279        proto.write(ApplicationInfoProto.SOURCE_DIR, sourceDir);
1280        if (!Objects.equals(sourceDir, publicSourceDir)) {
1281            proto.write(ApplicationInfoProto.PUBLIC_SOURCE_DIR, publicSourceDir);
1282        }
1283        if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1284            for (String dir : splitSourceDirs) {
1285                proto.write(ApplicationInfoProto.SPLIT_SOURCE_DIRS, dir);
1286            }
1287        }
1288        if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1289                && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1290            for (String dir : splitPublicSourceDirs) {
1291                proto.write(ApplicationInfoProto.SPLIT_PUBLIC_SOURCE_DIRS, dir);
1292            }
1293        }
1294        if (resourceDirs != null) {
1295            for (String dir : resourceDirs) {
1296                proto.write(ApplicationInfoProto.RESOURCE_DIRS, dir);
1297            }
1298        }
1299        proto.write(ApplicationInfoProto.DATA_DIR, dataDir);
1300        proto.write(ApplicationInfoProto.CLASS_LOADER_NAME, classLoaderName);
1301        if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1302            for (String name : splitClassLoaderNames) {
1303                proto.write(ApplicationInfoProto.SPLIT_CLASS_LOADER_NAMES, name);
1304            }
1305        }
1306
1307        long versionToken = proto.start(ApplicationInfoProto.VERSION);
1308        proto.write(ApplicationInfoProto.Version.ENABLED, enabled);
1309        proto.write(ApplicationInfoProto.Version.MIN_SDK_VERSION, minSdkVersion);
1310        proto.write(ApplicationInfoProto.Version.TARGET_SDK_VERSION, targetSdkVersion);
1311        proto.write(ApplicationInfoProto.Version.VERSION_CODE, longVersionCode);
1312        proto.write(ApplicationInfoProto.Version.TARGET_SANDBOX_VERSION, targetSandboxVersion);
1313        proto.end(versionToken);
1314
1315        if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1316            long detailToken = proto.start(ApplicationInfoProto.DETAIL);
1317            if (className != null) {
1318                proto.write(ApplicationInfoProto.Detail.CLASS_NAME, className);
1319            }
1320            proto.write(ApplicationInfoProto.Detail.TASK_AFFINITY, taskAffinity);
1321            proto.write(ApplicationInfoProto.Detail.REQUIRES_SMALLEST_WIDTH_DP,
1322                    requiresSmallestWidthDp);
1323            proto.write(ApplicationInfoProto.Detail.COMPATIBLE_WIDTH_LIMIT_DP,
1324                    compatibleWidthLimitDp);
1325            proto.write(ApplicationInfoProto.Detail.LARGEST_WIDTH_LIMIT_DP,
1326                    largestWidthLimitDp);
1327            if (seInfo != null) {
1328                proto.write(ApplicationInfoProto.Detail.SEINFO, seInfo);
1329                proto.write(ApplicationInfoProto.Detail.SEINFO_USER, seInfoUser);
1330            }
1331            proto.write(ApplicationInfoProto.Detail.DEVICE_PROTECTED_DATA_DIR,
1332                    deviceProtectedDataDir);
1333            proto.write(ApplicationInfoProto.Detail.CREDENTIAL_PROTECTED_DATA_DIR,
1334                    credentialProtectedDataDir);
1335            if (sharedLibraryFiles != null) {
1336                for (String f : sharedLibraryFiles) {
1337                    proto.write(ApplicationInfoProto.Detail.SHARED_LIBRARY_FILES, f);
1338                }
1339            }
1340            if (manageSpaceActivityName != null) {
1341                proto.write(ApplicationInfoProto.Detail.MANAGE_SPACE_ACTIVITY_NAME,
1342                        manageSpaceActivityName);
1343            }
1344            if (descriptionRes != 0) {
1345                proto.write(ApplicationInfoProto.Detail.DESCRIPTION_RES, descriptionRes);
1346            }
1347            if (uiOptions != 0) {
1348                proto.write(ApplicationInfoProto.Detail.UI_OPTIONS, uiOptions);
1349            }
1350            proto.write(ApplicationInfoProto.Detail.SUPPORTS_RTL, hasRtlSupport());
1351            if (fullBackupContent > 0) {
1352                proto.write(ApplicationInfoProto.Detail.CONTENT, "@xml/" + fullBackupContent);
1353            } else {
1354                proto.write(ApplicationInfoProto.Detail.IS_FULL_BACKUP, fullBackupContent == 0);
1355            }
1356            if (networkSecurityConfigRes != 0) {
1357                proto.write(ApplicationInfoProto.Detail.NETWORK_SECURITY_CONFIG_RES,
1358                        networkSecurityConfigRes);
1359            }
1360            if (category != CATEGORY_UNDEFINED) {
1361                proto.write(ApplicationInfoProto.Detail.CATEGORY, category);
1362            }
1363            proto.end(detailToken);
1364        }
1365        proto.end(token);
1366    }
1367
1368    /**
1369     * @return true if "supportsRtl" has been set to true in the AndroidManifest
1370     * @hide
1371     */
1372    public boolean hasRtlSupport() {
1373        return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1374    }
1375
1376    /** {@hide} */
1377    public boolean hasCode() {
1378        return (flags & FLAG_HAS_CODE) != 0;
1379    }
1380
1381    public static class DisplayNameComparator
1382            implements Comparator<ApplicationInfo> {
1383        public DisplayNameComparator(PackageManager pm) {
1384            mPM = pm;
1385        }
1386
1387        public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1388            CharSequence  sa = mPM.getApplicationLabel(aa);
1389            if (sa == null) {
1390                sa = aa.packageName;
1391            }
1392            CharSequence  sb = mPM.getApplicationLabel(ab);
1393            if (sb == null) {
1394                sb = ab.packageName;
1395            }
1396
1397            return sCollator.compare(sa.toString(), sb.toString());
1398        }
1399
1400        private final Collator   sCollator = Collator.getInstance();
1401        private PackageManager   mPM;
1402    }
1403
1404    public ApplicationInfo() {
1405    }
1406
1407    public ApplicationInfo(ApplicationInfo orig) {
1408        super(orig);
1409        taskAffinity = orig.taskAffinity;
1410        permission = orig.permission;
1411        processName = orig.processName;
1412        className = orig.className;
1413        theme = orig.theme;
1414        flags = orig.flags;
1415        privateFlags = orig.privateFlags;
1416        requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1417        compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
1418        largestWidthLimitDp = orig.largestWidthLimitDp;
1419        volumeUuid = orig.volumeUuid;
1420        storageUuid = orig.storageUuid;
1421        scanSourceDir = orig.scanSourceDir;
1422        scanPublicSourceDir = orig.scanPublicSourceDir;
1423        sourceDir = orig.sourceDir;
1424        publicSourceDir = orig.publicSourceDir;
1425        splitNames = orig.splitNames;
1426        splitSourceDirs = orig.splitSourceDirs;
1427        splitPublicSourceDirs = orig.splitPublicSourceDirs;
1428        splitDependencies = orig.splitDependencies;
1429        nativeLibraryDir = orig.nativeLibraryDir;
1430        secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
1431        nativeLibraryRootDir = orig.nativeLibraryRootDir;
1432        nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
1433        primaryCpuAbi = orig.primaryCpuAbi;
1434        secondaryCpuAbi = orig.secondaryCpuAbi;
1435        resourceDirs = orig.resourceDirs;
1436        seInfo = orig.seInfo;
1437        seInfoUser = orig.seInfoUser;
1438        sharedLibraryFiles = orig.sharedLibraryFiles;
1439        dataDir = orig.dataDir;
1440        deviceProtectedDataDir = orig.deviceProtectedDataDir;
1441        credentialProtectedDataDir = orig.credentialProtectedDataDir;
1442        uid = orig.uid;
1443        minSdkVersion = orig.minSdkVersion;
1444        targetSdkVersion = orig.targetSdkVersion;
1445        setVersionCode(orig.longVersionCode);
1446        enabled = orig.enabled;
1447        enabledSetting = orig.enabledSetting;
1448        installLocation = orig.installLocation;
1449        manageSpaceActivityName = orig.manageSpaceActivityName;
1450        descriptionRes = orig.descriptionRes;
1451        uiOptions = orig.uiOptions;
1452        backupAgentName = orig.backupAgentName;
1453        fullBackupContent = orig.fullBackupContent;
1454        networkSecurityConfigRes = orig.networkSecurityConfigRes;
1455        category = orig.category;
1456        targetSandboxVersion = orig.targetSandboxVersion;
1457        classLoaderName = orig.classLoaderName;
1458        splitClassLoaderNames = orig.splitClassLoaderNames;
1459        appComponentFactory = orig.appComponentFactory;
1460        compileSdkVersion = orig.compileSdkVersion;
1461        compileSdkVersionCodename = orig.compileSdkVersionCodename;
1462        mHiddenApiPolicy = orig.mHiddenApiPolicy;
1463    }
1464
1465    public String toString() {
1466        return "ApplicationInfo{"
1467            + Integer.toHexString(System.identityHashCode(this))
1468            + " " + packageName + "}";
1469    }
1470
1471    public int describeContents() {
1472        return 0;
1473    }
1474
1475    @SuppressWarnings("unchecked")
1476    public void writeToParcel(Parcel dest, int parcelableFlags) {
1477        super.writeToParcel(dest, parcelableFlags);
1478        dest.writeString(taskAffinity);
1479        dest.writeString(permission);
1480        dest.writeString(processName);
1481        dest.writeString(className);
1482        dest.writeInt(theme);
1483        dest.writeInt(flags);
1484        dest.writeInt(privateFlags);
1485        dest.writeInt(requiresSmallestWidthDp);
1486        dest.writeInt(compatibleWidthLimitDp);
1487        dest.writeInt(largestWidthLimitDp);
1488        if (storageUuid != null) {
1489            dest.writeInt(1);
1490            dest.writeLong(storageUuid.getMostSignificantBits());
1491            dest.writeLong(storageUuid.getLeastSignificantBits());
1492        } else {
1493            dest.writeInt(0);
1494        }
1495        dest.writeString(scanSourceDir);
1496        dest.writeString(scanPublicSourceDir);
1497        dest.writeString(sourceDir);
1498        dest.writeString(publicSourceDir);
1499        dest.writeStringArray(splitNames);
1500        dest.writeStringArray(splitSourceDirs);
1501        dest.writeStringArray(splitPublicSourceDirs);
1502        dest.writeSparseArray((SparseArray) splitDependencies);
1503        dest.writeString(nativeLibraryDir);
1504        dest.writeString(secondaryNativeLibraryDir);
1505        dest.writeString(nativeLibraryRootDir);
1506        dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
1507        dest.writeString(primaryCpuAbi);
1508        dest.writeString(secondaryCpuAbi);
1509        dest.writeStringArray(resourceDirs);
1510        dest.writeString(seInfo);
1511        dest.writeString(seInfoUser);
1512        dest.writeStringArray(sharedLibraryFiles);
1513        dest.writeString(dataDir);
1514        dest.writeString(deviceProtectedDataDir);
1515        dest.writeString(credentialProtectedDataDir);
1516        dest.writeInt(uid);
1517        dest.writeInt(minSdkVersion);
1518        dest.writeInt(targetSdkVersion);
1519        dest.writeLong(longVersionCode);
1520        dest.writeInt(enabled ? 1 : 0);
1521        dest.writeInt(enabledSetting);
1522        dest.writeInt(installLocation);
1523        dest.writeString(manageSpaceActivityName);
1524        dest.writeString(backupAgentName);
1525        dest.writeInt(descriptionRes);
1526        dest.writeInt(uiOptions);
1527        dest.writeInt(fullBackupContent);
1528        dest.writeInt(networkSecurityConfigRes);
1529        dest.writeInt(category);
1530        dest.writeInt(targetSandboxVersion);
1531        dest.writeString(classLoaderName);
1532        dest.writeStringArray(splitClassLoaderNames);
1533        dest.writeInt(compileSdkVersion);
1534        dest.writeString(compileSdkVersionCodename);
1535        dest.writeString(appComponentFactory);
1536        dest.writeInt(mHiddenApiPolicy);
1537    }
1538
1539    public static final Parcelable.Creator<ApplicationInfo> CREATOR
1540            = new Parcelable.Creator<ApplicationInfo>() {
1541        public ApplicationInfo createFromParcel(Parcel source) {
1542            return new ApplicationInfo(source);
1543        }
1544        public ApplicationInfo[] newArray(int size) {
1545            return new ApplicationInfo[size];
1546        }
1547    };
1548
1549    @SuppressWarnings("unchecked")
1550    private ApplicationInfo(Parcel source) {
1551        super(source);
1552        taskAffinity = source.readString();
1553        permission = source.readString();
1554        processName = source.readString();
1555        className = source.readString();
1556        theme = source.readInt();
1557        flags = source.readInt();
1558        privateFlags = source.readInt();
1559        requiresSmallestWidthDp = source.readInt();
1560        compatibleWidthLimitDp = source.readInt();
1561        largestWidthLimitDp = source.readInt();
1562        if (source.readInt() != 0) {
1563            storageUuid = new UUID(source.readLong(), source.readLong());
1564            volumeUuid = StorageManager.convert(storageUuid);
1565        }
1566        scanSourceDir = source.readString();
1567        scanPublicSourceDir = source.readString();
1568        sourceDir = source.readString();
1569        publicSourceDir = source.readString();
1570        splitNames = source.readStringArray();
1571        splitSourceDirs = source.readStringArray();
1572        splitPublicSourceDirs = source.readStringArray();
1573        splitDependencies = source.readSparseArray(null);
1574        nativeLibraryDir = source.readString();
1575        secondaryNativeLibraryDir = source.readString();
1576        nativeLibraryRootDir = source.readString();
1577        nativeLibraryRootRequiresIsa = source.readInt() != 0;
1578        primaryCpuAbi = source.readString();
1579        secondaryCpuAbi = source.readString();
1580        resourceDirs = source.readStringArray();
1581        seInfo = source.readString();
1582        seInfoUser = source.readString();
1583        sharedLibraryFiles = source.readStringArray();
1584        dataDir = source.readString();
1585        deviceProtectedDataDir = source.readString();
1586        credentialProtectedDataDir = source.readString();
1587        uid = source.readInt();
1588        minSdkVersion = source.readInt();
1589        targetSdkVersion = source.readInt();
1590        setVersionCode(source.readLong());
1591        enabled = source.readInt() != 0;
1592        enabledSetting = source.readInt();
1593        installLocation = source.readInt();
1594        manageSpaceActivityName = source.readString();
1595        backupAgentName = source.readString();
1596        descriptionRes = source.readInt();
1597        uiOptions = source.readInt();
1598        fullBackupContent = source.readInt();
1599        networkSecurityConfigRes = source.readInt();
1600        category = source.readInt();
1601        targetSandboxVersion = source.readInt();
1602        classLoaderName = source.readString();
1603        splitClassLoaderNames = source.readStringArray();
1604        compileSdkVersion = source.readInt();
1605        compileSdkVersionCodename = source.readString();
1606        appComponentFactory = source.readString();
1607        mHiddenApiPolicy = source.readInt();
1608    }
1609
1610    /**
1611     * Retrieve the textual description of the application.  This
1612     * will call back on the given PackageManager to load the description from
1613     * the application.
1614     *
1615     * @param pm A PackageManager from which the label can be loaded; usually
1616     * the PackageManager from which you originally retrieved this item.
1617     *
1618     * @return Returns a CharSequence containing the application's description.
1619     * If there is no description, null is returned.
1620     */
1621    public CharSequence loadDescription(PackageManager pm) {
1622        if (descriptionRes != 0) {
1623            CharSequence label = pm.getText(packageName, descriptionRes, this);
1624            if (label != null) {
1625                return label;
1626            }
1627        }
1628        return null;
1629    }
1630
1631    /**
1632     * Disable compatibility mode
1633     *
1634     * @hide
1635     */
1636    public void disableCompatibilityMode() {
1637        flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1638                FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1639                FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
1640    }
1641
1642    /**
1643     * Is using compatibility mode for non densty aware legacy applications.
1644     *
1645     * @hide
1646     */
1647    public boolean usesCompatibilityMode() {
1648        return targetSdkVersion < DONUT ||
1649                (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1650                 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1651                 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1652    }
1653
1654    /** {@hide} */
1655    public void initForUser(int userId) {
1656        uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1657
1658        if ("android".equals(packageName)) {
1659            dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1660            return;
1661        }
1662
1663        deviceProtectedDataDir = Environment
1664                .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
1665                .getAbsolutePath();
1666        credentialProtectedDataDir = Environment
1667                .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
1668                .getAbsolutePath();
1669
1670        if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1671                && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1672            dataDir = deviceProtectedDataDir;
1673        } else {
1674            dataDir = credentialProtectedDataDir;
1675        }
1676    }
1677
1678    private boolean isPackageWhitelistedForHiddenApis() {
1679        return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
1680    }
1681
1682    private boolean isAllowedToUseHiddenApis() {
1683        return isSignedWithPlatformKey()
1684            || (isPackageWhitelistedForHiddenApis() && (isSystemApp() || isUpdatedSystemApp()));
1685    }
1686
1687    /**
1688     * @hide
1689     */
1690    public @HiddenApiEnforcementPolicy int getHiddenApiEnforcementPolicy() {
1691        if (isAllowedToUseHiddenApis()) {
1692            return HIDDEN_API_ENFORCEMENT_NONE;
1693        }
1694        if (mHiddenApiPolicy != HIDDEN_API_ENFORCEMENT_DEFAULT) {
1695            return mHiddenApiPolicy;
1696        }
1697        if (targetSdkVersion < Build.VERSION_CODES.P) {
1698            return HIDDEN_API_ENFORCEMENT_BLACK;
1699        } else {
1700            return HIDDEN_API_ENFORCEMENT_DARK_GREY_AND_BLACK;
1701        }
1702    }
1703
1704    /**
1705     * @hide
1706     */
1707    public void setHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
1708        if (!isValidHiddenApiEnforcementPolicy(policy)) {
1709            throw new IllegalArgumentException("Invalid API enforcement policy: " + policy);
1710        }
1711        mHiddenApiPolicy = policy;
1712    }
1713
1714    /**
1715     * Updates the hidden API enforcement policy for this app from the given values, if appropriate.
1716     *
1717     * This will have no effect if this app is not subject to hidden API enforcement, i.e. if it
1718     * is on the package whitelist.
1719     *
1720     * @param policyPreP configured policy for pre-P apps, or {@link
1721     *        #HIDDEN_API_ENFORCEMENT_DEFAULT} if nothing configured.
1722     * @param policyP configured policy for apps targeting P or later, or {@link
1723     *        #HIDDEN_API_ENFORCEMENT_DEFAULT} if nothing configured.
1724     * @hide
1725     */
1726    public void maybeUpdateHiddenApiEnforcementPolicy(
1727            @HiddenApiEnforcementPolicy int policyPreP, @HiddenApiEnforcementPolicy int policyP) {
1728        if (isPackageWhitelistedForHiddenApis()) {
1729            return;
1730        }
1731        if (targetSdkVersion < Build.VERSION_CODES.P) {
1732            setHiddenApiEnforcementPolicy(policyPreP);
1733        } else if (targetSdkVersion >= Build.VERSION_CODES.P) {
1734            setHiddenApiEnforcementPolicy(policyP);
1735        }
1736
1737    }
1738
1739    /**
1740     * @hide
1741     */
1742    public void setVersionCode(long newVersionCode) {
1743        longVersionCode = newVersionCode;
1744        versionCode = (int) newVersionCode;
1745    }
1746
1747    /**
1748     * @hide
1749     */
1750    @Override
1751    public Drawable loadDefaultIcon(PackageManager pm) {
1752        if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1753                && isPackageUnavailable(pm)) {
1754            return Resources.getSystem().getDrawable(
1755                    com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1756        }
1757        return pm.getDefaultActivityIcon();
1758    }
1759
1760    private boolean isPackageUnavailable(PackageManager pm) {
1761        try {
1762            return pm.getPackageInfo(packageName, 0) == null;
1763        } catch (NameNotFoundException ex) {
1764            return true;
1765        }
1766    }
1767
1768    /** @hide */
1769    public boolean isDefaultToDeviceProtectedStorage() {
1770        return (privateFlags
1771                & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
1772    }
1773
1774    /** @hide */
1775    public boolean isDirectBootAware() {
1776        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
1777    }
1778
1779    /** @hide */
1780    public boolean isEncryptionAware() {
1781        return isDirectBootAware() || isPartiallyDirectBootAware();
1782    }
1783
1784    /** @hide */
1785    public boolean isExternal() {
1786        return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1787    }
1788
1789    /** @hide */
1790    public boolean isExternalAsec() {
1791        return TextUtils.isEmpty(volumeUuid) && isExternal();
1792    }
1793
1794    /** @hide */
1795    public boolean isForwardLocked() {
1796        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1797    }
1798
1799    /**
1800     * True if the application is installed as an instant app.
1801     * @hide
1802     */
1803    @SystemApi
1804    public boolean isInstantApp() {
1805        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
1806    }
1807
1808    /** @hide */
1809    public boolean isInternal() {
1810        return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1811    }
1812
1813    /** @hide */
1814    public boolean isOem() {
1815        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
1816    }
1817
1818    /** @hide */
1819    public boolean isPartiallyDirectBootAware() {
1820        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
1821    }
1822
1823    /** @hide */
1824    public boolean isSignedWithPlatformKey() {
1825        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY) != 0;
1826    }
1827
1828    /** @hide */
1829    @TestApi
1830    public boolean isPrivilegedApp() {
1831        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1832    }
1833
1834    /** @hide */
1835    public boolean isRequiredForSystemUser() {
1836        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1837    }
1838
1839    /** @hide */
1840    public boolean isStaticSharedLibrary() {
1841        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
1842    }
1843
1844    /** @hide */
1845    @TestApi
1846    public boolean isSystemApp() {
1847        return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1848    }
1849
1850    /** @hide */
1851    public boolean isUpdatedSystemApp() {
1852        return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1853    }
1854
1855    /** @hide */
1856    public boolean isVendor() {
1857        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0;
1858    }
1859
1860    /** @hide */
1861    public boolean isProduct() {
1862        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRODUCT) != 0;
1863    }
1864
1865    /**
1866     * Returns whether or not this application was installed as a virtual preload.
1867     */
1868    public boolean isVirtualPreload() {
1869        return (privateFlags & PRIVATE_FLAG_VIRTUAL_PRELOAD) != 0;
1870    }
1871
1872    /**
1873     * Returns true if the app has declared in its manifest that it wants its split APKs to be
1874     * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
1875     * @hide
1876     */
1877    public boolean requestsIsolatedSplitLoading() {
1878        return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
1879    }
1880
1881    /**
1882     * @hide
1883     */
1884    @Override protected ApplicationInfo getApplicationInfo() {
1885        return this;
1886    }
1887
1888    /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1889    /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1890    /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1891    /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1892    /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1893    /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1894
1895    /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1896    /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1897    /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1898    /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1899    /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
1900    /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
1901}
1902