Home | History | Annotate | Download | only in pm
      1 /*
      2  * Copyright (C) 2006 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.annotation.SdkConstant;
     20 import android.annotation.SdkConstant.SdkConstantType;
     21 import android.content.ComponentName;
     22 import android.content.Context;
     23 import android.content.Intent;
     24 import android.content.IntentFilter;
     25 import android.content.IntentSender;
     26 import android.content.res.Resources;
     27 import android.content.res.XmlResourceParser;
     28 import android.graphics.drawable.Drawable;
     29 import android.net.Uri;
     30 import android.os.Environment;
     31 import android.util.AndroidException;
     32 import android.util.DisplayMetrics;
     33 
     34 import java.io.File;
     35 import java.util.List;
     36 
     37 /**
     38  * Class for retrieving various kinds of information related to the application
     39  * packages that are currently installed on the device.
     40  *
     41  * You can find this class through {@link Context#getPackageManager}.
     42  */
     43 public abstract class PackageManager {
     44 
     45     /**
     46      * This exception is thrown when a given package, application, or component
     47      * name can not be found.
     48      */
     49     public static class NameNotFoundException extends AndroidException {
     50         public NameNotFoundException() {
     51         }
     52 
     53         public NameNotFoundException(String name) {
     54             super(name);
     55         }
     56     }
     57 
     58     /**
     59      * {@link PackageInfo} flag: return information about
     60      * activities in the package in {@link PackageInfo#activities}.
     61      */
     62     public static final int GET_ACTIVITIES              = 0x00000001;
     63 
     64     /**
     65      * {@link PackageInfo} flag: return information about
     66      * intent receivers in the package in
     67      * {@link PackageInfo#receivers}.
     68      */
     69     public static final int GET_RECEIVERS               = 0x00000002;
     70 
     71     /**
     72      * {@link PackageInfo} flag: return information about
     73      * services in the package in {@link PackageInfo#services}.
     74      */
     75     public static final int GET_SERVICES                = 0x00000004;
     76 
     77     /**
     78      * {@link PackageInfo} flag: return information about
     79      * content providers in the package in
     80      * {@link PackageInfo#providers}.
     81      */
     82     public static final int GET_PROVIDERS               = 0x00000008;
     83 
     84     /**
     85      * {@link PackageInfo} flag: return information about
     86      * instrumentation in the package in
     87      * {@link PackageInfo#instrumentation}.
     88      */
     89     public static final int GET_INSTRUMENTATION         = 0x00000010;
     90 
     91     /**
     92      * {@link PackageInfo} flag: return information about the
     93      * intent filters supported by the activity.
     94      */
     95     public static final int GET_INTENT_FILTERS          = 0x00000020;
     96 
     97     /**
     98      * {@link PackageInfo} flag: return information about the
     99      * signatures included in the package.
    100      */
    101     public static final int GET_SIGNATURES          = 0x00000040;
    102 
    103     /**
    104      * {@link ResolveInfo} flag: return the IntentFilter that
    105      * was matched for a particular ResolveInfo in
    106      * {@link ResolveInfo#filter}.
    107      */
    108     public static final int GET_RESOLVED_FILTER         = 0x00000040;
    109 
    110     /**
    111      * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
    112      * data {@link android.os.Bundle}s that are associated with a component.
    113      * This applies for any API returning a ComponentInfo subclass.
    114      */
    115     public static final int GET_META_DATA               = 0x00000080;
    116 
    117     /**
    118      * {@link PackageInfo} flag: return the
    119      * {@link PackageInfo#gids group ids} that are associated with an
    120      * application.
    121      * This applies for any API returning a PackageInfo class, either
    122      * directly or nested inside of another.
    123      */
    124     public static final int GET_GIDS                    = 0x00000100;
    125 
    126     /**
    127      * {@link PackageInfo} flag: include disabled components in the returned info.
    128      */
    129     public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
    130 
    131     /**
    132      * {@link ApplicationInfo} flag: return the
    133      * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
    134      * that are associated with an application.
    135      * This applies for any API returning an ApplicationInfo class, either
    136      * directly or nested inside of another.
    137      */
    138     public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
    139 
    140     /**
    141      * {@link ProviderInfo} flag: return the
    142      * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
    143      * that are associated with a content provider.
    144      * This applies for any API returning a ProviderInfo class, either
    145      * directly or nested inside of another.
    146      */
    147     public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
    148     /**
    149      * {@link PackageInfo} flag: return information about
    150      * permissions in the package in
    151      * {@link PackageInfo#permissions}.
    152      */
    153     public static final int GET_PERMISSIONS               = 0x00001000;
    154 
    155     /**
    156      * Flag parameter to retrieve some information about all applications (even
    157      * uninstalled ones) which have data directories. This state could have
    158      * resulted if applications have been deleted with flag
    159      * {@code DONT_DELETE_DATA} with a possibility of being replaced or
    160      * reinstalled in future.
    161      * <p>
    162      * Note: this flag may cause less information about currently installed
    163      * applications to be returned.
    164      */
    165     public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
    166 
    167     /**
    168      * {@link PackageInfo} flag: return information about
    169      * hardware preferences in
    170      * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
    171      * requested features in {@link PackageInfo#reqFeatures
    172      * PackageInfo.reqFeatures}.
    173      */
    174     public static final int GET_CONFIGURATIONS = 0x00004000;
    175 
    176     /**
    177      * Resolution and querying flag: if set, only filters that support the
    178      * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
    179      * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
    180      * supplied Intent.
    181      */
    182     public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
    183 
    184     /**
    185      * Permission check result: this is returned by {@link #checkPermission}
    186      * if the permission has been granted to the given package.
    187      */
    188     public static final int PERMISSION_GRANTED = 0;
    189 
    190     /**
    191      * Permission check result: this is returned by {@link #checkPermission}
    192      * if the permission has not been granted to the given package.
    193      */
    194     public static final int PERMISSION_DENIED = -1;
    195 
    196     /**
    197      * Signature check result: this is returned by {@link #checkSignatures}
    198      * if all signatures on the two packages match.
    199      */
    200     public static final int SIGNATURE_MATCH = 0;
    201 
    202     /**
    203      * Signature check result: this is returned by {@link #checkSignatures}
    204      * if neither of the two packages is signed.
    205      */
    206     public static final int SIGNATURE_NEITHER_SIGNED = 1;
    207 
    208     /**
    209      * Signature check result: this is returned by {@link #checkSignatures}
    210      * if the first package is not signed but the second is.
    211      */
    212     public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
    213 
    214     /**
    215      * Signature check result: this is returned by {@link #checkSignatures}
    216      * if the second package is not signed but the first is.
    217      */
    218     public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
    219 
    220     /**
    221      * Signature check result: this is returned by {@link #checkSignatures}
    222      * if not all signatures on both packages match.
    223      */
    224     public static final int SIGNATURE_NO_MATCH = -3;
    225 
    226     /**
    227      * Signature check result: this is returned by {@link #checkSignatures}
    228      * if either of the packages are not valid.
    229      */
    230     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
    231 
    232     /**
    233      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
    234      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
    235      * component or application is in its default enabled state (as specified
    236      * in its manifest).
    237      */
    238     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
    239 
    240     /**
    241      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
    242      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
    243      * component or application has been explictily enabled, regardless of
    244      * what it has specified in its manifest.
    245      */
    246     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
    247 
    248     /**
    249      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
    250      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
    251      * component or application has been explicitly disabled, regardless of
    252      * what it has specified in its manifest.
    253      */
    254     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
    255 
    256     /**
    257      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
    258      * user has explicitly disabled the application, regardless of what it has
    259      * specified in its manifest.  Because this is due to the user's request,
    260      * they may re-enable it if desired through the appropriate system UI.  This
    261      * option currently <strong>can not</strong> be used with
    262      * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
    263      */
    264     public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
    265 
    266     /**
    267      * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
    268      * indicate that this package should be installed as forward locked, i.e. only the app itself
    269      * should have access to its code and non-resource assets.
    270      * @hide
    271      */
    272     public static final int INSTALL_FORWARD_LOCK = 0x00000001;
    273 
    274     /**
    275      * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
    276      * installed package, if one exists.
    277      * @hide
    278      */
    279     public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
    280 
    281     /**
    282      * Flag parameter for {@link #installPackage} to indicate that you want to
    283      * allow test packages (those that have set android:testOnly in their
    284      * manifest) to be installed.
    285      * @hide
    286      */
    287     public static final int INSTALL_ALLOW_TEST = 0x00000004;
    288 
    289     /**
    290      * Flag parameter for {@link #installPackage} to indicate that this
    291      * package has to be installed on the sdcard.
    292      * @hide
    293      */
    294     public static final int INSTALL_EXTERNAL = 0x00000008;
    295 
    296     /**
    297      * Flag parameter for {@link #installPackage} to indicate that this package
    298      * has to be installed on the sdcard.
    299      * @hide
    300      */
    301     public static final int INSTALL_INTERNAL = 0x00000010;
    302 
    303     /**
    304      * Flag parameter for {@link #installPackage} to indicate that this install
    305      * was initiated via ADB.
    306      *
    307      * @hide
    308      */
    309     public static final int INSTALL_FROM_ADB = 0x00000020;
    310 
    311     /**
    312      * Flag parameter for
    313      * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
    314      * that you don't want to kill the app containing the component.  Be careful when you set this
    315      * since changing component states can make the containing application's behavior unpredictable.
    316      */
    317     public static final int DONT_KILL_APP = 0x00000001;
    318 
    319     /**
    320      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    321      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
    322      * @hide
    323      */
    324     public static final int INSTALL_SUCCEEDED = 1;
    325 
    326     /**
    327      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    328      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
    329      * already installed.
    330      * @hide
    331      */
    332     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
    333 
    334     /**
    335      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    336      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
    337      * file is invalid.
    338      * @hide
    339      */
    340     public static final int INSTALL_FAILED_INVALID_APK = -2;
    341 
    342     /**
    343      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    344      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
    345      * is invalid.
    346      * @hide
    347      */
    348     public static final int INSTALL_FAILED_INVALID_URI = -3;
    349 
    350     /**
    351      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    352      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
    353      * service found that the device didn't have enough storage space to install the app.
    354      * @hide
    355      */
    356     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
    357 
    358     /**
    359      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    360      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
    361      * package is already installed with the same name.
    362      * @hide
    363      */
    364     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
    365 
    366     /**
    367      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    368      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    369      * the requested shared user does not exist.
    370      * @hide
    371      */
    372     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
    373 
    374     /**
    375      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    376      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    377      * a previously installed package of the same name has a different signature
    378      * than the new package (and the old package's data was not removed).
    379      * @hide
    380      */
    381     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
    382 
    383     /**
    384      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    385      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    386      * the new package is requested a shared user which is already installed on the
    387      * device and does not have matching signature.
    388      * @hide
    389      */
    390     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
    391 
    392     /**
    393      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    394      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    395      * the new package uses a shared library that is not available.
    396      * @hide
    397      */
    398     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
    399 
    400     /**
    401      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    402      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    403      * the new package uses a shared library that is not available.
    404      * @hide
    405      */
    406     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
    407 
    408     /**
    409      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    410      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    411      * the new package failed while optimizing and validating its dex files,
    412      * either because there was not enough storage or the validation failed.
    413      * @hide
    414      */
    415     public static final int INSTALL_FAILED_DEXOPT = -11;
    416 
    417     /**
    418      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    419      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    420      * the new package failed because the current SDK version is older than
    421      * that required by the package.
    422      * @hide
    423      */
    424     public static final int INSTALL_FAILED_OLDER_SDK = -12;
    425 
    426     /**
    427      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    428      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    429      * the new package failed because it contains a content provider with the
    430      * same authority as a provider already installed in the system.
    431      * @hide
    432      */
    433     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
    434 
    435     /**
    436      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    437      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    438      * the new package failed because the current SDK version is newer than
    439      * that required by the package.
    440      * @hide
    441      */
    442     public static final int INSTALL_FAILED_NEWER_SDK = -14;
    443 
    444     /**
    445      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    446      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    447      * the new package failed because it has specified that it is a test-only
    448      * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
    449      * flag.
    450      * @hide
    451      */
    452     public static final int INSTALL_FAILED_TEST_ONLY = -15;
    453 
    454     /**
    455      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    456      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    457      * the package being installed contains native code, but none that is
    458      * compatible with the the device's CPU_ABI.
    459      * @hide
    460      */
    461     public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
    462 
    463     /**
    464      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    465      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    466      * the new package uses a feature that is not available.
    467      * @hide
    468      */
    469     public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
    470 
    471     // ------ Errors related to sdcard
    472     /**
    473      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    474      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    475      * a secure container mount point couldn't be accessed on external media.
    476      * @hide
    477      */
    478     public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
    479 
    480     /**
    481      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    482      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    483      * the new package couldn't be installed in the specified install
    484      * location.
    485      * @hide
    486      */
    487     public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
    488 
    489     /**
    490      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    491      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    492      * the new package couldn't be installed in the specified install
    493      * location because the media is not available.
    494      * @hide
    495      */
    496     public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
    497 
    498     /**
    499      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    500      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    501      * the new package couldn't be installed because the verification timed out.
    502      * @hide
    503      */
    504     public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
    505 
    506     /**
    507      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    508      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    509      * the new package couldn't be installed because the verification did not succeed.
    510      * @hide
    511      */
    512     public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
    513 
    514     /**
    515      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    516      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    517      * the package changed from what the calling program expected.
    518      * @hide
    519      */
    520     public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
    521 
    522     /**
    523      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    524      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    525      * the new package is assigned a different UID than it previously held.
    526      * @hide
    527      */
    528     public static final int INSTALL_FAILED_UID_CHANGED = -24;
    529 
    530     /**
    531      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    532      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    533      * if the parser was given a path that is not a file, or does not end with the expected
    534      * '.apk' extension.
    535      * @hide
    536      */
    537     public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
    538 
    539     /**
    540      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    541      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    542      * if the parser was unable to retrieve the AndroidManifest.xml file.
    543      * @hide
    544      */
    545     public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
    546 
    547     /**
    548      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    549      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    550      * if the parser encountered an unexpected exception.
    551      * @hide
    552      */
    553     public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
    554 
    555     /**
    556      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    557      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    558      * if the parser did not find any certificates in the .apk.
    559      * @hide
    560      */
    561     public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
    562 
    563     /**
    564      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    565      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    566      * if the parser found inconsistent certificates on the files in the .apk.
    567      * @hide
    568      */
    569     public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
    570 
    571     /**
    572      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    573      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    574      * if the parser encountered a CertificateEncodingException in one of the
    575      * files in the .apk.
    576      * @hide
    577      */
    578     public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
    579 
    580     /**
    581      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    582      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    583      * if the parser encountered a bad or missing package name in the manifest.
    584      * @hide
    585      */
    586     public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
    587 
    588     /**
    589      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    590      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    591      * if the parser encountered a bad shared user id name in the manifest.
    592      * @hide
    593      */
    594     public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
    595 
    596     /**
    597      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    598      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    599      * if the parser encountered some structural problem in the manifest.
    600      * @hide
    601      */
    602     public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
    603 
    604     /**
    605      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    606      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    607      * if the parser did not find any actionable tags (instrumentation or application)
    608      * in the manifest.
    609      * @hide
    610      */
    611     public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
    612 
    613     /**
    614      * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
    615      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    616      * if the system failed to install the package because of system issues.
    617      * @hide
    618      */
    619     public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
    620 
    621     /**
    622      * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
    623      * package's data directory.
    624      *
    625      * @hide
    626      */
    627     public static final int DONT_DELETE_DATA = 0x00000001;
    628 
    629     /**
    630      * Return code for when package deletion succeeds. This is passed to the
    631      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    632      * succeeded in deleting the package.
    633      *
    634      * @hide
    635      */
    636     public static final int DELETE_SUCCEEDED = 1;
    637 
    638     /**
    639      * Deletion failed return code: this is passed to the
    640      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    641      * failed to delete the package for an unspecified reason.
    642      *
    643      * @hide
    644      */
    645     public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
    646 
    647     /**
    648      * Deletion failed return code: this is passed to the
    649      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    650      * failed to delete the package because it is the active DevicePolicy
    651      * manager.
    652      *
    653      * @hide
    654      */
    655     public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
    656 
    657     /**
    658      * Return code that is passed to the {@link IPackageMoveObserver} by
    659      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
    660      * package has been successfully moved by the system.
    661      *
    662      * @hide
    663      */
    664     public static final int MOVE_SUCCEEDED = 1;
    665     /**
    666      * Error code that is passed to the {@link IPackageMoveObserver} by
    667      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    668      * when the package hasn't been successfully moved by the system
    669      * because of insufficient memory on specified media.
    670      * @hide
    671      */
    672     public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
    673 
    674     /**
    675      * Error code that is passed to the {@link IPackageMoveObserver} by
    676      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    677      * if the specified package doesn't exist.
    678      * @hide
    679      */
    680     public static final int MOVE_FAILED_DOESNT_EXIST = -2;
    681 
    682     /**
    683      * Error code that is passed to the {@link IPackageMoveObserver} by
    684      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    685      * if the specified package cannot be moved since its a system package.
    686      * @hide
    687      */
    688     public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
    689 
    690     /**
    691      * Error code that is passed to the {@link IPackageMoveObserver} by
    692      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    693      * if the specified package cannot be moved since its forward locked.
    694      * @hide
    695      */
    696     public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
    697 
    698     /**
    699      * Error code that is passed to the {@link IPackageMoveObserver} by
    700      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    701      * if the specified package cannot be moved to the specified location.
    702      * @hide
    703      */
    704     public static final int MOVE_FAILED_INVALID_LOCATION = -5;
    705 
    706     /**
    707      * Error code that is passed to the {@link IPackageMoveObserver} by
    708      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    709      * if the specified package cannot be moved to the specified location.
    710      * @hide
    711      */
    712     public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
    713 
    714     /**
    715      * Error code that is passed to the {@link IPackageMoveObserver} by
    716      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
    717      * specified package already has an operation pending in the
    718      * {@link PackageHandler} queue.
    719      *
    720      * @hide
    721      */
    722     public static final int MOVE_FAILED_OPERATION_PENDING = -7;
    723 
    724     /**
    725      * Flag parameter for {@link #movePackage} to indicate that
    726      * the package should be moved to internal storage if its
    727      * been installed on external media.
    728      * @hide
    729      */
    730     public static final int MOVE_INTERNAL = 0x00000001;
    731 
    732     /**
    733      * Flag parameter for {@link #movePackage} to indicate that
    734      * the package should be moved to external media.
    735      * @hide
    736      */
    737     public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
    738 
    739     /**
    740      * Usable by the required verifier as the {@code verificationCode} argument
    741      * for {@link PackageManager#verifyPendingInstall} to indicate that it will
    742      * allow the installation to proceed without any of the optional verifiers
    743      * needing to vote.
    744      *
    745      * @hide
    746      */
    747     public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
    748 
    749     /**
    750      * Used as the {@code verificationCode} argument for
    751      * {@link PackageManager#verifyPendingInstall} to indicate that the calling
    752      * package verifier allows the installation to proceed.
    753      */
    754     public static final int VERIFICATION_ALLOW = 1;
    755 
    756     /**
    757      * Used as the {@code verificationCode} argument for
    758      * {@link PackageManager#verifyPendingInstall} to indicate the calling
    759      * package verifier does not vote to allow the installation to proceed.
    760      */
    761     public static final int VERIFICATION_REJECT = -1;
    762 
    763     /**
    764      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
    765      * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
    766      * lag in sound input or output.
    767      */
    768     @SdkConstant(SdkConstantType.FEATURE)
    769     public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
    770 
    771     /**
    772      * Feature for {@link #getSystemAvailableFeatures} and
    773      * {@link #hasSystemFeature}: The device is capable of communicating with
    774      * other devices via Bluetooth.
    775      */
    776     @SdkConstant(SdkConstantType.FEATURE)
    777     public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
    778 
    779     /**
    780      * Feature for {@link #getSystemAvailableFeatures} and
    781      * {@link #hasSystemFeature}: The device has a camera facing away
    782      * from the screen.
    783      */
    784     @SdkConstant(SdkConstantType.FEATURE)
    785     public static final String FEATURE_CAMERA = "android.hardware.camera";
    786 
    787     /**
    788      * Feature for {@link #getSystemAvailableFeatures} and
    789      * {@link #hasSystemFeature}: The device's camera supports auto-focus.
    790      */
    791     @SdkConstant(SdkConstantType.FEATURE)
    792     public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
    793 
    794     /**
    795      * Feature for {@link #getSystemAvailableFeatures} and
    796      * {@link #hasSystemFeature}: The device's camera supports flash.
    797      */
    798     @SdkConstant(SdkConstantType.FEATURE)
    799     public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
    800 
    801     /**
    802      * Feature for {@link #getSystemAvailableFeatures} and
    803      * {@link #hasSystemFeature}: The device has a front facing camera.
    804      */
    805     @SdkConstant(SdkConstantType.FEATURE)
    806     public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
    807 
    808     /**
    809      * Feature for {@link #getSystemAvailableFeatures} and
    810      * {@link #hasSystemFeature}: The device supports one or more methods of
    811      * reporting current location.
    812      */
    813     @SdkConstant(SdkConstantType.FEATURE)
    814     public static final String FEATURE_LOCATION = "android.hardware.location";
    815 
    816     /**
    817      * Feature for {@link #getSystemAvailableFeatures} and
    818      * {@link #hasSystemFeature}: The device has a Global Positioning System
    819      * receiver and can report precise location.
    820      */
    821     @SdkConstant(SdkConstantType.FEATURE)
    822     public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
    823 
    824     /**
    825      * Feature for {@link #getSystemAvailableFeatures} and
    826      * {@link #hasSystemFeature}: The device can report location with coarse
    827      * accuracy using a network-based geolocation system.
    828      */
    829     @SdkConstant(SdkConstantType.FEATURE)
    830     public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
    831 
    832     /**
    833      * Feature for {@link #getSystemAvailableFeatures} and
    834      * {@link #hasSystemFeature}: The device can record audio via a
    835      * microphone.
    836      */
    837     @SdkConstant(SdkConstantType.FEATURE)
    838     public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
    839 
    840     /**
    841      * Feature for {@link #getSystemAvailableFeatures} and
    842      * {@link #hasSystemFeature}: The device can communicate using Near-Field
    843      * Communications (NFC).
    844      */
    845     @SdkConstant(SdkConstantType.FEATURE)
    846     public static final String FEATURE_NFC = "android.hardware.nfc";
    847 
    848     /**
    849      * Feature for {@link #getSystemAvailableFeatures} and
    850      * {@link #hasSystemFeature}: The device includes an accelerometer.
    851      */
    852     @SdkConstant(SdkConstantType.FEATURE)
    853     public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
    854 
    855     /**
    856      * Feature for {@link #getSystemAvailableFeatures} and
    857      * {@link #hasSystemFeature}: The device includes a barometer (air
    858      * pressure sensor.)
    859      */
    860     @SdkConstant(SdkConstantType.FEATURE)
    861     public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
    862 
    863     /**
    864      * Feature for {@link #getSystemAvailableFeatures} and
    865      * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
    866      */
    867     @SdkConstant(SdkConstantType.FEATURE)
    868     public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
    869 
    870     /**
    871      * Feature for {@link #getSystemAvailableFeatures} and
    872      * {@link #hasSystemFeature}: The device includes a gyroscope.
    873      */
    874     @SdkConstant(SdkConstantType.FEATURE)
    875     public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
    876 
    877     /**
    878      * Feature for {@link #getSystemAvailableFeatures} and
    879      * {@link #hasSystemFeature}: The device includes a light sensor.
    880      */
    881     @SdkConstant(SdkConstantType.FEATURE)
    882     public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
    883 
    884     /**
    885      * Feature for {@link #getSystemAvailableFeatures} and
    886      * {@link #hasSystemFeature}: The device includes a proximity sensor.
    887      */
    888     @SdkConstant(SdkConstantType.FEATURE)
    889     public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
    890 
    891     /**
    892      * Feature for {@link #getSystemAvailableFeatures} and
    893      * {@link #hasSystemFeature}: The device has a telephony radio with data
    894      * communication support.
    895      */
    896     @SdkConstant(SdkConstantType.FEATURE)
    897     public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
    898 
    899     /**
    900      * Feature for {@link #getSystemAvailableFeatures} and
    901      * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
    902      */
    903     @SdkConstant(SdkConstantType.FEATURE)
    904     public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
    905 
    906     /**
    907      * Feature for {@link #getSystemAvailableFeatures} and
    908      * {@link #hasSystemFeature}: The device has a GSM telephony stack.
    909      */
    910     @SdkConstant(SdkConstantType.FEATURE)
    911     public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
    912 
    913     /**
    914      * Feature for {@link #getSystemAvailableFeatures} and
    915      * {@link #hasSystemFeature}: The device supports connecting to USB devices
    916      * as the USB host.
    917      */
    918     @SdkConstant(SdkConstantType.FEATURE)
    919     public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
    920 
    921     /**
    922      * Feature for {@link #getSystemAvailableFeatures} and
    923      * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
    924      */
    925     @SdkConstant(SdkConstantType.FEATURE)
    926     public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
    927 
    928     /**
    929      * Feature for {@link #getSystemAvailableFeatures} and
    930      * {@link #hasSystemFeature}: The SIP API is enabled on the device.
    931      */
    932     @SdkConstant(SdkConstantType.FEATURE)
    933     public static final String FEATURE_SIP = "android.software.sip";
    934 
    935     /**
    936      * Feature for {@link #getSystemAvailableFeatures} and
    937      * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
    938      */
    939     @SdkConstant(SdkConstantType.FEATURE)
    940     public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
    941 
    942     /**
    943      * Feature for {@link #getSystemAvailableFeatures} and
    944      * {@link #hasSystemFeature}: The device's display has a touch screen.
    945      */
    946     @SdkConstant(SdkConstantType.FEATURE)
    947     public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
    948 
    949 
    950     /**
    951      * Feature for {@link #getSystemAvailableFeatures} and
    952      * {@link #hasSystemFeature}: The device's touch screen supports
    953      * multitouch sufficient for basic two-finger gesture detection.
    954      */
    955     @SdkConstant(SdkConstantType.FEATURE)
    956     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
    957 
    958     /**
    959      * Feature for {@link #getSystemAvailableFeatures} and
    960      * {@link #hasSystemFeature}: The device's touch screen is capable of
    961      * tracking two or more fingers fully independently.
    962      */
    963     @SdkConstant(SdkConstantType.FEATURE)
    964     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
    965 
    966     /**
    967      * Feature for {@link #getSystemAvailableFeatures} and
    968      * {@link #hasSystemFeature}: The device's touch screen is capable of
    969      * tracking a full hand of fingers fully independently -- that is, 5 or
    970      * more simultaneous independent pointers.
    971      */
    972     @SdkConstant(SdkConstantType.FEATURE)
    973     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
    974 
    975     /**
    976      * Feature for {@link #getSystemAvailableFeatures} and
    977      * {@link #hasSystemFeature}: The device does not have a touch screen, but
    978      * does support touch emulation for basic events. For instance, the
    979      * device might use a mouse or remote control to drive a cursor, and
    980      * emulate basic touch pointer events like down, up, drag, etc. All
    981      * devices that support android.hardware.touchscreen or a sub-feature are
    982      * presumed to also support faketouch.
    983      */
    984     @SdkConstant(SdkConstantType.FEATURE)
    985     public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
    986 
    987     /**
    988      * Feature for {@link #getSystemAvailableFeatures} and
    989      * {@link #hasSystemFeature}: The device does not have a touch screen, but
    990      * does support touch emulation for basic events that supports distinct
    991      * tracking of two or more fingers.  This is an extension of
    992      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
    993      * that unlike a distinct multitouch screen as defined by
    994      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
    995      * devices will not actually provide full two-finger gestures since the
    996      * input is being transformed to cursor movement on the screen.  That is,
    997      * single finger gestures will move a cursor; two-finger swipes will
    998      * result in single-finger touch events; other two-finger gestures will
    999      * result in the corresponding two-finger touch event.
   1000      */
   1001     @SdkConstant(SdkConstantType.FEATURE)
   1002     public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
   1003 
   1004     /**
   1005      * Feature for {@link #getSystemAvailableFeatures} and
   1006      * {@link #hasSystemFeature}: The device does not have a touch screen, but
   1007      * does support touch emulation for basic events that supports tracking
   1008      * a hand of fingers (5 or more fingers) fully independently.
   1009      * This is an extension of
   1010      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
   1011      * that unlike a multitouch screen as defined by
   1012      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
   1013      * gestures can be detected due to the limitations described for
   1014      * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
   1015      */
   1016     @SdkConstant(SdkConstantType.FEATURE)
   1017     public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
   1018 
   1019     /**
   1020      * Feature for {@link #getSystemAvailableFeatures} and
   1021      * {@link #hasSystemFeature}: The device supports portrait orientation
   1022      * screens.  For backwards compatibility, you can assume that if neither
   1023      * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
   1024      * both portrait and landscape.
   1025      */
   1026     @SdkConstant(SdkConstantType.FEATURE)
   1027     public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
   1028 
   1029     /**
   1030      * Feature for {@link #getSystemAvailableFeatures} and
   1031      * {@link #hasSystemFeature}: The device supports landscape orientation
   1032      * screens.  For backwards compatibility, you can assume that if neither
   1033      * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
   1034      * both portrait and landscape.
   1035      */
   1036     @SdkConstant(SdkConstantType.FEATURE)
   1037     public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
   1038 
   1039     /**
   1040      * Feature for {@link #getSystemAvailableFeatures} and
   1041      * {@link #hasSystemFeature}: The device supports live wallpapers.
   1042      */
   1043     @SdkConstant(SdkConstantType.FEATURE)
   1044     public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
   1045 
   1046     /**
   1047      * Feature for {@link #getSystemAvailableFeatures} and
   1048      * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
   1049      */
   1050     @SdkConstant(SdkConstantType.FEATURE)
   1051     public static final String FEATURE_WIFI = "android.hardware.wifi";
   1052 
   1053     /**
   1054      * Feature for {@link #getSystemAvailableFeatures} and
   1055      * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
   1056      */
   1057     @SdkConstant(SdkConstantType.FEATURE)
   1058     public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
   1059 
   1060     /**
   1061      * Feature for {@link #getSystemAvailableFeatures} and
   1062      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
   1063      * on a television.  Television here is defined to be a typical living
   1064      * room television experience: displayed on a big screen, where the user
   1065      * is sitting far away from it, and the dominant form of input will be
   1066      * something like a DPAD, not through touch or mouse.
   1067      */
   1068     @SdkConstant(SdkConstantType.FEATURE)
   1069     public static final String FEATURE_TELEVISION = "android.hardware.type.television";
   1070 
   1071     /**
   1072      * Action to external storage service to clean out removed apps.
   1073      * @hide
   1074      */
   1075     public static final String ACTION_CLEAN_EXTERNAL_STORAGE
   1076             = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
   1077 
   1078     /**
   1079      * Extra field name for the URI to a verification file. Passed to a package
   1080      * verifier.
   1081      *
   1082      * @hide
   1083      */
   1084     public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
   1085 
   1086     /**
   1087      * Extra field name for the ID of a package pending verification. Passed to
   1088      * a package verifier and is used to call back to
   1089      * {@link PackageManager#verifyPendingInstall(int, int)}
   1090      */
   1091     public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
   1092 
   1093     /**
   1094      * Extra field name for the package identifier which is trying to install
   1095      * the package.
   1096      *
   1097      * @hide
   1098      */
   1099     public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
   1100             = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
   1101 
   1102     /**
   1103      * Extra field name for the requested install flags for a package pending
   1104      * verification. Passed to a package verifier.
   1105      *
   1106      * @hide
   1107      */
   1108     public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
   1109             = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
   1110 
   1111     /**
   1112      * Retrieve overall information about an application package that is
   1113      * installed on the system.
   1114      * <p>
   1115      * Throws {@link NameNotFoundException} if a package with the given name can
   1116      * not be found on the system.
   1117      *
   1118      * @param packageName The full name (i.e. com.google.apps.contacts) of the
   1119      *            desired package.
   1120      * @param flags Additional option flags. Use any combination of
   1121      *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
   1122      *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
   1123      *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
   1124      *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
   1125      *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
   1126      *            modify the data returned.
   1127      * @return Returns a PackageInfo object containing information about the
   1128      *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
   1129      *         package is not found in the list of installed applications, the
   1130      *         package information is retrieved from the list of uninstalled
   1131      *         applications(which includes installed applications as well as
   1132      *         applications with data directory ie applications which had been
   1133      *         deleted with DONT_DELTE_DATA flag set).
   1134      * @see #GET_ACTIVITIES
   1135      * @see #GET_GIDS
   1136      * @see #GET_CONFIGURATIONS
   1137      * @see #GET_INSTRUMENTATION
   1138      * @see #GET_PERMISSIONS
   1139      * @see #GET_PROVIDERS
   1140      * @see #GET_RECEIVERS
   1141      * @see #GET_SERVICES
   1142      * @see #GET_SIGNATURES
   1143      * @see #GET_UNINSTALLED_PACKAGES
   1144      */
   1145     public abstract PackageInfo getPackageInfo(String packageName, int flags)
   1146             throws NameNotFoundException;
   1147 
   1148     /**
   1149      * Map from the current package names in use on the device to whatever
   1150      * the current canonical name of that package is.
   1151      * @param names Array of current names to be mapped.
   1152      * @return Returns an array of the same size as the original, containing
   1153      * the canonical name for each package.
   1154      */
   1155     public abstract String[] currentToCanonicalPackageNames(String[] names);
   1156 
   1157     /**
   1158      * Map from a packages canonical name to the current name in use on the device.
   1159      * @param names Array of new names to be mapped.
   1160      * @return Returns an array of the same size as the original, containing
   1161      * the current name for each package.
   1162      */
   1163     public abstract String[] canonicalToCurrentPackageNames(String[] names);
   1164 
   1165     /**
   1166      * Return a "good" intent to launch a front-door activity in a package,
   1167      * for use for example to implement an "open" button when browsing through
   1168      * packages.  The current implementation will look first for a main
   1169      * activity in the category {@link Intent#CATEGORY_INFO}, next for a
   1170      * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
   1171      * null if neither are found.
   1172      *
   1173      * <p>Throws {@link NameNotFoundException} if a package with the given
   1174      * name can not be found on the system.
   1175      *
   1176      * @param packageName The name of the package to inspect.
   1177      *
   1178      * @return Returns either a fully-qualified Intent that can be used to
   1179      * launch the main activity in the package, or null if the package does
   1180      * not contain such an activity.
   1181      */
   1182     public abstract Intent getLaunchIntentForPackage(String packageName);
   1183 
   1184     /**
   1185      * Return an array of all of the secondary group-ids that have been
   1186      * assigned to a package.
   1187      *
   1188      * <p>Throws {@link NameNotFoundException} if a package with the given
   1189      * name can not be found on the system.
   1190      *
   1191      * @param packageName The full name (i.e. com.google.apps.contacts) of the
   1192      *                    desired package.
   1193      *
   1194      * @return Returns an int array of the assigned gids, or null if there
   1195      * are none.
   1196      */
   1197     public abstract int[] getPackageGids(String packageName)
   1198             throws NameNotFoundException;
   1199 
   1200     /**
   1201      * Retrieve all of the information we know about a particular permission.
   1202      *
   1203      * <p>Throws {@link NameNotFoundException} if a permission with the given
   1204      * name can not be found on the system.
   1205      *
   1206      * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
   1207      *             of the permission you are interested in.
   1208      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   1209      * retrieve any meta-data associated with the permission.
   1210      *
   1211      * @return Returns a {@link PermissionInfo} containing information about the
   1212      *         permission.
   1213      */
   1214     public abstract PermissionInfo getPermissionInfo(String name, int flags)
   1215             throws NameNotFoundException;
   1216 
   1217     /**
   1218      * Query for all of the permissions associated with a particular group.
   1219      *
   1220      * <p>Throws {@link NameNotFoundException} if the given group does not
   1221      * exist.
   1222      *
   1223      * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
   1224      *             of the permission group you are interested in.  Use null to
   1225      *             find all of the permissions not associated with a group.
   1226      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   1227      * retrieve any meta-data associated with the permissions.
   1228      *
   1229      * @return Returns a list of {@link PermissionInfo} containing information
   1230      * about all of the permissions in the given group.
   1231      */
   1232     public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
   1233             int flags) throws NameNotFoundException;
   1234 
   1235     /**
   1236      * Retrieve all of the information we know about a particular group of
   1237      * permissions.
   1238      *
   1239      * <p>Throws {@link NameNotFoundException} if a permission group with the given
   1240      * name can not be found on the system.
   1241      *
   1242      * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
   1243      *             of the permission you are interested in.
   1244      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   1245      * retrieve any meta-data associated with the permission group.
   1246      *
   1247      * @return Returns a {@link PermissionGroupInfo} containing information
   1248      * about the permission.
   1249      */
   1250     public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
   1251             int flags) throws NameNotFoundException;
   1252 
   1253     /**
   1254      * Retrieve all of the known permission groups in the system.
   1255      *
   1256      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   1257      * retrieve any meta-data associated with the permission group.
   1258      *
   1259      * @return Returns a list of {@link PermissionGroupInfo} containing
   1260      * information about all of the known permission groups.
   1261      */
   1262     public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
   1263 
   1264     /**
   1265      * Retrieve all of the information we know about a particular
   1266      * package/application.
   1267      *
   1268      * <p>Throws {@link NameNotFoundException} if an application with the given
   1269      * package name can not be found on the system.
   1270      *
   1271      * @param packageName The full name (i.e. com.google.apps.contacts) of an
   1272      *                    application.
   1273      * @param flags Additional option flags. Use any combination of
   1274      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1275      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   1276      *
   1277      * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
   1278      *         information about the package.
   1279      *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
   1280      *         found in the list of installed applications,
   1281      *         the application information is retrieved from the
   1282      *         list of uninstalled applications(which includes
   1283      *         installed applications as well as applications
   1284      *         with data directory ie applications which had been
   1285      *         deleted with DONT_DELTE_DATA flag set).
   1286      *
   1287      * @see #GET_META_DATA
   1288      * @see #GET_SHARED_LIBRARY_FILES
   1289      * @see #GET_UNINSTALLED_PACKAGES
   1290      */
   1291     public abstract ApplicationInfo getApplicationInfo(String packageName,
   1292             int flags) throws NameNotFoundException;
   1293 
   1294     /**
   1295      * Retrieve all of the information we know about a particular activity
   1296      * class.
   1297      *
   1298      * <p>Throws {@link NameNotFoundException} if an activity with the given
   1299      * class name can not be found on the system.
   1300      *
   1301      * @param component The full component name (i.e.
   1302      * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
   1303      * class.
   1304      * @param flags Additional option flags. Use any combination of
   1305      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1306      * to modify the data (in ApplicationInfo) returned.
   1307      *
   1308      * @return {@link ActivityInfo} containing information about the activity.
   1309      *
   1310      * @see #GET_INTENT_FILTERS
   1311      * @see #GET_META_DATA
   1312      * @see #GET_SHARED_LIBRARY_FILES
   1313      */
   1314     public abstract ActivityInfo getActivityInfo(ComponentName component,
   1315             int flags) throws NameNotFoundException;
   1316 
   1317     /**
   1318      * Retrieve all of the information we know about a particular receiver
   1319      * class.
   1320      *
   1321      * <p>Throws {@link NameNotFoundException} if a receiver with the given
   1322      * class name can not be found on the system.
   1323      *
   1324      * @param component The full component name (i.e.
   1325      * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
   1326      * class.
   1327      * @param flags Additional option flags.  Use any combination of
   1328      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1329      * to modify the data returned.
   1330      *
   1331      * @return {@link ActivityInfo} containing information about the receiver.
   1332      *
   1333      * @see #GET_INTENT_FILTERS
   1334      * @see #GET_META_DATA
   1335      * @see #GET_SHARED_LIBRARY_FILES
   1336      */
   1337     public abstract ActivityInfo getReceiverInfo(ComponentName component,
   1338             int flags) throws NameNotFoundException;
   1339 
   1340     /**
   1341      * Retrieve all of the information we know about a particular service
   1342      * class.
   1343      *
   1344      * <p>Throws {@link NameNotFoundException} if a service with the given
   1345      * class name can not be found on the system.
   1346      *
   1347      * @param component The full component name (i.e.
   1348      * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
   1349      * class.
   1350      * @param flags Additional option flags.  Use any combination of
   1351      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1352      * to modify the data returned.
   1353      *
   1354      * @return ServiceInfo containing information about the service.
   1355      *
   1356      * @see #GET_META_DATA
   1357      * @see #GET_SHARED_LIBRARY_FILES
   1358      */
   1359     public abstract ServiceInfo getServiceInfo(ComponentName component,
   1360             int flags) throws NameNotFoundException;
   1361 
   1362     /**
   1363      * Retrieve all of the information we know about a particular content
   1364      * provider class.
   1365      *
   1366      * <p>Throws {@link NameNotFoundException} if a provider with the given
   1367      * class name can not be found on the system.
   1368      *
   1369      * @param component The full component name (i.e.
   1370      * com.google.providers.media/com.google.providers.media.MediaProvider) of a
   1371      * ContentProvider class.
   1372      * @param flags Additional option flags.  Use any combination of
   1373      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1374      * to modify the data returned.
   1375      *
   1376      * @return ProviderInfo containing information about the service.
   1377      *
   1378      * @see #GET_META_DATA
   1379      * @see #GET_SHARED_LIBRARY_FILES
   1380      */
   1381     public abstract ProviderInfo getProviderInfo(ComponentName component,
   1382             int flags) throws NameNotFoundException;
   1383 
   1384     /**
   1385      * Return a List of all packages that are installed
   1386      * on the device.
   1387      *
   1388      * @param flags Additional option flags. Use any combination of
   1389      * {@link #GET_ACTIVITIES},
   1390      * {@link #GET_GIDS},
   1391      * {@link #GET_CONFIGURATIONS},
   1392      * {@link #GET_INSTRUMENTATION},
   1393      * {@link #GET_PERMISSIONS},
   1394      * {@link #GET_PROVIDERS},
   1395      * {@link #GET_RECEIVERS},
   1396      * {@link #GET_SERVICES},
   1397      * {@link #GET_SIGNATURES},
   1398      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   1399      *
   1400      * @return A List of PackageInfo objects, one for each package that is
   1401      *         installed on the device.  In the unlikely case of there being no
   1402      *         installed packages, an empty list is returned.
   1403      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
   1404      *         applications including those deleted with DONT_DELETE_DATA
   1405      *         (partially installed apps with data directory) will be returned.
   1406      *
   1407      * @see #GET_ACTIVITIES
   1408      * @see #GET_GIDS
   1409      * @see #GET_CONFIGURATIONS
   1410      * @see #GET_INSTRUMENTATION
   1411      * @see #GET_PERMISSIONS
   1412      * @see #GET_PROVIDERS
   1413      * @see #GET_RECEIVERS
   1414      * @see #GET_SERVICES
   1415      * @see #GET_SIGNATURES
   1416      * @see #GET_UNINSTALLED_PACKAGES
   1417      *
   1418      */
   1419     public abstract List<PackageInfo> getInstalledPackages(int flags);
   1420 
   1421     /**
   1422      * Check whether a particular package has been granted a particular
   1423      * permission.
   1424      *
   1425      * @param permName The name of the permission you are checking for,
   1426      * @param pkgName The name of the package you are checking against.
   1427      *
   1428      * @return If the package has the permission, PERMISSION_GRANTED is
   1429      * returned.  If it does not have the permission, PERMISSION_DENIED
   1430      * is returned.
   1431      *
   1432      * @see #PERMISSION_GRANTED
   1433      * @see #PERMISSION_DENIED
   1434      */
   1435     public abstract int checkPermission(String permName, String pkgName);
   1436 
   1437     /**
   1438      * Add a new dynamic permission to the system.  For this to work, your
   1439      * package must have defined a permission tree through the
   1440      * {@link android.R.styleable#AndroidManifestPermissionTree
   1441      * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
   1442      * permissions to trees that were defined by either its own package or
   1443      * another with the same user id; a permission is in a tree if it
   1444      * matches the name of the permission tree + ".": for example,
   1445      * "com.foo.bar" is a member of the permission tree "com.foo".
   1446      *
   1447      * <p>It is good to make your permission tree name descriptive, because you
   1448      * are taking possession of that entire set of permission names.  Thus, it
   1449      * must be under a domain you control, with a suffix that will not match
   1450      * any normal permissions that may be declared in any applications that
   1451      * are part of that domain.
   1452      *
   1453      * <p>New permissions must be added before
   1454      * any .apks are installed that use those permissions.  Permissions you
   1455      * add through this method are remembered across reboots of the device.
   1456      * If the given permission already exists, the info you supply here
   1457      * will be used to update it.
   1458      *
   1459      * @param info Description of the permission to be added.
   1460      *
   1461      * @return Returns true if a new permission was created, false if an
   1462      * existing one was updated.
   1463      *
   1464      * @throws SecurityException if you are not allowed to add the
   1465      * given permission name.
   1466      *
   1467      * @see #removePermission(String)
   1468      */
   1469     public abstract boolean addPermission(PermissionInfo info);
   1470 
   1471     /**
   1472      * Like {@link #addPermission(PermissionInfo)} but asynchronously
   1473      * persists the package manager state after returning from the call,
   1474      * allowing it to return quicker and batch a series of adds at the
   1475      * expense of no guarantee the added permission will be retained if
   1476      * the device is rebooted before it is written.
   1477      */
   1478     public abstract boolean addPermissionAsync(PermissionInfo info);
   1479 
   1480     /**
   1481      * Removes a permission that was previously added with
   1482      * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
   1483      * -- you are only allowed to remove permissions that you are allowed
   1484      * to add.
   1485      *
   1486      * @param name The name of the permission to remove.
   1487      *
   1488      * @throws SecurityException if you are not allowed to remove the
   1489      * given permission name.
   1490      *
   1491      * @see #addPermission(PermissionInfo)
   1492      */
   1493     public abstract void removePermission(String name);
   1494 
   1495     /**
   1496      * Grant a permission to an application which the application does not
   1497      * already have.  The permission must have been requested by the application,
   1498      * but as an optional permission.  If the application is not allowed to
   1499      * hold the permission, a SecurityException is thrown.
   1500      * @hide
   1501      *
   1502      * @param packageName The name of the package that the permission will be
   1503      * granted to.
   1504      * @param permissionName The name of the permission.
   1505      */
   1506     public abstract void grantPermission(String packageName, String permissionName);
   1507 
   1508     /**
   1509      * Revoke a permission that was previously granted by {@link #grantPermission}.
   1510      * @hide
   1511      *
   1512      * @param packageName The name of the package that the permission will be
   1513      * granted to.
   1514      * @param permissionName The name of the permission.
   1515      */
   1516     public abstract void revokePermission(String packageName, String permissionName);
   1517 
   1518     /**
   1519      * Compare the signatures of two packages to determine if the same
   1520      * signature appears in both of them.  If they do contain the same
   1521      * signature, then they are allowed special privileges when working
   1522      * with each other: they can share the same user-id, run instrumentation
   1523      * against each other, etc.
   1524      *
   1525      * @param pkg1 First package name whose signature will be compared.
   1526      * @param pkg2 Second package name whose signature will be compared.
   1527      *
   1528      * @return Returns an integer indicating whether all signatures on the
   1529      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
   1530      * all signatures match or < 0 if there is not a match ({@link
   1531      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
   1532      *
   1533      * @see #checkSignatures(int, int)
   1534      * @see #SIGNATURE_MATCH
   1535      * @see #SIGNATURE_NO_MATCH
   1536      * @see #SIGNATURE_UNKNOWN_PACKAGE
   1537      */
   1538     public abstract int checkSignatures(String pkg1, String pkg2);
   1539 
   1540     /**
   1541      * Like {@link #checkSignatures(String, String)}, but takes UIDs of
   1542      * the two packages to be checked.  This can be useful, for example,
   1543      * when doing the check in an IPC, where the UID is the only identity
   1544      * available.  It is functionally identical to determining the package
   1545      * associated with the UIDs and checking their signatures.
   1546      *
   1547      * @param uid1 First UID whose signature will be compared.
   1548      * @param uid2 Second UID whose signature will be compared.
   1549      *
   1550      * @return Returns an integer indicating whether all signatures on the
   1551      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
   1552      * all signatures match or < 0 if there is not a match ({@link
   1553      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
   1554      *
   1555      * @see #checkSignatures(String, String)
   1556      * @see #SIGNATURE_MATCH
   1557      * @see #SIGNATURE_NO_MATCH
   1558      * @see #SIGNATURE_UNKNOWN_PACKAGE
   1559      */
   1560     public abstract int checkSignatures(int uid1, int uid2);
   1561 
   1562     /**
   1563      * Retrieve the names of all packages that are associated with a particular
   1564      * user id.  In most cases, this will be a single package name, the package
   1565      * that has been assigned that user id.  Where there are multiple packages
   1566      * sharing the same user id through the "sharedUserId" mechanism, all
   1567      * packages with that id will be returned.
   1568      *
   1569      * @param uid The user id for which you would like to retrieve the
   1570      * associated packages.
   1571      *
   1572      * @return Returns an array of one or more packages assigned to the user
   1573      * id, or null if there are no known packages with the given id.
   1574      */
   1575     public abstract String[] getPackagesForUid(int uid);
   1576 
   1577     /**
   1578      * Retrieve the official name associated with a user id.  This name is
   1579      * guaranteed to never change, though it is possibly for the underlying
   1580      * user id to be changed.  That is, if you are storing information about
   1581      * user ids in persistent storage, you should use the string returned
   1582      * by this function instead of the raw user-id.
   1583      *
   1584      * @param uid The user id for which you would like to retrieve a name.
   1585      * @return Returns a unique name for the given user id, or null if the
   1586      * user id is not currently assigned.
   1587      */
   1588     public abstract String getNameForUid(int uid);
   1589 
   1590     /**
   1591      * Return the user id associated with a shared user name. Multiple
   1592      * applications can specify a shared user name in their manifest and thus
   1593      * end up using a common uid. This might be used for new applications
   1594      * that use an existing shared user name and need to know the uid of the
   1595      * shared user.
   1596      *
   1597      * @param sharedUserName The shared user name whose uid is to be retrieved.
   1598      * @return Returns the uid associated with the shared user, or  NameNotFoundException
   1599      * if the shared user name is not being used by any installed packages
   1600      * @hide
   1601      */
   1602     public abstract int getUidForSharedUser(String sharedUserName)
   1603             throws NameNotFoundException;
   1604 
   1605     /**
   1606      * Return a List of all application packages that are installed on the
   1607      * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
   1608      * applications including those deleted with DONT_DELETE_DATA(partially
   1609      * installed apps with data directory) will be returned.
   1610      *
   1611      * @param flags Additional option flags. Use any combination of
   1612      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1613      * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   1614      *
   1615      * @return A List of ApplicationInfo objects, one for each application that
   1616      *         is installed on the device.  In the unlikely case of there being
   1617      *         no installed applications, an empty list is returned.
   1618      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
   1619      *         applications including those deleted with DONT_DELETE_DATA
   1620      *         (partially installed apps with data directory) will be returned.
   1621      *
   1622      * @see #GET_META_DATA
   1623      * @see #GET_SHARED_LIBRARY_FILES
   1624      * @see #GET_UNINSTALLED_PACKAGES
   1625      */
   1626     public abstract List<ApplicationInfo> getInstalledApplications(int flags);
   1627 
   1628     /**
   1629      * Get a list of shared libraries that are available on the
   1630      * system.
   1631      *
   1632      * @return An array of shared library names that are
   1633      * available on the system, or null if none are installed.
   1634      *
   1635      */
   1636     public abstract String[] getSystemSharedLibraryNames();
   1637 
   1638     /**
   1639      * Get a list of features that are available on the
   1640      * system.
   1641      *
   1642      * @return An array of FeatureInfo classes describing the features
   1643      * that are available on the system, or null if there are none(!!).
   1644      */
   1645     public abstract FeatureInfo[] getSystemAvailableFeatures();
   1646 
   1647     /**
   1648      * Check whether the given feature name is one of the available
   1649      * features as returned by {@link #getSystemAvailableFeatures()}.
   1650      *
   1651      * @return Returns true if the devices supports the feature, else
   1652      * false.
   1653      */
   1654     public abstract boolean hasSystemFeature(String name);
   1655 
   1656     /**
   1657      * Determine the best action to perform for a given Intent.  This is how
   1658      * {@link Intent#resolveActivity} finds an activity if a class has not
   1659      * been explicitly specified.
   1660      *
   1661      * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
   1662      * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
   1663      * only flag.  You need to do so to resolve the activity in the same way
   1664      * that {@link android.content.Context#startActivity(Intent)} and
   1665      * {@link android.content.Intent#resolveActivity(PackageManager)
   1666      * Intent.resolveActivity(PackageManager)} do.</p>
   1667      *
   1668      * @param intent An intent containing all of the desired specification
   1669      *               (action, data, type, category, and/or component).
   1670      * @param flags Additional option flags.  The most important is
   1671      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   1672      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   1673      *
   1674      * @return Returns a ResolveInfo containing the final activity intent that
   1675      *         was determined to be the best action.  Returns null if no
   1676      *         matching activity was found. If multiple matching activities are
   1677      *         found and there is no default set, returns a ResolveInfo
   1678      *         containing something else, such as the activity resolver.
   1679      *
   1680      * @see #MATCH_DEFAULT_ONLY
   1681      * @see #GET_INTENT_FILTERS
   1682      * @see #GET_RESOLVED_FILTER
   1683      */
   1684     public abstract ResolveInfo resolveActivity(Intent intent, int flags);
   1685 
   1686     /**
   1687      * Retrieve all activities that can be performed for the given intent.
   1688      *
   1689      * @param intent The desired intent as per resolveActivity().
   1690      * @param flags Additional option flags.  The most important is
   1691      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   1692      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   1693      *
   1694      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   1695      *         Activity. These are ordered from best to worst match -- that
   1696      *         is, the first item in the list is what is returned by
   1697      *         {@link #resolveActivity}.  If there are no matching activities, an empty
   1698      *         list is returned.
   1699      *
   1700      * @see #MATCH_DEFAULT_ONLY
   1701      * @see #GET_INTENT_FILTERS
   1702      * @see #GET_RESOLVED_FILTER
   1703      */
   1704     public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
   1705             int flags);
   1706 
   1707     /**
   1708      * Retrieve a set of activities that should be presented to the user as
   1709      * similar options.  This is like {@link #queryIntentActivities}, except it
   1710      * also allows you to supply a list of more explicit Intents that you would
   1711      * like to resolve to particular options, and takes care of returning the
   1712      * final ResolveInfo list in a reasonable order, with no duplicates, based
   1713      * on those inputs.
   1714      *
   1715      * @param caller The class name of the activity that is making the
   1716      *               request.  This activity will never appear in the output
   1717      *               list.  Can be null.
   1718      * @param specifics An array of Intents that should be resolved to the
   1719      *                  first specific results.  Can be null.
   1720      * @param intent The desired intent as per resolveActivity().
   1721      * @param flags Additional option flags.  The most important is
   1722      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   1723      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   1724      *
   1725      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   1726      *         Activity. These are ordered first by all of the intents resolved
   1727      *         in <var>specifics</var> and then any additional activities that
   1728      *         can handle <var>intent</var> but did not get included by one of
   1729      *         the <var>specifics</var> intents.  If there are no matching
   1730      *         activities, an empty list is returned.
   1731      *
   1732      * @see #MATCH_DEFAULT_ONLY
   1733      * @see #GET_INTENT_FILTERS
   1734      * @see #GET_RESOLVED_FILTER
   1735      */
   1736     public abstract List<ResolveInfo> queryIntentActivityOptions(
   1737             ComponentName caller, Intent[] specifics, Intent intent, int flags);
   1738 
   1739     /**
   1740      * Retrieve all receivers that can handle a broadcast of the given intent.
   1741      *
   1742      * @param intent The desired intent as per resolveActivity().
   1743      * @param flags Additional option flags.
   1744      *
   1745      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   1746      *         Receiver. These are ordered from first to last in priority.  If
   1747      *         there are no matching receivers, an empty list is returned.
   1748      *
   1749      * @see #MATCH_DEFAULT_ONLY
   1750      * @see #GET_INTENT_FILTERS
   1751      * @see #GET_RESOLVED_FILTER
   1752      */
   1753     public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
   1754             int flags);
   1755 
   1756     /**
   1757      * Determine the best service to handle for a given Intent.
   1758      *
   1759      * @param intent An intent containing all of the desired specification
   1760      *               (action, data, type, category, and/or component).
   1761      * @param flags Additional option flags.
   1762      *
   1763      * @return Returns a ResolveInfo containing the final service intent that
   1764      *         was determined to be the best action.  Returns null if no
   1765      *         matching service was found.
   1766      *
   1767      * @see #GET_INTENT_FILTERS
   1768      * @see #GET_RESOLVED_FILTER
   1769      */
   1770     public abstract ResolveInfo resolveService(Intent intent, int flags);
   1771 
   1772     /**
   1773      * Retrieve all services that can match the given intent.
   1774      *
   1775      * @param intent The desired intent as per resolveService().
   1776      * @param flags Additional option flags.
   1777      *
   1778      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   1779      *         ServiceInfo. These are ordered from best to worst match -- that
   1780      *         is, the first item in the list is what is returned by
   1781      *         resolveService().  If there are no matching services, an empty
   1782      *         list is returned.
   1783      *
   1784      * @see #GET_INTENT_FILTERS
   1785      * @see #GET_RESOLVED_FILTER
   1786      */
   1787     public abstract List<ResolveInfo> queryIntentServices(Intent intent,
   1788             int flags);
   1789 
   1790     /**
   1791      * Find a single content provider by its base path name.
   1792      *
   1793      * @param name The name of the provider to find.
   1794      * @param flags Additional option flags.  Currently should always be 0.
   1795      *
   1796      * @return ContentProviderInfo Information about the provider, if found,
   1797      *         else null.
   1798      */
   1799     public abstract ProviderInfo resolveContentProvider(String name,
   1800             int flags);
   1801 
   1802     /**
   1803      * Retrieve content provider information.
   1804      *
   1805      * <p><em>Note: unlike most other methods, an empty result set is indicated
   1806      * by a null return instead of an empty list.</em>
   1807      *
   1808      * @param processName If non-null, limits the returned providers to only
   1809      *                    those that are hosted by the given process.  If null,
   1810      *                    all content providers are returned.
   1811      * @param uid If <var>processName</var> is non-null, this is the required
   1812      *        uid owning the requested content providers.
   1813      * @param flags Additional option flags.  Currently should always be 0.
   1814      *
   1815      * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
   1816      *         content provider either patching <var>processName</var> or, if
   1817      *         <var>processName</var> is null, all known content providers.
   1818      *         <em>If there are no matching providers, null is returned.</em>
   1819      */
   1820     public abstract List<ProviderInfo> queryContentProviders(
   1821             String processName, int uid, int flags);
   1822 
   1823     /**
   1824      * Retrieve all of the information we know about a particular
   1825      * instrumentation class.
   1826      *
   1827      * <p>Throws {@link NameNotFoundException} if instrumentation with the
   1828      * given class name can not be found on the system.
   1829      *
   1830      * @param className The full name (i.e.
   1831      *                  com.google.apps.contacts.InstrumentList) of an
   1832      *                  Instrumentation class.
   1833      * @param flags Additional option flags.  Currently should always be 0.
   1834      *
   1835      * @return InstrumentationInfo containing information about the
   1836      *         instrumentation.
   1837      */
   1838     public abstract InstrumentationInfo getInstrumentationInfo(
   1839             ComponentName className, int flags) throws NameNotFoundException;
   1840 
   1841     /**
   1842      * Retrieve information about available instrumentation code.  May be used
   1843      * to retrieve either all instrumentation code, or only the code targeting
   1844      * a particular package.
   1845      *
   1846      * @param targetPackage If null, all instrumentation is returned; only the
   1847      *                      instrumentation targeting this package name is
   1848      *                      returned.
   1849      * @param flags Additional option flags.  Currently should always be 0.
   1850      *
   1851      * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
   1852      *         matching available Instrumentation.  Returns an empty list if
   1853      *         there is no instrumentation available for the given package.
   1854      */
   1855     public abstract List<InstrumentationInfo> queryInstrumentation(
   1856             String targetPackage, int flags);
   1857 
   1858     /**
   1859      * Retrieve an image from a package.  This is a low-level API used by
   1860      * the various package manager info structures (such as
   1861      * {@link ComponentInfo} to implement retrieval of their associated
   1862      * icon.
   1863      *
   1864      * @param packageName The name of the package that this icon is coming from.
   1865      * Can not be null.
   1866      * @param resid The resource identifier of the desired image.  Can not be 0.
   1867      * @param appInfo Overall information about <var>packageName</var>.  This
   1868      * may be null, in which case the application information will be retrieved
   1869      * for you if needed; if you already have this information around, it can
   1870      * be much more efficient to supply it here.
   1871      *
   1872      * @return Returns a Drawable holding the requested image.  Returns null if
   1873      * an image could not be found for any reason.
   1874      */
   1875     public abstract Drawable getDrawable(String packageName, int resid,
   1876             ApplicationInfo appInfo);
   1877 
   1878     /**
   1879      * Retrieve the icon associated with an activity.  Given the full name of
   1880      * an activity, retrieves the information about it and calls
   1881      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
   1882      * If the activity can not be found, NameNotFoundException is thrown.
   1883      *
   1884      * @param activityName Name of the activity whose icon is to be retrieved.
   1885      *
   1886      * @return Returns the image of the icon, or the default activity icon if
   1887      * it could not be found.  Does not return null.
   1888      * @throws NameNotFoundException Thrown if the resources for the given
   1889      * activity could not be loaded.
   1890      *
   1891      * @see #getActivityIcon(Intent)
   1892      */
   1893     public abstract Drawable getActivityIcon(ComponentName activityName)
   1894             throws NameNotFoundException;
   1895 
   1896     /**
   1897      * Retrieve the icon associated with an Intent.  If intent.getClassName() is
   1898      * set, this simply returns the result of
   1899      * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
   1900      * component and returns the icon associated with the resolved component.
   1901      * If intent.getClassName() can not be found or the Intent can not be resolved
   1902      * to a component, NameNotFoundException is thrown.
   1903      *
   1904      * @param intent The intent for which you would like to retrieve an icon.
   1905      *
   1906      * @return Returns the image of the icon, or the default activity icon if
   1907      * it could not be found.  Does not return null.
   1908      * @throws NameNotFoundException Thrown if the resources for application
   1909      * matching the given intent could not be loaded.
   1910      *
   1911      * @see #getActivityIcon(ComponentName)
   1912      */
   1913     public abstract Drawable getActivityIcon(Intent intent)
   1914             throws NameNotFoundException;
   1915 
   1916     /**
   1917      * Return the generic icon for an activity that is used when no specific
   1918      * icon is defined.
   1919      *
   1920      * @return Drawable Image of the icon.
   1921      */
   1922     public abstract Drawable getDefaultActivityIcon();
   1923 
   1924     /**
   1925      * Retrieve the icon associated with an application.  If it has not defined
   1926      * an icon, the default app icon is returned.  Does not return null.
   1927      *
   1928      * @param info Information about application being queried.
   1929      *
   1930      * @return Returns the image of the icon, or the default application icon
   1931      * if it could not be found.
   1932      *
   1933      * @see #getApplicationIcon(String)
   1934      */
   1935     public abstract Drawable getApplicationIcon(ApplicationInfo info);
   1936 
   1937     /**
   1938      * Retrieve the icon associated with an application.  Given the name of the
   1939      * application's package, retrieves the information about it and calls
   1940      * getApplicationIcon() to return its icon. If the application can not be
   1941      * found, NameNotFoundException is thrown.
   1942      *
   1943      * @param packageName Name of the package whose application icon is to be
   1944      *                    retrieved.
   1945      *
   1946      * @return Returns the image of the icon, or the default application icon
   1947      * if it could not be found.  Does not return null.
   1948      * @throws NameNotFoundException Thrown if the resources for the given
   1949      * application could not be loaded.
   1950      *
   1951      * @see #getApplicationIcon(ApplicationInfo)
   1952      */
   1953     public abstract Drawable getApplicationIcon(String packageName)
   1954             throws NameNotFoundException;
   1955 
   1956     /**
   1957      * Retrieve the logo associated with an activity.  Given the full name of
   1958      * an activity, retrieves the information about it and calls
   1959      * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
   1960      * If the activity can not be found, NameNotFoundException is thrown.
   1961      *
   1962      * @param activityName Name of the activity whose logo is to be retrieved.
   1963      *
   1964      * @return Returns the image of the logo or null if the activity has no
   1965      * logo specified.
   1966      *
   1967      * @throws NameNotFoundException Thrown if the resources for the given
   1968      * activity could not be loaded.
   1969      *
   1970      * @see #getActivityLogo(Intent)
   1971      */
   1972     public abstract Drawable getActivityLogo(ComponentName activityName)
   1973             throws NameNotFoundException;
   1974 
   1975     /**
   1976      * Retrieve the logo associated with an Intent.  If intent.getClassName() is
   1977      * set, this simply returns the result of
   1978      * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
   1979      * component and returns the logo associated with the resolved component.
   1980      * If intent.getClassName() can not be found or the Intent can not be resolved
   1981      * to a component, NameNotFoundException is thrown.
   1982      *
   1983      * @param intent The intent for which you would like to retrieve a logo.
   1984      *
   1985      * @return Returns the image of the logo, or null if the activity has no
   1986      * logo specified.
   1987      *
   1988      * @throws NameNotFoundException Thrown if the resources for application
   1989      * matching the given intent could not be loaded.
   1990      *
   1991      * @see #getActivityLogo(ComponentName)
   1992      */
   1993     public abstract Drawable getActivityLogo(Intent intent)
   1994             throws NameNotFoundException;
   1995 
   1996     /**
   1997      * Retrieve the logo associated with an application.  If it has not specified
   1998      * a logo, this method returns null.
   1999      *
   2000      * @param info Information about application being queried.
   2001      *
   2002      * @return Returns the image of the logo, or null if no logo is specified
   2003      * by the application.
   2004      *
   2005      * @see #getApplicationLogo(String)
   2006      */
   2007     public abstract Drawable getApplicationLogo(ApplicationInfo info);
   2008 
   2009     /**
   2010      * Retrieve the logo associated with an application.  Given the name of the
   2011      * application's package, retrieves the information about it and calls
   2012      * getApplicationLogo() to return its logo. If the application can not be
   2013      * found, NameNotFoundException is thrown.
   2014      *
   2015      * @param packageName Name of the package whose application logo is to be
   2016      *                    retrieved.
   2017      *
   2018      * @return Returns the image of the logo, or null if no application logo
   2019      * has been specified.
   2020      *
   2021      * @throws NameNotFoundException Thrown if the resources for the given
   2022      * application could not be loaded.
   2023      *
   2024      * @see #getApplicationLogo(ApplicationInfo)
   2025      */
   2026     public abstract Drawable getApplicationLogo(String packageName)
   2027             throws NameNotFoundException;
   2028 
   2029     /**
   2030      * Retrieve text from a package.  This is a low-level API used by
   2031      * the various package manager info structures (such as
   2032      * {@link ComponentInfo} to implement retrieval of their associated
   2033      * labels and other text.
   2034      *
   2035      * @param packageName The name of the package that this text is coming from.
   2036      * Can not be null.
   2037      * @param resid The resource identifier of the desired text.  Can not be 0.
   2038      * @param appInfo Overall information about <var>packageName</var>.  This
   2039      * may be null, in which case the application information will be retrieved
   2040      * for you if needed; if you already have this information around, it can
   2041      * be much more efficient to supply it here.
   2042      *
   2043      * @return Returns a CharSequence holding the requested text.  Returns null
   2044      * if the text could not be found for any reason.
   2045      */
   2046     public abstract CharSequence getText(String packageName, int resid,
   2047             ApplicationInfo appInfo);
   2048 
   2049     /**
   2050      * Retrieve an XML file from a package.  This is a low-level API used to
   2051      * retrieve XML meta data.
   2052      *
   2053      * @param packageName The name of the package that this xml is coming from.
   2054      * Can not be null.
   2055      * @param resid The resource identifier of the desired xml.  Can not be 0.
   2056      * @param appInfo Overall information about <var>packageName</var>.  This
   2057      * may be null, in which case the application information will be retrieved
   2058      * for you if needed; if you already have this information around, it can
   2059      * be much more efficient to supply it here.
   2060      *
   2061      * @return Returns an XmlPullParser allowing you to parse out the XML
   2062      * data.  Returns null if the xml resource could not be found for any
   2063      * reason.
   2064      */
   2065     public abstract XmlResourceParser getXml(String packageName, int resid,
   2066             ApplicationInfo appInfo);
   2067 
   2068     /**
   2069      * Return the label to use for this application.
   2070      *
   2071      * @return Returns the label associated with this application, or null if
   2072      * it could not be found for any reason.
   2073      * @param info The application to get the label of
   2074      */
   2075     public abstract CharSequence getApplicationLabel(ApplicationInfo info);
   2076 
   2077     /**
   2078      * Retrieve the resources associated with an activity.  Given the full
   2079      * name of an activity, retrieves the information about it and calls
   2080      * getResources() to return its application's resources.  If the activity
   2081      * can not be found, NameNotFoundException is thrown.
   2082      *
   2083      * @param activityName Name of the activity whose resources are to be
   2084      *                     retrieved.
   2085      *
   2086      * @return Returns the application's Resources.
   2087      * @throws NameNotFoundException Thrown if the resources for the given
   2088      * application could not be loaded.
   2089      *
   2090      * @see #getResourcesForApplication(ApplicationInfo)
   2091      */
   2092     public abstract Resources getResourcesForActivity(ComponentName activityName)
   2093             throws NameNotFoundException;
   2094 
   2095     /**
   2096      * Retrieve the resources for an application.  Throws NameNotFoundException
   2097      * if the package is no longer installed.
   2098      *
   2099      * @param app Information about the desired application.
   2100      *
   2101      * @return Returns the application's Resources.
   2102      * @throws NameNotFoundException Thrown if the resources for the given
   2103      * application could not be loaded (most likely because it was uninstalled).
   2104      */
   2105     public abstract Resources getResourcesForApplication(ApplicationInfo app)
   2106             throws NameNotFoundException;
   2107 
   2108     /**
   2109      * Retrieve the resources associated with an application.  Given the full
   2110      * package name of an application, retrieves the information about it and
   2111      * calls getResources() to return its application's resources.  If the
   2112      * appPackageName can not be found, NameNotFoundException is thrown.
   2113      *
   2114      * @param appPackageName Package name of the application whose resources
   2115      *                       are to be retrieved.
   2116      *
   2117      * @return Returns the application's Resources.
   2118      * @throws NameNotFoundException Thrown if the resources for the given
   2119      * application could not be loaded.
   2120      *
   2121      * @see #getResourcesForApplication(ApplicationInfo)
   2122      */
   2123     public abstract Resources getResourcesForApplication(String appPackageName)
   2124             throws NameNotFoundException;
   2125 
   2126     /**
   2127      * Retrieve overall information about an application package defined
   2128      * in a package archive file
   2129      *
   2130      * @param archiveFilePath The path to the archive file
   2131      * @param flags Additional option flags. Use any combination of
   2132      * {@link #GET_ACTIVITIES},
   2133      * {@link #GET_GIDS},
   2134      * {@link #GET_CONFIGURATIONS},
   2135      * {@link #GET_INSTRUMENTATION},
   2136      * {@link #GET_PERMISSIONS},
   2137      * {@link #GET_PROVIDERS},
   2138      * {@link #GET_RECEIVERS},
   2139      * {@link #GET_SERVICES},
   2140      * {@link #GET_SIGNATURES}, to modify the data returned.
   2141      *
   2142      * @return Returns the information about the package. Returns
   2143      * null if the package could not be successfully parsed.
   2144      *
   2145      * @see #GET_ACTIVITIES
   2146      * @see #GET_GIDS
   2147      * @see #GET_CONFIGURATIONS
   2148      * @see #GET_INSTRUMENTATION
   2149      * @see #GET_PERMISSIONS
   2150      * @see #GET_PROVIDERS
   2151      * @see #GET_RECEIVERS
   2152      * @see #GET_SERVICES
   2153      * @see #GET_SIGNATURES
   2154      *
   2155      */
   2156     public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
   2157         PackageParser packageParser = new PackageParser(archiveFilePath);
   2158         DisplayMetrics metrics = new DisplayMetrics();
   2159         metrics.setToDefaults();
   2160         final File sourceFile = new File(archiveFilePath);
   2161         PackageParser.Package pkg = packageParser.parsePackage(
   2162                 sourceFile, archiveFilePath, metrics, 0);
   2163         if (pkg == null) {
   2164             return null;
   2165         }
   2166         if ((flags & GET_SIGNATURES) != 0) {
   2167             packageParser.collectCertificates(pkg, 0);
   2168         }
   2169         return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, false,
   2170                 COMPONENT_ENABLED_STATE_DEFAULT);
   2171     }
   2172 
   2173     /**
   2174      * @hide
   2175      *
   2176      * Install a package. Since this may take a little while, the result will
   2177      * be posted back to the given observer.  An installation will fail if the calling context
   2178      * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
   2179      * package named in the package file's manifest is already installed, or if there's no space
   2180      * available on the device.
   2181      *
   2182      * @param packageURI The location of the package file to install.  This can be a 'file:' or a
   2183      * 'content:' URI.
   2184      * @param observer An observer callback to get notified when the package installation is
   2185      * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
   2186      * called when that happens.  observer may be null to indicate that no callback is desired.
   2187      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   2188      * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
   2189      * @param installerPackageName Optional package name of the application that is performing the
   2190      * installation. This identifies which market the package came from.
   2191      */
   2192     public abstract void installPackage(
   2193             Uri packageURI, IPackageInstallObserver observer, int flags,
   2194             String installerPackageName);
   2195 
   2196     /**
   2197      * Similar to
   2198      * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
   2199      * with an extra verification file provided.
   2200      *
   2201      * @param packageURI The location of the package file to install. This can
   2202      *            be a 'file:' or a 'content:' URI.
   2203      * @param observer An observer callback to get notified when the package
   2204      *            installation is complete.
   2205      *            {@link IPackageInstallObserver#packageInstalled(String, int)}
   2206      *            will be called when that happens. observer may be null to
   2207      *            indicate that no callback is desired.
   2208      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   2209      *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}
   2210      *            .
   2211      * @param installerPackageName Optional package name of the application that
   2212      *            is performing the installation. This identifies which market
   2213      *            the package came from.
   2214      * @param verificationURI The location of the supplementary verification
   2215      *            file. This can be a 'file:' or a 'content:' URI. May be
   2216      *            {@code null}.
   2217      * @param manifestDigest an object that holds the digest of the package
   2218      *            which can be used to verify ownership. May be {@code null}.
   2219      * @param encryptionParams if the package to be installed is encrypted,
   2220      *            these parameters describing the encryption and authentication
   2221      *            used. May be {@code null}.
   2222      * @hide
   2223      */
   2224     public abstract void installPackageWithVerification(Uri packageURI,
   2225             IPackageInstallObserver observer, int flags, String installerPackageName,
   2226             Uri verificationURI, ManifestDigest manifestDigest,
   2227             ContainerEncryptionParams encryptionParams);
   2228 
   2229     /**
   2230      * Allows a package listening to the
   2231      * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
   2232      * broadcast} to respond to the package manager. The response must include
   2233      * the {@code verificationCode} which is one of
   2234      * {@link PackageManager#VERIFICATION_ALLOW} or
   2235      * {@link PackageManager#VERIFICATION_REJECT}.
   2236      *
   2237      * @param id pending package identifier as passed via the
   2238      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra
   2239      * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
   2240      *            or {@link PackageManager#VERIFICATION_REJECT}.
   2241      */
   2242     public abstract void verifyPendingInstall(int id, int verificationCode);
   2243 
   2244     /**
   2245      * Change the installer associated with a given package.  There are limitations
   2246      * on how the installer package can be changed; in particular:
   2247      * <ul>
   2248      * <li> A SecurityException will be thrown if <var>installerPackageName</var>
   2249      * is not signed with the same certificate as the calling application.
   2250      * <li> A SecurityException will be thrown if <var>targetPackage</var> already
   2251      * has an installer package, and that installer package is not signed with
   2252      * the same certificate as the calling application.
   2253      * </ul>
   2254      *
   2255      * @param targetPackage The installed package whose installer will be changed.
   2256      * @param installerPackageName The package name of the new installer.  May be
   2257      * null to clear the association.
   2258      */
   2259     public abstract void setInstallerPackageName(String targetPackage,
   2260             String installerPackageName);
   2261 
   2262     /**
   2263      * Attempts to delete a package.  Since this may take a little while, the result will
   2264      * be posted back to the given observer.  A deletion will fail if the calling context
   2265      * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
   2266      * named package cannot be found, or if the named package is a "system package".
   2267      * (TODO: include pointer to documentation on "system packages")
   2268      *
   2269      * @param packageName The name of the package to delete
   2270      * @param observer An observer callback to get notified when the package deletion is
   2271      * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
   2272      * called when that happens.  observer may be null to indicate that no callback is desired.
   2273      * @param flags - possible values: {@link #DONT_DELETE_DATA}
   2274      *
   2275      * @hide
   2276      */
   2277     public abstract void deletePackage(
   2278             String packageName, IPackageDeleteObserver observer, int flags);
   2279 
   2280     /**
   2281      * Retrieve the package name of the application that installed a package. This identifies
   2282      * which market the package came from.
   2283      *
   2284      * @param packageName The name of the package to query
   2285      */
   2286     public abstract String getInstallerPackageName(String packageName);
   2287 
   2288     /**
   2289      * Attempts to clear the user data directory of an application.
   2290      * Since this may take a little while, the result will
   2291      * be posted back to the given observer.  A deletion will fail if the
   2292      * named package cannot be found, or if the named package is a "system package".
   2293      *
   2294      * @param packageName The name of the package
   2295      * @param observer An observer callback to get notified when the operation is finished
   2296      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
   2297      * will be called when that happens.  observer may be null to indicate that
   2298      * no callback is desired.
   2299      *
   2300      * @hide
   2301      */
   2302     public abstract void clearApplicationUserData(String packageName,
   2303             IPackageDataObserver observer);
   2304     /**
   2305      * Attempts to delete the cache files associated with an application.
   2306      * Since this may take a little while, the result will
   2307      * be posted back to the given observer.  A deletion will fail if the calling context
   2308      * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
   2309      * named package cannot be found, or if the named package is a "system package".
   2310      *
   2311      * @param packageName The name of the package to delete
   2312      * @param observer An observer callback to get notified when the cache file deletion
   2313      * is complete.
   2314      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
   2315      * will be called when that happens.  observer may be null to indicate that
   2316      * no callback is desired.
   2317      *
   2318      * @hide
   2319      */
   2320     public abstract void deleteApplicationCacheFiles(String packageName,
   2321             IPackageDataObserver observer);
   2322 
   2323     /**
   2324      * Free storage by deleting LRU sorted list of cache files across
   2325      * all applications. If the currently available free storage
   2326      * on the device is greater than or equal to the requested
   2327      * free storage, no cache files are cleared. If the currently
   2328      * available storage on the device is less than the requested
   2329      * free storage, some or all of the cache files across
   2330      * all applications are deleted (based on last accessed time)
   2331      * to increase the free storage space on the device to
   2332      * the requested value. There is no guarantee that clearing all
   2333      * the cache files from all applications will clear up
   2334      * enough storage to achieve the desired value.
   2335      * @param freeStorageSize The number of bytes of storage to be
   2336      * freed by the system. Say if freeStorageSize is XX,
   2337      * and the current free storage is YY,
   2338      * if XX is less than YY, just return. if not free XX-YY number
   2339      * of bytes if possible.
   2340      * @param observer call back used to notify when
   2341      * the operation is completed
   2342      *
   2343      * @hide
   2344      */
   2345     public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
   2346 
   2347     /**
   2348      * Free storage by deleting LRU sorted list of cache files across
   2349      * all applications. If the currently available free storage
   2350      * on the device is greater than or equal to the requested
   2351      * free storage, no cache files are cleared. If the currently
   2352      * available storage on the device is less than the requested
   2353      * free storage, some or all of the cache files across
   2354      * all applications are deleted (based on last accessed time)
   2355      * to increase the free storage space on the device to
   2356      * the requested value. There is no guarantee that clearing all
   2357      * the cache files from all applications will clear up
   2358      * enough storage to achieve the desired value.
   2359      * @param freeStorageSize The number of bytes of storage to be
   2360      * freed by the system. Say if freeStorageSize is XX,
   2361      * and the current free storage is YY,
   2362      * if XX is less than YY, just return. if not free XX-YY number
   2363      * of bytes if possible.
   2364      * @param pi IntentSender call back used to
   2365      * notify when the operation is completed.May be null
   2366      * to indicate that no call back is desired.
   2367      *
   2368      * @hide
   2369      */
   2370     public abstract void freeStorage(long freeStorageSize, IntentSender pi);
   2371 
   2372     /**
   2373      * Retrieve the size information for a package.
   2374      * Since this may take a little while, the result will
   2375      * be posted back to the given observer.  The calling context
   2376      * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
   2377      *
   2378      * @param packageName The name of the package whose size information is to be retrieved
   2379      * @param observer An observer callback to get notified when the operation
   2380      * is complete.
   2381      * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
   2382      * The observer's callback is invoked with a PackageStats object(containing the
   2383      * code, data and cache sizes of the package) and a boolean value representing
   2384      * the status of the operation. observer may be null to indicate that
   2385      * no callback is desired.
   2386      *
   2387      * @hide
   2388      */
   2389     public abstract void getPackageSizeInfo(String packageName,
   2390             IPackageStatsObserver observer);
   2391 
   2392     /**
   2393      * @deprecated This function no longer does anything; it was an old
   2394      * approach to managing preferred activities, which has been superceeded
   2395      * (and conflicts with) the modern activity-based preferences.
   2396      */
   2397     @Deprecated
   2398     public abstract void addPackageToPreferred(String packageName);
   2399 
   2400     /**
   2401      * @deprecated This function no longer does anything; it was an old
   2402      * approach to managing preferred activities, which has been superceeded
   2403      * (and conflicts with) the modern activity-based preferences.
   2404      */
   2405     @Deprecated
   2406     public abstract void removePackageFromPreferred(String packageName);
   2407 
   2408     /**
   2409      * Retrieve the list of all currently configured preferred packages.  The
   2410      * first package on the list is the most preferred, the last is the
   2411      * least preferred.
   2412      *
   2413      * @param flags Additional option flags. Use any combination of
   2414      * {@link #GET_ACTIVITIES},
   2415      * {@link #GET_GIDS},
   2416      * {@link #GET_CONFIGURATIONS},
   2417      * {@link #GET_INSTRUMENTATION},
   2418      * {@link #GET_PERMISSIONS},
   2419      * {@link #GET_PROVIDERS},
   2420      * {@link #GET_RECEIVERS},
   2421      * {@link #GET_SERVICES},
   2422      * {@link #GET_SIGNATURES}, to modify the data returned.
   2423      *
   2424      * @return Returns a list of PackageInfo objects describing each
   2425      * preferred application, in order of preference.
   2426      *
   2427      * @see #GET_ACTIVITIES
   2428      * @see #GET_GIDS
   2429      * @see #GET_CONFIGURATIONS
   2430      * @see #GET_INSTRUMENTATION
   2431      * @see #GET_PERMISSIONS
   2432      * @see #GET_PROVIDERS
   2433      * @see #GET_RECEIVERS
   2434      * @see #GET_SERVICES
   2435      * @see #GET_SIGNATURES
   2436      */
   2437     public abstract List<PackageInfo> getPreferredPackages(int flags);
   2438 
   2439     /**
   2440      * @deprecated This is a protected API that should not have been available
   2441      * to third party applications.  It is the platform's responsibility for
   2442      * assigning preferred activities and this can not be directly modified.
   2443      *
   2444      * Add a new preferred activity mapping to the system.  This will be used
   2445      * to automatically select the given activity component when
   2446      * {@link Context#startActivity(Intent) Context.startActivity()} finds
   2447      * multiple matching activities and also matches the given filter.
   2448      *
   2449      * @param filter The set of intents under which this activity will be
   2450      * made preferred.
   2451      * @param match The IntentFilter match category that this preference
   2452      * applies to.
   2453      * @param set The set of activities that the user was picking from when
   2454      * this preference was made.
   2455      * @param activity The component name of the activity that is to be
   2456      * preferred.
   2457      */
   2458     @Deprecated
   2459     public abstract void addPreferredActivity(IntentFilter filter, int match,
   2460             ComponentName[] set, ComponentName activity);
   2461 
   2462     /**
   2463      * @deprecated This is a protected API that should not have been available
   2464      * to third party applications.  It is the platform's responsibility for
   2465      * assigning preferred activities and this can not be directly modified.
   2466      *
   2467      * Replaces an existing preferred activity mapping to the system, and if that were not present
   2468      * adds a new preferred activity.  This will be used
   2469      * to automatically select the given activity component when
   2470      * {@link Context#startActivity(Intent) Context.startActivity()} finds
   2471      * multiple matching activities and also matches the given filter.
   2472      *
   2473      * @param filter The set of intents under which this activity will be
   2474      * made preferred.
   2475      * @param match The IntentFilter match category that this preference
   2476      * applies to.
   2477      * @param set The set of activities that the user was picking from when
   2478      * this preference was made.
   2479      * @param activity The component name of the activity that is to be
   2480      * preferred.
   2481      * @hide
   2482      */
   2483     @Deprecated
   2484     public abstract void replacePreferredActivity(IntentFilter filter, int match,
   2485             ComponentName[] set, ComponentName activity);
   2486 
   2487     /**
   2488      * Remove all preferred activity mappings, previously added with
   2489      * {@link #addPreferredActivity}, from the
   2490      * system whose activities are implemented in the given package name.
   2491      * An application can only clear its own package(s).
   2492      *
   2493      * @param packageName The name of the package whose preferred activity
   2494      * mappings are to be removed.
   2495      */
   2496     public abstract void clearPackagePreferredActivities(String packageName);
   2497 
   2498     /**
   2499      * Retrieve all preferred activities, previously added with
   2500      * {@link #addPreferredActivity}, that are
   2501      * currently registered with the system.
   2502      *
   2503      * @param outFilters A list in which to place the filters of all of the
   2504      * preferred activities, or null for none.
   2505      * @param outActivities A list in which to place the component names of
   2506      * all of the preferred activities, or null for none.
   2507      * @param packageName An option package in which you would like to limit
   2508      * the list.  If null, all activities will be returned; if non-null, only
   2509      * those activities in the given package are returned.
   2510      *
   2511      * @return Returns the total number of registered preferred activities
   2512      * (the number of distinct IntentFilter records, not the number of unique
   2513      * activity components) that were found.
   2514      */
   2515     public abstract int getPreferredActivities(List<IntentFilter> outFilters,
   2516             List<ComponentName> outActivities, String packageName);
   2517 
   2518     /**
   2519      * Set the enabled setting for a package component (activity, receiver, service, provider).
   2520      * This setting will override any enabled state which may have been set by the component in its
   2521      * manifest.
   2522      *
   2523      * @param componentName The component to enable
   2524      * @param newState The new enabled state for the component.  The legal values for this state
   2525      *                 are:
   2526      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2527      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
   2528      *                   and
   2529      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
   2530      *                 The last one removes the setting, thereby restoring the component's state to
   2531      *                 whatever was set in it's manifest (or enabled, by default).
   2532      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
   2533      */
   2534     public abstract void setComponentEnabledSetting(ComponentName componentName,
   2535             int newState, int flags);
   2536 
   2537 
   2538     /**
   2539      * Return the the enabled setting for a package component (activity,
   2540      * receiver, service, provider).  This returns the last value set by
   2541      * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
   2542      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
   2543      * the value originally specified in the manifest has not been modified.
   2544      *
   2545      * @param componentName The component to retrieve.
   2546      * @return Returns the current enabled state for the component.  May
   2547      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2548      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
   2549      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
   2550      * component's enabled state is based on the original information in
   2551      * the manifest as found in {@link ComponentInfo}.
   2552      */
   2553     public abstract int getComponentEnabledSetting(ComponentName componentName);
   2554 
   2555     /**
   2556      * Set the enabled setting for an application
   2557      * This setting will override any enabled state which may have been set by the application in
   2558      * its manifest.  It also overrides the enabled state set in the manifest for any of the
   2559      * application's components.  It does not override any enabled state set by
   2560      * {@link #setComponentEnabledSetting} for any of the application's components.
   2561      *
   2562      * @param packageName The package name of the application to enable
   2563      * @param newState The new enabled state for the component.  The legal values for this state
   2564      *                 are:
   2565      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2566      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
   2567      *                   and
   2568      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
   2569      *                 The last one removes the setting, thereby restoring the applications's state to
   2570      *                 whatever was set in its manifest (or enabled, by default).
   2571      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
   2572      */
   2573     public abstract void setApplicationEnabledSetting(String packageName,
   2574             int newState, int flags);
   2575 
   2576     /**
   2577      * Return the the enabled setting for an application.  This returns
   2578      * the last value set by
   2579      * {@link #setApplicationEnabledSetting(String, int, int)}; in most
   2580      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
   2581      * the value originally specified in the manifest has not been modified.
   2582      *
   2583      * @param packageName The component to retrieve.
   2584      * @return Returns the current enabled state for the component.  May
   2585      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2586      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
   2587      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
   2588      * application's enabled state is based on the original information in
   2589      * the manifest as found in {@link ComponentInfo}.
   2590      * @throws IllegalArgumentException if the named package does not exist.
   2591      */
   2592     public abstract int getApplicationEnabledSetting(String packageName);
   2593 
   2594     /**
   2595      * Return whether the device has been booted into safe mode.
   2596      */
   2597     public abstract boolean isSafeMode();
   2598 
   2599     /**
   2600      * Attempts to move package resources from internal to external media or vice versa.
   2601      * Since this may take a little while, the result will
   2602      * be posted back to the given observer.   This call may fail if the calling context
   2603      * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
   2604      * named package cannot be found, or if the named package is a "system package".
   2605      *
   2606      * @param packageName The name of the package to delete
   2607      * @param observer An observer callback to get notified when the package move is
   2608      * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
   2609      * called when that happens.  observer may be null to indicate that no callback is desired.
   2610      * @param flags To indicate install location {@link #MOVE_INTERNAL} or
   2611      * {@link #MOVE_EXTERNAL_MEDIA}
   2612      *
   2613      * @hide
   2614      */
   2615     public abstract void movePackage(
   2616             String packageName, IPackageMoveObserver observer, int flags);
   2617 
   2618     /**
   2619      * Creates a user with the specified name and options.
   2620      *
   2621      * @param name the user's name
   2622      * @param flags flags that identify the type of user and other properties.
   2623      * @see UserInfo
   2624      *
   2625      * @return the UserInfo object for the created user, or null if the user could not be created.
   2626      * @hide
   2627      */
   2628     public abstract UserInfo createUser(String name, int flags);
   2629 
   2630     /**
   2631      * @return the list of users that were created
   2632      * @hide
   2633      */
   2634     public abstract List<UserInfo> getUsers();
   2635 
   2636     /**
   2637      * @param id the ID of the user, where 0 is the primary user.
   2638      * @hide
   2639      */
   2640     public abstract boolean removeUser(int id);
   2641 
   2642     /**
   2643      * Updates the user's name.
   2644      *
   2645      * @param id the user's id
   2646      * @param name the new name for the user
   2647      * @hide
   2648      */
   2649     public abstract void updateUserName(int id, String name);
   2650 
   2651     /**
   2652      * Changes the user's properties specified by the flags.
   2653      *
   2654      * @param id the user's id
   2655      * @param flags the new flags for the user
   2656      * @hide
   2657      */
   2658     public abstract void updateUserFlags(int id, int flags);
   2659 
   2660     /**
   2661      * Returns the details for the user specified by userId.
   2662      * @param userId the user id of the user
   2663      * @return UserInfo for the specified user, or null if no such user exists.
   2664      * @hide
   2665      */
   2666     public abstract UserInfo getUser(int userId);
   2667 
   2668     /**
   2669      * Returns the device identity that verifiers can use to associate their scheme to a particular
   2670      * device. This should not be used by anything other than a package verifier.
   2671      *
   2672      * @return identity that uniquely identifies current device
   2673      * @hide
   2674      */
   2675     public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
   2676 
   2677     /**
   2678      * Returns the data directory for a particular user and package, given the uid of the package.
   2679      * @param uid uid of the package, including the userId and appId
   2680      * @param packageName name of the package
   2681      * @return the user-specific data directory for the package
   2682      * @hide
   2683      */
   2684     public static String getDataDirForUser(int userId, String packageName) {
   2685         // TODO: This should be shared with Installer's knowledge of user directory
   2686         return Environment.getDataDirectory().toString() + "/user/" + userId
   2687                 + "/" + packageName;
   2688     }
   2689 }
   2690