blob: aa0bd84a23a542ddb9076d3bd634d0eaefe70016 [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070019import static android.os.Build.VERSION_CODES.DONUT;
20
21import android.annotation.IntDef;
Alan Viveretteb6a25732017-11-21 14:49:24 -050022import android.annotation.Nullable;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060023import android.annotation.SystemApi;
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -070024import android.annotation.TestApi;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060025import android.content.Context;
Jeff Brown07330792010-03-30 19:57:08 -070026import android.content.pm.PackageManager.NameNotFoundException;
27import android.content.res.Resources;
28import android.graphics.drawable.Drawable;
Jeff Sharkey15447792015-11-05 16:18:51 -080029import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.os.Parcel;
31import android.os.Parcelable;
Jeff Sharkey15447792015-11-05 16:18:51 -080032import android.os.UserHandle;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060033import android.os.storage.StorageManager;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070034import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035import android.util.Printer;
Adam Lesinski1665d0f2017-03-10 14:46:57 -080036import android.util.SparseArray;
Yi Jin148d7f42017-11-28 14:23:56 -080037import android.util.proto.ProtoOutputStream;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070039import com.android.internal.util.ArrayUtils;
Mathew Inwood4693a752018-02-20 16:04:25 +000040import com.android.server.SystemConfig;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070041
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070042import java.lang.annotation.Retention;
43import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070045import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070047import java.util.Objects;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -060048import java.util.UUID;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049
50/**
51 * Information you can retrieve about a particular application. This
52 * corresponds to information collected from the AndroidManifest.xml's
53 * <application> tag.
54 */
55public class ApplicationInfo extends PackageItemInfo implements Parcelable {
56
57 /**
58 * Default task affinity of all activities in this application. See
59 * {@link ActivityInfo#taskAffinity} for more information. This comes
60 * from the "taskAffinity" attribute.
61 */
62 public String taskAffinity;
63
64 /**
65 * Optional name of a permission required to be able to access this
66 * application's components. From the "permission" attribute.
67 */
68 public String permission;
69
70 /**
71 * The name of the process this application should run in. From the
72 * "process" attribute or, if not set, the same as
73 * <var>packageName</var>.
74 */
75 public String processName;
76
77 /**
78 * Class implementing the Application object. From the "class"
79 * attribute.
80 */
81 public String className;
82
83 /**
84 * A style resource identifier (in the package's resources) of the
85 * description of an application. From the "description" attribute
86 * or, if not set, 0.
87 */
88 public int descriptionRes;
89
90 /**
91 * A style resource identifier (in the package's resources) of the
92 * default visual theme of the application. From the "theme" attribute
93 * or, if not set, 0.
94 */
95 public int theme;
96
97 /**
98 * Class implementing the Application's manage space
99 * functionality. From the "manageSpaceActivity"
100 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -0700101 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800102 */
103 public String manageSpaceActivityName;
104
105 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700106 * Class implementing the Application's backup functionality. From
107 * the "backupAgent" attribute. This is an optional attribute and
108 * will be null if the application does not specify it in its manifest.
109 *
110 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -0700111 */
112 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700113
114 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700115 * An optional attribute that indicates the app supports automatic backup of app data.
116 * <p>0 is the default and means the app's entire data folder + managed external storage will
117 * be backed up;
118 * Any negative value indicates the app does not support full-data backup, though it may still
119 * want to participate via the traditional key/value backup API;
120 * A positive number specifies an xml resource in which the application has defined its backup
121 * include/exclude criteria.
122 * <p>If android:allowBackup is set to false, this attribute is ignored.
123 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600124 * @see android.content.Context#getNoBackupFilesDir()
125 * @see #FLAG_ALLOW_BACKUP
Christopher Tate98fa6562015-05-14 13:20:10 -0700126 *
127 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700128 */
129 public int fullBackupContent = 0;
130
131 /**
Adam Powell269248d2011-08-02 10:26:54 -0700132 * The default extra UI options for activities in this application.
133 * Set from the {@link android.R.attr#uiOptions} attribute in the
134 * activity's manifest.
135 */
136 public int uiOptions = 0;
137
138 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800139 * Value for {@link #flags}: if set, this application is installed in the
140 * device's system image.
141 */
142 public static final int FLAG_SYSTEM = 1<<0;
143
144 /**
145 * Value for {@link #flags}: set to true if this application would like to
146 * allow debugging of its
147 * code, even when installed on a non-development system. Comes
148 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
149 * android:debuggable} of the &lt;application&gt; tag.
150 */
151 public static final int FLAG_DEBUGGABLE = 1<<1;
152
153 /**
154 * Value for {@link #flags}: set to true if this application has code
155 * associated with it. Comes
156 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
157 * android:hasCode} of the &lt;application&gt; tag.
158 */
159 public static final int FLAG_HAS_CODE = 1<<2;
160
161 /**
162 * Value for {@link #flags}: set to true if this application is persistent.
163 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
164 * android:persistent} of the &lt;application&gt; tag.
165 */
166 public static final int FLAG_PERSISTENT = 1<<3;
167
168 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700169 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
171 * device is running in factory test mode.
172 */
173 public static final int FLAG_FACTORY_TEST = 1<<4;
174
175 /**
176 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
177 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
178 * android:allowTaskReparenting} of the &lt;application&gt; tag.
179 */
180 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
181
182 /**
183 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
184 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
185 * android:allowClearUserData} of the &lt;application&gt; tag.
186 */
187 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
188
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800189 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700190 * Value for {@link #flags}: this is set if this application has been
Kweku Adams8de29ca2016-01-22 12:30:26 -0800191 * installed as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192 */
193 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700194
195 /**
Svet Ganov354cd3c2015-12-17 11:35:04 -0800196 * Value for {@link #flags}: this is set if the application has specified
Dianne Hackborn7f205432009-07-28 00:13:47 -0700197 * {@link android.R.styleable#AndroidManifestApplication_testOnly
198 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700199 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700200 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700201
202 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700203 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700204 * reduced in size for smaller screens. Corresponds to
205 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
206 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700207 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700208 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
209
210 /**
211 * Value for {@link #flags}: true when the application's window can be
212 * displayed on normal screens. Corresponds to
213 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
214 * android:normalScreens}.
215 */
216 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
217
218 /**
219 * Value for {@link #flags}: true when the application's window can be
220 * increased in size for larger screens. Corresponds to
221 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700222 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700223 */
224 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700225
226 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700227 * Value for {@link #flags}: true when the application knows how to adjust
228 * its UI for different screen sizes. Corresponds to
229 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
230 * android:resizeable}.
231 */
232 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
233
234 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700235 * Value for {@link #flags}: true when the application knows how to
236 * accomodate different screen densities. Corresponds to
237 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
238 * android:anyDensity}.
239 */
240 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
241
242 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800243 * Value for {@link #flags}: set to true if this application would like to
244 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700245 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
246 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800247 */
248 public static final int FLAG_VM_SAFE_MODE = 1<<14;
249
250 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800251 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
252 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700253 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800254 * <p>Comes from the
255 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
256 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700257 */
Ben Cheng23085b72010-02-08 16:06:32 -0800258 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700259
260 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800261 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
262 * in memory following a full-system restore operation; <code>true</code> otherwise.
263 * Ordinarily, during a full system restore operation each application is shut down
264 * following execution of its agent's onRestore() method. Setting this attribute to
265 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700266 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800267 * <p>If
268 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
269 * is set to <code>false</code> or no
270 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700271 * is specified, this flag will be ignored.
272 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800273 * <p>Comes from the
274 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
275 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700276 */
Ben Cheng23085b72010-02-08 16:06:32 -0800277 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700278
279 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800280 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
281 * agent claims to be able to handle restore data even "from the future,"
282 * i.e. from versions of the application with a versionCode greater than
283 * the one currently installed on the device. <i>Use with caution!</i> By default
284 * this attribute is <code>false</code> and the Backup Manager will ensure that data
285 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700286 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800287 * <p>If
288 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
289 * is set to <code>false</code> or no
290 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700291 * is specified, this flag will be ignored.
292 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800293 * <p>Comes from the
294 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
295 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700296 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800297 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700298
Christopher Tate181fafa2009-05-14 11:12:14 -0700299 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700300 * Value for {@link #flags}: Set to true if the application is
301 * currently installed on external/removable/unprotected storage. Such
302 * applications may not be available if their storage is not currently
303 * mounted. When the storage it is on is not available, it will look like
304 * the application has been uninstalled (its .apk is no longer available)
305 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800306 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700307 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800308
309 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700310 * Value for {@link #flags}: true when the application's window can be
311 * increased in size for extra large screens. Corresponds to
312 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700313 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700314 */
315 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
316
317 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800318 * Value for {@link #flags}: true when the application has requested a
319 * large heap for its processes. Corresponds to
320 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
321 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600322 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800323 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600324
325 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800326 * Value for {@link #flags}: true if this application's package is in
327 * the stopped state.
328 */
329 public static final int FLAG_STOPPED = 1<<21;
330
331 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700332 * Value for {@link #flags}: true when the application is willing to support
333 * RTL (right to left). All activities will inherit this value.
334 *
335 * Set from the {@link android.R.attr#supportsRtl} attribute in the
336 * activity's manifest.
337 *
338 * Default value is false (no support for RTL).
339 */
340 public static final int FLAG_SUPPORTS_RTL = 1<<22;
341
342 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700343 * Value for {@link #flags}: true if the application is currently
344 * installed for the calling user.
345 */
346 public static final int FLAG_INSTALLED = 1<<23;
347
348 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700349 * Value for {@link #flags}: true if the application only has its
350 * data installed; the application package itself does not currently
351 * exist on the device.
352 */
353 public static final int FLAG_IS_DATA_ONLY = 1<<24;
354
355 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700356 * Value for {@link #flags}: true if the application was declared to be a
357 * game, or false if it is a non-game application.
358 *
359 * @deprecated use {@link #CATEGORY_GAME} instead.
Jose Lima12d0b4c2014-03-14 16:55:12 -0700360 */
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700361 @Deprecated
Jose Lima12d0b4c2014-03-14 16:55:12 -0700362 public static final int FLAG_IS_GAME = 1<<25;
363
364 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700365 * Value for {@link #flags}: {@code true} if the application asks that only
366 * full-data streaming backups of its data be performed even though it defines
367 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
368 * indicates that the app will manage its backed-up data via incremental
369 * key/value updates.
370 */
371 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
372
373 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700374 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
375 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
376 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
377 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700378 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
379 * traffic. Third-party libraries are encouraged to honor this flag as well.
380 *
Nate Fischer6a2a5412017-10-23 18:02:41 -0700381 * <p>NOTE: {@code WebView} honors this flag for applications targeting API level 26 and up.
Alex Klyubinfbf45992015-04-21 13:44:29 -0700382 *
Chad Brubaker2df5ba72016-04-11 13:31:24 -0700383 * <p>This flag is ignored on Android N and above if an Android Network Security Config is
384 * present.
385 *
Alex Klyubinfbf45992015-04-21 13:44:29 -0700386 * <p>This flag comes from
387 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
388 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700389 */
390 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
391
392 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700393 * When set installer extracts native libs from .apk files.
394 */
395 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
396
397 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700398 * Value for {@link #flags}: {@code true} when the application's rendering
399 * should be hardware accelerated.
400 */
401 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
402
403 /**
Andrei Stingaceanu1e283912015-11-26 15:26:28 +0000404 * Value for {@link #flags}: true if this application's package is in
405 * the suspended state.
406 */
407 public static final int FLAG_SUSPENDED = 1<<30;
408
409 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100410 * Value for {@link #flags}: true if code from this application will need to be
411 * loaded into other applications' processes. On devices that support multiple
412 * instruction sets, this implies the code might be loaded into a process that's
413 * using any of the devices supported instruction sets.
414 *
415 * <p> The system might treat such applications specially, for eg., by
416 * extracting the application's native libraries for all supported instruction
417 * sets or by compiling the application's dex code for all supported instruction
418 * sets.
419 */
420 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700421
422 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800423 * Flags associated with the application. Any combination of
424 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
425 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
426 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700427 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700428 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
429 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700430 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
431 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700432 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800433 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
434 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
435 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
436 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
437 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700438 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
439 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800440 */
441 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700442
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800443 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800444 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
445 * most purposes is considered as not installed.
446 * {@hide}
447 */
448 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
449
450 /**
451 * Value for {@link #privateFlags}: set to <code>true</code> if the application
452 * has reported that it is heavy-weight, and thus can not participate in
453 * the normal application lifecycle.
454 *
455 * <p>Comes from the
456 * android.R.styleable#AndroidManifestApplication_cantSaveState
457 * attribute of the &lt;application&gt; tag.
458 *
459 * {@hide}
460 */
461 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
462
463 /**
464 * Value for {@link #privateFlags}: Set to true if the application has been
465 * installed using the forward lock option.
466 *
467 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
468 *
469 * {@hide}
470 */
471 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
472
473 /**
474 * Value for {@link #privateFlags}: set to {@code true} if the application
475 * is permitted to hold privileged permissions.
476 *
477 * {@hide}
478 */
479 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
480
481 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800482 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
483 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700484 *
485 * {@hide}
486 */
487 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
488
489 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600490 * When set, the default data storage directory for this app is pointed at
491 * the device-protected location.
Jeff Sharkey15447792015-11-05 16:18:51 -0800492 *
493 * @hide
494 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600495 public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800496
497 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600498 * When set, assume that all components under the given app are direct boot
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800499 * aware, unless otherwise specified.
500 *
501 * @hide
502 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600503 public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800504
505 /**
Todd Kennedybe0b8892017-02-15 14:13:52 -0800506 * Value for {@link #privateFlags}: {@code true} if the application is installed
507 * as instant app.
508 *
509 * @hide
Chad Brubaker4389c232016-11-04 14:50:50 -0700510 */
Todd Kennedybe0b8892017-02-15 14:13:52 -0800511 public static final int PRIVATE_FLAG_INSTANT = 1 << 7;
Chad Brubaker4389c232016-11-04 14:50:50 -0700512
513 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600514 * When set, at least one component inside this application is direct boot
515 * aware.
Jeff Sharkey8924e872015-11-30 12:52:10 -0700516 *
517 * @hide
518 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600519 public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
Jeff Sharkey8924e872015-11-30 12:52:10 -0700520
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800521
522 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800523 * When set, signals that the application is required for the system user and should not be
524 * uninstalled.
525 *
526 * @hide
527 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700528 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800529
530 /**
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700531 * When set, the application explicitly requested that its activities be resizeable by default.
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800532 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
533 *
534 * @hide
535 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700536 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE = 1 << 10;
537
538 /**
539 * When set, the application explicitly requested that its activities *not* be resizeable by
540 * default.
541 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
542 *
543 * @hide
544 */
545 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE = 1 << 11;
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700546
547 /**
548 * The application isn't requesting explicitly requesting for its activities to be resizeable or
549 * non-resizeable by default. So, we are making it activities resizeable by default based on the
550 * target SDK version of the app.
551 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
552 *
553 * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
554 * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
555 * where certain pre-N apps are forced to the resizeable.
556 *
557 * @hide
558 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700559 public static final int PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION =
560 1 << 12;
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800561
562 /**
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800563 * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
564 * run full-data backup operations for the app even when it is in a
565 * foreground-equivalent run state. Defaults to {@code false} if unspecified.
566 * @hide
567 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700568 public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 13;
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800569
570 /**
Svet Ganov67882122016-12-11 16:36:34 -0800571 * Value for {@link #privateFlags}: {@code true} means this application
572 * contains a static shared library. Defaults to {@code false} if unspecified.
573 * @hide
574 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700575 public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 14;
Svet Ganov67882122016-12-11 16:36:34 -0800576
577 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700578 * Value for {@link #privateFlags}: When set, the application will only have its splits loaded
Adam Lesinski4e862812016-11-21 16:02:24 -0800579 * if they are required to load a component. Splits can be loaded on demand using the
580 * {@link Context#createContextForSplit(String)} API.
581 * @hide
582 */
Wale Ogunwalee633eb02017-03-30 12:57:29 -0700583 public static final int PRIVATE_FLAG_ISOLATED_SPLIT_LOADING = 1 << 15;
Adam Lesinski4e862812016-11-21 16:02:24 -0800584
585 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700586 * Value for {@link #privateFlags}: When set, the application was installed as
587 * a virtual preload.
588 * @hide
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800589 */
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700590 public static final int PRIVATE_FLAG_VIRTUAL_PRELOAD = 1 << 16;
591
Svet Ganov087dce22017-09-07 15:42:16 -0700592 /**
Mathew Inwood9d895432018-04-04 16:08:21 +0100593 * Value for {@link #privateFlags}: whether this app is pre-installed on the
Svet Ganov087dce22017-09-07 15:42:16 -0700594 * OEM partition of the system image.
595 * @hide
596 */
597 public static final int PRIVATE_FLAG_OEM = 1 << 17;
598
Jiyong Park002fdbd2017-02-13 20:50:31 +0900599 /**
Mathew Inwood9d895432018-04-04 16:08:21 +0100600 * Value for {@link #privateFlags}: whether this app is pre-installed on the
Jiyong Park002fdbd2017-02-13 20:50:31 +0900601 * vendor partition of the system image.
602 * @hide
603 */
604 public static final int PRIVATE_FLAG_VENDOR = 1 << 18;
605
Jaekyun Seok1713d9e2018-01-12 21:47:26 +0900606 /**
Mathew Inwood9d895432018-04-04 16:08:21 +0100607 * Value for {@link #privateFlags}: whether this app is pre-installed on the
Jaekyun Seok1713d9e2018-01-12 21:47:26 +0900608 * product partition of the system image.
609 * @hide
610 */
611 public static final int PRIVATE_FLAG_PRODUCT = 1 << 19;
612
Mathew Inwood9d895432018-04-04 16:08:21 +0100613 /**
614 * Value for {@link #privateFlags}: whether this app is signed with the
615 * platform key.
616 * @hide
617 */
618 public static final int PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY = 1 << 20;
619
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700620 /** @hide */
621 @IntDef(flag = true, prefix = { "PRIVATE_FLAG_" }, value = {
Svet Ganov087dce22017-09-07 15:42:16 -0700622 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE,
623 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION,
624 PRIVATE_FLAG_ACTIVITIES_RESIZE_MODE_UNRESIZEABLE,
625 PRIVATE_FLAG_BACKUP_IN_FOREGROUND,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700626 PRIVATE_FLAG_CANT_SAVE_STATE,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700627 PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE,
628 PRIVATE_FLAG_DIRECT_BOOT_AWARE,
Svet Ganov087dce22017-09-07 15:42:16 -0700629 PRIVATE_FLAG_FORWARD_LOCK,
630 PRIVATE_FLAG_HAS_DOMAIN_URLS,
631 PRIVATE_FLAG_HIDDEN,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700632 PRIVATE_FLAG_INSTANT,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700633 PRIVATE_FLAG_ISOLATED_SPLIT_LOADING,
Svet Ganov087dce22017-09-07 15:42:16 -0700634 PRIVATE_FLAG_OEM,
635 PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE,
636 PRIVATE_FLAG_PRIVILEGED,
Jaekyun Seok1713d9e2018-01-12 21:47:26 +0900637 PRIVATE_FLAG_PRODUCT,
Svet Ganov087dce22017-09-07 15:42:16 -0700638 PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER,
Mathew Inwood9d895432018-04-04 16:08:21 +0100639 PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY,
Svet Ganov087dce22017-09-07 15:42:16 -0700640 PRIVATE_FLAG_STATIC_SHARED_LIBRARY,
Jiyong Park002fdbd2017-02-13 20:50:31 +0900641 PRIVATE_FLAG_VENDOR,
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -0700642 PRIVATE_FLAG_VIRTUAL_PRELOAD,
643 })
644 @Retention(RetentionPolicy.SOURCE)
645 public @interface ApplicationInfoPrivateFlags {}
646
647 /**
648 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
649 * @hide
650 */
651 public @ApplicationInfoPrivateFlags int privateFlags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800652
653 /**
Clara Bayarri4b5a4d22017-01-27 20:15:45 +0000654 * @hide
655 */
656 public static final String METADATA_PRELOADED_FONTS = "preloaded_fonts";
657
658 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700659 * The required smallest screen width the application can run on. If 0,
660 * nothing has been specified. Comes from
661 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
662 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
663 */
664 public int requiresSmallestWidthDp = 0;
665
666 /**
667 * The maximum smallest screen width the application is designed for. If 0,
668 * nothing has been specified. Comes from
669 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
670 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
671 */
672 public int compatibleWidthLimitDp = 0;
673
674 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700675 * The maximum smallest screen width the application will work on. If 0,
676 * nothing has been specified. Comes from
677 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
678 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
679 */
680 public int largestWidthLimitDp = 0;
681
Jeff Sharkey61128602017-01-26 17:07:35 -0700682 /**
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700683 * Value indicating the maximum aspect ratio the application supports.
684 * <p>
685 * 0 means unset.
686 * @See {@link android.R.attr#maxAspectRatio}.
687 * @hide
688 */
689 public float maxAspectRatio;
690
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600691 /** @removed */
692 @Deprecated
693 public String volumeUuid;
694
Wale Ogunwale55ddf8f2017-03-20 08:56:38 -0700695 /**
Jeff Sharkey61128602017-01-26 17:07:35 -0700696 * UUID of the storage volume on which this application is being hosted. For
697 * apps hosted on the default internal storage at
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600698 * {@link Environment#getDataDirectory()}, the UUID value is
699 * {@link StorageManager#UUID_DEFAULT}.
Jeff Sharkey61128602017-01-26 17:07:35 -0700700 */
Jeff Sharkey789a8fc2017-04-16 13:18:35 -0600701 public UUID storageUuid;
Jeff Sharkey61128602017-01-26 17:07:35 -0700702
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700703 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700704 public String scanSourceDir;
705 /** {@hide} */
706 public String scanPublicSourceDir;
707
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700708 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700709 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800710 */
711 public String sourceDir;
712
713 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700714 * Full path to the publicly available parts of {@link #sourceDir},
715 * including resources and manifest. This may be different from
716 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800717 */
718 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700719
720 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800721 * The names of all installed split APKs, ordered lexicographically.
722 */
723 public String[] splitNames;
724
725 /**
726 * Full paths to zero or more split APKs, indexed by the same order as {@link #splitNames}.
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700727 */
728 public String[] splitSourceDirs;
729
730 /**
731 * Full path to the publicly available parts of {@link #splitSourceDirs},
732 * including resources and manifest. This may be different from
733 * {@link #splitSourceDirs} if an application is forward locked.
Adam Lesinski4e862812016-11-21 16:02:24 -0800734 *
735 * @see #splitSourceDirs
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700736 */
737 public String[] splitPublicSourceDirs;
738
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800739 /**
Adam Lesinski4e862812016-11-21 16:02:24 -0800740 * Maps the dependencies between split APKs. All splits implicitly depend on the base APK.
741 *
742 * Available since platform version O.
743 *
744 * Only populated if the application opts in to isolated split loading via the
745 * {@link android.R.attr.isolatedSplits} attribute in the &lt;manifest&gt; tag of the app's
746 * AndroidManifest.xml.
747 *
748 * The keys and values are all indices into the {@link #splitNames}, {@link #splitSourceDirs},
749 * and {@link #splitPublicSourceDirs} arrays.
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800750 * Each key represents a split and its value is an array of splits. The first element of this
751 * array is the parent split, and the rest are configuration splits. These configuration splits
752 * have no dependencies themselves.
Adam Lesinski4e862812016-11-21 16:02:24 -0800753 * Cycles do not exist because they are illegal and screened for during installation.
754 *
755 * May be null if no splits are installed, or if no dependencies exist between them.
Calin Juravleda098152017-09-01 17:30:01 -0700756 *
757 * NOTE: Any change to the way split dependencies are stored must update the logic that
758 * creates the class loader context for dexopt (DexoptUtils#getClassLoaderContexts).
759 *
Adam Lesinski4e862812016-11-21 16:02:24 -0800760 * @hide
761 */
Adam Lesinski1665d0f2017-03-10 14:46:57 -0800762 public SparseArray<int[]> splitDependencies;
Adam Lesinski4e862812016-11-21 16:02:24 -0800763
764 /**
765 * Full paths to the locations of extra resource packages (runtime overlays)
766 * this application uses. This field is only used if there are extra resource
767 * packages, otherwise it is null.
768 *
Kenny Rootace5a3f2010-02-05 12:59:28 -0800769 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800770 */
771 public String[] resourceDirs;
772
773 /**
Jeff Vander Stoepcab36392018-03-06 15:52:22 -0800774 * String retrieved from the seinfo tag found in selinux policy. This value can be set through
775 * the mac_permissions.xml policy construct. This value is used for setting an SELinux security
776 * context on the process as well as its data directory.
Robert Craig0f40dc92013-03-25 06:33:03 -0400777 *
778 * {@hide}
779 */
Jeff Vander Stoepcab36392018-03-06 15:52:22 -0800780 public String seInfo;
Todd Kennedybe0b8892017-02-15 14:13:52 -0800781
782 /**
783 * The seinfo tag generated per-user. This value may change based upon the
784 * user's configuration. For example, when an instant app is installed for
785 * a user. It is an error if this field is ever {@code null} when trying to
786 * start a new process.
787 * <p>NOTE: We need to separate this out because we modify per-user values
788 * multiple times. This needs to be refactored since we're performing more
789 * work than necessary and these values should only be set once. When that
790 * happens, we can merge the per-user value with the seInfo state above.
791 *
792 * {@hide}
793 */
794 public String seInfoUser;
Robert Craig0f40dc92013-03-25 06:33:03 -0400795
796 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800797 * Paths to all shared libraries this application is linked against. This
798 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
799 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
800 * the structure.
801 */
802 public String[] sharedLibraryFiles;
803
804 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700805 * Full path to the default directory assigned to the package for its
806 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800807 */
808 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700809
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700810 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600811 * Full path to the device-protected directory assigned to the package for
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700812 * its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600813 *
814 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700815 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600816 public String deviceProtectedDataDir;
817
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700818 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600819 * Full path to the credential-protected directory assigned to the package
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700820 * for its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600821 *
822 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700823 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600824 @SystemApi
825 public String credentialProtectedDataDir;
826
Kenny Root85387d72010-08-26 10:13:11 -0700827 /**
828 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700829 */
830 public String nativeLibraryDir;
831
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800832 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100833 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
834 * are stored, if present.
835 *
836 * The main reason this exists is for bundled multi-arch apps, where
837 * it's not trivial to calculate the location of libs for the secondary abi
838 * given the location of the primary.
839 *
840 * TODO: Change the layout of bundled installs so that we can use
841 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
842 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
843 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
844 *
845 * @hide
846 */
847 public String secondaryNativeLibraryDir;
848
849 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700850 * The root path where unpacked native libraries are stored.
851 * <p>
852 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
853 * placed in ISA-specific subdirectories under this path, otherwise the
854 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100855 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700856 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100857 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700858 public String nativeLibraryRootDir;
859
860 /**
861 * Flag indicating that ISA must be appended to
862 * {@link #nativeLibraryRootDir} to be useful.
863 *
864 * @hide
865 */
866 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100867
868 /**
869 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100870 * of the native JNI libraries the application bundles. Will be {@code null}
871 * if this application does not require any particular ABI.
872 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100873 * If non-null, the application will always be launched with this ABI.
874 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100875 * {@hide}
876 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100877 public String primaryCpuAbi;
878
879 /**
880 * The secondary ABI for this application. Might be non-null for multi-arch
881 * installs. The application itself never uses this ABI, but other applications that
882 * use its code might.
883 *
884 * {@hide}
885 */
886 public String secondaryCpuAbi;
887
888 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800889 * The kernel user-ID that has been assigned to this application;
890 * currently this is not a unique ID (multiple applications can have
891 * the same uid).
892 */
893 public int uid;
894
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700895 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800896 * The minimum SDK version this application can run on. It will not run
897 * on earlier versions.
898 */
Todd Kennedy6e2e7f52016-05-02 14:56:45 -0700899 public int minSdkVersion;
Todd Kennedy89d60182016-03-11 11:18:32 -0800900
901 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700902 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700903 * versions, but it knows how to work with any new behavior added at this
904 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
905 * if this is a development build and the app is targeting that. You should
906 * compare that this number is >= the SDK version number at which your
907 * behavior was introduced.
908 */
909 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800910
911 /**
912 * The app's declared version code.
913 * @hide
914 */
Dianne Hackborn3accca02013-09-20 09:32:11 -0700915 public long versionCode;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800916
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700917 /**
Alan Viveretteb6a25732017-11-21 14:49:24 -0500918 * The user-visible SDK version (ex. 26) of the framework against which the application claims
919 * to have been compiled, or {@code 0} if not specified.
920 * <p>
921 * This property is the compile-time equivalent of
922 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.SDK_INT}.
923 *
924 * @hide For platform use only; we don't expect developers to need to read this value.
925 */
926 public int compileSdkVersion;
927
928 /**
929 * The development codename (ex. "O", "REL") of the framework against which the application
930 * claims to have been compiled, or {@code null} if not specified.
931 * <p>
932 * This property is the compile-time equivalent of
933 * {@link android.os.Build.VERSION#CODENAME Build.VERSION.CODENAME}.
934 *
935 * @hide For platform use only; we don't expect developers to need to read this value.
936 */
937 @Nullable
938 public String compileSdkVersionCodename;
939
940 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800941 * When false, indicates that all components within this application are
942 * considered disabled, regardless of their individually set enabled status.
943 */
944 public boolean enabled = true;
945
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700946 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700947 * For convenient access to the current enabled setting of this app.
948 * @hide
949 */
950 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
951
952 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700953 * For convenient access to package's install location.
954 * @hide
955 */
956 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700957
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700958 /**
959 * Resource file providing the application's Network Security Config.
960 * @hide
961 */
962 public int networkSecurityConfigRes;
963
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700964 /**
Todd Kennedy11e45072017-01-25 13:24:21 -0800965 * Version of the sandbox the application wants to run in.
966 * @hide
967 */
Patrick Baumann159cd022018-01-11 13:25:05 -0800968 @SystemApi
Todd Kennedy11e45072017-01-25 13:24:21 -0800969 public int targetSandboxVersion;
970
971 /**
Jason Monka80bfb52017-11-16 17:15:37 -0500972 * The factory of this package, as specified by the &lt;manifest&gt;
973 * tag's {@link android.R.styleable#AndroidManifestApplication_appComponentFactory}
974 * attribute.
975 */
976 public String appComponentFactory;
977
978 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700979 * The category of this app. Categories are used to cluster multiple apps
980 * together into meaningful groups, such as when summarizing battery,
981 * network, or disk usage. Apps should only define this value when they fit
982 * well into one of the specific categories.
983 * <p>
984 * Set from the {@link android.R.attr#appCategory} attribute in the
985 * manifest. If the manifest doesn't define a category, this value may have
986 * been provided by the installer via
987 * {@link PackageManager#setApplicationCategoryHint(String, int)}.
988 */
989 public @Category int category = CATEGORY_UNDEFINED;
990
991 /** {@hide} */
Jeff Sharkey4347f812017-04-21 12:08:39 -0600992 @IntDef(prefix = { "CATEGORY_" }, value = {
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700993 CATEGORY_UNDEFINED,
994 CATEGORY_GAME,
995 CATEGORY_AUDIO,
996 CATEGORY_VIDEO,
997 CATEGORY_IMAGE,
998 CATEGORY_SOCIAL,
999 CATEGORY_NEWS,
1000 CATEGORY_MAPS,
1001 CATEGORY_PRODUCTIVITY
1002 })
1003 @Retention(RetentionPolicy.SOURCE)
1004 public @interface Category {
1005 }
1006
1007 /**
1008 * Value when category is undefined.
1009 *
1010 * @see #category
1011 */
1012 public static final int CATEGORY_UNDEFINED = -1;
1013
1014 /**
1015 * Category for apps which are primarily games.
1016 *
1017 * @see #category
1018 */
1019 public static final int CATEGORY_GAME = 0;
1020
1021 /**
1022 * Category for apps which primarily work with audio or music, such as music
1023 * players.
1024 *
1025 * @see #category
1026 */
1027 public static final int CATEGORY_AUDIO = 1;
1028
1029 /**
1030 * Category for apps which primarily work with video or movies, such as
1031 * streaming video apps.
1032 *
1033 * @see #category
1034 */
1035 public static final int CATEGORY_VIDEO = 2;
1036
1037 /**
1038 * Category for apps which primarily work with images or photos, such as
1039 * camera or gallery apps.
1040 *
1041 * @see #category
1042 */
1043 public static final int CATEGORY_IMAGE = 3;
1044
1045 /**
1046 * Category for apps which are primarily social apps, such as messaging,
Jeff Sharkeyd2b69102017-03-21 19:40:38 -06001047 * communication, email, or social network apps.
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001048 *
1049 * @see #category
1050 */
1051 public static final int CATEGORY_SOCIAL = 4;
1052
1053 /**
1054 * Category for apps which are primarily news apps, such as newspapers,
1055 * magazines, or sports apps.
1056 *
1057 * @see #category
1058 */
1059 public static final int CATEGORY_NEWS = 5;
1060
1061 /**
1062 * Category for apps which are primarily maps apps, such as navigation apps.
1063 *
1064 * @see #category
1065 */
1066 public static final int CATEGORY_MAPS = 6;
1067
1068 /**
1069 * Category for apps which are primarily productivity apps, such as cloud
1070 * storage or workplace apps.
1071 *
1072 * @see #category
1073 */
1074 public static final int CATEGORY_PRODUCTIVITY = 7;
1075
1076 /**
1077 * Return a concise, localized title for the given
1078 * {@link ApplicationInfo#category} value, or {@code null} for unknown
1079 * values such as {@link #CATEGORY_UNDEFINED}.
1080 *
1081 * @see #category
1082 */
1083 public static CharSequence getCategoryTitle(Context context, @Category int category) {
1084 switch (category) {
1085 case ApplicationInfo.CATEGORY_GAME:
1086 return context.getText(com.android.internal.R.string.app_category_game);
1087 case ApplicationInfo.CATEGORY_AUDIO:
1088 return context.getText(com.android.internal.R.string.app_category_audio);
1089 case ApplicationInfo.CATEGORY_VIDEO:
1090 return context.getText(com.android.internal.R.string.app_category_video);
1091 case ApplicationInfo.CATEGORY_IMAGE:
1092 return context.getText(com.android.internal.R.string.app_category_image);
1093 case ApplicationInfo.CATEGORY_SOCIAL:
1094 return context.getText(com.android.internal.R.string.app_category_social);
1095 case ApplicationInfo.CATEGORY_NEWS:
1096 return context.getText(com.android.internal.R.string.app_category_news);
1097 case ApplicationInfo.CATEGORY_MAPS:
1098 return context.getText(com.android.internal.R.string.app_category_maps);
1099 case ApplicationInfo.CATEGORY_PRODUCTIVITY:
1100 return context.getText(com.android.internal.R.string.app_category_productivity);
1101 default:
1102 return null;
1103 }
1104 }
1105
Narayan Kamathf9419f02017-06-15 11:35:38 +01001106 /** @hide */
1107 public String classLoaderName;
1108
1109 /** @hide */
1110 public String[] splitClassLoaderNames;
1111
Mathew Inwoode3299532018-02-22 13:19:53 +00001112 /**
1113 * Represents the default policy. The actual policy used will depend on other properties of
1114 * the application, e.g. the target SDK version.
1115 * @hide
1116 */
1117 public static final int HIDDEN_API_ENFORCEMENT_DEFAULT = -1;
1118 /**
1119 * No API enforcement; the app can access the entire internal private API. Only for use by
1120 * system apps.
1121 * @hide
1122 */
1123 public static final int HIDDEN_API_ENFORCEMENT_NONE = 0;
1124 /**
1125 * Light grey list enforcement, the strictest option. Enforces the light grey, dark grey and
1126 * black lists.
1127 * @hide
1128 * */
1129 public static final int HIDDEN_API_ENFORCEMENT_ALL_LISTS = 1;
1130 /**
1131 * Dark grey list enforcement. Enforces the dark grey and black lists
1132 * @hide
1133 */
1134 public static final int HIDDEN_API_ENFORCEMENT_DARK_GREY_AND_BLACK = 2;
1135 /**
1136 * Blacklist enforcement only.
1137 * @hide
1138 */
1139 public static final int HIDDEN_API_ENFORCEMENT_BLACK = 3;
1140
1141 private static final int HIDDEN_API_ENFORCEMENT_MAX = HIDDEN_API_ENFORCEMENT_BLACK;
1142
1143 /**
1144 * Values in this IntDef MUST be kept in sync with enum hiddenapi::EnforcementPolicy in
1145 * art/runtime/hidden_api.h
1146 * @hide
1147 */
1148 @IntDef(prefix = { "HIDDEN_API_ENFORCEMENT_" }, value = {
1149 HIDDEN_API_ENFORCEMENT_DEFAULT,
1150 HIDDEN_API_ENFORCEMENT_NONE,
1151 HIDDEN_API_ENFORCEMENT_ALL_LISTS,
1152 HIDDEN_API_ENFORCEMENT_DARK_GREY_AND_BLACK,
1153 HIDDEN_API_ENFORCEMENT_BLACK,
1154 })
1155 @Retention(RetentionPolicy.SOURCE)
1156 public @interface HiddenApiEnforcementPolicy {}
1157
1158 private boolean isValidHiddenApiEnforcementPolicy(int policy) {
1159 return policy >= HIDDEN_API_ENFORCEMENT_DEFAULT && policy <= HIDDEN_API_ENFORCEMENT_MAX;
1160 }
1161
1162 private int mHiddenApiPolicy = HIDDEN_API_ENFORCEMENT_DEFAULT;
1163
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001164 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001165 dump(pw, prefix, DUMP_FLAG_ALL);
1166 }
1167
1168 /** @hide */
Yohei Yukawa8f272172017-08-31 00:26:01 -07001169 public void dump(Printer pw, String prefix, int dumpFlags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001170 super.dumpFront(pw, prefix);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001171 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -08001172 pw.println(prefix + "className=" + className);
1173 }
1174 if (permission != null) {
1175 pw.println(prefix + "permission=" + permission);
1176 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001177 pw.println(prefix + "processName=" + processName);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001178 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001179 pw.println(prefix + "taskAffinity=" + taskAffinity);
1180 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001181 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001182 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -07001183 + " theme=0x" + Integer.toHexString(theme));
Yohei Yukawa8f272172017-08-31 00:26:01 -07001184 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001185 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
1186 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
1187 + " largestWidthLimitDp=" + largestWidthLimitDp);
1188 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001190 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -07001191 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
1192 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001193 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1194 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
1195 }
1196 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1197 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1198 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
1199 }
Dianne Hackborn39792d22010-08-19 18:01:52 -07001200 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -08001201 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -07001202 }
Yohei Yukawa8f272172017-08-31 00:26:01 -07001203 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0 && seInfo != null) {
Todd Kennedybe0b8892017-02-15 14:13:52 -08001204 pw.println(prefix + "seinfo=" + seInfo);
1205 pw.println(prefix + "seinfoUser=" + seInfoUser);
Robert Craig0f40dc92013-03-25 06:33:03 -04001206 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001207 pw.println(prefix + "dataDir=" + dataDir);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001208 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001209 pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
1210 pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001211 if (sharedLibraryFiles != null) {
1212 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
1213 }
Dianne Hackborn12527f92009-11-11 17:39:50 -08001214 }
Narayan Kamathf9419f02017-06-15 11:35:38 +01001215 if (classLoaderName != null) {
1216 pw.println(prefix + "classLoaderName=" + classLoaderName);
1217 }
1218 if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1219 pw.println(prefix + "splitClassLoaderNames=" + Arrays.toString(splitClassLoaderNames));
1220 }
1221
Todd Kennedy89d60182016-03-11 11:18:32 -08001222 pw.println(prefix + "enabled=" + enabled
1223 + " minSdkVersion=" + minSdkVersion
1224 + " targetSdkVersion=" + targetSdkVersion
Todd Kennedy11e45072017-01-25 13:24:21 -08001225 + " versionCode=" + versionCode
1226 + " targetSandboxVersion=" + targetSandboxVersion);
Yohei Yukawa8f272172017-08-31 00:26:01 -07001227 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08001228 if (manageSpaceActivityName != null) {
1229 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
1230 }
1231 if (descriptionRes != 0) {
1232 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
1233 }
1234 if (uiOptions != 0) {
1235 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
1236 }
1237 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
1238 if (fullBackupContent > 0) {
1239 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
1240 } else {
1241 pw.println(prefix + "fullBackupContent="
1242 + (fullBackupContent < 0 ? "false" : "true"));
1243 }
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001244 if (networkSecurityConfigRes != 0) {
1245 pw.println(prefix + "networkSecurityConfigRes=0x"
1246 + Integer.toHexString(networkSecurityConfigRes));
1247 }
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001248 if (category != CATEGORY_UNDEFINED) {
1249 pw.println(prefix + "category=" + category);
1250 }
Mathew Inwoode3299532018-02-22 13:19:53 +00001251 pw.println(prefix + "HiddenApiEnforcementPolicy=" + getHiddenApiEnforcementPolicy());
Matthew Williams303650c2015-04-17 18:22:51 -07001252 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001253 super.dumpBack(pw, prefix);
1254 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001255
Yi Jin148d7f42017-11-28 14:23:56 -08001256 /** {@hide} */
1257 public void writeToProto(ProtoOutputStream proto, long fieldId, int dumpFlags) {
1258 long token = proto.start(fieldId);
1259 super.writeToProto(proto, ApplicationInfoProto.PACKAGE);
1260 proto.write(ApplicationInfoProto.PERMISSION, permission);
1261 proto.write(ApplicationInfoProto.PROCESS_NAME, processName);
1262 proto.write(ApplicationInfoProto.UID, uid);
1263 proto.write(ApplicationInfoProto.FLAGS, flags);
1264 proto.write(ApplicationInfoProto.PRIVATE_FLAGS, privateFlags);
1265 proto.write(ApplicationInfoProto.THEME, theme);
1266 proto.write(ApplicationInfoProto.SOURCE_DIR, sourceDir);
1267 if (!Objects.equals(sourceDir, publicSourceDir)) {
1268 proto.write(ApplicationInfoProto.PUBLIC_SOURCE_DIR, publicSourceDir);
1269 }
1270 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
1271 for (String dir : splitSourceDirs) {
1272 proto.write(ApplicationInfoProto.SPLIT_SOURCE_DIRS, dir);
1273 }
1274 }
1275 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
1276 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
1277 for (String dir : splitPublicSourceDirs) {
1278 proto.write(ApplicationInfoProto.SPLIT_PUBLIC_SOURCE_DIRS, dir);
1279 }
1280 }
1281 if (resourceDirs != null) {
1282 for (String dir : resourceDirs) {
1283 proto.write(ApplicationInfoProto.RESOURCE_DIRS, dir);
1284 }
1285 }
1286 proto.write(ApplicationInfoProto.DATA_DIR, dataDir);
1287 proto.write(ApplicationInfoProto.CLASS_LOADER_NAME, classLoaderName);
1288 if (!ArrayUtils.isEmpty(splitClassLoaderNames)) {
1289 for (String name : splitClassLoaderNames) {
1290 proto.write(ApplicationInfoProto.SPLIT_CLASS_LOADER_NAMES, name);
1291 }
1292 }
1293
1294 long versionToken = proto.start(ApplicationInfoProto.VERSION);
1295 proto.write(ApplicationInfoProto.Version.ENABLED, enabled);
1296 proto.write(ApplicationInfoProto.Version.MIN_SDK_VERSION, minSdkVersion);
1297 proto.write(ApplicationInfoProto.Version.TARGET_SDK_VERSION, targetSdkVersion);
1298 proto.write(ApplicationInfoProto.Version.VERSION_CODE, versionCode);
1299 proto.write(ApplicationInfoProto.Version.TARGET_SANDBOX_VERSION, targetSandboxVersion);
1300 proto.end(versionToken);
1301
1302 if ((dumpFlags & DUMP_FLAG_DETAILS) != 0) {
1303 long detailToken = proto.start(ApplicationInfoProto.DETAIL);
1304 if (className != null) {
1305 proto.write(ApplicationInfoProto.Detail.CLASS_NAME, className);
1306 }
1307 proto.write(ApplicationInfoProto.Detail.TASK_AFFINITY, taskAffinity);
1308 proto.write(ApplicationInfoProto.Detail.REQUIRES_SMALLEST_WIDTH_DP,
1309 requiresSmallestWidthDp);
1310 proto.write(ApplicationInfoProto.Detail.COMPATIBLE_WIDTH_LIMIT_DP,
1311 compatibleWidthLimitDp);
1312 proto.write(ApplicationInfoProto.Detail.LARGEST_WIDTH_LIMIT_DP,
1313 largestWidthLimitDp);
1314 if (seInfo != null) {
1315 proto.write(ApplicationInfoProto.Detail.SEINFO, seInfo);
1316 proto.write(ApplicationInfoProto.Detail.SEINFO_USER, seInfoUser);
1317 }
1318 proto.write(ApplicationInfoProto.Detail.DEVICE_PROTECTED_DATA_DIR,
1319 deviceProtectedDataDir);
1320 proto.write(ApplicationInfoProto.Detail.CREDENTIAL_PROTECTED_DATA_DIR,
1321 credentialProtectedDataDir);
1322 if (sharedLibraryFiles != null) {
1323 for (String f : sharedLibraryFiles) {
1324 proto.write(ApplicationInfoProto.Detail.SHARED_LIBRARY_FILES, f);
1325 }
1326 }
1327 if (manageSpaceActivityName != null) {
1328 proto.write(ApplicationInfoProto.Detail.MANAGE_SPACE_ACTIVITY_NAME,
1329 manageSpaceActivityName);
1330 }
1331 if (descriptionRes != 0) {
1332 proto.write(ApplicationInfoProto.Detail.DESCRIPTION_RES, descriptionRes);
1333 }
1334 if (uiOptions != 0) {
1335 proto.write(ApplicationInfoProto.Detail.UI_OPTIONS, uiOptions);
1336 }
1337 proto.write(ApplicationInfoProto.Detail.SUPPORTS_RTL, hasRtlSupport());
1338 if (fullBackupContent > 0) {
1339 proto.write(ApplicationInfoProto.Detail.CONTENT, "@xml/" + fullBackupContent);
1340 } else {
1341 proto.write(ApplicationInfoProto.Detail.IS_FULL_BACKUP, fullBackupContent == 0);
1342 }
1343 if (networkSecurityConfigRes != 0) {
1344 proto.write(ApplicationInfoProto.Detail.NETWORK_SECURITY_CONFIG_RES,
1345 networkSecurityConfigRes);
1346 }
1347 if (category != CATEGORY_UNDEFINED) {
1348 proto.write(ApplicationInfoProto.Detail.CATEGORY, category);
1349 }
1350 proto.end(detailToken);
1351 }
1352 proto.end(token);
1353 }
1354
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001355 /**
1356 * @return true if "supportsRtl" has been set to true in the AndroidManifest
1357 * @hide
1358 */
1359 public boolean hasRtlSupport() {
1360 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1361 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -07001362
1363 /** {@hide} */
1364 public boolean hasCode() {
1365 return (flags & FLAG_HAS_CODE) != 0;
1366 }
1367
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001368 public static class DisplayNameComparator
1369 implements Comparator<ApplicationInfo> {
1370 public DisplayNameComparator(PackageManager pm) {
1371 mPM = pm;
1372 }
1373
1374 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1375 CharSequence sa = mPM.getApplicationLabel(aa);
1376 if (sa == null) {
1377 sa = aa.packageName;
1378 }
1379 CharSequence sb = mPM.getApplicationLabel(ab);
1380 if (sb == null) {
1381 sb = ab.packageName;
1382 }
1383
1384 return sCollator.compare(sa.toString(), sb.toString());
1385 }
1386
1387 private final Collator sCollator = Collator.getInstance();
1388 private PackageManager mPM;
1389 }
1390
1391 public ApplicationInfo() {
1392 }
1393
1394 public ApplicationInfo(ApplicationInfo orig) {
1395 super(orig);
1396 taskAffinity = orig.taskAffinity;
1397 permission = orig.permission;
1398 processName = orig.processName;
1399 className = orig.className;
1400 theme = orig.theme;
1401 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001402 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001403 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1404 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001405 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001406 volumeUuid = orig.volumeUuid;
Jeff Sharkey789a8fc2017-04-16 13:18:35 -06001407 storageUuid = orig.storageUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001408 scanSourceDir = orig.scanSourceDir;
1409 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001410 sourceDir = orig.sourceDir;
1411 publicSourceDir = orig.publicSourceDir;
Adam Lesinski4e862812016-11-21 16:02:24 -08001412 splitNames = orig.splitNames;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001413 splitSourceDirs = orig.splitSourceDirs;
1414 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Adam Lesinski4e862812016-11-21 16:02:24 -08001415 splitDependencies = orig.splitDependencies;
Kenny Root85387d72010-08-26 10:13:11 -07001416 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001417 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -07001418 nativeLibraryRootDir = orig.nativeLibraryRootDir;
1419 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001420 primaryCpuAbi = orig.primaryCpuAbi;
1421 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -08001422 resourceDirs = orig.resourceDirs;
Todd Kennedybe0b8892017-02-15 14:13:52 -08001423 seInfo = orig.seInfo;
1424 seInfoUser = orig.seInfoUser;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001425 sharedLibraryFiles = orig.sharedLibraryFiles;
1426 dataDir = orig.dataDir;
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001427 deviceProtectedDataDir = orig.deviceProtectedDataDir;
1428 credentialProtectedDataDir = orig.credentialProtectedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001429 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -08001430 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001431 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -08001432 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001433 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001434 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001435 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001436 manageSpaceActivityName = orig.manageSpaceActivityName;
1437 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -07001438 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -07001439 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -07001440 fullBackupContent = orig.fullBackupContent;
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001441 networkSecurityConfigRes = orig.networkSecurityConfigRes;
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001442 category = orig.category;
Todd Kennedy11e45072017-01-25 13:24:21 -08001443 targetSandboxVersion = orig.targetSandboxVersion;
Narayan Kamathf9419f02017-06-15 11:35:38 +01001444 classLoaderName = orig.classLoaderName;
1445 splitClassLoaderNames = orig.splitClassLoaderNames;
Jason Monka80bfb52017-11-16 17:15:37 -05001446 appComponentFactory = orig.appComponentFactory;
Adam Lesinskid3ea00992018-02-20 16:51:13 -08001447 compileSdkVersion = orig.compileSdkVersion;
1448 compileSdkVersionCodename = orig.compileSdkVersionCodename;
Mathew Inwoode3299532018-02-22 13:19:53 +00001449 mHiddenApiPolicy = orig.mHiddenApiPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001450 }
1451
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001452 public String toString() {
1453 return "ApplicationInfo{"
1454 + Integer.toHexString(System.identityHashCode(this))
1455 + " " + packageName + "}";
1456 }
1457
1458 public int describeContents() {
1459 return 0;
1460 }
1461
Adam Lesinski4e862812016-11-21 16:02:24 -08001462 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001463 public void writeToParcel(Parcel dest, int parcelableFlags) {
1464 super.writeToParcel(dest, parcelableFlags);
1465 dest.writeString(taskAffinity);
1466 dest.writeString(permission);
1467 dest.writeString(processName);
1468 dest.writeString(className);
1469 dest.writeInt(theme);
1470 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001471 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001472 dest.writeInt(requiresSmallestWidthDp);
1473 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001474 dest.writeInt(largestWidthLimitDp);
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001475 if (storageUuid != null) {
1476 dest.writeInt(1);
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001477 dest.writeLong(storageUuid.getMostSignificantBits());
1478 dest.writeLong(storageUuid.getLeastSignificantBits());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001479 } else {
1480 dest.writeInt(0);
1481 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001482 dest.writeString(scanSourceDir);
1483 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001484 dest.writeString(sourceDir);
1485 dest.writeString(publicSourceDir);
Adam Lesinski4e862812016-11-21 16:02:24 -08001486 dest.writeStringArray(splitNames);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001487 dest.writeStringArray(splitSourceDirs);
1488 dest.writeStringArray(splitPublicSourceDirs);
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001489 dest.writeSparseArray((SparseArray) splitDependencies);
Kenny Root85387d72010-08-26 10:13:11 -07001490 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001491 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -07001492 dest.writeString(nativeLibraryRootDir);
1493 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +01001494 dest.writeString(primaryCpuAbi);
1495 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -08001496 dest.writeStringArray(resourceDirs);
Todd Kennedybe0b8892017-02-15 14:13:52 -08001497 dest.writeString(seInfo);
1498 dest.writeString(seInfoUser);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001499 dest.writeStringArray(sharedLibraryFiles);
1500 dest.writeString(dataDir);
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001501 dest.writeString(deviceProtectedDataDir);
1502 dest.writeString(credentialProtectedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001503 dest.writeInt(uid);
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001504 dest.writeInt(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001505 dest.writeInt(targetSdkVersion);
Dianne Hackborn3accca02013-09-20 09:32:11 -07001506 dest.writeLong(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001507 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001508 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001509 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001510 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -07001511 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001512 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -07001513 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -07001514 dest.writeInt(fullBackupContent);
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001515 dest.writeInt(networkSecurityConfigRes);
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001516 dest.writeInt(category);
Todd Kennedy11e45072017-01-25 13:24:21 -08001517 dest.writeInt(targetSandboxVersion);
Narayan Kamathf9419f02017-06-15 11:35:38 +01001518 dest.writeString(classLoaderName);
1519 dest.writeStringArray(splitClassLoaderNames);
Alan Viveretteb6a25732017-11-21 14:49:24 -05001520 dest.writeInt(compileSdkVersion);
1521 dest.writeString(compileSdkVersionCodename);
Jason Monka80bfb52017-11-16 17:15:37 -05001522 dest.writeString(appComponentFactory);
Mathew Inwoode3299532018-02-22 13:19:53 +00001523 dest.writeInt(mHiddenApiPolicy);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001524 }
1525
1526 public static final Parcelable.Creator<ApplicationInfo> CREATOR
1527 = new Parcelable.Creator<ApplicationInfo>() {
1528 public ApplicationInfo createFromParcel(Parcel source) {
1529 return new ApplicationInfo(source);
1530 }
1531 public ApplicationInfo[] newArray(int size) {
1532 return new ApplicationInfo[size];
1533 }
1534 };
1535
Adam Lesinski4e862812016-11-21 16:02:24 -08001536 @SuppressWarnings("unchecked")
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001537 private ApplicationInfo(Parcel source) {
1538 super(source);
1539 taskAffinity = source.readString();
1540 permission = source.readString();
1541 processName = source.readString();
1542 className = source.readString();
1543 theme = source.readInt();
1544 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001545 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001546 requiresSmallestWidthDp = source.readInt();
1547 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001548 largestWidthLimitDp = source.readInt();
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001549 if (source.readInt() != 0) {
Jeff Sharkeya4d34d92017-04-27 11:21:41 -06001550 storageUuid = new UUID(source.readLong(), source.readLong());
Jeff Sharkey67c8c1e2017-04-19 11:22:02 -06001551 volumeUuid = StorageManager.convert(storageUuid);
1552 }
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001553 scanSourceDir = source.readString();
1554 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001555 sourceDir = source.readString();
1556 publicSourceDir = source.readString();
Adam Lesinski4e862812016-11-21 16:02:24 -08001557 splitNames = source.readStringArray();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001558 splitSourceDirs = source.readStringArray();
1559 splitPublicSourceDirs = source.readStringArray();
Adam Lesinski1665d0f2017-03-10 14:46:57 -08001560 splitDependencies = source.readSparseArray(null);
Kenny Root85387d72010-08-26 10:13:11 -07001561 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001562 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -07001563 nativeLibraryRootDir = source.readString();
1564 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001565 primaryCpuAbi = source.readString();
1566 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -08001567 resourceDirs = source.readStringArray();
Todd Kennedybe0b8892017-02-15 14:13:52 -08001568 seInfo = source.readString();
1569 seInfoUser = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001570 sharedLibraryFiles = source.readStringArray();
1571 dataDir = source.readString();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001572 deviceProtectedDataDir = source.readString();
1573 credentialProtectedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001574 uid = source.readInt();
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001575 minSdkVersion = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001576 targetSdkVersion = source.readInt();
Dianne Hackborn3accca02013-09-20 09:32:11 -07001577 versionCode = source.readLong();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001578 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001579 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001580 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001581 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001582 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001583 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001584 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001585 fullBackupContent = source.readInt();
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001586 networkSecurityConfigRes = source.readInt();
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001587 category = source.readInt();
Todd Kennedy11e45072017-01-25 13:24:21 -08001588 targetSandboxVersion = source.readInt();
Narayan Kamathf9419f02017-06-15 11:35:38 +01001589 classLoaderName = source.readString();
1590 splitClassLoaderNames = source.readStringArray();
Alan Viveretteb6a25732017-11-21 14:49:24 -05001591 compileSdkVersion = source.readInt();
1592 compileSdkVersionCodename = source.readString();
Jason Monka80bfb52017-11-16 17:15:37 -05001593 appComponentFactory = source.readString();
Mathew Inwoode3299532018-02-22 13:19:53 +00001594 mHiddenApiPolicy = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001595 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001596
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001597 /**
1598 * Retrieve the textual description of the application. This
1599 * will call back on the given PackageManager to load the description from
1600 * the application.
1601 *
1602 * @param pm A PackageManager from which the label can be loaded; usually
1603 * the PackageManager from which you originally retrieved this item.
1604 *
1605 * @return Returns a CharSequence containing the application's description.
1606 * If there is no description, null is returned.
1607 */
1608 public CharSequence loadDescription(PackageManager pm) {
1609 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001610 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001611 if (label != null) {
1612 return label;
1613 }
1614 }
1615 return null;
1616 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001617
1618 /**
1619 * Disable compatibility mode
1620 *
1621 * @hide
1622 */
1623 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001624 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001625 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001626 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001627 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001628
skuhne@google.com7e85eb02017-01-04 13:49:54 -08001629 /**
1630 * Is using compatibility mode for non densty aware legacy applications.
1631 *
1632 * @hide
1633 */
1634 public boolean usesCompatibilityMode() {
1635 return targetSdkVersion < DONUT ||
1636 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1637 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1638 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1639 }
1640
Jeff Sharkey15447792015-11-05 16:18:51 -08001641 /** {@hide} */
1642 public void initForUser(int userId) {
1643 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1644
1645 if ("android".equals(packageName)) {
1646 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1647 return;
1648 }
1649
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001650 deviceProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001651 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001652 .getAbsolutePath();
Jeff Sharkeydd9bda82017-02-23 17:38:31 -07001653 credentialProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001654 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001655 .getAbsolutePath();
1656
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001657 if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1658 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1659 dataDir = deviceProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001660 } else {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001661 dataDir = credentialProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001662 }
1663 }
1664
Mathew Inwoode3299532018-02-22 13:19:53 +00001665 private boolean isPackageWhitelistedForHiddenApis() {
1666 return SystemConfig.getInstance().getHiddenApiWhitelistedApps().contains(packageName);
1667 }
1668
Mathew Inwood9d895432018-04-04 16:08:21 +01001669 private boolean isAllowedToUseHiddenApis() {
1670 return isSignedWithPlatformKey()
1671 || (isPackageWhitelistedForHiddenApis() && (isSystemApp() || isUpdatedSystemApp()));
1672 }
1673
Jeff Brown07330792010-03-30 19:57:08 -07001674 /**
1675 * @hide
1676 */
Mathew Inwoode3299532018-02-22 13:19:53 +00001677 public @HiddenApiEnforcementPolicy int getHiddenApiEnforcementPolicy() {
1678 if (mHiddenApiPolicy != HIDDEN_API_ENFORCEMENT_DEFAULT) {
1679 return mHiddenApiPolicy;
1680 }
Mathew Inwood9d895432018-04-04 16:08:21 +01001681 if (isAllowedToUseHiddenApis()) {
Mathew Inwoode3299532018-02-22 13:19:53 +00001682 return HIDDEN_API_ENFORCEMENT_NONE;
1683 }
1684 return HIDDEN_API_ENFORCEMENT_BLACK;
1685 }
1686
1687 /**
1688 * @hide
1689 */
1690 public void setHiddenApiEnforcementPolicy(@HiddenApiEnforcementPolicy int policy) {
1691 if (!isValidHiddenApiEnforcementPolicy(policy)) {
1692 throw new IllegalArgumentException("Invalid API enforcement policy: " + policy);
1693 }
1694 mHiddenApiPolicy = policy;
David Brazdil464ed3d2018-01-18 15:25:18 +00001695 }
1696
1697 /**
1698 * @hide
1699 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001700 @Override
1701 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001702 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1703 && isPackageUnavailable(pm)) {
1704 return Resources.getSystem().getDrawable(
1705 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1706 }
1707 return pm.getDefaultActivityIcon();
1708 }
1709
1710 private boolean isPackageUnavailable(PackageManager pm) {
1711 try {
1712 return pm.getPackageInfo(packageName, 0) == null;
1713 } catch (NameNotFoundException ex) {
1714 return true;
1715 }
1716 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001717
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001718 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001719 public boolean isDefaultToDeviceProtectedStorage() {
1720 return (privateFlags
1721 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
Jeff Sharkeye4697132016-02-06 19:46:15 -07001722 }
1723
1724 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001725 public boolean isDirectBootAware() {
1726 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001727 }
1728
Jeff Sharkey8924e872015-11-30 12:52:10 -07001729 /** @hide */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001730 public boolean isEncryptionAware() {
1731 return isDirectBootAware() || isPartiallyDirectBootAware();
1732 }
1733
1734 /** @hide */
1735 public boolean isExternal() {
1736 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1737 }
1738
1739 /** @hide */
1740 public boolean isExternalAsec() {
1741 return TextUtils.isEmpty(volumeUuid) && isExternal();
1742 }
1743
1744 /** @hide */
1745 public boolean isForwardLocked() {
1746 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1747 }
1748
Patrick Baumann159cd022018-01-11 13:25:05 -08001749 /**
1750 * True if the application is installed as an instant app.
1751 * @hide
1752 */
1753 @SystemApi
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001754 public boolean isInstantApp() {
1755 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_INSTANT) != 0;
1756 }
1757
1758 /** @hide */
1759 public boolean isInternal() {
1760 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1761 }
1762
1763 /** @hide */
1764 public boolean isOem() {
1765 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
1766 }
1767
1768 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001769 public boolean isPartiallyDirectBootAware() {
1770 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkey8924e872015-11-30 12:52:10 -07001771 }
1772
Bryce Lee8558ec72017-08-17 15:37:26 -07001773 /** @hide */
Mathew Inwood9d895432018-04-04 16:08:21 +01001774 public boolean isSignedWithPlatformKey() {
1775 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_SIGNED_WITH_PLATFORM_KEY) != 0;
1776 }
1777
1778 /** @hide */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001779 @TestApi
1780 public boolean isPrivilegedApp() {
1781 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
Bryce Lee8558ec72017-08-17 15:37:26 -07001782 }
1783
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001784 /** @hide */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001785 public boolean isRequiredForSystemUser() {
1786 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1787 }
1788
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001789 /** @hide */
Svet Ganov67882122016-12-11 16:36:34 -08001790 public boolean isStaticSharedLibrary() {
1791 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
1792 }
1793
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001794 /** @hide */
1795 @TestApi
1796 public boolean isSystemApp() {
1797 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1798 }
1799
1800 /** @hide */
1801 public boolean isUpdatedSystemApp() {
1802 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1803 }
1804
Jiyong Park002fdbd2017-02-13 20:50:31 +09001805 /** @hide */
1806 public boolean isVendor() {
1807 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0;
1808 }
1809
Jaekyun Seok1713d9e2018-01-12 21:47:26 +09001810 /** @hide */
1811 public boolean isProduct() {
1812 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRODUCT) != 0;
1813 }
1814
Svet Ganov67882122016-12-11 16:36:34 -08001815 /**
Todd Kennedy5eb5a7d2017-08-01 07:42:47 -07001816 * Returns whether or not this application was installed as a virtual preload.
1817 */
1818 public boolean isVirtualPreload() {
1819 return (privateFlags & PRIVATE_FLAG_VIRTUAL_PRELOAD) != 0;
1820 }
1821
1822 /**
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001823 * Returns true if the app has declared in its manifest that it wants its split APKs to be
1824 * loaded into isolated Contexts, with their own ClassLoaders and Resources objects.
Svet Ganov67882122016-12-11 16:36:34 -08001825 * @hide
1826 */
Todd Kennedyc29b11a2017-10-23 15:55:59 -07001827 public boolean requestsIsolatedSplitLoading() {
1828 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_ISOLATED_SPLIT_LOADING) != 0;
Svet Ganov087dce22017-09-07 15:42:16 -07001829 }
1830
1831 /**
1832 * @hide
1833 */
Jeff Brown07330792010-03-30 19:57:08 -07001834 @Override protected ApplicationInfo getApplicationInfo() {
1835 return this;
1836 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001837
1838 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1839 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1840 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1841 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1842 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1843 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1844
1845 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1846 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1847 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1848 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1849 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
Jeff Sharkeya3a43b02016-11-15 17:54:23 -07001850 /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001851}