blob: 4b38d48c00bd11611be92047df2b5b317c0f1eef [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
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
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
Jeff Brown07330792010-03-30 19:57:08 -070019import android.content.pm.PackageManager.NameNotFoundException;
20import android.content.res.Resources;
21import android.graphics.drawable.Drawable;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.os.Parcel;
23import android.os.Parcelable;
24import android.util.Printer;
25
26import java.text.Collator;
27import 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 */
34public 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
Christopher Tate181fafa2009-05-14 11:12:14 -070080 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 */
82 public String manageSpaceActivityName;
83
84 /**
Christopher Tate181fafa2009-05-14 11:12:14 -070085 * 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.
Christopher Tate181fafa2009-05-14 11:12:14 -070090 */
91 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -070092
93 /**
94 * Class implementing the package's *full* backup functionality. This
95 * is not usable except by system-installed packages. It can be the same
96 * as the backupAgent.
97 *
98 * @hide
99 */
100 public String fullBackupAgentName;
101
Christopher Tate181fafa2009-05-14 11:12:14 -0700102 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 * Value for {@link #flags}: if set, this application is installed in the
104 * device's system image.
105 */
106 public static final int FLAG_SYSTEM = 1<<0;
107
108 /**
109 * Value for {@link #flags}: set to true if this application would like to
110 * allow debugging of its
111 * code, even when installed on a non-development system. Comes
112 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
113 * android:debuggable} of the &lt;application&gt; tag.
114 */
115 public static final int FLAG_DEBUGGABLE = 1<<1;
116
117 /**
118 * Value for {@link #flags}: set to true if this application has code
119 * associated with it. Comes
120 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
121 * android:hasCode} of the &lt;application&gt; tag.
122 */
123 public static final int FLAG_HAS_CODE = 1<<2;
124
125 /**
126 * Value for {@link #flags}: set to true if this application is persistent.
127 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
128 * android:persistent} of the &lt;application&gt; tag.
129 */
130 public static final int FLAG_PERSISTENT = 1<<3;
131
132 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700133 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
135 * device is running in factory test mode.
136 */
137 public static final int FLAG_FACTORY_TEST = 1<<4;
138
139 /**
140 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
141 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
142 * android:allowTaskReparenting} of the &lt;application&gt; tag.
143 */
144 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
145
146 /**
147 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
148 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
149 * android:allowClearUserData} of the &lt;application&gt; tag.
150 */
151 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
152
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800153 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700154 * Value for {@link #flags}: this is set if this application has been
155 * install as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800156 */
157 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700158
159 /**
Dianne Hackborn7f205432009-07-28 00:13:47 -0700160 * Value for {@link #flags}: this is set of the application has specified
161 * {@link android.R.styleable#AndroidManifestApplication_testOnly
162 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700163 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700164 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700165
166 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700167 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700168 * reduced in size for smaller screens. Corresponds to
169 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
170 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700171 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700172 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
173
174 /**
175 * Value for {@link #flags}: true when the application's window can be
176 * displayed on normal screens. Corresponds to
177 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
178 * android:normalScreens}.
179 */
180 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
181
182 /**
183 * Value for {@link #flags}: true when the application's window can be
184 * increased in size for larger screens. Corresponds to
185 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700186 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700187 */
188 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700189
190 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700191 * Value for {@link #flags}: true when the application knows how to adjust
192 * its UI for different screen sizes. Corresponds to
193 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
194 * android:resizeable}.
195 */
196 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
197
198 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700199 * Value for {@link #flags}: true when the application knows how to
200 * accomodate different screen densities. Corresponds to
201 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
202 * android:anyDensity}.
203 */
204 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
205
206 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800207 * Value for {@link #flags}: set to true if this application would like to
208 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700209 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
210 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800211 */
212 public static final int FLAG_VM_SAFE_MODE = 1<<14;
213
214 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800215 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
216 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700217 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800218 * <p>Comes from the
219 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
220 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700221 */
Ben Cheng23085b72010-02-08 16:06:32 -0800222 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700223
224 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800225 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
226 * in memory following a full-system restore operation; <code>true</code> otherwise.
227 * Ordinarily, during a full system restore operation each application is shut down
228 * following execution of its agent's onRestore() method. Setting this attribute to
229 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700230 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800231 * <p>If
232 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
233 * is set to <code>false</code> or no
234 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700235 * is specified, this flag will be ignored.
236 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800237 * <p>Comes from the
238 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
239 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700240 */
Ben Cheng23085b72010-02-08 16:06:32 -0800241 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700242
243 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800244 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
245 * agent claims to be able to handle restore data even "from the future,"
246 * i.e. from versions of the application with a versionCode greater than
247 * the one currently installed on the device. <i>Use with caution!</i> By default
248 * this attribute is <code>false</code> and the Backup Manager will ensure that data
249 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700250 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800251 * <p>If
252 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
253 * is set to <code>false</code> or no
254 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700255 * is specified, this flag will be ignored.
256 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800257 * <p>Comes from the
258 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
259 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700260 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800261 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700262
Christopher Tate181fafa2009-05-14 11:12:14 -0700263 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700264 * Value for {@link #flags}: Set to true if the application is
265 * currently installed on external/removable/unprotected storage. Such
266 * applications may not be available if their storage is not currently
267 * mounted. When the storage it is on is not available, it will look like
268 * the application has been uninstalled (its .apk is no longer available)
269 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800270 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700271 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800272
273 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700274 * Value for {@link #flags}: true when the application's window can be
275 * increased in size for extra large screens. Corresponds to
276 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700277 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700278 */
279 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
280
281 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800282 * Value for {@link #flags}: true when the application has requested a
283 * large heap for its processes. Corresponds to
284 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
285 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600286 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800287 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600288
289 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800290 * Value for {@link #flags}: true if this application's package is in
291 * the stopped state.
292 */
293 public static final int FLAG_STOPPED = 1<<21;
294
295 /**
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800296 * Value for {@link #flags}: Set to true if the application has been
297 * installed using the forward lock option.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800298 *
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800299 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
300 *
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800301 * {@hide}
302 */
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800303 public static final int FLAG_FORWARD_LOCK = 1<<29;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800304
305 /**
Dianne Hackborn02486b12010-08-26 14:18:37 -0700306 * Value for {@link #flags}: set to <code>true</code> if the application
307 * has reported that it is heavy-weight, and thus can not participate in
308 * the normal application lifecycle.
309 *
310 * <p>Comes from the
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700311 * {@link android.R.styleable#AndroidManifestApplication_cantSaveState android:cantSaveState}
Dianne Hackborn02486b12010-08-26 14:18:37 -0700312 * attribute of the &lt;application&gt; tag.
313 *
314 * {@hide}
315 */
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800316 public static final int FLAG_CANT_SAVE_STATE = 1<<28;
Dianne Hackborn02486b12010-08-26 14:18:37 -0700317
318 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800319 * Flags associated with the application. Any combination of
320 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
321 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
322 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700323 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700324 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
325 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700326 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
327 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Ben Cheng23085b72010-02-08 16:06:32 -0800328 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800329 */
330 public int flags = 0;
331
332 /**
333 * Full path to the location of this package.
334 */
335 public String sourceDir;
336
337 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800338 * Full path to the location of the publicly available parts of this
339 * package (i.e. the primary resource package and manifest). For
340 * non-forward-locked apps this will be the same as {@link #sourceDir).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800341 */
342 public String publicSourceDir;
343
344 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800345 * Full paths to the locations of extra resource packages this application
346 * uses. This field is only used if there are extra resource packages,
347 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800348 *
349 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800350 */
351 public String[] resourceDirs;
352
353 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800354 * Paths to all shared libraries this application is linked against. This
355 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
356 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
357 * the structure.
358 */
359 public String[] sharedLibraryFiles;
360
361 /**
362 * Full path to a directory assigned to the package for its persistent
363 * data.
364 */
365 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700366
367 /**
368 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700369 */
370 public String nativeLibraryDir;
371
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800372 /**
373 * The kernel user-ID that has been assigned to this application;
374 * currently this is not a unique ID (multiple applications can have
375 * the same uid).
376 */
377 public int uid;
378
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700379 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700380 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700381 * versions, but it knows how to work with any new behavior added at this
382 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
383 * if this is a development build and the app is targeting that. You should
384 * compare that this number is >= the SDK version number at which your
385 * behavior was introduced.
386 */
387 public int targetSdkVersion;
388
389 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390 * When false, indicates that all components within this application are
391 * considered disabled, regardless of their individually set enabled status.
392 */
393 public boolean enabled = true;
394
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700395 /**
396 * For convenient access to package's install location.
397 * @hide
398 */
399 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
400
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800401 public void dump(Printer pw, String prefix) {
402 super.dumpFront(pw, prefix);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800403 if (className != null) {
404 pw.println(prefix + "className=" + className);
405 }
406 if (permission != null) {
407 pw.println(prefix + "permission=" + permission);
408 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700409 pw.println(prefix + "processName=" + processName);
410 pw.println(prefix + "taskAffinity=" + taskAffinity);
411 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
412 + " theme=0x" + Integer.toHexString(theme));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800413 pw.println(prefix + "sourceDir=" + sourceDir);
Dianne Hackborn817c2472010-10-05 14:40:22 -0700414 if (sourceDir == null) {
415 if (publicSourceDir != null) {
416 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
417 }
418 } else if (!sourceDir.equals(publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700419 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
420 }
421 if (resourceDirs != null) {
422 pw.println(prefix + "resourceDirs=" + resourceDirs);
423 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800424 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800425 if (sharedLibraryFiles != null) {
426 pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
427 }
428 pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion);
429 if (manageSpaceActivityName != null) {
430 pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
431 }
432 if (descriptionRes != 0) {
433 pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
434 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800435 super.dumpBack(pw, prefix);
436 }
437
438 public static class DisplayNameComparator
439 implements Comparator<ApplicationInfo> {
440 public DisplayNameComparator(PackageManager pm) {
441 mPM = pm;
442 }
443
444 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
445 CharSequence sa = mPM.getApplicationLabel(aa);
446 if (sa == null) {
447 sa = aa.packageName;
448 }
449 CharSequence sb = mPM.getApplicationLabel(ab);
450 if (sb == null) {
451 sb = ab.packageName;
452 }
453
454 return sCollator.compare(sa.toString(), sb.toString());
455 }
456
457 private final Collator sCollator = Collator.getInstance();
458 private PackageManager mPM;
459 }
460
461 public ApplicationInfo() {
462 }
463
464 public ApplicationInfo(ApplicationInfo orig) {
465 super(orig);
466 taskAffinity = orig.taskAffinity;
467 permission = orig.permission;
468 processName = orig.processName;
469 className = orig.className;
470 theme = orig.theme;
471 flags = orig.flags;
472 sourceDir = orig.sourceDir;
473 publicSourceDir = orig.publicSourceDir;
Kenny Root85387d72010-08-26 10:13:11 -0700474 nativeLibraryDir = orig.nativeLibraryDir;
Kenny Rootd1ab0162010-01-21 17:27:14 -0800475 resourceDirs = orig.resourceDirs;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800476 sharedLibraryFiles = orig.sharedLibraryFiles;
477 dataDir = orig.dataDir;
478 uid = orig.uid;
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700479 targetSdkVersion = orig.targetSdkVersion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800480 enabled = orig.enabled;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700481 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800482 manageSpaceActivityName = orig.manageSpaceActivityName;
483 descriptionRes = orig.descriptionRes;
484 }
485
486
487 public String toString() {
488 return "ApplicationInfo{"
489 + Integer.toHexString(System.identityHashCode(this))
490 + " " + packageName + "}";
491 }
492
493 public int describeContents() {
494 return 0;
495 }
496
497 public void writeToParcel(Parcel dest, int parcelableFlags) {
498 super.writeToParcel(dest, parcelableFlags);
499 dest.writeString(taskAffinity);
500 dest.writeString(permission);
501 dest.writeString(processName);
502 dest.writeString(className);
503 dest.writeInt(theme);
504 dest.writeInt(flags);
505 dest.writeString(sourceDir);
506 dest.writeString(publicSourceDir);
Kenny Root85387d72010-08-26 10:13:11 -0700507 dest.writeString(nativeLibraryDir);
Kenny Rootd1ab0162010-01-21 17:27:14 -0800508 dest.writeStringArray(resourceDirs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 dest.writeStringArray(sharedLibraryFiles);
510 dest.writeString(dataDir);
511 dest.writeInt(uid);
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700512 dest.writeInt(targetSdkVersion);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800513 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700514 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800515 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700516 dest.writeString(backupAgentName);
Christopher Tate4a627c72011-04-01 14:43:32 -0700517 dest.writeString(fullBackupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800518 dest.writeInt(descriptionRes);
519 }
520
521 public static final Parcelable.Creator<ApplicationInfo> CREATOR
522 = new Parcelable.Creator<ApplicationInfo>() {
523 public ApplicationInfo createFromParcel(Parcel source) {
524 return new ApplicationInfo(source);
525 }
526 public ApplicationInfo[] newArray(int size) {
527 return new ApplicationInfo[size];
528 }
529 };
530
531 private ApplicationInfo(Parcel source) {
532 super(source);
533 taskAffinity = source.readString();
534 permission = source.readString();
535 processName = source.readString();
536 className = source.readString();
537 theme = source.readInt();
538 flags = source.readInt();
539 sourceDir = source.readString();
540 publicSourceDir = source.readString();
Kenny Root85387d72010-08-26 10:13:11 -0700541 nativeLibraryDir = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -0800542 resourceDirs = source.readStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 sharedLibraryFiles = source.readStringArray();
544 dataDir = source.readString();
545 uid = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700546 targetSdkVersion = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800547 enabled = source.readInt() != 0;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700548 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -0700550 backupAgentName = source.readString();
Christopher Tate4a627c72011-04-01 14:43:32 -0700551 fullBackupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800552 descriptionRes = source.readInt();
553 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700554
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800555 /**
556 * Retrieve the textual description of the application. This
557 * will call back on the given PackageManager to load the description from
558 * the application.
559 *
560 * @param pm A PackageManager from which the label can be loaded; usually
561 * the PackageManager from which you originally retrieved this item.
562 *
563 * @return Returns a CharSequence containing the application's description.
564 * If there is no description, null is returned.
565 */
566 public CharSequence loadDescription(PackageManager pm) {
567 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -0700568 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800569 if (label != null) {
570 return label;
571 }
572 }
573 return null;
574 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700575
576 /**
577 * Disable compatibility mode
578 *
579 * @hide
580 */
581 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -0700582 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700583 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700584 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700585 }
Jeff Brown07330792010-03-30 19:57:08 -0700586
587 /**
588 * @hide
589 */
590 @Override protected Drawable loadDefaultIcon(PackageManager pm) {
591 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
592 && isPackageUnavailable(pm)) {
593 return Resources.getSystem().getDrawable(
594 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
595 }
596 return pm.getDefaultActivityIcon();
597 }
598
599 private boolean isPackageUnavailable(PackageManager pm) {
600 try {
601 return pm.getPackageInfo(packageName, 0) == null;
602 } catch (NameNotFoundException ex) {
603 return true;
604 }
605 }
606
607 /**
608 * @hide
609 */
610 @Override protected ApplicationInfo getApplicationInfo() {
611 return this;
612 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800613}