blob: 71071e1d45ad5bd19c9da0a795d5bcdb775d1adb [file] [log] [blame]
Kenny Root15a4d2f2010-03-11 18:20:12 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080017package android.content.pm;
18
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070019import static android.os.Build.VERSION_CODES.DONUT;
20
21import android.annotation.IntDef;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060022import android.annotation.SystemApi;
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -070023import android.annotation.TestApi;
Jeff Sharkey8a372a02016-03-16 16:25:45 -060024import android.content.Context;
Jeff Brown07330792010-03-30 19:57:08 -070025import android.content.pm.PackageManager.NameNotFoundException;
26import android.content.res.Resources;
27import android.graphics.drawable.Drawable;
Jeff Sharkey15447792015-11-05 16:18:51 -080028import android.os.Environment;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.os.Parcel;
30import android.os.Parcelable;
Jeff Sharkey15447792015-11-05 16:18:51 -080031import android.os.UserHandle;
Jeff Sharkeye2d45be2015-04-15 17:14:12 -070032import android.text.TextUtils;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.util.Printer;
34
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070035import com.android.internal.util.ArrayUtils;
36
Jeff Sharkey9bc89af2017-01-11 11:25:50 -070037import java.lang.annotation.Retention;
38import java.lang.annotation.RetentionPolicy;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import java.text.Collator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070040import java.util.Arrays;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import java.util.Comparator;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -070042import java.util.Objects;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043
44/**
45 * Information you can retrieve about a particular application. This
46 * corresponds to information collected from the AndroidManifest.xml's
47 * <application> tag.
48 */
49public class ApplicationInfo extends PackageItemInfo implements Parcelable {
50
51 /**
52 * Default task affinity of all activities in this application. See
53 * {@link ActivityInfo#taskAffinity} for more information. This comes
54 * from the "taskAffinity" attribute.
55 */
56 public String taskAffinity;
57
58 /**
59 * Optional name of a permission required to be able to access this
60 * application's components. From the "permission" attribute.
61 */
62 public String permission;
63
64 /**
65 * The name of the process this application should run in. From the
66 * "process" attribute or, if not set, the same as
67 * <var>packageName</var>.
68 */
69 public String processName;
70
71 /**
72 * Class implementing the Application object. From the "class"
73 * attribute.
74 */
75 public String className;
76
77 /**
78 * A style resource identifier (in the package's resources) of the
79 * description of an application. From the "description" attribute
80 * or, if not set, 0.
81 */
82 public int descriptionRes;
83
84 /**
85 * A style resource identifier (in the package's resources) of the
86 * default visual theme of the application. From the "theme" attribute
87 * or, if not set, 0.
88 */
89 public int theme;
90
91 /**
92 * Class implementing the Application's manage space
93 * functionality. From the "manageSpaceActivity"
94 * attribute. This is an optional attribute and will be null if
Christopher Tate181fafa2009-05-14 11:12:14 -070095 * applications don't specify it in their manifest
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 */
97 public String manageSpaceActivityName;
98
99 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700100 * Class implementing the Application's backup functionality. From
101 * the "backupAgent" attribute. This is an optional attribute and
102 * will be null if the application does not specify it in its manifest.
103 *
104 * <p>If android:allowBackup is set to false, this attribute is ignored.
Christopher Tate181fafa2009-05-14 11:12:14 -0700105 */
106 public String backupAgentName;
Christopher Tate4a627c72011-04-01 14:43:32 -0700107
108 /**
Matthew Williams303650c2015-04-17 18:22:51 -0700109 * An optional attribute that indicates the app supports automatic backup of app data.
110 * <p>0 is the default and means the app's entire data folder + managed external storage will
111 * be backed up;
112 * Any negative value indicates the app does not support full-data backup, though it may still
113 * want to participate via the traditional key/value backup API;
114 * A positive number specifies an xml resource in which the application has defined its backup
115 * include/exclude criteria.
116 * <p>If android:allowBackup is set to false, this attribute is ignored.
117 *
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600118 * @see android.content.Context#getNoBackupFilesDir()
119 * @see #FLAG_ALLOW_BACKUP
Christopher Tate98fa6562015-05-14 13:20:10 -0700120 *
121 * @hide
Matthew Williams303650c2015-04-17 18:22:51 -0700122 */
123 public int fullBackupContent = 0;
124
125 /**
Adam Powell269248d2011-08-02 10:26:54 -0700126 * The default extra UI options for activities in this application.
127 * Set from the {@link android.R.attr#uiOptions} attribute in the
128 * activity's manifest.
129 */
130 public int uiOptions = 0;
131
132 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800133 * Value for {@link #flags}: if set, this application is installed in the
134 * device's system image.
135 */
136 public static final int FLAG_SYSTEM = 1<<0;
137
138 /**
139 * Value for {@link #flags}: set to true if this application would like to
140 * allow debugging of its
141 * code, even when installed on a non-development system. Comes
142 * from {@link android.R.styleable#AndroidManifestApplication_debuggable
143 * android:debuggable} of the &lt;application&gt; tag.
144 */
145 public static final int FLAG_DEBUGGABLE = 1<<1;
146
147 /**
148 * Value for {@link #flags}: set to true if this application has code
149 * associated with it. Comes
150 * from {@link android.R.styleable#AndroidManifestApplication_hasCode
151 * android:hasCode} of the &lt;application&gt; tag.
152 */
153 public static final int FLAG_HAS_CODE = 1<<2;
154
155 /**
156 * Value for {@link #flags}: set to true if this application is persistent.
157 * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
158 * android:persistent} of the &lt;application&gt; tag.
159 */
160 public static final int FLAG_PERSISTENT = 1<<3;
161
162 /**
Christopher Tate181fafa2009-05-14 11:12:14 -0700163 * Value for {@link #flags}: set to true if this application holds the
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800164 * {@link android.Manifest.permission#FACTORY_TEST} permission and the
165 * device is running in factory test mode.
166 */
167 public static final int FLAG_FACTORY_TEST = 1<<4;
168
169 /**
170 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
171 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
172 * android:allowTaskReparenting} of the &lt;application&gt; tag.
173 */
174 public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
175
176 /**
177 * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
178 * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
179 * android:allowClearUserData} of the &lt;application&gt; tag.
180 */
181 public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
182
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800183 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700184 * Value for {@link #flags}: this is set if this application has been
Kweku Adams8de29ca2016-01-22 12:30:26 -0800185 * installed as an update to a built-in system application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800186 */
187 public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
Dianne Hackborn851a5412009-05-08 12:06:44 -0700188
189 /**
Svet Ganov354cd3c2015-12-17 11:35:04 -0800190 * Value for {@link #flags}: this is set if the application has specified
Dianne Hackborn7f205432009-07-28 00:13:47 -0700191 * {@link android.R.styleable#AndroidManifestApplication_testOnly
192 * android:testOnly} to be true.
Dianne Hackborn851a5412009-05-08 12:06:44 -0700193 */
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700194 public static final int FLAG_TEST_ONLY = 1<<8;
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700195
196 /**
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700197 * Value for {@link #flags}: true when the application's window can be
Dianne Hackborn723738c2009-06-25 19:48:04 -0700198 * reduced in size for smaller screens. Corresponds to
199 * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
200 * android:smallScreens}.
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700201 */
Dianne Hackborn723738c2009-06-25 19:48:04 -0700202 public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
203
204 /**
205 * Value for {@link #flags}: true when the application's window can be
206 * displayed on normal screens. Corresponds to
207 * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
208 * android:normalScreens}.
209 */
210 public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
211
212 /**
213 * Value for {@link #flags}: true when the application's window can be
214 * increased in size for larger screens. Corresponds to
215 * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700216 * android:largeScreens}.
Dianne Hackborn723738c2009-06-25 19:48:04 -0700217 */
218 public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
Dianne Hackborn5c1e00b2009-06-18 17:10:57 -0700219
220 /**
Dianne Hackbornc4db95c2009-07-21 17:46:02 -0700221 * Value for {@link #flags}: true when the application knows how to adjust
222 * its UI for different screen sizes. Corresponds to
223 * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
224 * android:resizeable}.
225 */
226 public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
227
228 /**
Dianne Hackborn11b822d2009-07-21 20:03:02 -0700229 * Value for {@link #flags}: true when the application knows how to
230 * accomodate different screen densities. Corresponds to
231 * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
232 * android:anyDensity}.
233 */
234 public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
235
236 /**
Ben Cheng23085b72010-02-08 16:06:32 -0800237 * Value for {@link #flags}: set to true if this application would like to
238 * request the VM to operate under the safe mode. Comes from
Ben Chengef3f5dd2010-03-29 15:47:26 -0700239 * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
240 * android:vmSafeMode} of the &lt;application&gt; tag.
Ben Cheng23085b72010-02-08 16:06:32 -0800241 */
242 public static final int FLAG_VM_SAFE_MODE = 1<<14;
243
244 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800245 * Value for {@link #flags}: set to <code>false</code> if the application does not wish
246 * to permit any OS-driven backups of its data; <code>true</code> otherwise.
Christopher Tate181fafa2009-05-14 11:12:14 -0700247 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800248 * <p>Comes from the
249 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
250 * attribute of the &lt;application&gt; tag.
Christopher Tate181fafa2009-05-14 11:12:14 -0700251 */
Ben Cheng23085b72010-02-08 16:06:32 -0800252 public static final int FLAG_ALLOW_BACKUP = 1<<15;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700253
254 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800255 * Value for {@link #flags}: set to <code>false</code> if the application must be kept
256 * in memory following a full-system restore operation; <code>true</code> otherwise.
257 * Ordinarily, during a full system restore operation each application is shut down
258 * following execution of its agent's onRestore() method. Setting this attribute to
259 * <code>false</code> prevents this. Most applications will not need to set this attribute.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700260 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800261 * <p>If
262 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
263 * is set to <code>false</code> or no
264 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700265 * is specified, this flag will be ignored.
266 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800267 * <p>Comes from the
268 * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
269 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700270 */
Ben Cheng23085b72010-02-08 16:06:32 -0800271 public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700272
273 /**
Christopher Tate3de55bc2010-03-12 17:28:08 -0800274 * Value for {@link #flags}: Set to <code>true</code> if the application's backup
275 * agent claims to be able to handle restore data even "from the future,"
276 * i.e. from versions of the application with a versionCode greater than
277 * the one currently installed on the device. <i>Use with caution!</i> By default
278 * this attribute is <code>false</code> and the Backup Manager will ensure that data
279 * from "future" versions of the application are never supplied during a restore operation.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700280 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800281 * <p>If
282 * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
283 * is set to <code>false</code> or no
284 * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
Christopher Tate5e1ab332009-09-01 20:32:49 -0700285 * is specified, this flag will be ignored.
286 *
Christopher Tate3de55bc2010-03-12 17:28:08 -0800287 * <p>Comes from the
288 * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
289 * attribute of the &lt;application&gt; tag.
Christopher Tate5e1ab332009-09-01 20:32:49 -0700290 */
Christopher Tate3de55bc2010-03-12 17:28:08 -0800291 public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
Christopher Tate5e1ab332009-09-01 20:32:49 -0700292
Christopher Tate181fafa2009-05-14 11:12:14 -0700293 /**
Dianne Hackborn3202d382010-04-26 17:51:34 -0700294 * Value for {@link #flags}: Set to true if the application is
295 * currently installed on external/removable/unprotected storage. Such
296 * applications may not be available if their storage is not currently
297 * mounted. When the storage it is on is not available, it will look like
298 * the application has been uninstalled (its .apk is no longer available)
299 * but its persistent data is not removed.
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800300 */
Dianne Hackborn94c567e2010-04-26 18:13:10 -0700301 public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800302
303 /**
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700304 * Value for {@link #flags}: true when the application's window can be
305 * increased in size for extra large screens. Corresponds to
306 * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
Dianne Hackborn22ec9ab2010-04-29 17:56:03 -0700307 * android:xlargeScreens}.
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700308 */
309 public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
310
311 /**
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800312 * Value for {@link #flags}: true when the application has requested a
313 * large heap for its processes. Corresponds to
314 * {@link android.R.styleable#AndroidManifestApplication_largeHeap
315 * android:largeHeap}.
Jason parksa3cdaa52011-01-13 14:15:43 -0600316 */
Dianne Hackborn3b81bc12011-01-15 11:50:52 -0800317 public static final int FLAG_LARGE_HEAP = 1<<20;
Jason parksa3cdaa52011-01-13 14:15:43 -0600318
319 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -0800320 * Value for {@link #flags}: true if this application's package is in
321 * the stopped state.
322 */
323 public static final int FLAG_STOPPED = 1<<21;
324
325 /**
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700326 * Value for {@link #flags}: true when the application is willing to support
327 * RTL (right to left). All activities will inherit this value.
328 *
329 * Set from the {@link android.R.attr#supportsRtl} attribute in the
330 * activity's manifest.
331 *
332 * Default value is false (no support for RTL).
333 */
334 public static final int FLAG_SUPPORTS_RTL = 1<<22;
335
336 /**
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700337 * Value for {@link #flags}: true if the application is currently
338 * installed for the calling user.
339 */
340 public static final int FLAG_INSTALLED = 1<<23;
341
342 /**
Dianne Hackborn5e03e2c2012-09-06 14:21:19 -0700343 * Value for {@link #flags}: true if the application only has its
344 * data installed; the application package itself does not currently
345 * exist on the device.
346 */
347 public static final int FLAG_IS_DATA_ONLY = 1<<24;
348
349 /**
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700350 * Value for {@link #flags}: true if the application was declared to be a
351 * game, or false if it is a non-game application.
352 *
353 * @deprecated use {@link #CATEGORY_GAME} instead.
Jose Lima12d0b4c2014-03-14 16:55:12 -0700354 */
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700355 @Deprecated
Jose Lima12d0b4c2014-03-14 16:55:12 -0700356 public static final int FLAG_IS_GAME = 1<<25;
357
358 /**
Christopher Tated1de2562014-06-17 17:12:35 -0700359 * Value for {@link #flags}: {@code true} if the application asks that only
360 * full-data streaming backups of its data be performed even though it defines
361 * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
362 * indicates that the app will manage its backed-up data via incremental
363 * key/value updates.
364 */
365 public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
366
367 /**
Alex Klyubin01a959d2015-03-18 10:05:45 -0700368 * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
369 * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
370 * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
371 * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
Alex Klyubinfbf45992015-04-21 13:44:29 -0700372 * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
373 * traffic. Third-party libraries are encouraged to honor this flag as well.
374 *
375 * <p>NOTE: {@code WebView} does not honor this flag.
376 *
Chad Brubaker2df5ba72016-04-11 13:31:24 -0700377 * <p>This flag is ignored on Android N and above if an Android Network Security Config is
378 * present.
379 *
Alex Klyubinfbf45992015-04-21 13:44:29 -0700380 * <p>This flag comes from
381 * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
382 * android:usesCleartextTraffic} of the &lt;application&gt; tag.
Alex Klyubin01a959d2015-03-18 10:05:45 -0700383 */
384 public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
385
386 /**
Dmitriy Ivanovff193d62014-09-30 15:10:48 -0700387 * When set installer extracts native libs from .apk files.
388 */
389 public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
390
391 /**
Alan Viveretted70b9e72015-05-27 14:29:20 -0700392 * Value for {@link #flags}: {@code true} when the application's rendering
393 * should be hardware accelerated.
394 */
395 public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
396
397 /**
Andrei Stingaceanu1e283912015-11-26 15:26:28 +0000398 * Value for {@link #flags}: true if this application's package is in
399 * the suspended state.
400 */
401 public static final int FLAG_SUSPENDED = 1<<30;
402
403 /**
Narayan Kamath589a1bc2014-07-03 14:43:26 +0100404 * Value for {@link #flags}: true if code from this application will need to be
405 * loaded into other applications' processes. On devices that support multiple
406 * instruction sets, this implies the code might be loaded into a process that's
407 * using any of the devices supported instruction sets.
408 *
409 * <p> The system might treat such applications specially, for eg., by
410 * extracting the application's native libraries for all supported instruction
411 * sets or by compiling the application's dex code for all supported instruction
412 * sets.
413 */
414 public static final int FLAG_MULTIARCH = 1 << 31;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700415
416 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800417 * Flags associated with the application. Any combination of
418 * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
419 * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
420 * {@link #FLAG_ALLOW_TASK_REPARENTING}
Dianne Hackborn851a5412009-05-08 12:06:44 -0700421 * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
Dianne Hackborn723738c2009-06-25 19:48:04 -0700422 * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
423 * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
Dianne Hackborn14cee9f2010-04-23 17:51:26 -0700424 * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
425 * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
Dianne Hackborn7767eac2012-08-23 18:25:40 -0700426 * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800427 * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
428 * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
429 * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
430 * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
431 * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
Alex Klyubin7cb000f2015-03-26 11:00:04 -0700432 * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
433 * {@link #FLAG_MULTIARCH}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800434 */
435 public int flags = 0;
Amith Yamasani655d0e22013-06-12 14:19:10 -0700436
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800437 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800438 * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
439 * most purposes is considered as not installed.
440 * {@hide}
441 */
442 public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
443
444 /**
445 * Value for {@link #privateFlags}: set to <code>true</code> if the application
446 * has reported that it is heavy-weight, and thus can not participate in
447 * the normal application lifecycle.
448 *
449 * <p>Comes from the
450 * android.R.styleable#AndroidManifestApplication_cantSaveState
451 * attribute of the &lt;application&gt; tag.
452 *
453 * {@hide}
454 */
455 public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
456
457 /**
458 * Value for {@link #privateFlags}: Set to true if the application has been
459 * installed using the forward lock option.
460 *
461 * NOTE: DO NOT CHANGE THIS VALUE! It is saved in packages.xml.
462 *
463 * {@hide}
464 */
465 public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
466
467 /**
468 * Value for {@link #privateFlags}: set to {@code true} if the application
469 * is permitted to hold privileged permissions.
470 *
471 * {@hide}
472 */
473 public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
474
475 /**
Svet Ganov2acf0632015-11-24 19:10:59 -0800476 * Value for {@link #privateFlags}: {@code true} if the application has any IntentFiler
477 * with some data URI using HTTP or HTTPS with an associated VIEW action.
Fabrice Di Megliod3d8a322015-04-01 15:58:47 -0700478 *
479 * {@hide}
480 */
481 public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
482
483 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600484 * When set, the default data storage directory for this app is pointed at
485 * the device-protected location.
Jeff Sharkey15447792015-11-05 16:18:51 -0800486 *
487 * @hide
488 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600489 public static final int PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = 1 << 5;
Jeff Sharkey15447792015-11-05 16:18:51 -0800490
491 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600492 * When set, assume that all components under the given app are direct boot
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800493 * aware, unless otherwise specified.
494 *
495 * @hide
496 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600497 public static final int PRIVATE_FLAG_DIRECT_BOOT_AWARE = 1 << 6;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -0800498
499 /**
Chad Brubaker4389c232016-11-04 14:50:50 -0700500 * Value for {@link #flags}: {@code true} if the application is blocked via restrictions
501 * and for most purposes is considered as not installed.
502 * {@hide}
503 */
504 public static final int PRIVATE_FLAG_EPHEMERAL = 1 << 7;
505
506 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600507 * When set, at least one component inside this application is direct boot
508 * aware.
Jeff Sharkey8924e872015-11-30 12:52:10 -0700509 *
510 * @hide
511 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600512 public static final int PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE = 1 << 8;
Jeff Sharkey8924e872015-11-30 12:52:10 -0700513
Fyodor Kupolovf99104d2015-12-14 11:31:29 -0800514
515 /**
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800516 * When set, signals that the application is required for the system user and should not be
517 * uninstalled.
518 *
519 * @hide
520 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700521 public static final int PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER = 1 << 9;
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -0800522
523 /**
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700524 * When set, the application explicitly requested that its activities by resizeable by default.
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800525 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
526 *
527 * @hide
528 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700529 public static final int PRIVATE_FLAG_RESIZEABLE_ACTIVITIES_EXPLICITLY_SET = 1 << 10;
Wale Ogunwale72a73e32016-10-13 12:16:39 -0700530
531 /**
532 * The application isn't requesting explicitly requesting for its activities to be resizeable or
533 * non-resizeable by default. So, we are making it activities resizeable by default based on the
534 * target SDK version of the app.
535 * @see android.R.styleable#AndroidManifestActivity_resizeableActivity
536 *
537 * NOTE: This only affects apps with target SDK >= N where the resizeableActivity attribute was
538 * introduced. It shouldn't be confused with {@link ActivityInfo#RESIZE_MODE_FORCE_RESIZEABLE}
539 * where certain pre-N apps are forced to the resizeable.
540 *
541 * @hide
542 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700543 public static final int PRIVATE_FLAG_RESIZEABLE_ACTIVITIES_VIA_SDK_VERSION = 1 << 11;
Wale Ogunwale6afdf912016-01-30 13:01:33 -0800544
545 /**
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800546 * Value for {@link #privateFlags}: {@code true} means the OS should go ahead and
547 * run full-data backup operations for the app even when it is in a
548 * foreground-equivalent run state. Defaults to {@code false} if unspecified.
549 * @hide
550 */
Chad Brubaker4389c232016-11-04 14:50:50 -0700551 public static final int PRIVATE_FLAG_BACKUP_IN_FOREGROUND = 1 << 12;
Christopher Tate43fbc5f2016-02-17 18:00:48 -0800552
553 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800554 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
555 * {@hide}
556 */
557 public int privateFlags;
558
559 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700560 * The required smallest screen width the application can run on. If 0,
561 * nothing has been specified. Comes from
562 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
563 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
564 */
565 public int requiresSmallestWidthDp = 0;
566
567 /**
568 * The maximum smallest screen width the application is designed for. If 0,
569 * nothing has been specified. Comes from
570 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
571 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
572 */
573 public int compatibleWidthLimitDp = 0;
574
575 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700576 * The maximum smallest screen width the application will work on. If 0,
577 * nothing has been specified. Comes from
578 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
579 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
580 */
581 public int largestWidthLimitDp = 0;
582
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700583 /** {@hide} */
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700584 public String volumeUuid;
585 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700586 public String scanSourceDir;
587 /** {@hide} */
588 public String scanPublicSourceDir;
589
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700590 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700591 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800592 */
593 public String sourceDir;
594
595 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700596 * Full path to the publicly available parts of {@link #sourceDir},
597 * including resources and manifest. This may be different from
598 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800599 */
600 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700601
602 /**
603 * Full paths to zero or more split APKs that, when combined with the base
604 * APK defined in {@link #sourceDir}, form a complete application.
605 */
606 public String[] splitSourceDirs;
607
608 /**
609 * Full path to the publicly available parts of {@link #splitSourceDirs},
610 * including resources and manifest. This may be different from
611 * {@link #splitSourceDirs} if an application is forward locked.
612 */
613 public String[] splitPublicSourceDirs;
614
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800615 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800616 * Full paths to the locations of extra resource packages this application
617 * uses. This field is only used if there are extra resource packages,
618 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800619 *
620 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800621 */
622 public String[] resourceDirs;
623
624 /**
Robert Craig0f40dc92013-03-25 06:33:03 -0400625 * String retrieved from the seinfo tag found in selinux policy. This value
Robert Craig5e16bc52015-08-28 12:11:41 -0400626 * can be overridden with a value set through the mac_permissions.xml policy
627 * construct. This value is useful in setting an SELinux security context on
628 * the process as well as its data directory. The String default is being used
629 * here to represent a catchall label when no policy matches.
Robert Craig0f40dc92013-03-25 06:33:03 -0400630 *
631 * {@hide}
632 */
Robert Craig5e16bc52015-08-28 12:11:41 -0400633 public String seinfo = "default";
Robert Craig0f40dc92013-03-25 06:33:03 -0400634
635 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800636 * Paths to all shared libraries this application is linked against. This
637 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
638 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
639 * the structure.
640 */
641 public String[] sharedLibraryFiles;
642
643 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700644 * Full path to the default directory assigned to the package for its
645 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800646 */
647 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700648
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700649 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600650 * Full path to the device-protected directory assigned to the package for
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700651 * its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600652 *
653 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700654 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600655 public String deviceProtectedDataDir;
656
657 /** @removed */
658 @Deprecated
Jeff Sharkey15447792015-11-05 16:18:51 -0800659 public String deviceEncryptedDataDir;
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700660
661 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600662 * Full path to the credential-protected directory assigned to the package
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700663 * for its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600664 *
665 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700666 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600667 @SystemApi
668 public String credentialProtectedDataDir;
669
670 /** @removed */
671 @Deprecated
Jeff Sharkey15447792015-11-05 16:18:51 -0800672 public String credentialEncryptedDataDir;
673
Kenny Root85387d72010-08-26 10:13:11 -0700674 /**
675 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700676 */
677 public String nativeLibraryDir;
678
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800679 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100680 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
681 * are stored, if present.
682 *
683 * The main reason this exists is for bundled multi-arch apps, where
684 * it's not trivial to calculate the location of libs for the secondary abi
685 * given the location of the primary.
686 *
687 * TODO: Change the layout of bundled installs so that we can use
688 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
689 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
690 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
691 *
692 * @hide
693 */
694 public String secondaryNativeLibraryDir;
695
696 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700697 * The root path where unpacked native libraries are stored.
698 * <p>
699 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
700 * placed in ISA-specific subdirectories under this path, otherwise the
701 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100702 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700703 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100704 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700705 public String nativeLibraryRootDir;
706
707 /**
708 * Flag indicating that ISA must be appended to
709 * {@link #nativeLibraryRootDir} to be useful.
710 *
711 * @hide
712 */
713 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100714
715 /**
716 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100717 * of the native JNI libraries the application bundles. Will be {@code null}
718 * if this application does not require any particular ABI.
719 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100720 * If non-null, the application will always be launched with this ABI.
721 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100722 * {@hide}
723 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100724 public String primaryCpuAbi;
725
726 /**
727 * The secondary ABI for this application. Might be non-null for multi-arch
728 * installs. The application itself never uses this ABI, but other applications that
729 * use its code might.
730 *
731 * {@hide}
732 */
733 public String secondaryCpuAbi;
734
735 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800736 * The kernel user-ID that has been assigned to this application;
737 * currently this is not a unique ID (multiple applications can have
738 * the same uid).
739 */
740 public int uid;
741
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700742 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800743 * The minimum SDK version this application can run on. It will not run
744 * on earlier versions.
745 */
Todd Kennedy6e2e7f52016-05-02 14:56:45 -0700746 public int minSdkVersion;
Todd Kennedy89d60182016-03-11 11:18:32 -0800747
748 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700749 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700750 * versions, but it knows how to work with any new behavior added at this
751 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
752 * if this is a development build and the app is targeting that. You should
753 * compare that this number is >= the SDK version number at which your
754 * behavior was introduced.
755 */
756 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800757
758 /**
759 * The app's declared version code.
760 * @hide
761 */
762 public int versionCode;
763
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700764 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800765 * When false, indicates that all components within this application are
766 * considered disabled, regardless of their individually set enabled status.
767 */
768 public boolean enabled = true;
769
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700770 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700771 * For convenient access to the current enabled setting of this app.
772 * @hide
773 */
774 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
775
776 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700777 * For convenient access to package's install location.
778 * @hide
779 */
780 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700781
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700782 /**
783 * Resource file providing the application's Network Security Config.
784 * @hide
785 */
786 public int networkSecurityConfigRes;
787
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700788 /**
789 * The category of this app. Categories are used to cluster multiple apps
790 * together into meaningful groups, such as when summarizing battery,
791 * network, or disk usage. Apps should only define this value when they fit
792 * well into one of the specific categories.
793 * <p>
794 * Set from the {@link android.R.attr#appCategory} attribute in the
795 * manifest. If the manifest doesn't define a category, this value may have
796 * been provided by the installer via
797 * {@link PackageManager#setApplicationCategoryHint(String, int)}.
798 */
799 public @Category int category = CATEGORY_UNDEFINED;
800
801 /** {@hide} */
802 @IntDef({
803 CATEGORY_UNDEFINED,
804 CATEGORY_GAME,
805 CATEGORY_AUDIO,
806 CATEGORY_VIDEO,
807 CATEGORY_IMAGE,
808 CATEGORY_SOCIAL,
809 CATEGORY_NEWS,
810 CATEGORY_MAPS,
811 CATEGORY_PRODUCTIVITY
812 })
813 @Retention(RetentionPolicy.SOURCE)
814 public @interface Category {
815 }
816
817 /**
818 * Value when category is undefined.
819 *
820 * @see #category
821 */
822 public static final int CATEGORY_UNDEFINED = -1;
823
824 /**
825 * Category for apps which are primarily games.
826 *
827 * @see #category
828 */
829 public static final int CATEGORY_GAME = 0;
830
831 /**
832 * Category for apps which primarily work with audio or music, such as music
833 * players.
834 *
835 * @see #category
836 */
837 public static final int CATEGORY_AUDIO = 1;
838
839 /**
840 * Category for apps which primarily work with video or movies, such as
841 * streaming video apps.
842 *
843 * @see #category
844 */
845 public static final int CATEGORY_VIDEO = 2;
846
847 /**
848 * Category for apps which primarily work with images or photos, such as
849 * camera or gallery apps.
850 *
851 * @see #category
852 */
853 public static final int CATEGORY_IMAGE = 3;
854
855 /**
856 * Category for apps which are primarily social apps, such as messaging,
857 * communication, or social network apps.
858 *
859 * @see #category
860 */
861 public static final int CATEGORY_SOCIAL = 4;
862
863 /**
864 * Category for apps which are primarily news apps, such as newspapers,
865 * magazines, or sports apps.
866 *
867 * @see #category
868 */
869 public static final int CATEGORY_NEWS = 5;
870
871 /**
872 * Category for apps which are primarily maps apps, such as navigation apps.
873 *
874 * @see #category
875 */
876 public static final int CATEGORY_MAPS = 6;
877
878 /**
879 * Category for apps which are primarily productivity apps, such as cloud
880 * storage or workplace apps.
881 *
882 * @see #category
883 */
884 public static final int CATEGORY_PRODUCTIVITY = 7;
885
886 /**
887 * Return a concise, localized title for the given
888 * {@link ApplicationInfo#category} value, or {@code null} for unknown
889 * values such as {@link #CATEGORY_UNDEFINED}.
890 *
891 * @see #category
892 */
893 public static CharSequence getCategoryTitle(Context context, @Category int category) {
894 switch (category) {
895 case ApplicationInfo.CATEGORY_GAME:
896 return context.getText(com.android.internal.R.string.app_category_game);
897 case ApplicationInfo.CATEGORY_AUDIO:
898 return context.getText(com.android.internal.R.string.app_category_audio);
899 case ApplicationInfo.CATEGORY_VIDEO:
900 return context.getText(com.android.internal.R.string.app_category_video);
901 case ApplicationInfo.CATEGORY_IMAGE:
902 return context.getText(com.android.internal.R.string.app_category_image);
903 case ApplicationInfo.CATEGORY_SOCIAL:
904 return context.getText(com.android.internal.R.string.app_category_social);
905 case ApplicationInfo.CATEGORY_NEWS:
906 return context.getText(com.android.internal.R.string.app_category_news);
907 case ApplicationInfo.CATEGORY_MAPS:
908 return context.getText(com.android.internal.R.string.app_category_maps);
909 case ApplicationInfo.CATEGORY_PRODUCTIVITY:
910 return context.getText(com.android.internal.R.string.app_category_productivity);
911 default:
912 return null;
913 }
914 }
915
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800916 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800917 dump(pw, prefix, DUMP_FLAG_ALL);
918 }
919
920 /** @hide */
921 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800922 super.dumpFront(pw, prefix);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800923 if ((flags&DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -0800924 pw.println(prefix + "className=" + className);
925 }
926 if (permission != null) {
927 pw.println(prefix + "permission=" + permission);
928 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700929 pw.println(prefix + "processName=" + processName);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800930 if ((flags&DUMP_FLAG_DETAILS) != 0) {
931 pw.println(prefix + "taskAffinity=" + taskAffinity);
932 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700933 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800934 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -0700935 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800936 if ((flags&DUMP_FLAG_DETAILS) != 0) {
937 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
938 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
939 + " largestWidthLimitDp=" + largestWidthLimitDp);
940 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800941 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700942 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700943 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
944 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700945 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
946 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
947 }
948 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
949 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
950 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
951 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700952 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -0800953 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -0700954 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800955 if ((flags&DUMP_FLAG_DETAILS) != 0 && seinfo != null) {
Robert Craig0f40dc92013-03-25 06:33:03 -0400956 pw.println(prefix + "seinfo=" + seinfo);
957 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800958 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800959 if ((flags&DUMP_FLAG_DETAILS) != 0) {
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600960 pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
961 pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800962 if (sharedLibraryFiles != null) {
963 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
964 }
Dianne Hackborn12527f92009-11-11 17:39:50 -0800965 }
Todd Kennedy89d60182016-03-11 11:18:32 -0800966 pw.println(prefix + "enabled=" + enabled
967 + " minSdkVersion=" + minSdkVersion
968 + " targetSdkVersion=" + targetSdkVersion
Dianne Hackborn8472e612014-01-23 17:57:20 -0800969 + " versionCode=" + versionCode);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800970 if ((flags&DUMP_FLAG_DETAILS) != 0) {
971 if (manageSpaceActivityName != null) {
972 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
973 }
974 if (descriptionRes != 0) {
975 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
976 }
977 if (uiOptions != 0) {
978 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
979 }
980 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
981 if (fullBackupContent > 0) {
982 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
983 } else {
984 pw.println(prefix + "fullBackupContent="
985 + (fullBackupContent < 0 ? "false" : "true"));
986 }
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700987 if (networkSecurityConfigRes != 0) {
988 pw.println(prefix + "networkSecurityConfigRes=0x"
989 + Integer.toHexString(networkSecurityConfigRes));
990 }
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700991 if (category != CATEGORY_UNDEFINED) {
992 pw.println(prefix + "category=" + category);
993 }
Matthew Williams303650c2015-04-17 18:22:51 -0700994 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800995 super.dumpBack(pw, prefix);
996 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -0700997
998 /**
999 * @return true if "supportsRtl" has been set to true in the AndroidManifest
1000 * @hide
1001 */
1002 public boolean hasRtlSupport() {
1003 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1004 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -07001005
1006 /** {@hide} */
1007 public boolean hasCode() {
1008 return (flags & FLAG_HAS_CODE) != 0;
1009 }
1010
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001011 public static class DisplayNameComparator
1012 implements Comparator<ApplicationInfo> {
1013 public DisplayNameComparator(PackageManager pm) {
1014 mPM = pm;
1015 }
1016
1017 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1018 CharSequence sa = mPM.getApplicationLabel(aa);
1019 if (sa == null) {
1020 sa = aa.packageName;
1021 }
1022 CharSequence sb = mPM.getApplicationLabel(ab);
1023 if (sb == null) {
1024 sb = ab.packageName;
1025 }
1026
1027 return sCollator.compare(sa.toString(), sb.toString());
1028 }
1029
1030 private final Collator sCollator = Collator.getInstance();
1031 private PackageManager mPM;
1032 }
1033
1034 public ApplicationInfo() {
1035 }
1036
1037 public ApplicationInfo(ApplicationInfo orig) {
1038 super(orig);
1039 taskAffinity = orig.taskAffinity;
1040 permission = orig.permission;
1041 processName = orig.processName;
1042 className = orig.className;
1043 theme = orig.theme;
1044 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001045 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001046 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1047 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001048 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001049 volumeUuid = orig.volumeUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001050 scanSourceDir = orig.scanSourceDir;
1051 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001052 sourceDir = orig.sourceDir;
1053 publicSourceDir = orig.publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001054 splitSourceDirs = orig.splitSourceDirs;
1055 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Kenny Root85387d72010-08-26 10:13:11 -07001056 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001057 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -07001058 nativeLibraryRootDir = orig.nativeLibraryRootDir;
1059 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001060 primaryCpuAbi = orig.primaryCpuAbi;
1061 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -08001062 resourceDirs = orig.resourceDirs;
Robert Craig0f40dc92013-03-25 06:33:03 -04001063 seinfo = orig.seinfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001064 sharedLibraryFiles = orig.sharedLibraryFiles;
1065 dataDir = orig.dataDir;
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001066 deviceEncryptedDataDir = deviceProtectedDataDir = orig.deviceProtectedDataDir;
1067 credentialEncryptedDataDir = credentialProtectedDataDir = orig.credentialProtectedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001068 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -08001069 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001070 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -08001071 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001072 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001073 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001074 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001075 manageSpaceActivityName = orig.manageSpaceActivityName;
1076 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -07001077 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -07001078 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -07001079 fullBackupContent = orig.fullBackupContent;
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001080 networkSecurityConfigRes = orig.networkSecurityConfigRes;
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001081 category = orig.category;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001082 }
1083
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001084 public String toString() {
1085 return "ApplicationInfo{"
1086 + Integer.toHexString(System.identityHashCode(this))
1087 + " " + packageName + "}";
1088 }
1089
1090 public int describeContents() {
1091 return 0;
1092 }
1093
1094 public void writeToParcel(Parcel dest, int parcelableFlags) {
1095 super.writeToParcel(dest, parcelableFlags);
1096 dest.writeString(taskAffinity);
1097 dest.writeString(permission);
1098 dest.writeString(processName);
1099 dest.writeString(className);
1100 dest.writeInt(theme);
1101 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001102 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001103 dest.writeInt(requiresSmallestWidthDp);
1104 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001105 dest.writeInt(largestWidthLimitDp);
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001106 dest.writeString(volumeUuid);
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001107 dest.writeString(scanSourceDir);
1108 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001109 dest.writeString(sourceDir);
1110 dest.writeString(publicSourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001111 dest.writeStringArray(splitSourceDirs);
1112 dest.writeStringArray(splitPublicSourceDirs);
Kenny Root85387d72010-08-26 10:13:11 -07001113 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001114 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -07001115 dest.writeString(nativeLibraryRootDir);
1116 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +01001117 dest.writeString(primaryCpuAbi);
1118 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -08001119 dest.writeStringArray(resourceDirs);
Robert Craig0f40dc92013-03-25 06:33:03 -04001120 dest.writeString(seinfo);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001121 dest.writeStringArray(sharedLibraryFiles);
1122 dest.writeString(dataDir);
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001123 dest.writeString(deviceProtectedDataDir);
1124 dest.writeString(credentialProtectedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001125 dest.writeInt(uid);
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001126 dest.writeInt(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001127 dest.writeInt(targetSdkVersion);
Dianne Hackborn8472e612014-01-23 17:57:20 -08001128 dest.writeInt(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001129 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001130 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001131 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001132 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -07001133 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001134 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -07001135 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -07001136 dest.writeInt(fullBackupContent);
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001137 dest.writeInt(networkSecurityConfigRes);
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001138 dest.writeInt(category);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001139 }
1140
1141 public static final Parcelable.Creator<ApplicationInfo> CREATOR
1142 = new Parcelable.Creator<ApplicationInfo>() {
1143 public ApplicationInfo createFromParcel(Parcel source) {
1144 return new ApplicationInfo(source);
1145 }
1146 public ApplicationInfo[] newArray(int size) {
1147 return new ApplicationInfo[size];
1148 }
1149 };
1150
1151 private ApplicationInfo(Parcel source) {
1152 super(source);
1153 taskAffinity = source.readString();
1154 permission = source.readString();
1155 processName = source.readString();
1156 className = source.readString();
1157 theme = source.readInt();
1158 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001159 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001160 requiresSmallestWidthDp = source.readInt();
1161 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001162 largestWidthLimitDp = source.readInt();
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001163 volumeUuid = source.readString();
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001164 scanSourceDir = source.readString();
1165 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001166 sourceDir = source.readString();
1167 publicSourceDir = source.readString();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001168 splitSourceDirs = source.readStringArray();
1169 splitPublicSourceDirs = source.readStringArray();
Kenny Root85387d72010-08-26 10:13:11 -07001170 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001171 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -07001172 nativeLibraryRootDir = source.readString();
1173 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001174 primaryCpuAbi = source.readString();
1175 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -08001176 resourceDirs = source.readStringArray();
Robert Craig0f40dc92013-03-25 06:33:03 -04001177 seinfo = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001178 sharedLibraryFiles = source.readStringArray();
1179 dataDir = source.readString();
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001180 deviceEncryptedDataDir = deviceProtectedDataDir = source.readString();
1181 credentialEncryptedDataDir = credentialProtectedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001182 uid = source.readInt();
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001183 minSdkVersion = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001184 targetSdkVersion = source.readInt();
Dianne Hackborn8472e612014-01-23 17:57:20 -08001185 versionCode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001186 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001187 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001188 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001190 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001191 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001192 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001193 fullBackupContent = source.readInt();
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001194 networkSecurityConfigRes = source.readInt();
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001195 category = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001196 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001197
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001198 /**
1199 * Retrieve the textual description of the application. This
1200 * will call back on the given PackageManager to load the description from
1201 * the application.
1202 *
1203 * @param pm A PackageManager from which the label can be loaded; usually
1204 * the PackageManager from which you originally retrieved this item.
1205 *
1206 * @return Returns a CharSequence containing the application's description.
1207 * If there is no description, null is returned.
1208 */
1209 public CharSequence loadDescription(PackageManager pm) {
1210 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001211 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001212 if (label != null) {
1213 return label;
1214 }
1215 }
1216 return null;
1217 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001218
1219 /**
1220 * Disable compatibility mode
1221 *
1222 * @hide
1223 */
1224 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001225 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001226 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001227 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001228 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001229
skuhne@google.com7e85eb02017-01-04 13:49:54 -08001230 /**
1231 * Is using compatibility mode for non densty aware legacy applications.
1232 *
1233 * @hide
1234 */
1235 public boolean usesCompatibilityMode() {
1236 return targetSdkVersion < DONUT ||
1237 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1238 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1239 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1240 }
1241
Jeff Sharkey15447792015-11-05 16:18:51 -08001242 /** {@hide} */
1243 public void initForUser(int userId) {
1244 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1245
1246 if ("android".equals(packageName)) {
1247 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1248 return;
1249 }
1250
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001251 deviceEncryptedDataDir = deviceProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001252 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001253 .getAbsolutePath();
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001254 credentialEncryptedDataDir = credentialProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001255 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001256 .getAbsolutePath();
1257
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001258 if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1259 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1260 dataDir = deviceProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001261 } else {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001262 dataDir = credentialProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001263 }
1264 }
1265
Jeff Brown07330792010-03-30 19:57:08 -07001266 /**
1267 * @hide
1268 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001269 @Override
1270 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001271 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1272 && isPackageUnavailable(pm)) {
1273 return Resources.getSystem().getDrawable(
1274 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1275 }
1276 return pm.getDefaultActivityIcon();
1277 }
1278
1279 private boolean isPackageUnavailable(PackageManager pm) {
1280 try {
1281 return pm.getPackageInfo(packageName, 0) == null;
1282 } catch (NameNotFoundException ex) {
1283 return true;
1284 }
1285 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001286
Jeff Brown07330792010-03-30 19:57:08 -07001287 /**
1288 * @hide
1289 */
Fyodor Kupoloveeea67b2015-02-23 17:14:45 -08001290 public boolean isForwardLocked() {
1291 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1292 }
1293
1294 /**
1295 * @hide
1296 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001297 @TestApi
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001298 public boolean isSystemApp() {
1299 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1300 }
1301
1302 /**
1303 * @hide
1304 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001305 @TestApi
Svet Ganovadc1cf42015-06-15 16:36:24 -07001306 public boolean isPrivilegedApp() {
1307 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1308 }
1309
1310 /**
1311 * @hide
1312 */
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001313 public boolean isUpdatedSystemApp() {
1314 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1315 }
1316
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07001317 /** @hide */
1318 public boolean isInternal() {
1319 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1320 }
1321
1322 /** @hide */
1323 public boolean isExternalAsec() {
1324 return TextUtils.isEmpty(volumeUuid)
1325 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1326 }
1327
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001328 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001329 public boolean isDefaultToDeviceProtectedStorage() {
1330 return (privateFlags
1331 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
Jeff Sharkeye4697132016-02-06 19:46:15 -07001332 }
1333
1334 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001335 public boolean isDirectBootAware() {
1336 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001337 }
1338
Jeff Sharkey8924e872015-11-30 12:52:10 -07001339 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001340 public boolean isPartiallyDirectBootAware() {
1341 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkey8924e872015-11-30 12:52:10 -07001342 }
1343
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001344 /**
1345 * @hide
1346 */
Svet Ganov2acf0632015-11-24 19:10:59 -08001347 public boolean isEphemeralApp() {
1348 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0;
1349 }
1350
1351 /**
1352 * @hide
1353 */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001354 public boolean isRequiredForSystemUser() {
1355 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1356 }
1357
1358 /**
1359 * @hide
1360 */
Jeff Brown07330792010-03-30 19:57:08 -07001361 @Override protected ApplicationInfo getApplicationInfo() {
1362 return this;
1363 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001364
1365 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1366 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1367 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1368 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1369 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1370 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1371
1372 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1373 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1374 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1375 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1376 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
Jeff Sharkeya3a43b02016-11-15 17:54:23 -07001377 /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001378}