blob: 454cb31953164fe6dd001a4c487558a08592dfff [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 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700333 * The required smallest screen width the application can run on. If 0,
334 * nothing has been specified. Comes from
335 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
336 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
337 */
338 public int requiresSmallestWidthDp = 0;
339
340 /**
341 * The maximum smallest screen width the application is designed for. If 0,
342 * nothing has been specified. Comes from
343 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
344 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
345 */
346 public int compatibleWidthLimitDp = 0;
347
348 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700349 * The maximum smallest screen width the application will work on. If 0,
350 * nothing has been specified. Comes from
351 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
352 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
353 */
354 public int largestWidthLimitDp = 0;
355
356 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800357 * Full path to the location of this package.
358 */
359 public String sourceDir;
360
361 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800362 * Full path to the location of the publicly available parts of this
363 * package (i.e. the primary resource package and manifest). For
364 * non-forward-locked apps this will be the same as {@link #sourceDir).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800365 */
366 public String publicSourceDir;
367
368 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800369 * Full paths to the locations of extra resource packages this application
370 * uses. This field is only used if there are extra resource packages,
371 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800372 *
373 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800374 */
375 public String[] resourceDirs;
376
377 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800378 * Paths to all shared libraries this application is linked against. This
379 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
380 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
381 * the structure.
382 */
383 public String[] sharedLibraryFiles;
384
385 /**
386 * Full path to a directory assigned to the package for its persistent
387 * data.
388 */
389 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700390
391 /**
392 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700393 */
394 public String nativeLibraryDir;
395
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800396 /**
397 * The kernel user-ID that has been assigned to this application;
398 * currently this is not a unique ID (multiple applications can have
399 * the same uid).
400 */
401 public int uid;
402
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700403 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700404 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700405 * versions, but it knows how to work with any new behavior added at this
406 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
407 * if this is a development build and the app is targeting that. You should
408 * compare that this number is >= the SDK version number at which your
409 * behavior was introduced.
410 */
411 public int targetSdkVersion;
412
413 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800414 * When false, indicates that all components within this application are
415 * considered disabled, regardless of their individually set enabled status.
416 */
417 public boolean enabled = true;
418
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700419 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700420 * For convenient access to the current enabled setting of this app.
421 * @hide
422 */
423 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
424
425 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700426 * For convenient access to package's install location.
427 * @hide
428 */
429 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
430
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800431 public void dump(Printer pw, String prefix) {
432 super.dumpFront(pw, prefix);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800433 if (className != null) {
434 pw.println(prefix + "className=" + className);
435 }
436 if (permission != null) {
437 pw.println(prefix + "permission=" + permission);
438 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700439 pw.println(prefix + "processName=" + processName);
440 pw.println(prefix + "taskAffinity=" + taskAffinity);
441 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
442 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700443 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700444 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
445 + " largestWidthLimitDp=" + largestWidthLimitDp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 pw.println(prefix + "sourceDir=" + sourceDir);
Dianne Hackborn817c2472010-10-05 14:40:22 -0700447 if (sourceDir == null) {
448 if (publicSourceDir != null) {
449 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
450 }
451 } else if (!sourceDir.equals(publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700452 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
453 }
454 if (resourceDirs != null) {
455 pw.println(prefix + "resourceDirs=" + resourceDirs);
456 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800458 if (sharedLibraryFiles != null) {
459 pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
460 }
461 pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion);
462 if (manageSpaceActivityName != null) {
463 pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
464 }
465 if (descriptionRes != 0) {
466 pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
467 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800468 super.dumpBack(pw, prefix);
469 }
470
471 public static class DisplayNameComparator
472 implements Comparator<ApplicationInfo> {
473 public DisplayNameComparator(PackageManager pm) {
474 mPM = pm;
475 }
476
477 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
478 CharSequence sa = mPM.getApplicationLabel(aa);
479 if (sa == null) {
480 sa = aa.packageName;
481 }
482 CharSequence sb = mPM.getApplicationLabel(ab);
483 if (sb == null) {
484 sb = ab.packageName;
485 }
486
487 return sCollator.compare(sa.toString(), sb.toString());
488 }
489
490 private final Collator sCollator = Collator.getInstance();
491 private PackageManager mPM;
492 }
493
494 public ApplicationInfo() {
495 }
496
497 public ApplicationInfo(ApplicationInfo orig) {
498 super(orig);
499 taskAffinity = orig.taskAffinity;
500 permission = orig.permission;
501 processName = orig.processName;
502 className = orig.className;
503 theme = orig.theme;
504 flags = orig.flags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700505 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
506 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700507 largestWidthLimitDp = orig.largestWidthLimitDp;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800508 sourceDir = orig.sourceDir;
509 publicSourceDir = orig.publicSourceDir;
Kenny Root85387d72010-08-26 10:13:11 -0700510 nativeLibraryDir = orig.nativeLibraryDir;
Kenny Rootd1ab0162010-01-21 17:27:14 -0800511 resourceDirs = orig.resourceDirs;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800512 sharedLibraryFiles = orig.sharedLibraryFiles;
513 dataDir = orig.dataDir;
514 uid = orig.uid;
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700515 targetSdkVersion = orig.targetSdkVersion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800516 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700517 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700518 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 manageSpaceActivityName = orig.manageSpaceActivityName;
520 descriptionRes = orig.descriptionRes;
521 }
522
523
524 public String toString() {
525 return "ApplicationInfo{"
526 + Integer.toHexString(System.identityHashCode(this))
527 + " " + packageName + "}";
528 }
529
530 public int describeContents() {
531 return 0;
532 }
533
534 public void writeToParcel(Parcel dest, int parcelableFlags) {
535 super.writeToParcel(dest, parcelableFlags);
536 dest.writeString(taskAffinity);
537 dest.writeString(permission);
538 dest.writeString(processName);
539 dest.writeString(className);
540 dest.writeInt(theme);
541 dest.writeInt(flags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700542 dest.writeInt(requiresSmallestWidthDp);
543 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700544 dest.writeInt(largestWidthLimitDp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800545 dest.writeString(sourceDir);
546 dest.writeString(publicSourceDir);
Kenny Root85387d72010-08-26 10:13:11 -0700547 dest.writeString(nativeLibraryDir);
Kenny Rootd1ab0162010-01-21 17:27:14 -0800548 dest.writeStringArray(resourceDirs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 dest.writeStringArray(sharedLibraryFiles);
550 dest.writeString(dataDir);
551 dest.writeInt(uid);
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700552 dest.writeInt(targetSdkVersion);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800553 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700554 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700555 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800556 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700557 dest.writeString(backupAgentName);
Christopher Tate4a627c72011-04-01 14:43:32 -0700558 dest.writeString(fullBackupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800559 dest.writeInt(descriptionRes);
560 }
561
562 public static final Parcelable.Creator<ApplicationInfo> CREATOR
563 = new Parcelable.Creator<ApplicationInfo>() {
564 public ApplicationInfo createFromParcel(Parcel source) {
565 return new ApplicationInfo(source);
566 }
567 public ApplicationInfo[] newArray(int size) {
568 return new ApplicationInfo[size];
569 }
570 };
571
572 private ApplicationInfo(Parcel source) {
573 super(source);
574 taskAffinity = source.readString();
575 permission = source.readString();
576 processName = source.readString();
577 className = source.readString();
578 theme = source.readInt();
579 flags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700580 requiresSmallestWidthDp = source.readInt();
581 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700582 largestWidthLimitDp = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800583 sourceDir = source.readString();
584 publicSourceDir = source.readString();
Kenny Root85387d72010-08-26 10:13:11 -0700585 nativeLibraryDir = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -0800586 resourceDirs = source.readStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800587 sharedLibraryFiles = source.readStringArray();
588 dataDir = source.readString();
589 uid = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700590 targetSdkVersion = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800591 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700592 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700593 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800594 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -0700595 backupAgentName = source.readString();
Christopher Tate4a627c72011-04-01 14:43:32 -0700596 fullBackupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800597 descriptionRes = source.readInt();
598 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700599
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800600 /**
601 * Retrieve the textual description of the application. This
602 * will call back on the given PackageManager to load the description from
603 * the application.
604 *
605 * @param pm A PackageManager from which the label can be loaded; usually
606 * the PackageManager from which you originally retrieved this item.
607 *
608 * @return Returns a CharSequence containing the application's description.
609 * If there is no description, null is returned.
610 */
611 public CharSequence loadDescription(PackageManager pm) {
612 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -0700613 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800614 if (label != null) {
615 return label;
616 }
617 }
618 return null;
619 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700620
621 /**
622 * Disable compatibility mode
623 *
624 * @hide
625 */
626 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -0700627 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700628 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700629 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700630 }
Jeff Brown07330792010-03-30 19:57:08 -0700631
632 /**
633 * @hide
634 */
635 @Override protected Drawable loadDefaultIcon(PackageManager pm) {
636 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
637 && isPackageUnavailable(pm)) {
638 return Resources.getSystem().getDrawable(
639 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
640 }
641 return pm.getDefaultActivityIcon();
642 }
643
644 private boolean isPackageUnavailable(PackageManager pm) {
645 try {
646 return pm.getPackageInfo(packageName, 0) == null;
647 } catch (NameNotFoundException ex) {
648 return true;
649 }
650 }
651
652 /**
653 * @hide
654 */
655 @Override protected ApplicationInfo getApplicationInfo() {
656 return this;
657 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800658}