Home | History | Annotate | Download | only in pm
      1 /*
      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 
     17 package android.content.pm;
     18 
     19 import android.content.pm.PackageManager.NameNotFoundException;
     20 import android.content.res.Resources;
     21 import android.graphics.drawable.Drawable;
     22 import android.os.Parcel;
     23 import android.os.Parcelable;
     24 import android.text.TextUtils;
     25 import android.util.Printer;
     26 
     27 import com.android.internal.util.ArrayUtils;
     28 
     29 import java.text.Collator;
     30 import java.util.Arrays;
     31 import java.util.Comparator;
     32 import java.util.Objects;
     33 
     34 /**
     35  * Information you can retrieve about a particular application.  This
     36  * corresponds to information collected from the AndroidManifest.xml's
     37  * <application> tag.
     38  */
     39 public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     40 
     41     /**
     42      * Default task affinity of all activities in this application. See
     43      * {@link ActivityInfo#taskAffinity} for more information.  This comes
     44      * from the "taskAffinity" attribute.
     45      */
     46     public String taskAffinity;
     47 
     48     /**
     49      * Optional name of a permission required to be able to access this
     50      * application's components.  From the "permission" attribute.
     51      */
     52     public String permission;
     53 
     54     /**
     55      * The name of the process this application should run in.  From the
     56      * "process" attribute or, if not set, the same as
     57      * <var>packageName</var>.
     58      */
     59     public String processName;
     60 
     61     /**
     62      * Class implementing the Application object.  From the "class"
     63      * attribute.
     64      */
     65     public String className;
     66 
     67     /**
     68      * A style resource identifier (in the package's resources) of the
     69      * description of an application.  From the "description" attribute
     70      * or, if not set, 0.
     71      */
     72     public int descriptionRes;
     73 
     74     /**
     75      * A style resource identifier (in the package's resources) of the
     76      * default visual theme of the application.  From the "theme" attribute
     77      * or, if not set, 0.
     78      */
     79     public int theme;
     80 
     81     /**
     82      * Class implementing the Application's manage space
     83      * functionality.  From the "manageSpaceActivity"
     84      * attribute. This is an optional attribute and will be null if
     85      * applications don't specify it in their manifest
     86      */
     87     public String manageSpaceActivityName;
     88 
     89     /**
     90      * Class implementing the Application's backup functionality.  From
     91      * the "backupAgent" attribute.  This is an optional attribute and
     92      * will be null if the application does not specify it in its manifest.
     93      *
     94      * <p>If android:allowBackup is set to false, this attribute is ignored.
     95      */
     96     public String backupAgentName;
     97 
     98     /**
     99      * An optional attribute that indicates the app supports automatic backup of app data.
    100      * <p>0 is the default and means the app's entire data folder + managed external storage will
    101      * be backed up;
    102      * Any negative value indicates the app does not support full-data backup, though it may still
    103      * want to participate via the traditional key/value backup API;
    104      * A positive number specifies an xml resource in which the application has defined its backup
    105      * include/exclude criteria.
    106      * <p>If android:allowBackup is set to false, this attribute is ignored.
    107      *
    108      * @see {@link android.content.Context#getNoBackupFilesDir}
    109      * @see {@link #FLAG_ALLOW_BACKUP}
    110      *
    111      * @hide
    112      */
    113     public int fullBackupContent = 0;
    114 
    115     /**
    116      * The default extra UI options for activities in this application.
    117      * Set from the {@link android.R.attr#uiOptions} attribute in the
    118      * activity's manifest.
    119      */
    120     public int uiOptions = 0;
    121 
    122     /**
    123      * Value for {@link #flags}: if set, this application is installed in the
    124      * device's system image.
    125      */
    126     public static final int FLAG_SYSTEM = 1<<0;
    127 
    128     /**
    129      * Value for {@link #flags}: set to true if this application would like to
    130      * allow debugging of its
    131      * code, even when installed on a non-development system.  Comes
    132      * from {@link android.R.styleable#AndroidManifestApplication_debuggable
    133      * android:debuggable} of the &lt;application&gt; tag.
    134      */
    135     public static final int FLAG_DEBUGGABLE = 1<<1;
    136 
    137     /**
    138      * Value for {@link #flags}: set to true if this application has code
    139      * associated with it.  Comes
    140      * from {@link android.R.styleable#AndroidManifestApplication_hasCode
    141      * android:hasCode} of the &lt;application&gt; tag.
    142      */
    143     public static final int FLAG_HAS_CODE = 1<<2;
    144 
    145     /**
    146      * Value for {@link #flags}: set to true if this application is persistent.
    147      * Comes from {@link android.R.styleable#AndroidManifestApplication_persistent
    148      * android:persistent} of the &lt;application&gt; tag.
    149      */
    150     public static final int FLAG_PERSISTENT = 1<<3;
    151 
    152     /**
    153      * Value for {@link #flags}: set to true if this application holds the
    154      * {@link android.Manifest.permission#FACTORY_TEST} permission and the
    155      * device is running in factory test mode.
    156      */
    157     public static final int FLAG_FACTORY_TEST = 1<<4;
    158 
    159     /**
    160      * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
    161      * Comes from {@link android.R.styleable#AndroidManifestApplication_allowTaskReparenting
    162      * android:allowTaskReparenting} of the &lt;application&gt; tag.
    163      */
    164     public static final int FLAG_ALLOW_TASK_REPARENTING = 1<<5;
    165 
    166     /**
    167      * Value for {@link #flags}: default value for the corresponding ActivityInfo flag.
    168      * Comes from {@link android.R.styleable#AndroidManifestApplication_allowClearUserData
    169      * android:allowClearUserData} of the &lt;application&gt; tag.
    170      */
    171     public static final int FLAG_ALLOW_CLEAR_USER_DATA = 1<<6;
    172 
    173     /**
    174      * Value for {@link #flags}: this is set if this application has been
    175      * install as an update to a built-in system application.
    176      */
    177     public static final int FLAG_UPDATED_SYSTEM_APP = 1<<7;
    178 
    179     /**
    180      * Value for {@link #flags}: this is set of the application has specified
    181      * {@link android.R.styleable#AndroidManifestApplication_testOnly
    182      * android:testOnly} to be true.
    183      */
    184     public static final int FLAG_TEST_ONLY = 1<<8;
    185 
    186     /**
    187      * Value for {@link #flags}: true when the application's window can be
    188      * reduced in size for smaller screens.  Corresponds to
    189      * {@link android.R.styleable#AndroidManifestSupportsScreens_smallScreens
    190      * android:smallScreens}.
    191      */
    192     public static final int FLAG_SUPPORTS_SMALL_SCREENS = 1<<9;
    193 
    194     /**
    195      * Value for {@link #flags}: true when the application's window can be
    196      * displayed on normal screens.  Corresponds to
    197      * {@link android.R.styleable#AndroidManifestSupportsScreens_normalScreens
    198      * android:normalScreens}.
    199      */
    200     public static final int FLAG_SUPPORTS_NORMAL_SCREENS = 1<<10;
    201 
    202     /**
    203      * Value for {@link #flags}: true when the application's window can be
    204      * increased in size for larger screens.  Corresponds to
    205      * {@link android.R.styleable#AndroidManifestSupportsScreens_largeScreens
    206      * android:largeScreens}.
    207      */
    208     public static final int FLAG_SUPPORTS_LARGE_SCREENS = 1<<11;
    209 
    210     /**
    211      * Value for {@link #flags}: true when the application knows how to adjust
    212      * its UI for different screen sizes.  Corresponds to
    213      * {@link android.R.styleable#AndroidManifestSupportsScreens_resizeable
    214      * android:resizeable}.
    215      */
    216     public static final int FLAG_RESIZEABLE_FOR_SCREENS = 1<<12;
    217 
    218     /**
    219      * Value for {@link #flags}: true when the application knows how to
    220      * accomodate different screen densities.  Corresponds to
    221      * {@link android.R.styleable#AndroidManifestSupportsScreens_anyDensity
    222      * android:anyDensity}.
    223      */
    224     public static final int FLAG_SUPPORTS_SCREEN_DENSITIES = 1<<13;
    225 
    226     /**
    227      * Value for {@link #flags}: set to true if this application would like to
    228      * request the VM to operate under the safe mode. Comes from
    229      * {@link android.R.styleable#AndroidManifestApplication_vmSafeMode
    230      * android:vmSafeMode} of the &lt;application&gt; tag.
    231      */
    232     public static final int FLAG_VM_SAFE_MODE = 1<<14;
    233 
    234     /**
    235      * Value for {@link #flags}: set to <code>false</code> if the application does not wish
    236      * to permit any OS-driven backups of its data; <code>true</code> otherwise.
    237      *
    238      * <p>Comes from the
    239      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
    240      * attribute of the &lt;application&gt; tag.
    241      */
    242     public static final int FLAG_ALLOW_BACKUP = 1<<15;
    243 
    244     /**
    245      * Value for {@link #flags}: set to <code>false</code> if the application must be kept
    246      * in memory following a full-system restore operation; <code>true</code> otherwise.
    247      * Ordinarily, during a full system restore operation each application is shut down
    248      * following execution of its agent's onRestore() method.  Setting this attribute to
    249      * <code>false</code> prevents this.  Most applications will not need to set this attribute.
    250      *
    251      * <p>If
    252      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
    253      * is set to <code>false</code> or no
    254      * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
    255      * is specified, this flag will be ignored.
    256      *
    257      * <p>Comes from the
    258      * {@link android.R.styleable#AndroidManifestApplication_killAfterRestore android:killAfterRestore}
    259      * attribute of the &lt;application&gt; tag.
    260      */
    261     public static final int FLAG_KILL_AFTER_RESTORE = 1<<16;
    262 
    263     /**
    264      * Value for {@link #flags}: Set to <code>true</code> if the application's backup
    265      * agent claims to be able to handle restore data even "from the future,"
    266      * i.e. from versions of the application with a versionCode greater than
    267      * the one currently installed on the device.  <i>Use with caution!</i>  By default
    268      * this attribute is <code>false</code> and the Backup Manager will ensure that data
    269      * from "future" versions of the application are never supplied during a restore operation.
    270      *
    271      * <p>If
    272      * {@link android.R.styleable#AndroidManifestApplication_allowBackup android:allowBackup}
    273      * is set to <code>false</code> or no
    274      * {@link android.R.styleable#AndroidManifestApplication_backupAgent android:backupAgent}
    275      * is specified, this flag will be ignored.
    276      *
    277      * <p>Comes from the
    278      * {@link android.R.styleable#AndroidManifestApplication_restoreAnyVersion android:restoreAnyVersion}
    279      * attribute of the &lt;application&gt; tag.
    280      */
    281     public static final int FLAG_RESTORE_ANY_VERSION = 1<<17;
    282 
    283     /**
    284      * Value for {@link #flags}: Set to true if the application is
    285      * currently installed on external/removable/unprotected storage.  Such
    286      * applications may not be available if their storage is not currently
    287      * mounted.  When the storage it is on is not available, it will look like
    288      * the application has been uninstalled (its .apk is no longer available)
    289      * but its persistent data is not removed.
    290      */
    291     public static final int FLAG_EXTERNAL_STORAGE = 1<<18;
    292 
    293     /**
    294      * Value for {@link #flags}: true when the application's window can be
    295      * increased in size for extra large screens.  Corresponds to
    296      * {@link android.R.styleable#AndroidManifestSupportsScreens_xlargeScreens
    297      * android:xlargeScreens}.
    298      */
    299     public static final int FLAG_SUPPORTS_XLARGE_SCREENS = 1<<19;
    300 
    301     /**
    302      * Value for {@link #flags}: true when the application has requested a
    303      * large heap for its processes.  Corresponds to
    304      * {@link android.R.styleable#AndroidManifestApplication_largeHeap
    305      * android:largeHeap}.
    306      */
    307     public static final int FLAG_LARGE_HEAP = 1<<20;
    308 
    309     /**
    310      * Value for {@link #flags}: true if this application's package is in
    311      * the stopped state.
    312      */
    313     public static final int FLAG_STOPPED = 1<<21;
    314 
    315     /**
    316      * Value for {@link #flags}: true  when the application is willing to support
    317      * RTL (right to left). All activities will inherit this value.
    318      *
    319      * Set from the {@link android.R.attr#supportsRtl} attribute in the
    320      * activity's manifest.
    321      *
    322      * Default value is false (no support for RTL).
    323      */
    324     public static final int FLAG_SUPPORTS_RTL = 1<<22;
    325 
    326     /**
    327      * Value for {@link #flags}: true if the application is currently
    328      * installed for the calling user.
    329      */
    330     public static final int FLAG_INSTALLED = 1<<23;
    331 
    332     /**
    333      * Value for {@link #flags}: true if the application only has its
    334      * data installed; the application package itself does not currently
    335      * exist on the device.
    336      */
    337     public static final int FLAG_IS_DATA_ONLY = 1<<24;
    338 
    339     /**
    340      * Value for {@link #flags}: true if the application was declared to be a game, or
    341      * false if it is a non-game application.
    342      */
    343     public static final int FLAG_IS_GAME = 1<<25;
    344 
    345     /**
    346      * Value for {@link #flags}: {@code true} if the application asks that only
    347      * full-data streaming backups of its data be performed even though it defines
    348      * a {@link android.app.backup.BackupAgent BackupAgent}, which normally
    349      * indicates that the app will manage its backed-up data via incremental
    350      * key/value updates.
    351      */
    352     public static final int FLAG_FULL_BACKUP_ONLY = 1<<26;
    353 
    354     /**
    355      * Value for {@link #flags}: {@code true} if the application may use cleartext network traffic
    356      * (e.g., HTTP rather than HTTPS; WebSockets rather than WebSockets Secure; XMPP, IMAP, STMP
    357      * without STARTTLS or TLS). If {@code false}, the app declares that it does not intend to use
    358      * cleartext network traffic, in which case platform components (e.g., HTTP stacks,
    359      * {@code DownloadManager}, {@code MediaPlayer}) will refuse app's requests to use cleartext
    360      * traffic. Third-party libraries are encouraged to honor this flag as well.
    361      *
    362      * <p>NOTE: {@code WebView} does not honor this flag.
    363      *
    364      * <p>This flag comes from
    365      * {@link android.R.styleable#AndroidManifestApplication_usesCleartextTraffic
    366      * android:usesCleartextTraffic} of the &lt;application&gt; tag.
    367      */
    368     public static final int FLAG_USES_CLEARTEXT_TRAFFIC = 1<<27;
    369 
    370     /**
    371      * When set installer extracts native libs from .apk files.
    372      */
    373     public static final int FLAG_EXTRACT_NATIVE_LIBS = 1<<28;
    374 
    375     /**
    376      * Value for {@link #flags}: {@code true} when the application's rendering
    377      * should be hardware accelerated.
    378      */
    379     public static final int FLAG_HARDWARE_ACCELERATED = 1<<29;
    380 
    381     /**
    382      * Value for {@link #flags}: true if code from this application will need to be
    383      * loaded into other applications' processes. On devices that support multiple
    384      * instruction sets, this implies the code might be loaded into a process that's
    385      * using any of the devices supported instruction sets.
    386      *
    387      * <p> The system might treat such applications specially, for eg., by
    388      * extracting the application's native libraries for all supported instruction
    389      * sets or by compiling the application's dex code for all supported instruction
    390      * sets.
    391      */
    392     public static final int FLAG_MULTIARCH  = 1 << 31;
    393 
    394     /**
    395      * Flags associated with the application.  Any combination of
    396      * {@link #FLAG_SYSTEM}, {@link #FLAG_DEBUGGABLE}, {@link #FLAG_HAS_CODE},
    397      * {@link #FLAG_PERSISTENT}, {@link #FLAG_FACTORY_TEST}, and
    398      * {@link #FLAG_ALLOW_TASK_REPARENTING}
    399      * {@link #FLAG_ALLOW_CLEAR_USER_DATA}, {@link #FLAG_UPDATED_SYSTEM_APP},
    400      * {@link #FLAG_TEST_ONLY}, {@link #FLAG_SUPPORTS_SMALL_SCREENS},
    401      * {@link #FLAG_SUPPORTS_NORMAL_SCREENS},
    402      * {@link #FLAG_SUPPORTS_LARGE_SCREENS}, {@link #FLAG_SUPPORTS_XLARGE_SCREENS},
    403      * {@link #FLAG_RESIZEABLE_FOR_SCREENS},
    404      * {@link #FLAG_SUPPORTS_SCREEN_DENSITIES}, {@link #FLAG_VM_SAFE_MODE},
    405      * {@link #FLAG_ALLOW_BACKUP}, {@link #FLAG_KILL_AFTER_RESTORE},
    406      * {@link #FLAG_RESTORE_ANY_VERSION}, {@link #FLAG_EXTERNAL_STORAGE},
    407      * {@link #FLAG_LARGE_HEAP}, {@link #FLAG_STOPPED},
    408      * {@link #FLAG_SUPPORTS_RTL}, {@link #FLAG_INSTALLED},
    409      * {@link #FLAG_IS_DATA_ONLY}, {@link #FLAG_IS_GAME},
    410      * {@link #FLAG_FULL_BACKUP_ONLY}, {@link #FLAG_USES_CLEARTEXT_TRAFFIC},
    411      * {@link #FLAG_MULTIARCH}.
    412      */
    413     public int flags = 0;
    414 
    415     /**
    416      * Value for {@link #privateFlags}: true if the application is hidden via restrictions and for
    417      * most purposes is considered as not installed.
    418      * {@hide}
    419      */
    420     public static final int PRIVATE_FLAG_HIDDEN = 1<<0;
    421 
    422     /**
    423      * Value for {@link #privateFlags}: set to <code>true</code> if the application
    424      * has reported that it is heavy-weight, and thus can not participate in
    425      * the normal application lifecycle.
    426      *
    427      * <p>Comes from the
    428      * android.R.styleable#AndroidManifestApplication_cantSaveState
    429      * attribute of the &lt;application&gt; tag.
    430      *
    431      * {@hide}
    432      */
    433     public static final int PRIVATE_FLAG_CANT_SAVE_STATE = 1<<1;
    434 
    435     /**
    436      * Value for {@link #privateFlags}: Set to true if the application has been
    437      * installed using the forward lock option.
    438      *
    439      * NOTE: DO NOT CHANGE THIS VALUE!  It is saved in packages.xml.
    440      *
    441      * {@hide}
    442      */
    443     public static final int PRIVATE_FLAG_FORWARD_LOCK = 1<<2;
    444 
    445     /**
    446      * Value for {@link #privateFlags}: set to {@code true} if the application
    447      * is permitted to hold privileged permissions.
    448      *
    449      * {@hide}
    450      */
    451     public static final int PRIVATE_FLAG_PRIVILEGED = 1<<3;
    452 
    453     /**
    454      * Value for {@link #flags}: {@code true} if the application has any IntentFiler with some
    455      * data URI using HTTP or HTTPS with an associated VIEW action.
    456      *
    457      * {@hide}
    458      */
    459     public static final int PRIVATE_FLAG_HAS_DOMAIN_URLS = 1<<4;
    460 
    461     /**
    462      * Private/hidden flags. See {@code PRIVATE_FLAG_...} constants.
    463      * {@hide}
    464      */
    465     public int privateFlags;
    466 
    467     /**
    468      * The required smallest screen width the application can run on.  If 0,
    469      * nothing has been specified.  Comes from
    470      * {@link android.R.styleable#AndroidManifestSupportsScreens_requiresSmallestWidthDp
    471      * android:requiresSmallestWidthDp} attribute of the &lt;supports-screens&gt; tag.
    472      */
    473     public int requiresSmallestWidthDp = 0;
    474 
    475     /**
    476      * The maximum smallest screen width the application is designed for.  If 0,
    477      * nothing has been specified.  Comes from
    478      * {@link android.R.styleable#AndroidManifestSupportsScreens_compatibleWidthLimitDp
    479      * android:compatibleWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
    480      */
    481     public int compatibleWidthLimitDp = 0;
    482 
    483     /**
    484      * The maximum smallest screen width the application will work on.  If 0,
    485      * nothing has been specified.  Comes from
    486      * {@link android.R.styleable#AndroidManifestSupportsScreens_largestWidthLimitDp
    487      * android:largestWidthLimitDp} attribute of the &lt;supports-screens&gt; tag.
    488      */
    489     public int largestWidthLimitDp = 0;
    490 
    491     /** {@hide} */
    492     public String volumeUuid;
    493     /** {@hide} */
    494     public String scanSourceDir;
    495     /** {@hide} */
    496     public String scanPublicSourceDir;
    497 
    498     /**
    499      * Full path to the base APK for this application.
    500      */
    501     public String sourceDir;
    502 
    503     /**
    504      * Full path to the publicly available parts of {@link #sourceDir},
    505      * including resources and manifest. This may be different from
    506      * {@link #sourceDir} if an application is forward locked.
    507      */
    508     public String publicSourceDir;
    509 
    510     /**
    511      * Full paths to zero or more split APKs that, when combined with the base
    512      * APK defined in {@link #sourceDir}, form a complete application.
    513      */
    514     public String[] splitSourceDirs;
    515 
    516     /**
    517      * Full path to the publicly available parts of {@link #splitSourceDirs},
    518      * including resources and manifest. This may be different from
    519      * {@link #splitSourceDirs} if an application is forward locked.
    520      */
    521     public String[] splitPublicSourceDirs;
    522 
    523     /**
    524      * Full paths to the locations of extra resource packages this application
    525      * uses. This field is only used if there are extra resource packages,
    526      * otherwise it is null.
    527      *
    528      * {@hide}
    529      */
    530     public String[] resourceDirs;
    531 
    532     /**
    533      * String retrieved from the seinfo tag found in selinux policy. This value
    534      * is useful in setting an SELinux security context on the process as well
    535      * as its data directory.
    536      *
    537      * {@hide}
    538      */
    539     public String seinfo;
    540 
    541     /**
    542      * Paths to all shared libraries this application is linked against.  This
    543      * field is only set if the {@link PackageManager#GET_SHARED_LIBRARY_FILES
    544      * PackageManager.GET_SHARED_LIBRARY_FILES} flag was used when retrieving
    545      * the structure.
    546      */
    547     public String[] sharedLibraryFiles;
    548 
    549     /**
    550      * Full path to a directory assigned to the package for its persistent
    551      * data.
    552      */
    553     public String dataDir;
    554 
    555     /**
    556      * Full path to the directory where native JNI libraries are stored.
    557      */
    558     public String nativeLibraryDir;
    559 
    560     /**
    561      * Full path where unpacked native libraries for {@link #secondaryCpuAbi}
    562      * are stored, if present.
    563      *
    564      * The main reason this exists is for bundled multi-arch apps, where
    565      * it's not trivial to calculate the location of libs for the secondary abi
    566      * given the location of the primary.
    567      *
    568      * TODO: Change the layout of bundled installs so that we can use
    569      * nativeLibraryRootDir & nativeLibraryRootRequiresIsa there as well.
    570      * (e.g {@code [ "/system/app-lib/Foo/arm", "/system/app-lib/Foo/arm64" ]}
    571      * instead of {@code [ "/system/lib/Foo", "/system/lib64/Foo" ]}.
    572      *
    573      * @hide
    574      */
    575     public String secondaryNativeLibraryDir;
    576 
    577     /**
    578      * The root path where unpacked native libraries are stored.
    579      * <p>
    580      * When {@link #nativeLibraryRootRequiresIsa} is set, the libraries are
    581      * placed in ISA-specific subdirectories under this path, otherwise the
    582      * libraries are placed directly at this path.
    583      *
    584      * @hide
    585      */
    586     public String nativeLibraryRootDir;
    587 
    588     /**
    589      * Flag indicating that ISA must be appended to
    590      * {@link #nativeLibraryRootDir} to be useful.
    591      *
    592      * @hide
    593      */
    594     public boolean nativeLibraryRootRequiresIsa;
    595 
    596     /**
    597      * The primary ABI that this application requires, This is inferred from the ABIs
    598      * of the native JNI libraries the application bundles. Will be {@code null}
    599      * if this application does not require any particular ABI.
    600      *
    601      * If non-null, the application will always be launched with this ABI.
    602      *
    603      * {@hide}
    604      */
    605     public String primaryCpuAbi;
    606 
    607     /**
    608      * The secondary ABI for this application. Might be non-null for multi-arch
    609      * installs. The application itself never uses this ABI, but other applications that
    610      * use its code might.
    611      *
    612      * {@hide}
    613      */
    614     public String secondaryCpuAbi;
    615 
    616     /**
    617      * The kernel user-ID that has been assigned to this application;
    618      * currently this is not a unique ID (multiple applications can have
    619      * the same uid).
    620      */
    621     public int uid;
    622 
    623     /**
    624      * The minimum SDK version this application targets.  It may run on earlier
    625      * versions, but it knows how to work with any new behavior added at this
    626      * version.  Will be {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}
    627      * if this is a development build and the app is targeting that.  You should
    628      * compare that this number is >= the SDK version number at which your
    629      * behavior was introduced.
    630      */
    631     public int targetSdkVersion;
    632 
    633     /**
    634      * The app's declared version code.
    635      * @hide
    636      */
    637     public int versionCode;
    638 
    639     /**
    640      * When false, indicates that all components within this application are
    641      * considered disabled, regardless of their individually set enabled status.
    642      */
    643     public boolean enabled = true;
    644 
    645     /**
    646      * For convenient access to the current enabled setting of this app.
    647      * @hide
    648      */
    649     public int enabledSetting = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
    650 
    651     /**
    652      * For convenient access to package's install location.
    653      * @hide
    654      */
    655     public int installLocation = PackageInfo.INSTALL_LOCATION_UNSPECIFIED;
    656 
    657     public void dump(Printer pw, String prefix) {
    658         super.dumpFront(pw, prefix);
    659         if (className != null) {
    660             pw.println(prefix + "className=" + className);
    661         }
    662         if (permission != null) {
    663             pw.println(prefix + "permission=" + permission);
    664         }
    665         pw.println(prefix + "processName=" + processName);
    666         pw.println(prefix + "taskAffinity=" + taskAffinity);
    667         pw.println(prefix + "uid=" + uid + " flags=0x" + Integer.toHexString(flags)
    668                 + " privateFlags=0x" + Integer.toHexString(privateFlags)
    669                 + " theme=0x" + Integer.toHexString(theme));
    670         pw.println(prefix + "requiresSmallestWidthDp=" + requiresSmallestWidthDp
    671                 + " compatibleWidthLimitDp=" + compatibleWidthLimitDp
    672                 + " largestWidthLimitDp=" + largestWidthLimitDp);
    673         pw.println(prefix + "sourceDir=" + sourceDir);
    674         if (!Objects.equals(sourceDir, publicSourceDir)) {
    675             pw.println(prefix + "publicSourceDir=" + publicSourceDir);
    676         }
    677         if (!ArrayUtils.isEmpty(splitSourceDirs)) {
    678             pw.println(prefix + "splitSourceDirs=" + Arrays.toString(splitSourceDirs));
    679         }
    680         if (!ArrayUtils.isEmpty(splitPublicSourceDirs)
    681                 && !Arrays.equals(splitSourceDirs, splitPublicSourceDirs)) {
    682             pw.println(prefix + "splitPublicSourceDirs=" + Arrays.toString(splitPublicSourceDirs));
    683         }
    684         if (resourceDirs != null) {
    685             pw.println(prefix + "resourceDirs=" + resourceDirs);
    686         }
    687         if (seinfo != null) {
    688             pw.println(prefix + "seinfo=" + seinfo);
    689         }
    690         pw.println(prefix + "dataDir=" + dataDir);
    691         if (sharedLibraryFiles != null) {
    692             pw.println(prefix + "sharedLibraryFiles=" + Arrays.toString(sharedLibraryFiles));
    693         }
    694         pw.println(prefix + "enabled=" + enabled + " targetSdkVersion=" + targetSdkVersion
    695                 + " versionCode=" + versionCode);
    696         if (manageSpaceActivityName != null) {
    697             pw.println(prefix + "manageSpaceActivityName="+manageSpaceActivityName);
    698         }
    699         if (descriptionRes != 0) {
    700             pw.println(prefix + "description=0x"+Integer.toHexString(descriptionRes));
    701         }
    702         if (uiOptions != 0) {
    703             pw.println(prefix + "uiOptions=0x" + Integer.toHexString(uiOptions));
    704         }
    705         pw.println(prefix + "supportsRtl=" + (hasRtlSupport() ? "true" : "false"));
    706         if (fullBackupContent > 0) {
    707             pw.println(prefix + "fullBackupContent=@xml/" + fullBackupContent);
    708         } else {
    709             pw.println(prefix + "fullBackupContent=" + (fullBackupContent < 0 ? "false" : "true"));
    710         }
    711         super.dumpBack(pw, prefix);
    712     }
    713 
    714     /**
    715      * @return true if "supportsRtl" has been set to true in the AndroidManifest
    716      * @hide
    717      */
    718     public boolean hasRtlSupport() {
    719         return (flags & FLAG_SUPPORTS_RTL) == FLAG_SUPPORTS_RTL;
    720     }
    721 
    722     public static class DisplayNameComparator
    723             implements Comparator<ApplicationInfo> {
    724         public DisplayNameComparator(PackageManager pm) {
    725             mPM = pm;
    726         }
    727 
    728         public final int compare(ApplicationInfo aa, ApplicationInfo ab) {
    729             CharSequence  sa = mPM.getApplicationLabel(aa);
    730             if (sa == null) {
    731                 sa = aa.packageName;
    732             }
    733             CharSequence  sb = mPM.getApplicationLabel(ab);
    734             if (sb == null) {
    735                 sb = ab.packageName;
    736             }
    737 
    738             return sCollator.compare(sa.toString(), sb.toString());
    739         }
    740 
    741         private final Collator   sCollator = Collator.getInstance();
    742         private PackageManager   mPM;
    743     }
    744 
    745     public ApplicationInfo() {
    746     }
    747 
    748     public ApplicationInfo(ApplicationInfo orig) {
    749         super(orig);
    750         taskAffinity = orig.taskAffinity;
    751         permission = orig.permission;
    752         processName = orig.processName;
    753         className = orig.className;
    754         theme = orig.theme;
    755         flags = orig.flags;
    756         privateFlags = orig.privateFlags;
    757         requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
    758         compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
    759         largestWidthLimitDp = orig.largestWidthLimitDp;
    760         volumeUuid = orig.volumeUuid;
    761         scanSourceDir = orig.scanSourceDir;
    762         scanPublicSourceDir = orig.scanPublicSourceDir;
    763         sourceDir = orig.sourceDir;
    764         publicSourceDir = orig.publicSourceDir;
    765         splitSourceDirs = orig.splitSourceDirs;
    766         splitPublicSourceDirs = orig.splitPublicSourceDirs;
    767         nativeLibraryDir = orig.nativeLibraryDir;
    768         secondaryNativeLibraryDir = orig.secondaryNativeLibraryDir;
    769         nativeLibraryRootDir = orig.nativeLibraryRootDir;
    770         nativeLibraryRootRequiresIsa = orig.nativeLibraryRootRequiresIsa;
    771         primaryCpuAbi = orig.primaryCpuAbi;
    772         secondaryCpuAbi = orig.secondaryCpuAbi;
    773         resourceDirs = orig.resourceDirs;
    774         seinfo = orig.seinfo;
    775         sharedLibraryFiles = orig.sharedLibraryFiles;
    776         dataDir = orig.dataDir;
    777         uid = orig.uid;
    778         targetSdkVersion = orig.targetSdkVersion;
    779         versionCode = orig.versionCode;
    780         enabled = orig.enabled;
    781         enabledSetting = orig.enabledSetting;
    782         installLocation = orig.installLocation;
    783         manageSpaceActivityName = orig.manageSpaceActivityName;
    784         descriptionRes = orig.descriptionRes;
    785         uiOptions = orig.uiOptions;
    786         backupAgentName = orig.backupAgentName;
    787         fullBackupContent = orig.fullBackupContent;
    788     }
    789 
    790 
    791     public String toString() {
    792         return "ApplicationInfo{"
    793             + Integer.toHexString(System.identityHashCode(this))
    794             + " " + packageName + "}";
    795     }
    796 
    797     public int describeContents() {
    798         return 0;
    799     }
    800 
    801     public void writeToParcel(Parcel dest, int parcelableFlags) {
    802         super.writeToParcel(dest, parcelableFlags);
    803         dest.writeString(taskAffinity);
    804         dest.writeString(permission);
    805         dest.writeString(processName);
    806         dest.writeString(className);
    807         dest.writeInt(theme);
    808         dest.writeInt(flags);
    809         dest.writeInt(privateFlags);
    810         dest.writeInt(requiresSmallestWidthDp);
    811         dest.writeInt(compatibleWidthLimitDp);
    812         dest.writeInt(largestWidthLimitDp);
    813         dest.writeString(volumeUuid);
    814         dest.writeString(scanSourceDir);
    815         dest.writeString(scanPublicSourceDir);
    816         dest.writeString(sourceDir);
    817         dest.writeString(publicSourceDir);
    818         dest.writeStringArray(splitSourceDirs);
    819         dest.writeStringArray(splitPublicSourceDirs);
    820         dest.writeString(nativeLibraryDir);
    821         dest.writeString(secondaryNativeLibraryDir);
    822         dest.writeString(nativeLibraryRootDir);
    823         dest.writeInt(nativeLibraryRootRequiresIsa ? 1 : 0);
    824         dest.writeString(primaryCpuAbi);
    825         dest.writeString(secondaryCpuAbi);
    826         dest.writeStringArray(resourceDirs);
    827         dest.writeString(seinfo);
    828         dest.writeStringArray(sharedLibraryFiles);
    829         dest.writeString(dataDir);
    830         dest.writeInt(uid);
    831         dest.writeInt(targetSdkVersion);
    832         dest.writeInt(versionCode);
    833         dest.writeInt(enabled ? 1 : 0);
    834         dest.writeInt(enabledSetting);
    835         dest.writeInt(installLocation);
    836         dest.writeString(manageSpaceActivityName);
    837         dest.writeString(backupAgentName);
    838         dest.writeInt(descriptionRes);
    839         dest.writeInt(uiOptions);
    840         dest.writeInt(fullBackupContent);
    841     }
    842 
    843     public static final Parcelable.Creator<ApplicationInfo> CREATOR
    844             = new Parcelable.Creator<ApplicationInfo>() {
    845         public ApplicationInfo createFromParcel(Parcel source) {
    846             return new ApplicationInfo(source);
    847         }
    848         public ApplicationInfo[] newArray(int size) {
    849             return new ApplicationInfo[size];
    850         }
    851     };
    852 
    853     private ApplicationInfo(Parcel source) {
    854         super(source);
    855         taskAffinity = source.readString();
    856         permission = source.readString();
    857         processName = source.readString();
    858         className = source.readString();
    859         theme = source.readInt();
    860         flags = source.readInt();
    861         privateFlags = source.readInt();
    862         requiresSmallestWidthDp = source.readInt();
    863         compatibleWidthLimitDp = source.readInt();
    864         largestWidthLimitDp = source.readInt();
    865         volumeUuid = source.readString();
    866         scanSourceDir = source.readString();
    867         scanPublicSourceDir = source.readString();
    868         sourceDir = source.readString();
    869         publicSourceDir = source.readString();
    870         splitSourceDirs = source.readStringArray();
    871         splitPublicSourceDirs = source.readStringArray();
    872         nativeLibraryDir = source.readString();
    873         secondaryNativeLibraryDir = source.readString();
    874         nativeLibraryRootDir = source.readString();
    875         nativeLibraryRootRequiresIsa = source.readInt() != 0;
    876         primaryCpuAbi = source.readString();
    877         secondaryCpuAbi = source.readString();
    878         resourceDirs = source.readStringArray();
    879         seinfo = source.readString();
    880         sharedLibraryFiles = source.readStringArray();
    881         dataDir = source.readString();
    882         uid = source.readInt();
    883         targetSdkVersion = source.readInt();
    884         versionCode = source.readInt();
    885         enabled = source.readInt() != 0;
    886         enabledSetting = source.readInt();
    887         installLocation = source.readInt();
    888         manageSpaceActivityName = source.readString();
    889         backupAgentName = source.readString();
    890         descriptionRes = source.readInt();
    891         uiOptions = source.readInt();
    892         fullBackupContent = source.readInt();
    893     }
    894 
    895     /**
    896      * Retrieve the textual description of the application.  This
    897      * will call back on the given PackageManager to load the description from
    898      * the application.
    899      *
    900      * @param pm A PackageManager from which the label can be loaded; usually
    901      * the PackageManager from which you originally retrieved this item.
    902      *
    903      * @return Returns a CharSequence containing the application's description.
    904      * If there is no description, null is returned.
    905      */
    906     public CharSequence loadDescription(PackageManager pm) {
    907         if (descriptionRes != 0) {
    908             CharSequence label = pm.getText(packageName, descriptionRes, this);
    909             if (label != null) {
    910                 return label;
    911             }
    912         }
    913         return null;
    914     }
    915 
    916     /**
    917      * Disable compatibility mode
    918      *
    919      * @hide
    920      */
    921     public void disableCompatibilityMode() {
    922         flags |= (FLAG_SUPPORTS_LARGE_SCREENS | FLAG_SUPPORTS_NORMAL_SCREENS |
    923                 FLAG_SUPPORTS_SMALL_SCREENS | FLAG_RESIZEABLE_FOR_SCREENS |
    924                 FLAG_SUPPORTS_SCREEN_DENSITIES | FLAG_SUPPORTS_XLARGE_SCREENS);
    925     }
    926 
    927     /**
    928      * @hide
    929      */
    930     @Override
    931     public Drawable loadDefaultIcon(PackageManager pm) {
    932         if ((flags & FLAG_EXTERNAL_STORAGE) != 0
    933                 && isPackageUnavailable(pm)) {
    934             return Resources.getSystem().getDrawable(
    935                     com.android.internal.R.drawable.sym_app_on_sd_unavailable_icon);
    936         }
    937         return pm.getDefaultActivityIcon();
    938     }
    939 
    940     private boolean isPackageUnavailable(PackageManager pm) {
    941         try {
    942             return pm.getPackageInfo(packageName, 0) == null;
    943         } catch (NameNotFoundException ex) {
    944             return true;
    945         }
    946     }
    947 
    948     /**
    949      * @hide
    950      */
    951     public boolean isForwardLocked() {
    952         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_FORWARD_LOCK) != 0;
    953     }
    954 
    955     /**
    956      * @hide
    957      */
    958     public boolean isSystemApp() {
    959         return (flags & ApplicationInfo.FLAG_SYSTEM) != 0;
    960     }
    961 
    962     /**
    963      * @hide
    964      */
    965     public boolean isPrivilegedApp() {
    966         return (privateFlags & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
    967     }
    968 
    969     /**
    970      * @hide
    971      */
    972     public boolean isUpdatedSystemApp() {
    973         return (flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;
    974     }
    975 
    976     /** @hide */
    977     public boolean isInternal() {
    978         return (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) == 0;
    979     }
    980 
    981     /** @hide */
    982     public boolean isExternalAsec() {
    983         return TextUtils.isEmpty(volumeUuid)
    984                 && (flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
    985     }
    986 
    987     /**
    988      * @hide
    989      */
    990     @Override protected ApplicationInfo getApplicationInfo() {
    991         return this;
    992     }
    993 
    994     /** {@hide} */ public void setCodePath(String codePath) { scanSourceDir = codePath; }
    995     /** {@hide} */ public void setBaseCodePath(String baseCodePath) { sourceDir = baseCodePath; }
    996     /** {@hide} */ public void setSplitCodePaths(String[] splitCodePaths) { splitSourceDirs = splitCodePaths; }
    997     /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
    998     /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
    999     /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
   1000 
   1001     /** {@hide} */ public String getCodePath() { return scanSourceDir; }
   1002     /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
   1003     /** {@hide} */ public String[] getSplitCodePaths() { return splitSourceDirs; }
   1004     /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
   1005     /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
   1006     /** {@hide} */ public String[] getSplitResourcePaths() { return splitSourceDirs; }
   1007 }
   1008