2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.content.pm;
19 import android.annotation.TestApi;
20 import android.content.pm.PackageManager.NameNotFoundException;
21 import android.content.res.Resources;
22 import android.graphics.drawable.Drawable;
23 import android.os.Environment;
24 import android.os.Parcel;
25 import android.os.Parcelable;
26 import android.os.UserHandle;
27 import android.os.storage.StorageManager;
28 import android.text.TextUtils;
29 import android.util.Printer;
31 import com.android.internal.util.ArrayUtils;
33 import java.text.Collator;
34 import java.util.Arrays;
35 import java.util.Comparator;
36 import java.util.Objects;
39 * Information you can retrieve about a particular application. This
40 * corresponds to information collected from the AndroidManifest.xml's
41 * <application> tag.
43 public class ApplicationInfo extends PackageItemInfo implements Parcelable {
46 * Default task affinity of all activities in this application. See
47 * {@link ActivityInfo#taskAffinity} for more information. This comes
48 * from the "taskAffinity" attribute.
50 public String taskAffinity;
53 * Optional name of a permission required to be able to access this
54 * application's components. From the "permission" attribute.
56 public String permission;
59 * The name of the process this application should run in. From the
60 * "process" attribute or, if not set, the same as
61 * <var>packageName</var>.
63 public String processName;
66 * Class implementing the Application object. From the "class"
69 public String className;
72 * A style resource identifier (in the package's resources) of the
73 * description of an application. From the "description" attribute
76 public int descriptionRes;
79 * A style resource identifier (in the package's resources) of the
80 * default visual theme of the application. From the "theme" attribute
86 * Class implementing the Application's manage space
87 * functionality. From the "manageSpaceActivity"
88 * attribute. This is an optional attribute and will be null if
89 * applications don't specify it in their manifest
91 public String manageSpaceActivityName;
94 * Class implementing the Application's backup functionality. From
95 * the "backupAgent" attribute. This is an optional attribute and
96 * will be null if the application does not specify it in its manifest.
98 * <p>If android:allowBackup is set to false, this attribute is ignored.
100 public String backupAgentName;
103 * An optional attribute that indicates the app supports automatic backup of app data.
104 * <p>0 is the default and means the app's entire data folder + managed external storage will
106 * Any negative value indicates the app does not support full-data backup, though it may still
107 * want to participate via the traditional key/value backup API;
108 * A positive number specifies an xml resource in which the application has defined its backup
109 * include/exclude criteria.
110 * <p>If android:allowBackup is set to false, this attribute is ignored.
112 * @see {@link android.content.Context#getNoBackupFilesDir}
113 * @see {@link #FLAG_ALLOW_BACKUP}
117 public int fullBackupContent = 0;
120 * The default extra UI options for activities in this application.
121 * Set from the {@link android.R.attr#uiOptions} attribute in the
122 * activity's manifest.
124 public int uiOptions = 0;
127 * Value for {@link #flags}: if set, this application is installed in the
128 * device's system image.
130 public static final int FLAG_SYSTEM = 1<<0;
133 * Value for {@link #flags}: set to true if this application would like to
134 * allow debugging of its
135 * code, even when installed on a non-development system. Comes
136 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
137 * android:debuggable} of the <application> tag.
139 public static final int FLAG_DEBUGGABLE = 1<<1;
142 * Value for {@link #flags}: set to true if this application has code
143 * associated with it. Comes
144 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
145 * android:hasCode} of the <application> tag.
147 public static final int FLAG_HAS_CODE = 1<<2;
150 * Value for {@link #flags}: set to true if this application is persistent.
151 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
152 * android:persistent} of the <application> tag.
154 public static final int FLAG_PERSISTENT = 1<<3;
157 * Value for {@link #flags}: set to true if this application holds the
158 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
159 * device is running in factory test mode.
161 public static final int FLAG_FACTORY_TEST = 1<<4;
164 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
165 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
166 * android:allowTaskReparenting} of the <application> tag.
168 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
171 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
172 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
173 * android:allowClearUserData} of the <application> tag.
175 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
178 * Value for {@link #flags}: this is set if this application has been
179 * install as an update to a built-in system application.
181 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
184 * Value for {@link #flags}: this is set of the application has specified
185 * {@link android.R.styleable#AndroidManifestApplication_testOnly
186 * android:testOnly} to be true.
188 public static final int FLAG_TEST_ONLY = 1<<8;
191 * Value for {@link #flags}: true when the application's window can be
192 * reduced in size for smaller screens. Corresponds to
193 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
194 * android:smallScreens}.
196 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
199 * Value for {@link #flags}: true when the application's window can be
200 * displayed on normal screens. Corresponds to
201 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
202 * android:normalScreens}.
204 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
207 * Value for {@link #flags}: true when the application's window can be
208 * increased in size for larger screens. Corresponds to
209 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
210 * android:largeScreens}.
212 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
215 * Value for {@link #flags}: true when the application knows how to adjust
216 * its UI for different screen sizes. Corresponds to
217 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
218 * android:resizeable}.
220 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
223 * Value for {@link #flags}: true when the application knows how to
224 * accomodate different screen densities. Corresponds to
225 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
226 * android:anyDensity}.
228 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
231 * Value for {@link #flags}: set to true if this application would like to
232 * request the VM to operate under the safe mode. Comes from
233 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
234 * android:vmSafeMode} of the <application> tag.
236 public static final int FLAG_VM_SAFE_MODE = 1<<14;
239 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
240 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
243 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
244 * attribute of the <application> tag.
246 public static final int FLAG_ALLOW_BACKUP = 1<<15;
249 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
250 * in memory following a full-system restore operation; <code>true</code> otherwise.
251 * Ordinarily, during a full system restore operation each application is shut down
252 * following execution of its agent's onRestore() method. Setting this attribute to
253 * <code>false</code> prevents this. Most applications will not need to set this attribute.
256 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
257 * is set to <code>false</code> or no
258 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
259 * is specified, this flag will be ignored.
262 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
263 * attribute of the <application> tag.
265 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
268 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
269 * agent claims to be able to handle restore data even "from the future,"
270 * i.e. from versions of the application with a versionCode greater than
271 * the one currently installed on the device. <i>Use with caution!</i> By default
272 * this attribute is <code>false</code> and the Backup Manager will ensure that data
273 * from "future" versions of the application are never supplied during a restore operation.
276 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
277 * is set to <code>false</code> or no
278 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
279 * is specified, this flag will be ignored.
282 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
283 * attribute of the <application> tag.
285 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
288 * Value for {@link #flags}: Set to true if the application is
289 * currently installed on external/removable/unprotected storage. Such
290 * applications may not be available if their storage is not currently
291 * mounted. When the storage it is on is not available, it will look like
292 * the application has been uninstalled (its .apk is no longer available)
293 * but its persistent data is not removed.
295 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
298 * Value for {@link #flags}: true when the application's window can be
299 * increased in size for extra large screens. Corresponds to
300 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
301 * android:xlargeScreens}.
303 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
306 * Value for {@link #flags}: true when the application has requested a
307 * large heap for its processes. Corresponds to
308 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
309 * android:largeHeap}.
311 public static final int FLAG_LARGE_HEAP = 1<<20;
314 * Value for {@link #flags}: true if this application's package is in
317 public static final int FLAG_STOPPED = 1<<21;
320 * Value for {@link #flags}: true when the application is willing to support
321 * RTL (right to left). All activities will inherit this value.
323 * Set from the {@link android.R.attr#supportsRtl} attribute in the
324 * activity's manifest.
326 * Default value is false (no support for RTL).
328 public static final int FLAG_SUPPORTS_RTL = 1<<22;
331 * Value for {@link #flags}: true if the application is currently
332 * installed for the calling user.
334 public static final int FLAG_INSTALLED = 1<<23;
337 * Value for {@link #flags}: true if the application only has its
338 * data installed; the application package itself does not currently
339 * exist on the device.
341 public static final int FLAG_IS_DATA_ONLY = 1<<24;
344 * Value for {@link #flags}: true if the application was declared to be a game, or
345 * false if it is a non-game application.
347 public static final int FLAG_IS_GAME = 1<<25;
350 * Value for {@link #flags}: {@code true} if the application asks that only
351 * full-data streaming backups of its data be performed even though it defines
352 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
353 * indicates that the app will manage its backed-up data via incremental
356 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
359 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
360 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
361 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
362 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
363 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
364 * traffic. Third-party libraries are encouraged to honor this flag as well.
366 * <p>NOTE: {@code WebView} does not honor this flag.
368 * <p>This flag comes from
369 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
370 * android:usesCleartextTraffic} of the <application> tag.
372 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
375 * When set installer extracts native libs from .apk files.
377 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
380 * Value for {@link #flags}: {@code true} when the application's rendering
381 * should be hardware accelerated.
383 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
386 * Value for {@link #flags}: true if this application's package is in
387 * the suspended state.
389 public static final int FLAG_SUSPENDED = 1<<30;
392 * Value for {@link #flags}: true if code from this application will need to be
393 * loaded into other applications' processes. On devices that support multiple
394 * instruction sets, this implies the code might be loaded into a process that's
395 * using any of the devices supported instruction sets.
397 * <p> The system might treat such applications specially, for eg., by
398 * extracting the application's native libraries for all supported instruction
399 * sets or by compiling the application's dex code for all supported instruction
402 public static final int FLAG_MULTIARCH = 1 << 31;
405 * Flags associated with the application. Any combination of
406 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
407 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
408 * {@link #FLAG_ALLOW_TASK_REPARENTING}
409 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
410 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
411 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
412 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
413 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
414 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
415 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
416 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
417 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
418 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
419 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
420 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
421 * {@link #FLAG_MULTIARCH}.
423 public int flags = 0;
426 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
427 * most purposes is considered as not installed.
430 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
433 * Value for {@link #privateFlags}: set to <code>true</code> if the application
434 * has reported that it is heavy-weight, and thus can not participate in
435 * the normal application lifecycle.
438 * android.R.styleable#AndroidManifestApplication_cantSaveState
439 * attribute of the <application> tag.
443 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
446 * Value for {@link #privateFlags}: Set to true if the application has been
447 * installed using the forward lock option.
449 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
453 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
456 * Value for {@link #privateFlags}: set to {@code true} if the application
457 * is permitted to hold privileged permissions.
461 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
464 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
465 * with some data URI using HTTP or HTTPS with an associated VIEW action.
469 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
472 * When set, default data storage directory for given app is pointed at
473 * device-encrypted location.
477 public static final int PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED = 1 << 5;
480 * When set, assume that all components under the given app are encryption
481 * aware, unless otherwise specified.
485 public static final int PRIVATE_FLAG_ENCRYPTION_AWARE = 1 << 6;
488 * Value for {@link #privateFlags}: set to {@code true} if the application
493 public static final int PRIVATE_FLAG_AUTOPLAY = 1 << 7;
496 * When set, at least one component inside this application is encryption aware.
500 public static final int PRIVATE_FLAG_PARTIALLY_ENCRYPTION_AWARE = 1 << 8;
503 * Value for {@link #flags}: {@code true} if the application is blocked via restrictions
504 * and for most purposes is considered as not installed.
507 public static final int PRIVATE_FLAG_EPHEMERAL = 1 << 9;
510 * When set, signals that the application is required for the system user and should not be
515 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 10;
518 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
521 public int privateFlags;
524 * The required smallest screen width the application can run on. If 0,
525 * nothing has been specified. Comes from
526 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
527 * android:requiresSmallestWidthDp} attribute of the <supports-screens> tag.
529 public int requiresSmallestWidthDp = 0;
532 * The maximum smallest screen width the application is designed for. If 0,
533 * nothing has been specified. Comes from
534 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
535 * android:compatibleWidthLimitDp} attribute of the <supports-screens> tag.
537 public int compatibleWidthLimitDp = 0;
540 * The maximum smallest screen width the application will work on. If 0,
541 * nothing has been specified. Comes from
542 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
543 * android:largestWidthLimitDp} attribute of the <supports-screens> tag.
545 public int largestWidthLimitDp = 0;
548 public String volumeUuid;
550 public String scanSourceDir;
552 public String scanPublicSourceDir;
555 * Full path to the base APK for this application.
557 public String sourceDir;
560 * Full path to the publicly available parts of {@link #sourceDir},
561 * including resources and manifest. This may be different from
562 * {@link #sourceDir} if an application is forward locked.
564 public String publicSourceDir;
567 * Full paths to zero or more split APKs that, when combined with the base
568 * APK defined in {@link #sourceDir}, form a complete application.
570 public String[] splitSourceDirs;
573 * Full path to the publicly available parts of {@link #splitSourceDirs},
574 * including resources and manifest. This may be different from
575 * {@link #splitSourceDirs} if an application is forward locked.
577 public String[] splitPublicSourceDirs;
580 * Full paths to the locations of extra resource packages this application
581 * uses. This field is only used if there are extra resource packages,
582 * otherwise it is null.
586 public String[] resourceDirs;
589 * String retrieved from the seinfo tag found in selinux policy. This value
590 * can be overridden with a value set through the mac_permissions.xml policy
591 * construct. This value is useful in setting an SELinux security context on
592 * the process as well as its data directory. The String default is being used
593 * here to represent a catchall label when no policy matches.
597 public String seinfo = "default";
600 * Paths to all shared libraries this application is linked against. This
601 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
602 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
605 public String[] sharedLibraryFiles;
608 * Full path to the default directory assigned to the package for its
611 public String dataDir;
614 * Full path to the device-encrypted directory assigned to the package for
615 * its persistent data.
617 public String deviceEncryptedDataDir;
620 * Full path to the credential-encrypted directory assigned to the package
621 * for its persistent data.
623 public String credentialEncryptedDataDir;
626 * Full path to the directory where native JNI libraries are stored.
628 public String nativeLibraryDir;
631 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
632 * are stored, if present.
634 * The main reason this exists is for bundled multi-arch apps, where
635 * it's not trivial to calculate the location of libs for the secondary abi
636 * given the location of the primary.
638 * TODO: Change the layout of bundled installs so that we can use
639 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
640 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
641 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
645 public String secondaryNativeLibraryDir;
648 * The root path where unpacked native libraries are stored.
650 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
651 * placed in ISA-specific subdirectories under this path, otherwise the
652 * libraries are placed directly at this path.
656 public String nativeLibraryRootDir;
659 * Flag indicating that ISA must be appended to
660 * {@link #nativeLibraryRootDir} to be useful.
664 public boolean nativeLibraryRootRequiresIsa;
667 * The primary ABI that this application requires, This is inferred from the ABIs
668 * of the native JNI libraries the application bundles. Will be {@code null}
669 * if this application does not require any particular ABI.
671 * If non-null, the application will always be launched with this ABI.
675 public String primaryCpuAbi;
678 * The secondary ABI for this application. Might be non-null for multi-arch
679 * installs. The application itself never uses this ABI, but other applications that
680 * use its code might.
684 public String secondaryCpuAbi;
687 * The kernel user-ID that has been assigned to this application;
688 * currently this is not a unique ID (multiple applications can have
694 * The minimum SDK version this application targets. It may run on earlier
695 * versions, but it knows how to work with any new behavior added at this
696 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
697 * if this is a development build and the app is targeting that. You should
698 * compare that this number is >= the SDK version number at which your
699 * behavior was introduced.
701 public int targetSdkVersion;
704 * The app's declared version code.
707 public int versionCode;
710 * When false, indicates that all components within this application are
711 * considered disabled, regardless of their individually set enabled status.
713 public boolean enabled = true;
716 * For convenient access to the current enabled setting of this app.
719 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
722 * For convenient access to package's install location.
725 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
727 public void dump(Printer pw, String prefix) {
728 dump(pw, prefix, DUMP_FLAG_ALL);
732 public void dump(Printer pw, String prefix, int flags) {
733 super.dumpFront(pw, prefix);
734 if ((flags&DUMP_FLAG_DETAILS) != 0 && className != null) {
735 pw.println(prefix + "className=" + className);
737 if (permission != null) {
738 pw.println(prefix + "permission=" + permission);
740 pw.println(prefix + "processName=" + processName);
741 if ((flags&DUMP_FLAG_DETAILS) != 0) {
742 pw.println(prefix + "taskAffinity=" + taskAffinity);
744 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
745 + " privateFlags=0x" + Integer.toHexString(privateFlags)
746 + " theme=0x" + Integer.toHexString(theme));
747 if ((flags&DUMP_FLAG_DETAILS) != 0) {
748 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
749 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
750 + " largestWidthLimitDp=" + largestWidthLimitDp);
752 pw.println(prefix + "sourceDir=" + sourceDir);
753 if (!Objects.equals(sourceDir, publicSourceDir)) {
754 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
756 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
757 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
759 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
760 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
761 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
763 if (resourceDirs != null) {
764 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
766 if ((flags&DUMP_FLAG_DETAILS) != 0 && seinfo != null) {
767 pw.println(prefix + "seinfo=" + seinfo);
769 pw.println(prefix + "dataDir=" + dataDir);
770 if ((flags&DUMP_FLAG_DETAILS) != 0) {
771 pw.println(prefix + "deviceEncryptedDataDir=" + deviceEncryptedDataDir);
772 pw.println(prefix + "credentialEncryptedDataDir=" + credentialEncryptedDataDir);
773 if (sharedLibraryFiles != null) {
774 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
777 pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion
778 + " versionCode=" + versionCode);
779 if ((flags&DUMP_FLAG_DETAILS) != 0) {
780 if (manageSpaceActivityName != null) {
781 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
783 if (descriptionRes != 0) {
784 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
786 if (uiOptions != 0) {
787 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
789 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
790 if (fullBackupContent > 0) {
791 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
793 pw.println(prefix + "fullBackupContent="
794 + (fullBackupContent < 0 ? "false" : "true"));
797 super.dumpBack(pw, prefix);
801 * @return true if "supportsRtl" has been set to true in the AndroidManifest
804 public boolean hasRtlSupport() {
805 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
809 public boolean hasCode() {
810 return (flags & FLAG_HAS_CODE) != 0;
813 public static class DisplayNameComparator
814 implements Comparator<ApplicationInfo> {
815 public DisplayNameComparator(PackageManager pm) {
819 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
820 CharSequence sa = mPM.getApplicationLabel(aa);
824 CharSequence sb = mPM.getApplicationLabel(ab);
829 return sCollator.compare(sa.toString(), sb.toString());
832 private final Collator sCollator = Collator.getInstance();
833 private PackageManager mPM;
836 public ApplicationInfo() {
839 public ApplicationInfo(ApplicationInfo orig) {
841 taskAffinity = orig.taskAffinity;
842 permission = orig.permission;
843 processName = orig.processName;
844 className = orig.className;
847 privateFlags = orig.privateFlags;
848 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
849 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
850 largestWidthLimitDp = orig.largestWidthLimitDp;
851 volumeUuid = orig.volumeUuid;
852 scanSourceDir = orig.scanSourceDir;
853 scanPublicSourceDir = orig.scanPublicSourceDir;
854 sourceDir = orig.sourceDir;
855 publicSourceDir = orig.publicSourceDir;
856 splitSourceDirs = orig.splitSourceDirs;
857 splitPublicSourceDirs = orig.splitPublicSourceDirs;
858 nativeLibraryDir = orig.nativeLibraryDir;
859 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
860 nativeLibraryRootDir = orig.nativeLibraryRootDir;
861 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
862 primaryCpuAbi = orig.primaryCpuAbi;
863 secondaryCpuAbi = orig.secondaryCpuAbi;
864 resourceDirs = orig.resourceDirs;
865 seinfo = orig.seinfo;
866 sharedLibraryFiles = orig.sharedLibraryFiles;
867 dataDir = orig.dataDir;
868 deviceEncryptedDataDir = orig.deviceEncryptedDataDir;
869 credentialEncryptedDataDir = orig.credentialEncryptedDataDir;
871 targetSdkVersion = orig.targetSdkVersion;
872 versionCode = orig.versionCode;
873 enabled = orig.enabled;
874 enabledSetting = orig.enabledSetting;
875 installLocation = orig.installLocation;
876 manageSpaceActivityName = orig.manageSpaceActivityName;
877 descriptionRes = orig.descriptionRes;
878 uiOptions = orig.uiOptions;
879 backupAgentName = orig.backupAgentName;
880 fullBackupContent = orig.fullBackupContent;
883 public String toString() {
884 return "ApplicationInfo{"
885 + Integer.toHexString(System.identityHashCode(this))
886 + " " + packageName + "}";
889 public int describeContents() {
893 public void writeToParcel(Parcel dest, int parcelableFlags) {
894 super.writeToParcel(dest, parcelableFlags);
895 dest.writeString(taskAffinity);
896 dest.writeString(permission);
897 dest.writeString(processName);
898 dest.writeString(className);
899 dest.writeInt(theme);
900 dest.writeInt(flags);
901 dest.writeInt(privateFlags);
902 dest.writeInt(requiresSmallestWidthDp);
903 dest.writeInt(compatibleWidthLimitDp);
904 dest.writeInt(largestWidthLimitDp);
905 dest.writeString(volumeUuid);
906 dest.writeString(scanSourceDir);
907 dest.writeString(scanPublicSourceDir);
908 dest.writeString(sourceDir);
909 dest.writeString(publicSourceDir);
910 dest.writeStringArray(splitSourceDirs);
911 dest.writeStringArray(splitPublicSourceDirs);
912 dest.writeString(nativeLibraryDir);
913 dest.writeString(secondaryNativeLibraryDir);
914 dest.writeString(nativeLibraryRootDir);
915 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
916 dest.writeString(primaryCpuAbi);
917 dest.writeString(secondaryCpuAbi);
918 dest.writeStringArray(resourceDirs);
919 dest.writeString(seinfo);
920 dest.writeStringArray(sharedLibraryFiles);
921 dest.writeString(dataDir);
922 dest.writeString(deviceEncryptedDataDir);
923 dest.writeString(credentialEncryptedDataDir);
925 dest.writeInt(targetSdkVersion);
926 dest.writeInt(versionCode);
927 dest.writeInt(enabled ? 1 : 0);
928 dest.writeInt(enabledSetting);
929 dest.writeInt(installLocation);
930 dest.writeString(manageSpaceActivityName);
931 dest.writeString(backupAgentName);
932 dest.writeInt(descriptionRes);
933 dest.writeInt(uiOptions);
934 dest.writeInt(fullBackupContent);
937 public static final Parcelable.Creator<ApplicationInfo> CREATOR
938 = new Parcelable.Creator<ApplicationInfo>() {
939 public ApplicationInfo createFromParcel(Parcel source) {
940 return new ApplicationInfo(source);
942 public ApplicationInfo[] newArray(int size) {
943 return new ApplicationInfo[size];
947 private ApplicationInfo(Parcel source) {
949 taskAffinity = source.readString();
950 permission = source.readString();
951 processName = source.readString();
952 className = source.readString();
953 theme = source.readInt();
954 flags = source.readInt();
955 privateFlags = source.readInt();
956 requiresSmallestWidthDp = source.readInt();
957 compatibleWidthLimitDp = source.readInt();
958 largestWidthLimitDp = source.readInt();
959 volumeUuid = source.readString();
960 scanSourceDir = source.readString();
961 scanPublicSourceDir = source.readString();
962 sourceDir = source.readString();
963 publicSourceDir = source.readString();
964 splitSourceDirs = source.readStringArray();
965 splitPublicSourceDirs = source.readStringArray();
966 nativeLibraryDir = source.readString();
967 secondaryNativeLibraryDir = source.readString();
968 nativeLibraryRootDir = source.readString();
969 nativeLibraryRootRequiresIsa = source.readInt() != 0;
970 primaryCpuAbi = source.readString();
971 secondaryCpuAbi = source.readString();
972 resourceDirs = source.readStringArray();
973 seinfo = source.readString();
974 sharedLibraryFiles = source.readStringArray();
975 dataDir = source.readString();
976 deviceEncryptedDataDir = source.readString();
977 credentialEncryptedDataDir = source.readString();
978 uid = source.readInt();
979 targetSdkVersion = source.readInt();
980 versionCode = source.readInt();
981 enabled = source.readInt() != 0;
982 enabledSetting = source.readInt();
983 installLocation = source.readInt();
984 manageSpaceActivityName = source.readString();
985 backupAgentName = source.readString();
986 descriptionRes = source.readInt();
987 uiOptions = source.readInt();
988 fullBackupContent = source.readInt();
992 * Retrieve the textual description of the application. This
993 * will call back on the given PackageManager to load the description from
996 * @param pm A PackageManager from which the label can be loaded; usually
997 * the PackageManager from which you originally retrieved this item.
999 * @return Returns a CharSequence containing the application's description.
1000 * If there is no description, null is returned.
1002 public CharSequence loadDescription(PackageManager pm) {
1003 if (descriptionRes != 0) {
1004 CharSequence label = pm.getText(packageName, descriptionRes, this);
1005 if (label != null) {
1013 * Disable compatibility mode
1017 public void disableCompatibilityMode() {
1018 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1019 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1020 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
1024 public void initForUser(int userId) {
1025 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1027 if ("android".equals(packageName)) {
1028 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1032 deviceEncryptedDataDir = Environment
1033 .getDataUserDeviceEncryptedPackageDirectory(volumeUuid, userId, packageName)
1035 credentialEncryptedDataDir = Environment
1036 .getDataUserCredentialEncryptedPackageDirectory(volumeUuid, userId, packageName)
1039 if ((privateFlags & PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED) != 0
1040 && StorageManager.isFileBasedEncryptionEnabled()) {
1041 dataDir = deviceEncryptedDataDir;
1043 dataDir = credentialEncryptedDataDir;
1051 public Drawable loadDefaultIcon(PackageManager pm) {
1052 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1053 && isPackageUnavailable(pm)) {
1054 return Resources.getSystem().getDrawable(
1055 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1057 return pm.getDefaultActivityIcon();
1060 private boolean isPackageUnavailable(PackageManager pm) {
1062 return pm.getPackageInfo(packageName, 0) == null;
1063 } catch (NameNotFoundException ex) {
1071 public boolean isForwardLocked() {
1072 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1079 public boolean isSystemApp() {
1080 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1087 public boolean isPrivilegedApp() {
1088 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1094 public boolean isUpdatedSystemApp() {
1095 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1099 public boolean isInternal() {
1100 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1104 public boolean isExternalAsec() {
1105 return TextUtils.isEmpty(volumeUuid)
1106 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1110 public boolean isEncryptionAware() {
1111 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ENCRYPTION_AWARE) != 0;
1115 public boolean isPartiallyEncryptionAware() {
1116 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_ENCRYPTION_AWARE) != 0;
1122 public boolean isAutoPlayApp() {
1123 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_AUTOPLAY) != 0;
1129 public boolean isEphemeralApp() {
1130 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0;
1136 public boolean isRequiredForSystemUser() {
1137 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1143 @Override protected ApplicationInfo getApplicationInfo() {
1147 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1148 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1149 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1150 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1151 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1152 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1154 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1155 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1156 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1157 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1158 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
1159 /** {@hide} */ public String[] getSplitResourcePaths() { return splitSourceDirs; }