blob: 2bd632d5f917595c4e32761a570c3a692b485296 [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;
92
93 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080094 * Value for {@link #flags}: if set, this application is installed in the
95 * device's system image.
96 */
97 public static final int FLAG_SYSTEM = 1<<0;
98
99 /**
100 * Value for {@link #flags}: set to true if this application would like to
101 * allow debugging of its
102 * code, even when installed on a non-development system. Comes
103 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
104 * android:debuggable} of the &lt;application&gt; tag.
105 */
106 public static final int FLAG_DEBUGGABLE = 1<<1;
107
108 /**
109 * Value for {@link #flags}: set to true if this application has code
110 * associated with it. Comes
111 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
112 * android:hasCode} of the &lt;application&gt; tag.
113 */
114 public static final int FLAG_HAS_CODE = 1<<2;
115
116 /**
117 * Value for {@link #flags}: set to true if this application is persistent.
118 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
119 * android:persistent} of the &lt;application&gt; tag.
120 */
121 public static final int FLAG_PERSISTENT = 1<<3;
122
123 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700124 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800125 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
126 * device is running in factory test mode.
127 */
128 public static final int FLAG_FACTORY_TEST = 1<<4;
129
130 /**
131 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
132 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
133 * android:allowTaskReparenting} of the &lt;application&gt; tag.
134 */
135 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
136
137 /**
138 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
139 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
140 * android:allowClearUserData} of the &lt;application&gt; tag.
141 */
142 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
143
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800144 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700145 * Value for {@link #flags}: this is set if this application has been
146 * install as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147 */
148 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700149
150 /**
Dianne Hackborn7f205432009-07-28 00:13:47 -0700151 * Value for {@link #flags}: this is set of the application has specified
152 * {@link android.R.styleable#AndroidManifestApplication_testOnly
153 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700154 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700155 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700156
157 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700158 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700159 * reduced in size for smaller screens. Corresponds to
160 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
161 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700162 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700163 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
164
165 /**
166 * Value for {@link #flags}: true when the application's window can be
167 * displayed on normal screens. Corresponds to
168 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
169 * android:normalScreens}.
170 */
171 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
172
173 /**
174 * Value for {@link #flags}: true when the application's window can be
175 * increased in size for larger screens. Corresponds to
176 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700177 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700178 */
179 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700180
181 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700182 * Value for {@link #flags}: true when the application knows how to adjust
183 * its UI for different screen sizes. Corresponds to
184 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
185 * android:resizeable}.
186 */
187 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
188
189 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700190 * Value for {@link #flags}: true when the application knows how to
191 * accomodate different screen densities. Corresponds to
192 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
193 * android:anyDensity}.
194 */
195 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
196
197 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800198 * Value for {@link #flags}: set to true if this application would like to
199 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700200 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
201 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800202 */
203 public static final int FLAG_VM_SAFE_MODE = 1<<14;
204
205 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800206 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
207 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700208 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800209 * <p>Comes from the
210 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
211 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700212 */
Ben Cheng23085b72010-02-08 16:06:32 -0800213 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700214
215 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800216 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
217 * in memory following a full-system restore operation; <code>true</code> otherwise.
218 * Ordinarily, during a full system restore operation each application is shut down
219 * following execution of its agent's onRestore() method. Setting this attribute to
220 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700221 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800222 * <p>If
223 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
224 * is set to <code>false</code> or no
225 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700226 * is specified, this flag will be ignored.
227 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800228 * <p>Comes from the
229 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
230 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700231 */
Ben Cheng23085b72010-02-08 16:06:32 -0800232 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700233
234 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800235 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
236 * agent claims to be able to handle restore data even "from the future,"
237 * i.e. from versions of the application with a versionCode greater than
238 * the one currently installed on the device. <i>Use with caution!</i> By default
239 * this attribute is <code>false</code> and the Backup Manager will ensure that data
240 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700241 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800242 * <p>If
243 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
244 * is set to <code>false</code> or no
245 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700246 * is specified, this flag will be ignored.
247 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800248 * <p>Comes from the
249 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
250 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700251 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800252 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700253
Christopher Tate181fafa2009-05-14 11:12:14 -0700254 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700255 * Value for {@link #flags}: Set to true if the application is
256 * currently installed on external/removable/unprotected storage. Such
257 * applications may not be available if their storage is not currently
258 * mounted. When the storage it is on is not available, it will look like
259 * the application has been uninstalled (its .apk is no longer available)
260 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800261 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700262 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800263
264 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700265 * Value for {@link #flags}: true when the application's window can be
266 * increased in size for extra large screens. Corresponds to
267 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700268 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700269 */
270 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
271
272 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800273 * Value for {@link #flags}: true when the application has requested a
274 * large heap for its processes. Corresponds to
275 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
276 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600277 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800278 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600279
280 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800281 * Value for {@link #flags}: true if this application's package is in
282 * the stopped state.
283 */
284 public static final int FLAG_STOPPED = 1<<21;
285
286 /**
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800287 * Value for {@link #flags}: Set to true if the application has been
288 * installed using the forward lock option.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800289 *
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800290 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
291 *
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800292 * {@hide}
293 */
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800294 public static final int FLAG_FORWARD_LOCK = 1<<29;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800295
296 /**
Dianne Hackborn02486b12010-08-26 14:18:37 -0700297 * Value for {@link #flags}: set to <code>true</code> if the application
298 * has reported that it is heavy-weight, and thus can not participate in
299 * the normal application lifecycle.
300 *
301 * <p>Comes from the
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700302 * {@link android.R.styleable#AndroidManifestApplication_cantSaveState android:cantSaveState}
Dianne Hackborn02486b12010-08-26 14:18:37 -0700303 * attribute of the &lt;application&gt; tag.
304 *
305 * {@hide}
306 */
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800307 public static final int FLAG_CANT_SAVE_STATE = 1<<28;
Dianne Hackborn02486b12010-08-26 14:18:37 -0700308
309 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800310 * Flags associated with the application. Any combination of
311 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
312 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
313 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700314 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700315 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
316 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700317 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
318 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Ben Cheng23085b72010-02-08 16:06:32 -0800319 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800320 */
321 public int flags = 0;
322
323 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700324 * The required smallest screen width the application can run on. If 0,
325 * nothing has been specified. Comes from
326 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
327 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
328 */
329 public int requiresSmallestWidthDp = 0;
330
331 /**
332 * The maximum smallest screen width the application is designed for. If 0,
333 * nothing has been specified. Comes from
334 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
335 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
336 */
337 public int compatibleWidthLimitDp = 0;
338
339 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700340 * The maximum smallest screen width the application will work on. If 0,
341 * nothing has been specified. Comes from
342 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
343 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
344 */
345 public int largestWidthLimitDp = 0;
346
347 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800348 * Full path to the location of this package.
349 */
350 public String sourceDir;
351
352 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800353 * Full path to the location of the publicly available parts of this
354 * package (i.e. the primary resource package and manifest). For
355 * non-forward-locked apps this will be the same as {@link #sourceDir).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800356 */
357 public String publicSourceDir;
358
359 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800360 * Full paths to the locations of extra resource packages this application
361 * uses. This field is only used if there are extra resource packages,
362 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800363 *
364 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800365 */
366 public String[] resourceDirs;
367
368 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369 * Paths to all shared libraries this application is linked against. This
370 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
371 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
372 * the structure.
373 */
374 public String[] sharedLibraryFiles;
375
376 /**
377 * Full path to a directory assigned to the package for its persistent
378 * data.
379 */
380 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700381
382 /**
383 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700384 */
385 public String nativeLibraryDir;
386
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800387 /**
388 * The kernel user-ID that has been assigned to this application;
389 * currently this is not a unique ID (multiple applications can have
390 * the same uid).
391 */
392 public int uid;
393
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700394 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700395 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700396 * versions, but it knows how to work with any new behavior added at this
397 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
398 * if this is a development build and the app is targeting that. You should
399 * compare that this number is >= the SDK version number at which your
400 * behavior was introduced.
401 */
402 public int targetSdkVersion;
403
404 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405 * When false, indicates that all components within this application are
406 * considered disabled, regardless of their individually set enabled status.
407 */
408 public boolean enabled = true;
409
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700410 /**
411 * For convenient access to package's install location.
412 * @hide
413 */
414 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
415
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800416 public void dump(Printer pw, String prefix) {
417 super.dumpFront(pw, prefix);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800418 if (className != null) {
419 pw.println(prefix + "className=" + className);
420 }
421 if (permission != null) {
422 pw.println(prefix + "permission=" + permission);
423 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700424 pw.println(prefix + "processName=" + processName);
425 pw.println(prefix + "taskAffinity=" + taskAffinity);
426 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
427 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700428 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700429 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
430 + " largestWidthLimitDp=" + largestWidthLimitDp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800431 pw.println(prefix + "sourceDir=" + sourceDir);
Dianne Hackborn817c2472010-10-05 14:40:22 -0700432 if (sourceDir == null) {
433 if (publicSourceDir != null) {
434 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
435 }
436 } else if (!sourceDir.equals(publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700437 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
438 }
439 if (resourceDirs != null) {
440 pw.println(prefix + "resourceDirs=" + resourceDirs);
441 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800442 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800443 if (sharedLibraryFiles != null) {
444 pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
445 }
446 pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion);
447 if (manageSpaceActivityName != null) {
448 pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
449 }
450 if (descriptionRes != 0) {
451 pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
452 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800453 super.dumpBack(pw, prefix);
454 }
455
456 public static class DisplayNameComparator
457 implements Comparator<ApplicationInfo> {
458 public DisplayNameComparator(PackageManager pm) {
459 mPM = pm;
460 }
461
462 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
463 CharSequence sa = mPM.getApplicationLabel(aa);
464 if (sa == null) {
465 sa = aa.packageName;
466 }
467 CharSequence sb = mPM.getApplicationLabel(ab);
468 if (sb == null) {
469 sb = ab.packageName;
470 }
471
472 return sCollator.compare(sa.toString(), sb.toString());
473 }
474
475 private final Collator sCollator = Collator.getInstance();
476 private PackageManager mPM;
477 }
478
479 public ApplicationInfo() {
480 }
481
482 public ApplicationInfo(ApplicationInfo orig) {
483 super(orig);
484 taskAffinity = orig.taskAffinity;
485 permission = orig.permission;
486 processName = orig.processName;
487 className = orig.className;
488 theme = orig.theme;
489 flags = orig.flags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700490 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
491 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700492 largestWidthLimitDp = orig.largestWidthLimitDp;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800493 sourceDir = orig.sourceDir;
494 publicSourceDir = orig.publicSourceDir;
Kenny Root85387d72010-08-26 10:13:11 -0700495 nativeLibraryDir = orig.nativeLibraryDir;
Kenny Rootd1ab0162010-01-21 17:27:14 -0800496 resourceDirs = orig.resourceDirs;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800497 sharedLibraryFiles = orig.sharedLibraryFiles;
498 dataDir = orig.dataDir;
499 uid = orig.uid;
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700500 targetSdkVersion = orig.targetSdkVersion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800501 enabled = orig.enabled;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700502 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 manageSpaceActivityName = orig.manageSpaceActivityName;
504 descriptionRes = orig.descriptionRes;
505 }
506
507
508 public String toString() {
509 return "ApplicationInfo{"
510 + Integer.toHexString(System.identityHashCode(this))
511 + " " + packageName + "}";
512 }
513
514 public int describeContents() {
515 return 0;
516 }
517
518 public void writeToParcel(Parcel dest, int parcelableFlags) {
519 super.writeToParcel(dest, parcelableFlags);
520 dest.writeString(taskAffinity);
521 dest.writeString(permission);
522 dest.writeString(processName);
523 dest.writeString(className);
524 dest.writeInt(theme);
525 dest.writeInt(flags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700526 dest.writeInt(requiresSmallestWidthDp);
527 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700528 dest.writeInt(largestWidthLimitDp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800529 dest.writeString(sourceDir);
530 dest.writeString(publicSourceDir);
Kenny Root85387d72010-08-26 10:13:11 -0700531 dest.writeString(nativeLibraryDir);
Kenny Rootd1ab0162010-01-21 17:27:14 -0800532 dest.writeStringArray(resourceDirs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800533 dest.writeStringArray(sharedLibraryFiles);
534 dest.writeString(dataDir);
535 dest.writeInt(uid);
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700536 dest.writeInt(targetSdkVersion);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800537 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700538 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700540 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800541 dest.writeInt(descriptionRes);
542 }
543
544 public static final Parcelable.Creator<ApplicationInfo> CREATOR
545 = new Parcelable.Creator<ApplicationInfo>() {
546 public ApplicationInfo createFromParcel(Parcel source) {
547 return new ApplicationInfo(source);
548 }
549 public ApplicationInfo[] newArray(int size) {
550 return new ApplicationInfo[size];
551 }
552 };
553
554 private ApplicationInfo(Parcel source) {
555 super(source);
556 taskAffinity = source.readString();
557 permission = source.readString();
558 processName = source.readString();
559 className = source.readString();
560 theme = source.readInt();
561 flags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700562 requiresSmallestWidthDp = source.readInt();
563 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700564 largestWidthLimitDp = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 sourceDir = source.readString();
566 publicSourceDir = source.readString();
Kenny Root85387d72010-08-26 10:13:11 -0700567 nativeLibraryDir = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -0800568 resourceDirs = source.readStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800569 sharedLibraryFiles = source.readStringArray();
570 dataDir = source.readString();
571 uid = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700572 targetSdkVersion = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573 enabled = source.readInt() != 0;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700574 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800575 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -0700576 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800577 descriptionRes = source.readInt();
578 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700579
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800580 /**
581 * Retrieve the textual description of the application. This
582 * will call back on the given PackageManager to load the description from
583 * the application.
584 *
585 * @param pm A PackageManager from which the label can be loaded; usually
586 * the PackageManager from which you originally retrieved this item.
587 *
588 * @return Returns a CharSequence containing the application's description.
589 * If there is no description, null is returned.
590 */
591 public CharSequence loadDescription(PackageManager pm) {
592 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -0700593 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800594 if (label != null) {
595 return label;
596 }
597 }
598 return null;
599 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700600
601 /**
602 * Disable compatibility mode
603 *
604 * @hide
605 */
606 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -0700607 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700608 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700609 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700610 }
Jeff Brown07330792010-03-30 19:57:08 -0700611
612 /**
613 * @hide
614 */
615 @Override protected Drawable loadDefaultIcon(PackageManager pm) {
616 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
617 && isPackageUnavailable(pm)) {
618 return Resources.getSystem().getDrawable(
619 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
620 }
621 return pm.getDefaultActivityIcon();
622 }
623
624 private boolean isPackageUnavailable(PackageManager pm) {
625 try {
626 return pm.getPackageInfo(packageName, 0) == null;
627 } catch (NameNotFoundException ex) {
628 return true;
629 }
630 }
631
632 /**
633 * @hide
634 */
635 @Override protected ApplicationInfo getApplicationInfo() {
636 return this;
637 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800638}