blob: b4d77a0fe54aed7147e22029371d2c0c2a833eb5 [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 Sharkeye2d45be2015-04-15 17:14:12 -070032import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.util.Printer;
Adam Lesinski4e862812016-11-21 16:02:24 -080034import android.util.SparseIntArray;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070036import com.android.internal.util.ArrayUtils;
37
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070038import java.lang.annotation.Retention;
39import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070041import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070043import java.util.Objects;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044
45/**
46 * Information you can retrieve about a particular application. This
47 * corresponds to information collected from the AndroidManifest.xml's
48 * <application> tag.
49 */
50public class ApplicationInfo extends PackageItemInfo implements Parcelable {
51
52 /**
53 * Default task affinity of all activities in this application. See
54 * {@link ActivityInfo#taskAffinity} for more information. This comes
55 * from the "taskAffinity" attribute.
56 */
57 public String taskAffinity;
58
59 /**
60 * Optional name of a permission required to be able to access this
61 * application's components. From the "permission" attribute.
62 */
63 public String permission;
64
65 /**
66 * The name of the process this application should run in. From the
67 * "process" attribute or, if not set, the same as
68 * <var>packageName</var>.
69 */
70 public String processName;
71
72 /**
73 * Class implementing the Application object. From the "class"
74 * attribute.
75 */
76 public String className;
77
78 /**
79 * A style resource identifier (in the package's resources) of the
80 * description of an application. From the "description" attribute
81 * or, if not set, 0.
82 */
83 public int descriptionRes;
84
85 /**
86 * A style resource identifier (in the package's resources) of the
87 * default visual theme of the application. From the "theme" attribute
88 * or, if not set, 0.
89 */
90 public int theme;
91
92 /**
93 * Class implementing the Application's manage space
94 * functionality. From the "manageSpaceActivity"
95 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -070096 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 */
98 public String manageSpaceActivityName;
99
100 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700101 * Class implementing the Application's backup functionality. From
102 * the "backupAgent" attribute. This is an optional attribute and
103 * will be null if the application does not specify it in its manifest.
104 *
105 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -0700106 */
107 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700108
109 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700110 * An optional attribute that indicates the app supports automatic backup of app data.
111 * <p>0 is the default and means the app's entire data folder + managed external storage will
112 * be backed up;
113 * Any negative value indicates the app does not support full-data backup, though it may still
114 * want to participate via the traditional key/value backup API;
115 * A positive number specifies an xml resource in which the application has defined its backup
116 * include/exclude criteria.
117 * <p>If android:allowBackup is set to false, this attribute is ignored.
118 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600119 * @see android.content.Context#getNoBackupFilesDir()
120 * @see #FLAG_ALLOW_BACKUP
Christopher Tate98fa6562015-05-14 13:20:10 -0700121 *
122 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700123 */
124 public int fullBackupContent = 0;
125
126 /**
Adam Powell269248d2011-08-02 10:26:54 -0700127 * The default extra UI options for activities in this application.
128 * Set from the {@link android.R.attr#uiOptions} attribute in the
129 * activity's manifest.
130 */
131 public int uiOptions = 0;
132
133 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800134 * Value for {@link #flags}: if set, this application is installed in the
135 * device's system image.
136 */
137 public static final int FLAG_SYSTEM = 1<<0;
138
139 /**
140 * Value for {@link #flags}: set to true if this application would like to
141 * allow debugging of its
142 * code, even when installed on a non-development system. Comes
143 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
144 * android:debuggable} of the &lt;application&gt; tag.
145 */
146 public static final int FLAG_DEBUGGABLE = 1<<1;
147
148 /**
149 * Value for {@link #flags}: set to true if this application has code
150 * associated with it. Comes
151 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
152 * android:hasCode} of the &lt;application&gt; tag.
153 */
154 public static final int FLAG_HAS_CODE = 1<<2;
155
156 /**
157 * Value for {@link #flags}: set to true if this application is persistent.
158 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
159 * android:persistent} of the &lt;application&gt; tag.
160 */
161 public static final int FLAG_PERSISTENT = 1<<3;
162
163 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700164 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800165 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
166 * device is running in factory test mode.
167 */
168 public static final int FLAG_FACTORY_TEST = 1<<4;
169
170 /**
171 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
172 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
173 * android:allowTaskReparenting} of the &lt;application&gt; tag.
174 */
175 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
176
177 /**
178 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
179 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
180 * android:allowClearUserData} of the &lt;application&gt; tag.
181 */
182 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
183
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800184 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700185 * Value for {@link #flags}: this is set if this application has been
Kweku Adams8de29ca2016-01-22 12:30:26 -0800186 * installed as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800187 */
188 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700189
190 /**
Svet Ganov354cd3c2015-12-17 11:35:04 -0800191 * Value for {@link #flags}: this is set if the application has specified
Dianne Hackborn7f205432009-07-28 00:13:47 -0700192 * {@link android.R.styleable#AndroidManifestApplication_testOnly
193 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700194 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700195 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700196
197 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700198 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700199 * reduced in size for smaller screens. Corresponds to
200 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
201 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700202 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700203 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
204
205 /**
206 * Value for {@link #flags}: true when the application's window can be
207 * displayed on normal screens. Corresponds to
208 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
209 * android:normalScreens}.
210 */
211 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
212
213 /**
214 * Value for {@link #flags}: true when the application's window can be
215 * increased in size for larger screens. Corresponds to
216 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700217 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700218 */
219 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700220
221 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700222 * Value for {@link #flags}: true when the application knows how to adjust
223 * its UI for different screen sizes. Corresponds to
224 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
225 * android:resizeable}.
226 */
227 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
228
229 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700230 * Value for {@link #flags}: true when the application knows how to
231 * accomodate different screen densities. Corresponds to
232 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
233 * android:anyDensity}.
234 */
235 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
236
237 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800238 * Value for {@link #flags}: set to true if this application would like to
239 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700240 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
241 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800242 */
243 public static final int FLAG_VM_SAFE_MODE = 1<<14;
244
245 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800246 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
247 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700248 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800249 * <p>Comes from the
250 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
251 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700252 */
Ben Cheng23085b72010-02-08 16:06:32 -0800253 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700254
255 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800256 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
257 * in memory following a full-system restore operation; <code>true</code> otherwise.
258 * Ordinarily, during a full system restore operation each application is shut down
259 * following execution of its agent's onRestore() method. Setting this attribute to
260 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700261 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800262 * <p>If
263 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
264 * is set to <code>false</code> or no
265 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700266 * is specified, this flag will be ignored.
267 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800268 * <p>Comes from the
269 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
270 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700271 */
Ben Cheng23085b72010-02-08 16:06:32 -0800272 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700273
274 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800275 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
276 * agent claims to be able to handle restore data even "from the future,"
277 * i.e. from versions of the application with a versionCode greater than
278 * the one currently installed on the device. <i>Use with caution!</i> By default
279 * this attribute is <code>false</code> and the Backup Manager will ensure that data
280 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700281 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800282 * <p>If
283 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
284 * is set to <code>false</code> or no
285 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700286 * is specified, this flag will be ignored.
287 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800288 * <p>Comes from the
289 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
290 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700291 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800292 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700293
Christopher Tate181fafa2009-05-14 11:12:14 -0700294 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700295 * Value for {@link #flags}: Set to true if the application is
296 * currently installed on external/removable/unprotected storage. Such
297 * applications may not be available if their storage is not currently
298 * mounted. When the storage it is on is not available, it will look like
299 * the application has been uninstalled (its .apk is no longer available)
300 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800301 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700302 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800303
304 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700305 * Value for {@link #flags}: true when the application's window can be
306 * increased in size for extra large screens. Corresponds to
307 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700308 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700309 */
310 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
311
312 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800313 * Value for {@link #flags}: true when the application has requested a
314 * large heap for its processes. Corresponds to
315 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
316 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600317 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800318 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600319
320 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800321 * Value for {@link #flags}: true if this application's package is in
322 * the stopped state.
323 */
324 public static final int FLAG_STOPPED = 1<<21;
325
326 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700327 * Value for {@link #flags}: true when the application is willing to support
328 * RTL (right to left). All activities will inherit this value.
329 *
330 * Set from the {@link android.R.attr#supportsRtl} attribute in the
331 * activity's manifest.
332 *
333 * Default value is false (no support for RTL).
334 */
335 public static final int FLAG_SUPPORTS_RTL = 1<<22;
336
337 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700338 * Value for {@link #flags}: true if the application is currently
339 * installed for the calling user.
340 */
341 public static final int FLAG_INSTALLED = 1<<23;
342
343 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700344 * Value for {@link #flags}: true if the application only has its
345 * data installed; the application package itself does not currently
346 * exist on the device.
347 */
348 public static final int FLAG_IS_DATA_ONLY = 1<<24;
349
350 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700351 * Value for {@link #flags}: true if the application was declared to be a
352 * game, or false if it is a non-game application.
353 *
354 * @deprecated use {@link #CATEGORY_GAME} instead.
Jose Lima12d0b4c2014-03-14 16:55:12 -0700355 */
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700356 @Deprecated
Jose Lima12d0b4c2014-03-14 16:55:12 -0700357 public static final int FLAG_IS_GAME = 1<<25;
358
359 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700360 * Value for {@link #flags}: {@code true} if the application asks that only
361 * full-data streaming backups of its data be performed even though it defines
362 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
363 * indicates that the app will manage its backed-up data via incremental
364 * key/value updates.
365 */
366 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
367
368 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700369 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
370 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
371 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
372 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700373 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
374 * traffic. Third-party libraries are encouraged to honor this flag as well.
375 *
376 * <p>NOTE: {@code WebView} does not honor this flag.
377 *
Chad Brubaker2df5ba72016-04-11 13:31:24 -0700378 * <p>This flag is ignored on Android N and above if an Android Network Security Config is
379 * present.
380 *
Alex Klyubinfbf45992015-04-21 13:44:29 -0700381 * <p>This flag comes from
382 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
383 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700384 */
385 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
386
387 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700388 * When set installer extracts native libs from .apk files.
389 */
390 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
391
392 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700393 * Value for {@link #flags}: {@code true} when the application's rendering
394 * should be hardware accelerated.
395 */
396 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
397
398 /**
Andrei Stingaceanu1e283912015-11-26 15:26:28 +0000399 * Value for {@link #flags}: true if this application's package is in
400 * the suspended state.
401 */
402 public static final int FLAG_SUSPENDED = 1<<30;
403
404 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100405 * Value for {@link #flags}: true if code from this application will need to be
406 * loaded into other applications' processes. On devices that support multiple
407 * instruction sets, this implies the code might be loaded into a process that's
408 * using any of the devices supported instruction sets.
409 *
410 * <p> The system might treat such applications specially, for eg., by
411 * extracting the application's native libraries for all supported instruction
412 * sets or by compiling the application's dex code for all supported instruction
413 * sets.
414 */
415 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700416
417 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800418 * Flags associated with the application. Any combination of
419 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
420 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
421 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700422 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700423 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
424 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700425 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
426 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700427 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800428 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
429 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
430 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
431 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
432 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700433 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
434 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800435 */
436 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700437
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800439 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
440 * most purposes is considered as not installed.
441 * {@hide}
442 */
443 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
444
445 /**
446 * Value for {@link #privateFlags}: set to <code>true</code> if the application
447 * has reported that it is heavy-weight, and thus can not participate in
448 * the normal application lifecycle.
449 *
450 * <p>Comes from the
451 * android.R.styleable#AndroidManifestApplication_cantSaveState
452 * attribute of the &lt;application&gt; tag.
453 *
454 * {@hide}
455 */
456 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
457
458 /**
459 * Value for {@link #privateFlags}: Set to true if the application has been
460 * installed using the forward lock option.
461 *
462 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
463 *
464 * {@hide}
465 */
466 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
467
468 /**
469 * Value for {@link #privateFlags}: set to {@code true} if the application
470 * is permitted to hold privileged permissions.
471 *
472 * {@hide}
473 */
474 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
475
476 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800477 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
478 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700479 *
480 * {@hide}
481 */
482 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
483
484 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600485 * When set, the default data storage directory for this app is pointed at
486 * the device-protected location.
Jeff Sharkey15447792015-11-05 16:18:51 -0800487 *
488 * @hide
489 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600490 public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800491
492 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600493 * When set, assume that all components under the given app are direct boot
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800494 * aware, unless otherwise specified.
495 *
496 * @hide
497 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600498 public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800499
500 /**
Todd Kennedybe0b8892017-02-15 14:13:52 -0800501 * Value for {@link #privateFlags}: {@code true} if the application is installed
502 * as instant app.
503 *
504 * @hide
Chad Brubaker4389c232016-11-04 14:50:50 -0700505 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800506 public static final int PRIVATE_FLAG_INSTANT = 1 << 7;
Chad Brubaker4389c232016-11-04 14:50:50 -0700507
508 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600509 * When set, at least one component inside this application is direct boot
510 * aware.
Jeff Sharkey8924e872015-11-30 12:52:10 -0700511 *
512 * @hide
513 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600514 public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
Jeff Sharkey8924e872015-11-30 12:52:10 -0700515
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800516
517 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800518 * When set, signals that the application is required for the system user and should not be
519 * uninstalled.
520 *
521 * @hide
522 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700523 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800524
525 /**
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700526 * When set, the application explicitly requested that its activities by resizeable by default.
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800527 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
528 *
529 * @hide
530 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700531 public static final int PRIVATE_FLAG_RESIZEABLE_ACTIVITIES_EXPLICITLY_SET = 1 << 10;
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700532
533 /**
534 * The application isn't requesting explicitly requesting for its activities to be resizeable or
535 * non-resizeable by default. So, we are making it activities resizeable by default based on the
536 * target SDK version of the app.
537 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
538 *
539 * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
540 * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
541 * where certain pre-N apps are forced to the resizeable.
542 *
543 * @hide
544 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700545 public static final int PRIVATE_FLAG_RESIZEABLE_ACTIVITIES_VIA_SDK_VERSION = 1 << 11;
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800546
547 /**
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800548 * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
549 * run full-data backup operations for the app even when it is in a
550 * foreground-equivalent run state. Defaults to {@code false} if unspecified.
551 * @hide
552 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700553 public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 12;
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800554
555 /**
Svet Ganov67882122016-12-11 16:36:34 -0800556 * Value for {@link #privateFlags}: {@code true} means this application
557 * contains a static shared library. Defaults to {@code false} if unspecified.
558 * @hide
559 */
560 public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 13;
561
562 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800563 * Value for {@linl #privateFlags}: When set, the application will only have its splits loaded
564 * if they are required to load a component. Splits can be loaded on demand using the
565 * {@link Context#createContextForSplit(String)} API.
566 * @hide
567 */
568 public static final int PRIVATE_FLAG_ISOLATED_SPLIT_LOADING = 1 << 14;
569
570 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800571 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
572 * {@hide}
573 */
574 public int privateFlags;
575
576 /**
Clara Bayarri4b5a4d22017-01-27 20:15:45 +0000577 * @hide
578 */
579 public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
580
581 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700582 * The required smallest screen width the application can run on. If 0,
583 * nothing has been specified. Comes from
584 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
585 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
586 */
587 public int requiresSmallestWidthDp = 0;
588
589 /**
590 * The maximum smallest screen width the application is designed for. If 0,
591 * nothing has been specified. Comes from
592 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
593 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
594 */
595 public int compatibleWidthLimitDp = 0;
596
597 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700598 * The maximum smallest screen width the application will work on. If 0,
599 * nothing has been specified. Comes from
600 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
601 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
602 */
603 public int largestWidthLimitDp = 0;
604
Jeff Sharkey61128602017-01-26 17:07:35 -0700605 /**
606 * UUID of the storage volume on which this application is being hosted. For
607 * apps hosted on the default internal storage at
608 * {@link Environment#getDataDirectory()}, the UUID value is {@code null}.
609 */
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700610 public String volumeUuid;
Jeff Sharkey61128602017-01-26 17:07:35 -0700611
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700612 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700613 public String scanSourceDir;
614 /** {@hide} */
615 public String scanPublicSourceDir;
616
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700617 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700618 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800619 */
620 public String sourceDir;
621
622 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700623 * Full path to the publicly available parts of {@link #sourceDir},
624 * including resources and manifest. This may be different from
625 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800626 */
627 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700628
629 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800630 * The names of all installed split APKs, ordered lexicographically.
631 */
632 public String[] splitNames;
633
634 /**
635 * Full paths to zero or more split APKs, indexed by the same order as {@link #splitNames}.
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700636 */
637 public String[] splitSourceDirs;
638
639 /**
640 * Full path to the publicly available parts of {@link #splitSourceDirs},
641 * including resources and manifest. This may be different from
642 * {@link #splitSourceDirs} if an application is forward locked.
Adam Lesinski4e862812016-11-21 16:02:24 -0800643 *
644 * @see #splitSourceDirs
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700645 */
646 public String[] splitPublicSourceDirs;
647
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800648 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800649 * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
650 *
651 * Available since platform version O.
652 *
653 * Only populated if the application opts in to isolated split loading via the
654 * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
655 * AndroidManifest.xml.
656 *
657 * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
658 * and {@link #splitPublicSourceDirs} arrays.
659 * Each key represents a split and its value is its parent split.
660 * Cycles do not exist because they are illegal and screened for during installation.
661 *
662 * May be null if no splits are installed, or if no dependencies exist between them.
663 * @hide
664 */
665 public SparseIntArray splitDependencies;
666
667 /**
668 * Full paths to the locations of extra resource packages (runtime overlays)
669 * this application uses. This field is only used if there are extra resource
670 * packages, otherwise it is null.
671 *
Kenny Rootace5a3f2010-02-05 12:59:28 -0800672 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800673 */
674 public String[] resourceDirs;
675
676 /**
Robert Craig0f40dc92013-03-25 06:33:03 -0400677 * String retrieved from the seinfo tag found in selinux policy. This value
Robert Craig5e16bc52015-08-28 12:11:41 -0400678 * can be overridden with a value set through the mac_permissions.xml policy
679 * construct. This value is useful in setting an SELinux security context on
680 * the process as well as its data directory. The String default is being used
681 * here to represent a catchall label when no policy matches.
Robert Craig0f40dc92013-03-25 06:33:03 -0400682 *
683 * {@hide}
684 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800685 public String seInfo = "default";
686
687 /**
688 * The seinfo tag generated per-user. This value may change based upon the
689 * user's configuration. For example, when an instant app is installed for
690 * a user. It is an error if this field is ever {@code null} when trying to
691 * start a new process.
692 * <p>NOTE: We need to separate this out because we modify per-user values
693 * multiple times. This needs to be refactored since we're performing more
694 * work than necessary and these values should only be set once. When that
695 * happens, we can merge the per-user value with the seInfo state above.
696 *
697 * {@hide}
698 */
699 public String seInfoUser;
Robert Craig0f40dc92013-03-25 06:33:03 -0400700
701 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800702 * Paths to all shared libraries this application is linked against. This
703 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
704 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
705 * the structure.
706 */
707 public String[] sharedLibraryFiles;
708
709 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700710 * Full path to the default directory assigned to the package for its
711 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800712 */
713 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700714
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700715 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600716 * Full path to the device-protected directory assigned to the package for
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700717 * its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600718 *
719 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700720 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600721 public String deviceProtectedDataDir;
722
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700723 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600724 * Full path to the credential-protected directory assigned to the package
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700725 * for its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600726 *
727 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700728 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600729 @SystemApi
730 public String credentialProtectedDataDir;
731
Kenny Root85387d72010-08-26 10:13:11 -0700732 /**
733 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700734 */
735 public String nativeLibraryDir;
736
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800737 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100738 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
739 * are stored, if present.
740 *
741 * The main reason this exists is for bundled multi-arch apps, where
742 * it's not trivial to calculate the location of libs for the secondary abi
743 * given the location of the primary.
744 *
745 * TODO: Change the layout of bundled installs so that we can use
746 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
747 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
748 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
749 *
750 * @hide
751 */
752 public String secondaryNativeLibraryDir;
753
754 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700755 * The root path where unpacked native libraries are stored.
756 * <p>
757 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
758 * placed in ISA-specific subdirectories under this path, otherwise the
759 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100760 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700761 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100762 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700763 public String nativeLibraryRootDir;
764
765 /**
766 * Flag indicating that ISA must be appended to
767 * {@link #nativeLibraryRootDir} to be useful.
768 *
769 * @hide
770 */
771 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100772
773 /**
774 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100775 * of the native JNI libraries the application bundles. Will be {@code null}
776 * if this application does not require any particular ABI.
777 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100778 * If non-null, the application will always be launched with this ABI.
779 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100780 * {@hide}
781 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100782 public String primaryCpuAbi;
783
784 /**
785 * The secondary ABI for this application. Might be non-null for multi-arch
786 * installs. The application itself never uses this ABI, but other applications that
787 * use its code might.
788 *
789 * {@hide}
790 */
791 public String secondaryCpuAbi;
792
793 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800794 * The kernel user-ID that has been assigned to this application;
795 * currently this is not a unique ID (multiple applications can have
796 * the same uid).
797 */
798 public int uid;
799
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700800 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800801 * The minimum SDK version this application can run on. It will not run
802 * on earlier versions.
803 */
Todd Kennedy6e2e7f52016-05-02 14:56:45 -0700804 public int minSdkVersion;
Todd Kennedy89d60182016-03-11 11:18:32 -0800805
806 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700807 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700808 * versions, but it knows how to work with any new behavior added at this
809 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
810 * if this is a development build and the app is targeting that. You should
811 * compare that this number is >= the SDK version number at which your
812 * behavior was introduced.
813 */
814 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800815
816 /**
817 * The app's declared version code.
818 * @hide
819 */
820 public int versionCode;
821
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700822 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800823 * When false, indicates that all components within this application are
824 * considered disabled, regardless of their individually set enabled status.
825 */
826 public boolean enabled = true;
827
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700828 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700829 * For convenient access to the current enabled setting of this app.
830 * @hide
831 */
832 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
833
834 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700835 * For convenient access to package's install location.
836 * @hide
837 */
838 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700839
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700840 /**
841 * Resource file providing the application's Network Security Config.
842 * @hide
843 */
844 public int networkSecurityConfigRes;
845
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700846 /**
Todd Kennedy11e45072017-01-25 13:24:21 -0800847 * Version of the sandbox the application wants to run in.
848 * @hide
849 */
850 public int targetSandboxVersion;
851
852 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700853 * The category of this app. Categories are used to cluster multiple apps
854 * together into meaningful groups, such as when summarizing battery,
855 * network, or disk usage. Apps should only define this value when they fit
856 * well into one of the specific categories.
857 * <p>
858 * Set from the {@link android.R.attr#appCategory} attribute in the
859 * manifest. If the manifest doesn't define a category, this value may have
860 * been provided by the installer via
861 * {@link PackageManager#setApplicationCategoryHint(String, int)}.
862 */
863 public @Category int category = CATEGORY_UNDEFINED;
864
865 /** {@hide} */
866 @IntDef({
867 CATEGORY_UNDEFINED,
868 CATEGORY_GAME,
869 CATEGORY_AUDIO,
870 CATEGORY_VIDEO,
871 CATEGORY_IMAGE,
872 CATEGORY_SOCIAL,
873 CATEGORY_NEWS,
874 CATEGORY_MAPS,
875 CATEGORY_PRODUCTIVITY
876 })
877 @Retention(RetentionPolicy.SOURCE)
878 public @interface Category {
879 }
880
881 /**
882 * Value when category is undefined.
883 *
884 * @see #category
885 */
886 public static final int CATEGORY_UNDEFINED = -1;
887
888 /**
889 * Category for apps which are primarily games.
890 *
891 * @see #category
892 */
893 public static final int CATEGORY_GAME = 0;
894
895 /**
896 * Category for apps which primarily work with audio or music, such as music
897 * players.
898 *
899 * @see #category
900 */
901 public static final int CATEGORY_AUDIO = 1;
902
903 /**
904 * Category for apps which primarily work with video or movies, such as
905 * streaming video apps.
906 *
907 * @see #category
908 */
909 public static final int CATEGORY_VIDEO = 2;
910
911 /**
912 * Category for apps which primarily work with images or photos, such as
913 * camera or gallery apps.
914 *
915 * @see #category
916 */
917 public static final int CATEGORY_IMAGE = 3;
918
919 /**
920 * Category for apps which are primarily social apps, such as messaging,
921 * communication, or social network apps.
922 *
923 * @see #category
924 */
925 public static final int CATEGORY_SOCIAL = 4;
926
927 /**
928 * Category for apps which are primarily news apps, such as newspapers,
929 * magazines, or sports apps.
930 *
931 * @see #category
932 */
933 public static final int CATEGORY_NEWS = 5;
934
935 /**
936 * Category for apps which are primarily maps apps, such as navigation apps.
937 *
938 * @see #category
939 */
940 public static final int CATEGORY_MAPS = 6;
941
942 /**
943 * Category for apps which are primarily productivity apps, such as cloud
944 * storage or workplace apps.
945 *
946 * @see #category
947 */
948 public static final int CATEGORY_PRODUCTIVITY = 7;
949
950 /**
951 * Return a concise, localized title for the given
952 * {@link ApplicationInfo#category} value, or {@code null} for unknown
953 * values such as {@link #CATEGORY_UNDEFINED}.
954 *
955 * @see #category
956 */
957 public static CharSequence getCategoryTitle(Context context, @Category int category) {
958 switch (category) {
959 case ApplicationInfo.CATEGORY_GAME:
960 return context.getText(com.android.internal.R.string.app_category_game);
961 case ApplicationInfo.CATEGORY_AUDIO:
962 return context.getText(com.android.internal.R.string.app_category_audio);
963 case ApplicationInfo.CATEGORY_VIDEO:
964 return context.getText(com.android.internal.R.string.app_category_video);
965 case ApplicationInfo.CATEGORY_IMAGE:
966 return context.getText(com.android.internal.R.string.app_category_image);
967 case ApplicationInfo.CATEGORY_SOCIAL:
968 return context.getText(com.android.internal.R.string.app_category_social);
969 case ApplicationInfo.CATEGORY_NEWS:
970 return context.getText(com.android.internal.R.string.app_category_news);
971 case ApplicationInfo.CATEGORY_MAPS:
972 return context.getText(com.android.internal.R.string.app_category_maps);
973 case ApplicationInfo.CATEGORY_PRODUCTIVITY:
974 return context.getText(com.android.internal.R.string.app_category_productivity);
975 default:
976 return null;
977 }
978 }
979
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800980 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800981 dump(pw, prefix, DUMP_FLAG_ALL);
982 }
983
984 /** @hide */
985 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800986 super.dumpFront(pw, prefix);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800987 if ((flags&DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -0800988 pw.println(prefix + "className=" + className);
989 }
990 if (permission != null) {
991 pw.println(prefix + "permission=" + permission);
992 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700993 pw.println(prefix + "processName=" + processName);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800994 if ((flags&DUMP_FLAG_DETAILS) != 0) {
995 pw.println(prefix + "taskAffinity=" + taskAffinity);
996 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700997 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800998 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -0700999 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001000 if ((flags&DUMP_FLAG_DETAILS) != 0) {
1001 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1002 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1003 + " largestWidthLimitDp=" + largestWidthLimitDp);
1004 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001005 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001006 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -07001007 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1008 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001009 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1010 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1011 }
1012 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1013 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1014 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1015 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001016 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -08001017 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -07001018 }
Todd Kennedybe0b8892017-02-15 14:13:52 -08001019 if ((flags&DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
1020 pw.println(prefix + "seinfo=" + seInfo);
1021 pw.println(prefix + "seinfoUser=" + seInfoUser);
Robert Craig0f40dc92013-03-25 06:33:03 -04001022 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001023 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001024 if ((flags&DUMP_FLAG_DETAILS) != 0) {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001025 pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1026 pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001027 if (sharedLibraryFiles != null) {
1028 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1029 }
Dianne Hackborn12527f92009-11-11 17:39:50 -08001030 }
Todd Kennedy89d60182016-03-11 11:18:32 -08001031 pw.println(prefix + "enabled=" + enabled
1032 + " minSdkVersion=" + minSdkVersion
1033 + " targetSdkVersion=" + targetSdkVersion
Todd Kennedy11e45072017-01-25 13:24:21 -08001034 + " versionCode=" + versionCode
1035 + " targetSandboxVersion=" + targetSandboxVersion);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001036 if ((flags&DUMP_FLAG_DETAILS) != 0) {
1037 if (manageSpaceActivityName != null) {
1038 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1039 }
1040 if (descriptionRes != 0) {
1041 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1042 }
1043 if (uiOptions != 0) {
1044 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1045 }
1046 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1047 if (fullBackupContent > 0) {
1048 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1049 } else {
1050 pw.println(prefix + "fullBackupContent="
1051 + (fullBackupContent < 0 ? "false" : "true"));
1052 }
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001053 if (networkSecurityConfigRes != 0) {
1054 pw.println(prefix + "networkSecurityConfigRes=0x"
1055 + Integer.toHexString(networkSecurityConfigRes));
1056 }
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001057 if (category != CATEGORY_UNDEFINED) {
1058 pw.println(prefix + "category=" + category);
1059 }
Matthew Williams303650c2015-04-17 18:22:51 -07001060 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001061 super.dumpBack(pw, prefix);
1062 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001063
1064 /**
1065 * @return true if "supportsRtl" has been set to true in the AndroidManifest
1066 * @hide
1067 */
1068 public boolean hasRtlSupport() {
1069 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1070 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -07001071
1072 /** {@hide} */
1073 public boolean hasCode() {
1074 return (flags & FLAG_HAS_CODE) != 0;
1075 }
1076
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001077 public static class DisplayNameComparator
1078 implements Comparator<ApplicationInfo> {
1079 public DisplayNameComparator(PackageManager pm) {
1080 mPM = pm;
1081 }
1082
1083 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1084 CharSequence sa = mPM.getApplicationLabel(aa);
1085 if (sa == null) {
1086 sa = aa.packageName;
1087 }
1088 CharSequence sb = mPM.getApplicationLabel(ab);
1089 if (sb == null) {
1090 sb = ab.packageName;
1091 }
1092
1093 return sCollator.compare(sa.toString(), sb.toString());
1094 }
1095
1096 private final Collator sCollator = Collator.getInstance();
1097 private PackageManager mPM;
1098 }
1099
1100 public ApplicationInfo() {
1101 }
1102
1103 public ApplicationInfo(ApplicationInfo orig) {
1104 super(orig);
1105 taskAffinity = orig.taskAffinity;
1106 permission = orig.permission;
1107 processName = orig.processName;
1108 className = orig.className;
1109 theme = orig.theme;
1110 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001111 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001112 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1113 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001114 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001115 volumeUuid = orig.volumeUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001116 scanSourceDir = orig.scanSourceDir;
1117 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001118 sourceDir = orig.sourceDir;
1119 publicSourceDir = orig.publicSourceDir;
Adam Lesinski4e862812016-11-21 16:02:24 -08001120 splitNames = orig.splitNames;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001121 splitSourceDirs = orig.splitSourceDirs;
1122 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Adam Lesinski4e862812016-11-21 16:02:24 -08001123 splitDependencies = orig.splitDependencies;
Kenny Root85387d72010-08-26 10:13:11 -07001124 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001125 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -07001126 nativeLibraryRootDir = orig.nativeLibraryRootDir;
1127 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001128 primaryCpuAbi = orig.primaryCpuAbi;
1129 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -08001130 resourceDirs = orig.resourceDirs;
Todd Kennedybe0b8892017-02-15 14:13:52 -08001131 seInfo = orig.seInfo;
1132 seInfoUser = orig.seInfoUser;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001133 sharedLibraryFiles = orig.sharedLibraryFiles;
1134 dataDir = orig.dataDir;
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001135 deviceProtectedDataDir = orig.deviceProtectedDataDir;
1136 credentialProtectedDataDir = orig.credentialProtectedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001137 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -08001138 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001139 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -08001140 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001141 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001142 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001143 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001144 manageSpaceActivityName = orig.manageSpaceActivityName;
1145 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -07001146 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -07001147 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -07001148 fullBackupContent = orig.fullBackupContent;
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001149 networkSecurityConfigRes = orig.networkSecurityConfigRes;
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001150 category = orig.category;
Todd Kennedy11e45072017-01-25 13:24:21 -08001151 targetSandboxVersion = orig.targetSandboxVersion;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001152 }
1153
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001154 public String toString() {
1155 return "ApplicationInfo{"
1156 + Integer.toHexString(System.identityHashCode(this))
1157 + " " + packageName + "}";
1158 }
1159
1160 public int describeContents() {
1161 return 0;
1162 }
1163
Adam Lesinski4e862812016-11-21 16:02:24 -08001164 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001165 public void writeToParcel(Parcel dest, int parcelableFlags) {
1166 super.writeToParcel(dest, parcelableFlags);
1167 dest.writeString(taskAffinity);
1168 dest.writeString(permission);
1169 dest.writeString(processName);
1170 dest.writeString(className);
1171 dest.writeInt(theme);
1172 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001173 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001174 dest.writeInt(requiresSmallestWidthDp);
1175 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001176 dest.writeInt(largestWidthLimitDp);
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001177 dest.writeString(volumeUuid);
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001178 dest.writeString(scanSourceDir);
1179 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001180 dest.writeString(sourceDir);
1181 dest.writeString(publicSourceDir);
Adam Lesinski4e862812016-11-21 16:02:24 -08001182 dest.writeStringArray(splitNames);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001183 dest.writeStringArray(splitSourceDirs);
1184 dest.writeStringArray(splitPublicSourceDirs);
Adam Lesinski4e862812016-11-21 16:02:24 -08001185 dest.writeSparseIntArray(splitDependencies);
Kenny Root85387d72010-08-26 10:13:11 -07001186 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001187 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -07001188 dest.writeString(nativeLibraryRootDir);
1189 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +01001190 dest.writeString(primaryCpuAbi);
1191 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -08001192 dest.writeStringArray(resourceDirs);
Todd Kennedybe0b8892017-02-15 14:13:52 -08001193 dest.writeString(seInfo);
1194 dest.writeString(seInfoUser);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001195 dest.writeStringArray(sharedLibraryFiles);
1196 dest.writeString(dataDir);
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001197 dest.writeString(deviceProtectedDataDir);
1198 dest.writeString(credentialProtectedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001199 dest.writeInt(uid);
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001200 dest.writeInt(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001201 dest.writeInt(targetSdkVersion);
Dianne Hackborn8472e612014-01-23 17:57:20 -08001202 dest.writeInt(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001203 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001204 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001205 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001206 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -07001207 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001208 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -07001209 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -07001210 dest.writeInt(fullBackupContent);
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001211 dest.writeInt(networkSecurityConfigRes);
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001212 dest.writeInt(category);
Todd Kennedy11e45072017-01-25 13:24:21 -08001213 dest.writeInt(targetSandboxVersion);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001214 }
1215
1216 public static final Parcelable.Creator<ApplicationInfo> CREATOR
1217 = new Parcelable.Creator<ApplicationInfo>() {
1218 public ApplicationInfo createFromParcel(Parcel source) {
1219 return new ApplicationInfo(source);
1220 }
1221 public ApplicationInfo[] newArray(int size) {
1222 return new ApplicationInfo[size];
1223 }
1224 };
1225
Adam Lesinski4e862812016-11-21 16:02:24 -08001226 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001227 private ApplicationInfo(Parcel source) {
1228 super(source);
1229 taskAffinity = source.readString();
1230 permission = source.readString();
1231 processName = source.readString();
1232 className = source.readString();
1233 theme = source.readInt();
1234 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001235 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001236 requiresSmallestWidthDp = source.readInt();
1237 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001238 largestWidthLimitDp = source.readInt();
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001239 volumeUuid = source.readString();
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001240 scanSourceDir = source.readString();
1241 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001242 sourceDir = source.readString();
1243 publicSourceDir = source.readString();
Adam Lesinski4e862812016-11-21 16:02:24 -08001244 splitNames = source.readStringArray();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001245 splitSourceDirs = source.readStringArray();
1246 splitPublicSourceDirs = source.readStringArray();
Adam Lesinski4e862812016-11-21 16:02:24 -08001247 splitDependencies = source.readSparseIntArray();
Kenny Root85387d72010-08-26 10:13:11 -07001248 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001249 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -07001250 nativeLibraryRootDir = source.readString();
1251 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001252 primaryCpuAbi = source.readString();
1253 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -08001254 resourceDirs = source.readStringArray();
Todd Kennedybe0b8892017-02-15 14:13:52 -08001255 seInfo = source.readString();
1256 seInfoUser = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001257 sharedLibraryFiles = source.readStringArray();
1258 dataDir = source.readString();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001259 deviceProtectedDataDir = source.readString();
1260 credentialProtectedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001261 uid = source.readInt();
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001262 minSdkVersion = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001263 targetSdkVersion = source.readInt();
Dianne Hackborn8472e612014-01-23 17:57:20 -08001264 versionCode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001265 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001266 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001267 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001268 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001269 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001270 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001271 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001272 fullBackupContent = source.readInt();
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001273 networkSecurityConfigRes = source.readInt();
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001274 category = source.readInt();
Todd Kennedy11e45072017-01-25 13:24:21 -08001275 targetSandboxVersion = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001276 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001277
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001278 /**
1279 * Retrieve the textual description of the application. This
1280 * will call back on the given PackageManager to load the description from
1281 * the application.
1282 *
1283 * @param pm A PackageManager from which the label can be loaded; usually
1284 * the PackageManager from which you originally retrieved this item.
1285 *
1286 * @return Returns a CharSequence containing the application's description.
1287 * If there is no description, null is returned.
1288 */
1289 public CharSequence loadDescription(PackageManager pm) {
1290 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001291 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001292 if (label != null) {
1293 return label;
1294 }
1295 }
1296 return null;
1297 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001298
1299 /**
1300 * Disable compatibility mode
1301 *
1302 * @hide
1303 */
1304 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001305 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001306 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001307 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001308 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001309
skuhne@google.com7e85eb02017-01-04 13:49:54 -08001310 /**
1311 * Is using compatibility mode for non densty aware legacy applications.
1312 *
1313 * @hide
1314 */
1315 public boolean usesCompatibilityMode() {
1316 return targetSdkVersion < DONUT ||
1317 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1318 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1319 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1320 }
1321
Jeff Sharkey15447792015-11-05 16:18:51 -08001322 /** {@hide} */
1323 public void initForUser(int userId) {
1324 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1325
1326 if ("android".equals(packageName)) {
1327 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1328 return;
1329 }
1330
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001331 deviceProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001332 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001333 .getAbsolutePath();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001334 credentialProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001335 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001336 .getAbsolutePath();
1337
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001338 if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1339 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1340 dataDir = deviceProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001341 } else {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001342 dataDir = credentialProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001343 }
1344 }
1345
Jeff Brown07330792010-03-30 19:57:08 -07001346 /**
1347 * @hide
1348 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001349 @Override
1350 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001351 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1352 && isPackageUnavailable(pm)) {
1353 return Resources.getSystem().getDrawable(
1354 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1355 }
1356 return pm.getDefaultActivityIcon();
1357 }
1358
1359 private boolean isPackageUnavailable(PackageManager pm) {
1360 try {
1361 return pm.getPackageInfo(packageName, 0) == null;
1362 } catch (NameNotFoundException ex) {
1363 return true;
1364 }
1365 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001366
Jeff Brown07330792010-03-30 19:57:08 -07001367 /**
1368 * @hide
1369 */
Fyodor Kupoloveeea67b2015-02-23 17:14:45 -08001370 public boolean isForwardLocked() {
1371 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1372 }
1373
1374 /**
1375 * @hide
1376 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001377 @TestApi
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001378 public boolean isSystemApp() {
1379 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1380 }
1381
1382 /**
1383 * @hide
1384 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001385 @TestApi
Svet Ganovadc1cf42015-06-15 16:36:24 -07001386 public boolean isPrivilegedApp() {
1387 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1388 }
1389
1390 /**
1391 * @hide
1392 */
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001393 public boolean isUpdatedSystemApp() {
1394 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1395 }
1396
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07001397 /** @hide */
1398 public boolean isInternal() {
1399 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1400 }
1401
1402 /** @hide */
1403 public boolean isExternalAsec() {
1404 return TextUtils.isEmpty(volumeUuid)
1405 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1406 }
1407
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001408 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001409 public boolean isDefaultToDeviceProtectedStorage() {
1410 return (privateFlags
1411 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
Jeff Sharkeye4697132016-02-06 19:46:15 -07001412 }
1413
1414 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001415 public boolean isDirectBootAware() {
1416 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001417 }
1418
Jeff Sharkey8924e872015-11-30 12:52:10 -07001419 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001420 public boolean isPartiallyDirectBootAware() {
1421 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkey8924e872015-11-30 12:52:10 -07001422 }
1423
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001424 /**
1425 * @hide
1426 */
Svetoslav Ganov096d3042017-01-30 16:34:13 -08001427 public boolean isInstantApp() {
Todd Kennedybe0b8892017-02-15 14:13:52 -08001428 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
Svet Ganov2acf0632015-11-24 19:10:59 -08001429 }
1430
1431 /**
1432 * @hide
1433 */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001434 public boolean isRequiredForSystemUser() {
1435 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1436 }
1437
1438 /**
Adam Lesinski4e862812016-11-21 16:02:24 -08001439 * Returns true if the app has declared in its manifest that it wants its split APKs to be
1440 * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
1441 * @hide
1442 */
1443 public boolean requestsIsolatedSplitLoading() {
1444 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
1445 }
1446
1447 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001448 * @hide
1449 */
Svet Ganov67882122016-12-11 16:36:34 -08001450 public boolean isStaticSharedLibrary() {
1451 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
1452 }
1453
1454 /**
1455 * @hide
1456 */
Jeff Brown07330792010-03-30 19:57:08 -07001457 @Override protected ApplicationInfo getApplicationInfo() {
1458 return this;
1459 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001460
1461 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1462 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1463 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1464 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1465 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1466 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1467
1468 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1469 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1470 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1471 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1472 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
Jeff Sharkeya3a43b02016-11-15 17:54:23 -07001473 /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001474}