blob: 04ab2394b0d1a81b941c7982639175531329188a [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 /**
Svet Ganov67882122016-12-11 16:36:34 -0800554 * Value for {@link #privateFlags}: {@code true} means this application
555 * contains a static shared library. Defaults to {@code false} if unspecified.
556 * @hide
557 */
558 public static final int PRIVATE_FLAG_STATIC_SHARED_LIBRARY = 1 << 13;
559
560 /**
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800561 * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
562 * {@hide}
563 */
564 public int privateFlags;
565
566 /**
Dianne Hackborndf6e9802011-05-26 14:20:23 -0700567 * The required smallest screen width the application can run on. If 0,
568 * nothing has been specified. Comes from
569 * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
570 * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
571 */
572 public int requiresSmallestWidthDp = 0;
573
574 /**
575 * The maximum smallest screen width the application is designed for. If 0,
576 * nothing has been specified. Comes from
577 * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
578 * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
579 */
580 public int compatibleWidthLimitDp = 0;
581
582 /**
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700583 * The maximum smallest screen width the application will work on. If 0,
584 * nothing has been specified. Comes from
585 * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
586 * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
587 */
588 public int largestWidthLimitDp = 0;
589
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700590 /** {@hide} */
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -0700591 public String volumeUuid;
592 /** {@hide} */
Jeff Sharkeyd7460572014-07-06 20:44:55 -0700593 public String scanSourceDir;
594 /** {@hide} */
595 public String scanPublicSourceDir;
596
Dianne Hackborn2762ff32011-06-01 21:27:05 -0700597 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700598 * Full path to the base APK for this application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800599 */
600 public String sourceDir;
601
602 /**
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700603 * Full path to the publicly available parts of {@link #sourceDir},
604 * including resources and manifest. This may be different from
605 * {@link #sourceDir} if an application is forward locked.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800606 */
607 public String publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700608
609 /**
610 * Full paths to zero or more split APKs that, when combined with the base
611 * APK defined in {@link #sourceDir}, form a complete application.
612 */
613 public String[] splitSourceDirs;
614
615 /**
616 * Full path to the publicly available parts of {@link #splitSourceDirs},
617 * including resources and manifest. This may be different from
618 * {@link #splitSourceDirs} if an application is forward locked.
619 */
620 public String[] splitPublicSourceDirs;
621
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800622 /**
Kenny Rootd1ab0162010-01-21 17:27:14 -0800623 * Full paths to the locations of extra resource packages this application
624 * uses. This field is only used if there are extra resource packages,
625 * otherwise it is null.
Kenny Rootace5a3f2010-02-05 12:59:28 -0800626 *
627 * {@hide}
Kenny Rootd1ab0162010-01-21 17:27:14 -0800628 */
629 public String[] resourceDirs;
630
631 /**
Robert Craig0f40dc92013-03-25 06:33:03 -0400632 * String retrieved from the seinfo tag found in selinux policy. This value
Robert Craig5e16bc52015-08-28 12:11:41 -0400633 * can be overridden with a value set through the mac_permissions.xml policy
634 * construct. This value is useful in setting an SELinux security context on
635 * the process as well as its data directory. The String default is being used
636 * here to represent a catchall label when no policy matches.
Robert Craig0f40dc92013-03-25 06:33:03 -0400637 *
638 * {@hide}
639 */
Robert Craig5e16bc52015-08-28 12:11:41 -0400640 public String seinfo = "default";
Robert Craig0f40dc92013-03-25 06:33:03 -0400641
642 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800643 * Paths to all shared libraries this application is linked against. This
644 * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
645 * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
646 * the structure.
647 */
648 public String[] sharedLibraryFiles;
649
650 /**
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700651 * Full path to the default directory assigned to the package for its
652 * persistent data.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800653 */
654 public String dataDir;
Kenny Root85387d72010-08-26 10:13:11 -0700655
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700656 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600657 * Full path to the device-protected directory assigned to the package for
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700658 * its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600659 *
660 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700661 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600662 public String deviceProtectedDataDir;
663
664 /** @removed */
665 @Deprecated
Jeff Sharkey15447792015-11-05 16:18:51 -0800666 public String deviceEncryptedDataDir;
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700667
668 /**
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600669 * Full path to the credential-protected directory assigned to the package
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700670 * for its persistent data.
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600671 *
672 * @hide
Jeff Sharkey7a30a302015-12-08 14:20:06 -0700673 */
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600674 @SystemApi
675 public String credentialProtectedDataDir;
676
677 /** @removed */
678 @Deprecated
Jeff Sharkey15447792015-11-05 16:18:51 -0800679 public String credentialEncryptedDataDir;
680
Kenny Root85387d72010-08-26 10:13:11 -0700681 /**
682 * Full path to the directory where native JNI libraries are stored.
Kenny Root85387d72010-08-26 10:13:11 -0700683 */
684 public String nativeLibraryDir;
685
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800686 /**
Narayan Kamath7dba6eb2014-07-16 08:53:30 +0100687 * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
688 * are stored, if present.
689 *
690 * The main reason this exists is for bundled multi-arch apps, where
691 * it's not trivial to calculate the location of libs for the secondary abi
692 * given the location of the primary.
693 *
694 * TODO: Change the layout of bundled installs so that we can use
695 * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
696 * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
697 * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
698 *
699 * @hide
700 */
701 public String secondaryNativeLibraryDir;
702
703 /**
Jeff Sharkey84f12942014-07-10 17:48:11 -0700704 * The root path where unpacked native libraries are stored.
705 * <p>
706 * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
707 * placed in ISA-specific subdirectories under this path, otherwise the
708 * libraries are placed directly at this path.
Narayan Kamathff110bd2014-07-04 18:30:45 +0100709 *
Jeff Sharkey84f12942014-07-10 17:48:11 -0700710 * @hide
Narayan Kamathff110bd2014-07-04 18:30:45 +0100711 */
Jeff Sharkey84f12942014-07-10 17:48:11 -0700712 public String nativeLibraryRootDir;
713
714 /**
715 * Flag indicating that ISA must be appended to
716 * {@link #nativeLibraryRootDir} to be useful.
717 *
718 * @hide
719 */
720 public boolean nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +0100721
722 /**
723 * The primary ABI that this application requires, This is inferred from the ABIs
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100724 * of the native JNI libraries the application bundles. Will be {@code null}
725 * if this application does not require any particular ABI.
726 *
Narayan Kamathff110bd2014-07-04 18:30:45 +0100727 * If non-null, the application will always be launched with this ABI.
728 *
Ramin Zaghiff0c4702014-04-01 15:02:29 +0100729 * {@hide}
730 */
Narayan Kamathff110bd2014-07-04 18:30:45 +0100731 public String primaryCpuAbi;
732
733 /**
734 * The secondary ABI for this application. Might be non-null for multi-arch
735 * installs. The application itself never uses this ABI, but other applications that
736 * use its code might.
737 *
738 * {@hide}
739 */
740 public String secondaryCpuAbi;
741
742 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800743 * The kernel user-ID that has been assigned to this application;
744 * currently this is not a unique ID (multiple applications can have
745 * the same uid).
746 */
747 public int uid;
748
Mitsuru Oshima8d112672009-04-27 12:01:23 -0700749 /**
Todd Kennedy89d60182016-03-11 11:18:32 -0800750 * The minimum SDK version this application can run on. It will not run
751 * on earlier versions.
752 */
Todd Kennedy6e2e7f52016-05-02 14:56:45 -0700753 public int minSdkVersion;
Todd Kennedy89d60182016-03-11 11:18:32 -0800754
755 /**
Dianne Hackborn3b3e1452009-09-24 19:22:12 -0700756 * The minimum SDK version this application targets. It may run on earlier
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700757 * versions, but it knows how to work with any new behavior added at this
758 * version. Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
759 * if this is a development build and the app is targeting that. You should
760 * compare that this number is >= the SDK version number at which your
761 * behavior was introduced.
762 */
763 public int targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -0800764
765 /**
766 * The app's declared version code.
767 * @hide
768 */
769 public int versionCode;
770
Dianne Hackborna96cbb42009-05-13 15:06:13 -0700771 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800772 * When false, indicates that all components within this application are
773 * considered disabled, regardless of their individually set enabled status.
774 */
775 public boolean enabled = true;
776
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700777 /**
Dianne Hackborn0ac30312011-06-17 14:49:23 -0700778 * For convenient access to the current enabled setting of this app.
779 * @hide
780 */
781 public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
782
783 /**
Dianne Hackborn54e570f2010-10-04 18:32:32 -0700784 * For convenient access to package's install location.
785 * @hide
786 */
787 public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
Jose Lima12d0b4c2014-03-14 16:55:12 -0700788
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700789 /**
790 * Resource file providing the application's Network Security Config.
791 * @hide
792 */
793 public int networkSecurityConfigRes;
794
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700795 /**
796 * The category of this app. Categories are used to cluster multiple apps
797 * together into meaningful groups, such as when summarizing battery,
798 * network, or disk usage. Apps should only define this value when they fit
799 * well into one of the specific categories.
800 * <p>
801 * Set from the {@link android.R.attr#appCategory} attribute in the
802 * manifest. If the manifest doesn't define a category, this value may have
803 * been provided by the installer via
804 * {@link PackageManager#setApplicationCategoryHint(String, int)}.
805 */
806 public @Category int category = CATEGORY_UNDEFINED;
807
808 /** {@hide} */
809 @IntDef({
810 CATEGORY_UNDEFINED,
811 CATEGORY_GAME,
812 CATEGORY_AUDIO,
813 CATEGORY_VIDEO,
814 CATEGORY_IMAGE,
815 CATEGORY_SOCIAL,
816 CATEGORY_NEWS,
817 CATEGORY_MAPS,
818 CATEGORY_PRODUCTIVITY
819 })
820 @Retention(RetentionPolicy.SOURCE)
821 public @interface Category {
822 }
823
824 /**
825 * Value when category is undefined.
826 *
827 * @see #category
828 */
829 public static final int CATEGORY_UNDEFINED = -1;
830
831 /**
832 * Category for apps which are primarily games.
833 *
834 * @see #category
835 */
836 public static final int CATEGORY_GAME = 0;
837
838 /**
839 * Category for apps which primarily work with audio or music, such as music
840 * players.
841 *
842 * @see #category
843 */
844 public static final int CATEGORY_AUDIO = 1;
845
846 /**
847 * Category for apps which primarily work with video or movies, such as
848 * streaming video apps.
849 *
850 * @see #category
851 */
852 public static final int CATEGORY_VIDEO = 2;
853
854 /**
855 * Category for apps which primarily work with images or photos, such as
856 * camera or gallery apps.
857 *
858 * @see #category
859 */
860 public static final int CATEGORY_IMAGE = 3;
861
862 /**
863 * Category for apps which are primarily social apps, such as messaging,
864 * communication, or social network apps.
865 *
866 * @see #category
867 */
868 public static final int CATEGORY_SOCIAL = 4;
869
870 /**
871 * Category for apps which are primarily news apps, such as newspapers,
872 * magazines, or sports apps.
873 *
874 * @see #category
875 */
876 public static final int CATEGORY_NEWS = 5;
877
878 /**
879 * Category for apps which are primarily maps apps, such as navigation apps.
880 *
881 * @see #category
882 */
883 public static final int CATEGORY_MAPS = 6;
884
885 /**
886 * Category for apps which are primarily productivity apps, such as cloud
887 * storage or workplace apps.
888 *
889 * @see #category
890 */
891 public static final int CATEGORY_PRODUCTIVITY = 7;
892
893 /**
894 * Return a concise, localized title for the given
895 * {@link ApplicationInfo#category} value, or {@code null} for unknown
896 * values such as {@link #CATEGORY_UNDEFINED}.
897 *
898 * @see #category
899 */
900 public static CharSequence getCategoryTitle(Context context, @Category int category) {
901 switch (category) {
902 case ApplicationInfo.CATEGORY_GAME:
903 return context.getText(com.android.internal.R.string.app_category_game);
904 case ApplicationInfo.CATEGORY_AUDIO:
905 return context.getText(com.android.internal.R.string.app_category_audio);
906 case ApplicationInfo.CATEGORY_VIDEO:
907 return context.getText(com.android.internal.R.string.app_category_video);
908 case ApplicationInfo.CATEGORY_IMAGE:
909 return context.getText(com.android.internal.R.string.app_category_image);
910 case ApplicationInfo.CATEGORY_SOCIAL:
911 return context.getText(com.android.internal.R.string.app_category_social);
912 case ApplicationInfo.CATEGORY_NEWS:
913 return context.getText(com.android.internal.R.string.app_category_news);
914 case ApplicationInfo.CATEGORY_MAPS:
915 return context.getText(com.android.internal.R.string.app_category_maps);
916 case ApplicationInfo.CATEGORY_PRODUCTIVITY:
917 return context.getText(com.android.internal.R.string.app_category_productivity);
918 default:
919 return null;
920 }
921 }
922
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800923 public void dump(Printer pw, String prefix) {
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800924 dump(pw, prefix, DUMP_FLAG_ALL);
925 }
926
927 /** @hide */
928 public void dump(Printer pw, String prefix, int flags) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800929 super.dumpFront(pw, prefix);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800930 if ((flags&DUMP_FLAG_DETAILS) != 0 && className != null) {
Dianne Hackborn12527f92009-11-11 17:39:50 -0800931 pw.println(prefix + "className=" + className);
932 }
933 if (permission != null) {
934 pw.println(prefix + "permission=" + permission);
935 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700936 pw.println(prefix + "processName=" + processName);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800937 if ((flags&DUMP_FLAG_DETAILS) != 0) {
938 pw.println(prefix + "taskAffinity=" + taskAffinity);
939 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700940 pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
Alex Klyubinb9f8a522015-02-03 11:12:59 -0800941 + " privateFlags=0x" + Integer.toHexString(privateFlags)
Dianne Hackborn39792d22010-08-19 18:01:52 -0700942 + " theme=0x" + Integer.toHexString(theme));
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800943 if ((flags&DUMP_FLAG_DETAILS) != 0) {
944 pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
945 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
946 + " largestWidthLimitDp=" + largestWidthLimitDp);
947 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800948 pw.println(prefix + "sourceDir=" + sourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700949 if (!Objects.equals(sourceDir, publicSourceDir)) {
Dianne Hackborn39792d22010-08-19 18:01:52 -0700950 pw.println(prefix + "publicSourceDir=" + publicSourceDir);
951 }
Jeff Sharkey8a4c9722014-06-16 13:48:42 -0700952 if (!ArrayUtils.isEmpty(splitSourceDirs)) {
953 pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
954 }
955 if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
956 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
957 pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
958 }
Dianne Hackborn39792d22010-08-19 18:01:52 -0700959 if (resourceDirs != null) {
Andreas Gampee6748ce2015-12-11 18:00:38 -0800960 pw.println(prefix + "resourceDirs=" + Arrays.toString(resourceDirs));
Dianne Hackborn39792d22010-08-19 18:01:52 -0700961 }
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800962 if ((flags&DUMP_FLAG_DETAILS) != 0 && seinfo != null) {
Robert Craig0f40dc92013-03-25 06:33:03 -0400963 pw.println(prefix + "seinfo=" + seinfo);
964 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800965 pw.println(prefix + "dataDir=" + dataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800966 if ((flags&DUMP_FLAG_DETAILS) != 0) {
Jeff Sharkey8a372a02016-03-16 16:25:45 -0600967 pw.println(prefix + "deviceProtectedDataDir=" + deviceProtectedDataDir);
968 pw.println(prefix + "credentialProtectedDataDir=" + credentialProtectedDataDir);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800969 if (sharedLibraryFiles != null) {
970 pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
971 }
Dianne Hackborn12527f92009-11-11 17:39:50 -0800972 }
Todd Kennedy89d60182016-03-11 11:18:32 -0800973 pw.println(prefix + "enabled=" + enabled
974 + " minSdkVersion=" + minSdkVersion
975 + " targetSdkVersion=" + targetSdkVersion
Dianne Hackborn8472e612014-01-23 17:57:20 -0800976 + " versionCode=" + versionCode);
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -0800977 if ((flags&DUMP_FLAG_DETAILS) != 0) {
978 if (manageSpaceActivityName != null) {
979 pw.println(prefix + "manageSpaceActivityName=" + manageSpaceActivityName);
980 }
981 if (descriptionRes != 0) {
982 pw.println(prefix + "description=0x" + Integer.toHexString(descriptionRes));
983 }
984 if (uiOptions != 0) {
985 pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
986 }
987 pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
988 if (fullBackupContent > 0) {
989 pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
990 } else {
991 pw.println(prefix + "fullBackupContent="
992 + (fullBackupContent < 0 ? "false" : "true"));
993 }
Chad Brubakerc845b2a2016-05-13 14:09:27 -0700994 if (networkSecurityConfigRes != 0) {
995 pw.println(prefix + "networkSecurityConfigRes=0x"
996 + Integer.toHexString(networkSecurityConfigRes));
997 }
Jeff Sharkey9bc89af2017-01-11 11:25:50 -0700998 if (category != CATEGORY_UNDEFINED) {
999 pw.println(prefix + "category=" + category);
1000 }
Matthew Williams303650c2015-04-17 18:22:51 -07001001 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001002 super.dumpBack(pw, prefix);
1003 }
Fabrice Di Meglio59dfce82012-04-02 16:17:20 -07001004
1005 /**
1006 * @return true if "supportsRtl" has been set to true in the AndroidManifest
1007 * @hide
1008 */
1009 public boolean hasRtlSupport() {
1010 return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
1011 }
Jeff Sharkeyba75a9b2016-01-07 11:51:33 -07001012
1013 /** {@hide} */
1014 public boolean hasCode() {
1015 return (flags & FLAG_HAS_CODE) != 0;
1016 }
1017
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001018 public static class DisplayNameComparator
1019 implements Comparator<ApplicationInfo> {
1020 public DisplayNameComparator(PackageManager pm) {
1021 mPM = pm;
1022 }
1023
1024 public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
1025 CharSequence sa = mPM.getApplicationLabel(aa);
1026 if (sa == null) {
1027 sa = aa.packageName;
1028 }
1029 CharSequence sb = mPM.getApplicationLabel(ab);
1030 if (sb == null) {
1031 sb = ab.packageName;
1032 }
1033
1034 return sCollator.compare(sa.toString(), sb.toString());
1035 }
1036
1037 private final Collator sCollator = Collator.getInstance();
1038 private PackageManager mPM;
1039 }
1040
1041 public ApplicationInfo() {
1042 }
1043
1044 public ApplicationInfo(ApplicationInfo orig) {
1045 super(orig);
1046 taskAffinity = orig.taskAffinity;
1047 permission = orig.permission;
1048 processName = orig.processName;
1049 className = orig.className;
1050 theme = orig.theme;
1051 flags = orig.flags;
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001052 privateFlags = orig.privateFlags;
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001053 requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
1054 compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001055 largestWidthLimitDp = orig.largestWidthLimitDp;
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001056 volumeUuid = orig.volumeUuid;
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001057 scanSourceDir = orig.scanSourceDir;
1058 scanPublicSourceDir = orig.scanPublicSourceDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001059 sourceDir = orig.sourceDir;
1060 publicSourceDir = orig.publicSourceDir;
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001061 splitSourceDirs = orig.splitSourceDirs;
1062 splitPublicSourceDirs = orig.splitPublicSourceDirs;
Kenny Root85387d72010-08-26 10:13:11 -07001063 nativeLibraryDir = orig.nativeLibraryDir;
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001064 secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
Jeff Sharkey84f12942014-07-10 17:48:11 -07001065 nativeLibraryRootDir = orig.nativeLibraryRootDir;
1066 nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001067 primaryCpuAbi = orig.primaryCpuAbi;
1068 secondaryCpuAbi = orig.secondaryCpuAbi;
Kenny Rootd1ab0162010-01-21 17:27:14 -08001069 resourceDirs = orig.resourceDirs;
Robert Craig0f40dc92013-03-25 06:33:03 -04001070 seinfo = orig.seinfo;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001071 sharedLibraryFiles = orig.sharedLibraryFiles;
1072 dataDir = orig.dataDir;
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001073 deviceEncryptedDataDir = deviceProtectedDataDir = orig.deviceProtectedDataDir;
1074 credentialEncryptedDataDir = credentialProtectedDataDir = orig.credentialProtectedDataDir;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001075 uid = orig.uid;
Todd Kennedy89d60182016-03-11 11:18:32 -08001076 minSdkVersion = orig.minSdkVersion;
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001077 targetSdkVersion = orig.targetSdkVersion;
Dianne Hackborn8472e612014-01-23 17:57:20 -08001078 versionCode = orig.versionCode;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001079 enabled = orig.enabled;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001080 enabledSetting = orig.enabledSetting;
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001081 installLocation = orig.installLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001082 manageSpaceActivityName = orig.manageSpaceActivityName;
1083 descriptionRes = orig.descriptionRes;
Adam Powell269248d2011-08-02 10:26:54 -07001084 uiOptions = orig.uiOptions;
Christopher Tatebcb02552012-10-16 17:14:34 -07001085 backupAgentName = orig.backupAgentName;
Matthew Williams303650c2015-04-17 18:22:51 -07001086 fullBackupContent = orig.fullBackupContent;
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001087 networkSecurityConfigRes = orig.networkSecurityConfigRes;
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001088 category = orig.category;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001089 }
1090
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001091 public String toString() {
1092 return "ApplicationInfo{"
1093 + Integer.toHexString(System.identityHashCode(this))
1094 + " " + packageName + "}";
1095 }
1096
1097 public int describeContents() {
1098 return 0;
1099 }
1100
1101 public void writeToParcel(Parcel dest, int parcelableFlags) {
1102 super.writeToParcel(dest, parcelableFlags);
1103 dest.writeString(taskAffinity);
1104 dest.writeString(permission);
1105 dest.writeString(processName);
1106 dest.writeString(className);
1107 dest.writeInt(theme);
1108 dest.writeInt(flags);
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001109 dest.writeInt(privateFlags);
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001110 dest.writeInt(requiresSmallestWidthDp);
1111 dest.writeInt(compatibleWidthLimitDp);
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001112 dest.writeInt(largestWidthLimitDp);
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001113 dest.writeString(volumeUuid);
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001114 dest.writeString(scanSourceDir);
1115 dest.writeString(scanPublicSourceDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001116 dest.writeString(sourceDir);
1117 dest.writeString(publicSourceDir);
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001118 dest.writeStringArray(splitSourceDirs);
1119 dest.writeStringArray(splitPublicSourceDirs);
Kenny Root85387d72010-08-26 10:13:11 -07001120 dest.writeString(nativeLibraryDir);
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001121 dest.writeString(secondaryNativeLibraryDir);
Jeff Sharkey84f12942014-07-10 17:48:11 -07001122 dest.writeString(nativeLibraryRootDir);
1123 dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
Narayan Kamathff110bd2014-07-04 18:30:45 +01001124 dest.writeString(primaryCpuAbi);
1125 dest.writeString(secondaryCpuAbi);
Kenny Rootd1ab0162010-01-21 17:27:14 -08001126 dest.writeStringArray(resourceDirs);
Robert Craig0f40dc92013-03-25 06:33:03 -04001127 dest.writeString(seinfo);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001128 dest.writeStringArray(sharedLibraryFiles);
1129 dest.writeString(dataDir);
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001130 dest.writeString(deviceProtectedDataDir);
1131 dest.writeString(credentialProtectedDataDir);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001132 dest.writeInt(uid);
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001133 dest.writeInt(minSdkVersion);
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001134 dest.writeInt(targetSdkVersion);
Dianne Hackborn8472e612014-01-23 17:57:20 -08001135 dest.writeInt(versionCode);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001136 dest.writeInt(enabled ? 1 : 0);
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001137 dest.writeInt(enabledSetting);
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001138 dest.writeInt(installLocation);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001139 dest.writeString(manageSpaceActivityName);
Christopher Tate181fafa2009-05-14 11:12:14 -07001140 dest.writeString(backupAgentName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001141 dest.writeInt(descriptionRes);
Adam Powell269248d2011-08-02 10:26:54 -07001142 dest.writeInt(uiOptions);
Matthew Williams303650c2015-04-17 18:22:51 -07001143 dest.writeInt(fullBackupContent);
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001144 dest.writeInt(networkSecurityConfigRes);
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001145 dest.writeInt(category);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001146 }
1147
1148 public static final Parcelable.Creator<ApplicationInfo> CREATOR
1149 = new Parcelable.Creator<ApplicationInfo>() {
1150 public ApplicationInfo createFromParcel(Parcel source) {
1151 return new ApplicationInfo(source);
1152 }
1153 public ApplicationInfo[] newArray(int size) {
1154 return new ApplicationInfo[size];
1155 }
1156 };
1157
1158 private ApplicationInfo(Parcel source) {
1159 super(source);
1160 taskAffinity = source.readString();
1161 permission = source.readString();
1162 processName = source.readString();
1163 className = source.readString();
1164 theme = source.readInt();
1165 flags = source.readInt();
Alex Klyubinb9f8a522015-02-03 11:12:59 -08001166 privateFlags = source.readInt();
Dianne Hackborndf6e9802011-05-26 14:20:23 -07001167 requiresSmallestWidthDp = source.readInt();
1168 compatibleWidthLimitDp = source.readInt();
Dianne Hackborn2762ff32011-06-01 21:27:05 -07001169 largestWidthLimitDp = source.readInt();
Jeff Sharkeyb2b9ab82015-04-05 21:10:42 -07001170 volumeUuid = source.readString();
Jeff Sharkey7f1a57a2014-10-08 10:14:53 -07001171 scanSourceDir = source.readString();
1172 scanPublicSourceDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001173 sourceDir = source.readString();
1174 publicSourceDir = source.readString();
Jeff Sharkey8a4c9722014-06-16 13:48:42 -07001175 splitSourceDirs = source.readStringArray();
1176 splitPublicSourceDirs = source.readStringArray();
Kenny Root85387d72010-08-26 10:13:11 -07001177 nativeLibraryDir = source.readString();
Narayan Kamath7dba6eb2014-07-16 08:53:30 +01001178 secondaryNativeLibraryDir = source.readString();
Jeff Sharkey84f12942014-07-10 17:48:11 -07001179 nativeLibraryRootDir = source.readString();
1180 nativeLibraryRootRequiresIsa = source.readInt() != 0;
Narayan Kamathff110bd2014-07-04 18:30:45 +01001181 primaryCpuAbi = source.readString();
1182 secondaryCpuAbi = source.readString();
Kenny Rootd1ab0162010-01-21 17:27:14 -08001183 resourceDirs = source.readStringArray();
Robert Craig0f40dc92013-03-25 06:33:03 -04001184 seinfo = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001185 sharedLibraryFiles = source.readStringArray();
1186 dataDir = source.readString();
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001187 deviceEncryptedDataDir = deviceProtectedDataDir = source.readString();
1188 credentialEncryptedDataDir = credentialProtectedDataDir = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001189 uid = source.readInt();
Todd Kennedy6e2e7f52016-05-02 14:56:45 -07001190 minSdkVersion = source.readInt();
Dianne Hackborna96cbb42009-05-13 15:06:13 -07001191 targetSdkVersion = source.readInt();
Dianne Hackborn8472e612014-01-23 17:57:20 -08001192 versionCode = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001193 enabled = source.readInt() != 0;
Dianne Hackborn0ac30312011-06-17 14:49:23 -07001194 enabledSetting = source.readInt();
Dianne Hackborn54e570f2010-10-04 18:32:32 -07001195 installLocation = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001196 manageSpaceActivityName = source.readString();
Christopher Tate181fafa2009-05-14 11:12:14 -07001197 backupAgentName = source.readString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001198 descriptionRes = source.readInt();
Adam Powell269248d2011-08-02 10:26:54 -07001199 uiOptions = source.readInt();
Matthew Williams303650c2015-04-17 18:22:51 -07001200 fullBackupContent = source.readInt();
Chad Brubakerc845b2a2016-05-13 14:09:27 -07001201 networkSecurityConfigRes = source.readInt();
Jeff Sharkey9bc89af2017-01-11 11:25:50 -07001202 category = source.readInt();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001203 }
Mitsuru Oshima8d112672009-04-27 12:01:23 -07001204
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001205 /**
1206 * Retrieve the textual description of the application. This
1207 * will call back on the given PackageManager to load the description from
1208 * the application.
1209 *
1210 * @param pm A PackageManager from which the label can be loaded; usually
1211 * the PackageManager from which you originally retrieved this item.
1212 *
1213 * @return Returns a CharSequence containing the application's description.
1214 * If there is no description, null is returned.
1215 */
1216 public CharSequence loadDescription(PackageManager pm) {
1217 if (descriptionRes != 0) {
Jeff Brown07330792010-03-30 19:57:08 -07001218 CharSequence label = pm.getText(packageName, descriptionRes, this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001219 if (label != null) {
1220 return label;
1221 }
1222 }
1223 return null;
1224 }
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001225
1226 /**
1227 * Disable compatibility mode
1228 *
1229 * @hide
1230 */
1231 public void disableCompatibilityMode() {
Mitsuru Oshima69fff4a2009-07-21 09:51:05 -07001232 flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
Dianne Hackborn11b822d2009-07-21 20:03:02 -07001233 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
Dianne Hackborn14cee9f2010-04-23 17:51:26 -07001234 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
Mitsuru Oshimae5fb3282009-06-09 21:16:08 -07001235 }
Jeff Sharkey15447792015-11-05 16:18:51 -08001236
skuhne@google.com7e85eb02017-01-04 13:49:54 -08001237 /**
1238 * Is using compatibility mode for non densty aware legacy applications.
1239 *
1240 * @hide
1241 */
1242 public boolean usesCompatibilityMode() {
1243 return targetSdkVersion < DONUT ||
1244 (flags & (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
1245 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
1246 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS)) == 0;
1247 }
1248
Jeff Sharkey15447792015-11-05 16:18:51 -08001249 /** {@hide} */
1250 public void initForUser(int userId) {
1251 uid = UserHandle.getUid(userId, UserHandle.getAppId(uid));
1252
1253 if ("android".equals(packageName)) {
1254 dataDir = Environment.getDataSystemDirectory().getAbsolutePath();
1255 return;
1256 }
1257
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001258 deviceEncryptedDataDir = deviceProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001259 .getDataUserDePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001260 .getAbsolutePath();
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001261 credentialEncryptedDataDir = credentialProtectedDataDir = Environment
Jeff Sharkey8212ae02016-02-10 14:46:43 -07001262 .getDataUserCePackageDirectory(volumeUuid, userId, packageName)
Jeff Sharkey15447792015-11-05 16:18:51 -08001263 .getAbsolutePath();
1264
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001265 if ((privateFlags & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0
1266 && PackageManager.APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) {
1267 dataDir = deviceProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001268 } else {
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001269 dataDir = credentialProtectedDataDir;
Jeff Sharkey15447792015-11-05 16:18:51 -08001270 }
1271 }
1272
Jeff Brown07330792010-03-30 19:57:08 -07001273 /**
1274 * @hide
1275 */
Alexandra Gherghinaa7093142014-07-30 13:43:39 +01001276 @Override
1277 public Drawable loadDefaultIcon(PackageManager pm) {
Jeff Brown07330792010-03-30 19:57:08 -07001278 if ((flags & FLAG_EXTERNAL_STORAGE) != 0
1279 && isPackageUnavailable(pm)) {
1280 return Resources.getSystem().getDrawable(
1281 com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
1282 }
1283 return pm.getDefaultActivityIcon();
1284 }
1285
1286 private boolean isPackageUnavailable(PackageManager pm) {
1287 try {
1288 return pm.getPackageInfo(packageName, 0) == null;
1289 } catch (NameNotFoundException ex) {
1290 return true;
1291 }
1292 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001293
Jeff Brown07330792010-03-30 19:57:08 -07001294 /**
1295 * @hide
1296 */
Fyodor Kupoloveeea67b2015-02-23 17:14:45 -08001297 public boolean isForwardLocked() {
1298 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
1299 }
1300
1301 /**
1302 * @hide
1303 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001304 @TestApi
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001305 public boolean isSystemApp() {
1306 return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
1307 }
1308
1309 /**
1310 * @hide
1311 */
Jeff Sharkeya73b8fd2016-01-06 17:02:08 -07001312 @TestApi
Svet Ganovadc1cf42015-06-15 16:36:24 -07001313 public boolean isPrivilegedApp() {
1314 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
1315 }
1316
1317 /**
1318 * @hide
1319 */
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001320 public boolean isUpdatedSystemApp() {
1321 return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
1322 }
1323
Jeff Sharkeye2d45be2015-04-15 17:14:12 -07001324 /** @hide */
1325 public boolean isInternal() {
1326 return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
1327 }
1328
1329 /** @hide */
1330 public boolean isExternalAsec() {
1331 return TextUtils.isEmpty(volumeUuid)
1332 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
1333 }
1334
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001335 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001336 public boolean isDefaultToDeviceProtectedStorage() {
1337 return (privateFlags
1338 & ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
Jeff Sharkeye4697132016-02-06 19:46:15 -07001339 }
1340
1341 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001342 public boolean isDirectBootAware() {
1343 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkeyf9fc6d62015-11-08 16:46:05 -08001344 }
1345
Jeff Sharkey8924e872015-11-30 12:52:10 -07001346 /** @hide */
Jeff Sharkey8a372a02016-03-16 16:25:45 -06001347 public boolean isPartiallyDirectBootAware() {
1348 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PARTIALLY_DIRECT_BOOT_AWARE) != 0;
Jeff Sharkey8924e872015-11-30 12:52:10 -07001349 }
1350
Fyodor Kupolovb94c1652015-03-03 12:25:30 -08001351 /**
1352 * @hide
1353 */
Svet Ganov2acf0632015-11-24 19:10:59 -08001354 public boolean isEphemeralApp() {
1355 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_EPHEMERAL) != 0;
1356 }
1357
1358 /**
1359 * @hide
1360 */
Fyodor Kupolovbdbc9692015-12-14 13:11:13 -08001361 public boolean isRequiredForSystemUser() {
1362 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
1363 }
1364
1365 /**
1366 * @hide
1367 */
Svet Ganov67882122016-12-11 16:36:34 -08001368 public boolean isStaticSharedLibrary() {
1369 return (privateFlags & ApplicationInfo.PRIVATE_FLAG_STATIC_SHARED_LIBRARY) != 0;
1370 }
1371
1372 /**
1373 * @hide
1374 */
Jeff Brown07330792010-03-30 19:57:08 -07001375 @Override protected ApplicationInfo getApplicationInfo() {
1376 return this;
1377 }
Jeff Sharkeyd7460572014-07-06 20:44:55 -07001378
1379 /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
1380 /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
1381 /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
1382 /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
1383 /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
1384 /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
1385
1386 /** {@hide} */ public String getCodePath() { return scanSourceDir; }
1387 /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
1388 /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
1389 /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
1390 /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
Jeff Sharkeya3a43b02016-11-15 17:54:23 -07001391 /** {@hide} */ public String[] getSplitResourcePaths() { return splitPublicSourceDirs; }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001392}