blob: edb27cd4ecf1a5a468475a408783ecc130b762b8 [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;
Alan Viveretteb6a25732017-11-21 14:49:24 -050022import android.annotation.Nullable;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060023import android.annotation.SystemApi;
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -070024import android.annotation.TestApi;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060025import android.content.Context;
Jeff Brown07330792010-03-30 19:57:08 -070026import android.content.pm.PackageManager.NameNotFoundException;
27import android.content.res.Resources;
28import android.graphics.drawable.Drawable;
Jeff Sharkey15447792015-11-05 16:18:51 -080029import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.os.Parcel;
31import android.os.Parcelable;
Jeff Sharkey15447792015-11-05 16:18:51 -080032import android.os.UserHandle;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060033import android.os.storage.StorageManager;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070034import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035import android.util.Printer;
Adam Lesinski1665d0f2017-03-10 14:46:57 -080036import android.util.SparseArray;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070038import com.android.internal.util.ArrayUtils;
39
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070040import java.lang.annotation.Retention;
41import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070043import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070045import java.util.Objects;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060046import java.util.UUID;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047
48/**
49 * Information you can retrieve about a particular application. This
50 * corresponds to information collected from the AndroidManifest.xml's
51 * <application> tag.
52 */
53public class ApplicationInfo extends PackageItemInfo implements Parcelable {
54
55 /**
56 * Default task affinity of all activities in this application. See
57 * {@link ActivityInfo#taskAffinity} for more information. This comes
58 * from the "taskAffinity" attribute.
59 */
60 public String taskAffinity;
61
62 /**
63 * Optional name of a permission required to be able to access this
64 * application's components. From the "permission" attribute.
65 */
66 public String permission;
67
68 /**
69 * The name of the process this application should run in. From the
70 * "process" attribute or, if not set, the same as
71 * <var>packageName</var>.
72 */
73 public String processName;
74
75 /**
76 * Class implementing the Application object. From the "class"
77 * attribute.
78 */
79 public String className;
80
81 /**
82 * A style resource identifier (in the package's resources) of the
83 * description of an application. From the "description" attribute
84 * or, if not set, 0.
85 */
86 public int descriptionRes;
87
88 /**
89 * A style resource identifier (in the package's resources) of the
90 * default visual theme of the application. From the "theme" attribute
91 * or, if not set, 0.
92 */
93 public int theme;
94
95 /**
96 * Class implementing the Application's manage space
97 * functionality. From the "manageSpaceActivity"
98 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -070099 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100 */
101 public String manageSpaceActivityName;
102
103 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700104 * Class implementing the Application's backup functionality. From
105 * the "backupAgent" attribute. This is an optional attribute and
106 * will be null if the application does not specify it in its manifest.
107 *
108 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -0700109 */
110 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700111
112 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700113 * An optional attribute that indicates the app supports automatic backup of app data.
114 * <p>0 is the default and means the app's entire data folder + managed external storage will
115 * be backed up;
116 * Any negative value indicates the app does not support full-data backup, though it may still
117 * want to participate via the traditional key/value backup API;
118 * A positive number specifies an xml resource in which the application has defined its backup
119 * include/exclude criteria.
120 * <p>If android:allowBackup is set to false, this attribute is ignored.
121 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600122 * @see android.content.Context#getNoBackupFilesDir()
123 * @see #FLAG_ALLOW_BACKUP
Christopher Tate98fa6562015-05-14 13:20:10 -0700124 *
125 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700126 */
127 public int fullBackupContent = 0;
128
129 /**
Adam Powell269248d2011-08-02 10:26:54 -0700130 * The default extra UI options for activities in this application.
131 * Set from the {@link android.R.attr#uiOptions} attribute in the
132 * activity's manifest.
133 */
134 public int uiOptions = 0;
135
136 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137 * Value for {@link #flags}: if set, this application is installed in the
138 * device's system image.
139 */
140 public static final int FLAG_SYSTEM = 1<<0;
141
142 /**
143 * Value for {@link #flags}: set to true if this application would like to
144 * allow debugging of its
145 * code, even when installed on a non-development system. Comes
146 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
147 * android:debuggable} of the &lt;application&gt; tag.
148 */
149 public static final int FLAG_DEBUGGABLE = 1<<1;
150
151 /**
152 * Value for {@link #flags}: set to true if this application has code
153 * associated with it. Comes
154 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
155 * android:hasCode} of the &lt;application&gt; tag.
156 */
157 public static final int FLAG_HAS_CODE = 1<<2;
158
159 /**
160 * Value for {@link #flags}: set to true if this application is persistent.
161 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
162 * android:persistent} of the &lt;application&gt; tag.
163 */
164 public static final int FLAG_PERSISTENT = 1<<3;
165
166 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700167 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800168 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
169 * device is running in factory test mode.
170 */
171 public static final int FLAG_FACTORY_TEST = 1<<4;
172
173 /**
174 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
175 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
176 * android:allowTaskReparenting} of the &lt;application&gt; tag.
177 */
178 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
179
180 /**
181 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
182 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
183 * android:allowClearUserData} of the &lt;application&gt; tag.
184 */
185 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
186
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700188 * Value for {@link #flags}: this is set if this application has been
Kweku Adams8de29ca2016-01-22 12:30:26 -0800189 * installed as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800190 */
191 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700192
193 /**
Svet Ganov354cd3c2015-12-17 11:35:04 -0800194 * Value for {@link #flags}: this is set if the application has specified
Dianne Hackborn7f205432009-07-28 00:13:47 -0700195 * {@link android.R.styleable#AndroidManifestApplication_testOnly
196 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700197 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700198 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700199
200 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700201 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700202 * reduced in size for smaller screens. Corresponds to
203 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
204 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700205 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700206 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
207
208 /**
209 * Value for {@link #flags}: true when the application's window can be
210 * displayed on normal screens. Corresponds to
211 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
212 * android:normalScreens}.
213 */
214 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
215
216 /**
217 * Value for {@link #flags}: true when the application's window can be
218 * increased in size for larger screens. Corresponds to
219 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700220 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700221 */
222 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700223
224 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700225 * Value for {@link #flags}: true when the application knows how to adjust
226 * its UI for different screen sizes. Corresponds to
227 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
228 * android:resizeable}.
229 */
230 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
231
232 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700233 * Value for {@link #flags}: true when the application knows how to
234 * accomodate different screen densities. Corresponds to
235 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
236 * android:anyDensity}.
237 */
238 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
239
240 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800241 * Value for {@link #flags}: set to true if this application would like to
242 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700243 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
244 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800245 */
246 public static final int FLAG_VM_SAFE_MODE = 1<<14;
247
248 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800249 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
250 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700251 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800252 * <p>Comes from the
253 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
254 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700255 */
Ben Cheng23085b72010-02-08 16:06:32 -0800256 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700257
258 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800259 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
260 * in memory following a full-system restore operation; <code>true</code> otherwise.
261 * Ordinarily, during a full system restore operation each application is shut down
262 * following execution of its agent's onRestore() method. Setting this attribute to
263 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700264 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800265 * <p>If
266 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
267 * is set to <code>false</code> or no
268 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700269 * is specified, this flag will be ignored.
270 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800271 * <p>Comes from the
272 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
273 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700274 */
Ben Cheng23085b72010-02-08 16:06:32 -0800275 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700276
277 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800278 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
279 * agent claims to be able to handle restore data even "from the future,"
280 * i.e. from versions of the application with a versionCode greater than
281 * the one currently installed on the device. <i>Use with caution!</i> By default
282 * this attribute is <code>false</code> and the Backup Manager will ensure that data
283 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700284 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800285 * <p>If
286 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
287 * is set to <code>false</code> or no
288 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700289 * is specified, this flag will be ignored.
290 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800291 * <p>Comes from the
292 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
293 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700294 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800295 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700296
Christopher Tate181fafa2009-05-14 11:12:14 -0700297 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700298 * Value for {@link #flags}: Set to true if the application is
299 * currently installed on external/removable/unprotected storage. Such
300 * applications may not be available if their storage is not currently
301 * mounted. When the storage it is on is not available, it will look like
302 * the application has been uninstalled (its .apk is no longer available)
303 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800304 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700305 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800306
307 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700308 * Value for {@link #flags}: true when the application's window can be
309 * increased in size for extra large screens. Corresponds to
310 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700311 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700312 */
313 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
314
315 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800316 * Value for {@link #flags}: true when the application has requested a
317 * large heap for its processes. Corresponds to
318 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
319 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600320 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800321 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600322
323 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800324 * Value for {@link #flags}: true if this application's package is in
325 * the stopped state.
326 */
327 public static final int FLAG_STOPPED = 1<<21;
328
329 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700330 * Value for {@link #flags}: true when the application is willing to support
331 * RTL (right to left). All activities will inherit this value.
332 *
333 * Set from the {@link android.R.attr#supportsRtl} attribute in the
334 * activity's manifest.
335 *
336 * Default value is false (no support for RTL).
337 */
338 public static final int FLAG_SUPPORTS_RTL = 1<<22;
339
340 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700341 * Value for {@link #flags}: true if the application is currently
342 * installed for the calling user.
343 */
344 public static final int FLAG_INSTALLED = 1<<23;
345
346 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700347 * Value for {@link #flags}: true if the application only has its
348 * data installed; the application package itself does not currently
349 * exist on the device.
350 */
351 public static final int FLAG_IS_DATA_ONLY = 1<<24;
352
353 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700354 * Value for {@link #flags}: true if the application was declared to be a
355 * game, or false if it is a non-game application.
356 *
357 * @deprecated use {@link #CATEGORY_GAME} instead.
Jose Lima12d0b4c2014-03-14 16:55:12 -0700358 */
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700359 @Deprecated
Jose Lima12d0b4c2014-03-14 16:55:12 -0700360 public static final int FLAG_IS_GAME = 1<<25;
361
362 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700363 * Value for {@link #flags}: {@code true} if the application asks that only
364 * full-data streaming backups of its data be performed even though it defines
365 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
366 * indicates that the app will manage its backed-up data via incremental
367 * key/value updates.
368 */
369 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
370
371 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700372 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
373 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
374 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
375 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700376 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
377 * traffic. Third-party libraries are encouraged to honor this flag as well.
378 *
Nate Fischer6a2a5412017-10-23 18:02:41 -0700379 * <p>NOTE: {@code WebView} honors this flag for applications targeting API level 26 and up.
Alex Klyubinfbf45992015-04-21 13:44:29 -0700380 *
Chad Brubaker2df5ba72016-04-11 13:31:24 -0700381 * <p>This flag is ignored on Android N and above if an Android Network Security Config is
382 * present.
383 *
Alex Klyubinfbf45992015-04-21 13:44:29 -0700384 * <p>This flag comes from
385 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
386 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700387 */
388 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
389
390 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700391 * When set installer extracts native libs from .apk files.
392 */
393 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
394
395 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700396 * Value for {@link #flags}: {@code true} when the application's rendering
397 * should be hardware accelerated.
398 */
399 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
400
401 /**
Andrei Stingaceanu1e283912015-11-26 15:26:28 +0000402 * Value for {@link #flags}: true if this application's package is in
403 * the suspended state.
404 */
405 public static final int FLAG_SUSPENDED = 1<<30;
406
407 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100408 * Value for {@link #flags}: true if code from this application will need to be
409 * loaded into other applications' processes. On devices that support multiple
410 * instruction sets, this implies the code might be loaded into a process that's
411 * using any of the devices supported instruction sets.
412 *
413 * <p> The system might treat such applications specially, for eg., by
414 * extracting the application's native libraries for all supported instruction
415 * sets or by compiling the application's dex code for all supported instruction
416 * sets.
417 */
418 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700419
420 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800421 * Flags associated with the application. Any combination of
422 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
423 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
424 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700425 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700426 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
427 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700428 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
429 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700430 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800431 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
432 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
433 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
434 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
435 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700436 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
437 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 */
439 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700440
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800441 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800442 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
443 * most purposes is considered as not installed.
444 * {@hide}
445 */
446 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
447
448 /**
449 * Value for {@link #privateFlags}: set to <code>true</code> if the application
450 * has reported that it is heavy-weight, and thus can not participate in
451 * the normal application lifecycle.
452 *
453 * <p>Comes from the
454 * android.R.styleable#AndroidManifestApplication_cantSaveState
455 * attribute of the &lt;application&gt; tag.
456 *
457 * {@hide}
458 */
459 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
460
461 /**
462 * Value for {@link #privateFlags}: Set to true if the application has been
463 * installed using the forward lock option.
464 *
465 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
466 *
467 * {@hide}
468 */
469 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
470
471 /**
472 * Value for {@link #privateFlags}: set to {@code true} if the application
473 * is permitted to hold privileged permissions.
474 *
475 * {@hide}
476 */
477 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
478
479 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800480 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
481 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700482 *
483 * {@hide}
484 */
485 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
486
487 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600488 * When set, the default data storage directory for this app is pointed at
489 * the device-protected location.
Jeff Sharkey15447792015-11-05 16:18:51 -0800490 *
491 * @hide
492 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600493 public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800494
495 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600496 * When set, assume that all components under the given app are direct boot
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800497 * aware, unless otherwise specified.
498 *
499 * @hide
500 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600501 public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800502
503 /**
Todd Kennedybe0b8892017-02-15 14:13:52 -0800504 * Value for {@link #privateFlags}: {@code true} if the application is installed
505 * as instant app.
506 *
507 * @hide
Chad Brubaker4389c232016-11-04 14:50:50 -0700508 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800509 public static final int PRIVATE_FLAG_INSTANT = 1 << 7;
Chad Brubaker4389c232016-11-04 14:50:50 -0700510
511 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600512 * When set, at least one component inside this application is direct boot
513 * aware.
Jeff Sharkey8924e872015-11-30 12:52:10 -0700514 *
515 * @hide
516 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600517 public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
Jeff Sharkey8924e872015-11-30 12:52:10 -0700518
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800519
520 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800521 * When set, signals that the application is required for the system user and should not be
522 * uninstalled.
523 *
524 * @hide
525 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700526 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800527
528 /**
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700529 * When set, the application explicitly requested that its activities be resizeable by default.
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800530 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
531 *
532 * @hide
533 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700534 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE = 1 << 10;
535
536 /**
537 * When set, the application explicitly requested that its activities *not* be resizeable by
538 * default.
539 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
540 *
541 * @hide
542 */
543 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE = 1 << 11;
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700544
545 /**
546 * The application isn't requesting explicitly requesting for its activities to be resizeable or
547 * non-resizeable by default. So, we are making it activities resizeable by default based on the
548 * target SDK version of the app.
549 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
550 *
551 * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
552 * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
553 * where certain pre-N apps are forced to the resizeable.
554 *
555 * @hide
556 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700557 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION =
558 1 << 12;
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800559
560 /**
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800561 * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
562 * run full-data backup operations for the app even when it is in a
563 * foreground-equivalent run state. Defaults to {@code false} if unspecified.
564 * @hide
565 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700566 public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 13;
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800567
568 /**
Svet Ganov67882122016-12-11 16:36:34 -0800569 * Value for {@link #privateFlags}: {@code true} means this application
570 * contains a static shared library. Defaults to {@code false} if unspecified.
571 * @hide
572 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700573 public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 14;
Svet Ganov67882122016-12-11 16:36:34 -0800574
575 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700576 * Value for {@link #privateFlags}: When set, the application will only have its splits loaded
Adam Lesinski4e862812016-11-21 16:02:24 -0800577 * if they are required to load a component. Splits can be loaded on demand using the
578 * {@link Context#createContextForSplit(String)} API.
579 * @hide
580 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700581 public static final int PRIVATE_FLAG_ISOLATED_SPLIT_LOADING = 1 << 15;
Adam Lesinski4e862812016-11-21 16:02:24 -0800582
583 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700584 * Value for {@link #privateFlags}: When set, the application was installed as
585 * a virtual preload.
586 * @hide
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800587 */
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700588 public static final int PRIVATE_FLAG_VIRTUAL_PRELOAD = 1 << 16;
589
Svet Ganov087dce22017-09-07 15:42:16 -0700590 /**
591 * Value for {@linl #privateFlags}: whether this app is pre-installed on the
592 * OEM partition of the system image.
593 * @hide
594 */
595 public static final int PRIVATE_FLAG_OEM = 1 << 17;
596
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700597 /** @hide */
598 @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
Svet Ganov087dce22017-09-07 15:42:16 -0700599 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
600 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION,
601 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE,
602 PRIVATE_FLAG_BACKUP_IN_FOREGROUND,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700603 PRIVATE_FLAG_CANT_SAVE_STATE,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700604 PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE,
605 PRIVATE_FLAG_DIRECT_BOOT_AWARE,
Svet Ganov087dce22017-09-07 15:42:16 -0700606 PRIVATE_FLAG_FORWARD_LOCK,
607 PRIVATE_FLAG_HAS_DOMAIN_URLS,
608 PRIVATE_FLAG_HIDDEN,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700609 PRIVATE_FLAG_INSTANT,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700610 PRIVATE_FLAG_ISOLATED_SPLIT_LOADING,
Svet Ganov087dce22017-09-07 15:42:16 -0700611 PRIVATE_FLAG_OEM,
612 PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE,
613 PRIVATE_FLAG_PRIVILEGED,
614 PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER,
615 PRIVATE_FLAG_STATIC_SHARED_LIBRARY,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700616 PRIVATE_FLAG_VIRTUAL_PRELOAD,
617 })
618 @Retention(RetentionPolicy.SOURCE)
619 public @interface ApplicationInfoPrivateFlags {}
620
621 /**
622 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
623 * @hide
624 */
625 public @ApplicationInfoPrivateFlags int privateFlags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800626
627 /**
Clara Bayarri4b5a4d22017-01-27 20:15:45 +0000628 * @hide
629 */
630 public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
631
632 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700633 * The required smallest screen width the application can run on. If 0,
634 * nothing has been specified. Comes from
635 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
636 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
637 */
638 public int requiresSmallestWidthDp = 0;
639
640 /**
641 * The maximum smallest screen width the application is designed for. If 0,
642 * nothing has been specified. Comes from
643 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
644 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
645 */
646 public int compatibleWidthLimitDp = 0;
647
648 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700649 * The maximum smallest screen width the application will work on. If 0,
650 * nothing has been specified. Comes from
651 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
652 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
653 */
654 public int largestWidthLimitDp = 0;
655
Jeff Sharkey61128602017-01-26 17:07:35 -0700656 /**
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700657 * Value indicating the maximum aspect ratio the application supports.
658 * <p>
659 * 0 means unset.
660 * @See {@link android.R.attr#maxAspectRatio}.
661 * @hide
662 */
663 public float maxAspectRatio;
664
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600665 /** @removed */
666 @Deprecated
667 public String volumeUuid;
668
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700669 /**
Jeff Sharkey61128602017-01-26 17:07:35 -0700670 * UUID of the storage volume on which this application is being hosted. For
671 * apps hosted on the default internal storage at
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600672 * {@link Environment#getDataDirectory()}, the UUID value is
673 * {@link StorageManager#UUID_DEFAULT}.
Jeff Sharkey61128602017-01-26 17:07:35 -0700674 */
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600675 public UUID storageUuid;
Jeff Sharkey61128602017-01-26 17:07:35 -0700676
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700677 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700678 public String scanSourceDir;
679 /** {@hide} */
680 public String scanPublicSourceDir;
681
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700682 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700683 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800684 */
685 public String sourceDir;
686
687 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700688 * Full path to the publicly available parts of {@link #sourceDir},
689 * including resources and manifest. This may be different from
690 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800691 */
692 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700693
694 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800695 * The names of all installed split APKs, ordered lexicographically.
696 */
697 public String[] splitNames;
698
699 /**
700 * Full paths to zero or more split APKs, indexed by the same order as {@link #splitNames}.
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700701 */
702 public String[] splitSourceDirs;
703
704 /**
705 * Full path to the publicly available parts of {@link #splitSourceDirs},
706 * including resources and manifest. This may be different from
707 * {@link #splitSourceDirs} if an application is forward locked.
Adam Lesinski4e862812016-11-21 16:02:24 -0800708 *
709 * @see #splitSourceDirs
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700710 */
711 public String[] splitPublicSourceDirs;
712
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800713 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800714 * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
715 *
716 * Available since platform version O.
717 *
718 * Only populated if the application opts in to isolated split loading via the
719 * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
720 * AndroidManifest.xml.
721 *
722 * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
723 * and {@link #splitPublicSourceDirs} arrays.
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800724 * Each key represents a split and its value is an array of splits. The first element of this
725 * array is the parent split, and the rest are configuration splits. These configuration splits
726 * have no dependencies themselves.
Adam Lesinski4e862812016-11-21 16:02:24 -0800727 * Cycles do not exist because they are illegal and screened for during installation.
728 *
729 * May be null if no splits are installed, or if no dependencies exist between them.
Calin Juravleda098152017-09-01 17:30:01 -0700730 *
731 * NOTE: Any change to the way split dependencies are stored must update the logic that
732 * creates the class loader context for dexopt (DexoptUtils#getClassLoaderContexts).
733 *
Adam Lesinski4e862812016-11-21 16:02:24 -0800734 * @hide
735 */
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800736 public SparseArray<int[]> splitDependencies;
Adam Lesinski4e862812016-11-21 16:02:24 -0800737
738 /**
739 * Full paths to the locations of extra resource packages (runtime overlays)
740 * this application uses. This field is only used if there are extra resource
741 * packages, otherwise it is null.
742 *
Kenny Rootace5a3f2010-02-05 12:59:28 -0800743 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800744 */
745 public String[] resourceDirs;
746
747 /**
Robert Craig0f40dc92013-03-25 06:33:03 -0400748 * String retrieved from the seinfo tag found in selinux policy. This value
Robert Craig5e16bc52015-08-28 12:11:41 -0400749 * can be overridden with a value set through the mac_permissions.xml policy
750 * construct. This value is useful in setting an SELinux security context on
751 * the process as well as its data directory. The String default is being used
752 * here to represent a catchall label when no policy matches.
Robert Craig0f40dc92013-03-25 06:33:03 -0400753 *
754 * {@hide}
755 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800756 public String seInfo = "default";
757
758 /**
759 * The seinfo tag generated per-user. This value may change based upon the
760 * user's configuration. For example, when an instant app is installed for
761 * a user. It is an error if this field is ever {@code null} when trying to
762 * start a new process.
763 * <p>NOTE: We need to separate this out because we modify per-user values
764 * multiple times. This needs to be refactored since we're performing more
765 * work than necessary and these values should only be set once. When that
766 * happens, we can merge the per-user value with the seInfo state above.
767 *
768 * {@hide}
769 */
770 public String seInfoUser;
Robert Craig0f40dc92013-03-25 06:33:03 -0400771
772 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800773 * Paths to all shared libraries this application is linked against. This
774 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
775 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
776 * the structure.
777 */
778 public String[] sharedLibraryFiles;
779
780 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700781 * Full path to the default directory assigned to the package for its
782 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800783 */
784 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700785
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700786 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600787 * Full path to the device-protected directory assigned to the package for
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700788 * its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600789 *
790 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700791 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600792 public String deviceProtectedDataDir;
793
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700794 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600795 * Full path to the credential-protected directory assigned to the package
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700796 * for its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600797 *
798 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700799 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600800 @SystemApi
801 public String credentialProtectedDataDir;
802
Kenny Root85387d72010-08-26 10:13:11 -0700803 /**
804 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700805 */
806 public String nativeLibraryDir;
807
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800808 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100809 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
810 * are stored, if present.
811 *
812 * The main reason this exists is for bundled multi-arch apps, where
813 * it's not trivial to calculate the location of libs for the secondary abi
814 * given the location of the primary.
815 *
816 * TODO: Change the layout of bundled installs so that we can use
817 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
818 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
819 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
820 *
821 * @hide
822 */
823 public String secondaryNativeLibraryDir;
824
825 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700826 * The root path where unpacked native libraries are stored.
827 * <p>
828 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
829 * placed in ISA-specific subdirectories under this path, otherwise the
830 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100831 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700832 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100833 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700834 public String nativeLibraryRootDir;
835
836 /**
837 * Flag indicating that ISA must be appended to
838 * {@link #nativeLibraryRootDir} to be useful.
839 *
840 * @hide
841 */
842 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100843
844 /**
845 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100846 * of the native JNI libraries the application bundles. Will be {@code null}
847 * if this application does not require any particular ABI.
848 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100849 * If non-null, the application will always be launched with this ABI.
850 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100851 * {@hide}
852 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100853 public String primaryCpuAbi;
854
855 /**
856 * The secondary ABI for this application. Might be non-null for multi-arch
857 * installs. The application itself never uses this ABI, but other applications that
858 * use its code might.
859 *
860 * {@hide}
861 */
862 public String secondaryCpuAbi;
863
864 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800865 * The kernel user-ID that has been assigned to this application;
866 * currently this is not a unique ID (multiple applications can have
867 * the same uid).
868 */
869 public int uid;
870
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700871 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800872 * The minimum SDK version this application can run on. It will not run
873 * on earlier versions.
874 */
Todd Kennedy6e2e7f52016-05-02 14:56:45 -0700875 public int minSdkVersion;
Todd Kennedy89d60182016-03-11 11:18:32 -0800876
877 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700878 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700879 * versions, but it knows how to work with any new behavior added at this
880 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
881 * if this is a development build and the app is targeting that. You should
882 * compare that this number is >= the SDK version number at which your
883 * behavior was introduced.
884 */
885 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800886
887 /**
888 * The app's declared version code.
889 * @hide
890 */
891 public int versionCode;
892
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700893 /**
Alan Viveretteb6a25732017-11-21 14:49:24 -0500894 * The user-visible SDK version (ex. 26) of the framework against which the application claims
895 * to have been compiled, or {@code 0} if not specified.
896 * <p>
897 * This property is the compile-time equivalent of
898 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.SDK_INT}.
899 *
900 * @hide For platform use only; we don't expect developers to need to read this value.
901 */
902 public int compileSdkVersion;
903
904 /**
905 * The development codename (ex. "O", "REL") of the framework against which the application
906 * claims to have been compiled, or {@code null} if not specified.
907 * <p>
908 * This property is the compile-time equivalent of
909 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
910 *
911 * @hide For platform use only; we don't expect developers to need to read this value.
912 */
913 @Nullable
914 public String compileSdkVersionCodename;
915
916 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800917 * When false, indicates that all components within this application are
918 * considered disabled, regardless of their individually set enabled status.
919 */
920 public boolean enabled = true;
921
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700922 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700923 * For convenient access to the current enabled setting of this app.
924 * @hide
925 */
926 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
927
928 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700929 * For convenient access to package's install location.
930 * @hide
931 */
932 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700933
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700934 /**
935 * Resource file providing the application's Network Security Config.
936 * @hide
937 */
938 public int networkSecurityConfigRes;
939
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700940 /**
Todd Kennedy11e45072017-01-25 13:24:21 -0800941 * Version of the sandbox the application wants to run in.
942 * @hide
943 */
944 public int targetSandboxVersion;
945
946 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700947 * The category of this app. Categories are used to cluster multiple apps
948 * together into meaningful groups, such as when summarizing battery,
949 * network, or disk usage. Apps should only define this value when they fit
950 * well into one of the specific categories.
951 * <p>
952 * Set from the {@link android.R.attr#appCategory} attribute in the
953 * manifest. If the manifest doesn't define a category, this value may have
954 * been provided by the installer via
955 * {@link PackageManager#setApplicationCategoryHint(String, int)}.
956 */
957 public @Category int category = CATEGORY_UNDEFINED;
958
959 /** {@hide} */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600960 @IntDef(prefix = { "CATEGORY_" }, value = {
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700961 CATEGORY_UNDEFINED,
962 CATEGORY_GAME,
963 CATEGORY_AUDIO,
964 CATEGORY_VIDEO,
965 CATEGORY_IMAGE,
966 CATEGORY_SOCIAL,
967 CATEGORY_NEWS,
968 CATEGORY_MAPS,
969 CATEGORY_PRODUCTIVITY
970 })
971 @Retention(RetentionPolicy.SOURCE)
972 public @interface Category {
973 }
974
975 /**
976 * Value when category is undefined.
977 *
978 * @see #category
979 */
980 public static final int CATEGORY_UNDEFINED = -1;
981
982 /**
983 * Category for apps which are primarily games.
984 *
985 * @see #category
986 */
987 public static final int CATEGORY_GAME = 0;
988
989 /**
990 * Category for apps which primarily work with audio or music, such as music
991 * players.
992 *
993 * @see #category
994 */
995 public static final int CATEGORY_AUDIO = 1;
996
997 /**
998 * Category for apps which primarily work with video or movies, such as
999 * streaming video apps.
1000 *
1001 * @see #category
1002 */
1003 public static final int CATEGORY_VIDEO = 2;
1004
1005 /**
1006 * Category for apps which primarily work with images or photos, such as
1007 * camera or gallery apps.
1008 *
1009 * @see #category
1010 */
1011 public static final int CATEGORY_IMAGE = 3;
1012
1013 /**
1014 * Category for apps which are primarily social apps, such as messaging,
Jeff Sharkeyd2b69102017-03-21 19:40:38 -06001015 * communication, email, or social network apps.
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001016 *
1017 * @see #category
1018 */
1019 public static final int CATEGORY_SOCIAL = 4;
1020
1021 /**
1022 * Category for apps which are primarily news apps, such as newspapers,
1023 * magazines, or sports apps.
1024 *
1025 * @see #category
1026 */
1027 public static final int CATEGORY_NEWS = 5;
1028
1029 /**
1030 * Category for apps which are primarily maps apps, such as navigation apps.
1031 *
1032 * @see #category
1033 */
1034 public static final int CATEGORY_MAPS = 6;
1035
1036 /**
1037 * Category for apps which are primarily productivity apps, such as cloud
1038 * storage or workplace apps.
1039 *
1040 * @see #category
1041 */
1042 public static final int CATEGORY_PRODUCTIVITY = 7;
1043
1044 /**
1045 * Return a concise, localized title for the given
1046 * {@link ApplicationInfo#category} value, or {@code null} for unknown
1047 * values such as {@link #CATEGORY_UNDEFINED}.
1048 *
1049 * @see #category
1050 */
1051 public static CharSequence getCategoryTitle(Context context, @Category int category) {
1052 switch (category) {
1053 case ApplicationInfo.CATEGORY_GAME:
1054 return context.getText(com.android.internal.R.string.app_category_game);
1055 case ApplicationInfo.CATEGORY_AUDIO:
1056 return context.getText(com.android.internal.R.string.app_category_audio);
1057 case ApplicationInfo.CATEGORY_VIDEO:
1058 return context.getText(com.android.internal.R.string.app_category_video);
1059 case ApplicationInfo.CATEGORY_IMAGE:
1060 return context.getText(com.android.internal.R.string.app_category_image);
1061 case ApplicationInfo.CATEGORY_SOCIAL:
1062 return context.getText(com.android.internal.R.string.app_category_social);
1063 case ApplicationInfo.CATEGORY_NEWS:
1064 return context.getText(com.android.internal.R.string.app_category_news);
1065 case ApplicationInfo.CATEGORY_MAPS:
1066 return context.getText(com.android.internal.R.string.app_category_maps);
1067 case ApplicationInfo.CATEGORY_PRODUCTIVITY:
1068 return context.getText(com.android.internal.R.string.app_category_productivity);
1069 default:
1070 return null;
1071 }
1072 }
1073
Narayan Kamathf9419f02017-06-15 11:35:38 +01001074 /** @hide */
1075 public String classLoaderName;
1076
1077 /** @hide */
1078 public String[] splitClassLoaderNames;
1079
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001080 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001081 dump(pw, prefix, DUMP_FLAG_ALL);
1082 }
1083
1084 /** @hide */
Yohei Yukawa8f272172017-08-31 00:26:01 -07001085 public void dump(Printer pw, String prefix, int dumpFlags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001086 super.dumpFront(pw, prefix);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001087 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -08001088 pw.println(prefix + "className=" + className);
1089 }
1090 if (permission != null) {
1091 pw.println(prefix + "permission=" + permission);
1092 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001093 pw.println(prefix + "processName=" + processName);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001094 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001095 pw.println(prefix + "taskAffinity=" + taskAffinity);
1096 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001097 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001098 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -07001099 + " theme=0x" + Integer.toHexString(theme));
Yohei Yukawa8f272172017-08-31 00:26:01 -07001100 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001101 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1102 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1103 + " largestWidthLimitDp=" + largestWidthLimitDp);
1104 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001105 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001106 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -07001107 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1108 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001109 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1110 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1111 }
1112 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1113 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1114 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1115 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001116 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -08001117 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -07001118 }
Yohei Yukawa8f272172017-08-31 00:26:01 -07001119 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
Todd Kennedybe0b8892017-02-15 14:13:52 -08001120 pw.println(prefix + "seinfo=" + seInfo);
1121 pw.println(prefix + "seinfoUser=" + seInfoUser);
Robert Craig0f40dc92013-03-25 06:33:03 -04001122 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001123 pw.println(prefix + "dataDir=" + dataDir);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001124 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001125 pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1126 pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001127 if (sharedLibraryFiles != null) {
1128 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1129 }
Dianne Hackborn12527f92009-11-11 17:39:50 -08001130 }
Narayan Kamathf9419f02017-06-15 11:35:38 +01001131 if (classLoaderName != null) {
1132 pw.println(prefix + "classLoaderName=" + classLoaderName);
1133 }
1134 if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1135 pw.println(prefix + "splitClassLoaderNames=" + Arrays.toString(splitClassLoaderNames));
1136 }
1137
Todd Kennedy89d60182016-03-11 11:18:32 -08001138 pw.println(prefix + "enabled=" + enabled
1139 + " minSdkVersion=" + minSdkVersion
1140 + " targetSdkVersion=" + targetSdkVersion
Todd Kennedy11e45072017-01-25 13:24:21 -08001141 + " versionCode=" + versionCode
1142 + " targetSandboxVersion=" + targetSandboxVersion);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001143 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001144 if (manageSpaceActivityName != null) {
1145 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1146 }
1147 if (descriptionRes != 0) {
1148 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1149 }
1150 if (uiOptions != 0) {
1151 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1152 }
1153 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1154 if (fullBackupContent > 0) {
1155 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1156 } else {
1157 pw.println(prefix + "fullBackupContent="
1158 + (fullBackupContent < 0 ? "false" : "true"));
1159 }
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001160 if (networkSecurityConfigRes != 0) {
1161 pw.println(prefix + "networkSecurityConfigRes=0x"
1162 + Integer.toHexString(networkSecurityConfigRes));
1163 }
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001164 if (category != CATEGORY_UNDEFINED) {
1165 pw.println(prefix + "category=" + category);
1166 }
Matthew Williams303650c2015-04-17 18:22:51 -07001167 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001168 super.dumpBack(pw, prefix);
1169 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001170
1171 /**
1172 * @return true if "supportsRtl" has been set to true in the AndroidManifest
1173 * @hide
1174 */
1175 public boolean hasRtlSupport() {
1176 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1177 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -07001178
1179 /** {@hide} */
1180 public boolean hasCode() {
1181 return (flags & FLAG_HAS_CODE) != 0;
1182 }
1183
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001184 public static class DisplayNameComparator
1185 implements Comparator<ApplicationInfo> {
1186 public DisplayNameComparator(PackageManager pm) {
1187 mPM = pm;
1188 }
1189
1190 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1191 CharSequence sa = mPM.getApplicationLabel(aa);
1192 if (sa == null) {
1193 sa = aa.packageName;
1194 }
1195 CharSequence sb = mPM.getApplicationLabel(ab);
1196 if (sb == null) {
1197 sb = ab.packageName;
1198 }
1199
1200 return sCollator.compare(sa.toString(), sb.toString());
1201 }
1202
1203 private final Collator sCollator = Collator.getInstance();
1204 private PackageManager mPM;
1205 }
1206
1207 public ApplicationInfo() {
1208 }
1209
1210 public ApplicationInfo(ApplicationInfo orig) {
1211 super(orig);
1212 taskAffinity = orig.taskAffinity;
1213 permission = orig.permission;
1214 processName = orig.processName;
1215 className = orig.className;
1216 theme = orig.theme;
1217 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001218 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001219 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1220 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001221 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001222 volumeUuid = orig.volumeUuid;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -06001223 storageUuid = orig.storageUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001224 scanSourceDir = orig.scanSourceDir;
1225 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001226 sourceDir = orig.sourceDir;
1227 publicSourceDir = orig.publicSourceDir;
Adam Lesinski4e862812016-11-21 16:02:24 -08001228 splitNames = orig.splitNames;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001229 splitSourceDirs = orig.splitSourceDirs;
1230 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Adam Lesinski4e862812016-11-21 16:02:24 -08001231 splitDependencies = orig.splitDependencies;
Kenny Root85387d72010-08-26 10:13:11 -07001232 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001233 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -07001234 nativeLibraryRootDir = orig.nativeLibraryRootDir;
1235 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001236 primaryCpuAbi = orig.primaryCpuAbi;
1237 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -08001238 resourceDirs = orig.resourceDirs;
Todd Kennedybe0b8892017-02-15 14:13:52 -08001239 seInfo = orig.seInfo;
1240 seInfoUser = orig.seInfoUser;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001241 sharedLibraryFiles = orig.sharedLibraryFiles;
1242 dataDir = orig.dataDir;
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001243 deviceProtectedDataDir = orig.deviceProtectedDataDir;
1244 credentialProtectedDataDir = orig.credentialProtectedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001245 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -08001246 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001247 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -08001248 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001249 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001250 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001251 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001252 manageSpaceActivityName = orig.manageSpaceActivityName;
1253 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -07001254 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -07001255 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -07001256 fullBackupContent = orig.fullBackupContent;
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001257 networkSecurityConfigRes = orig.networkSecurityConfigRes;
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001258 category = orig.category;
Todd Kennedy11e45072017-01-25 13:24:21 -08001259 targetSandboxVersion = orig.targetSandboxVersion;
Narayan Kamathf9419f02017-06-15 11:35:38 +01001260 classLoaderName = orig.classLoaderName;
1261 splitClassLoaderNames = orig.splitClassLoaderNames;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001262 }
1263
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001264 public String toString() {
1265 return "ApplicationInfo{"
1266 + Integer.toHexString(System.identityHashCode(this))
1267 + " " + packageName + "}";
1268 }
1269
1270 public int describeContents() {
1271 return 0;
1272 }
1273
Adam Lesinski4e862812016-11-21 16:02:24 -08001274 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001275 public void writeToParcel(Parcel dest, int parcelableFlags) {
1276 super.writeToParcel(dest, parcelableFlags);
1277 dest.writeString(taskAffinity);
1278 dest.writeString(permission);
1279 dest.writeString(processName);
1280 dest.writeString(className);
1281 dest.writeInt(theme);
1282 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001283 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001284 dest.writeInt(requiresSmallestWidthDp);
1285 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001286 dest.writeInt(largestWidthLimitDp);
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001287 if (storageUuid != null) {
1288 dest.writeInt(1);
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001289 dest.writeLong(storageUuid.getMostSignificantBits());
1290 dest.writeLong(storageUuid.getLeastSignificantBits());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001291 } else {
1292 dest.writeInt(0);
1293 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001294 dest.writeString(scanSourceDir);
1295 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001296 dest.writeString(sourceDir);
1297 dest.writeString(publicSourceDir);
Adam Lesinski4e862812016-11-21 16:02:24 -08001298 dest.writeStringArray(splitNames);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001299 dest.writeStringArray(splitSourceDirs);
1300 dest.writeStringArray(splitPublicSourceDirs);
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001301 dest.writeSparseArray((SparseArray) splitDependencies);
Kenny Root85387d72010-08-26 10:13:11 -07001302 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001303 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -07001304 dest.writeString(nativeLibraryRootDir);
1305 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +01001306 dest.writeString(primaryCpuAbi);
1307 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -08001308 dest.writeStringArray(resourceDirs);
Todd Kennedybe0b8892017-02-15 14:13:52 -08001309 dest.writeString(seInfo);
1310 dest.writeString(seInfoUser);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001311 dest.writeStringArray(sharedLibraryFiles);
1312 dest.writeString(dataDir);
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001313 dest.writeString(deviceProtectedDataDir);
1314 dest.writeString(credentialProtectedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001315 dest.writeInt(uid);
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001316 dest.writeInt(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001317 dest.writeInt(targetSdkVersion);
Dianne Hackborn8472e612014-01-23 17:57:20 -08001318 dest.writeInt(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001319 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001320 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001321 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001322 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -07001323 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001324 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -07001325 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -07001326 dest.writeInt(fullBackupContent);
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001327 dest.writeInt(networkSecurityConfigRes);
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001328 dest.writeInt(category);
Todd Kennedy11e45072017-01-25 13:24:21 -08001329 dest.writeInt(targetSandboxVersion);
Narayan Kamathf9419f02017-06-15 11:35:38 +01001330 dest.writeString(classLoaderName);
1331 dest.writeStringArray(splitClassLoaderNames);
Alan Viveretteb6a25732017-11-21 14:49:24 -05001332 dest.writeInt(compileSdkVersion);
1333 dest.writeString(compileSdkVersionCodename);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001334 }
1335
1336 public static final Parcelable.Creator<ApplicationInfo> CREATOR
1337 = new Parcelable.Creator<ApplicationInfo>() {
1338 public ApplicationInfo createFromParcel(Parcel source) {
1339 return new ApplicationInfo(source);
1340 }
1341 public ApplicationInfo[] newArray(int size) {
1342 return new ApplicationInfo[size];
1343 }
1344 };
1345
Adam Lesinski4e862812016-11-21 16:02:24 -08001346 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001347 private ApplicationInfo(Parcel source) {
1348 super(source);
1349 taskAffinity = source.readString();
1350 permission = source.readString();
1351 processName = source.readString();
1352 className = source.readString();
1353 theme = source.readInt();
1354 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001355 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001356 requiresSmallestWidthDp = source.readInt();
1357 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001358 largestWidthLimitDp = source.readInt();
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001359 if (source.readInt() != 0) {
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001360 storageUuid = new UUID(source.readLong(), source.readLong());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001361 volumeUuid = StorageManager.convert(storageUuid);
1362 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001363 scanSourceDir = source.readString();
1364 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001365 sourceDir = source.readString();
1366 publicSourceDir = source.readString();
Adam Lesinski4e862812016-11-21 16:02:24 -08001367 splitNames = source.readStringArray();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001368 splitSourceDirs = source.readStringArray();
1369 splitPublicSourceDirs = source.readStringArray();
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001370 splitDependencies = source.readSparseArray(null);
Kenny Root85387d72010-08-26 10:13:11 -07001371 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001372 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -07001373 nativeLibraryRootDir = source.readString();
1374 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001375 primaryCpuAbi = source.readString();
1376 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -08001377 resourceDirs = source.readStringArray();
Todd Kennedybe0b8892017-02-15 14:13:52 -08001378 seInfo = source.readString();
1379 seInfoUser = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001380 sharedLibraryFiles = source.readStringArray();
1381 dataDir = source.readString();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001382 deviceProtectedDataDir = source.readString();
1383 credentialProtectedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001384 uid = source.readInt();
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001385 minSdkVersion = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001386 targetSdkVersion = source.readInt();
Dianne Hackborn8472e612014-01-23 17:57:20 -08001387 versionCode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001388 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001389 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001390 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001391 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001392 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001393 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001394 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001395 fullBackupContent = source.readInt();
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001396 networkSecurityConfigRes = source.readInt();
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001397 category = source.readInt();
Todd Kennedy11e45072017-01-25 13:24:21 -08001398 targetSandboxVersion = source.readInt();
Narayan Kamathf9419f02017-06-15 11:35:38 +01001399 classLoaderName = source.readString();
1400 splitClassLoaderNames = source.readStringArray();
Alan Viveretteb6a25732017-11-21 14:49:24 -05001401 compileSdkVersion = source.readInt();
1402 compileSdkVersionCodename = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001403 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001404
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001405 /**
1406 * Retrieve the textual description of the application. This
1407 * will call back on the given PackageManager to load the description from
1408 * the application.
1409 *
1410 * @param pm A PackageManager from which the label can be loaded; usually
1411 * the PackageManager from which you originally retrieved this item.
1412 *
1413 * @return Returns a CharSequence containing the application's description.
1414 * If there is no description, null is returned.
1415 */
1416 public CharSequence loadDescription(PackageManager pm) {
1417 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001418 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001419 if (label != null) {
1420 return label;
1421 }
1422 }
1423 return null;
1424 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001425
1426 /**
1427 * Disable compatibility mode
1428 *
1429 * @hide
1430 */
1431 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001432 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001433 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001434 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001435 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001436
skuhne@google.com7e85eb02017-01-04 13:49:54 -08001437 /**
1438 * Is using compatibility mode for non densty aware legacy applications.
1439 *
1440 * @hide
1441 */
1442 public boolean usesCompatibilityMode() {
1443 return targetSdkVersion < DONUT ||
1444 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1445 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1446 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1447 }
1448
Jeff Sharkey15447792015-11-05 16:18:51 -08001449 /** {@hide} */
1450 public void initForUser(int userId) {
1451 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1452
1453 if ("android".equals(packageName)) {
1454 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1455 return;
1456 }
1457
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001458 deviceProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001459 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001460 .getAbsolutePath();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001461 credentialProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001462 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001463 .getAbsolutePath();
1464
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001465 if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1466 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1467 dataDir = deviceProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001468 } else {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001469 dataDir = credentialProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001470 }
1471 }
1472
Jeff Brown07330792010-03-30 19:57:08 -07001473 /**
1474 * @hide
1475 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001476 @Override
1477 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001478 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1479 && isPackageUnavailable(pm)) {
1480 return Resources.getSystem().getDrawable(
1481 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1482 }
1483 return pm.getDefaultActivityIcon();
1484 }
1485
1486 private boolean isPackageUnavailable(PackageManager pm) {
1487 try {
1488 return pm.getPackageInfo(packageName, 0) == null;
1489 } catch (NameNotFoundException ex) {
1490 return true;
1491 }
1492 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001493
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001494 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001495 public boolean isDefaultToDeviceProtectedStorage() {
1496 return (privateFlags
1497 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
Jeff Sharkeye4697132016-02-06 19:46:15 -07001498 }
1499
1500 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001501 public boolean isDirectBootAware() {
1502 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001503 }
1504
Jeff Sharkey8924e872015-11-30 12:52:10 -07001505 /** @hide */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001506 public boolean isEncryptionAware() {
1507 return isDirectBootAware() || isPartiallyDirectBootAware();
1508 }
1509
1510 /** @hide */
1511 public boolean isExternal() {
1512 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1513 }
1514
1515 /** @hide */
1516 public boolean isExternalAsec() {
1517 return TextUtils.isEmpty(volumeUuid) && isExternal();
1518 }
1519
1520 /** @hide */
1521 public boolean isForwardLocked() {
1522 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1523 }
1524
1525 /** @hide */
1526 public boolean isInstantApp() {
1527 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
1528 }
1529
1530 /** @hide */
1531 public boolean isInternal() {
1532 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1533 }
1534
1535 /** @hide */
1536 public boolean isOem() {
1537 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
1538 }
1539
1540 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001541 public boolean isPartiallyDirectBootAware() {
1542 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkey8924e872015-11-30 12:52:10 -07001543 }
1544
Bryce Lee8558ec72017-08-17 15:37:26 -07001545 /** @hide */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001546 @TestApi
1547 public boolean isPrivilegedApp() {
1548 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
Bryce Lee8558ec72017-08-17 15:37:26 -07001549 }
1550
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001551 /** @hide */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001552 public boolean isRequiredForSystemUser() {
1553 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1554 }
1555
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001556 /** @hide */
Svet Ganov67882122016-12-11 16:36:34 -08001557 public boolean isStaticSharedLibrary() {
1558 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
1559 }
1560
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001561 /** @hide */
1562 @TestApi
1563 public boolean isSystemApp() {
1564 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1565 }
1566
1567 /** @hide */
1568 public boolean isUpdatedSystemApp() {
1569 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1570 }
1571
Svet Ganov67882122016-12-11 16:36:34 -08001572 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -07001573 * Returns whether or not this application was installed as a virtual preload.
1574 */
1575 public boolean isVirtualPreload() {
1576 return (privateFlags & PRIVATE_FLAG_VIRTUAL_PRELOAD) != 0;
1577 }
1578
1579 /**
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001580 * Returns true if the app has declared in its manifest that it wants its split APKs to be
1581 * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
Svet Ganov67882122016-12-11 16:36:34 -08001582 * @hide
1583 */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001584 public boolean requestsIsolatedSplitLoading() {
1585 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
Svet Ganov087dce22017-09-07 15:42:16 -07001586 }
1587
1588 /**
1589 * @hide
1590 */
Jeff Brown07330792010-03-30 19:57:08 -07001591 @Override protected ApplicationInfo getApplicationInfo() {
1592 return this;
1593 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001594
1595 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1596 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1597 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1598 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1599 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1600 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1601
1602 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1603 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1604 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1605 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1606 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
Jeff Sharkeya3a43b02016-11-15 17:54:23 -07001607 /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001608}