blob: dcc682116993d40fd2ab74508e059348b4959b4c [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 Sharkey9bc89af2017-01-11 11:25:50 -070019import static android.os.Build.VERSION_CODES.DONUT;
20
21import android.annotation.IntDef;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060022import android.annotation.SystemApi;
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -070023import android.annotation.TestApi;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060024import android.content.Context;
Jeff Brown07330792010-03-30 19:57:08 -070025import android.content.pm.PackageManager.NameNotFoundException;
26import android.content.res.Resources;
27import android.graphics.drawable.Drawable;
Jeff Sharkey15447792015-11-05 16:18:51 -080028import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.os.Parcel;
30import android.os.Parcelable;
Jeff Sharkey15447792015-11-05 16:18:51 -080031import android.os.UserHandle;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060032import android.os.storage.StorageManager;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070033import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.util.Printer;
Adam Lesinski1665d0f2017-03-10 14:46:57 -080035import android.util.SparseArray;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070037import com.android.internal.util.ArrayUtils;
38
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070039import java.lang.annotation.Retention;
40import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070042import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070044import java.util.Objects;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060045import java.util.UUID;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046
47/**
48 * Information you can retrieve about a particular application. This
49 * corresponds to information collected from the AndroidManifest.xml's
50 * <application> tag.
51 */
52public class ApplicationInfo extends PackageItemInfo implements Parcelable {
53
54 /**
55 * Default task affinity of all activities in this application. See
56 * {@link ActivityInfo#taskAffinity} for more information. This comes
57 * from the "taskAffinity" attribute.
58 */
59 public String taskAffinity;
60
61 /**
62 * Optional name of a permission required to be able to access this
63 * application's components. From the "permission" attribute.
64 */
65 public String permission;
66
67 /**
68 * The name of the process this application should run in. From the
69 * "process" attribute or, if not set, the same as
70 * <var>packageName</var>.
71 */
72 public String processName;
73
74 /**
75 * Class implementing the Application object. From the "class"
76 * attribute.
77 */
78 public String className;
79
80 /**
81 * A style resource identifier (in the package's resources) of the
82 * description of an application. From the "description" attribute
83 * or, if not set, 0.
84 */
85 public int descriptionRes;
86
87 /**
88 * A style resource identifier (in the package's resources) of the
89 * default visual theme of the application. From the "theme" attribute
90 * or, if not set, 0.
91 */
92 public int theme;
93
94 /**
95 * Class implementing the Application's manage space
96 * functionality. From the "manageSpaceActivity"
97 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -070098 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080099 */
100 public String manageSpaceActivityName;
101
102 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700103 * Class implementing the Application's backup functionality. From
104 * the "backupAgent" attribute. This is an optional attribute and
105 * will be null if the application does not specify it in its manifest.
106 *
107 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -0700108 */
109 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700110
111 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700112 * An optional attribute that indicates the app supports automatic backup of app data.
113 * <p>0 is the default and means the app's entire data folder + managed external storage will
114 * be backed up;
115 * Any negative value indicates the app does not support full-data backup, though it may still
116 * want to participate via the traditional key/value backup API;
117 * A positive number specifies an xml resource in which the application has defined its backup
118 * include/exclude criteria.
119 * <p>If android:allowBackup is set to false, this attribute is ignored.
120 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600121 * @see android.content.Context#getNoBackupFilesDir()
122 * @see #FLAG_ALLOW_BACKUP
Christopher Tate98fa6562015-05-14 13:20:10 -0700123 *
124 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700125 */
126 public int fullBackupContent = 0;
127
128 /**
Adam Powell269248d2011-08-02 10:26:54 -0700129 * The default extra UI options for activities in this application.
130 * Set from the {@link android.R.attr#uiOptions} attribute in the
131 * activity's manifest.
132 */
133 public int uiOptions = 0;
134
135 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800136 * Value for {@link #flags}: if set, this application is installed in the
137 * device's system image.
138 */
139 public static final int FLAG_SYSTEM = 1<<0;
140
141 /**
142 * Value for {@link #flags}: set to true if this application would like to
143 * allow debugging of its
144 * code, even when installed on a non-development system. Comes
145 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
146 * android:debuggable} of the &lt;application&gt; tag.
147 */
148 public static final int FLAG_DEBUGGABLE = 1<<1;
149
150 /**
151 * Value for {@link #flags}: set to true if this application has code
152 * associated with it. Comes
153 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
154 * android:hasCode} of the &lt;application&gt; tag.
155 */
156 public static final int FLAG_HAS_CODE = 1<<2;
157
158 /**
159 * Value for {@link #flags}: set to true if this application is persistent.
160 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
161 * android:persistent} of the &lt;application&gt; tag.
162 */
163 public static final int FLAG_PERSISTENT = 1<<3;
164
165 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700166 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800167 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
168 * device is running in factory test mode.
169 */
170 public static final int FLAG_FACTORY_TEST = 1<<4;
171
172 /**
173 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
174 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
175 * android:allowTaskReparenting} of the &lt;application&gt; tag.
176 */
177 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
178
179 /**
180 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
181 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
182 * android:allowClearUserData} of the &lt;application&gt; tag.
183 */
184 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
185
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800186 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700187 * Value for {@link #flags}: this is set if this application has been
Kweku Adams8de29ca2016-01-22 12:30:26 -0800188 * installed as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800189 */
190 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700191
192 /**
Svet Ganov354cd3c2015-12-17 11:35:04 -0800193 * Value for {@link #flags}: this is set if the application has specified
Dianne Hackborn7f205432009-07-28 00:13:47 -0700194 * {@link android.R.styleable#AndroidManifestApplication_testOnly
195 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700196 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700197 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700198
199 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700200 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700201 * reduced in size for smaller screens. Corresponds to
202 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
203 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700204 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700205 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
206
207 /**
208 * Value for {@link #flags}: true when the application's window can be
209 * displayed on normal screens. Corresponds to
210 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
211 * android:normalScreens}.
212 */
213 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
214
215 /**
216 * Value for {@link #flags}: true when the application's window can be
217 * increased in size for larger screens. Corresponds to
218 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700219 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700220 */
221 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700222
223 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700224 * Value for {@link #flags}: true when the application knows how to adjust
225 * its UI for different screen sizes. Corresponds to
226 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
227 * android:resizeable}.
228 */
229 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
230
231 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700232 * Value for {@link #flags}: true when the application knows how to
233 * accomodate different screen densities. Corresponds to
234 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
235 * android:anyDensity}.
236 */
237 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
238
239 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800240 * Value for {@link #flags}: set to true if this application would like to
241 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700242 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
243 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800244 */
245 public static final int FLAG_VM_SAFE_MODE = 1<<14;
246
247 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800248 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
249 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700250 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800251 * <p>Comes from the
252 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
253 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700254 */
Ben Cheng23085b72010-02-08 16:06:32 -0800255 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700256
257 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800258 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
259 * in memory following a full-system restore operation; <code>true</code> otherwise.
260 * Ordinarily, during a full system restore operation each application is shut down
261 * following execution of its agent's onRestore() method. Setting this attribute to
262 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700263 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800264 * <p>If
265 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
266 * is set to <code>false</code> or no
267 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700268 * is specified, this flag will be ignored.
269 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800270 * <p>Comes from the
271 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
272 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700273 */
Ben Cheng23085b72010-02-08 16:06:32 -0800274 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700275
276 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800277 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
278 * agent claims to be able to handle restore data even "from the future,"
279 * i.e. from versions of the application with a versionCode greater than
280 * the one currently installed on the device. <i>Use with caution!</i> By default
281 * this attribute is <code>false</code> and the Backup Manager will ensure that data
282 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700283 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800284 * <p>If
285 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
286 * is set to <code>false</code> or no
287 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700288 * is specified, this flag will be ignored.
289 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800290 * <p>Comes from the
291 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
292 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700293 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800294 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700295
Christopher Tate181fafa2009-05-14 11:12:14 -0700296 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700297 * Value for {@link #flags}: Set to true if the application is
298 * currently installed on external/removable/unprotected storage. Such
299 * applications may not be available if their storage is not currently
300 * mounted. When the storage it is on is not available, it will look like
301 * the application has been uninstalled (its .apk is no longer available)
302 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800303 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700304 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800305
306 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700307 * Value for {@link #flags}: true when the application's window can be
308 * increased in size for extra large screens. Corresponds to
309 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700310 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700311 */
312 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
313
314 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800315 * Value for {@link #flags}: true when the application has requested a
316 * large heap for its processes. Corresponds to
317 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
318 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600319 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800320 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600321
322 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800323 * Value for {@link #flags}: true if this application's package is in
324 * the stopped state.
325 */
326 public static final int FLAG_STOPPED = 1<<21;
327
328 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700329 * Value for {@link #flags}: true when the application is willing to support
330 * RTL (right to left). All activities will inherit this value.
331 *
332 * Set from the {@link android.R.attr#supportsRtl} attribute in the
333 * activity's manifest.
334 *
335 * Default value is false (no support for RTL).
336 */
337 public static final int FLAG_SUPPORTS_RTL = 1<<22;
338
339 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700340 * Value for {@link #flags}: true if the application is currently
341 * installed for the calling user.
342 */
343 public static final int FLAG_INSTALLED = 1<<23;
344
345 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700346 * Value for {@link #flags}: true if the application only has its
347 * data installed; the application package itself does not currently
348 * exist on the device.
349 */
350 public static final int FLAG_IS_DATA_ONLY = 1<<24;
351
352 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700353 * Value for {@link #flags}: true if the application was declared to be a
354 * game, or false if it is a non-game application.
355 *
356 * @deprecated use {@link #CATEGORY_GAME} instead.
Jose Lima12d0b4c2014-03-14 16:55:12 -0700357 */
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700358 @Deprecated
Jose Lima12d0b4c2014-03-14 16:55:12 -0700359 public static final int FLAG_IS_GAME = 1<<25;
360
361 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700362 * Value for {@link #flags}: {@code true} if the application asks that only
363 * full-data streaming backups of its data be performed even though it defines
364 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
365 * indicates that the app will manage its backed-up data via incremental
366 * key/value updates.
367 */
368 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
369
370 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700371 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
372 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
373 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
374 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700375 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
376 * traffic. Third-party libraries are encouraged to honor this flag as well.
377 *
Nate Fischer6a2a5412017-10-23 18:02:41 -0700378 * <p>NOTE: {@code WebView} honors this flag for applications targeting API level 26 and up.
Alex Klyubinfbf45992015-04-21 13:44:29 -0700379 *
Chad Brubaker2df5ba72016-04-11 13:31:24 -0700380 * <p>This flag is ignored on Android N and above if an Android Network Security Config is
381 * present.
382 *
Alex Klyubinfbf45992015-04-21 13:44:29 -0700383 * <p>This flag comes from
384 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
385 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700386 */
387 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
388
389 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700390 * When set installer extracts native libs from .apk files.
391 */
392 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
393
394 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700395 * Value for {@link #flags}: {@code true} when the application's rendering
396 * should be hardware accelerated.
397 */
398 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
399
400 /**
Andrei Stingaceanu1e283912015-11-26 15:26:28 +0000401 * Value for {@link #flags}: true if this application's package is in
402 * the suspended state.
403 */
404 public static final int FLAG_SUSPENDED = 1<<30;
405
406 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100407 * Value for {@link #flags}: true if code from this application will need to be
408 * loaded into other applications' processes. On devices that support multiple
409 * instruction sets, this implies the code might be loaded into a process that's
410 * using any of the devices supported instruction sets.
411 *
412 * <p> The system might treat such applications specially, for eg., by
413 * extracting the application's native libraries for all supported instruction
414 * sets or by compiling the application's dex code for all supported instruction
415 * sets.
416 */
417 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700418
419 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800420 * Flags associated with the application. Any combination of
421 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
422 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
423 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700424 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700425 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
426 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700427 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
428 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700429 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800430 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
431 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
432 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
433 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
434 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700435 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
436 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800437 */
438 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700439
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800441 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
442 * most purposes is considered as not installed.
443 * {@hide}
444 */
445 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
446
447 /**
448 * Value for {@link #privateFlags}: set to <code>true</code> if the application
449 * has reported that it is heavy-weight, and thus can not participate in
450 * the normal application lifecycle.
451 *
452 * <p>Comes from the
453 * android.R.styleable#AndroidManifestApplication_cantSaveState
454 * attribute of the &lt;application&gt; tag.
455 *
456 * {@hide}
457 */
458 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
459
460 /**
461 * Value for {@link #privateFlags}: Set to true if the application has been
462 * installed using the forward lock option.
463 *
464 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
465 *
466 * {@hide}
467 */
468 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
469
470 /**
471 * Value for {@link #privateFlags}: set to {@code true} if the application
472 * is permitted to hold privileged permissions.
473 *
474 * {@hide}
475 */
476 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
477
478 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800479 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
480 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700481 *
482 * {@hide}
483 */
484 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
485
486 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600487 * When set, the default data storage directory for this app is pointed at
488 * the device-protected location.
Jeff Sharkey15447792015-11-05 16:18:51 -0800489 *
490 * @hide
491 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600492 public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800493
494 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600495 * When set, assume that all components under the given app are direct boot
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800496 * aware, unless otherwise specified.
497 *
498 * @hide
499 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600500 public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800501
502 /**
Todd Kennedybe0b8892017-02-15 14:13:52 -0800503 * Value for {@link #privateFlags}: {@code true} if the application is installed
504 * as instant app.
505 *
506 * @hide
Chad Brubaker4389c232016-11-04 14:50:50 -0700507 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800508 public static final int PRIVATE_FLAG_INSTANT = 1 << 7;
Chad Brubaker4389c232016-11-04 14:50:50 -0700509
510 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600511 * When set, at least one component inside this application is direct boot
512 * aware.
Jeff Sharkey8924e872015-11-30 12:52:10 -0700513 *
514 * @hide
515 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600516 public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
Jeff Sharkey8924e872015-11-30 12:52:10 -0700517
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800518
519 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800520 * When set, signals that the application is required for the system user and should not be
521 * uninstalled.
522 *
523 * @hide
524 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700525 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800526
527 /**
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700528 * When set, the application explicitly requested that its activities be resizeable by default.
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800529 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
530 *
531 * @hide
532 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700533 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE = 1 << 10;
534
535 /**
536 * When set, the application explicitly requested that its activities *not* be resizeable by
537 * default.
538 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
539 *
540 * @hide
541 */
542 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE = 1 << 11;
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700543
544 /**
545 * The application isn't requesting explicitly requesting for its activities to be resizeable or
546 * non-resizeable by default. So, we are making it activities resizeable by default based on the
547 * target SDK version of the app.
548 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
549 *
550 * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
551 * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
552 * where certain pre-N apps are forced to the resizeable.
553 *
554 * @hide
555 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700556 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION =
557 1 << 12;
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800558
559 /**
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800560 * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
561 * run full-data backup operations for the app even when it is in a
562 * foreground-equivalent run state. Defaults to {@code false} if unspecified.
563 * @hide
564 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700565 public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 13;
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800566
567 /**
Svet Ganov67882122016-12-11 16:36:34 -0800568 * Value for {@link #privateFlags}: {@code true} means this application
569 * contains a static shared library. Defaults to {@code false} if unspecified.
570 * @hide
571 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700572 public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 14;
Svet Ganov67882122016-12-11 16:36:34 -0800573
574 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700575 * Value for {@link #privateFlags}: When set, the application will only have its splits loaded
Adam Lesinski4e862812016-11-21 16:02:24 -0800576 * if they are required to load a component. Splits can be loaded on demand using the
577 * {@link Context#createContextForSplit(String)} API.
578 * @hide
579 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700580 public static final int PRIVATE_FLAG_ISOLATED_SPLIT_LOADING = 1 << 15;
Adam Lesinski4e862812016-11-21 16:02:24 -0800581
582 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700583 * Value for {@link #privateFlags}: When set, the application was installed as
584 * a virtual preload.
585 * @hide
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800586 */
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700587 public static final int PRIVATE_FLAG_VIRTUAL_PRELOAD = 1 << 16;
588
Svet Ganov087dce22017-09-07 15:42:16 -0700589 /**
590 * Value for {@linl #privateFlags}: whether this app is pre-installed on the
591 * OEM partition of the system image.
592 * @hide
593 */
594 public static final int PRIVATE_FLAG_OEM = 1 << 17;
595
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700596 /** @hide */
597 @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
Svet Ganov087dce22017-09-07 15:42:16 -0700598 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
599 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION,
600 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE,
601 PRIVATE_FLAG_BACKUP_IN_FOREGROUND,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700602 PRIVATE_FLAG_CANT_SAVE_STATE,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700603 PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE,
604 PRIVATE_FLAG_DIRECT_BOOT_AWARE,
Svet Ganov087dce22017-09-07 15:42:16 -0700605 PRIVATE_FLAG_FORWARD_LOCK,
606 PRIVATE_FLAG_HAS_DOMAIN_URLS,
607 PRIVATE_FLAG_HIDDEN,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700608 PRIVATE_FLAG_INSTANT,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700609 PRIVATE_FLAG_ISOLATED_SPLIT_LOADING,
Svet Ganov087dce22017-09-07 15:42:16 -0700610 PRIVATE_FLAG_OEM,
611 PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE,
612 PRIVATE_FLAG_PRIVILEGED,
613 PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER,
614 PRIVATE_FLAG_STATIC_SHARED_LIBRARY,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700615 PRIVATE_FLAG_VIRTUAL_PRELOAD,
616 })
617 @Retention(RetentionPolicy.SOURCE)
618 public @interface ApplicationInfoPrivateFlags {}
619
620 /**
621 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
622 * @hide
623 */
624 public @ApplicationInfoPrivateFlags int privateFlags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800625
626 /**
Clara Bayarri4b5a4d22017-01-27 20:15:45 +0000627 * @hide
628 */
629 public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
630
631 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700632 * The required smallest screen width the application can run on. If 0,
633 * nothing has been specified. Comes from
634 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
635 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
636 */
637 public int requiresSmallestWidthDp = 0;
638
639 /**
640 * The maximum smallest screen width the application is designed for. If 0,
641 * nothing has been specified. Comes from
642 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
643 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
644 */
645 public int compatibleWidthLimitDp = 0;
646
647 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700648 * The maximum smallest screen width the application will work on. If 0,
649 * nothing has been specified. Comes from
650 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
651 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
652 */
653 public int largestWidthLimitDp = 0;
654
Jeff Sharkey61128602017-01-26 17:07:35 -0700655 /**
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700656 * Value indicating the maximum aspect ratio the application supports.
657 * <p>
658 * 0 means unset.
659 * @See {@link android.R.attr#maxAspectRatio}.
660 * @hide
661 */
662 public float maxAspectRatio;
663
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600664 /** @removed */
665 @Deprecated
666 public String volumeUuid;
667
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700668 /**
Jeff Sharkey61128602017-01-26 17:07:35 -0700669 * UUID of the storage volume on which this application is being hosted. For
670 * apps hosted on the default internal storage at
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600671 * {@link Environment#getDataDirectory()}, the UUID value is
672 * {@link StorageManager#UUID_DEFAULT}.
Jeff Sharkey61128602017-01-26 17:07:35 -0700673 */
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600674 public UUID storageUuid;
Jeff Sharkey61128602017-01-26 17:07:35 -0700675
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700676 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700677 public String scanSourceDir;
678 /** {@hide} */
679 public String scanPublicSourceDir;
680
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700681 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700682 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800683 */
684 public String sourceDir;
685
686 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700687 * Full path to the publicly available parts of {@link #sourceDir},
688 * including resources and manifest. This may be different from
689 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800690 */
691 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700692
693 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800694 * The names of all installed split APKs, ordered lexicographically.
695 */
696 public String[] splitNames;
697
698 /**
699 * Full paths to zero or more split APKs, indexed by the same order as {@link #splitNames}.
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700700 */
701 public String[] splitSourceDirs;
702
703 /**
704 * Full path to the publicly available parts of {@link #splitSourceDirs},
705 * including resources and manifest. This may be different from
706 * {@link #splitSourceDirs} if an application is forward locked.
Adam Lesinski4e862812016-11-21 16:02:24 -0800707 *
708 * @see #splitSourceDirs
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700709 */
710 public String[] splitPublicSourceDirs;
711
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800712 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800713 * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
714 *
715 * Available since platform version O.
716 *
717 * Only populated if the application opts in to isolated split loading via the
718 * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
719 * AndroidManifest.xml.
720 *
721 * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
722 * and {@link #splitPublicSourceDirs} arrays.
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800723 * Each key represents a split and its value is an array of splits. The first element of this
724 * array is the parent split, and the rest are configuration splits. These configuration splits
725 * have no dependencies themselves.
Adam Lesinski4e862812016-11-21 16:02:24 -0800726 * Cycles do not exist because they are illegal and screened for during installation.
727 *
728 * May be null if no splits are installed, or if no dependencies exist between them.
Calin Juravleda098152017-09-01 17:30:01 -0700729 *
730 * NOTE: Any change to the way split dependencies are stored must update the logic that
731 * creates the class loader context for dexopt (DexoptUtils#getClassLoaderContexts).
732 *
Adam Lesinski4e862812016-11-21 16:02:24 -0800733 * @hide
734 */
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800735 public SparseArray<int[]> splitDependencies;
Adam Lesinski4e862812016-11-21 16:02:24 -0800736
737 /**
738 * Full paths to the locations of extra resource packages (runtime overlays)
739 * this application uses. This field is only used if there are extra resource
740 * packages, otherwise it is null.
741 *
Kenny Rootace5a3f2010-02-05 12:59:28 -0800742 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800743 */
744 public String[] resourceDirs;
745
746 /**
Robert Craig0f40dc92013-03-25 06:33:03 -0400747 * String retrieved from the seinfo tag found in selinux policy. This value
Robert Craig5e16bc52015-08-28 12:11:41 -0400748 * can be overridden with a value set through the mac_permissions.xml policy
749 * construct. This value is useful in setting an SELinux security context on
750 * the process as well as its data directory. The String default is being used
751 * here to represent a catchall label when no policy matches.
Robert Craig0f40dc92013-03-25 06:33:03 -0400752 *
753 * {@hide}
754 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800755 public String seInfo = "default";
756
757 /**
758 * The seinfo tag generated per-user. This value may change based upon the
759 * user's configuration. For example, when an instant app is installed for
760 * a user. It is an error if this field is ever {@code null} when trying to
761 * start a new process.
762 * <p>NOTE: We need to separate this out because we modify per-user values
763 * multiple times. This needs to be refactored since we're performing more
764 * work than necessary and these values should only be set once. When that
765 * happens, we can merge the per-user value with the seInfo state above.
766 *
767 * {@hide}
768 */
769 public String seInfoUser;
Robert Craig0f40dc92013-03-25 06:33:03 -0400770
771 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800772 * Paths to all shared libraries this application is linked against. This
773 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
774 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
775 * the structure.
776 */
777 public String[] sharedLibraryFiles;
778
779 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700780 * Full path to the default directory assigned to the package for its
781 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800782 */
783 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700784
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700785 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600786 * Full path to the device-protected directory assigned to the package for
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700787 * its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600788 *
789 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700790 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600791 public String deviceProtectedDataDir;
792
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700793 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600794 * Full path to the credential-protected directory assigned to the package
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700795 * for its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600796 *
797 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700798 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600799 @SystemApi
800 public String credentialProtectedDataDir;
801
Kenny Root85387d72010-08-26 10:13:11 -0700802 /**
803 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700804 */
805 public String nativeLibraryDir;
806
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800807 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100808 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
809 * are stored, if present.
810 *
811 * The main reason this exists is for bundled multi-arch apps, where
812 * it's not trivial to calculate the location of libs for the secondary abi
813 * given the location of the primary.
814 *
815 * TODO: Change the layout of bundled installs so that we can use
816 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
817 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
818 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
819 *
820 * @hide
821 */
822 public String secondaryNativeLibraryDir;
823
824 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700825 * The root path where unpacked native libraries are stored.
826 * <p>
827 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
828 * placed in ISA-specific subdirectories under this path, otherwise the
829 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100830 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700831 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100832 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700833 public String nativeLibraryRootDir;
834
835 /**
836 * Flag indicating that ISA must be appended to
837 * {@link #nativeLibraryRootDir} to be useful.
838 *
839 * @hide
840 */
841 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100842
843 /**
844 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100845 * of the native JNI libraries the application bundles. Will be {@code null}
846 * if this application does not require any particular ABI.
847 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100848 * If non-null, the application will always be launched with this ABI.
849 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100850 * {@hide}
851 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100852 public String primaryCpuAbi;
853
854 /**
855 * The secondary ABI for this application. Might be non-null for multi-arch
856 * installs. The application itself never uses this ABI, but other applications that
857 * use its code might.
858 *
859 * {@hide}
860 */
861 public String secondaryCpuAbi;
862
863 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800864 * The kernel user-ID that has been assigned to this application;
865 * currently this is not a unique ID (multiple applications can have
866 * the same uid).
867 */
868 public int uid;
869
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700870 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800871 * The minimum SDK version this application can run on. It will not run
872 * on earlier versions.
873 */
Todd Kennedy6e2e7f52016-05-02 14:56:45 -0700874 public int minSdkVersion;
Todd Kennedy89d60182016-03-11 11:18:32 -0800875
876 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700877 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700878 * versions, but it knows how to work with any new behavior added at this
879 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
880 * if this is a development build and the app is targeting that. You should
881 * compare that this number is >= the SDK version number at which your
882 * behavior was introduced.
883 */
884 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800885
886 /**
887 * The app's declared version code.
888 * @hide
889 */
890 public int versionCode;
891
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700892 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800893 * When false, indicates that all components within this application are
894 * considered disabled, regardless of their individually set enabled status.
895 */
896 public boolean enabled = true;
897
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700898 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700899 * For convenient access to the current enabled setting of this app.
900 * @hide
901 */
902 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
903
904 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700905 * For convenient access to package's install location.
906 * @hide
907 */
908 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700909
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700910 /**
911 * Resource file providing the application's Network Security Config.
912 * @hide
913 */
914 public int networkSecurityConfigRes;
915
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700916 /**
Todd Kennedy11e45072017-01-25 13:24:21 -0800917 * Version of the sandbox the application wants to run in.
918 * @hide
919 */
920 public int targetSandboxVersion;
921
922 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700923 * The category of this app. Categories are used to cluster multiple apps
924 * together into meaningful groups, such as when summarizing battery,
925 * network, or disk usage. Apps should only define this value when they fit
926 * well into one of the specific categories.
927 * <p>
928 * Set from the {@link android.R.attr#appCategory} attribute in the
929 * manifest. If the manifest doesn't define a category, this value may have
930 * been provided by the installer via
931 * {@link PackageManager#setApplicationCategoryHint(String, int)}.
932 */
933 public @Category int category = CATEGORY_UNDEFINED;
934
935 /** {@hide} */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600936 @IntDef(prefix = { "CATEGORY_" }, value = {
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700937 CATEGORY_UNDEFINED,
938 CATEGORY_GAME,
939 CATEGORY_AUDIO,
940 CATEGORY_VIDEO,
941 CATEGORY_IMAGE,
942 CATEGORY_SOCIAL,
943 CATEGORY_NEWS,
944 CATEGORY_MAPS,
945 CATEGORY_PRODUCTIVITY
946 })
947 @Retention(RetentionPolicy.SOURCE)
948 public @interface Category {
949 }
950
951 /**
952 * Value when category is undefined.
953 *
954 * @see #category
955 */
956 public static final int CATEGORY_UNDEFINED = -1;
957
958 /**
959 * Category for apps which are primarily games.
960 *
961 * @see #category
962 */
963 public static final int CATEGORY_GAME = 0;
964
965 /**
966 * Category for apps which primarily work with audio or music, such as music
967 * players.
968 *
969 * @see #category
970 */
971 public static final int CATEGORY_AUDIO = 1;
972
973 /**
974 * Category for apps which primarily work with video or movies, such as
975 * streaming video apps.
976 *
977 * @see #category
978 */
979 public static final int CATEGORY_VIDEO = 2;
980
981 /**
982 * Category for apps which primarily work with images or photos, such as
983 * camera or gallery apps.
984 *
985 * @see #category
986 */
987 public static final int CATEGORY_IMAGE = 3;
988
989 /**
990 * Category for apps which are primarily social apps, such as messaging,
Jeff Sharkeyd2b69102017-03-21 19:40:38 -0600991 * communication, email, or social network apps.
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700992 *
993 * @see #category
994 */
995 public static final int CATEGORY_SOCIAL = 4;
996
997 /**
998 * Category for apps which are primarily news apps, such as newspapers,
999 * magazines, or sports apps.
1000 *
1001 * @see #category
1002 */
1003 public static final int CATEGORY_NEWS = 5;
1004
1005 /**
1006 * Category for apps which are primarily maps apps, such as navigation apps.
1007 *
1008 * @see #category
1009 */
1010 public static final int CATEGORY_MAPS = 6;
1011
1012 /**
1013 * Category for apps which are primarily productivity apps, such as cloud
1014 * storage or workplace apps.
1015 *
1016 * @see #category
1017 */
1018 public static final int CATEGORY_PRODUCTIVITY = 7;
1019
1020 /**
1021 * Return a concise, localized title for the given
1022 * {@link ApplicationInfo#category} value, or {@code null} for unknown
1023 * values such as {@link #CATEGORY_UNDEFINED}.
1024 *
1025 * @see #category
1026 */
1027 public static CharSequence getCategoryTitle(Context context, @Category int category) {
1028 switch (category) {
1029 case ApplicationInfo.CATEGORY_GAME:
1030 return context.getText(com.android.internal.R.string.app_category_game);
1031 case ApplicationInfo.CATEGORY_AUDIO:
1032 return context.getText(com.android.internal.R.string.app_category_audio);
1033 case ApplicationInfo.CATEGORY_VIDEO:
1034 return context.getText(com.android.internal.R.string.app_category_video);
1035 case ApplicationInfo.CATEGORY_IMAGE:
1036 return context.getText(com.android.internal.R.string.app_category_image);
1037 case ApplicationInfo.CATEGORY_SOCIAL:
1038 return context.getText(com.android.internal.R.string.app_category_social);
1039 case ApplicationInfo.CATEGORY_NEWS:
1040 return context.getText(com.android.internal.R.string.app_category_news);
1041 case ApplicationInfo.CATEGORY_MAPS:
1042 return context.getText(com.android.internal.R.string.app_category_maps);
1043 case ApplicationInfo.CATEGORY_PRODUCTIVITY:
1044 return context.getText(com.android.internal.R.string.app_category_productivity);
1045 default:
1046 return null;
1047 }
1048 }
1049
Narayan Kamathf9419f02017-06-15 11:35:38 +01001050 /** @hide */
1051 public String classLoaderName;
1052
1053 /** @hide */
1054 public String[] splitClassLoaderNames;
1055
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001056 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001057 dump(pw, prefix, DUMP_FLAG_ALL);
1058 }
1059
1060 /** @hide */
Yohei Yukawa8f272172017-08-31 00:26:01 -07001061 public void dump(Printer pw, String prefix, int dumpFlags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001062 super.dumpFront(pw, prefix);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001063 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -08001064 pw.println(prefix + "className=" + className);
1065 }
1066 if (permission != null) {
1067 pw.println(prefix + "permission=" + permission);
1068 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001069 pw.println(prefix + "processName=" + processName);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001070 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001071 pw.println(prefix + "taskAffinity=" + taskAffinity);
1072 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001073 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001074 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -07001075 + " theme=0x" + Integer.toHexString(theme));
Yohei Yukawa8f272172017-08-31 00:26:01 -07001076 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001077 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1078 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1079 + " largestWidthLimitDp=" + largestWidthLimitDp);
1080 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001081 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001082 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -07001083 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1084 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001085 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1086 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1087 }
1088 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1089 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1090 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1091 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001092 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -08001093 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -07001094 }
Yohei Yukawa8f272172017-08-31 00:26:01 -07001095 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
Todd Kennedybe0b8892017-02-15 14:13:52 -08001096 pw.println(prefix + "seinfo=" + seInfo);
1097 pw.println(prefix + "seinfoUser=" + seInfoUser);
Robert Craig0f40dc92013-03-25 06:33:03 -04001098 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001099 pw.println(prefix + "dataDir=" + dataDir);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001100 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001101 pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1102 pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001103 if (sharedLibraryFiles != null) {
1104 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1105 }
Dianne Hackborn12527f92009-11-11 17:39:50 -08001106 }
Narayan Kamathf9419f02017-06-15 11:35:38 +01001107 if (classLoaderName != null) {
1108 pw.println(prefix + "classLoaderName=" + classLoaderName);
1109 }
1110 if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1111 pw.println(prefix + "splitClassLoaderNames=" + Arrays.toString(splitClassLoaderNames));
1112 }
1113
Todd Kennedy89d60182016-03-11 11:18:32 -08001114 pw.println(prefix + "enabled=" + enabled
1115 + " minSdkVersion=" + minSdkVersion
1116 + " targetSdkVersion=" + targetSdkVersion
Todd Kennedy11e45072017-01-25 13:24:21 -08001117 + " versionCode=" + versionCode
1118 + " targetSandboxVersion=" + targetSandboxVersion);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001119 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001120 if (manageSpaceActivityName != null) {
1121 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1122 }
1123 if (descriptionRes != 0) {
1124 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1125 }
1126 if (uiOptions != 0) {
1127 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1128 }
1129 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1130 if (fullBackupContent > 0) {
1131 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1132 } else {
1133 pw.println(prefix + "fullBackupContent="
1134 + (fullBackupContent < 0 ? "false" : "true"));
1135 }
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001136 if (networkSecurityConfigRes != 0) {
1137 pw.println(prefix + "networkSecurityConfigRes=0x"
1138 + Integer.toHexString(networkSecurityConfigRes));
1139 }
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001140 if (category != CATEGORY_UNDEFINED) {
1141 pw.println(prefix + "category=" + category);
1142 }
Matthew Williams303650c2015-04-17 18:22:51 -07001143 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001144 super.dumpBack(pw, prefix);
1145 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001146
1147 /**
1148 * @return true if "supportsRtl" has been set to true in the AndroidManifest
1149 * @hide
1150 */
1151 public boolean hasRtlSupport() {
1152 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1153 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -07001154
1155 /** {@hide} */
1156 public boolean hasCode() {
1157 return (flags & FLAG_HAS_CODE) != 0;
1158 }
1159
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001160 public static class DisplayNameComparator
1161 implements Comparator<ApplicationInfo> {
1162 public DisplayNameComparator(PackageManager pm) {
1163 mPM = pm;
1164 }
1165
1166 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1167 CharSequence sa = mPM.getApplicationLabel(aa);
1168 if (sa == null) {
1169 sa = aa.packageName;
1170 }
1171 CharSequence sb = mPM.getApplicationLabel(ab);
1172 if (sb == null) {
1173 sb = ab.packageName;
1174 }
1175
1176 return sCollator.compare(sa.toString(), sb.toString());
1177 }
1178
1179 private final Collator sCollator = Collator.getInstance();
1180 private PackageManager mPM;
1181 }
1182
1183 public ApplicationInfo() {
1184 }
1185
1186 public ApplicationInfo(ApplicationInfo orig) {
1187 super(orig);
1188 taskAffinity = orig.taskAffinity;
1189 permission = orig.permission;
1190 processName = orig.processName;
1191 className = orig.className;
1192 theme = orig.theme;
1193 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001194 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001195 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1196 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001197 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001198 volumeUuid = orig.volumeUuid;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -06001199 storageUuid = orig.storageUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001200 scanSourceDir = orig.scanSourceDir;
1201 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001202 sourceDir = orig.sourceDir;
1203 publicSourceDir = orig.publicSourceDir;
Adam Lesinski4e862812016-11-21 16:02:24 -08001204 splitNames = orig.splitNames;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001205 splitSourceDirs = orig.splitSourceDirs;
1206 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Adam Lesinski4e862812016-11-21 16:02:24 -08001207 splitDependencies = orig.splitDependencies;
Kenny Root85387d72010-08-26 10:13:11 -07001208 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001209 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -07001210 nativeLibraryRootDir = orig.nativeLibraryRootDir;
1211 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001212 primaryCpuAbi = orig.primaryCpuAbi;
1213 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -08001214 resourceDirs = orig.resourceDirs;
Todd Kennedybe0b8892017-02-15 14:13:52 -08001215 seInfo = orig.seInfo;
1216 seInfoUser = orig.seInfoUser;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001217 sharedLibraryFiles = orig.sharedLibraryFiles;
1218 dataDir = orig.dataDir;
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001219 deviceProtectedDataDir = orig.deviceProtectedDataDir;
1220 credentialProtectedDataDir = orig.credentialProtectedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001221 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -08001222 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001223 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -08001224 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001225 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001226 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001227 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001228 manageSpaceActivityName = orig.manageSpaceActivityName;
1229 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -07001230 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -07001231 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -07001232 fullBackupContent = orig.fullBackupContent;
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001233 networkSecurityConfigRes = orig.networkSecurityConfigRes;
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001234 category = orig.category;
Todd Kennedy11e45072017-01-25 13:24:21 -08001235 targetSandboxVersion = orig.targetSandboxVersion;
Narayan Kamathf9419f02017-06-15 11:35:38 +01001236 classLoaderName = orig.classLoaderName;
1237 splitClassLoaderNames = orig.splitClassLoaderNames;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001238 }
1239
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001240 public String toString() {
1241 return "ApplicationInfo{"
1242 + Integer.toHexString(System.identityHashCode(this))
1243 + " " + packageName + "}";
1244 }
1245
1246 public int describeContents() {
1247 return 0;
1248 }
1249
Adam Lesinski4e862812016-11-21 16:02:24 -08001250 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001251 public void writeToParcel(Parcel dest, int parcelableFlags) {
1252 super.writeToParcel(dest, parcelableFlags);
1253 dest.writeString(taskAffinity);
1254 dest.writeString(permission);
1255 dest.writeString(processName);
1256 dest.writeString(className);
1257 dest.writeInt(theme);
1258 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001259 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001260 dest.writeInt(requiresSmallestWidthDp);
1261 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001262 dest.writeInt(largestWidthLimitDp);
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001263 if (storageUuid != null) {
1264 dest.writeInt(1);
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001265 dest.writeLong(storageUuid.getMostSignificantBits());
1266 dest.writeLong(storageUuid.getLeastSignificantBits());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001267 } else {
1268 dest.writeInt(0);
1269 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001270 dest.writeString(scanSourceDir);
1271 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001272 dest.writeString(sourceDir);
1273 dest.writeString(publicSourceDir);
Adam Lesinski4e862812016-11-21 16:02:24 -08001274 dest.writeStringArray(splitNames);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001275 dest.writeStringArray(splitSourceDirs);
1276 dest.writeStringArray(splitPublicSourceDirs);
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001277 dest.writeSparseArray((SparseArray) splitDependencies);
Kenny Root85387d72010-08-26 10:13:11 -07001278 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001279 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -07001280 dest.writeString(nativeLibraryRootDir);
1281 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +01001282 dest.writeString(primaryCpuAbi);
1283 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -08001284 dest.writeStringArray(resourceDirs);
Todd Kennedybe0b8892017-02-15 14:13:52 -08001285 dest.writeString(seInfo);
1286 dest.writeString(seInfoUser);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001287 dest.writeStringArray(sharedLibraryFiles);
1288 dest.writeString(dataDir);
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001289 dest.writeString(deviceProtectedDataDir);
1290 dest.writeString(credentialProtectedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001291 dest.writeInt(uid);
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001292 dest.writeInt(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001293 dest.writeInt(targetSdkVersion);
Dianne Hackborn8472e612014-01-23 17:57:20 -08001294 dest.writeInt(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001295 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001296 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001297 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001298 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -07001299 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001300 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -07001301 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -07001302 dest.writeInt(fullBackupContent);
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001303 dest.writeInt(networkSecurityConfigRes);
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001304 dest.writeInt(category);
Todd Kennedy11e45072017-01-25 13:24:21 -08001305 dest.writeInt(targetSandboxVersion);
Narayan Kamathf9419f02017-06-15 11:35:38 +01001306 dest.writeString(classLoaderName);
1307 dest.writeStringArray(splitClassLoaderNames);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001308 }
1309
1310 public static final Parcelable.Creator<ApplicationInfo> CREATOR
1311 = new Parcelable.Creator<ApplicationInfo>() {
1312 public ApplicationInfo createFromParcel(Parcel source) {
1313 return new ApplicationInfo(source);
1314 }
1315 public ApplicationInfo[] newArray(int size) {
1316 return new ApplicationInfo[size];
1317 }
1318 };
1319
Adam Lesinski4e862812016-11-21 16:02:24 -08001320 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001321 private ApplicationInfo(Parcel source) {
1322 super(source);
1323 taskAffinity = source.readString();
1324 permission = source.readString();
1325 processName = source.readString();
1326 className = source.readString();
1327 theme = source.readInt();
1328 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001329 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001330 requiresSmallestWidthDp = source.readInt();
1331 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001332 largestWidthLimitDp = source.readInt();
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001333 if (source.readInt() != 0) {
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001334 storageUuid = new UUID(source.readLong(), source.readLong());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001335 volumeUuid = StorageManager.convert(storageUuid);
1336 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001337 scanSourceDir = source.readString();
1338 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001339 sourceDir = source.readString();
1340 publicSourceDir = source.readString();
Adam Lesinski4e862812016-11-21 16:02:24 -08001341 splitNames = source.readStringArray();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001342 splitSourceDirs = source.readStringArray();
1343 splitPublicSourceDirs = source.readStringArray();
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001344 splitDependencies = source.readSparseArray(null);
Kenny Root85387d72010-08-26 10:13:11 -07001345 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001346 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -07001347 nativeLibraryRootDir = source.readString();
1348 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001349 primaryCpuAbi = source.readString();
1350 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -08001351 resourceDirs = source.readStringArray();
Todd Kennedybe0b8892017-02-15 14:13:52 -08001352 seInfo = source.readString();
1353 seInfoUser = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001354 sharedLibraryFiles = source.readStringArray();
1355 dataDir = source.readString();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001356 deviceProtectedDataDir = source.readString();
1357 credentialProtectedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001358 uid = source.readInt();
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001359 minSdkVersion = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001360 targetSdkVersion = source.readInt();
Dianne Hackborn8472e612014-01-23 17:57:20 -08001361 versionCode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001362 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001363 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001364 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001365 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001366 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001367 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001368 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001369 fullBackupContent = source.readInt();
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001370 networkSecurityConfigRes = source.readInt();
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001371 category = source.readInt();
Todd Kennedy11e45072017-01-25 13:24:21 -08001372 targetSandboxVersion = source.readInt();
Narayan Kamathf9419f02017-06-15 11:35:38 +01001373 classLoaderName = source.readString();
1374 splitClassLoaderNames = source.readStringArray();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001375 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001376
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001377 /**
1378 * Retrieve the textual description of the application. This
1379 * will call back on the given PackageManager to load the description from
1380 * the application.
1381 *
1382 * @param pm A PackageManager from which the label can be loaded; usually
1383 * the PackageManager from which you originally retrieved this item.
1384 *
1385 * @return Returns a CharSequence containing the application's description.
1386 * If there is no description, null is returned.
1387 */
1388 public CharSequence loadDescription(PackageManager pm) {
1389 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001390 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001391 if (label != null) {
1392 return label;
1393 }
1394 }
1395 return null;
1396 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001397
1398 /**
1399 * Disable compatibility mode
1400 *
1401 * @hide
1402 */
1403 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001404 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001405 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001406 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001407 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001408
skuhne@google.com7e85eb02017-01-04 13:49:54 -08001409 /**
1410 * Is using compatibility mode for non densty aware legacy applications.
1411 *
1412 * @hide
1413 */
1414 public boolean usesCompatibilityMode() {
1415 return targetSdkVersion < DONUT ||
1416 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1417 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1418 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1419 }
1420
Jeff Sharkey15447792015-11-05 16:18:51 -08001421 /** {@hide} */
1422 public void initForUser(int userId) {
1423 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1424
1425 if ("android".equals(packageName)) {
1426 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1427 return;
1428 }
1429
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001430 deviceProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001431 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001432 .getAbsolutePath();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001433 credentialProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001434 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001435 .getAbsolutePath();
1436
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001437 if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1438 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1439 dataDir = deviceProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001440 } else {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001441 dataDir = credentialProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001442 }
1443 }
1444
Jeff Brown07330792010-03-30 19:57:08 -07001445 /**
1446 * @hide
1447 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001448 @Override
1449 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001450 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1451 && isPackageUnavailable(pm)) {
1452 return Resources.getSystem().getDrawable(
1453 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1454 }
1455 return pm.getDefaultActivityIcon();
1456 }
1457
1458 private boolean isPackageUnavailable(PackageManager pm) {
1459 try {
1460 return pm.getPackageInfo(packageName, 0) == null;
1461 } catch (NameNotFoundException ex) {
1462 return true;
1463 }
1464 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001465
Jeff Brown07330792010-03-30 19:57:08 -07001466 /**
1467 * @hide
1468 */
Fyodor Kupoloveeea67b2015-02-23 17:14:45 -08001469 public boolean isForwardLocked() {
1470 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1471 }
1472
1473 /**
1474 * @hide
1475 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001476 @TestApi
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001477 public boolean isSystemApp() {
1478 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1479 }
1480
1481 /**
1482 * @hide
1483 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001484 @TestApi
Svet Ganovadc1cf42015-06-15 16:36:24 -07001485 public boolean isPrivilegedApp() {
1486 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1487 }
1488
1489 /**
1490 * @hide
1491 */
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001492 public boolean isUpdatedSystemApp() {
1493 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1494 }
1495
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07001496 /** @hide */
1497 public boolean isInternal() {
1498 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1499 }
1500
1501 /** @hide */
1502 public boolean isExternalAsec() {
1503 return TextUtils.isEmpty(volumeUuid)
1504 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1505 }
1506
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001507 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001508 public boolean isDefaultToDeviceProtectedStorage() {
1509 return (privateFlags
1510 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
Jeff Sharkeye4697132016-02-06 19:46:15 -07001511 }
1512
1513 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001514 public boolean isDirectBootAware() {
1515 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001516 }
1517
Jeff Sharkey8924e872015-11-30 12:52:10 -07001518 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001519 public boolean isPartiallyDirectBootAware() {
1520 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkey8924e872015-11-30 12:52:10 -07001521 }
1522
Bryce Lee8558ec72017-08-17 15:37:26 -07001523 /** @hide */
1524 public boolean isEncryptionAware() {
1525 return isDirectBootAware() || isPartiallyDirectBootAware();
1526 }
1527
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001528 /**
1529 * @hide
1530 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08001531 public boolean isInstantApp() {
Todd Kennedybe0b8892017-02-15 14:13:52 -08001532 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
Svet Ganov2acf0632015-11-24 19:10:59 -08001533 }
1534
1535 /**
1536 * @hide
1537 */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001538 public boolean isRequiredForSystemUser() {
1539 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1540 }
1541
1542 /**
Adam Lesinski4e862812016-11-21 16:02:24 -08001543 * Returns true if the app has declared in its manifest that it wants its split APKs to be
1544 * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
1545 * @hide
1546 */
1547 public boolean requestsIsolatedSplitLoading() {
1548 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
1549 }
1550
1551 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001552 * @hide
1553 */
Svet Ganov67882122016-12-11 16:36:34 -08001554 public boolean isStaticSharedLibrary() {
1555 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
1556 }
1557
1558 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -07001559 * Returns whether or not this application was installed as a virtual preload.
1560 */
1561 public boolean isVirtualPreload() {
1562 return (privateFlags & PRIVATE_FLAG_VIRTUAL_PRELOAD) != 0;
1563 }
1564
1565 /**
Svet Ganov67882122016-12-11 16:36:34 -08001566 * @hide
1567 */
Svet Ganov087dce22017-09-07 15:42:16 -07001568 public boolean isOem() {
1569 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
1570 }
1571
1572 /**
1573 * @hide
1574 */
Jeff Brown07330792010-03-30 19:57:08 -07001575 @Override protected ApplicationInfo getApplicationInfo() {
1576 return this;
1577 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001578
1579 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1580 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1581 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1582 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1583 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1584 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1585
1586 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1587 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1588 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1589 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1590 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
Jeff Sharkeya3a43b02016-11-15 17:54:23 -07001591 /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001592}