• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.content.pm;
18 
19 import 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;
25 
26 import java.text.Collator;
27 import java.util.Comparator;
28 
29 /**
30  * Information you can retrieve about a particular application.  This
31  * corresponds to information collected from the AndroidManifest.xml's
32  * <application> tag.
33  */
34 public class ApplicationInfo extends PackageItemInfo implements Parcelable {
35 
36     /**
37      * Default task affinity of all activities in this application. See
38      * {@link ActivityInfo#taskAffinity} for more information.  This comes
39      * from the "taskAffinity" attribute.
40      */
41     public String taskAffinity;
42 
43     /**
44      * Optional name of a permission required to be able to access this
45      * application's components.  From the "permission" attribute.
46      */
47     public String permission;
48 
49     /**
50      * The name of the process this application should run in.  From the
51      * "process" attribute or, if not set, the same as
52      * <var>packageName</var>.
53      */
54     public String processName;
55 
56     /**
57      * Class implementing the Application object.  From the "class"
58      * attribute.
59      */
60     public String className;
61 
62     /**
63      * A style resource identifier (in the package's resources) of the
64      * description of an application.  From the "description" attribute
65      * or, if not set, 0.
66      */
67     public int descriptionRes;
68 
69     /**
70      * A style resource identifier (in the package's resources) of the
71      * default visual theme of the application.  From the "theme" attribute
72      * or, if not set, 0.
73      */
74     public int theme;
75 
76     /**
77      * Class implementing the Application's manage space
78      * functionality.  From the "manageSpaceActivity"
79      * attribute. This is an optional attribute and will be null if
80      * applications don't specify it in their manifest
81      */
82     public String manageSpaceActivityName;
83 
84     /**
85      * Class implementing the Application's backup functionality.  From
86      * the "backupAgent" attribute.  This is an optional attribute and
87      * will be null if the application does not specify it in its manifest.
88      *
89      * <p>If android:allowBackup is set to false, this attribute is ignored.
90      */
91     public String backupAgentName;
92 
93     /**
94      * The default extra UI options for activities in this application.
95      * Set from the {@link android.R.attr#uiOptions} attribute in the
96      * activity's manifest.
97      */
98     public int uiOptions = 0;
99 
100     /**
101      * Value for {@link #flags}: if set, this application is installed in the
102      * device's system image.
103      */
104     public static final int FLAG_SYSTEM = 1<<0;
105 
106     /**
107      * Value for {@link #flags}: set to true if this application would like to
108      * allow debugging of its
109      * code, even when installed on a non-development system.  Comes
110      * from {@link android.R.styleable#AndroidManifestApplication_debuggable
111      * android:debuggable} of the &lt;application&gt; tag.
112      */
113     public static final int FLAG_DEBUGGABLE = 1<<1;
114 
115     /**
116      * Value for {@link #flags}: set to true if this application has code
117      * associated with it.  Comes
118      * from {@link android.R.styleable#AndroidManifestApplication_hasCode
119      * android:hasCode} of the &lt;application&gt; tag.
120      */
121     public static final int FLAG_HAS_CODE = 1<<2;
122 
123     /**
124      * Value for {@link #flags}: set to true if this application is persistent.
125      * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
126      * android:persistent} of the &lt;application&gt; tag.
127      */
128     public static final int FLAG_PERSISTENT = 1<<3;
129 
130     /**
131      * Value for {@link #flags}: set to true if this application holds the
132      * {@link android.Manifest.permission#FACTORY_TEST} permission and the
133      * device is running in factory test mode.
134      */
135     public static final int FLAG_FACTORY_TEST = 1<<4;
136 
137     /**
138      * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
139      * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
140      * android:allowTaskReparenting} of the &lt;application&gt; tag.
141      */
142     public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
143 
144     /**
145      * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
146      * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
147      * android:allowClearUserData} of the &lt;application&gt; tag.
148      */
149     public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
150 
151     /**
152      * Value for {@link #flags}: this is set if this application has been
153      * install as an update to a built-in system application.
154      */
155     public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
156 
157     /**
158      * Value for {@link #flags}: this is set of the application has specified
159      * {@link android.R.styleable#AndroidManifestApplication_testOnly
160      * android:testOnly} to be true.
161      */
162     public static final int FLAG_TEST_ONLY = 1<<8;
163 
164     /**
165      * Value for {@link #flags}: true when the application's window can be
166      * reduced in size for smaller screens.  Corresponds to
167      * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
168      * android:smallScreens}.
169      */
170     public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
171 
172     /**
173      * Value for {@link #flags}: true when the application's window can be
174      * displayed on normal screens.  Corresponds to
175      * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
176      * android:normalScreens}.
177      */
178     public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
179 
180     /**
181      * Value for {@link #flags}: true when the application's window can be
182      * increased in size for larger screens.  Corresponds to
183      * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
184      * android:largeScreens}.
185      */
186     public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
187 
188     /**
189      * Value for {@link #flags}: true when the application knows how to adjust
190      * its UI for different screen sizes.  Corresponds to
191      * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
192      * android:resizeable}.
193      */
194     public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
195 
196     /**
197      * Value for {@link #flags}: true when the application knows how to
198      * accomodate different screen densities.  Corresponds to
199      * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
200      * android:anyDensity}.
201      */
202     public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
203 
204     /**
205      * Value for {@link #flags}: set to true if this application would like to
206      * request the VM to operate under the safe mode. Comes from
207      * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
208      * android:vmSafeMode} of the &lt;application&gt; tag.
209      */
210     public static final int FLAG_VM_SAFE_MODE = 1<<14;
211 
212     /**
213      * Value for {@link #flags}: set to <code>false</code> if the application does not wish
214      * to permit any OS-driven backups of its data; <code>true</code> otherwise.
215      *
216      * <p>Comes from the
217      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
218      * attribute of the &lt;application&gt; tag.
219      */
220     public static final int FLAG_ALLOW_BACKUP = 1<<15;
221 
222     /**
223      * Value for {@link #flags}: set to <code>false</code> if the application must be kept
224      * in memory following a full-system restore operation; <code>true</code> otherwise.
225      * Ordinarily, during a full system restore operation each application is shut down
226      * following execution of its agent's onRestore() method.  Setting this attribute to
227      * <code>false</code> prevents this.  Most applications will not need to set this attribute.
228      *
229      * <p>If
230      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
231      * is set to <code>false</code> or no
232      * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
233      * is specified, this flag will be ignored.
234      *
235      * <p>Comes from the
236      * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
237      * attribute of the &lt;application&gt; tag.
238      */
239     public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
240 
241     /**
242      * Value for {@link #flags}: Set to <code>true</code> if the application's backup
243      * agent claims to be able to handle restore data even "from the future,"
244      * i.e. from versions of the application with a versionCode greater than
245      * the one currently installed on the device.  <i>Use with caution!</i>  By default
246      * this attribute is <code>false</code> and the Backup Manager will ensure that data
247      * from "future" versions of the application are never supplied during a restore operation.
248      *
249      * <p>If
250      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
251      * is set to <code>false</code> or no
252      * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
253      * is specified, this flag will be ignored.
254      *
255      * <p>Comes from the
256      * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
257      * attribute of the &lt;application&gt; tag.
258      */
259     public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
260 
261     /**
262      * Value for {@link #flags}: Set to true if the application is
263      * currently installed on external/removable/unprotected storage.  Such
264      * applications may not be available if their storage is not currently
265      * mounted.  When the storage it is on is not available, it will look like
266      * the application has been uninstalled (its .apk is no longer available)
267      * but its persistent data is not removed.
268      */
269     public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
270 
271     /**
272      * Value for {@link #flags}: true when the application's window can be
273      * increased in size for extra large screens.  Corresponds to
274      * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
275      * android:xlargeScreens}.
276      */
277     public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
278 
279     /**
280      * Value for {@link #flags}: true when the application has requested a
281      * large heap for its processes.  Corresponds to
282      * {@link android.R.styleable#AndroidManifestApplication_largeHeap
283      * android:largeHeap}.
284      */
285     public static final int FLAG_LARGE_HEAP = 1<<20;
286 
287     /**
288      * Value for {@link #flags}: true if this application's package is in
289      * the stopped state.
290      */
291     public static final int FLAG_STOPPED = 1<<21;
292 
293     /**
294      * Value for {@link #flags}: true  when the application is willing to support
295      * RTL (right to left). All activities will inherit this value.
296      *
297      * Set from the {@link android.R.attr#supportsRtl} attribute in the
298      * activity's manifest.
299      *
300      * Default value is false (no support for RTL).
301      * @hide
302      */
303     public static final int FLAG_SUPPORTS_RTL = 1<<22;
304 
305     /**
306      * Value for {@link #flags}: Set to true if the application has been
307      * installed using the forward lock option.
308      *
309      * NOTE: DO NOT CHANGE THIS VALUE!  It is saved in packages.xml.
310      *
311      * {@hide}
312      */
313     public static final int FLAG_FORWARD_LOCK = 1<<29;
314 
315     /**
316      * Value for {@link #flags}: set to <code>true</code> if the application
317      * has reported that it is heavy-weight, and thus can not participate in
318      * the normal application lifecycle.
319      *
320      * <p>Comes from the
321      * {@link android.R.styleable#AndroidManifestApplication_cantSaveState android:cantSaveState}
322      * attribute of the &lt;application&gt; tag.
323      *
324      * {@hide}
325      */
326     public static final int FLAG_CANT_SAVE_STATE = 1<<28;
327 
328     /**
329      * Flags associated with the application.  Any combination of
330      * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
331      * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
332      * {@link #FLAG_ALLOW_TASK_REPARENTING}
333      * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
334      * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
335      * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
336      * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
337      * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
338      * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE}
339      */
340     public int flags = 0;
341 
342     /**
343      * The required smallest screen width the application can run on.  If 0,
344      * nothing has been specified.  Comes from
345      * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
346      * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
347      */
348     public int requiresSmallestWidthDp = 0;
349 
350     /**
351      * The maximum smallest screen width the application is designed for.  If 0,
352      * nothing has been specified.  Comes from
353      * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
354      * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
355      */
356     public int compatibleWidthLimitDp = 0;
357 
358     /**
359      * The maximum smallest screen width the application will work on.  If 0,
360      * nothing has been specified.  Comes from
361      * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
362      * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
363      */
364     public int largestWidthLimitDp = 0;
365 
366     /**
367      * Full path to the location of this package.
368      */
369     public String sourceDir;
370 
371     /**
372      * Full path to the location of the publicly available parts of this
373      * package (i.e. the primary resource package and manifest).  For
374      * non-forward-locked apps this will be the same as {@link #sourceDir).
375      */
376     public String publicSourceDir;
377 
378     /**
379      * Full paths to the locations of extra resource packages this application
380      * uses. This field is only used if there are extra resource packages,
381      * otherwise it is null.
382      *
383      * {@hide}
384      */
385     public String[] resourceDirs;
386 
387     /**
388      * Paths to all shared libraries this application is linked against.  This
389      * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
390      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
391      * the structure.
392      */
393     public String[] sharedLibraryFiles;
394 
395     /**
396      * Full path to a directory assigned to the package for its persistent
397      * data.
398      */
399     public String dataDir;
400 
401     /**
402      * Full path to the directory where native JNI libraries are stored.
403      */
404     public String nativeLibraryDir;
405 
406     /**
407      * The kernel user-ID that has been assigned to this application;
408      * currently this is not a unique ID (multiple applications can have
409      * the same uid).
410      */
411     public int uid;
412 
413     /**
414      * The minimum SDK version this application targets.  It may run on earlier
415      * versions, but it knows how to work with any new behavior added at this
416      * version.  Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
417      * if this is a development build and the app is targeting that.  You should
418      * compare that this number is >= the SDK version number at which your
419      * behavior was introduced.
420      */
421     public int targetSdkVersion;
422 
423     /**
424      * When false, indicates that all components within this application are
425      * considered disabled, regardless of their individually set enabled status.
426      */
427     public boolean enabled = true;
428 
429     /**
430      * For convenient access to the current enabled setting of this app.
431      * @hide
432      */
433     public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
434 
435     /**
436      * For convenient access to package's install location.
437      * @hide
438      */
439     public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
440 
dump(Printer pw, String prefix)441     public void dump(Printer pw, String prefix) {
442         super.dumpFront(pw, prefix);
443         if (className != null) {
444             pw.println(prefix + "className=" + className);
445         }
446         if (permission != null) {
447             pw.println(prefix + "permission=" + permission);
448         }
449         pw.println(prefix + "processName=" + processName);
450         pw.println(prefix + "taskAffinity=" + taskAffinity);
451         pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
452                 + " theme=0x" + Integer.toHexString(theme));
453         pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
454                 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
455                 + " largestWidthLimitDp=" + largestWidthLimitDp);
456         pw.println(prefix + "sourceDir=" + sourceDir);
457         if (sourceDir == null) {
458             if (publicSourceDir != null) {
459                 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
460             }
461         } else if (!sourceDir.equals(publicSourceDir)) {
462             pw.println(prefix + "publicSourceDir=" + publicSourceDir);
463         }
464         if (resourceDirs != null) {
465             pw.println(prefix + "resourceDirs=" + resourceDirs);
466         }
467         pw.println(prefix + "dataDir=" + dataDir);
468         if (sharedLibraryFiles != null) {
469             pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
470         }
471         pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion);
472         if (manageSpaceActivityName != null) {
473             pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
474         }
475         if (descriptionRes != 0) {
476             pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
477         }
478         if (uiOptions != 0) {
479             pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
480         }
481         pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
482         super.dumpBack(pw, prefix);
483     }
484 
485     /**
486      * @return true if "supportsRtl" has been set to true in the AndroidManifest
487      * @hide
488      */
hasRtlSupport()489     public boolean hasRtlSupport() {
490         return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
491     }
492 
493     public static class DisplayNameComparator
494             implements Comparator<ApplicationInfo> {
DisplayNameComparator(PackageManager pm)495         public DisplayNameComparator(PackageManager pm) {
496             mPM = pm;
497         }
498 
compare(ApplicationInfo aa, ApplicationInfo ab)499         public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
500             CharSequence  sa = mPM.getApplicationLabel(aa);
501             if (sa == null) {
502                 sa = aa.packageName;
503             }
504             CharSequence  sb = mPM.getApplicationLabel(ab);
505             if (sb == null) {
506                 sb = ab.packageName;
507             }
508 
509             return sCollator.compare(sa.toString(), sb.toString());
510         }
511 
512         private final Collator   sCollator = Collator.getInstance();
513         private PackageManager   mPM;
514     }
515 
ApplicationInfo()516     public ApplicationInfo() {
517     }
518 
ApplicationInfo(ApplicationInfo orig)519     public ApplicationInfo(ApplicationInfo orig) {
520         super(orig);
521         taskAffinity = orig.taskAffinity;
522         permission = orig.permission;
523         processName = orig.processName;
524         className = orig.className;
525         theme = orig.theme;
526         flags = orig.flags;
527         requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
528         compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
529         largestWidthLimitDp = orig.largestWidthLimitDp;
530         sourceDir = orig.sourceDir;
531         publicSourceDir = orig.publicSourceDir;
532         nativeLibraryDir = orig.nativeLibraryDir;
533         resourceDirs = orig.resourceDirs;
534         sharedLibraryFiles = orig.sharedLibraryFiles;
535         dataDir = orig.dataDir;
536         uid = orig.uid;
537         targetSdkVersion = orig.targetSdkVersion;
538         enabled = orig.enabled;
539         enabledSetting = orig.enabledSetting;
540         installLocation = orig.installLocation;
541         manageSpaceActivityName = orig.manageSpaceActivityName;
542         descriptionRes = orig.descriptionRes;
543         uiOptions = orig.uiOptions;
544     }
545 
546 
toString()547     public String toString() {
548         return "ApplicationInfo{"
549             + Integer.toHexString(System.identityHashCode(this))
550             + " " + packageName + "}";
551     }
552 
describeContents()553     public int describeContents() {
554         return 0;
555     }
556 
writeToParcel(Parcel dest, int parcelableFlags)557     public void writeToParcel(Parcel dest, int parcelableFlags) {
558         super.writeToParcel(dest, parcelableFlags);
559         dest.writeString(taskAffinity);
560         dest.writeString(permission);
561         dest.writeString(processName);
562         dest.writeString(className);
563         dest.writeInt(theme);
564         dest.writeInt(flags);
565         dest.writeInt(requiresSmallestWidthDp);
566         dest.writeInt(compatibleWidthLimitDp);
567         dest.writeInt(largestWidthLimitDp);
568         dest.writeString(sourceDir);
569         dest.writeString(publicSourceDir);
570         dest.writeString(nativeLibraryDir);
571         dest.writeStringArray(resourceDirs);
572         dest.writeStringArray(sharedLibraryFiles);
573         dest.writeString(dataDir);
574         dest.writeInt(uid);
575         dest.writeInt(targetSdkVersion);
576         dest.writeInt(enabled ? 1 : 0);
577         dest.writeInt(enabledSetting);
578         dest.writeInt(installLocation);
579         dest.writeString(manageSpaceActivityName);
580         dest.writeString(backupAgentName);
581         dest.writeInt(descriptionRes);
582         dest.writeInt(uiOptions);
583     }
584 
585     public static final Parcelable.Creator<ApplicationInfo> CREATOR
586             = new Parcelable.Creator<ApplicationInfo>() {
587         public ApplicationInfo createFromParcel(Parcel source) {
588             return new ApplicationInfo(source);
589         }
590         public ApplicationInfo[] newArray(int size) {
591             return new ApplicationInfo[size];
592         }
593     };
594 
ApplicationInfo(Parcel source)595     private ApplicationInfo(Parcel source) {
596         super(source);
597         taskAffinity = source.readString();
598         permission = source.readString();
599         processName = source.readString();
600         className = source.readString();
601         theme = source.readInt();
602         flags = source.readInt();
603         requiresSmallestWidthDp = source.readInt();
604         compatibleWidthLimitDp = source.readInt();
605         largestWidthLimitDp = source.readInt();
606         sourceDir = source.readString();
607         publicSourceDir = source.readString();
608         nativeLibraryDir = source.readString();
609         resourceDirs = source.readStringArray();
610         sharedLibraryFiles = source.readStringArray();
611         dataDir = source.readString();
612         uid = source.readInt();
613         targetSdkVersion = source.readInt();
614         enabled = source.readInt() != 0;
615         enabledSetting = source.readInt();
616         installLocation = source.readInt();
617         manageSpaceActivityName = source.readString();
618         backupAgentName = source.readString();
619         descriptionRes = source.readInt();
620         uiOptions = source.readInt();
621     }
622 
623     /**
624      * Retrieve the textual description of the application.  This
625      * will call back on the given PackageManager to load the description from
626      * the application.
627      *
628      * @param pm A PackageManager from which the label can be loaded; usually
629      * the PackageManager from which you originally retrieved this item.
630      *
631      * @return Returns a CharSequence containing the application's description.
632      * If there is no description, null is returned.
633      */
loadDescription(PackageManager pm)634     public CharSequence loadDescription(PackageManager pm) {
635         if (descriptionRes != 0) {
636             CharSequence label = pm.getText(packageName, descriptionRes, this);
637             if (label != null) {
638                 return label;
639             }
640         }
641         return null;
642     }
643 
644     /**
645      * Disable compatibility mode
646      *
647      * @hide
648      */
disableCompatibilityMode()649     public void disableCompatibilityMode() {
650         flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
651                 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
652                 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
653     }
654 
655     /**
656      * @hide
657      */
loadDefaultIcon(PackageManager pm)658     @Override protected Drawable loadDefaultIcon(PackageManager pm) {
659         if ((flags & FLAG_EXTERNAL_STORAGE) != 0
660                 && isPackageUnavailable(pm)) {
661             return Resources.getSystem().getDrawable(
662                     com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
663         }
664         return pm.getDefaultActivityIcon();
665     }
666 
isPackageUnavailable(PackageManager pm)667     private boolean isPackageUnavailable(PackageManager pm) {
668         try {
669             return pm.getPackageInfo(packageName, 0) == null;
670         } catch (NameNotFoundException ex) {
671             return true;
672         }
673     }
674 
675     /**
676      * @hide
677      */
getApplicationInfo()678     @Override protected ApplicationInfo getApplicationInfo() {
679         return this;
680     }
681 }
682