blob: 58d75f761c8e73a2d21fbabb935a1cd7791a2cb9 [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 Sharkeya73b8fd2016-01-06 17:02:08 -070019import android.annotation.TestApi;
Jeff Brown07330792010-03-30 19:57:08 -070020import android.content.pm.PackageManager.NameNotFoundException;
21import android.content.res.Resources;
22import android.graphics.drawable.Drawable;
Jeff Sharkey15447792015-11-05 16:18:51 -080023import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.os.Parcel;
25import android.os.Parcelable;
Jeff Sharkey15447792015-11-05 16:18:51 -080026import android.os.UserHandle;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -080027import android.os.storage.StorageManager;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070028import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.util.Printer;
30
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070031import com.android.internal.util.ArrayUtils;
32
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070034import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070036import java.util.Objects;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037
38/**
39 * Information you can retrieve about a particular application. This
40 * corresponds to information collected from the AndroidManifest.xml's
41 * <application> tag.
42 */
43public class ApplicationInfo extends PackageItemInfo implements Parcelable {
44
45 /**
46 * Default task affinity of all activities in this application. See
47 * {@link ActivityInfo#taskAffinity} for more information. This comes
48 * from the "taskAffinity" attribute.
49 */
50 public String taskAffinity;
51
52 /**
53 * Optional name of a permission required to be able to access this
54 * application's components. From the "permission" attribute.
55 */
56 public String permission;
57
58 /**
59 * The name of the process this application should run in. From the
60 * "process" attribute or, if not set, the same as
61 * <var>packageName</var>.
62 */
63 public String processName;
64
65 /**
66 * Class implementing the Application object. From the "class"
67 * attribute.
68 */
69 public String className;
70
71 /**
72 * A style resource identifier (in the package's resources) of the
73 * description of an application. From the "description" attribute
74 * or, if not set, 0.
75 */
76 public int descriptionRes;
77
78 /**
79 * A style resource identifier (in the package's resources) of the
80 * default visual theme of the application. From the "theme" attribute
81 * or, if not set, 0.
82 */
83 public int theme;
84
85 /**
86 * Class implementing the Application's manage space
87 * functionality. From the "manageSpaceActivity"
88 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -070089 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080090 */
91 public String manageSpaceActivityName;
92
93 /**
Christopher Tate181fafa2009-05-14 11:12:14 -070094 * Class implementing the Application's backup functionality. From
95 * the "backupAgent" attribute. This is an optional attribute and
96 * will be null if the application does not specify it in its manifest.
97 *
98 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -070099 */
100 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700101
102 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700103 * An optional attribute that indicates the app supports automatic backup of app data.
104 * <p>0 is the default and means the app's entire data folder + managed external storage will
105 * be backed up;
106 * Any negative value indicates the app does not support full-data backup, though it may still
107 * want to participate via the traditional key/value backup API;
108 * A positive number specifies an xml resource in which the application has defined its backup
109 * include/exclude criteria.
110 * <p>If android:allowBackup is set to false, this attribute is ignored.
111 *
112 * @see {@link android.content.Context#getNoBackupFilesDir}
113 * @see {@link #FLAG_ALLOW_BACKUP}
Christopher Tate98fa6562015-05-14 13:20:10 -0700114 *
115 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700116 */
117 public int fullBackupContent = 0;
118
119 /**
Adam Powell269248d2011-08-02 10:26:54 -0700120 * The default extra UI options for activities in this application.
121 * Set from the {@link android.R.attr#uiOptions} attribute in the
122 * activity's manifest.
123 */
124 public int uiOptions = 0;
125
126 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800127 * Value for {@link #flags}: if set, this application is installed in the
128 * device's system image.
129 */
130 public static final int FLAG_SYSTEM = 1<<0;
131
132 /**
133 * Value for {@link #flags}: set to true if this application would like to
134 * allow debugging of its
135 * code, even when installed on a non-development system. Comes
136 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
137 * android:debuggable} of the &lt;application&gt; tag.
138 */
139 public static final int FLAG_DEBUGGABLE = 1<<1;
140
141 /**
142 * Value for {@link #flags}: set to true if this application has code
143 * associated with it. Comes
144 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
145 * android:hasCode} of the &lt;application&gt; tag.
146 */
147 public static final int FLAG_HAS_CODE = 1<<2;
148
149 /**
150 * Value for {@link #flags}: set to true if this application is persistent.
151 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
152 * android:persistent} of the &lt;application&gt; tag.
153 */
154 public static final int FLAG_PERSISTENT = 1<<3;
155
156 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700157 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800158 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
159 * device is running in factory test mode.
160 */
161 public static final int FLAG_FACTORY_TEST = 1<<4;
162
163 /**
164 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
165 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
166 * android:allowTaskReparenting} of the &lt;application&gt; tag.
167 */
168 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
169
170 /**
171 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
172 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
173 * android:allowClearUserData} of the &lt;application&gt; tag.
174 */
175 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
176
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800177 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700178 * Value for {@link #flags}: this is set if this application has been
Kweku Adams8de29ca2016-01-22 12:30:26 -0800179 * installed as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800180 */
181 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700182
183 /**
Svet Ganov354cd3c2015-12-17 11:35:04 -0800184 * Value for {@link #flags}: this is set if the application has specified
Dianne Hackborn7f205432009-07-28 00:13:47 -0700185 * {@link android.R.styleable#AndroidManifestApplication_testOnly
186 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700187 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700188 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700189
190 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700191 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700192 * reduced in size for smaller screens. Corresponds to
193 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
194 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700195 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700196 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
197
198 /**
199 * Value for {@link #flags}: true when the application's window can be
200 * displayed on normal screens. Corresponds to
201 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
202 * android:normalScreens}.
203 */
204 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
205
206 /**
207 * Value for {@link #flags}: true when the application's window can be
208 * increased in size for larger screens. Corresponds to
209 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700210 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700211 */
212 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700213
214 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700215 * Value for {@link #flags}: true when the application knows how to adjust
216 * its UI for different screen sizes. Corresponds to
217 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
218 * android:resizeable}.
219 */
220 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
221
222 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700223 * Value for {@link #flags}: true when the application knows how to
224 * accomodate different screen densities. Corresponds to
225 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
226 * android:anyDensity}.
227 */
228 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
229
230 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800231 * Value for {@link #flags}: set to true if this application would like to
232 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700233 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
234 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800235 */
236 public static final int FLAG_VM_SAFE_MODE = 1<<14;
237
238 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800239 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
240 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700241 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800242 * <p>Comes from the
243 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
244 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700245 */
Ben Cheng23085b72010-02-08 16:06:32 -0800246 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700247
248 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800249 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
250 * in memory following a full-system restore operation; <code>true</code> otherwise.
251 * Ordinarily, during a full system restore operation each application is shut down
252 * following execution of its agent's onRestore() method. Setting this attribute to
253 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700254 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800255 * <p>If
256 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
257 * is set to <code>false</code> or no
258 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700259 * is specified, this flag will be ignored.
260 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800261 * <p>Comes from the
262 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
263 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700264 */
Ben Cheng23085b72010-02-08 16:06:32 -0800265 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700266
267 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800268 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
269 * agent claims to be able to handle restore data even "from the future,"
270 * i.e. from versions of the application with a versionCode greater than
271 * the one currently installed on the device. <i>Use with caution!</i> By default
272 * this attribute is <code>false</code> and the Backup Manager will ensure that data
273 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700274 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800275 * <p>If
276 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
277 * is set to <code>false</code> or no
278 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700279 * is specified, this flag will be ignored.
280 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800281 * <p>Comes from the
282 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
283 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700284 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800285 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700286
Christopher Tate181fafa2009-05-14 11:12:14 -0700287 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700288 * Value for {@link #flags}: Set to true if the application is
289 * currently installed on external/removable/unprotected storage. Such
290 * applications may not be available if their storage is not currently
291 * mounted. When the storage it is on is not available, it will look like
292 * the application has been uninstalled (its .apk is no longer available)
293 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800294 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700295 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800296
297 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700298 * Value for {@link #flags}: true when the application's window can be
299 * increased in size for extra large screens. Corresponds to
300 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700301 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700302 */
303 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
304
305 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800306 * Value for {@link #flags}: true when the application has requested a
307 * large heap for its processes. Corresponds to
308 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
309 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600310 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800311 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600312
313 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800314 * Value for {@link #flags}: true if this application's package is in
315 * the stopped state.
316 */
317 public static final int FLAG_STOPPED = 1<<21;
318
319 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700320 * Value for {@link #flags}: true when the application is willing to support
321 * RTL (right to left). All activities will inherit this value.
322 *
323 * Set from the {@link android.R.attr#supportsRtl} attribute in the
324 * activity's manifest.
325 *
326 * Default value is false (no support for RTL).
327 */
328 public static final int FLAG_SUPPORTS_RTL = 1<<22;
329
330 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700331 * Value for {@link #flags}: true if the application is currently
332 * installed for the calling user.
333 */
334 public static final int FLAG_INSTALLED = 1<<23;
335
336 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700337 * Value for {@link #flags}: true if the application only has its
338 * data installed; the application package itself does not currently
339 * exist on the device.
340 */
341 public static final int FLAG_IS_DATA_ONLY = 1<<24;
342
343 /**
Jose Lima12d0b4c2014-03-14 16:55:12 -0700344 * Value for {@link #flags}: true if the application was declared to be a game, or
345 * false if it is a non-game application.
346 */
347 public static final int FLAG_IS_GAME = 1<<25;
348
349 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700350 * Value for {@link #flags}: {@code true} if the application asks that only
351 * full-data streaming backups of its data be performed even though it defines
352 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
353 * indicates that the app will manage its backed-up data via incremental
354 * key/value updates.
355 */
356 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
357
358 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700359 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
360 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
361 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
362 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700363 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
364 * traffic. Third-party libraries are encouraged to honor this flag as well.
365 *
366 * <p>NOTE: {@code WebView} does not honor this flag.
367 *
368 * <p>This flag comes from
369 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
370 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700371 */
372 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
373
374 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700375 * When set installer extracts native libs from .apk files.
376 */
377 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
378
379 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700380 * Value for {@link #flags}: {@code true} when the application's rendering
381 * should be hardware accelerated.
382 */
383 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
384
385 /**
Andrei Stingaceanu1e283912015-11-26 15:26:28 +0000386 * Value for {@link #flags}: true if this application's package is in
387 * the suspended state.
388 */
389 public static final int FLAG_SUSPENDED = 1<<30;
390
391 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100392 * Value for {@link #flags}: true if code from this application will need to be
393 * loaded into other applications' processes. On devices that support multiple
394 * instruction sets, this implies the code might be loaded into a process that's
395 * using any of the devices supported instruction sets.
396 *
397 * <p> The system might treat such applications specially, for eg., by
398 * extracting the application's native libraries for all supported instruction
399 * sets or by compiling the application's dex code for all supported instruction
400 * sets.
401 */
402 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700403
404 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405 * Flags associated with the application. Any combination of
406 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
407 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
408 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700409 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700410 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
411 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700412 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
413 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700414 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800415 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
416 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
417 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
418 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
419 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700420 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
421 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800422 */
423 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700424
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800426 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
427 * most purposes is considered as not installed.
428 * {@hide}
429 */
430 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
431
432 /**
433 * Value for {@link #privateFlags}: set to <code>true</code> if the application
434 * has reported that it is heavy-weight, and thus can not participate in
435 * the normal application lifecycle.
436 *
437 * <p>Comes from the
438 * android.R.styleable#AndroidManifestApplication_cantSaveState
439 * attribute of the &lt;application&gt; tag.
440 *
441 * {@hide}
442 */
443 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
444
445 /**
446 * Value for {@link #privateFlags}: Set to true if the application has been
447 * installed using the forward lock option.
448 *
449 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
450 *
451 * {@hide}
452 */
453 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
454
455 /**
456 * Value for {@link #privateFlags}: set to {@code true} if the application
457 * is permitted to hold privileged permissions.
458 *
459 * {@hide}
460 */
461 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
462
463 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800464 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
465 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700466 *
467 * {@hide}
468 */
469 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
470
471 /**
Jeff Sharkey15447792015-11-05 16:18:51 -0800472 * When set, default data storage directory for given app is pointed at
473 * device-encrypted location.
474 *
475 * @hide
476 */
Jeff Sharkeye17ac152015-11-06 22:40:29 -0800477 public static final int PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800478
479 /**
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800480 * When set, assume that all components under the given app are encryption
481 * aware, unless otherwise specified.
482 *
483 * @hide
484 */
485 public static final int PRIVATE_FLAG_ENCRYPTION_AWARE = 1 << 6;
486
487 /**
Jeff Vander Stoepa4407bf2015-10-30 13:15:58 -0700488 * Value for {@link #privateFlags}: set to {@code true} if the application
489 * is AutoPlay.
490 *
491 * {@hide}
492 */
Jeff Vander Stoep9edb7bf2015-11-16 15:23:38 -0800493 public static final int PRIVATE_FLAG_AUTOPLAY = 1 << 7;
Jeff Vander Stoepa4407bf2015-10-30 13:15:58 -0700494
495 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -0700496 * When set, at least one component inside this application is encryption aware.
497 *
498 * @hide
499 */
500 public static final int PRIVATE_FLAG_PARTIALLY_ENCRYPTION_AWARE = 1 << 8;
501
502 /**
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800503 * Value for {@link #flags}: {@code true} if the application is blocked via restrictions
504 * and for most purposes is considered as not installed.
505 * {@hide}
506 */
507 public static final int PRIVATE_FLAG_EPHEMERAL = 1 << 9;
508
509 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800510 * When set, signals that the application is required for the system user and should not be
511 * uninstalled.
512 *
513 * @hide
514 */
515 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 10;
516
517 /**
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800518 * When set, the activities associated with this application are resizeable by default.
519 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
520 *
521 * @hide
522 */
523 public static final int PRIVATE_FLAG_RESIZEABLE_ACTIVITIES = 1 << 11;
524
525 /**
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800526 * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
527 * run full-data backup operations for the app even when it is in a
528 * foreground-equivalent run state. Defaults to {@code false} if unspecified.
529 * @hide
530 */
531 public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 12;
532
533 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800534 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
535 * {@hide}
536 */
537 public int privateFlags;
538
539 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700540 * The required smallest screen width the application can run on. If 0,
541 * nothing has been specified. Comes from
542 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
543 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
544 */
545 public int requiresSmallestWidthDp = 0;
546
547 /**
548 * The maximum smallest screen width the application is designed for. If 0,
549 * nothing has been specified. Comes from
550 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
551 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
552 */
553 public int compatibleWidthLimitDp = 0;
554
555 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700556 * The maximum smallest screen width the application will work on. If 0,
557 * nothing has been specified. Comes from
558 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
559 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
560 */
561 public int largestWidthLimitDp = 0;
562
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700563 /** {@hide} */
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700564 public String volumeUuid;
565 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700566 public String scanSourceDir;
567 /** {@hide} */
568 public String scanPublicSourceDir;
569
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700570 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700571 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800572 */
573 public String sourceDir;
574
575 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700576 * Full path to the publicly available parts of {@link #sourceDir},
577 * including resources and manifest. This may be different from
578 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800579 */
580 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700581
582 /**
583 * Full paths to zero or more split APKs that, when combined with the base
584 * APK defined in {@link #sourceDir}, form a complete application.
585 */
586 public String[] splitSourceDirs;
587
588 /**
589 * Full path to the publicly available parts of {@link #splitSourceDirs},
590 * including resources and manifest. This may be different from
591 * {@link #splitSourceDirs} if an application is forward locked.
592 */
593 public String[] splitPublicSourceDirs;
594
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800595 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800596 * Full paths to the locations of extra resource packages this application
597 * uses. This field is only used if there are extra resource packages,
598 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800599 *
600 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800601 */
602 public String[] resourceDirs;
603
604 /**
Robert Craig0f40dc92013-03-25 06:33:03 -0400605 * String retrieved from the seinfo tag found in selinux policy. This value
Robert Craig5e16bc52015-08-28 12:11:41 -0400606 * can be overridden with a value set through the mac_permissions.xml policy
607 * construct. This value is useful in setting an SELinux security context on
608 * the process as well as its data directory. The String default is being used
609 * here to represent a catchall label when no policy matches.
Robert Craig0f40dc92013-03-25 06:33:03 -0400610 *
611 * {@hide}
612 */
Robert Craig5e16bc52015-08-28 12:11:41 -0400613 public String seinfo = "default";
Robert Craig0f40dc92013-03-25 06:33:03 -0400614
615 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616 * Paths to all shared libraries this application is linked against. This
617 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
618 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
619 * the structure.
620 */
621 public String[] sharedLibraryFiles;
622
623 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700624 * Full path to the default directory assigned to the package for its
625 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800626 */
627 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700628
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700629 /**
630 * Full path to the device-encrypted directory assigned to the package for
631 * its persistent data.
632 */
Jeff Sharkey15447792015-11-05 16:18:51 -0800633 public String deviceEncryptedDataDir;
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700634
635 /**
636 * Full path to the credential-encrypted directory assigned to the package
637 * for its persistent data.
638 */
Jeff Sharkey15447792015-11-05 16:18:51 -0800639 public String credentialEncryptedDataDir;
640
Kenny Root85387d72010-08-26 10:13:11 -0700641 /**
642 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700643 */
644 public String nativeLibraryDir;
645
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800646 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100647 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
648 * are stored, if present.
649 *
650 * The main reason this exists is for bundled multi-arch apps, where
651 * it's not trivial to calculate the location of libs for the secondary abi
652 * given the location of the primary.
653 *
654 * TODO: Change the layout of bundled installs so that we can use
655 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
656 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
657 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
658 *
659 * @hide
660 */
661 public String secondaryNativeLibraryDir;
662
663 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700664 * The root path where unpacked native libraries are stored.
665 * <p>
666 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
667 * placed in ISA-specific subdirectories under this path, otherwise the
668 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100669 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700670 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100671 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700672 public String nativeLibraryRootDir;
673
674 /**
675 * Flag indicating that ISA must be appended to
676 * {@link #nativeLibraryRootDir} to be useful.
677 *
678 * @hide
679 */
680 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100681
682 /**
683 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100684 * of the native JNI libraries the application bundles. Will be {@code null}
685 * if this application does not require any particular ABI.
686 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100687 * If non-null, the application will always be launched with this ABI.
688 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100689 * {@hide}
690 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100691 public String primaryCpuAbi;
692
693 /**
694 * The secondary ABI for this application. Might be non-null for multi-arch
695 * installs. The application itself never uses this ABI, but other applications that
696 * use its code might.
697 *
698 * {@hide}
699 */
700 public String secondaryCpuAbi;
701
702 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800703 * The kernel user-ID that has been assigned to this application;
704 * currently this is not a unique ID (multiple applications can have
705 * the same uid).
706 */
707 public int uid;
708
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700709 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800710 * The minimum SDK version this application can run on. It will not run
711 * on earlier versions.
712 */
713 public String minSdkVersion;
714
715 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700716 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700717 * versions, but it knows how to work with any new behavior added at this
718 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
719 * if this is a development build and the app is targeting that. You should
720 * compare that this number is >= the SDK version number at which your
721 * behavior was introduced.
722 */
723 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800724
725 /**
726 * The app's declared version code.
727 * @hide
728 */
729 public int versionCode;
730
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700731 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800732 * When false, indicates that all components within this application are
733 * considered disabled, regardless of their individually set enabled status.
734 */
735 public boolean enabled = true;
736
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700737 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700738 * For convenient access to the current enabled setting of this app.
739 * @hide
740 */
741 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
742
743 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700744 * For convenient access to package's install location.
745 * @hide
746 */
747 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700748
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800749 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800750 dump(pw, prefix, DUMP_FLAG_ALL);
751 }
752
753 /** @hide */
754 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800755 super.dumpFront(pw, prefix);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800756 if ((flags&DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -0800757 pw.println(prefix + "className=" + className);
758 }
759 if (permission != null) {
760 pw.println(prefix + "permission=" + permission);
761 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700762 pw.println(prefix + "processName=" + processName);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800763 if ((flags&DUMP_FLAG_DETAILS) != 0) {
764 pw.println(prefix + "taskAffinity=" + taskAffinity);
765 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700766 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800767 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -0700768 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800769 if ((flags&DUMP_FLAG_DETAILS) != 0) {
770 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
771 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
772 + " largestWidthLimitDp=" + largestWidthLimitDp);
773 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800774 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700775 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700776 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
777 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700778 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
779 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
780 }
781 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
782 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
783 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
784 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700785 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -0800786 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -0700787 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800788 if ((flags&DUMP_FLAG_DETAILS) != 0 && seinfo != null) {
Robert Craig0f40dc92013-03-25 06:33:03 -0400789 pw.println(prefix + "seinfo=" + seinfo);
790 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800791 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800792 if ((flags&DUMP_FLAG_DETAILS) != 0) {
793 pw.println(prefix + "deviceEncryptedDataDir=" + deviceEncryptedDataDir);
794 pw.println(prefix + "credentialEncryptedDataDir=" + credentialEncryptedDataDir);
795 if (sharedLibraryFiles != null) {
796 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
797 }
Dianne Hackborn12527f92009-11-11 17:39:50 -0800798 }
Todd Kennedy89d60182016-03-11 11:18:32 -0800799 pw.println(prefix + "enabled=" + enabled
800 + " minSdkVersion=" + minSdkVersion
801 + " targetSdkVersion=" + targetSdkVersion
Dianne Hackborn8472e612014-01-23 17:57:20 -0800802 + " versionCode=" + versionCode);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800803 if ((flags&DUMP_FLAG_DETAILS) != 0) {
804 if (manageSpaceActivityName != null) {
805 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
806 }
807 if (descriptionRes != 0) {
808 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
809 }
810 if (uiOptions != 0) {
811 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
812 }
813 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
814 if (fullBackupContent > 0) {
815 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
816 } else {
817 pw.println(prefix + "fullBackupContent="
818 + (fullBackupContent < 0 ? "false" : "true"));
819 }
Matthew Williams303650c2015-04-17 18:22:51 -0700820 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800821 super.dumpBack(pw, prefix);
822 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700823
824 /**
825 * @return true if "supportsRtl" has been set to true in the AndroidManifest
826 * @hide
827 */
828 public boolean hasRtlSupport() {
829 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
830 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -0700831
832 /** {@hide} */
833 public boolean hasCode() {
834 return (flags & FLAG_HAS_CODE) != 0;
835 }
836
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800837 public static class DisplayNameComparator
838 implements Comparator<ApplicationInfo> {
839 public DisplayNameComparator(PackageManager pm) {
840 mPM = pm;
841 }
842
843 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
844 CharSequence sa = mPM.getApplicationLabel(aa);
845 if (sa == null) {
846 sa = aa.packageName;
847 }
848 CharSequence sb = mPM.getApplicationLabel(ab);
849 if (sb == null) {
850 sb = ab.packageName;
851 }
852
853 return sCollator.compare(sa.toString(), sb.toString());
854 }
855
856 private final Collator sCollator = Collator.getInstance();
857 private PackageManager mPM;
858 }
859
860 public ApplicationInfo() {
861 }
862
863 public ApplicationInfo(ApplicationInfo orig) {
864 super(orig);
865 taskAffinity = orig.taskAffinity;
866 permission = orig.permission;
867 processName = orig.processName;
868 className = orig.className;
869 theme = orig.theme;
870 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800871 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700872 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
873 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700874 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700875 volumeUuid = orig.volumeUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -0700876 scanSourceDir = orig.scanSourceDir;
877 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800878 sourceDir = orig.sourceDir;
879 publicSourceDir = orig.publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700880 splitSourceDirs = orig.splitSourceDirs;
881 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Kenny Root85387d72010-08-26 10:13:11 -0700882 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100883 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -0700884 nativeLibraryRootDir = orig.nativeLibraryRootDir;
885 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100886 primaryCpuAbi = orig.primaryCpuAbi;
887 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -0800888 resourceDirs = orig.resourceDirs;
Robert Craig0f40dc92013-03-25 06:33:03 -0400889 seinfo = orig.seinfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800890 sharedLibraryFiles = orig.sharedLibraryFiles;
891 dataDir = orig.dataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -0800892 deviceEncryptedDataDir = orig.deviceEncryptedDataDir;
893 credentialEncryptedDataDir = orig.credentialEncryptedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800894 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -0800895 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700896 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800897 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800898 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700899 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700900 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800901 manageSpaceActivityName = orig.manageSpaceActivityName;
902 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -0700903 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -0700904 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -0700905 fullBackupContent = orig.fullBackupContent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800906 }
907
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800908 public String toString() {
909 return "ApplicationInfo{"
910 + Integer.toHexString(System.identityHashCode(this))
911 + " " + packageName + "}";
912 }
913
914 public int describeContents() {
915 return 0;
916 }
917
918 public void writeToParcel(Parcel dest, int parcelableFlags) {
919 super.writeToParcel(dest, parcelableFlags);
920 dest.writeString(taskAffinity);
921 dest.writeString(permission);
922 dest.writeString(processName);
923 dest.writeString(className);
924 dest.writeInt(theme);
925 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800926 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700927 dest.writeInt(requiresSmallestWidthDp);
928 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700929 dest.writeInt(largestWidthLimitDp);
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700930 dest.writeString(volumeUuid);
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -0700931 dest.writeString(scanSourceDir);
932 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800933 dest.writeString(sourceDir);
934 dest.writeString(publicSourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700935 dest.writeStringArray(splitSourceDirs);
936 dest.writeStringArray(splitPublicSourceDirs);
Kenny Root85387d72010-08-26 10:13:11 -0700937 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100938 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -0700939 dest.writeString(nativeLibraryRootDir);
940 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +0100941 dest.writeString(primaryCpuAbi);
942 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -0800943 dest.writeStringArray(resourceDirs);
Robert Craig0f40dc92013-03-25 06:33:03 -0400944 dest.writeString(seinfo);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800945 dest.writeStringArray(sharedLibraryFiles);
946 dest.writeString(dataDir);
Jeff Sharkey15447792015-11-05 16:18:51 -0800947 dest.writeString(deviceEncryptedDataDir);
948 dest.writeString(credentialEncryptedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800949 dest.writeInt(uid);
Todd Kennedy89d60182016-03-11 11:18:32 -0800950 dest.writeString(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700951 dest.writeInt(targetSdkVersion);
Dianne Hackborn8472e612014-01-23 17:57:20 -0800952 dest.writeInt(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800953 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700954 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700955 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800956 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -0700957 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800958 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -0700959 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -0700960 dest.writeInt(fullBackupContent);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800961 }
962
963 public static final Parcelable.Creator<ApplicationInfo> CREATOR
964 = new Parcelable.Creator<ApplicationInfo>() {
965 public ApplicationInfo createFromParcel(Parcel source) {
966 return new ApplicationInfo(source);
967 }
968 public ApplicationInfo[] newArray(int size) {
969 return new ApplicationInfo[size];
970 }
971 };
972
973 private ApplicationInfo(Parcel source) {
974 super(source);
975 taskAffinity = source.readString();
976 permission = source.readString();
977 processName = source.readString();
978 className = source.readString();
979 theme = source.readInt();
980 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800981 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700982 requiresSmallestWidthDp = source.readInt();
983 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700984 largestWidthLimitDp = source.readInt();
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700985 volumeUuid = source.readString();
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -0700986 scanSourceDir = source.readString();
987 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800988 sourceDir = source.readString();
989 publicSourceDir = source.readString();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700990 splitSourceDirs = source.readStringArray();
991 splitPublicSourceDirs = source.readStringArray();
Kenny Root85387d72010-08-26 10:13:11 -0700992 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100993 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -0700994 nativeLibraryRootDir = source.readString();
995 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100996 primaryCpuAbi = source.readString();
997 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -0800998 resourceDirs = source.readStringArray();
Robert Craig0f40dc92013-03-25 06:33:03 -0400999 seinfo = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001000 sharedLibraryFiles = source.readStringArray();
1001 dataDir = source.readString();
Jeff Sharkey15447792015-11-05 16:18:51 -08001002 deviceEncryptedDataDir = source.readString();
1003 credentialEncryptedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001004 uid = source.readInt();
Todd Kennedy89d60182016-03-11 11:18:32 -08001005 minSdkVersion = source.readString();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001006 targetSdkVersion = source.readInt();
Dianne Hackborn8472e612014-01-23 17:57:20 -08001007 versionCode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001008 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001009 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001010 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001011 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001012 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001013 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001014 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001015 fullBackupContent = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001016 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001017
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001018 /**
1019 * Retrieve the textual description of the application. This
1020 * will call back on the given PackageManager to load the description from
1021 * the application.
1022 *
1023 * @param pm A PackageManager from which the label can be loaded; usually
1024 * the PackageManager from which you originally retrieved this item.
1025 *
1026 * @return Returns a CharSequence containing the application's description.
1027 * If there is no description, null is returned.
1028 */
1029 public CharSequence loadDescription(PackageManager pm) {
1030 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001031 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001032 if (label != null) {
1033 return label;
1034 }
1035 }
1036 return null;
1037 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001038
1039 /**
1040 * Disable compatibility mode
1041 *
1042 * @hide
1043 */
1044 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001045 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001046 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001047 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001048 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001049
1050 /** {@hide} */
1051 public void initForUser(int userId) {
1052 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1053
1054 if ("android".equals(packageName)) {
1055 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1056 return;
1057 }
1058
1059 deviceEncryptedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001060 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001061 .getAbsolutePath();
1062 credentialEncryptedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001063 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001064 .getAbsolutePath();
1065
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001066 if ((privateFlags & PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED) != 0
Jeff Sharkeye4697132016-02-06 19:46:15 -07001067 && PackageManager.APPLY_FORCE_DEVICE_ENCRYPTED) {
Jeff Sharkey15447792015-11-05 16:18:51 -08001068 dataDir = deviceEncryptedDataDir;
1069 } else {
1070 dataDir = credentialEncryptedDataDir;
1071 }
1072 }
1073
Jeff Brown07330792010-03-30 19:57:08 -07001074 /**
1075 * @hide
1076 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001077 @Override
1078 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001079 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1080 && isPackageUnavailable(pm)) {
1081 return Resources.getSystem().getDrawable(
1082 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1083 }
1084 return pm.getDefaultActivityIcon();
1085 }
1086
1087 private boolean isPackageUnavailable(PackageManager pm) {
1088 try {
1089 return pm.getPackageInfo(packageName, 0) == null;
1090 } catch (NameNotFoundException ex) {
1091 return true;
1092 }
1093 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001094
Jeff Brown07330792010-03-30 19:57:08 -07001095 /**
1096 * @hide
1097 */
Fyodor Kupoloveeea67b2015-02-23 17:14:45 -08001098 public boolean isForwardLocked() {
1099 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1100 }
1101
1102 /**
1103 * @hide
1104 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001105 @TestApi
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001106 public boolean isSystemApp() {
1107 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1108 }
1109
1110 /**
1111 * @hide
1112 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001113 @TestApi
Svet Ganovadc1cf42015-06-15 16:36:24 -07001114 public boolean isPrivilegedApp() {
1115 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1116 }
1117
1118 /**
1119 * @hide
1120 */
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001121 public boolean isUpdatedSystemApp() {
1122 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1123 }
1124
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07001125 /** @hide */
1126 public boolean isInternal() {
1127 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1128 }
1129
1130 /** @hide */
1131 public boolean isExternalAsec() {
1132 return TextUtils.isEmpty(volumeUuid)
1133 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1134 }
1135
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001136 /** @hide */
Jeff Sharkeye4697132016-02-06 19:46:15 -07001137 public boolean isForceDeviceEncrypted() {
1138 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORCE_DEVICE_ENCRYPTED) != 0;
1139 }
1140
1141 /** @hide */
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001142 public boolean isEncryptionAware() {
1143 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ENCRYPTION_AWARE) != 0;
1144 }
1145
Jeff Sharkey8924e872015-11-30 12:52:10 -07001146 /** @hide */
1147 public boolean isPartiallyEncryptionAware() {
1148 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_ENCRYPTION_AWARE) != 0;
1149 }
1150
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001151 /**
1152 * @hide
1153 */
Jeff Vander Stoepa4407bf2015-10-30 13:15:58 -07001154 public boolean isAutoPlayApp() {
1155 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_AUTOPLAY) != 0;
1156 }
1157
1158 /**
1159 * @hide
1160 */
Svet Ganov2acf0632015-11-24 19:10:59 -08001161 public boolean isEphemeralApp() {
1162 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0;
1163 }
1164
1165 /**
1166 * @hide
1167 */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001168 public boolean isRequiredForSystemUser() {
1169 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1170 }
1171
1172 /**
1173 * @hide
1174 */
Jeff Brown07330792010-03-30 19:57:08 -07001175 @Override protected ApplicationInfo getApplicationInfo() {
1176 return this;
1177 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001178
1179 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1180 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1181 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1182 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1183 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1184 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1185
1186 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1187 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1188 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1189 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1190 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
1191 /** {@hide} */ public String[] getSplitResourcePaths() { return splitSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001192}