blob: 594e992aad7dafbdc2b0fff34920fa960fa84786 [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;
Jeff Sharkey15447792015-11-05 16:18:51 -080022import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.os.Parcel;
24import android.os.Parcelable;
Jeff Sharkey15447792015-11-05 16:18:51 -080025import android.os.UserHandle;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -080026import android.os.storage.StorageManager;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070027import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.util.Printer;
29
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070030import com.android.internal.util.ArrayUtils;
31
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070033import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070035import java.util.Objects;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036
37/**
38 * Information you can retrieve about a particular application. This
39 * corresponds to information collected from the AndroidManifest.xml's
40 * <application> tag.
41 */
42public class ApplicationInfo extends PackageItemInfo implements Parcelable {
43
44 /**
45 * Default task affinity of all activities in this application. See
46 * {@link ActivityInfo#taskAffinity} for more information. This comes
47 * from the "taskAffinity" attribute.
48 */
49 public String taskAffinity;
50
51 /**
52 * Optional name of a permission required to be able to access this
53 * application's components. From the "permission" attribute.
54 */
55 public String permission;
56
57 /**
58 * The name of the process this application should run in. From the
59 * "process" attribute or, if not set, the same as
60 * <var>packageName</var>.
61 */
62 public String processName;
63
64 /**
65 * Class implementing the Application object. From the "class"
66 * attribute.
67 */
68 public String className;
69
70 /**
71 * A style resource identifier (in the package's resources) of the
72 * description of an application. From the "description" attribute
73 * or, if not set, 0.
74 */
75 public int descriptionRes;
76
77 /**
78 * A style resource identifier (in the package's resources) of the
79 * default visual theme of the application. From the "theme" attribute
80 * or, if not set, 0.
81 */
82 public int theme;
83
84 /**
85 * Class implementing the Application's manage space
86 * functionality. From the "manageSpaceActivity"
87 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -070088 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089 */
90 public String manageSpaceActivityName;
91
92 /**
Christopher Tate181fafa2009-05-14 11:12:14 -070093 * Class implementing the Application's backup functionality. From
94 * the "backupAgent" attribute. This is an optional attribute and
95 * will be null if the application does not specify it in its manifest.
96 *
97 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -070098 */
99 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700100
101 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700102 * An optional attribute that indicates the app supports automatic backup of app data.
103 * <p>0 is the default and means the app's entire data folder + managed external storage will
104 * be backed up;
105 * Any negative value indicates the app does not support full-data backup, though it may still
106 * want to participate via the traditional key/value backup API;
107 * A positive number specifies an xml resource in which the application has defined its backup
108 * include/exclude criteria.
109 * <p>If android:allowBackup is set to false, this attribute is ignored.
110 *
111 * @see {@link android.content.Context#getNoBackupFilesDir}
112 * @see {@link #FLAG_ALLOW_BACKUP}
Christopher Tate98fa6562015-05-14 13:20:10 -0700113 *
114 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700115 */
116 public int fullBackupContent = 0;
117
118 /**
Adam Powell269248d2011-08-02 10:26:54 -0700119 * The default extra UI options for activities in this application.
120 * Set from the {@link android.R.attr#uiOptions} attribute in the
121 * activity's manifest.
122 */
123 public int uiOptions = 0;
124
125 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800126 * Value for {@link #flags}: if set, this application is installed in the
127 * device's system image.
128 */
129 public static final int FLAG_SYSTEM = 1<<0;
130
131 /**
132 * Value for {@link #flags}: set to true if this application would like to
133 * allow debugging of its
134 * code, even when installed on a non-development system. Comes
135 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
136 * android:debuggable} of the &lt;application&gt; tag.
137 */
138 public static final int FLAG_DEBUGGABLE = 1<<1;
139
140 /**
141 * Value for {@link #flags}: set to true if this application has code
142 * associated with it. Comes
143 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
144 * android:hasCode} of the &lt;application&gt; tag.
145 */
146 public static final int FLAG_HAS_CODE = 1<<2;
147
148 /**
149 * Value for {@link #flags}: set to true if this application is persistent.
150 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
151 * android:persistent} of the &lt;application&gt; tag.
152 */
153 public static final int FLAG_PERSISTENT = 1<<3;
154
155 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700156 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800157 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
158 * device is running in factory test mode.
159 */
160 public static final int FLAG_FACTORY_TEST = 1<<4;
161
162 /**
163 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
164 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
165 * android:allowTaskReparenting} of the &lt;application&gt; tag.
166 */
167 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
168
169 /**
170 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
171 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
172 * android:allowClearUserData} of the &lt;application&gt; tag.
173 */
174 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
175
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800176 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700177 * Value for {@link #flags}: this is set if this application has been
178 * install as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800179 */
180 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700181
182 /**
Dianne Hackborn7f205432009-07-28 00:13:47 -0700183 * Value for {@link #flags}: this is set of the application has specified
184 * {@link android.R.styleable#AndroidManifestApplication_testOnly
185 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700186 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700187 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700188
189 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700190 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700191 * reduced in size for smaller screens. Corresponds to
192 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
193 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700194 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700195 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
196
197 /**
198 * Value for {@link #flags}: true when the application's window can be
199 * displayed on normal screens. Corresponds to
200 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
201 * android:normalScreens}.
202 */
203 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
204
205 /**
206 * Value for {@link #flags}: true when the application's window can be
207 * increased in size for larger screens. Corresponds to
208 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700209 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700210 */
211 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700212
213 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700214 * Value for {@link #flags}: true when the application knows how to adjust
215 * its UI for different screen sizes. Corresponds to
216 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
217 * android:resizeable}.
218 */
219 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
220
221 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700222 * Value for {@link #flags}: true when the application knows how to
223 * accomodate different screen densities. Corresponds to
224 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
225 * android:anyDensity}.
226 */
227 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
228
229 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800230 * Value for {@link #flags}: set to true if this application would like to
231 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700232 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
233 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800234 */
235 public static final int FLAG_VM_SAFE_MODE = 1<<14;
236
237 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800238 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
239 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700240 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800241 * <p>Comes from the
242 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
243 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700244 */
Ben Cheng23085b72010-02-08 16:06:32 -0800245 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700246
247 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800248 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
249 * in memory following a full-system restore operation; <code>true</code> otherwise.
250 * Ordinarily, during a full system restore operation each application is shut down
251 * following execution of its agent's onRestore() method. Setting this attribute to
252 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700253 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800254 * <p>If
255 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
256 * is set to <code>false</code> or no
257 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700258 * is specified, this flag will be ignored.
259 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800260 * <p>Comes from the
261 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
262 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700263 */
Ben Cheng23085b72010-02-08 16:06:32 -0800264 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700265
266 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800267 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
268 * agent claims to be able to handle restore data even "from the future,"
269 * i.e. from versions of the application with a versionCode greater than
270 * the one currently installed on the device. <i>Use with caution!</i> By default
271 * this attribute is <code>false</code> and the Backup Manager will ensure that data
272 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700273 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800274 * <p>If
275 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
276 * is set to <code>false</code> or no
277 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700278 * is specified, this flag will be ignored.
279 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800280 * <p>Comes from the
281 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
282 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700283 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800284 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700285
Christopher Tate181fafa2009-05-14 11:12:14 -0700286 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700287 * Value for {@link #flags}: Set to true if the application is
288 * currently installed on external/removable/unprotected storage. Such
289 * applications may not be available if their storage is not currently
290 * mounted. When the storage it is on is not available, it will look like
291 * the application has been uninstalled (its .apk is no longer available)
292 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800293 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700294 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800295
296 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700297 * Value for {@link #flags}: true when the application's window can be
298 * increased in size for extra large screens. Corresponds to
299 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700300 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700301 */
302 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
303
304 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800305 * Value for {@link #flags}: true when the application has requested a
306 * large heap for its processes. Corresponds to
307 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
308 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600309 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800310 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600311
312 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800313 * Value for {@link #flags}: true if this application's package is in
314 * the stopped state.
315 */
316 public static final int FLAG_STOPPED = 1<<21;
317
318 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700319 * Value for {@link #flags}: true when the application is willing to support
320 * RTL (right to left). All activities will inherit this value.
321 *
322 * Set from the {@link android.R.attr#supportsRtl} attribute in the
323 * activity's manifest.
324 *
325 * Default value is false (no support for RTL).
326 */
327 public static final int FLAG_SUPPORTS_RTL = 1<<22;
328
329 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700330 * Value for {@link #flags}: true if the application is currently
331 * installed for the calling user.
332 */
333 public static final int FLAG_INSTALLED = 1<<23;
334
335 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700336 * Value for {@link #flags}: true if the application only has its
337 * data installed; the application package itself does not currently
338 * exist on the device.
339 */
340 public static final int FLAG_IS_DATA_ONLY = 1<<24;
341
342 /**
Jose Lima12d0b4c2014-03-14 16:55:12 -0700343 * Value for {@link #flags}: true if the application was declared to be a game, or
344 * false if it is a non-game application.
345 */
346 public static final int FLAG_IS_GAME = 1<<25;
347
348 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700349 * Value for {@link #flags}: {@code true} if the application asks that only
350 * full-data streaming backups of its data be performed even though it defines
351 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
352 * indicates that the app will manage its backed-up data via incremental
353 * key/value updates.
354 */
355 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
356
357 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700358 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
359 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
360 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
361 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700362 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
363 * traffic. Third-party libraries are encouraged to honor this flag as well.
364 *
365 * <p>NOTE: {@code WebView} does not honor this flag.
366 *
367 * <p>This flag comes from
368 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
369 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700370 */
371 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
372
373 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700374 * When set installer extracts native libs from .apk files.
375 */
376 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
377
378 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700379 * Value for {@link #flags}: {@code true} when the application's rendering
380 * should be hardware accelerated.
381 */
382 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
383
384 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100385 * Value for {@link #flags}: true if code from this application will need to be
386 * loaded into other applications' processes. On devices that support multiple
387 * instruction sets, this implies the code might be loaded into a process that's
388 * using any of the devices supported instruction sets.
389 *
390 * <p> The system might treat such applications specially, for eg., by
391 * extracting the application's native libraries for all supported instruction
392 * sets or by compiling the application's dex code for all supported instruction
393 * sets.
394 */
395 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700396
397 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800398 * Flags associated with the application. Any combination of
399 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
400 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
401 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700402 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700403 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
404 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700405 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
406 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700407 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800408 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
409 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
410 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
411 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
412 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700413 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
414 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800415 */
416 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700417
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800418 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800419 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
420 * most purposes is considered as not installed.
421 * {@hide}
422 */
423 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
424
425 /**
426 * Value for {@link #privateFlags}: set to <code>true</code> if the application
427 * has reported that it is heavy-weight, and thus can not participate in
428 * the normal application lifecycle.
429 *
430 * <p>Comes from the
431 * android.R.styleable#AndroidManifestApplication_cantSaveState
432 * attribute of the &lt;application&gt; tag.
433 *
434 * {@hide}
435 */
436 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
437
438 /**
439 * Value for {@link #privateFlags}: Set to true if the application has been
440 * installed using the forward lock option.
441 *
442 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
443 *
444 * {@hide}
445 */
446 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
447
448 /**
449 * Value for {@link #privateFlags}: set to {@code true} if the application
450 * is permitted to hold privileged permissions.
451 *
452 * {@hide}
453 */
454 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
455
456 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800457 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
458 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700459 *
460 * {@hide}
461 */
462 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
463
464 /**
Jeff Sharkey15447792015-11-05 16:18:51 -0800465 * When set, default data storage directory for given app is pointed at
466 * device-encrypted location.
467 *
468 * @hide
469 */
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800470 public static final int PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800471
472 /**
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800473 * When set, assume that all components under the given app are encryption
474 * aware, unless otherwise specified.
475 *
476 * @hide
477 */
478 public static final int PRIVATE_FLAG_ENCRYPTION_AWARE = 1 << 6;
479
480 /**
Jeff Vander Stoepa4407bf2015-10-30 13:15:58 -0700481 * Value for {@link #privateFlags}: set to {@code true} if the application
482 * is AutoPlay.
483 *
484 * {@hide}
485 */
Jeff Vander Stoep9edb7bf2015-11-16 15:23:38 -0800486 public static final int PRIVATE_FLAG_AUTOPLAY = 1 << 7;
Jeff Vander Stoepa4407bf2015-10-30 13:15:58 -0700487
488 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -0700489 * When set, at least one component inside this application is encryption aware.
490 *
491 * @hide
492 */
493 public static final int PRIVATE_FLAG_PARTIALLY_ENCRYPTION_AWARE = 1 << 8;
494
495 /**
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800496 * Value for {@link #flags}: {@code true} if the application is blocked via restrictions
497 * and for most purposes is considered as not installed.
498 * {@hide}
499 */
500 public static final int PRIVATE_FLAG_EPHEMERAL = 1 << 9;
501
502 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800503 * When set, signals that the application is required for the system user and should not be
504 * uninstalled.
505 *
506 * @hide
507 */
508 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 10;
509
510 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800511 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
512 * {@hide}
513 */
514 public int privateFlags;
515
516 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700517 * The required smallest screen width the application can run on. If 0,
518 * nothing has been specified. Comes from
519 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
520 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
521 */
522 public int requiresSmallestWidthDp = 0;
523
524 /**
525 * The maximum smallest screen width the application is designed for. If 0,
526 * nothing has been specified. Comes from
527 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
528 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
529 */
530 public int compatibleWidthLimitDp = 0;
531
532 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700533 * The maximum smallest screen width the application will work on. If 0,
534 * nothing has been specified. Comes from
535 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
536 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
537 */
538 public int largestWidthLimitDp = 0;
539
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700540 /** {@hide} */
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700541 public String volumeUuid;
542 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700543 public String scanSourceDir;
544 /** {@hide} */
545 public String scanPublicSourceDir;
546
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700547 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700548 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 */
550 public String sourceDir;
551
552 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700553 * Full path to the publicly available parts of {@link #sourceDir},
554 * including resources and manifest. This may be different from
555 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800556 */
557 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700558
559 /**
560 * Full paths to zero or more split APKs that, when combined with the base
561 * APK defined in {@link #sourceDir}, form a complete application.
562 */
563 public String[] splitSourceDirs;
564
565 /**
566 * Full path to the publicly available parts of {@link #splitSourceDirs},
567 * including resources and manifest. This may be different from
568 * {@link #splitSourceDirs} if an application is forward locked.
569 */
570 public String[] splitPublicSourceDirs;
571
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800572 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800573 * Full paths to the locations of extra resource packages this application
574 * uses. This field is only used if there are extra resource packages,
575 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800576 *
577 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800578 */
579 public String[] resourceDirs;
580
581 /**
Robert Craig0f40dc92013-03-25 06:33:03 -0400582 * String retrieved from the seinfo tag found in selinux policy. This value
Robert Craig5e16bc52015-08-28 12:11:41 -0400583 * can be overridden with a value set through the mac_permissions.xml policy
584 * construct. This value is useful in setting an SELinux security context on
585 * the process as well as its data directory. The String default is being used
586 * here to represent a catchall label when no policy matches.
Robert Craig0f40dc92013-03-25 06:33:03 -0400587 *
588 * {@hide}
589 */
Robert Craig5e16bc52015-08-28 12:11:41 -0400590 public String seinfo = "default";
Robert Craig0f40dc92013-03-25 06:33:03 -0400591
592 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800593 * Paths to all shared libraries this application is linked against. This
594 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
595 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
596 * the structure.
597 */
598 public String[] sharedLibraryFiles;
599
600 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700601 * Full path to the default directory assigned to the package for its
602 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800603 */
604 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700605
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700606 /**
607 * Full path to the device-encrypted directory assigned to the package for
608 * its persistent data.
609 */
Jeff Sharkey15447792015-11-05 16:18:51 -0800610 public String deviceEncryptedDataDir;
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700611
612 /**
613 * Full path to the credential-encrypted directory assigned to the package
614 * for its persistent data.
615 */
Jeff Sharkey15447792015-11-05 16:18:51 -0800616 public String credentialEncryptedDataDir;
617
Kenny Root85387d72010-08-26 10:13:11 -0700618 /**
619 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700620 */
621 public String nativeLibraryDir;
622
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800623 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100624 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
625 * are stored, if present.
626 *
627 * The main reason this exists is for bundled multi-arch apps, where
628 * it's not trivial to calculate the location of libs for the secondary abi
629 * given the location of the primary.
630 *
631 * TODO: Change the layout of bundled installs so that we can use
632 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
633 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
634 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
635 *
636 * @hide
637 */
638 public String secondaryNativeLibraryDir;
639
640 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700641 * The root path where unpacked native libraries are stored.
642 * <p>
643 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
644 * placed in ISA-specific subdirectories under this path, otherwise the
645 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100646 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700647 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100648 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700649 public String nativeLibraryRootDir;
650
651 /**
652 * Flag indicating that ISA must be appended to
653 * {@link #nativeLibraryRootDir} to be useful.
654 *
655 * @hide
656 */
657 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100658
659 /**
660 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100661 * of the native JNI libraries the application bundles. Will be {@code null}
662 * if this application does not require any particular ABI.
663 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100664 * If non-null, the application will always be launched with this ABI.
665 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100666 * {@hide}
667 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100668 public String primaryCpuAbi;
669
670 /**
671 * The secondary ABI for this application. Might be non-null for multi-arch
672 * installs. The application itself never uses this ABI, but other applications that
673 * use its code might.
674 *
675 * {@hide}
676 */
677 public String secondaryCpuAbi;
678
679 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800680 * The kernel user-ID that has been assigned to this application;
681 * currently this is not a unique ID (multiple applications can have
682 * the same uid).
683 */
684 public int uid;
685
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700686 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700687 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700688 * versions, but it knows how to work with any new behavior added at this
689 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
690 * if this is a development build and the app is targeting that. You should
691 * compare that this number is >= the SDK version number at which your
692 * behavior was introduced.
693 */
694 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800695
696 /**
697 * The app's declared version code.
698 * @hide
699 */
700 public int versionCode;
701
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700702 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800703 * When false, indicates that all components within this application are
704 * considered disabled, regardless of their individually set enabled status.
705 */
706 public boolean enabled = true;
707
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700708 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700709 * For convenient access to the current enabled setting of this app.
710 * @hide
711 */
712 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
713
714 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700715 * For convenient access to package's install location.
716 * @hide
717 */
718 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700719
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800720 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800721 dump(pw, prefix, DUMP_FLAG_ALL);
722 }
723
724 /** @hide */
725 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800726 super.dumpFront(pw, prefix);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800727 if ((flags&DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -0800728 pw.println(prefix + "className=" + className);
729 }
730 if (permission != null) {
731 pw.println(prefix + "permission=" + permission);
732 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700733 pw.println(prefix + "processName=" + processName);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800734 if ((flags&DUMP_FLAG_DETAILS) != 0) {
735 pw.println(prefix + "taskAffinity=" + taskAffinity);
736 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700737 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800738 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -0700739 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800740 if ((flags&DUMP_FLAG_DETAILS) != 0) {
741 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
742 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
743 + " largestWidthLimitDp=" + largestWidthLimitDp);
744 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800745 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700746 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700747 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
748 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700749 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
750 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
751 }
752 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
753 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
754 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
755 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700756 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -0800757 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -0700758 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800759 if ((flags&DUMP_FLAG_DETAILS) != 0 && seinfo != null) {
Robert Craig0f40dc92013-03-25 06:33:03 -0400760 pw.println(prefix + "seinfo=" + seinfo);
761 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800762 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800763 if ((flags&DUMP_FLAG_DETAILS) != 0) {
764 pw.println(prefix + "deviceEncryptedDataDir=" + deviceEncryptedDataDir);
765 pw.println(prefix + "credentialEncryptedDataDir=" + credentialEncryptedDataDir);
766 if (sharedLibraryFiles != null) {
767 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
768 }
Dianne Hackborn12527f92009-11-11 17:39:50 -0800769 }
Dianne Hackborn8472e612014-01-23 17:57:20 -0800770 pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion
771 + " versionCode=" + versionCode);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800772 if ((flags&DUMP_FLAG_DETAILS) != 0) {
773 if (manageSpaceActivityName != null) {
774 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
775 }
776 if (descriptionRes != 0) {
777 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
778 }
779 if (uiOptions != 0) {
780 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
781 }
782 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
783 if (fullBackupContent > 0) {
784 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
785 } else {
786 pw.println(prefix + "fullBackupContent="
787 + (fullBackupContent < 0 ? "false" : "true"));
788 }
Matthew Williams303650c2015-04-17 18:22:51 -0700789 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800790 super.dumpBack(pw, prefix);
791 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700792
793 /**
794 * @return true if "supportsRtl" has been set to true in the AndroidManifest
795 * @hide
796 */
797 public boolean hasRtlSupport() {
798 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
799 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800800
801 public static class DisplayNameComparator
802 implements Comparator<ApplicationInfo> {
803 public DisplayNameComparator(PackageManager pm) {
804 mPM = pm;
805 }
806
807 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
808 CharSequence sa = mPM.getApplicationLabel(aa);
809 if (sa == null) {
810 sa = aa.packageName;
811 }
812 CharSequence sb = mPM.getApplicationLabel(ab);
813 if (sb == null) {
814 sb = ab.packageName;
815 }
816
817 return sCollator.compare(sa.toString(), sb.toString());
818 }
819
820 private final Collator sCollator = Collator.getInstance();
821 private PackageManager mPM;
822 }
823
824 public ApplicationInfo() {
825 }
826
827 public ApplicationInfo(ApplicationInfo orig) {
828 super(orig);
829 taskAffinity = orig.taskAffinity;
830 permission = orig.permission;
831 processName = orig.processName;
832 className = orig.className;
833 theme = orig.theme;
834 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800835 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700836 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
837 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700838 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700839 volumeUuid = orig.volumeUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -0700840 scanSourceDir = orig.scanSourceDir;
841 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800842 sourceDir = orig.sourceDir;
843 publicSourceDir = orig.publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700844 splitSourceDirs = orig.splitSourceDirs;
845 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Kenny Root85387d72010-08-26 10:13:11 -0700846 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100847 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -0700848 nativeLibraryRootDir = orig.nativeLibraryRootDir;
849 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100850 primaryCpuAbi = orig.primaryCpuAbi;
851 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -0800852 resourceDirs = orig.resourceDirs;
Robert Craig0f40dc92013-03-25 06:33:03 -0400853 seinfo = orig.seinfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800854 sharedLibraryFiles = orig.sharedLibraryFiles;
855 dataDir = orig.dataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -0800856 deviceEncryptedDataDir = orig.deviceEncryptedDataDir;
857 credentialEncryptedDataDir = orig.credentialEncryptedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800858 uid = orig.uid;
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700859 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800860 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800861 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700862 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700863 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800864 manageSpaceActivityName = orig.manageSpaceActivityName;
865 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -0700866 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -0700867 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -0700868 fullBackupContent = orig.fullBackupContent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800869 }
870
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800871 public String toString() {
872 return "ApplicationInfo{"
873 + Integer.toHexString(System.identityHashCode(this))
874 + " " + packageName + "}";
875 }
876
877 public int describeContents() {
878 return 0;
879 }
880
881 public void writeToParcel(Parcel dest, int parcelableFlags) {
882 super.writeToParcel(dest, parcelableFlags);
883 dest.writeString(taskAffinity);
884 dest.writeString(permission);
885 dest.writeString(processName);
886 dest.writeString(className);
887 dest.writeInt(theme);
888 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800889 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700890 dest.writeInt(requiresSmallestWidthDp);
891 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700892 dest.writeInt(largestWidthLimitDp);
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700893 dest.writeString(volumeUuid);
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -0700894 dest.writeString(scanSourceDir);
895 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800896 dest.writeString(sourceDir);
897 dest.writeString(publicSourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700898 dest.writeStringArray(splitSourceDirs);
899 dest.writeStringArray(splitPublicSourceDirs);
Kenny Root85387d72010-08-26 10:13:11 -0700900 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100901 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -0700902 dest.writeString(nativeLibraryRootDir);
903 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +0100904 dest.writeString(primaryCpuAbi);
905 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -0800906 dest.writeStringArray(resourceDirs);
Robert Craig0f40dc92013-03-25 06:33:03 -0400907 dest.writeString(seinfo);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800908 dest.writeStringArray(sharedLibraryFiles);
909 dest.writeString(dataDir);
Jeff Sharkey15447792015-11-05 16:18:51 -0800910 dest.writeString(deviceEncryptedDataDir);
911 dest.writeString(credentialEncryptedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800912 dest.writeInt(uid);
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700913 dest.writeInt(targetSdkVersion);
Dianne Hackborn8472e612014-01-23 17:57:20 -0800914 dest.writeInt(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800915 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700916 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700917 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800918 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700919 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800920 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -0700921 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -0700922 dest.writeInt(fullBackupContent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800923 }
924
925 public static final Parcelable.Creator<ApplicationInfo> CREATOR
926 = new Parcelable.Creator<ApplicationInfo>() {
927 public ApplicationInfo createFromParcel(Parcel source) {
928 return new ApplicationInfo(source);
929 }
930 public ApplicationInfo[] newArray(int size) {
931 return new ApplicationInfo[size];
932 }
933 };
934
935 private ApplicationInfo(Parcel source) {
936 super(source);
937 taskAffinity = source.readString();
938 permission = source.readString();
939 processName = source.readString();
940 className = source.readString();
941 theme = source.readInt();
942 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800943 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700944 requiresSmallestWidthDp = source.readInt();
945 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700946 largestWidthLimitDp = source.readInt();
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700947 volumeUuid = source.readString();
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -0700948 scanSourceDir = source.readString();
949 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800950 sourceDir = source.readString();
951 publicSourceDir = source.readString();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700952 splitSourceDirs = source.readStringArray();
953 splitPublicSourceDirs = source.readStringArray();
Kenny Root85387d72010-08-26 10:13:11 -0700954 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100955 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -0700956 nativeLibraryRootDir = source.readString();
957 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100958 primaryCpuAbi = source.readString();
959 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -0800960 resourceDirs = source.readStringArray();
Robert Craig0f40dc92013-03-25 06:33:03 -0400961 seinfo = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962 sharedLibraryFiles = source.readStringArray();
963 dataDir = source.readString();
Jeff Sharkey15447792015-11-05 16:18:51 -0800964 deviceEncryptedDataDir = source.readString();
965 credentialEncryptedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800966 uid = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700967 targetSdkVersion = source.readInt();
Dianne Hackborn8472e612014-01-23 17:57:20 -0800968 versionCode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800969 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700970 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700971 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800972 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -0700973 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800974 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -0700975 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -0700976 fullBackupContent = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800977 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700978
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800979 /**
980 * Retrieve the textual description of the application. This
981 * will call back on the given PackageManager to load the description from
982 * the application.
983 *
984 * @param pm A PackageManager from which the label can be loaded; usually
985 * the PackageManager from which you originally retrieved this item.
986 *
987 * @return Returns a CharSequence containing the application's description.
988 * If there is no description, null is returned.
989 */
990 public CharSequence loadDescription(PackageManager pm) {
991 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -0700992 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800993 if (label != null) {
994 return label;
995 }
996 }
997 return null;
998 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -0700999
1000 /**
1001 * Disable compatibility mode
1002 *
1003 * @hide
1004 */
1005 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001006 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001007 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001008 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001009 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001010
1011 /** {@hide} */
1012 public void initForUser(int userId) {
1013 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1014
1015 if ("android".equals(packageName)) {
1016 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1017 return;
1018 }
1019
1020 deviceEncryptedDataDir = Environment
1021 .getDataUserDeviceEncryptedPackageDirectory(volumeUuid, userId, packageName)
1022 .getAbsolutePath();
1023 credentialEncryptedDataDir = Environment
1024 .getDataUserCredentialEncryptedPackageDirectory(volumeUuid, userId, packageName)
1025 .getAbsolutePath();
1026
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001027 if ((privateFlags & PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED) != 0
Jeff Sharkeyba512352015-11-12 20:17:45 -08001028 && StorageManager.isFileBasedEncryptionEnabled()) {
Jeff Sharkey15447792015-11-05 16:18:51 -08001029 dataDir = deviceEncryptedDataDir;
1030 } else {
1031 dataDir = credentialEncryptedDataDir;
1032 }
1033 }
1034
Jeff Brown07330792010-03-30 19:57:08 -07001035 /**
1036 * @hide
1037 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001038 @Override
1039 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001040 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1041 && isPackageUnavailable(pm)) {
1042 return Resources.getSystem().getDrawable(
1043 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1044 }
1045 return pm.getDefaultActivityIcon();
1046 }
1047
1048 private boolean isPackageUnavailable(PackageManager pm) {
1049 try {
1050 return pm.getPackageInfo(packageName, 0) == null;
1051 } catch (NameNotFoundException ex) {
1052 return true;
1053 }
1054 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001055
Jeff Brown07330792010-03-30 19:57:08 -07001056 /**
1057 * @hide
1058 */
Fyodor Kupoloveeea67b2015-02-23 17:14:45 -08001059 public boolean isForwardLocked() {
1060 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1061 }
1062
1063 /**
1064 * @hide
1065 */
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001066 public boolean isSystemApp() {
1067 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1068 }
1069
1070 /**
1071 * @hide
1072 */
Svet Ganovadc1cf42015-06-15 16:36:24 -07001073 public boolean isPrivilegedApp() {
1074 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1075 }
1076
1077 /**
1078 * @hide
1079 */
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001080 public boolean isUpdatedSystemApp() {
1081 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1082 }
1083
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07001084 /** @hide */
1085 public boolean isInternal() {
1086 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1087 }
1088
1089 /** @hide */
1090 public boolean isExternalAsec() {
1091 return TextUtils.isEmpty(volumeUuid)
1092 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1093 }
1094
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001095 /** @hide */
1096 public boolean isEncryptionAware() {
1097 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ENCRYPTION_AWARE) != 0;
1098 }
1099
Jeff Sharkey8924e872015-11-30 12:52:10 -07001100 /** @hide */
1101 public boolean isPartiallyEncryptionAware() {
1102 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_ENCRYPTION_AWARE) != 0;
1103 }
1104
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001105 /**
1106 * @hide
1107 */
Jeff Vander Stoepa4407bf2015-10-30 13:15:58 -07001108 public boolean isAutoPlayApp() {
1109 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_AUTOPLAY) != 0;
1110 }
1111
1112 /**
1113 * @hide
1114 */
Svet Ganov2acf0632015-11-24 19:10:59 -08001115 public boolean isEphemeralApp() {
1116 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0;
1117 }
1118
1119 /**
1120 * @hide
1121 */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001122 public boolean isRequiredForSystemUser() {
1123 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1124 }
1125
1126 /**
1127 * @hide
1128 */
Jeff Brown07330792010-03-30 19:57:08 -07001129 @Override protected ApplicationInfo getApplicationInfo() {
1130 return this;
1131 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001132
1133 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1134 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1135 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1136 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1137 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1138 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1139
1140 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1141 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1142 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1143 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1144 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
1145 /** {@hide} */ public String[] getSplitResourcePaths() { return splitSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001146}