blob: 0ec509e1164eb3caf07e8723d5636888adc5dd45 [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;
Mathew Inwood1c77a112018-08-14 14:06:26 +010025import android.annotation.UnsupportedAppUsage;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060026import android.content.Context;
Jeff Brown07330792010-03-30 19:57:08 -070027import android.content.pm.PackageManager.NameNotFoundException;
28import android.content.res.Resources;
29import android.graphics.drawable.Drawable;
Jeff Sharkey15447792015-11-05 16:18:51 -080030import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031import android.os.Parcel;
32import android.os.Parcelable;
Jeff Sharkey15447792015-11-05 16:18:51 -080033import android.os.UserHandle;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060034import android.os.storage.StorageManager;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070035import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036import android.util.Printer;
Adam Lesinski1665d0f2017-03-10 14:46:57 -080037import android.util.SparseArray;
Yi Jin148d7f42017-11-28 14:23:56 -080038import android.util.proto.ProtoOutputStream;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070040import com.android.internal.util.ArrayUtils;
Mathew Inwood4693a752018-02-20 16:04:25 +000041import com.android.server.SystemConfig;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070042
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070043import java.lang.annotation.Retention;
44import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070046import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080047import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070048import java.util.Objects;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060049import java.util.UUID;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050
51/**
52 * Information you can retrieve about a particular application. This
53 * corresponds to information collected from the AndroidManifest.xml's
54 * <application> tag.
55 */
56public class ApplicationInfo extends PackageItemInfo implements Parcelable {
57
58 /**
59 * Default task affinity of all activities in this application. See
60 * {@link ActivityInfo#taskAffinity} for more information. This comes
61 * from the "taskAffinity" attribute.
62 */
63 public String taskAffinity;
64
65 /**
66 * Optional name of a permission required to be able to access this
67 * application's components. From the "permission" attribute.
68 */
69 public String permission;
70
71 /**
72 * The name of the process this application should run in. From the
73 * "process" attribute or, if not set, the same as
74 * <var>packageName</var>.
75 */
76 public String processName;
77
78 /**
79 * Class implementing the Application object. From the "class"
80 * attribute.
81 */
82 public String className;
83
84 /**
85 * A style resource identifier (in the package's resources) of the
86 * description of an application. From the "description" attribute
87 * or, if not set, 0.
88 */
89 public int descriptionRes;
90
91 /**
92 * A style resource identifier (in the package's resources) of the
93 * default visual theme of the application. From the "theme" attribute
94 * or, if not set, 0.
95 */
96 public int theme;
97
98 /**
99 * Class implementing the Application's manage space
100 * functionality. From the "manageSpaceActivity"
101 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -0700102 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800103 */
104 public String manageSpaceActivityName;
105
106 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700107 * Class implementing the Application's backup functionality. From
108 * the "backupAgent" attribute. This is an optional attribute and
109 * will be null if the application does not specify it in its manifest.
110 *
111 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -0700112 */
113 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700114
115 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700116 * An optional attribute that indicates the app supports automatic backup of app data.
117 * <p>0 is the default and means the app's entire data folder + managed external storage will
118 * be backed up;
119 * Any negative value indicates the app does not support full-data backup, though it may still
120 * want to participate via the traditional key/value backup API;
121 * A positive number specifies an xml resource in which the application has defined its backup
122 * include/exclude criteria.
123 * <p>If android:allowBackup is set to false, this attribute is ignored.
124 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600125 * @see android.content.Context#getNoBackupFilesDir()
126 * @see #FLAG_ALLOW_BACKUP
Christopher Tate98fa6562015-05-14 13:20:10 -0700127 *
128 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700129 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100130 @UnsupportedAppUsage
Matthew Williams303650c2015-04-17 18:22:51 -0700131 public int fullBackupContent = 0;
132
133 /**
Adam Powell269248d2011-08-02 10:26:54 -0700134 * The default extra UI options for activities in this application.
135 * Set from the {@link android.R.attr#uiOptions} attribute in the
136 * activity's manifest.
137 */
138 public int uiOptions = 0;
139
140 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800141 * Value for {@link #flags}: if set, this application is installed in the
142 * device's system image.
143 */
144 public static final int FLAG_SYSTEM = 1<<0;
145
146 /**
147 * Value for {@link #flags}: set to true if this application would like to
148 * allow debugging of its
149 * code, even when installed on a non-development system. Comes
150 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
151 * android:debuggable} of the &lt;application&gt; tag.
152 */
153 public static final int FLAG_DEBUGGABLE = 1<<1;
154
155 /**
156 * Value for {@link #flags}: set to true if this application has code
157 * associated with it. Comes
158 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
159 * android:hasCode} of the &lt;application&gt; tag.
160 */
161 public static final int FLAG_HAS_CODE = 1<<2;
162
163 /**
164 * Value for {@link #flags}: set to true if this application is persistent.
165 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
166 * android:persistent} of the &lt;application&gt; tag.
167 */
168 public static final int FLAG_PERSISTENT = 1<<3;
169
170 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700171 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800172 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
173 * device is running in factory test mode.
174 */
175 public static final int FLAG_FACTORY_TEST = 1<<4;
176
177 /**
178 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
179 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
180 * android:allowTaskReparenting} of the &lt;application&gt; tag.
181 */
182 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
183
184 /**
185 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
186 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
187 * android:allowClearUserData} of the &lt;application&gt; tag.
188 */
189 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
190
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800191 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700192 * Value for {@link #flags}: this is set if this application has been
Kweku Adams8de29ca2016-01-22 12:30:26 -0800193 * installed as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194 */
195 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700196
197 /**
Svet Ganov354cd3c2015-12-17 11:35:04 -0800198 * Value for {@link #flags}: this is set if the application has specified
Dianne Hackborn7f205432009-07-28 00:13:47 -0700199 * {@link android.R.styleable#AndroidManifestApplication_testOnly
200 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700201 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700202 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700203
204 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700205 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700206 * reduced in size for smaller screens. Corresponds to
207 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
208 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700209 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700210 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
211
212 /**
213 * Value for {@link #flags}: true when the application's window can be
214 * displayed on normal screens. Corresponds to
215 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
216 * android:normalScreens}.
217 */
218 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
219
220 /**
221 * Value for {@link #flags}: true when the application's window can be
222 * increased in size for larger screens. Corresponds to
223 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700224 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700225 */
226 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700227
228 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700229 * Value for {@link #flags}: true when the application knows how to adjust
230 * its UI for different screen sizes. Corresponds to
231 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
232 * android:resizeable}.
233 */
234 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
235
236 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700237 * Value for {@link #flags}: true when the application knows how to
238 * accomodate different screen densities. Corresponds to
239 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
240 * android:anyDensity}.
241 */
242 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
243
244 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800245 * Value for {@link #flags}: set to true if this application would like to
246 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700247 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
248 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800249 */
250 public static final int FLAG_VM_SAFE_MODE = 1<<14;
251
252 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800253 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
254 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700255 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800256 * <p>Comes from the
257 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
258 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700259 */
Ben Cheng23085b72010-02-08 16:06:32 -0800260 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700261
262 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800263 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
264 * in memory following a full-system restore operation; <code>true</code> otherwise.
265 * Ordinarily, during a full system restore operation each application is shut down
266 * following execution of its agent's onRestore() method. Setting this attribute to
267 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700268 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800269 * <p>If
270 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
271 * is set to <code>false</code> or no
272 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700273 * is specified, this flag will be ignored.
274 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800275 * <p>Comes from the
276 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
277 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700278 */
Ben Cheng23085b72010-02-08 16:06:32 -0800279 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700280
281 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800282 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
283 * agent claims to be able to handle restore data even "from the future,"
284 * i.e. from versions of the application with a versionCode greater than
285 * the one currently installed on the device. <i>Use with caution!</i> By default
286 * this attribute is <code>false</code> and the Backup Manager will ensure that data
287 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700288 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800289 * <p>If
290 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
291 * is set to <code>false</code> or no
292 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700293 * is specified, this flag will be ignored.
294 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800295 * <p>Comes from the
296 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
297 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700298 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800299 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700300
Christopher Tate181fafa2009-05-14 11:12:14 -0700301 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700302 * Value for {@link #flags}: Set to true if the application is
303 * currently installed on external/removable/unprotected storage. Such
304 * applications may not be available if their storage is not currently
305 * mounted. When the storage it is on is not available, it will look like
306 * the application has been uninstalled (its .apk is no longer available)
307 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800308 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700309 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800310
311 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700312 * Value for {@link #flags}: true when the application's window can be
313 * increased in size for extra large screens. Corresponds to
314 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700315 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700316 */
317 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
318
319 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800320 * Value for {@link #flags}: true when the application has requested a
321 * large heap for its processes. Corresponds to
322 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
323 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600324 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800325 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600326
327 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800328 * Value for {@link #flags}: true if this application's package is in
329 * the stopped state.
330 */
331 public static final int FLAG_STOPPED = 1<<21;
332
333 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700334 * Value for {@link #flags}: true when the application is willing to support
335 * RTL (right to left). All activities will inherit this value.
336 *
337 * Set from the {@link android.R.attr#supportsRtl} attribute in the
338 * activity's manifest.
339 *
340 * Default value is false (no support for RTL).
341 */
342 public static final int FLAG_SUPPORTS_RTL = 1<<22;
343
344 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700345 * Value for {@link #flags}: true if the application is currently
346 * installed for the calling user.
347 */
348 public static final int FLAG_INSTALLED = 1<<23;
349
350 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700351 * Value for {@link #flags}: true if the application only has its
352 * data installed; the application package itself does not currently
353 * exist on the device.
354 */
355 public static final int FLAG_IS_DATA_ONLY = 1<<24;
356
357 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700358 * Value for {@link #flags}: true if the application was declared to be a
359 * game, or false if it is a non-game application.
360 *
361 * @deprecated use {@link #CATEGORY_GAME} instead.
Jose Lima12d0b4c2014-03-14 16:55:12 -0700362 */
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700363 @Deprecated
Jose Lima12d0b4c2014-03-14 16:55:12 -0700364 public static final int FLAG_IS_GAME = 1<<25;
365
366 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700367 * Value for {@link #flags}: {@code true} if the application asks that only
368 * full-data streaming backups of its data be performed even though it defines
369 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
370 * indicates that the app will manage its backed-up data via incremental
371 * key/value updates.
372 */
373 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
374
375 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700376 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
377 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
378 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
379 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700380 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
381 * traffic. Third-party libraries are encouraged to honor this flag as well.
382 *
Nate Fischer6a2a5412017-10-23 18:02:41 -0700383 * <p>NOTE: {@code WebView} honors this flag for applications targeting API level 26 and up.
Alex Klyubinfbf45992015-04-21 13:44:29 -0700384 *
Chad Brubaker2df5ba72016-04-11 13:31:24 -0700385 * <p>This flag is ignored on Android N and above if an Android Network Security Config is
386 * present.
387 *
Alex Klyubinfbf45992015-04-21 13:44:29 -0700388 * <p>This flag comes from
389 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
390 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700391 */
392 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
393
394 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700395 * When set installer extracts native libs from .apk files.
396 */
397 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
398
399 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700400 * Value for {@link #flags}: {@code true} when the application's rendering
401 * should be hardware accelerated.
402 */
403 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
404
405 /**
Andrei Stingaceanu1e283912015-11-26 15:26:28 +0000406 * Value for {@link #flags}: true if this application's package is in
407 * the suspended state.
408 */
409 public static final int FLAG_SUSPENDED = 1<<30;
410
411 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100412 * Value for {@link #flags}: true if code from this application will need to be
413 * loaded into other applications' processes. On devices that support multiple
414 * instruction sets, this implies the code might be loaded into a process that's
415 * using any of the devices supported instruction sets.
416 *
417 * <p> The system might treat such applications specially, for eg., by
418 * extracting the application's native libraries for all supported instruction
419 * sets or by compiling the application's dex code for all supported instruction
420 * sets.
421 */
422 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700423
424 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800425 * Flags associated with the application. Any combination of
426 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
427 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
428 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700429 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700430 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
431 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700432 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
433 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700434 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800435 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
436 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
437 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
438 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
439 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700440 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
441 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800442 */
443 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700444
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800445 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800446 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
447 * most purposes is considered as not installed.
448 * {@hide}
449 */
450 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
451
452 /**
453 * Value for {@link #privateFlags}: set to <code>true</code> if the application
454 * has reported that it is heavy-weight, and thus can not participate in
455 * the normal application lifecycle.
456 *
457 * <p>Comes from the
458 * android.R.styleable#AndroidManifestApplication_cantSaveState
459 * attribute of the &lt;application&gt; tag.
460 *
461 * {@hide}
462 */
463 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
464
465 /**
466 * Value for {@link #privateFlags}: Set to true if the application has been
467 * installed using the forward lock option.
468 *
469 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
470 *
471 * {@hide}
472 */
473 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
474
475 /**
476 * Value for {@link #privateFlags}: set to {@code true} if the application
477 * is permitted to hold privileged permissions.
478 *
479 * {@hide}
480 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100481 @UnsupportedAppUsage
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800482 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
483
484 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800485 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
486 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700487 *
488 * {@hide}
489 */
490 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
491
492 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600493 * When set, the default data storage directory for this app is pointed at
494 * the device-protected location.
Jeff Sharkey15447792015-11-05 16:18:51 -0800495 *
496 * @hide
497 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600498 public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800499
500 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600501 * When set, assume that all components under the given app are direct boot
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800502 * aware, unless otherwise specified.
503 *
504 * @hide
505 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600506 public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800507
508 /**
Todd Kennedybe0b8892017-02-15 14:13:52 -0800509 * Value for {@link #privateFlags}: {@code true} if the application is installed
510 * as instant app.
511 *
512 * @hide
Chad Brubaker4389c232016-11-04 14:50:50 -0700513 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800514 public static final int PRIVATE_FLAG_INSTANT = 1 << 7;
Chad Brubaker4389c232016-11-04 14:50:50 -0700515
516 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600517 * When set, at least one component inside this application is direct boot
518 * aware.
Jeff Sharkey8924e872015-11-30 12:52:10 -0700519 *
520 * @hide
521 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600522 public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
Jeff Sharkey8924e872015-11-30 12:52:10 -0700523
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800524
525 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800526 * When set, signals that the application is required for the system user and should not be
527 * uninstalled.
528 *
529 * @hide
530 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700531 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800532
533 /**
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700534 * When set, the application explicitly requested that its activities be resizeable by default.
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800535 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
536 *
537 * @hide
538 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700539 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE = 1 << 10;
540
541 /**
542 * When set, the application explicitly requested that its activities *not* be resizeable by
543 * default.
544 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
545 *
546 * @hide
547 */
548 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE = 1 << 11;
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700549
550 /**
551 * The application isn't requesting explicitly requesting for its activities to be resizeable or
552 * non-resizeable by default. So, we are making it activities resizeable by default based on the
553 * target SDK version of the app.
554 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
555 *
556 * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
557 * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
558 * where certain pre-N apps are forced to the resizeable.
559 *
560 * @hide
561 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700562 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION =
563 1 << 12;
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800564
565 /**
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800566 * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
567 * run full-data backup operations for the app even when it is in a
568 * foreground-equivalent run state. Defaults to {@code false} if unspecified.
569 * @hide
570 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700571 public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 13;
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800572
573 /**
Svet Ganov67882122016-12-11 16:36:34 -0800574 * Value for {@link #privateFlags}: {@code true} means this application
575 * contains a static shared library. Defaults to {@code false} if unspecified.
576 * @hide
577 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700578 public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 14;
Svet Ganov67882122016-12-11 16:36:34 -0800579
580 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700581 * Value for {@link #privateFlags}: When set, the application will only have its splits loaded
Adam Lesinski4e862812016-11-21 16:02:24 -0800582 * if they are required to load a component. Splits can be loaded on demand using the
583 * {@link Context#createContextForSplit(String)} API.
584 * @hide
585 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700586 public static final int PRIVATE_FLAG_ISOLATED_SPLIT_LOADING = 1 << 15;
Adam Lesinski4e862812016-11-21 16:02:24 -0800587
588 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700589 * Value for {@link #privateFlags}: When set, the application was installed as
590 * a virtual preload.
591 * @hide
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800592 */
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700593 public static final int PRIVATE_FLAG_VIRTUAL_PRELOAD = 1 << 16;
594
Svet Ganov087dce22017-09-07 15:42:16 -0700595 /**
Mathew Inwood9d895432018-04-04 16:08:21 +0100596 * Value for {@link #privateFlags}: whether this app is pre-installed on the
Svet Ganov087dce22017-09-07 15:42:16 -0700597 * OEM partition of the system image.
598 * @hide
599 */
600 public static final int PRIVATE_FLAG_OEM = 1 << 17;
601
Jiyong Park002fdbd2017-02-13 20:50:31 +0900602 /**
Mathew Inwood9d895432018-04-04 16:08:21 +0100603 * Value for {@link #privateFlags}: whether this app is pre-installed on the
Jiyong Park002fdbd2017-02-13 20:50:31 +0900604 * vendor partition of the system image.
605 * @hide
606 */
607 public static final int PRIVATE_FLAG_VENDOR = 1 << 18;
608
Jaekyun Seok1713d9e2018-01-12 21:47:26 +0900609 /**
Mathew Inwood9d895432018-04-04 16:08:21 +0100610 * Value for {@link #privateFlags}: whether this app is pre-installed on the
Jaekyun Seok1713d9e2018-01-12 21:47:26 +0900611 * product partition of the system image.
612 * @hide
613 */
614 public static final int PRIVATE_FLAG_PRODUCT = 1 << 19;
615
Mathew Inwood9d895432018-04-04 16:08:21 +0100616 /**
617 * Value for {@link #privateFlags}: whether this app is signed with the
618 * platform key.
619 * @hide
620 */
621 public static final int PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY = 1 << 20;
622
David Brazdilfa5e8362018-09-06 09:49:14 +0100623 /**
624 * Indicates whether this package requires access to non-SDK APIs.
625 * Only system apps and tests are allowed to use this property.
626 * @hide
627 */
628 public static final int PRIVATE_FLAG_USES_NON_SDK_API = 1 << 22;
629
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700630 /** @hide */
631 @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
Svet Ganov087dce22017-09-07 15:42:16 -0700632 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
633 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION,
634 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE,
635 PRIVATE_FLAG_BACKUP_IN_FOREGROUND,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700636 PRIVATE_FLAG_CANT_SAVE_STATE,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700637 PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE,
638 PRIVATE_FLAG_DIRECT_BOOT_AWARE,
Svet Ganov087dce22017-09-07 15:42:16 -0700639 PRIVATE_FLAG_FORWARD_LOCK,
640 PRIVATE_FLAG_HAS_DOMAIN_URLS,
641 PRIVATE_FLAG_HIDDEN,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700642 PRIVATE_FLAG_INSTANT,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700643 PRIVATE_FLAG_ISOLATED_SPLIT_LOADING,
Svet Ganov087dce22017-09-07 15:42:16 -0700644 PRIVATE_FLAG_OEM,
645 PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE,
646 PRIVATE_FLAG_PRIVILEGED,
Jaekyun Seok1713d9e2018-01-12 21:47:26 +0900647 PRIVATE_FLAG_PRODUCT,
Svet Ganov087dce22017-09-07 15:42:16 -0700648 PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER,
Mathew Inwood9d895432018-04-04 16:08:21 +0100649 PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY,
Svet Ganov087dce22017-09-07 15:42:16 -0700650 PRIVATE_FLAG_STATIC_SHARED_LIBRARY,
Jiyong Park002fdbd2017-02-13 20:50:31 +0900651 PRIVATE_FLAG_VENDOR,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700652 PRIVATE_FLAG_VIRTUAL_PRELOAD,
653 })
654 @Retention(RetentionPolicy.SOURCE)
655 public @interface ApplicationInfoPrivateFlags {}
656
657 /**
658 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
659 * @hide
660 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100661 @UnsupportedAppUsage
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700662 public @ApplicationInfoPrivateFlags int privateFlags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800663
664 /**
Clara Bayarri4b5a4d22017-01-27 20:15:45 +0000665 * @hide
666 */
667 public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
668
669 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700670 * The required smallest screen width the application can run on. If 0,
671 * nothing has been specified. Comes from
672 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
673 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
674 */
675 public int requiresSmallestWidthDp = 0;
676
677 /**
678 * The maximum smallest screen width the application is designed for. If 0,
679 * nothing has been specified. Comes from
680 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
681 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
682 */
683 public int compatibleWidthLimitDp = 0;
684
685 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700686 * The maximum smallest screen width the application will work on. If 0,
687 * nothing has been specified. Comes from
688 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
689 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
690 */
691 public int largestWidthLimitDp = 0;
692
Jeff Sharkey61128602017-01-26 17:07:35 -0700693 /**
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700694 * Value indicating the maximum aspect ratio the application supports.
695 * <p>
696 * 0 means unset.
697 * @See {@link android.R.attr#maxAspectRatio}.
698 * @hide
699 */
700 public float maxAspectRatio;
701
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600702 /** @removed */
703 @Deprecated
704 public String volumeUuid;
705
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700706 /**
Jeff Sharkey61128602017-01-26 17:07:35 -0700707 * UUID of the storage volume on which this application is being hosted. For
708 * apps hosted on the default internal storage at
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600709 * {@link Environment#getDataDirectory()}, the UUID value is
710 * {@link StorageManager#UUID_DEFAULT}.
Jeff Sharkey61128602017-01-26 17:07:35 -0700711 */
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600712 public UUID storageUuid;
Jeff Sharkey61128602017-01-26 17:07:35 -0700713
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700714 /** {@hide} */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100715 @UnsupportedAppUsage
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700716 public String scanSourceDir;
717 /** {@hide} */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100718 @UnsupportedAppUsage
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700719 public String scanPublicSourceDir;
720
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700721 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700722 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800723 */
724 public String sourceDir;
725
726 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700727 * Full path to the publicly available parts of {@link #sourceDir},
728 * including resources and manifest. This may be different from
729 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800730 */
731 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700732
733 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800734 * The names of all installed split APKs, ordered lexicographically.
735 */
736 public String[] splitNames;
737
738 /**
739 * Full paths to zero or more split APKs, indexed by the same order as {@link #splitNames}.
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700740 */
741 public String[] splitSourceDirs;
742
743 /**
744 * Full path to the publicly available parts of {@link #splitSourceDirs},
745 * including resources and manifest. This may be different from
746 * {@link #splitSourceDirs} if an application is forward locked.
Adam Lesinski4e862812016-11-21 16:02:24 -0800747 *
748 * @see #splitSourceDirs
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700749 */
750 public String[] splitPublicSourceDirs;
751
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800752 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800753 * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
754 *
755 * Available since platform version O.
756 *
757 * Only populated if the application opts in to isolated split loading via the
758 * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
759 * AndroidManifest.xml.
760 *
761 * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
762 * and {@link #splitPublicSourceDirs} arrays.
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800763 * Each key represents a split and its value is an array of splits. The first element of this
764 * array is the parent split, and the rest are configuration splits. These configuration splits
765 * have no dependencies themselves.
Adam Lesinski4e862812016-11-21 16:02:24 -0800766 * Cycles do not exist because they are illegal and screened for during installation.
767 *
768 * May be null if no splits are installed, or if no dependencies exist between them.
Calin Juravleda098152017-09-01 17:30:01 -0700769 *
770 * NOTE: Any change to the way split dependencies are stored must update the logic that
771 * creates the class loader context for dexopt (DexoptUtils#getClassLoaderContexts).
772 *
Adam Lesinski4e862812016-11-21 16:02:24 -0800773 * @hide
774 */
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800775 public SparseArray<int[]> splitDependencies;
Adam Lesinski4e862812016-11-21 16:02:24 -0800776
777 /**
778 * Full paths to the locations of extra resource packages (runtime overlays)
779 * this application uses. This field is only used if there are extra resource
780 * packages, otherwise it is null.
781 *
Kenny Rootace5a3f2010-02-05 12:59:28 -0800782 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800783 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100784 @UnsupportedAppUsage
Kenny Rootd1ab0162010-01-21 17:27:14 -0800785 public String[] resourceDirs;
786
787 /**
Jeff Vander Stoepcab36392018-03-06 15:52:22 -0800788 * String retrieved from the seinfo tag found in selinux policy. This value can be set through
789 * the mac_permissions.xml policy construct. This value is used for setting an SELinux security
790 * context on the process as well as its data directory.
Robert Craig0f40dc92013-03-25 06:33:03 -0400791 *
792 * {@hide}
793 */
Jeff Vander Stoepcab36392018-03-06 15:52:22 -0800794 public String seInfo;
Todd Kennedybe0b8892017-02-15 14:13:52 -0800795
796 /**
797 * The seinfo tag generated per-user. This value may change based upon the
798 * user's configuration. For example, when an instant app is installed for
799 * a user. It is an error if this field is ever {@code null} when trying to
800 * start a new process.
801 * <p>NOTE: We need to separate this out because we modify per-user values
802 * multiple times. This needs to be refactored since we're performing more
803 * work than necessary and these values should only be set once. When that
804 * happens, we can merge the per-user value with the seInfo state above.
805 *
806 * {@hide}
807 */
808 public String seInfoUser;
Robert Craig0f40dc92013-03-25 06:33:03 -0400809
810 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800811 * Paths to all shared libraries this application is linked against. This
812 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
813 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
814 * the structure.
815 */
816 public String[] sharedLibraryFiles;
817
818 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700819 * Full path to the default directory assigned to the package for its
820 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800821 */
822 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700823
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700824 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600825 * Full path to the device-protected directory assigned to the package for
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700826 * its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600827 *
828 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700829 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600830 public String deviceProtectedDataDir;
831
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700832 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600833 * Full path to the credential-protected directory assigned to the package
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700834 * for its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600835 *
836 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700837 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600838 @SystemApi
839 public String credentialProtectedDataDir;
840
Kenny Root85387d72010-08-26 10:13:11 -0700841 /**
842 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700843 */
844 public String nativeLibraryDir;
845
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800846 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100847 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
848 * are stored, if present.
849 *
850 * The main reason this exists is for bundled multi-arch apps, where
851 * it's not trivial to calculate the location of libs for the secondary abi
852 * given the location of the primary.
853 *
854 * TODO: Change the layout of bundled installs so that we can use
855 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
856 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
857 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
858 *
859 * @hide
860 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100861 @UnsupportedAppUsage
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100862 public String secondaryNativeLibraryDir;
863
864 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700865 * The root path where unpacked native libraries are stored.
866 * <p>
867 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
868 * placed in ISA-specific subdirectories under this path, otherwise the
869 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100870 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700871 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100872 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100873 @UnsupportedAppUsage
Jeff Sharkey84f12942014-07-10 17:48:11 -0700874 public String nativeLibraryRootDir;
875
876 /**
877 * Flag indicating that ISA must be appended to
878 * {@link #nativeLibraryRootDir} to be useful.
879 *
880 * @hide
881 */
882 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100883
884 /**
885 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100886 * of the native JNI libraries the application bundles. Will be {@code null}
887 * if this application does not require any particular ABI.
888 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100889 * If non-null, the application will always be launched with this ABI.
890 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100891 * {@hide}
892 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100893 @UnsupportedAppUsage
Narayan Kamathff110bd2014-07-04 18:30:45 +0100894 public String primaryCpuAbi;
895
896 /**
897 * The secondary ABI for this application. Might be non-null for multi-arch
898 * installs. The application itself never uses this ABI, but other applications that
899 * use its code might.
900 *
901 * {@hide}
902 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100903 @UnsupportedAppUsage
Narayan Kamathff110bd2014-07-04 18:30:45 +0100904 public String secondaryCpuAbi;
905
906 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800907 * The kernel user-ID that has been assigned to this application;
908 * currently this is not a unique ID (multiple applications can have
909 * the same uid).
910 */
911 public int uid;
912
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700913 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800914 * The minimum SDK version this application can run on. It will not run
915 * on earlier versions.
916 */
Todd Kennedy6e2e7f52016-05-02 14:56:45 -0700917 public int minSdkVersion;
Todd Kennedy89d60182016-03-11 11:18:32 -0800918
919 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700920 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700921 * versions, but it knows how to work with any new behavior added at this
922 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
923 * if this is a development build and the app is targeting that. You should
924 * compare that this number is >= the SDK version number at which your
925 * behavior was introduced.
926 */
927 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800928
929 /**
930 * The app's declared version code.
931 * @hide
932 */
Patrick Baumannc2def582018-04-04 12:14:15 -0700933 public long longVersionCode;
934
935 /**
936 * An integer representation of the app's declared version code. This is being left in place as
937 * some apps were using reflection to access it before the move to long in
938 * {@link android.os.Build.VERSION_CODES#P}
939 * @deprecated Use {@link #longVersionCode} instead.
940 * @hide
941 */
942 @Deprecated
Mathew Inwood1c77a112018-08-14 14:06:26 +0100943 @UnsupportedAppUsage
Patrick Baumannc2def582018-04-04 12:14:15 -0700944 public int versionCode;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800945
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700946 /**
Alan Viveretteb6a25732017-11-21 14:49:24 -0500947 * The user-visible SDK version (ex. 26) of the framework against which the application claims
948 * to have been compiled, or {@code 0} if not specified.
949 * <p>
950 * This property is the compile-time equivalent of
951 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.SDK_INT}.
952 *
953 * @hide For platform use only; we don't expect developers to need to read this value.
954 */
955 public int compileSdkVersion;
956
957 /**
958 * The development codename (ex. "O", "REL") of the framework against which the application
959 * claims to have been compiled, or {@code null} if not specified.
960 * <p>
961 * This property is the compile-time equivalent of
962 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
963 *
964 * @hide For platform use only; we don't expect developers to need to read this value.
965 */
966 @Nullable
967 public String compileSdkVersionCodename;
968
969 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800970 * When false, indicates that all components within this application are
971 * considered disabled, regardless of their individually set enabled status.
972 */
973 public boolean enabled = true;
974
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700975 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700976 * For convenient access to the current enabled setting of this app.
977 * @hide
978 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100979 @UnsupportedAppUsage
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700980 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
981
982 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700983 * For convenient access to package's install location.
984 * @hide
985 */
Mathew Inwood1c77a112018-08-14 14:06:26 +0100986 @UnsupportedAppUsage
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700987 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700988
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700989 /**
990 * Resource file providing the application's Network Security Config.
991 * @hide
992 */
993 public int networkSecurityConfigRes;
994
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700995 /**
Todd Kennedy11e45072017-01-25 13:24:21 -0800996 * Version of the sandbox the application wants to run in.
997 * @hide
998 */
Patrick Baumann159cd022018-01-11 13:25:05 -0800999 @SystemApi
Todd Kennedy11e45072017-01-25 13:24:21 -08001000 public int targetSandboxVersion;
1001
1002 /**
Jason Monka80bfb52017-11-16 17:15:37 -05001003 * The factory of this package, as specified by the &lt;manifest&gt;
1004 * tag's {@link android.R.styleable#AndroidManifestApplication_appComponentFactory}
1005 * attribute.
1006 */
1007 public String appComponentFactory;
1008
1009 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001010 * The category of this app. Categories are used to cluster multiple apps
1011 * together into meaningful groups, such as when summarizing battery,
1012 * network, or disk usage. Apps should only define this value when they fit
1013 * well into one of the specific categories.
1014 * <p>
1015 * Set from the {@link android.R.attr#appCategory} attribute in the
1016 * manifest. If the manifest doesn't define a category, this value may have
1017 * been provided by the installer via
1018 * {@link PackageManager#setApplicationCategoryHint(String, int)}.
1019 */
1020 public @Category int category = CATEGORY_UNDEFINED;
1021
1022 /** {@hide} */
Jeff Sharkey4347f812017-04-21 12:08:39 -06001023 @IntDef(prefix = { "CATEGORY_" }, value = {
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001024 CATEGORY_UNDEFINED,
1025 CATEGORY_GAME,
1026 CATEGORY_AUDIO,
1027 CATEGORY_VIDEO,
1028 CATEGORY_IMAGE,
1029 CATEGORY_SOCIAL,
1030 CATEGORY_NEWS,
1031 CATEGORY_MAPS,
1032 CATEGORY_PRODUCTIVITY
1033 })
1034 @Retention(RetentionPolicy.SOURCE)
1035 public @interface Category {
1036 }
1037
1038 /**
1039 * Value when category is undefined.
1040 *
1041 * @see #category
1042 */
1043 public static final int CATEGORY_UNDEFINED = -1;
1044
1045 /**
1046 * Category for apps which are primarily games.
1047 *
1048 * @see #category
1049 */
1050 public static final int CATEGORY_GAME = 0;
1051
1052 /**
1053 * Category for apps which primarily work with audio or music, such as music
1054 * players.
1055 *
1056 * @see #category
1057 */
1058 public static final int CATEGORY_AUDIO = 1;
1059
1060 /**
1061 * Category for apps which primarily work with video or movies, such as
1062 * streaming video apps.
1063 *
1064 * @see #category
1065 */
1066 public static final int CATEGORY_VIDEO = 2;
1067
1068 /**
1069 * Category for apps which primarily work with images or photos, such as
1070 * camera or gallery apps.
1071 *
1072 * @see #category
1073 */
1074 public static final int CATEGORY_IMAGE = 3;
1075
1076 /**
1077 * Category for apps which are primarily social apps, such as messaging,
Jeff Sharkeyd2b69102017-03-21 19:40:38 -06001078 * communication, email, or social network apps.
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001079 *
1080 * @see #category
1081 */
1082 public static final int CATEGORY_SOCIAL = 4;
1083
1084 /**
1085 * Category for apps which are primarily news apps, such as newspapers,
1086 * magazines, or sports apps.
1087 *
1088 * @see #category
1089 */
1090 public static final int CATEGORY_NEWS = 5;
1091
1092 /**
1093 * Category for apps which are primarily maps apps, such as navigation apps.
1094 *
1095 * @see #category
1096 */
1097 public static final int CATEGORY_MAPS = 6;
1098
1099 /**
1100 * Category for apps which are primarily productivity apps, such as cloud
1101 * storage or workplace apps.
1102 *
1103 * @see #category
1104 */
1105 public static final int CATEGORY_PRODUCTIVITY = 7;
1106
1107 /**
1108 * Return a concise, localized title for the given
1109 * {@link ApplicationInfo#category} value, or {@code null} for unknown
1110 * values such as {@link #CATEGORY_UNDEFINED}.
1111 *
1112 * @see #category
1113 */
1114 public static CharSequence getCategoryTitle(Context context, @Category int category) {
1115 switch (category) {
1116 case ApplicationInfo.CATEGORY_GAME:
1117 return context.getText(com.android.internal.R.string.app_category_game);
1118 case ApplicationInfo.CATEGORY_AUDIO:
1119 return context.getText(com.android.internal.R.string.app_category_audio);
1120 case ApplicationInfo.CATEGORY_VIDEO:
1121 return context.getText(com.android.internal.R.string.app_category_video);
1122 case ApplicationInfo.CATEGORY_IMAGE:
1123 return context.getText(com.android.internal.R.string.app_category_image);
1124 case ApplicationInfo.CATEGORY_SOCIAL:
1125 return context.getText(com.android.internal.R.string.app_category_social);
1126 case ApplicationInfo.CATEGORY_NEWS:
1127 return context.getText(com.android.internal.R.string.app_category_news);
1128 case ApplicationInfo.CATEGORY_MAPS:
1129 return context.getText(com.android.internal.R.string.app_category_maps);
1130 case ApplicationInfo.CATEGORY_PRODUCTIVITY:
1131 return context.getText(com.android.internal.R.string.app_category_productivity);
1132 default:
1133 return null;
1134 }
1135 }
1136
Narayan Kamathf9419f02017-06-15 11:35:38 +01001137 /** @hide */
1138 public String classLoaderName;
1139
1140 /** @hide */
1141 public String[] splitClassLoaderNames;
1142
Rhed Jaoc19da782018-06-13 11:16:16 +08001143 /** @hide */
1144 public boolean hiddenUntilInstalled;
1145
Mathew Inwoode3299532018-02-22 13:19:53 +00001146 /**
1147 * Represents the default policy. The actual policy used will depend on other properties of
1148 * the application, e.g. the target SDK version.
1149 * @hide
1150 */
1151 public static final int HIDDEN_API_ENFORCEMENT_DEFAULT = -1;
1152 /**
1153 * No API enforcement; the app can access the entire internal private API. Only for use by
1154 * system apps.
1155 * @hide
1156 */
David Brazdildf1c7dc2018-10-26 16:23:59 +01001157 public static final int HIDDEN_API_ENFORCEMENT_DISABLED = 0;
Mathew Inwoode3299532018-02-22 13:19:53 +00001158 /**
Mathew Inwooda6d02fb2018-04-05 15:44:20 +01001159 * No API enforcement, but enable the detection logic and warnings. Observed behaviour is the
David Brazdildf1c7dc2018-10-26 16:23:59 +01001160 * same as {@link #HIDDEN_API_ENFORCEMENT_DISABLED} but you may see warnings in the log when
1161 * APIs are accessed.
Mathew Inwoode3299532018-02-22 13:19:53 +00001162 * @hide
1163 * */
Mathew Inwooda6d02fb2018-04-05 15:44:20 +01001164 public static final int HIDDEN_API_ENFORCEMENT_JUST_WARN = 1;
Mathew Inwoode3299532018-02-22 13:19:53 +00001165 /**
1166 * Dark grey list enforcement. Enforces the dark grey and black lists
1167 * @hide
1168 */
David Brazdildf1c7dc2018-10-26 16:23:59 +01001169 public static final int HIDDEN_API_ENFORCEMENT_ENABLED = 2;
Mathew Inwoode3299532018-02-22 13:19:53 +00001170
David Brazdildf1c7dc2018-10-26 16:23:59 +01001171 private static final int HIDDEN_API_ENFORCEMENT_MIN = HIDDEN_API_ENFORCEMENT_DEFAULT;
1172 private static final int HIDDEN_API_ENFORCEMENT_MAX = HIDDEN_API_ENFORCEMENT_ENABLED;
Mathew Inwoode3299532018-02-22 13:19:53 +00001173
1174 /**
1175 * Values in this IntDef MUST be kept in sync with enum hiddenapi::EnforcementPolicy in
1176 * art/runtime/hidden_api.h
1177 * @hide
1178 */
1179 @IntDef(prefix = { "HIDDEN_API_ENFORCEMENT_" }, value = {
1180 HIDDEN_API_ENFORCEMENT_DEFAULT,
David Brazdildf1c7dc2018-10-26 16:23:59 +01001181 HIDDEN_API_ENFORCEMENT_DISABLED,
Mathew Inwooda6d02fb2018-04-05 15:44:20 +01001182 HIDDEN_API_ENFORCEMENT_JUST_WARN,
David Brazdildf1c7dc2018-10-26 16:23:59 +01001183 HIDDEN_API_ENFORCEMENT_ENABLED,
Mathew Inwoode3299532018-02-22 13:19:53 +00001184 })
1185 @Retention(RetentionPolicy.SOURCE)
1186 public @interface HiddenApiEnforcementPolicy {}
1187
Mathew Inwood1ab30252018-04-03 14:47:26 +01001188 /** @hide */
1189 public static boolean isValidHiddenApiEnforcementPolicy(int policy) {
David Brazdildf1c7dc2018-10-26 16:23:59 +01001190 return policy >= HIDDEN_API_ENFORCEMENT_MIN && policy <= HIDDEN_API_ENFORCEMENT_MAX;
Mathew Inwoode3299532018-02-22 13:19:53 +00001191 }
1192
1193 private int mHiddenApiPolicy = HIDDEN_API_ENFORCEMENT_DEFAULT;
1194
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001195 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001196 dump(pw, prefix, DUMP_FLAG_ALL);
1197 }
1198
1199 /** @hide */
Yohei Yukawa8f272172017-08-31 00:26:01 -07001200 public void dump(Printer pw, String prefix, int dumpFlags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001201 super.dumpFront(pw, prefix);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001202 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -08001203 pw.println(prefix + "className=" + className);
1204 }
1205 if (permission != null) {
1206 pw.println(prefix + "permission=" + permission);
1207 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001208 pw.println(prefix + "processName=" + processName);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001209 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001210 pw.println(prefix + "taskAffinity=" + taskAffinity);
1211 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001212 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001213 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -07001214 + " theme=0x" + Integer.toHexString(theme));
Yohei Yukawa8f272172017-08-31 00:26:01 -07001215 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001216 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1217 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1218 + " largestWidthLimitDp=" + largestWidthLimitDp);
1219 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001220 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001221 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -07001222 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1223 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001224 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1225 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1226 }
1227 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1228 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1229 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1230 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001231 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -08001232 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -07001233 }
Yohei Yukawa8f272172017-08-31 00:26:01 -07001234 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
Todd Kennedybe0b8892017-02-15 14:13:52 -08001235 pw.println(prefix + "seinfo=" + seInfo);
1236 pw.println(prefix + "seinfoUser=" + seInfoUser);
Robert Craig0f40dc92013-03-25 06:33:03 -04001237 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001238 pw.println(prefix + "dataDir=" + dataDir);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001239 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001240 pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1241 pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001242 if (sharedLibraryFiles != null) {
1243 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1244 }
Dianne Hackborn12527f92009-11-11 17:39:50 -08001245 }
Narayan Kamathf9419f02017-06-15 11:35:38 +01001246 if (classLoaderName != null) {
1247 pw.println(prefix + "classLoaderName=" + classLoaderName);
1248 }
1249 if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1250 pw.println(prefix + "splitClassLoaderNames=" + Arrays.toString(splitClassLoaderNames));
1251 }
1252
Todd Kennedy89d60182016-03-11 11:18:32 -08001253 pw.println(prefix + "enabled=" + enabled
1254 + " minSdkVersion=" + minSdkVersion
1255 + " targetSdkVersion=" + targetSdkVersion
Patrick Baumannc2def582018-04-04 12:14:15 -07001256 + " versionCode=" + longVersionCode
Todd Kennedy11e45072017-01-25 13:24:21 -08001257 + " targetSandboxVersion=" + targetSandboxVersion);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001258 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001259 if (manageSpaceActivityName != null) {
1260 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1261 }
1262 if (descriptionRes != 0) {
1263 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1264 }
1265 if (uiOptions != 0) {
1266 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1267 }
1268 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1269 if (fullBackupContent > 0) {
1270 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1271 } else {
1272 pw.println(prefix + "fullBackupContent="
1273 + (fullBackupContent < 0 ? "false" : "true"));
1274 }
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001275 if (networkSecurityConfigRes != 0) {
1276 pw.println(prefix + "networkSecurityConfigRes=0x"
1277 + Integer.toHexString(networkSecurityConfigRes));
1278 }
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001279 if (category != CATEGORY_UNDEFINED) {
1280 pw.println(prefix + "category=" + category);
1281 }
Mathew Inwoode3299532018-02-22 13:19:53 +00001282 pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
David Brazdilfa5e8362018-09-06 09:49:14 +01001283 pw.println(prefix + "usesNonSdkApi=" + usesNonSdkApi());
Matthew Williams303650c2015-04-17 18:22:51 -07001284 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001285 super.dumpBack(pw, prefix);
1286 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001287
Yi Jin148d7f42017-11-28 14:23:56 -08001288 /** {@hide} */
1289 public void writeToProto(ProtoOutputStream proto, long fieldId, int dumpFlags) {
1290 long token = proto.start(fieldId);
1291 super.writeToProto(proto, ApplicationInfoProto.PACKAGE);
1292 proto.write(ApplicationInfoProto.PERMISSION, permission);
1293 proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
1294 proto.write(ApplicationInfoProto.UID, uid);
1295 proto.write(ApplicationInfoProto.FLAGS, flags);
1296 proto.write(ApplicationInfoProto.PRIVATE_FLAGS, privateFlags);
1297 proto.write(ApplicationInfoProto.THEME, theme);
1298 proto.write(ApplicationInfoProto.SOURCE_DIR, sourceDir);
1299 if (!Objects.equals(sourceDir, publicSourceDir)) {
1300 proto.write(ApplicationInfoProto.PUBLIC_SOURCE_DIR, publicSourceDir);
1301 }
1302 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1303 for (String dir : splitSourceDirs) {
1304 proto.write(ApplicationInfoProto.SPLIT_SOURCE_DIRS, dir);
1305 }
1306 }
1307 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1308 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1309 for (String dir : splitPublicSourceDirs) {
1310 proto.write(ApplicationInfoProto.SPLIT_PUBLIC_SOURCE_DIRS, dir);
1311 }
1312 }
1313 if (resourceDirs != null) {
1314 for (String dir : resourceDirs) {
1315 proto.write(ApplicationInfoProto.RESOURCE_DIRS, dir);
1316 }
1317 }
1318 proto.write(ApplicationInfoProto.DATA_DIR, dataDir);
1319 proto.write(ApplicationInfoProto.CLASS_LOADER_NAME, classLoaderName);
1320 if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1321 for (String name : splitClassLoaderNames) {
1322 proto.write(ApplicationInfoProto.SPLIT_CLASS_LOADER_NAMES, name);
1323 }
1324 }
1325
1326 long versionToken = proto.start(ApplicationInfoProto.VERSION);
1327 proto.write(ApplicationInfoProto.Version.ENABLED, enabled);
1328 proto.write(ApplicationInfoProto.Version.MIN_SDK_VERSION, minSdkVersion);
1329 proto.write(ApplicationInfoProto.Version.TARGET_SDK_VERSION, targetSdkVersion);
Patrick Baumannc2def582018-04-04 12:14:15 -07001330 proto.write(ApplicationInfoProto.Version.VERSION_CODE, longVersionCode);
Yi Jin148d7f42017-11-28 14:23:56 -08001331 proto.write(ApplicationInfoProto.Version.TARGET_SANDBOX_VERSION, targetSandboxVersion);
1332 proto.end(versionToken);
1333
1334 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1335 long detailToken = proto.start(ApplicationInfoProto.DETAIL);
1336 if (className != null) {
1337 proto.write(ApplicationInfoProto.Detail.CLASS_NAME, className);
1338 }
1339 proto.write(ApplicationInfoProto.Detail.TASK_AFFINITY, taskAffinity);
1340 proto.write(ApplicationInfoProto.Detail.REQUIRES_SMALLEST_WIDTH_DP,
1341 requiresSmallestWidthDp);
1342 proto.write(ApplicationInfoProto.Detail.COMPATIBLE_WIDTH_LIMIT_DP,
1343 compatibleWidthLimitDp);
1344 proto.write(ApplicationInfoProto.Detail.LARGEST_WIDTH_LIMIT_DP,
1345 largestWidthLimitDp);
1346 if (seInfo != null) {
1347 proto.write(ApplicationInfoProto.Detail.SEINFO, seInfo);
1348 proto.write(ApplicationInfoProto.Detail.SEINFO_USER, seInfoUser);
1349 }
1350 proto.write(ApplicationInfoProto.Detail.DEVICE_PROTECTED_DATA_DIR,
1351 deviceProtectedDataDir);
1352 proto.write(ApplicationInfoProto.Detail.CREDENTIAL_PROTECTED_DATA_DIR,
1353 credentialProtectedDataDir);
1354 if (sharedLibraryFiles != null) {
1355 for (String f : sharedLibraryFiles) {
1356 proto.write(ApplicationInfoProto.Detail.SHARED_LIBRARY_FILES, f);
1357 }
1358 }
1359 if (manageSpaceActivityName != null) {
1360 proto.write(ApplicationInfoProto.Detail.MANAGE_SPACE_ACTIVITY_NAME,
1361 manageSpaceActivityName);
1362 }
1363 if (descriptionRes != 0) {
1364 proto.write(ApplicationInfoProto.Detail.DESCRIPTION_RES, descriptionRes);
1365 }
1366 if (uiOptions != 0) {
1367 proto.write(ApplicationInfoProto.Detail.UI_OPTIONS, uiOptions);
1368 }
1369 proto.write(ApplicationInfoProto.Detail.SUPPORTS_RTL, hasRtlSupport());
1370 if (fullBackupContent > 0) {
1371 proto.write(ApplicationInfoProto.Detail.CONTENT, "@xml/" + fullBackupContent);
1372 } else {
1373 proto.write(ApplicationInfoProto.Detail.IS_FULL_BACKUP, fullBackupContent == 0);
1374 }
1375 if (networkSecurityConfigRes != 0) {
1376 proto.write(ApplicationInfoProto.Detail.NETWORK_SECURITY_CONFIG_RES,
1377 networkSecurityConfigRes);
1378 }
1379 if (category != CATEGORY_UNDEFINED) {
1380 proto.write(ApplicationInfoProto.Detail.CATEGORY, category);
1381 }
1382 proto.end(detailToken);
1383 }
1384 proto.end(token);
1385 }
1386
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001387 /**
1388 * @return true if "supportsRtl" has been set to true in the AndroidManifest
1389 * @hide
1390 */
Mathew Inwood1c77a112018-08-14 14:06:26 +01001391 @UnsupportedAppUsage
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001392 public boolean hasRtlSupport() {
1393 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1394 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -07001395
1396 /** {@hide} */
1397 public boolean hasCode() {
1398 return (flags & FLAG_HAS_CODE) != 0;
1399 }
1400
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001401 public static class DisplayNameComparator
1402 implements Comparator<ApplicationInfo> {
1403 public DisplayNameComparator(PackageManager pm) {
1404 mPM = pm;
1405 }
1406
1407 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1408 CharSequence sa = mPM.getApplicationLabel(aa);
1409 if (sa == null) {
1410 sa = aa.packageName;
1411 }
1412 CharSequence sb = mPM.getApplicationLabel(ab);
1413 if (sb == null) {
1414 sb = ab.packageName;
1415 }
1416
1417 return sCollator.compare(sa.toString(), sb.toString());
1418 }
1419
Mathew Inwood1c77a112018-08-14 14:06:26 +01001420 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001421 private final Collator sCollator = Collator.getInstance();
Mathew Inwood1c77a112018-08-14 14:06:26 +01001422 @UnsupportedAppUsage
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001423 private PackageManager mPM;
1424 }
1425
1426 public ApplicationInfo() {
1427 }
1428
1429 public ApplicationInfo(ApplicationInfo orig) {
1430 super(orig);
1431 taskAffinity = orig.taskAffinity;
1432 permission = orig.permission;
1433 processName = orig.processName;
1434 className = orig.className;
1435 theme = orig.theme;
1436 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001437 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001438 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1439 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001440 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001441 volumeUuid = orig.volumeUuid;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -06001442 storageUuid = orig.storageUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001443 scanSourceDir = orig.scanSourceDir;
1444 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001445 sourceDir = orig.sourceDir;
1446 publicSourceDir = orig.publicSourceDir;
Adam Lesinski4e862812016-11-21 16:02:24 -08001447 splitNames = orig.splitNames;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001448 splitSourceDirs = orig.splitSourceDirs;
1449 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Adam Lesinski4e862812016-11-21 16:02:24 -08001450 splitDependencies = orig.splitDependencies;
Kenny Root85387d72010-08-26 10:13:11 -07001451 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001452 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -07001453 nativeLibraryRootDir = orig.nativeLibraryRootDir;
1454 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001455 primaryCpuAbi = orig.primaryCpuAbi;
1456 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -08001457 resourceDirs = orig.resourceDirs;
Todd Kennedybe0b8892017-02-15 14:13:52 -08001458 seInfo = orig.seInfo;
1459 seInfoUser = orig.seInfoUser;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001460 sharedLibraryFiles = orig.sharedLibraryFiles;
1461 dataDir = orig.dataDir;
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001462 deviceProtectedDataDir = orig.deviceProtectedDataDir;
1463 credentialProtectedDataDir = orig.credentialProtectedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001464 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -08001465 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001466 targetSdkVersion = orig.targetSdkVersion;
Patrick Baumannc2def582018-04-04 12:14:15 -07001467 setVersionCode(orig.longVersionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001468 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001469 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001470 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001471 manageSpaceActivityName = orig.manageSpaceActivityName;
1472 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -07001473 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -07001474 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -07001475 fullBackupContent = orig.fullBackupContent;
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001476 networkSecurityConfigRes = orig.networkSecurityConfigRes;
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001477 category = orig.category;
Todd Kennedy11e45072017-01-25 13:24:21 -08001478 targetSandboxVersion = orig.targetSandboxVersion;
Narayan Kamathf9419f02017-06-15 11:35:38 +01001479 classLoaderName = orig.classLoaderName;
1480 splitClassLoaderNames = orig.splitClassLoaderNames;
Jason Monka80bfb52017-11-16 17:15:37 -05001481 appComponentFactory = orig.appComponentFactory;
Adam Lesinskid3ea00992018-02-20 16:51:13 -08001482 compileSdkVersion = orig.compileSdkVersion;
1483 compileSdkVersionCodename = orig.compileSdkVersionCodename;
Mathew Inwoode3299532018-02-22 13:19:53 +00001484 mHiddenApiPolicy = orig.mHiddenApiPolicy;
Rhed Jaoc19da782018-06-13 11:16:16 +08001485 hiddenUntilInstalled = orig.hiddenUntilInstalled;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001486 }
1487
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001488 public String toString() {
1489 return "ApplicationInfo{"
1490 + Integer.toHexString(System.identityHashCode(this))
1491 + " " + packageName + "}";
1492 }
1493
1494 public int describeContents() {
1495 return 0;
1496 }
1497
Adam Lesinski4e862812016-11-21 16:02:24 -08001498 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001499 public void writeToParcel(Parcel dest, int parcelableFlags) {
1500 super.writeToParcel(dest, parcelableFlags);
1501 dest.writeString(taskAffinity);
1502 dest.writeString(permission);
1503 dest.writeString(processName);
1504 dest.writeString(className);
1505 dest.writeInt(theme);
1506 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001507 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001508 dest.writeInt(requiresSmallestWidthDp);
1509 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001510 dest.writeInt(largestWidthLimitDp);
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001511 if (storageUuid != null) {
1512 dest.writeInt(1);
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001513 dest.writeLong(storageUuid.getMostSignificantBits());
1514 dest.writeLong(storageUuid.getLeastSignificantBits());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001515 } else {
1516 dest.writeInt(0);
1517 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001518 dest.writeString(scanSourceDir);
1519 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001520 dest.writeString(sourceDir);
1521 dest.writeString(publicSourceDir);
Adam Lesinski4e862812016-11-21 16:02:24 -08001522 dest.writeStringArray(splitNames);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001523 dest.writeStringArray(splitSourceDirs);
1524 dest.writeStringArray(splitPublicSourceDirs);
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001525 dest.writeSparseArray((SparseArray) splitDependencies);
Kenny Root85387d72010-08-26 10:13:11 -07001526 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001527 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -07001528 dest.writeString(nativeLibraryRootDir);
1529 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +01001530 dest.writeString(primaryCpuAbi);
1531 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -08001532 dest.writeStringArray(resourceDirs);
Todd Kennedybe0b8892017-02-15 14:13:52 -08001533 dest.writeString(seInfo);
1534 dest.writeString(seInfoUser);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001535 dest.writeStringArray(sharedLibraryFiles);
1536 dest.writeString(dataDir);
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001537 dest.writeString(deviceProtectedDataDir);
1538 dest.writeString(credentialProtectedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001539 dest.writeInt(uid);
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001540 dest.writeInt(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001541 dest.writeInt(targetSdkVersion);
Patrick Baumannc2def582018-04-04 12:14:15 -07001542 dest.writeLong(longVersionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001543 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001544 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001545 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001546 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -07001547 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001548 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -07001549 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -07001550 dest.writeInt(fullBackupContent);
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001551 dest.writeInt(networkSecurityConfigRes);
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001552 dest.writeInt(category);
Todd Kennedy11e45072017-01-25 13:24:21 -08001553 dest.writeInt(targetSandboxVersion);
Narayan Kamathf9419f02017-06-15 11:35:38 +01001554 dest.writeString(classLoaderName);
1555 dest.writeStringArray(splitClassLoaderNames);
Alan Viveretteb6a25732017-11-21 14:49:24 -05001556 dest.writeInt(compileSdkVersion);
1557 dest.writeString(compileSdkVersionCodename);
Jason Monka80bfb52017-11-16 17:15:37 -05001558 dest.writeString(appComponentFactory);
Mathew Inwoode3299532018-02-22 13:19:53 +00001559 dest.writeInt(mHiddenApiPolicy);
Rhed Jaoc19da782018-06-13 11:16:16 +08001560 dest.writeInt(hiddenUntilInstalled ? 1 : 0);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001561 }
1562
1563 public static final Parcelable.Creator<ApplicationInfo> CREATOR
1564 = new Parcelable.Creator<ApplicationInfo>() {
1565 public ApplicationInfo createFromParcel(Parcel source) {
1566 return new ApplicationInfo(source);
1567 }
1568 public ApplicationInfo[] newArray(int size) {
1569 return new ApplicationInfo[size];
1570 }
1571 };
1572
Adam Lesinski4e862812016-11-21 16:02:24 -08001573 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001574 private ApplicationInfo(Parcel source) {
1575 super(source);
1576 taskAffinity = source.readString();
1577 permission = source.readString();
1578 processName = source.readString();
1579 className = source.readString();
1580 theme = source.readInt();
1581 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001582 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001583 requiresSmallestWidthDp = source.readInt();
1584 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001585 largestWidthLimitDp = source.readInt();
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001586 if (source.readInt() != 0) {
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001587 storageUuid = new UUID(source.readLong(), source.readLong());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001588 volumeUuid = StorageManager.convert(storageUuid);
1589 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001590 scanSourceDir = source.readString();
1591 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001592 sourceDir = source.readString();
1593 publicSourceDir = source.readString();
Adam Lesinski4e862812016-11-21 16:02:24 -08001594 splitNames = source.readStringArray();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001595 splitSourceDirs = source.readStringArray();
1596 splitPublicSourceDirs = source.readStringArray();
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001597 splitDependencies = source.readSparseArray(null);
Kenny Root85387d72010-08-26 10:13:11 -07001598 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001599 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -07001600 nativeLibraryRootDir = source.readString();
1601 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001602 primaryCpuAbi = source.readString();
1603 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -08001604 resourceDirs = source.readStringArray();
Todd Kennedybe0b8892017-02-15 14:13:52 -08001605 seInfo = source.readString();
1606 seInfoUser = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001607 sharedLibraryFiles = source.readStringArray();
1608 dataDir = source.readString();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001609 deviceProtectedDataDir = source.readString();
1610 credentialProtectedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001611 uid = source.readInt();
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001612 minSdkVersion = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001613 targetSdkVersion = source.readInt();
Patrick Baumannc2def582018-04-04 12:14:15 -07001614 setVersionCode(source.readLong());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001615 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001616 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001617 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001618 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001619 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001620 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001621 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001622 fullBackupContent = source.readInt();
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001623 networkSecurityConfigRes = source.readInt();
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001624 category = source.readInt();
Todd Kennedy11e45072017-01-25 13:24:21 -08001625 targetSandboxVersion = source.readInt();
Narayan Kamathf9419f02017-06-15 11:35:38 +01001626 classLoaderName = source.readString();
1627 splitClassLoaderNames = source.readStringArray();
Alan Viveretteb6a25732017-11-21 14:49:24 -05001628 compileSdkVersion = source.readInt();
1629 compileSdkVersionCodename = source.readString();
Jason Monka80bfb52017-11-16 17:15:37 -05001630 appComponentFactory = source.readString();
Mathew Inwoode3299532018-02-22 13:19:53 +00001631 mHiddenApiPolicy = source.readInt();
Rhed Jaoc19da782018-06-13 11:16:16 +08001632 hiddenUntilInstalled = source.readInt() != 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001633 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001634
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001635 /**
1636 * Retrieve the textual description of the application. This
1637 * will call back on the given PackageManager to load the description from
1638 * the application.
1639 *
1640 * @param pm A PackageManager from which the label can be loaded; usually
1641 * the PackageManager from which you originally retrieved this item.
1642 *
1643 * @return Returns a CharSequence containing the application's description.
1644 * If there is no description, null is returned.
1645 */
1646 public CharSequence loadDescription(PackageManager pm) {
1647 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001648 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001649 if (label != null) {
1650 return label;
1651 }
1652 }
1653 return null;
1654 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001655
1656 /**
1657 * Disable compatibility mode
1658 *
1659 * @hide
1660 */
Mathew Inwood1c77a112018-08-14 14:06:26 +01001661 @UnsupportedAppUsage
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001662 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001663 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001664 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001665 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001666 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001667
skuhne@google.com7e85eb02017-01-04 13:49:54 -08001668 /**
1669 * Is using compatibility mode for non densty aware legacy applications.
1670 *
1671 * @hide
1672 */
1673 public boolean usesCompatibilityMode() {
1674 return targetSdkVersion < DONUT ||
1675 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1676 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1677 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1678 }
1679
Jeff Sharkey15447792015-11-05 16:18:51 -08001680 /** {@hide} */
1681 public void initForUser(int userId) {
1682 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1683
1684 if ("android".equals(packageName)) {
1685 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1686 return;
1687 }
1688
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001689 deviceProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001690 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001691 .getAbsolutePath();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001692 credentialProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001693 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001694 .getAbsolutePath();
1695
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001696 if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1697 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1698 dataDir = deviceProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001699 } else {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001700 dataDir = credentialProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001701 }
1702 }
1703
Mathew Inwoode3299532018-02-22 13:19:53 +00001704 private boolean isPackageWhitelistedForHiddenApis() {
1705 return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
1706 }
1707
David Brazdilfa5e8362018-09-06 09:49:14 +01001708 /**
1709 * @hide
1710 */
1711 public boolean usesNonSdkApi() {
1712 return (privateFlags & PRIVATE_FLAG_USES_NON_SDK_API) != 0;
1713 }
1714
Mathew Inwood9d895432018-04-04 16:08:21 +01001715 private boolean isAllowedToUseHiddenApis() {
David Brazdilca6f81d2018-08-28 12:55:56 +01001716 if (isSignedWithPlatformKey()) {
1717 return true;
1718 } else if (isSystemApp() || isUpdatedSystemApp()) {
David Brazdilfa5e8362018-09-06 09:49:14 +01001719 return usesNonSdkApi() || isPackageWhitelistedForHiddenApis();
David Brazdilca6f81d2018-08-28 12:55:56 +01001720 } else {
1721 return false;
1722 }
Mathew Inwood9d895432018-04-04 16:08:21 +01001723 }
1724
Jeff Brown07330792010-03-30 19:57:08 -07001725 /**
1726 * @hide
1727 */
Mathew Inwoode3299532018-02-22 13:19:53 +00001728 public @HiddenApiEnforcementPolicy int getHiddenApiEnforcementPolicy() {
Mathew Inwood9d895432018-04-04 16:08:21 +01001729 if (isAllowedToUseHiddenApis()) {
David Brazdildf1c7dc2018-10-26 16:23:59 +01001730 return HIDDEN_API_ENFORCEMENT_DISABLED;
Mathew Inwoode3299532018-02-22 13:19:53 +00001731 }
Mathew Inwood1ab30252018-04-03 14:47:26 +01001732 if (mHiddenApiPolicy != HIDDEN_API_ENFORCEMENT_DEFAULT) {
1733 return mHiddenApiPolicy;
1734 }
David Brazdildf1c7dc2018-10-26 16:23:59 +01001735 return HIDDEN_API_ENFORCEMENT_ENABLED;
Mathew Inwoode3299532018-02-22 13:19:53 +00001736 }
1737
1738 /**
1739 * @hide
1740 */
1741 public void setHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
1742 if (!isValidHiddenApiEnforcementPolicy(policy)) {
1743 throw new IllegalArgumentException("Invalid API enforcement policy: " + policy);
1744 }
1745 mHiddenApiPolicy = policy;
David Brazdil464ed3d2018-01-18 15:25:18 +00001746 }
1747
1748 /**
Mathew Inwood1ab30252018-04-03 14:47:26 +01001749 * Updates the hidden API enforcement policy for this app from the given values, if appropriate.
1750 *
1751 * This will have no effect if this app is not subject to hidden API enforcement, i.e. if it
1752 * is on the package whitelist.
1753 *
David Brazdildf1c7dc2018-10-26 16:23:59 +01001754 * @param policy configured policy for this app, or {@link #HIDDEN_API_ENFORCEMENT_DEFAULT}
1755 * if nothing configured.
Mathew Inwood1ab30252018-04-03 14:47:26 +01001756 * @hide
1757 */
David Brazdildf1c7dc2018-10-26 16:23:59 +01001758 public void maybeUpdateHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
Mathew Inwood1ab30252018-04-03 14:47:26 +01001759 if (isPackageWhitelistedForHiddenApis()) {
1760 return;
1761 }
David Brazdildf1c7dc2018-10-26 16:23:59 +01001762 setHiddenApiEnforcementPolicy(policy);
Mathew Inwood1ab30252018-04-03 14:47:26 +01001763 }
1764
1765 /**
David Brazdil464ed3d2018-01-18 15:25:18 +00001766 * @hide
1767 */
Patrick Baumannc2def582018-04-04 12:14:15 -07001768 public void setVersionCode(long newVersionCode) {
1769 longVersionCode = newVersionCode;
1770 versionCode = (int) newVersionCode;
1771 }
1772
1773 /**
1774 * @hide
1775 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001776 @Override
1777 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001778 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1779 && isPackageUnavailable(pm)) {
1780 return Resources.getSystem().getDrawable(
1781 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1782 }
1783 return pm.getDefaultActivityIcon();
1784 }
1785
Mathew Inwood1c77a112018-08-14 14:06:26 +01001786 @UnsupportedAppUsage
Jeff Brown07330792010-03-30 19:57:08 -07001787 private boolean isPackageUnavailable(PackageManager pm) {
1788 try {
1789 return pm.getPackageInfo(packageName, 0) == null;
1790 } catch (NameNotFoundException ex) {
1791 return true;
1792 }
1793 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001794
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001795 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001796 public boolean isDefaultToDeviceProtectedStorage() {
1797 return (privateFlags
1798 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
Jeff Sharkeye4697132016-02-06 19:46:15 -07001799 }
1800
1801 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001802 public boolean isDirectBootAware() {
1803 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001804 }
1805
Jeff Sharkey8924e872015-11-30 12:52:10 -07001806 /** @hide */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001807 public boolean isEncryptionAware() {
1808 return isDirectBootAware() || isPartiallyDirectBootAware();
1809 }
1810
1811 /** @hide */
1812 public boolean isExternal() {
1813 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1814 }
1815
1816 /** @hide */
1817 public boolean isExternalAsec() {
1818 return TextUtils.isEmpty(volumeUuid) && isExternal();
1819 }
1820
1821 /** @hide */
Mathew Inwood1c77a112018-08-14 14:06:26 +01001822 @UnsupportedAppUsage
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001823 public boolean isForwardLocked() {
1824 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1825 }
1826
Patrick Baumann159cd022018-01-11 13:25:05 -08001827 /**
1828 * True if the application is installed as an instant app.
1829 * @hide
1830 */
1831 @SystemApi
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001832 public boolean isInstantApp() {
1833 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
1834 }
1835
1836 /** @hide */
1837 public boolean isInternal() {
1838 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1839 }
1840
1841 /** @hide */
1842 public boolean isOem() {
1843 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
1844 }
1845
1846 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001847 public boolean isPartiallyDirectBootAware() {
1848 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkey8924e872015-11-30 12:52:10 -07001849 }
1850
Bryce Lee8558ec72017-08-17 15:37:26 -07001851 /** @hide */
Mathew Inwood9d895432018-04-04 16:08:21 +01001852 public boolean isSignedWithPlatformKey() {
1853 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY) != 0;
1854 }
1855
1856 /** @hide */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001857 @TestApi
1858 public boolean isPrivilegedApp() {
1859 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
Bryce Lee8558ec72017-08-17 15:37:26 -07001860 }
1861
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001862 /** @hide */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001863 public boolean isRequiredForSystemUser() {
1864 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1865 }
1866
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001867 /** @hide */
Svet Ganov67882122016-12-11 16:36:34 -08001868 public boolean isStaticSharedLibrary() {
1869 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
1870 }
1871
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001872 /** @hide */
1873 @TestApi
1874 public boolean isSystemApp() {
1875 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1876 }
1877
1878 /** @hide */
1879 public boolean isUpdatedSystemApp() {
1880 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1881 }
1882
Jiyong Park002fdbd2017-02-13 20:50:31 +09001883 /** @hide */
1884 public boolean isVendor() {
1885 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0;
1886 }
1887
Jaekyun Seok1713d9e2018-01-12 21:47:26 +09001888 /** @hide */
1889 public boolean isProduct() {
1890 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRODUCT) != 0;
1891 }
1892
Svet Ganov67882122016-12-11 16:36:34 -08001893 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -07001894 * Returns whether or not this application was installed as a virtual preload.
1895 */
1896 public boolean isVirtualPreload() {
1897 return (privateFlags & PRIVATE_FLAG_VIRTUAL_PRELOAD) != 0;
1898 }
1899
1900 /**
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001901 * Returns true if the app has declared in its manifest that it wants its split APKs to be
1902 * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
Svet Ganov67882122016-12-11 16:36:34 -08001903 * @hide
1904 */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001905 public boolean requestsIsolatedSplitLoading() {
1906 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
Svet Ganov087dce22017-09-07 15:42:16 -07001907 }
1908
1909 /**
1910 * @hide
1911 */
Jeff Brown07330792010-03-30 19:57:08 -07001912 @Override protected ApplicationInfo getApplicationInfo() {
1913 return this;
1914 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001915
1916 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1917 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1918 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1919 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1920 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1921 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1922
Mathew Inwood1c77a112018-08-14 14:06:26 +01001923 /** {@hide} */
1924 @UnsupportedAppUsage
1925 public String getCodePath() { return scanSourceDir; }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001926 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1927 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1928 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
Mathew Inwood1c77a112018-08-14 14:06:26 +01001929 /** {@hide} */
1930 @UnsupportedAppUsage
1931 public String getBaseResourcePath() { return publicSourceDir; }
Jeff Sharkeya3a43b02016-11-15 17:54:23 -07001932 /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001933}