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.content.pm.PackageManager.NameNotFoundException;
20 import android.content.res.Resources;
21 import android.graphics.drawable.Drawable;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.util.Printer;
26 import com.android.internal.util.ArrayUtils;
28 import java.text.Collator;
29 import java.util.Arrays;
30 import java.util.Comparator;
31 import java.util.Objects;
34 * Information you can retrieve about a particular application. This
35 * corresponds to information collected from the AndroidManifest.xml's
36 * <application> tag.
38 public class ApplicationInfo extends PackageItemInfo implements Parcelable {
41 * Default task affinity of all activities in this application. See
42 * {@link ActivityInfo#taskAffinity} for more information. This comes
43 * from the "taskAffinity" attribute.
45 public String taskAffinity;
48 * Optional name of a permission required to be able to access this
49 * application's components. From the "permission" attribute.
51 public String permission;
54 * The name of the process this application should run in. From the
55 * "process" attribute or, if not set, the same as
56 * <var>packageName</var>.
58 public String processName;
61 * Class implementing the Application object. From the "class"
64 public String className;
67 * A style resource identifier (in the package's resources) of the
68 * description of an application. From the "description" attribute
71 public int descriptionRes;
74 * A style resource identifier (in the package's resources) of the
75 * default visual theme of the application. From the "theme" attribute
81 * Class implementing the Application's manage space
82 * functionality. From the "manageSpaceActivity"
83 * attribute. This is an optional attribute and will be null if
84 * applications don't specify it in their manifest
86 public String manageSpaceActivityName;
89 * Class implementing the Application's backup functionality. From
90 * the "backupAgent" attribute. This is an optional attribute and
91 * will be null if the application does not specify it in its manifest.
93 * <p>If android:allowBackup is set to false, this attribute is ignored.
95 public String backupAgentName;
98 * The default extra UI options for activities in this application.
99 * Set from the {@link android.R.attr#uiOptions} attribute in the
100 * activity's manifest.
102 public int uiOptions = 0;
105 * Value for {@link #flags}: if set, this application is installed in the
106 * device's system image.
108 public static final int FLAG_SYSTEM = 1<<0;
111 * Value for {@link #flags}: set to true if this application would like to
112 * allow debugging of its
113 * code, even when installed on a non-development system. Comes
114 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
115 * android:debuggable} of the <application> tag.
117 public static final int FLAG_DEBUGGABLE = 1<<1;
120 * Value for {@link #flags}: set to true if this application has code
121 * associated with it. Comes
122 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
123 * android:hasCode} of the <application> tag.
125 public static final int FLAG_HAS_CODE = 1<<2;
128 * Value for {@link #flags}: set to true if this application is persistent.
129 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
130 * android:persistent} of the <application> tag.
132 public static final int FLAG_PERSISTENT = 1<<3;
135 * Value for {@link #flags}: set to true if this application holds the
136 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
137 * device is running in factory test mode.
139 public static final int FLAG_FACTORY_TEST = 1<<4;
142 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
143 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
144 * android:allowTaskReparenting} of the <application> tag.
146 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
149 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
150 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
151 * android:allowClearUserData} of the <application> tag.
153 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
156 * Value for {@link #flags}: this is set if this application has been
157 * install as an update to a built-in system application.
159 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
162 * Value for {@link #flags}: this is set of the application has specified
163 * {@link android.R.styleable#AndroidManifestApplication_testOnly
164 * android:testOnly} to be true.
166 public static final int FLAG_TEST_ONLY = 1<<8;
169 * Value for {@link #flags}: true when the application's window can be
170 * reduced in size for smaller screens. Corresponds to
171 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
172 * android:smallScreens}.
174 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
177 * Value for {@link #flags}: true when the application's window can be
178 * displayed on normal screens. Corresponds to
179 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
180 * android:normalScreens}.
182 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
185 * Value for {@link #flags}: true when the application's window can be
186 * increased in size for larger screens. Corresponds to
187 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
188 * android:largeScreens}.
190 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
193 * Value for {@link #flags}: true when the application knows how to adjust
194 * its UI for different screen sizes. Corresponds to
195 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
196 * android:resizeable}.
198 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
201 * Value for {@link #flags}: true when the application knows how to
202 * accomodate different screen densities. Corresponds to
203 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
204 * android:anyDensity}.
206 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
209 * Value for {@link #flags}: set to true if this application would like to
210 * request the VM to operate under the safe mode. Comes from
211 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
212 * android:vmSafeMode} of the <application> tag.
214 public static final int FLAG_VM_SAFE_MODE = 1<<14;
217 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
218 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
221 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
222 * attribute of the <application> tag.
224 public static final int FLAG_ALLOW_BACKUP = 1<<15;
227 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
228 * in memory following a full-system restore operation; <code>true</code> otherwise.
229 * Ordinarily, during a full system restore operation each application is shut down
230 * following execution of its agent's onRestore() method. Setting this attribute to
231 * <code>false</code> prevents this. Most applications will not need to set this attribute.
234 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
235 * is set to <code>false</code> or no
236 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
237 * is specified, this flag will be ignored.
240 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
241 * attribute of the <application> tag.
243 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
246 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
247 * agent claims to be able to handle restore data even "from the future,"
248 * i.e. from versions of the application with a versionCode greater than
249 * the one currently installed on the device. <i>Use with caution!</i> By default
250 * this attribute is <code>false</code> and the Backup Manager will ensure that data
251 * from "future" versions of the application are never supplied during a restore operation.
254 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
255 * is set to <code>false</code> or no
256 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
257 * is specified, this flag will be ignored.
260 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
261 * attribute of the <application> tag.
263 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
266 * Value for {@link #flags}: Set to true if the application is
267 * currently installed on external/removable/unprotected storage. Such
268 * applications may not be available if their storage is not currently
269 * mounted. When the storage it is on is not available, it will look like
270 * the application has been uninstalled (its .apk is no longer available)
271 * but its persistent data is not removed.
273 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
276 * Value for {@link #flags}: true when the application's window can be
277 * increased in size for extra large screens. Corresponds to
278 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
279 * android:xlargeScreens}.
281 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
284 * Value for {@link #flags}: true when the application has requested a
285 * large heap for its processes. Corresponds to
286 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
287 * android:largeHeap}.
289 public static final int FLAG_LARGE_HEAP = 1<<20;
292 * Value for {@link #flags}: true if this application's package is in
295 public static final int FLAG_STOPPED = 1<<21;
298 * Value for {@link #flags}: true when the application is willing to support
299 * RTL (right to left). All activities will inherit this value.
301 * Set from the {@link android.R.attr#supportsRtl} attribute in the
302 * activity's manifest.
304 * Default value is false (no support for RTL).
306 public static final int FLAG_SUPPORTS_RTL = 1<<22;
309 * Value for {@link #flags}: true if the application is currently
310 * installed for the calling user.
312 public static final int FLAG_INSTALLED = 1<<23;
315 * Value for {@link #flags}: true if the application only has its
316 * data installed; the application package itself does not currently
317 * exist on the device.
319 public static final int FLAG_IS_DATA_ONLY = 1<<24;
322 * Value for {@link #flags}: true if the application was declared to be a game, or
323 * false if it is a non-game application.
325 public static final int FLAG_IS_GAME = 1<<25;
328 * Value for {@link #flags}: {@code true} if the application asks that only
329 * full-data streaming backups of its data be performed even though it defines
330 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
331 * indicates that the app will manage its backed-up data via incremental
334 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
337 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
338 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
339 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
340 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
341 * {@code WebView}, {@code MediaPlayer}) will refuse app's requests to use cleartext traffic.
342 * Third-party libraries are encouraged to honor this flag as well.
346 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
349 * When set installer extracts native libs from .apk files.
351 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
354 * Value for {@link #flags}: true if code from this application will need to be
355 * loaded into other applications' processes. On devices that support multiple
356 * instruction sets, this implies the code might be loaded into a process that's
357 * using any of the devices supported instruction sets.
359 * <p> The system might treat such applications specially, for eg., by
360 * extracting the application's native libraries for all supported instruction
361 * sets or by compiling the application's dex code for all supported instruction
364 public static final int FLAG_MULTIARCH = 1 << 31;
367 * Flags associated with the application. Any combination of
368 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
369 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
370 * {@link #FLAG_ALLOW_TASK_REPARENTING}
371 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
372 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
373 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
374 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
375 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
376 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
377 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
378 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
379 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
380 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
381 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
382 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_MULTIARCH}.
384 public int flags = 0;
387 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
388 * most purposes is considered as not installed.
391 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
394 * Value for {@link #privateFlags}: set to <code>true</code> if the application
395 * has reported that it is heavy-weight, and thus can not participate in
396 * the normal application lifecycle.
399 * android.R.styleable#AndroidManifestApplication_cantSaveState
400 * attribute of the <application> tag.
404 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
407 * Value for {@link #privateFlags}: Set to true if the application has been
408 * installed using the forward lock option.
410 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
414 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
417 * Value for {@link #privateFlags}: set to {@code true} if the application
418 * is permitted to hold privileged permissions.
422 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
425 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
428 public int privateFlags;
431 * The required smallest screen width the application can run on. If 0,
432 * nothing has been specified. Comes from
433 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
434 * android:requiresSmallestWidthDp} attribute of the <supports-screens> tag.
436 public int requiresSmallestWidthDp = 0;
439 * The maximum smallest screen width the application is designed for. If 0,
440 * nothing has been specified. Comes from
441 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
442 * android:compatibleWidthLimitDp} attribute of the <supports-screens> tag.
444 public int compatibleWidthLimitDp = 0;
447 * The maximum smallest screen width the application will work on. If 0,
448 * nothing has been specified. Comes from
449 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
450 * android:largestWidthLimitDp} attribute of the <supports-screens> tag.
452 public int largestWidthLimitDp = 0;
455 public String scanSourceDir;
457 public String scanPublicSourceDir;
460 * Full path to the base APK for this application.
462 public String sourceDir;
465 * Full path to the publicly available parts of {@link #sourceDir},
466 * including resources and manifest. This may be different from
467 * {@link #sourceDir} if an application is forward locked.
469 public String publicSourceDir;
472 * Full paths to zero or more split APKs that, when combined with the base
473 * APK defined in {@link #sourceDir}, form a complete application.
475 public String[] splitSourceDirs;
478 * Full path to the publicly available parts of {@link #splitSourceDirs},
479 * including resources and manifest. This may be different from
480 * {@link #splitSourceDirs} if an application is forward locked.
482 public String[] splitPublicSourceDirs;
485 * Full paths to the locations of extra resource packages this application
486 * uses. This field is only used if there are extra resource packages,
487 * otherwise it is null.
491 public String[] resourceDirs;
494 * String retrieved from the seinfo tag found in selinux policy. This value
495 * is useful in setting an SELinux security context on the process as well
496 * as its data directory.
500 public String seinfo;
503 * Paths to all shared libraries this application is linked against. This
504 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
505 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
508 public String[] sharedLibraryFiles;
511 * Full path to a directory assigned to the package for its persistent
514 public String dataDir;
517 * Full path to the directory where native JNI libraries are stored.
519 public String nativeLibraryDir;
522 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
523 * are stored, if present.
525 * The main reason this exists is for bundled multi-arch apps, where
526 * it's not trivial to calculate the location of libs for the secondary abi
527 * given the location of the primary.
529 * TODO: Change the layout of bundled installs so that we can use
530 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
531 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
532 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
536 public String secondaryNativeLibraryDir;
539 * The root path where unpacked native libraries are stored.
541 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
542 * placed in ISA-specific subdirectories under this path, otherwise the
543 * libraries are placed directly at this path.
547 public String nativeLibraryRootDir;
550 * Flag indicating that ISA must be appended to
551 * {@link #nativeLibraryRootDir} to be useful.
555 public boolean nativeLibraryRootRequiresIsa;
558 * The primary ABI that this application requires, This is inferred from the ABIs
559 * of the native JNI libraries the application bundles. Will be {@code null}
560 * if this application does not require any particular ABI.
562 * If non-null, the application will always be launched with this ABI.
566 public String primaryCpuAbi;
569 * The secondary ABI for this application. Might be non-null for multi-arch
570 * installs. The application itself never uses this ABI, but other applications that
571 * use its code might.
575 public String secondaryCpuAbi;
578 * The kernel user-ID that has been assigned to this application;
579 * currently this is not a unique ID (multiple applications can have
585 * The minimum SDK version this application targets. It may run on earlier
586 * versions, but it knows how to work with any new behavior added at this
587 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
588 * if this is a development build and the app is targeting that. You should
589 * compare that this number is >= the SDK version number at which your
590 * behavior was introduced.
592 public int targetSdkVersion;
595 * The app's declared version code.
598 public int versionCode;
601 * When false, indicates that all components within this application are
602 * considered disabled, regardless of their individually set enabled status.
604 public boolean enabled = true;
607 * For convenient access to the current enabled setting of this app.
610 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
613 * For convenient access to package's install location.
616 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
618 public void dump(Printer pw, String prefix) {
619 super.dumpFront(pw, prefix);
620 if (className != null) {
621 pw.println(prefix + "className=" + className);
623 if (permission != null) {
624 pw.println(prefix + "permission=" + permission);
626 pw.println(prefix + "processName=" + processName);
627 pw.println(prefix + "taskAffinity=" + taskAffinity);
628 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
629 + " privateFlags=0x" + Integer.toHexString(privateFlags)
630 + " theme=0x" + Integer.toHexString(theme));
631 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
632 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
633 + " largestWidthLimitDp=" + largestWidthLimitDp);
634 pw.println(prefix + "sourceDir=" + sourceDir);
635 if (!Objects.equals(sourceDir, publicSourceDir)) {
636 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
638 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
639 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
641 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
642 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
643 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
645 if (resourceDirs != null) {
646 pw.println(prefix + "resourceDirs=" + resourceDirs);
648 if (seinfo != null) {
649 pw.println(prefix + "seinfo=" + seinfo);
651 pw.println(prefix + "dataDir=" + dataDir);
652 if (sharedLibraryFiles != null) {
653 pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
655 pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion
656 + " versionCode=" + versionCode);
657 if (manageSpaceActivityName != null) {
658 pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
660 if (descriptionRes != 0) {
661 pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
663 if (uiOptions != 0) {
664 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
666 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
667 super.dumpBack(pw, prefix);
671 * @return true if "supportsRtl" has been set to true in the AndroidManifest
674 public boolean hasRtlSupport() {
675 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
678 public static class DisplayNameComparator
679 implements Comparator<ApplicationInfo> {
680 public DisplayNameComparator(PackageManager pm) {
684 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
685 CharSequence sa = mPM.getApplicationLabel(aa);
689 CharSequence sb = mPM.getApplicationLabel(ab);
694 return sCollator.compare(sa.toString(), sb.toString());
697 private final Collator sCollator = Collator.getInstance();
698 private PackageManager mPM;
701 public ApplicationInfo() {
704 public ApplicationInfo(ApplicationInfo orig) {
706 taskAffinity = orig.taskAffinity;
707 permission = orig.permission;
708 processName = orig.processName;
709 className = orig.className;
712 privateFlags = orig.privateFlags;
713 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
714 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
715 largestWidthLimitDp = orig.largestWidthLimitDp;
716 scanSourceDir = orig.scanSourceDir;
717 scanPublicSourceDir = orig.scanPublicSourceDir;
718 sourceDir = orig.sourceDir;
719 publicSourceDir = orig.publicSourceDir;
720 splitSourceDirs = orig.splitSourceDirs;
721 splitPublicSourceDirs = orig.splitPublicSourceDirs;
722 nativeLibraryDir = orig.nativeLibraryDir;
723 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
724 nativeLibraryRootDir = orig.nativeLibraryRootDir;
725 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
726 primaryCpuAbi = orig.primaryCpuAbi;
727 secondaryCpuAbi = orig.secondaryCpuAbi;
728 resourceDirs = orig.resourceDirs;
729 seinfo = orig.seinfo;
730 sharedLibraryFiles = orig.sharedLibraryFiles;
731 dataDir = orig.dataDir;
733 targetSdkVersion = orig.targetSdkVersion;
734 versionCode = orig.versionCode;
735 enabled = orig.enabled;
736 enabledSetting = orig.enabledSetting;
737 installLocation = orig.installLocation;
738 manageSpaceActivityName = orig.manageSpaceActivityName;
739 descriptionRes = orig.descriptionRes;
740 uiOptions = orig.uiOptions;
741 backupAgentName = orig.backupAgentName;
745 public String toString() {
746 return "ApplicationInfo{"
747 + Integer.toHexString(System.identityHashCode(this))
748 + " " + packageName + "}";
751 public int describeContents() {
755 public void writeToParcel(Parcel dest, int parcelableFlags) {
756 super.writeToParcel(dest, parcelableFlags);
757 dest.writeString(taskAffinity);
758 dest.writeString(permission);
759 dest.writeString(processName);
760 dest.writeString(className);
761 dest.writeInt(theme);
762 dest.writeInt(flags);
763 dest.writeInt(privateFlags);
764 dest.writeInt(requiresSmallestWidthDp);
765 dest.writeInt(compatibleWidthLimitDp);
766 dest.writeInt(largestWidthLimitDp);
767 dest.writeString(scanSourceDir);
768 dest.writeString(scanPublicSourceDir);
769 dest.writeString(sourceDir);
770 dest.writeString(publicSourceDir);
771 dest.writeStringArray(splitSourceDirs);
772 dest.writeStringArray(splitPublicSourceDirs);
773 dest.writeString(nativeLibraryDir);
774 dest.writeString(secondaryNativeLibraryDir);
775 dest.writeString(nativeLibraryRootDir);
776 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
777 dest.writeString(primaryCpuAbi);
778 dest.writeString(secondaryCpuAbi);
779 dest.writeStringArray(resourceDirs);
780 dest.writeString(seinfo);
781 dest.writeStringArray(sharedLibraryFiles);
782 dest.writeString(dataDir);
784 dest.writeInt(targetSdkVersion);
785 dest.writeInt(versionCode);
786 dest.writeInt(enabled ? 1 : 0);
787 dest.writeInt(enabledSetting);
788 dest.writeInt(installLocation);
789 dest.writeString(manageSpaceActivityName);
790 dest.writeString(backupAgentName);
791 dest.writeInt(descriptionRes);
792 dest.writeInt(uiOptions);
795 public static final Parcelable.Creator<ApplicationInfo> CREATOR
796 = new Parcelable.Creator<ApplicationInfo>() {
797 public ApplicationInfo createFromParcel(Parcel source) {
798 return new ApplicationInfo(source);
800 public ApplicationInfo[] newArray(int size) {
801 return new ApplicationInfo[size];
805 private ApplicationInfo(Parcel source) {
807 taskAffinity = source.readString();
808 permission = source.readString();
809 processName = source.readString();
810 className = source.readString();
811 theme = source.readInt();
812 flags = source.readInt();
813 privateFlags = source.readInt();
814 requiresSmallestWidthDp = source.readInt();
815 compatibleWidthLimitDp = source.readInt();
816 largestWidthLimitDp = source.readInt();
817 scanSourceDir = source.readString();
818 scanPublicSourceDir = source.readString();
819 sourceDir = source.readString();
820 publicSourceDir = source.readString();
821 splitSourceDirs = source.readStringArray();
822 splitPublicSourceDirs = source.readStringArray();
823 nativeLibraryDir = source.readString();
824 secondaryNativeLibraryDir = source.readString();
825 nativeLibraryRootDir = source.readString();
826 nativeLibraryRootRequiresIsa = source.readInt() != 0;
827 primaryCpuAbi = source.readString();
828 secondaryCpuAbi = source.readString();
829 resourceDirs = source.readStringArray();
830 seinfo = source.readString();
831 sharedLibraryFiles = source.readStringArray();
832 dataDir = source.readString();
833 uid = source.readInt();
834 targetSdkVersion = source.readInt();
835 versionCode = source.readInt();
836 enabled = source.readInt() != 0;
837 enabledSetting = source.readInt();
838 installLocation = source.readInt();
839 manageSpaceActivityName = source.readString();
840 backupAgentName = source.readString();
841 descriptionRes = source.readInt();
842 uiOptions = source.readInt();
846 * Retrieve the textual description of the application. This
847 * will call back on the given PackageManager to load the description from
850 * @param pm A PackageManager from which the label can be loaded; usually
851 * the PackageManager from which you originally retrieved this item.
853 * @return Returns a CharSequence containing the application's description.
854 * If there is no description, null is returned.
856 public CharSequence loadDescription(PackageManager pm) {
857 if (descriptionRes != 0) {
858 CharSequence label = pm.getText(packageName, descriptionRes, this);
867 * Disable compatibility mode
871 public void disableCompatibilityMode() {
872 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
873 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
874 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
881 public Drawable loadDefaultIcon(PackageManager pm) {
882 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
883 && isPackageUnavailable(pm)) {
884 return Resources.getSystem().getDrawable(
885 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
887 return pm.getDefaultActivityIcon();
890 private boolean isPackageUnavailable(PackageManager pm) {
892 return pm.getPackageInfo(packageName, 0) == null;
893 } catch (NameNotFoundException ex) {
901 public boolean isForwardLocked() {
902 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
908 public boolean isSystemApp() {
909 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
915 public boolean isUpdatedSystemApp() {
916 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
922 @Override protected ApplicationInfo getApplicationInfo() {
926 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
927 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
928 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
929 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
930 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
931 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
933 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
934 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
935 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
936 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
937 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
938 /** {@hide} */ public String[] getSplitResourcePaths() { return splitSourceDirs; }