blob: 1a82d58bc1bc989582456ec113e664e87969a29f [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 /**
Adam Powell269248d2011-08-02 10:26:54 -070094 * The default extra UI options for activities in this application.
95 * Set from the {@link android.R.attr#uiOptions} attribute in the
96 * activity's manifest.
97 */
98 public int uiOptions = 0;
99
100 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 * Value for {@link #flags}: if set, this application is installed in the
102 * device's system image.
103 */
104 public static final int FLAG_SYSTEM = 1<<0;
105
106 /**
107 * Value for {@link #flags}: set to true if this application would like to
108 * allow debugging of its
109 * code, even when installed on a non-development system. Comes
110 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
111 * android:debuggable} of the &lt;application&gt; tag.
112 */
113 public static final int FLAG_DEBUGGABLE = 1<<1;
114
115 /**
116 * Value for {@link #flags}: set to true if this application has code
117 * associated with it. Comes
118 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
119 * android:hasCode} of the &lt;application&gt; tag.
120 */
121 public static final int FLAG_HAS_CODE = 1<<2;
122
123 /**
124 * Value for {@link #flags}: set to true if this application is persistent.
125 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
126 * android:persistent} of the &lt;application&gt; tag.
127 */
128 public static final int FLAG_PERSISTENT = 1<<3;
129
130 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700131 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800132 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
133 * device is running in factory test mode.
134 */
135 public static final int FLAG_FACTORY_TEST = 1<<4;
136
137 /**
138 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
139 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
140 * android:allowTaskReparenting} of the &lt;application&gt; tag.
141 */
142 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
143
144 /**
145 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
146 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
147 * android:allowClearUserData} of the &lt;application&gt; tag.
148 */
149 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
150
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800151 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700152 * Value for {@link #flags}: this is set if this application has been
153 * install as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154 */
155 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700156
157 /**
Dianne Hackborn7f205432009-07-28 00:13:47 -0700158 * Value for {@link #flags}: this is set of the application has specified
159 * {@link android.R.styleable#AndroidManifestApplication_testOnly
160 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700161 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700162 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700163
164 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700165 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700166 * reduced in size for smaller screens. Corresponds to
167 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
168 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700169 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700170 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
171
172 /**
173 * Value for {@link #flags}: true when the application's window can be
174 * displayed on normal screens. Corresponds to
175 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
176 * android:normalScreens}.
177 */
178 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
179
180 /**
181 * Value for {@link #flags}: true when the application's window can be
182 * increased in size for larger screens. Corresponds to
183 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700184 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700185 */
186 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700187
188 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700189 * Value for {@link #flags}: true when the application knows how to adjust
190 * its UI for different screen sizes. Corresponds to
191 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
192 * android:resizeable}.
193 */
194 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
195
196 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700197 * Value for {@link #flags}: true when the application knows how to
198 * accomodate different screen densities. Corresponds to
199 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
200 * android:anyDensity}.
201 */
202 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
203
204 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800205 * Value for {@link #flags}: set to true if this application would like to
206 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700207 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
208 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800209 */
210 public static final int FLAG_VM_SAFE_MODE = 1<<14;
211
212 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800213 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
214 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700215 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800216 * <p>Comes from the
217 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
218 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700219 */
Ben Cheng23085b72010-02-08 16:06:32 -0800220 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700221
222 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800223 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
224 * in memory following a full-system restore operation; <code>true</code> otherwise.
225 * Ordinarily, during a full system restore operation each application is shut down
226 * following execution of its agent's onRestore() method. Setting this attribute to
227 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700228 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800229 * <p>If
230 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
231 * is set to <code>false</code> or no
232 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700233 * is specified, this flag will be ignored.
234 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800235 * <p>Comes from the
236 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
237 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700238 */
Ben Cheng23085b72010-02-08 16:06:32 -0800239 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700240
241 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800242 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
243 * agent claims to be able to handle restore data even "from the future,"
244 * i.e. from versions of the application with a versionCode greater than
245 * the one currently installed on the device. <i>Use with caution!</i> By default
246 * this attribute is <code>false</code> and the Backup Manager will ensure that data
247 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700248 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800249 * <p>If
250 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
251 * is set to <code>false</code> or no
252 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700253 * is specified, this flag will be ignored.
254 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800255 * <p>Comes from the
256 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
257 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700258 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800259 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700260
Christopher Tate181fafa2009-05-14 11:12:14 -0700261 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700262 * Value for {@link #flags}: Set to true if the application is
263 * currently installed on external/removable/unprotected storage. Such
264 * applications may not be available if their storage is not currently
265 * mounted. When the storage it is on is not available, it will look like
266 * the application has been uninstalled (its .apk is no longer available)
267 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800268 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700269 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800270
271 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700272 * Value for {@link #flags}: true when the application's window can be
273 * increased in size for extra large screens. Corresponds to
274 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700275 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700276 */
277 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
278
279 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800280 * Value for {@link #flags}: true when the application has requested a
281 * large heap for its processes. Corresponds to
282 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
283 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600284 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800285 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600286
287 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800288 * Value for {@link #flags}: true if this application's package is in
289 * the stopped state.
290 */
291 public static final int FLAG_STOPPED = 1<<21;
292
293 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700294 * Value for {@link #flags}: true when the application is willing to support
295 * RTL (right to left). All activities will inherit this value.
296 *
297 * Set from the {@link android.R.attr#supportsRtl} attribute in the
298 * activity's manifest.
299 *
300 * Default value is false (no support for RTL).
301 */
302 public static final int FLAG_SUPPORTS_RTL = 1<<22;
303
304 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700305 * Value for {@link #flags}: true if the application is currently
306 * installed for the calling user.
307 */
308 public static final int FLAG_INSTALLED = 1<<23;
309
310 /**
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800311 * Value for {@link #flags}: Set to true if the application has been
312 * installed using the forward lock option.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800313 *
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800314 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
315 *
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800316 * {@hide}
317 */
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800318 public static final int FLAG_FORWARD_LOCK = 1<<29;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800319
320 /**
Dianne Hackborn02486b12010-08-26 14:18:37 -0700321 * Value for {@link #flags}: set to <code>true</code> if the application
322 * has reported that it is heavy-weight, and thus can not participate in
323 * the normal application lifecycle.
324 *
325 * <p>Comes from the
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700326 * {@link android.R.styleable#AndroidManifestApplication_cantSaveState android:cantSaveState}
Dianne Hackborn02486b12010-08-26 14:18:37 -0700327 * attribute of the &lt;application&gt; tag.
328 *
329 * {@hide}
330 */
Dianne Hackborn75e616e2011-01-16 13:31:24 -0800331 public static final int FLAG_CANT_SAVE_STATE = 1<<28;
Dianne Hackborn02486b12010-08-26 14:18:37 -0700332
333 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800334 * Flags associated with the application. Any combination of
335 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
336 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
337 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700338 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700339 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
340 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700341 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
342 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700343 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
344 * {@link #FLAG_INSTALLED}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800345 */
346 public int flags = 0;
347
348 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700349 * The required smallest screen width the application can run on. If 0,
350 * nothing has been specified. Comes from
351 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
352 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
353 */
354 public int requiresSmallestWidthDp = 0;
355
356 /**
357 * The maximum smallest screen width the application is designed for. If 0,
358 * nothing has been specified. Comes from
359 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
360 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
361 */
362 public int compatibleWidthLimitDp = 0;
363
364 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700365 * The maximum smallest screen width the application will work on. If 0,
366 * nothing has been specified. Comes from
367 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
368 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
369 */
370 public int largestWidthLimitDp = 0;
371
372 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800373 * Full path to the location of this package.
374 */
375 public String sourceDir;
376
377 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800378 * Full path to the location of the publicly available parts of this
379 * package (i.e. the primary resource package and manifest). For
380 * non-forward-locked apps this will be the same as {@link #sourceDir).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800381 */
382 public String publicSourceDir;
383
384 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800385 * Full paths to the locations of extra resource packages this application
386 * uses. This field is only used if there are extra resource packages,
387 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800388 *
389 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800390 */
391 public String[] resourceDirs;
392
393 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800394 * Paths to all shared libraries this application is linked against. This
395 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
396 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
397 * the structure.
398 */
399 public String[] sharedLibraryFiles;
400
401 /**
402 * Full path to a directory assigned to the package for its persistent
403 * data.
404 */
405 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700406
407 /**
408 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700409 */
410 public String nativeLibraryDir;
411
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 /**
413 * The kernel user-ID that has been assigned to this application;
414 * currently this is not a unique ID (multiple applications can have
415 * the same uid).
416 */
417 public int uid;
418
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700419 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700420 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700421 * versions, but it knows how to work with any new behavior added at this
422 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
423 * if this is a development build and the app is targeting that. You should
424 * compare that this number is >= the SDK version number at which your
425 * behavior was introduced.
426 */
427 public int targetSdkVersion;
428
429 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800430 * When false, indicates that all components within this application are
431 * considered disabled, regardless of their individually set enabled status.
432 */
433 public boolean enabled = true;
434
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700435 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700436 * For convenient access to the current enabled setting of this app.
437 * @hide
438 */
439 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
440
441 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700442 * For convenient access to package's install location.
443 * @hide
444 */
445 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
446
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800447 public void dump(Printer pw, String prefix) {
448 super.dumpFront(pw, prefix);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800449 if (className != null) {
450 pw.println(prefix + "className=" + className);
451 }
452 if (permission != null) {
453 pw.println(prefix + "permission=" + permission);
454 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700455 pw.println(prefix + "processName=" + processName);
456 pw.println(prefix + "taskAffinity=" + taskAffinity);
457 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
458 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700459 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700460 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
461 + " largestWidthLimitDp=" + largestWidthLimitDp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800462 pw.println(prefix + "sourceDir=" + sourceDir);
Dianne Hackborn817c2472010-10-05 14:40:22 -0700463 if (sourceDir == null) {
464 if (publicSourceDir != null) {
465 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
466 }
467 } else if (!sourceDir.equals(publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700468 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
469 }
470 if (resourceDirs != null) {
471 pw.println(prefix + "resourceDirs=" + resourceDirs);
472 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800473 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn12527f92009-11-11 17:39:50 -0800474 if (sharedLibraryFiles != null) {
475 pw.println(prefix + "sharedLibraryFiles=" + sharedLibraryFiles);
476 }
477 pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion);
478 if (manageSpaceActivityName != null) {
479 pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
480 }
481 if (descriptionRes != 0) {
482 pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
483 }
Adam Powell269248d2011-08-02 10:26:54 -0700484 if (uiOptions != 0) {
485 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
486 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700487 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800488 super.dumpBack(pw, prefix);
489 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700490
491 /**
492 * @return true if "supportsRtl" has been set to true in the AndroidManifest
493 * @hide
494 */
495 public boolean hasRtlSupport() {
496 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
497 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800498
499 public static class DisplayNameComparator
500 implements Comparator<ApplicationInfo> {
501 public DisplayNameComparator(PackageManager pm) {
502 mPM = pm;
503 }
504
505 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
506 CharSequence sa = mPM.getApplicationLabel(aa);
507 if (sa == null) {
508 sa = aa.packageName;
509 }
510 CharSequence sb = mPM.getApplicationLabel(ab);
511 if (sb == null) {
512 sb = ab.packageName;
513 }
514
515 return sCollator.compare(sa.toString(), sb.toString());
516 }
517
518 private final Collator sCollator = Collator.getInstance();
519 private PackageManager mPM;
520 }
521
522 public ApplicationInfo() {
523 }
524
525 public ApplicationInfo(ApplicationInfo orig) {
526 super(orig);
527 taskAffinity = orig.taskAffinity;
528 permission = orig.permission;
529 processName = orig.processName;
530 className = orig.className;
531 theme = orig.theme;
532 flags = orig.flags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700533 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
534 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700535 largestWidthLimitDp = orig.largestWidthLimitDp;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800536 sourceDir = orig.sourceDir;
537 publicSourceDir = orig.publicSourceDir;
Kenny Root85387d72010-08-26 10:13:11 -0700538 nativeLibraryDir = orig.nativeLibraryDir;
Kenny Rootd1ab0162010-01-21 17:27:14 -0800539 resourceDirs = orig.resourceDirs;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 sharedLibraryFiles = orig.sharedLibraryFiles;
541 dataDir = orig.dataDir;
542 uid = orig.uid;
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700543 targetSdkVersion = orig.targetSdkVersion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700545 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700546 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800547 manageSpaceActivityName = orig.manageSpaceActivityName;
548 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -0700549 uiOptions = orig.uiOptions;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800550 }
551
552
553 public String toString() {
554 return "ApplicationInfo{"
555 + Integer.toHexString(System.identityHashCode(this))
556 + " " + packageName + "}";
557 }
558
559 public int describeContents() {
560 return 0;
561 }
562
563 public void writeToParcel(Parcel dest, int parcelableFlags) {
564 super.writeToParcel(dest, parcelableFlags);
565 dest.writeString(taskAffinity);
566 dest.writeString(permission);
567 dest.writeString(processName);
568 dest.writeString(className);
569 dest.writeInt(theme);
570 dest.writeInt(flags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700571 dest.writeInt(requiresSmallestWidthDp);
572 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700573 dest.writeInt(largestWidthLimitDp);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574 dest.writeString(sourceDir);
575 dest.writeString(publicSourceDir);
Kenny Root85387d72010-08-26 10:13:11 -0700576 dest.writeString(nativeLibraryDir);
Kenny Rootd1ab0162010-01-21 17:27:14 -0800577 dest.writeStringArray(resourceDirs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800578 dest.writeStringArray(sharedLibraryFiles);
579 dest.writeString(dataDir);
580 dest.writeInt(uid);
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700581 dest.writeInt(targetSdkVersion);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800582 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700583 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700584 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700586 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800587 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -0700588 dest.writeInt(uiOptions);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800589 }
590
591 public static final Parcelable.Creator<ApplicationInfo> CREATOR
592 = new Parcelable.Creator<ApplicationInfo>() {
593 public ApplicationInfo createFromParcel(Parcel source) {
594 return new ApplicationInfo(source);
595 }
596 public ApplicationInfo[] newArray(int size) {
597 return new ApplicationInfo[size];
598 }
599 };
600
601 private ApplicationInfo(Parcel source) {
602 super(source);
603 taskAffinity = source.readString();
604 permission = source.readString();
605 processName = source.readString();
606 className = source.readString();
607 theme = source.readInt();
608 flags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700609 requiresSmallestWidthDp = source.readInt();
610 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700611 largestWidthLimitDp = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800612 sourceDir = source.readString();
613 publicSourceDir = source.readString();
Kenny Root85387d72010-08-26 10:13:11 -0700614 nativeLibraryDir = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -0800615 resourceDirs = source.readStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616 sharedLibraryFiles = source.readStringArray();
617 dataDir = source.readString();
618 uid = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700619 targetSdkVersion = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800620 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700621 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700622 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800623 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -0700624 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800625 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -0700626 uiOptions = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800627 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700628
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800629 /**
630 * Retrieve the textual description of the application. This
631 * will call back on the given PackageManager to load the description from
632 * the application.
633 *
634 * @param pm A PackageManager from which the label can be loaded; usually
635 * the PackageManager from which you originally retrieved this item.
636 *
637 * @return Returns a CharSequence containing the application's description.
638 * If there is no description, null is returned.
639 */
640 public CharSequence loadDescription(PackageManager pm) {
641 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -0700642 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800643 if (label != null) {
644 return label;
645 }
646 }
647 return null;
648 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700649
650 /**
651 * Disable compatibility mode
652 *
653 * @hide
654 */
655 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -0700656 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700657 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700658 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700659 }
Jeff Brown07330792010-03-30 19:57:08 -0700660
661 /**
662 * @hide
663 */
664 @Override protected Drawable loadDefaultIcon(PackageManager pm) {
665 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
666 && isPackageUnavailable(pm)) {
667 return Resources.getSystem().getDrawable(
668 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
669 }
670 return pm.getDefaultActivityIcon();
671 }
672
673 private boolean isPackageUnavailable(PackageManager pm) {
674 try {
675 return pm.getPackageInfo(packageName, 0) == null;
676 } catch (NameNotFoundException ex) {
677 return true;
678 }
679 }
680
681 /**
682 * @hide
683 */
684 @Override protected ApplicationInfo getApplicationInfo() {
685 return this;
686 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800687}