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.os.StatFs;
     32 import android.util.AndroidException;
     33 import android.util.DisplayMetrics;
     34 
     35 import java.io.File;
     36 import java.util.List;
     37 
     38 /**
     39  * Class for retrieving various kinds of information related to the application
     40  * packages that are currently installed on the device.
     41  *
     42  * You can find this class through {@link Context#getPackageManager}.
     43  */
     44 public abstract class PackageManager {
     45 
     46     /**
     47      * This exception is thrown when a given package, application, or component
     48      * name can not be found.
     49      */
     50     public static class NameNotFoundException extends AndroidException {
     51         public NameNotFoundException() {
     52         }
     53 
     54         public NameNotFoundException(String name) {
     55             super(name);
     56         }
     57     }
     58 
     59     /**
     60      * {@link PackageInfo} flag: return information about
     61      * activities in the package in {@link PackageInfo#activities}.
     62      */
     63     public static final int GET_ACTIVITIES              = 0x00000001;
     64 
     65     /**
     66      * {@link PackageInfo} flag: return information about
     67      * intent receivers in the package in
     68      * {@link PackageInfo#receivers}.
     69      */
     70     public static final int GET_RECEIVERS               = 0x00000002;
     71 
     72     /**
     73      * {@link PackageInfo} flag: return information about
     74      * services in the package in {@link PackageInfo#services}.
     75      */
     76     public static final int GET_SERVICES                = 0x00000004;
     77 
     78     /**
     79      * {@link PackageInfo} flag: return information about
     80      * content providers in the package in
     81      * {@link PackageInfo#providers}.
     82      */
     83     public static final int GET_PROVIDERS               = 0x00000008;
     84 
     85     /**
     86      * {@link PackageInfo} flag: return information about
     87      * instrumentation in the package in
     88      * {@link PackageInfo#instrumentation}.
     89      */
     90     public static final int GET_INSTRUMENTATION         = 0x00000010;
     91 
     92     /**
     93      * {@link PackageInfo} flag: return information about the
     94      * intent filters supported by the activity.
     95      */
     96     public static final int GET_INTENT_FILTERS          = 0x00000020;
     97 
     98     /**
     99      * {@link PackageInfo} flag: return information about the
    100      * signatures included in the package.
    101      */
    102     public static final int GET_SIGNATURES          = 0x00000040;
    103 
    104     /**
    105      * {@link ResolveInfo} flag: return the IntentFilter that
    106      * was matched for a particular ResolveInfo in
    107      * {@link ResolveInfo#filter}.
    108      */
    109     public static final int GET_RESOLVED_FILTER         = 0x00000040;
    110 
    111     /**
    112      * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
    113      * data {@link android.os.Bundle}s that are associated with a component.
    114      * This applies for any API returning a ComponentInfo subclass.
    115      */
    116     public static final int GET_META_DATA               = 0x00000080;
    117 
    118     /**
    119      * {@link PackageInfo} flag: return the
    120      * {@link PackageInfo#gids group ids} that are associated with an
    121      * application.
    122      * This applies for any API returning an PackageInfo class, either
    123      * directly or nested inside of another.
    124      */
    125     public static final int GET_GIDS                    = 0x00000100;
    126 
    127     /**
    128      * {@link PackageInfo} flag: include disabled components in the returned info.
    129      */
    130     public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
    131 
    132     /**
    133      * {@link ApplicationInfo} flag: return the
    134      * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
    135      * that are associated with an application.
    136      * This applies for any API returning an ApplicationInfo class, either
    137      * directly or nested inside of another.
    138      */
    139     public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
    140 
    141     /**
    142      * {@link ProviderInfo} flag: return the
    143      * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
    144      * that are associated with a content provider.
    145      * This applies for any API returning an ProviderInfo class, either
    146      * directly or nested inside of another.
    147      */
    148     public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
    149     /**
    150      * {@link PackageInfo} flag: return information about
    151      * permissions in the package in
    152      * {@link PackageInfo#permissions}.
    153      */
    154     public static final int GET_PERMISSIONS               = 0x00001000;
    155 
    156     /**
    157      * Flag parameter to retrieve all applications(even uninstalled ones) with data directories.
    158      * This state could have resulted if applications have been deleted with flag
    159      * DONT_DELETE_DATA
    160      * with a possibility of being replaced or reinstalled in future
    161      */
    162     public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
    163 
    164     /**
    165      * {@link PackageInfo} flag: return information about
    166      * hardware preferences in
    167      * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
    168      * requested features in {@link PackageInfo#reqFeatures
    169      * PackageInfo.reqFeatures}.
    170      */
    171     public static final int GET_CONFIGURATIONS = 0x00004000;
    172 
    173     /**
    174      * Resolution and querying flag: if set, only filters that support the
    175      * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
    176      * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
    177      * supplied Intent.
    178      */
    179     public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
    180 
    181     /**
    182      * Permission check result: this is returned by {@link #checkPermission}
    183      * if the permission has been granted to the given package.
    184      */
    185     public static final int PERMISSION_GRANTED = 0;
    186 
    187     /**
    188      * Permission check result: this is returned by {@link #checkPermission}
    189      * if the permission has not been granted to the given package.
    190      */
    191     public static final int PERMISSION_DENIED = -1;
    192 
    193     /**
    194      * Signature check result: this is returned by {@link #checkSignatures}
    195      * if the two packages have a matching signature.
    196      */
    197     public static final int SIGNATURE_MATCH = 0;
    198 
    199     /**
    200      * Signature check result: this is returned by {@link #checkSignatures}
    201      * if neither of the two packages is signed.
    202      */
    203     public static final int SIGNATURE_NEITHER_SIGNED = 1;
    204 
    205     /**
    206      * Signature check result: this is returned by {@link #checkSignatures}
    207      * if the first package is not signed, but the second is.
    208      */
    209     public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
    210 
    211     /**
    212      * Signature check result: this is returned by {@link #checkSignatures}
    213      * if the second package is not signed, but the first is.
    214      */
    215     public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
    216 
    217     /**
    218      * Signature check result: this is returned by {@link #checkSignatures}
    219      * if both packages are signed but there is no matching signature.
    220      */
    221     public static final int SIGNATURE_NO_MATCH = -3;
    222 
    223     /**
    224      * Signature check result: this is returned by {@link #checkSignatures}
    225      * if either of the given package names are not valid.
    226      */
    227     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
    228 
    229     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
    230     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
    231     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
    232 
    233     /**
    234      * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
    235      * indicate that this package should be installed as forward locked, i.e. only the app itself
    236      * should have access to its code and non-resource assets.
    237      * @hide
    238      */
    239     public static final int INSTALL_FORWARD_LOCK = 0x00000001;
    240 
    241     /**
    242      * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
    243      * installed package, if one exists.
    244      * @hide
    245      */
    246     public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
    247 
    248     /**
    249      * Flag parameter for {@link #installPackage} to indicate that you want to
    250      * allow test packages (those that have set android:testOnly in their
    251      * manifest) to be installed.
    252      * @hide
    253      */
    254     public static final int INSTALL_ALLOW_TEST = 0x00000004;
    255 
    256     /**
    257      * Flag parameter for {@link #installPackage} to indicate that this
    258      * package has to be installed on the sdcard.
    259      * @hide
    260      */
    261     public static final int INSTALL_EXTERNAL = 0x00000008;
    262 
    263     /**
    264     * Flag parameter for {@link #installPackage} to indicate that this
    265     * package has to be installed on the sdcard.
    266     * @hide
    267     */
    268    public static final int INSTALL_INTERNAL = 0x00000010;
    269 
    270     /**
    271      * Flag parameter for
    272      * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
    273      * that you don't want to kill the app containing the component.  Be careful when you set this
    274      * since changing component states can make the containing application's behavior unpredictable.
    275      */
    276     public static final int DONT_KILL_APP = 0x00000001;
    277 
    278     /**
    279      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    280      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
    281      * @hide
    282      */
    283     public static final int INSTALL_SUCCEEDED = 1;
    284 
    285     /**
    286      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    287      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
    288      * already installed.
    289      * @hide
    290      */
    291     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
    292 
    293     /**
    294      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    295      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
    296      * file is invalid.
    297      * @hide
    298      */
    299     public static final int INSTALL_FAILED_INVALID_APK = -2;
    300 
    301     /**
    302      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    303      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
    304      * is invalid.
    305      * @hide
    306      */
    307     public static final int INSTALL_FAILED_INVALID_URI = -3;
    308 
    309     /**
    310      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    311      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
    312      * service found that the device didn't have enough storage space to install the app.
    313      * @hide
    314      */
    315     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
    316 
    317     /**
    318      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    319      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
    320      * package is already installed with the same name.
    321      * @hide
    322      */
    323     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
    324 
    325     /**
    326      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    327      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    328      * the requested shared user does not exist.
    329      * @hide
    330      */
    331     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
    332 
    333     /**
    334      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    335      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    336      * a previously installed package of the same name has a different signature
    337      * than the new package (and the old package's data was not removed).
    338      * @hide
    339      */
    340     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
    341 
    342     /**
    343      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    344      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    345      * the new package is requested a shared user which is already installed on the
    346      * device and does not have matching signature.
    347      * @hide
    348      */
    349     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
    350 
    351     /**
    352      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    353      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    354      * the new package uses a shared library that is not available.
    355      * @hide
    356      */
    357     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
    358 
    359     /**
    360      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    361      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    362      * the new package uses a shared library that is not available.
    363      * @hide
    364      */
    365     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
    366 
    367     /**
    368      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    369      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    370      * the new package failed while optimizing and validating its dex files,
    371      * either because there was not enough storage or the validation failed.
    372      * @hide
    373      */
    374     public static final int INSTALL_FAILED_DEXOPT = -11;
    375 
    376     /**
    377      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    378      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    379      * the new package failed because the current SDK version is older than
    380      * that required by the package.
    381      * @hide
    382      */
    383     public static final int INSTALL_FAILED_OLDER_SDK = -12;
    384 
    385     /**
    386      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    387      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    388      * the new package failed because it contains a content provider with the
    389      * same authority as a provider already installed in the system.
    390      * @hide
    391      */
    392     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
    393 
    394     /**
    395      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    396      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    397      * the new package failed because the current SDK version is newer than
    398      * that required by the package.
    399      * @hide
    400      */
    401     public static final int INSTALL_FAILED_NEWER_SDK = -14;
    402 
    403     /**
    404      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    405      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    406      * the new package failed because it has specified that it is a test-only
    407      * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
    408      * flag.
    409      * @hide
    410      */
    411     public static final int INSTALL_FAILED_TEST_ONLY = -15;
    412 
    413     /**
    414      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    415      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    416      * the package being installed contains native code, but none that is
    417      * compatible with the the device's CPU_ABI.
    418      * @hide
    419      */
    420     public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
    421 
    422     /**
    423      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    424      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    425      * the new package uses a feature that is not available.
    426      * @hide
    427      */
    428     public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
    429 
    430     // ------ Errors related to sdcard
    431     /**
    432      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    433      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    434      * a secure container mount point couldn't be accessed on external media.
    435      * @hide
    436      */
    437     public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
    438 
    439     /**
    440      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    441      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    442      * the new package couldn't be installed in the specified install
    443      * location.
    444      * @hide
    445      */
    446     public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
    447 
    448     /**
    449      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    450      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    451      * the new package couldn't be installed in the specified install
    452      * location because the media is not available.
    453      * @hide
    454      */
    455     public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
    456 
    457     /**
    458      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    459      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    460      * if the parser was given a path that is not a file, or does not end with the expected
    461      * '.apk' extension.
    462      * @hide
    463      */
    464     public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
    465 
    466     /**
    467      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    468      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    469      * if the parser was unable to retrieve the AndroidManifest.xml file.
    470      * @hide
    471      */
    472     public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
    473 
    474     /**
    475      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    476      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    477      * if the parser encountered an unexpected exception.
    478      * @hide
    479      */
    480     public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
    481 
    482     /**
    483      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    484      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    485      * if the parser did not find any certificates in the .apk.
    486      * @hide
    487      */
    488     public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
    489 
    490     /**
    491      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    492      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    493      * if the parser found inconsistent certificates on the files in the .apk.
    494      * @hide
    495      */
    496     public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
    497 
    498     /**
    499      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    500      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    501      * if the parser encountered a CertificateEncodingException in one of the
    502      * files in the .apk.
    503      * @hide
    504      */
    505     public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
    506 
    507     /**
    508      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    509      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    510      * if the parser encountered a bad or missing package name in the manifest.
    511      * @hide
    512      */
    513     public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
    514 
    515     /**
    516      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    517      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    518      * if the parser encountered a bad shared user id name in the manifest.
    519      * @hide
    520      */
    521     public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
    522 
    523     /**
    524      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    525      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    526      * if the parser encountered some structural problem in the manifest.
    527      * @hide
    528      */
    529     public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
    530 
    531     /**
    532      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    533      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    534      * if the parser did not find any actionable tags (instrumentation or application)
    535      * in the manifest.
    536      * @hide
    537      */
    538     public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
    539 
    540     /**
    541      * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
    542      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    543      * if the system failed to install the package because of system issues.
    544      * @hide
    545      */
    546     public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
    547 
    548     /**
    549      * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
    550      * package's data directory.
    551      *
    552      * @hide
    553      */
    554     public static final int DONT_DELETE_DATA = 0x00000001;
    555 
    556     /**
    557      * Return code that is passed to the {@link IPackageMoveObserver} by
    558      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    559      * when the package has been successfully moved by the system.
    560      * @hide
    561      */
    562     public static final int MOVE_SUCCEEDED = 1;
    563     /**
    564      * Error code that is passed to the {@link IPackageMoveObserver} by
    565      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    566      * when the package hasn't been successfully moved by the system
    567      * because of insufficient memory on specified media.
    568      * @hide
    569      */
    570     public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
    571 
    572     /**
    573      * Error code that is passed to the {@link IPackageMoveObserver} by
    574      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    575      * if the specified package doesn't exist.
    576      * @hide
    577      */
    578     public static final int MOVE_FAILED_DOESNT_EXIST = -2;
    579 
    580     /**
    581      * Error code that is passed to the {@link IPackageMoveObserver} by
    582      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    583      * if the specified package cannot be moved since its a system package.
    584      * @hide
    585      */
    586     public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
    587 
    588     /**
    589      * Error code that is passed to the {@link IPackageMoveObserver} by
    590      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    591      * if the specified package cannot be moved since its forward locked.
    592      * @hide
    593      */
    594     public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
    595 
    596     /**
    597      * Error code that is passed to the {@link IPackageMoveObserver} by
    598      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    599      * if the specified package cannot be moved to the specified location.
    600      * @hide
    601      */
    602     public static final int MOVE_FAILED_INVALID_LOCATION = -5;
    603 
    604     /**
    605      * Error code that is passed to the {@link IPackageMoveObserver} by
    606      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    607      * if the specified package cannot be moved to the specified location.
    608      * @hide
    609      */
    610     public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
    611 
    612     /**
    613      * Flag parameter for {@link #movePackage} to indicate that
    614      * the package should be moved to internal storage if its
    615      * been installed on external media.
    616      * @hide
    617      */
    618     public static final int MOVE_INTERNAL = 0x00000001;
    619 
    620     /**
    621      * Flag parameter for {@link #movePackage} to indicate that
    622      * the package should be moved to external media.
    623      * @hide
    624      */
    625     public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
    626 
    627     /**
    628      * Feature for {@link #getSystemAvailableFeatures} and
    629      * {@link #hasSystemFeature}: The device is capable of communicating with
    630      * other devices via Bluetooth.
    631      */
    632     @SdkConstant(SdkConstantType.FEATURE)
    633     public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
    634 
    635     /**
    636      * Feature for {@link #getSystemAvailableFeatures} and
    637      * {@link #hasSystemFeature}: The device has a camera facing away
    638      * from the screen.
    639      */
    640     @SdkConstant(SdkConstantType.FEATURE)
    641     public static final String FEATURE_CAMERA = "android.hardware.camera";
    642 
    643     /**
    644      * Feature for {@link #getSystemAvailableFeatures} and
    645      * {@link #hasSystemFeature}: The device's camera supports auto-focus.
    646      */
    647     @SdkConstant(SdkConstantType.FEATURE)
    648     public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
    649 
    650     /**
    651      * Feature for {@link #getSystemAvailableFeatures} and
    652      * {@link #hasSystemFeature}: The device's camera supports flash.
    653      */
    654     @SdkConstant(SdkConstantType.FEATURE)
    655     public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
    656 
    657     /**
    658      * Feature for {@link #getSystemAvailableFeatures} and
    659      * {@link #hasSystemFeature}: The device supports one or more methods of
    660      * reporting current location.
    661      */
    662     @SdkConstant(SdkConstantType.FEATURE)
    663     public static final String FEATURE_LOCATION = "android.hardware.location";
    664 
    665     /**
    666      * Feature for {@link #getSystemAvailableFeatures} and
    667      * {@link #hasSystemFeature}: The device has a Global Positioning System
    668      * receiver and can report precise location.
    669      */
    670     @SdkConstant(SdkConstantType.FEATURE)
    671     public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
    672 
    673     /**
    674      * Feature for {@link #getSystemAvailableFeatures} and
    675      * {@link #hasSystemFeature}: The device can report location with coarse
    676      * accuracy using a network-based geolocation system.
    677      */
    678     @SdkConstant(SdkConstantType.FEATURE)
    679     public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
    680 
    681     /**
    682      * Feature for {@link #getSystemAvailableFeatures} and
    683      * {@link #hasSystemFeature}: The device can record audio via a
    684      * microphone.
    685      */
    686     @SdkConstant(SdkConstantType.FEATURE)
    687     public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
    688 
    689     /**
    690      * Feature for {@link #getSystemAvailableFeatures} and
    691      * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
    692      */
    693     @SdkConstant(SdkConstantType.FEATURE)
    694     public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
    695 
    696     /**
    697      * Feature for {@link #getSystemAvailableFeatures} and
    698      * {@link #hasSystemFeature}: The device includes an accelerometer.
    699      */
    700     @SdkConstant(SdkConstantType.FEATURE)
    701     public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
    702 
    703     /**
    704      * Feature for {@link #getSystemAvailableFeatures} and
    705      * {@link #hasSystemFeature}: The device includes a light sensor.
    706      */
    707     @SdkConstant(SdkConstantType.FEATURE)
    708     public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
    709 
    710     /**
    711      * Feature for {@link #getSystemAvailableFeatures} and
    712      * {@link #hasSystemFeature}: The device includes a proximity sensor.
    713      */
    714     @SdkConstant(SdkConstantType.FEATURE)
    715     public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
    716 
    717     /**
    718      * Feature for {@link #getSystemAvailableFeatures} and
    719      * {@link #hasSystemFeature}: The device has a telephony radio with data
    720      * communication support.
    721      */
    722     @SdkConstant(SdkConstantType.FEATURE)
    723     public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
    724 
    725     /**
    726      * Feature for {@link #getSystemAvailableFeatures} and
    727      * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
    728      */
    729     @SdkConstant(SdkConstantType.FEATURE)
    730     public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
    731 
    732     /**
    733      * Feature for {@link #getSystemAvailableFeatures} and
    734      * {@link #hasSystemFeature}: The device has a GSM telephony stack.
    735      */
    736     @SdkConstant(SdkConstantType.FEATURE)
    737     public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
    738 
    739     /**
    740      * Feature for {@link #getSystemAvailableFeatures} and
    741      * {@link #hasSystemFeature}: The device's display has a touch screen.
    742      */
    743     @SdkConstant(SdkConstantType.FEATURE)
    744     public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
    745 
    746 
    747     /**
    748      * Feature for {@link #getSystemAvailableFeatures} and
    749      * {@link #hasSystemFeature}: The device's touch screen supports
    750      * multitouch sufficient for basic two-finger gesture detection.
    751      */
    752     @SdkConstant(SdkConstantType.FEATURE)
    753     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
    754 
    755     /**
    756      * Feature for {@link #getSystemAvailableFeatures} and
    757      * {@link #hasSystemFeature}: The device's touch screen is capable of
    758      * tracking two or more fingers fully independently.
    759      */
    760     @SdkConstant(SdkConstantType.FEATURE)
    761     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
    762 
    763     /**
    764      * Feature for {@link #getSystemAvailableFeatures} and
    765      * {@link #hasSystemFeature}: The device supports live wallpapers.
    766      */
    767     @SdkConstant(SdkConstantType.FEATURE)
    768     public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
    769 
    770     /**
    771      * Feature for {@link #getSystemAvailableFeatures} and
    772      * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
    773      */
    774     @SdkConstant(SdkConstantType.FEATURE)
    775     public static final String FEATURE_WIFI = "android.hardware.wifi";
    776 
    777     /**
    778      * Action to external storage service to clean out removed apps.
    779      * @hide
    780      */
    781     public static final String ACTION_CLEAN_EXTERNAL_STORAGE
    782             = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
    783 
    784     /**
    785      * Retrieve overall information about an application package that is
    786      * installed on the system.
    787      *
    788      * <p>Throws {@link NameNotFoundException} if a package with the given
    789      * name can not be found on the system.
    790      *
    791      * @param packageName The full name (i.e. com.google.apps.contacts) of the
    792      *                    desired package.
    793 
    794      * @param flags Additional option flags. Use any combination of
    795      * {@link #GET_ACTIVITIES},
    796      * {@link #GET_GIDS},
    797      * {@link #GET_CONFIGURATIONS},
    798      * {@link #GET_INSTRUMENTATION},
    799      * {@link #GET_PERMISSIONS},
    800      * {@link #GET_PROVIDERS},
    801      * {@link #GET_RECEIVERS},
    802      * {@link #GET_SERVICES},
    803      * {@link #GET_SIGNATURES},
    804      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
    805      *
    806      * @return Returns a PackageInfo object containing information about the package.
    807      *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
    808      *         found in the list of installed applications, the package information is
    809      *         retrieved from the list of uninstalled applications(which includes
    810      *         installed applications as well as applications
    811      *         with data directory ie applications which had been
    812      *         deleted with DONT_DELTE_DATA flag set).
    813      *
    814      * @see #GET_ACTIVITIES
    815      * @see #GET_GIDS
    816      * @see #GET_CONFIGURATIONS
    817      * @see #GET_INSTRUMENTATION
    818      * @see #GET_PERMISSIONS
    819      * @see #GET_PROVIDERS
    820      * @see #GET_RECEIVERS
    821      * @see #GET_SERVICES
    822      * @see #GET_SIGNATURES
    823      * @see #GET_UNINSTALLED_PACKAGES
    824      *
    825      */
    826     public abstract PackageInfo getPackageInfo(String packageName, int flags)
    827             throws NameNotFoundException;
    828 
    829     /**
    830      * Map from the current package names in use on the device to whatever
    831      * the current canonical name of that package is.
    832      * @param names Array of current names to be mapped.
    833      * @return Returns an array of the same size as the original, containing
    834      * the canonical name for each package.
    835      */
    836     public abstract String[] currentToCanonicalPackageNames(String[] names);
    837 
    838     /**
    839      * Map from a packages canonical name to the current name in use on the device.
    840      * @param names Array of new names to be mapped.
    841      * @return Returns an array of the same size as the original, containing
    842      * the current name for each package.
    843      */
    844     public abstract String[] canonicalToCurrentPackageNames(String[] names);
    845 
    846     /**
    847      * Return a "good" intent to launch a front-door activity in a package,
    848      * for use for example to implement an "open" button when browsing through
    849      * packages.  The current implementation will look first for a main
    850      * activity in the category {@link Intent#CATEGORY_INFO}, next for a
    851      * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
    852      * null if neither are found.
    853      *
    854      * <p>Throws {@link NameNotFoundException} if a package with the given
    855      * name can not be found on the system.
    856      *
    857      * @param packageName The name of the package to inspect.
    858      *
    859      * @return Returns either a fully-qualified Intent that can be used to
    860      * launch the main activity in the package, or null if the package does
    861      * not contain such an activity.
    862      */
    863     public abstract Intent getLaunchIntentForPackage(String packageName);
    864 
    865     /**
    866      * Return an array of all of the secondary group-ids that have been
    867      * assigned to a package.
    868      *
    869      * <p>Throws {@link NameNotFoundException} if a package with the given
    870      * name can not be found on the system.
    871      *
    872      * @param packageName The full name (i.e. com.google.apps.contacts) of the
    873      *                    desired package.
    874      *
    875      * @return Returns an int array of the assigned gids, or null if there
    876      * are none.
    877      */
    878     public abstract int[] getPackageGids(String packageName)
    879             throws NameNotFoundException;
    880 
    881     /**
    882      * Retrieve all of the information we know about a particular permission.
    883      *
    884      * <p>Throws {@link NameNotFoundException} if a permission with the given
    885      * name can not be found on the system.
    886      *
    887      * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
    888      *             of the permission you are interested in.
    889      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
    890      * retrieve any meta-data associated with the permission.
    891      *
    892      * @return Returns a {@link PermissionInfo} containing information about the
    893      *         permission.
    894      */
    895     public abstract PermissionInfo getPermissionInfo(String name, int flags)
    896             throws NameNotFoundException;
    897 
    898     /**
    899      * Query for all of the permissions associated with a particular group.
    900      *
    901      * <p>Throws {@link NameNotFoundException} if the given group does not
    902      * exist.
    903      *
    904      * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
    905      *             of the permission group you are interested in.  Use null to
    906      *             find all of the permissions not associated with a group.
    907      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
    908      * retrieve any meta-data associated with the permissions.
    909      *
    910      * @return Returns a list of {@link PermissionInfo} containing information
    911      * about all of the permissions in the given group.
    912      */
    913     public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
    914             int flags) throws NameNotFoundException;
    915 
    916     /**
    917      * Retrieve all of the information we know about a particular group of
    918      * permissions.
    919      *
    920      * <p>Throws {@link NameNotFoundException} if a permission group with the given
    921      * name can not be found on the system.
    922      *
    923      * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
    924      *             of the permission you are interested in.
    925      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
    926      * retrieve any meta-data associated with the permission group.
    927      *
    928      * @return Returns a {@link PermissionGroupInfo} containing information
    929      * about the permission.
    930      */
    931     public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
    932             int flags) throws NameNotFoundException;
    933 
    934     /**
    935      * Retrieve all of the known permission groups in the system.
    936      *
    937      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
    938      * retrieve any meta-data associated with the permission group.
    939      *
    940      * @return Returns a list of {@link PermissionGroupInfo} containing
    941      * information about all of the known permission groups.
    942      */
    943     public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
    944 
    945     /**
    946      * Retrieve all of the information we know about a particular
    947      * package/application.
    948      *
    949      * <p>Throws {@link NameNotFoundException} if an application with the given
    950      * package name can not be found on the system.
    951      *
    952      * @param packageName The full name (i.e. com.google.apps.contacts) of an
    953      *                    application.
    954      * @param flags Additional option flags. Use any combination of
    955      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
    956      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
    957      *
    958      * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
    959      *         information about the package.
    960      *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
    961      *         found in the list of installed applications,
    962      *         the application information is retrieved from the
    963      *         list of uninstalled applications(which includes
    964      *         installed applications as well as applications
    965      *         with data directory ie applications which had been
    966      *         deleted with DONT_DELTE_DATA flag set).
    967      *
    968      * @see #GET_META_DATA
    969      * @see #GET_SHARED_LIBRARY_FILES
    970      * @see #GET_UNINSTALLED_PACKAGES
    971      */
    972     public abstract ApplicationInfo getApplicationInfo(String packageName,
    973             int flags) throws NameNotFoundException;
    974 
    975     /**
    976      * Retrieve all of the information we know about a particular activity
    977      * class.
    978      *
    979      * <p>Throws {@link NameNotFoundException} if an activity with the given
    980      * class name can not be found on the system.
    981      *
    982      * @param className The full name (i.e.
    983      *                  com.google.apps.contacts.ContactsList) of an Activity
    984      *                  class.
    985      * @param flags Additional option flags. Use any combination of
    986      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
    987      * to modify the data (in ApplicationInfo) returned.
    988      *
    989      * @return {@link ActivityInfo} containing information about the activity.
    990      *
    991      * @see #GET_INTENT_FILTERS
    992      * @see #GET_META_DATA
    993      * @see #GET_SHARED_LIBRARY_FILES
    994      */
    995     public abstract ActivityInfo getActivityInfo(ComponentName className,
    996             int flags) throws NameNotFoundException;
    997 
    998     /**
    999      * Retrieve all of the information we know about a particular receiver
   1000      * class.
   1001      *
   1002      * <p>Throws {@link NameNotFoundException} if a receiver with the given
   1003      * class name can not be found on the system.
   1004      *
   1005      * @param className The full name (i.e.
   1006      *                  com.google.apps.contacts.CalendarAlarm) of a Receiver
   1007      *                  class.
   1008      * @param flags Additional option flags.  Use any combination of
   1009      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1010      * to modify the data returned.
   1011      *
   1012      * @return {@link ActivityInfo} containing information about the receiver.
   1013      *
   1014      * @see #GET_INTENT_FILTERS
   1015      * @see #GET_META_DATA
   1016      * @see #GET_SHARED_LIBRARY_FILES
   1017      */
   1018     public abstract ActivityInfo getReceiverInfo(ComponentName className,
   1019             int flags) throws NameNotFoundException;
   1020 
   1021     /**
   1022      * Retrieve all of the information we know about a particular service
   1023      * class.
   1024      *
   1025      * <p>Throws {@link NameNotFoundException} if a service with the given
   1026      * class name can not be found on the system.
   1027      *
   1028      * @param className The full name (i.e.
   1029      *                  com.google.apps.media.BackgroundPlayback) of a Service
   1030      *                  class.
   1031      * @param flags Additional option flags.  Use any combination of
   1032      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1033      * to modify the data returned.
   1034      *
   1035      * @return ServiceInfo containing information about the service.
   1036      *
   1037      * @see #GET_META_DATA
   1038      * @see #GET_SHARED_LIBRARY_FILES
   1039      */
   1040     public abstract ServiceInfo getServiceInfo(ComponentName className,
   1041             int flags) throws NameNotFoundException;
   1042 
   1043     /**
   1044      * Return a List of all packages that are installed
   1045      * on the device.
   1046      *
   1047      * @param flags Additional option flags. Use any combination of
   1048      * {@link #GET_ACTIVITIES},
   1049      * {@link #GET_GIDS},
   1050      * {@link #GET_CONFIGURATIONS},
   1051      * {@link #GET_INSTRUMENTATION},
   1052      * {@link #GET_PERMISSIONS},
   1053      * {@link #GET_PROVIDERS},
   1054      * {@link #GET_RECEIVERS},
   1055      * {@link #GET_SERVICES},
   1056      * {@link #GET_SIGNATURES},
   1057      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   1058      *
   1059      * @return A List of PackageInfo objects, one for each package that is
   1060      *         installed on the device.  In the unlikely case of there being no
   1061      *         installed packages, an empty list is returned.
   1062      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
   1063      *         applications including those deleted with DONT_DELETE_DATA
   1064      *         (partially installed apps with data directory) will be returned.
   1065      *
   1066      * @see #GET_ACTIVITIES
   1067      * @see #GET_GIDS
   1068      * @see #GET_CONFIGURATIONS
   1069      * @see #GET_INSTRUMENTATION
   1070      * @see #GET_PERMISSIONS
   1071      * @see #GET_PROVIDERS
   1072      * @see #GET_RECEIVERS
   1073      * @see #GET_SERVICES
   1074      * @see #GET_SIGNATURES
   1075      * @see #GET_UNINSTALLED_PACKAGES
   1076      *
   1077      */
   1078     public abstract List<PackageInfo> getInstalledPackages(int flags);
   1079 
   1080     /**
   1081      * Check whether a particular package has been granted a particular
   1082      * permission.
   1083      *
   1084      * @param permName The name of the permission you are checking for,
   1085      * @param pkgName The name of the package you are checking against.
   1086      *
   1087      * @return If the package has the permission, PERMISSION_GRANTED is
   1088      * returned.  If it does not have the permission, PERMISSION_DENIED
   1089      * is returned.
   1090      *
   1091      * @see #PERMISSION_GRANTED
   1092      * @see #PERMISSION_DENIED
   1093      */
   1094     public abstract int checkPermission(String permName, String pkgName);
   1095 
   1096     /**
   1097      * Add a new dynamic permission to the system.  For this to work, your
   1098      * package must have defined a permission tree through the
   1099      * {@link android.R.styleable#AndroidManifestPermissionTree
   1100      * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
   1101      * permissions to trees that were defined by either its own package or
   1102      * another with the same user id; a permission is in a tree if it
   1103      * matches the name of the permission tree + ".": for example,
   1104      * "com.foo.bar" is a member of the permission tree "com.foo".
   1105      *
   1106      * <p>It is good to make your permission tree name descriptive, because you
   1107      * are taking possession of that entire set of permission names.  Thus, it
   1108      * must be under a domain you control, with a suffix that will not match
   1109      * any normal permissions that may be declared in any applications that
   1110      * are part of that domain.
   1111      *
   1112      * <p>New permissions must be added before
   1113      * any .apks are installed that use those permissions.  Permissions you
   1114      * add through this method are remembered across reboots of the device.
   1115      * If the given permission already exists, the info you supply here
   1116      * will be used to update it.
   1117      *
   1118      * @param info Description of the permission to be added.
   1119      *
   1120      * @return Returns true if a new permission was created, false if an
   1121      * existing one was updated.
   1122      *
   1123      * @throws SecurityException if you are not allowed to add the
   1124      * given permission name.
   1125      *
   1126      * @see #removePermission(String)
   1127      */
   1128     public abstract boolean addPermission(PermissionInfo info);
   1129 
   1130     /**
   1131      * Like {@link #addPermission(PermissionInfo)} but asynchronously
   1132      * persists the package manager state after returning from the call,
   1133      * allowing it to return quicker and batch a series of adds at the
   1134      * expense of no guarantee the added permission will be retained if
   1135      * the device is rebooted before it is written.
   1136      */
   1137     public abstract boolean addPermissionAsync(PermissionInfo info);
   1138 
   1139     /**
   1140      * Removes a permission that was previously added with
   1141      * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
   1142      * -- you are only allowed to remove permissions that you are allowed
   1143      * to add.
   1144      *
   1145      * @param name The name of the permission to remove.
   1146      *
   1147      * @throws SecurityException if you are not allowed to remove the
   1148      * given permission name.
   1149      *
   1150      * @see #addPermission(PermissionInfo)
   1151      */
   1152     public abstract void removePermission(String name);
   1153 
   1154     /**
   1155      * Compare the signatures of two packages to determine if the same
   1156      * signature appears in both of them.  If they do contain the same
   1157      * signature, then they are allowed special privileges when working
   1158      * with each other: they can share the same user-id, run instrumentation
   1159      * against each other, etc.
   1160      *
   1161      * @param pkg1 First package name whose signature will be compared.
   1162      * @param pkg2 Second package name whose signature will be compared.
   1163      * @return Returns an integer indicating whether there is a matching
   1164      * signature: the value is >= 0 if there is a match (or neither package
   1165      * is signed), or < 0 if there is not a match.  The match result can be
   1166      * further distinguished with the success (>= 0) constants
   1167      * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or
   1168      * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED},
   1169      * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH},
   1170      * or {@link #SIGNATURE_UNKNOWN_PACKAGE}.
   1171      *
   1172      * @see #checkSignatures(int, int)
   1173      * @see #SIGNATURE_MATCH
   1174      * @see #SIGNATURE_NEITHER_SIGNED
   1175      * @see #SIGNATURE_FIRST_NOT_SIGNED
   1176      * @see #SIGNATURE_SECOND_NOT_SIGNED
   1177      * @see #SIGNATURE_NO_MATCH
   1178      * @see #SIGNATURE_UNKNOWN_PACKAGE
   1179      */
   1180     public abstract int checkSignatures(String pkg1, String pkg2);
   1181 
   1182     /**
   1183      * Like {@link #checkSignatures(String, String)}, but takes UIDs of
   1184      * the two packages to be checked.  This can be useful, for example,
   1185      * when doing the check in an IPC, where the UID is the only identity
   1186      * available.  It is functionally identical to determining the package
   1187      * associated with the UIDs and checking their signatures.
   1188      *
   1189      * @param uid1 First UID whose signature will be compared.
   1190      * @param uid2 Second UID whose signature will be compared.
   1191      * @return Returns an integer indicating whether there is a matching
   1192      * signature: the value is >= 0 if there is a match (or neither package
   1193      * is signed), or < 0 if there is not a match.  The match result can be
   1194      * further distinguished with the success (>= 0) constants
   1195      * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or
   1196      * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED},
   1197      * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH},
   1198      * or {@link #SIGNATURE_UNKNOWN_PACKAGE}.
   1199      *
   1200      * @see #checkSignatures(int, int)
   1201      * @see #SIGNATURE_MATCH
   1202      * @see #SIGNATURE_NEITHER_SIGNED
   1203      * @see #SIGNATURE_FIRST_NOT_SIGNED
   1204      * @see #SIGNATURE_SECOND_NOT_SIGNED
   1205      * @see #SIGNATURE_NO_MATCH
   1206      * @see #SIGNATURE_UNKNOWN_PACKAGE
   1207      */
   1208     public abstract int checkSignatures(int uid1, int uid2);
   1209 
   1210     /**
   1211      * Retrieve the names of all packages that are associated with a particular
   1212      * user id.  In most cases, this will be a single package name, the package
   1213      * that has been assigned that user id.  Where there are multiple packages
   1214      * sharing the same user id through the "sharedUserId" mechanism, all
   1215      * packages with that id will be returned.
   1216      *
   1217      * @param uid The user id for which you would like to retrieve the
   1218      * associated packages.
   1219      *
   1220      * @return Returns an array of one or more packages assigned to the user
   1221      * id, or null if there are no known packages with the given id.
   1222      */
   1223     public abstract String[] getPackagesForUid(int uid);
   1224 
   1225     /**
   1226      * Retrieve the official name associated with a user id.  This name is
   1227      * guaranteed to never change, though it is possibly for the underlying
   1228      * user id to be changed.  That is, if you are storing information about
   1229      * user ids in persistent storage, you should use the string returned
   1230      * by this function instead of the raw user-id.
   1231      *
   1232      * @param uid The user id for which you would like to retrieve a name.
   1233      * @return Returns a unique name for the given user id, or null if the
   1234      * user id is not currently assigned.
   1235      */
   1236     public abstract String getNameForUid(int uid);
   1237 
   1238     /**
   1239      * Return the user id associated with a shared user name. Multiple
   1240      * applications can specify a shared user name in their manifest and thus
   1241      * end up using a common uid. This might be used for new applications
   1242      * that use an existing shared user name and need to know the uid of the
   1243      * shared user.
   1244      *
   1245      * @param sharedUserName The shared user name whose uid is to be retrieved.
   1246      * @return Returns the uid associated with the shared user, or  NameNotFoundException
   1247      * if the shared user name is not being used by any installed packages
   1248      * @hide
   1249      */
   1250     public abstract int getUidForSharedUser(String sharedUserName)
   1251             throws NameNotFoundException;
   1252 
   1253     /**
   1254      * Return a List of all application packages that are installed on the
   1255      * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
   1256      * applications including those deleted with DONT_DELETE_DATA(partially
   1257      * installed apps with data directory) will be returned.
   1258      *
   1259      * @param flags Additional option flags. Use any combination of
   1260      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   1261      * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   1262      *
   1263      * @return A List of ApplicationInfo objects, one for each application that
   1264      *         is installed on the device.  In the unlikely case of there being
   1265      *         no installed applications, an empty list is returned.
   1266      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
   1267      *         applications including those deleted with DONT_DELETE_DATA
   1268      *         (partially installed apps with data directory) will be returned.
   1269      *
   1270      * @see #GET_META_DATA
   1271      * @see #GET_SHARED_LIBRARY_FILES
   1272      * @see #GET_UNINSTALLED_PACKAGES
   1273      */
   1274     public abstract List<ApplicationInfo> getInstalledApplications(int flags);
   1275 
   1276     /**
   1277      * Get a list of shared libraries that are available on the
   1278      * system.
   1279      *
   1280      * @return An array of shared library names that are
   1281      * available on the system, or null if none are installed.
   1282      *
   1283      */
   1284     public abstract String[] getSystemSharedLibraryNames();
   1285 
   1286     /**
   1287      * Get a list of features that are available on the
   1288      * system.
   1289      *
   1290      * @return An array of FeatureInfo classes describing the features
   1291      * that are available on the system, or null if there are none(!!).
   1292      */
   1293     public abstract FeatureInfo[] getSystemAvailableFeatures();
   1294 
   1295     /**
   1296      * Check whether the given feature name is one of the available
   1297      * features as returned by {@link #getSystemAvailableFeatures()}.
   1298      *
   1299      * @return Returns true if the devices supports the feature, else
   1300      * false.
   1301      */
   1302     public abstract boolean hasSystemFeature(String name);
   1303 
   1304     /**
   1305      * Determine the best action to perform for a given Intent.  This is how
   1306      * {@link Intent#resolveActivity} finds an activity if a class has not
   1307      * been explicitly specified.
   1308      *
   1309      * @param intent An intent containing all of the desired specification
   1310      *               (action, data, type, category, and/or component).
   1311      * @param flags Additional option flags.  The most important is
   1312      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
   1313      *                    those activities that support the CATEGORY_DEFAULT.
   1314      *
   1315      * @return Returns a ResolveInfo containing the final activity intent that
   1316      *         was determined to be the best action.  Returns null if no
   1317      *         matching activity was found. If multiple matching activities are
   1318      *         found and there is no default set, returns a ResolveInfo
   1319      *         containing something else, such as the activity resolver.
   1320      *
   1321      * @see #MATCH_DEFAULT_ONLY
   1322      * @see #GET_INTENT_FILTERS
   1323      * @see #GET_RESOLVED_FILTER
   1324      */
   1325     public abstract ResolveInfo resolveActivity(Intent intent, int flags);
   1326 
   1327     /**
   1328      * Retrieve all activities that can be performed for the given intent.
   1329      *
   1330      * @param intent The desired intent as per resolveActivity().
   1331      * @param flags Additional option flags.  The most important is
   1332      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
   1333      *                    those activities that support the CATEGORY_DEFAULT.
   1334      *
   1335      * @return A List<ResolveInfo> containing one entry for each matching
   1336      *         Activity. These are ordered from best to worst match -- that
   1337      *         is, the first item in the list is what is returned by
   1338      *         resolveActivity().  If there are no matching activities, an empty
   1339      *         list is returned.
   1340      *
   1341      * @see #MATCH_DEFAULT_ONLY
   1342      * @see #GET_INTENT_FILTERS
   1343      * @see #GET_RESOLVED_FILTER
   1344      */
   1345     public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
   1346             int flags);
   1347 
   1348     /**
   1349      * Retrieve a set of activities that should be presented to the user as
   1350      * similar options.  This is like {@link #queryIntentActivities}, except it
   1351      * also allows you to supply a list of more explicit Intents that you would
   1352      * like to resolve to particular options, and takes care of returning the
   1353      * final ResolveInfo list in a reasonable order, with no duplicates, based
   1354      * on those inputs.
   1355      *
   1356      * @param caller The class name of the activity that is making the
   1357      *               request.  This activity will never appear in the output
   1358      *               list.  Can be null.
   1359      * @param specifics An array of Intents that should be resolved to the
   1360      *                  first specific results.  Can be null.
   1361      * @param intent The desired intent as per resolveActivity().
   1362      * @param flags Additional option flags.  The most important is
   1363      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
   1364      *                    those activities that support the CATEGORY_DEFAULT.
   1365      *
   1366      * @return A List<ResolveInfo> containing one entry for each matching
   1367      *         Activity. These are ordered first by all of the intents resolved
   1368      *         in <var>specifics</var> and then any additional activities that
   1369      *         can handle <var>intent</var> but did not get included by one of
   1370      *         the <var>specifics</var> intents.  If there are no matching
   1371      *         activities, an empty list is returned.
   1372      *
   1373      * @see #MATCH_DEFAULT_ONLY
   1374      * @see #GET_INTENT_FILTERS
   1375      * @see #GET_RESOLVED_FILTER
   1376      */
   1377     public abstract List<ResolveInfo> queryIntentActivityOptions(
   1378             ComponentName caller, Intent[] specifics, Intent intent, int flags);
   1379 
   1380     /**
   1381      * Retrieve all receivers that can handle a broadcast of the given intent.
   1382      *
   1383      * @param intent The desired intent as per resolveActivity().
   1384      * @param flags Additional option flags.  The most important is
   1385      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
   1386      *                    those activities that support the CATEGORY_DEFAULT.
   1387      *
   1388      * @return A List<ResolveInfo> containing one entry for each matching
   1389      *         Receiver. These are ordered from first to last in priority.  If
   1390      *         there are no matching receivers, an empty list is returned.
   1391      *
   1392      * @see #MATCH_DEFAULT_ONLY
   1393      * @see #GET_INTENT_FILTERS
   1394      * @see #GET_RESOLVED_FILTER
   1395      */
   1396     public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
   1397             int flags);
   1398 
   1399     /**
   1400      * Determine the best service to handle for a given Intent.
   1401      *
   1402      * @param intent An intent containing all of the desired specification
   1403      *               (action, data, type, category, and/or component).
   1404      * @param flags Additional option flags.
   1405      *
   1406      * @return Returns a ResolveInfo containing the final service intent that
   1407      *         was determined to be the best action.  Returns null if no
   1408      *         matching service was found.
   1409      *
   1410      * @see #GET_INTENT_FILTERS
   1411      * @see #GET_RESOLVED_FILTER
   1412      */
   1413     public abstract ResolveInfo resolveService(Intent intent, int flags);
   1414 
   1415     /**
   1416      * Retrieve all services that can match the given intent.
   1417      *
   1418      * @param intent The desired intent as per resolveService().
   1419      * @param flags Additional option flags.
   1420      *
   1421      * @return A List<ResolveInfo> containing one entry for each matching
   1422      *         ServiceInfo. These are ordered from best to worst match -- that
   1423      *         is, the first item in the list is what is returned by
   1424      *         resolveService().  If there are no matching services, an empty
   1425      *         list is returned.
   1426      *
   1427      * @see #GET_INTENT_FILTERS
   1428      * @see #GET_RESOLVED_FILTER
   1429      */
   1430     public abstract List<ResolveInfo> queryIntentServices(Intent intent,
   1431             int flags);
   1432 
   1433     /**
   1434      * Find a single content provider by its base path name.
   1435      *
   1436      * @param name The name of the provider to find.
   1437      * @param flags Additional option flags.  Currently should always be 0.
   1438      *
   1439      * @return ContentProviderInfo Information about the provider, if found,
   1440      *         else null.
   1441      */
   1442     public abstract ProviderInfo resolveContentProvider(String name,
   1443             int flags);
   1444 
   1445     /**
   1446      * Retrieve content provider information.
   1447      *
   1448      * <p><em>Note: unlike most other methods, an empty result set is indicated
   1449      * by a null return instead of an empty list.</em>
   1450      *
   1451      * @param processName If non-null, limits the returned providers to only
   1452      *                    those that are hosted by the given process.  If null,
   1453      *                    all content providers are returned.
   1454      * @param uid If <var>processName</var> is non-null, this is the required
   1455      *        uid owning the requested content providers.
   1456      * @param flags Additional option flags.  Currently should always be 0.
   1457      *
   1458      * @return A List<ContentProviderInfo> containing one entry for each
   1459      *         content provider either patching <var>processName</var> or, if
   1460      *         <var>processName</var> is null, all known content providers.
   1461      *         <em>If there are no matching providers, null is returned.</em>
   1462      */
   1463     public abstract List<ProviderInfo> queryContentProviders(
   1464             String processName, int uid, int flags);
   1465 
   1466     /**
   1467      * Retrieve all of the information we know about a particular
   1468      * instrumentation class.
   1469      *
   1470      * <p>Throws {@link NameNotFoundException} if instrumentation with the
   1471      * given class name can not be found on the system.
   1472      *
   1473      * @param className The full name (i.e.
   1474      *                  com.google.apps.contacts.InstrumentList) of an
   1475      *                  Instrumentation class.
   1476      * @param flags Additional option flags.  Currently should always be 0.
   1477      *
   1478      * @return InstrumentationInfo containing information about the
   1479      *         instrumentation.
   1480      */
   1481     public abstract InstrumentationInfo getInstrumentationInfo(
   1482             ComponentName className, int flags) throws NameNotFoundException;
   1483 
   1484     /**
   1485      * Retrieve information about available instrumentation code.  May be used
   1486      * to retrieve either all instrumentation code, or only the code targeting
   1487      * a particular package.
   1488      *
   1489      * @param targetPackage If null, all instrumentation is returned; only the
   1490      *                      instrumentation targeting this package name is
   1491      *                      returned.
   1492      * @param flags Additional option flags.  Currently should always be 0.
   1493      *
   1494      * @return A List<InstrumentationInfo> containing one entry for each
   1495      *         matching available Instrumentation.  Returns an empty list if
   1496      *         there is no instrumentation available for the given package.
   1497      */
   1498     public abstract List<InstrumentationInfo> queryInstrumentation(
   1499             String targetPackage, int flags);
   1500 
   1501     /**
   1502      * Retrieve an image from a package.  This is a low-level API used by
   1503      * the various package manager info structures (such as
   1504      * {@link ComponentInfo} to implement retrieval of their associated
   1505      * icon.
   1506      *
   1507      * @param packageName The name of the package that this icon is coming from.
   1508      * Can not be null.
   1509      * @param resid The resource identifier of the desired image.  Can not be 0.
   1510      * @param appInfo Overall information about <var>packageName</var>.  This
   1511      * may be null, in which case the application information will be retrieved
   1512      * for you if needed; if you already have this information around, it can
   1513      * be much more efficient to supply it here.
   1514      *
   1515      * @return Returns a Drawable holding the requested image.  Returns null if
   1516      * an image could not be found for any reason.
   1517      */
   1518     public abstract Drawable getDrawable(String packageName, int resid,
   1519             ApplicationInfo appInfo);
   1520 
   1521     /**
   1522      * Retrieve the icon associated with an activity.  Given the full name of
   1523      * an activity, retrieves the information about it and calls
   1524      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
   1525      * If the activity can not be found, NameNotFoundException is thrown.
   1526      *
   1527      * @param activityName Name of the activity whose icon is to be retrieved.
   1528      *
   1529      * @return Returns the image of the icon, or the default activity icon if
   1530      * it could not be found.  Does not return null.
   1531      * @throws NameNotFoundException Thrown if the resources for the given
   1532      * activity could not be loaded.
   1533      *
   1534      * @see #getActivityIcon(Intent)
   1535      */
   1536     public abstract Drawable getActivityIcon(ComponentName activityName)
   1537             throws NameNotFoundException;
   1538 
   1539     /**
   1540      * Retrieve the icon associated with an Intent.  If intent.getClassName() is
   1541      * set, this simply returns the result of
   1542      * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
   1543      * component and returns the icon associated with the resolved component.
   1544      * If intent.getClassName() can not be found or the Intent can not be resolved
   1545      * to a component, NameNotFoundException is thrown.
   1546      *
   1547      * @param intent The intent for which you would like to retrieve an icon.
   1548      *
   1549      * @return Returns the image of the icon, or the default activity icon if
   1550      * it could not be found.  Does not return null.
   1551      * @throws NameNotFoundException Thrown if the resources for application
   1552      * matching the given intent could not be loaded.
   1553      *
   1554      * @see #getActivityIcon(ComponentName)
   1555      */
   1556     public abstract Drawable getActivityIcon(Intent intent)
   1557             throws NameNotFoundException;
   1558 
   1559     /**
   1560      * Return the generic icon for an activity that is used when no specific
   1561      * icon is defined.
   1562      *
   1563      * @return Drawable Image of the icon.
   1564      */
   1565     public abstract Drawable getDefaultActivityIcon();
   1566 
   1567     /**
   1568      * Retrieve the icon associated with an application.  If it has not defined
   1569      * an icon, the default app icon is returned.  Does not return null.
   1570      *
   1571      * @param info Information about application being queried.
   1572      *
   1573      * @return Returns the image of the icon, or the default application icon
   1574      * if it could not be found.
   1575      *
   1576      * @see #getApplicationIcon(String)
   1577      */
   1578     public abstract Drawable getApplicationIcon(ApplicationInfo info);
   1579 
   1580     /**
   1581      * Retrieve the icon associated with an application.  Given the name of the
   1582      * application's package, retrieves the information about it and calls
   1583      * getApplicationIcon() to return its icon. If the application can not be
   1584      * found, NameNotFoundException is thrown.
   1585      *
   1586      * @param packageName Name of the package whose application icon is to be
   1587      *                    retrieved.
   1588      *
   1589      * @return Returns the image of the icon, or the default application icon
   1590      * if it could not be found.  Does not return null.
   1591      * @throws NameNotFoundException Thrown if the resources for the given
   1592      * application could not be loaded.
   1593      *
   1594      * @see #getApplicationIcon(ApplicationInfo)
   1595      */
   1596     public abstract Drawable getApplicationIcon(String packageName)
   1597             throws NameNotFoundException;
   1598 
   1599     /**
   1600      * Retrieve text from a package.  This is a low-level API used by
   1601      * the various package manager info structures (such as
   1602      * {@link ComponentInfo} to implement retrieval of their associated
   1603      * labels and other text.
   1604      *
   1605      * @param packageName The name of the package that this text is coming from.
   1606      * Can not be null.
   1607      * @param resid The resource identifier of the desired text.  Can not be 0.
   1608      * @param appInfo Overall information about <var>packageName</var>.  This
   1609      * may be null, in which case the application information will be retrieved
   1610      * for you if needed; if you already have this information around, it can
   1611      * be much more efficient to supply it here.
   1612      *
   1613      * @return Returns a CharSequence holding the requested text.  Returns null
   1614      * if the text could not be found for any reason.
   1615      */
   1616     public abstract CharSequence getText(String packageName, int resid,
   1617             ApplicationInfo appInfo);
   1618 
   1619     /**
   1620      * Retrieve an XML file from a package.  This is a low-level API used to
   1621      * retrieve XML meta data.
   1622      *
   1623      * @param packageName The name of the package that this xml is coming from.
   1624      * Can not be null.
   1625      * @param resid The resource identifier of the desired xml.  Can not be 0.
   1626      * @param appInfo Overall information about <var>packageName</var>.  This
   1627      * may be null, in which case the application information will be retrieved
   1628      * for you if needed; if you already have this information around, it can
   1629      * be much more efficient to supply it here.
   1630      *
   1631      * @return Returns an XmlPullParser allowing you to parse out the XML
   1632      * data.  Returns null if the xml resource could not be found for any
   1633      * reason.
   1634      */
   1635     public abstract XmlResourceParser getXml(String packageName, int resid,
   1636             ApplicationInfo appInfo);
   1637 
   1638     /**
   1639      * Return the label to use for this application.
   1640      *
   1641      * @return Returns the label associated with this application, or null if
   1642      * it could not be found for any reason.
   1643      * @param info The application to get the label of
   1644      */
   1645     public abstract CharSequence getApplicationLabel(ApplicationInfo info);
   1646 
   1647     /**
   1648      * Retrieve the resources associated with an activity.  Given the full
   1649      * name of an activity, retrieves the information about it and calls
   1650      * getResources() to return its application's resources.  If the activity
   1651      * can not be found, NameNotFoundException is thrown.
   1652      *
   1653      * @param activityName Name of the activity whose resources are to be
   1654      *                     retrieved.
   1655      *
   1656      * @return Returns the application's Resources.
   1657      * @throws NameNotFoundException Thrown if the resources for the given
   1658      * application could not be loaded.
   1659      *
   1660      * @see #getResourcesForApplication(ApplicationInfo)
   1661      */
   1662     public abstract Resources getResourcesForActivity(ComponentName activityName)
   1663             throws NameNotFoundException;
   1664 
   1665     /**
   1666      * Retrieve the resources for an application.  Throws NameNotFoundException
   1667      * if the package is no longer installed.
   1668      *
   1669      * @param app Information about the desired application.
   1670      *
   1671      * @return Returns the application's Resources.
   1672      * @throws NameNotFoundException Thrown if the resources for the given
   1673      * application could not be loaded (most likely because it was uninstalled).
   1674      */
   1675     public abstract Resources getResourcesForApplication(ApplicationInfo app)
   1676             throws NameNotFoundException;
   1677 
   1678     /**
   1679      * Retrieve the resources associated with an application.  Given the full
   1680      * package name of an application, retrieves the information about it and
   1681      * calls getResources() to return its application's resources.  If the
   1682      * appPackageName can not be found, NameNotFoundException is thrown.
   1683      *
   1684      * @param appPackageName Package name of the application whose resources
   1685      *                       are to be retrieved.
   1686      *
   1687      * @return Returns the application's Resources.
   1688      * @throws NameNotFoundException Thrown if the resources for the given
   1689      * application could not be loaded.
   1690      *
   1691      * @see #getResourcesForApplication(ApplicationInfo)
   1692      */
   1693     public abstract Resources getResourcesForApplication(String appPackageName)
   1694             throws NameNotFoundException;
   1695 
   1696     /**
   1697      * Retrieve overall information about an application package defined
   1698      * in a package archive file
   1699      *
   1700      * @param archiveFilePath The path to the archive file
   1701      * @param flags Additional option flags. Use any combination of
   1702      * {@link #GET_ACTIVITIES},
   1703      * {@link #GET_GIDS},
   1704      * {@link #GET_CONFIGURATIONS},
   1705      * {@link #GET_INSTRUMENTATION},
   1706      * {@link #GET_PERMISSIONS},
   1707      * {@link #GET_PROVIDERS},
   1708      * {@link #GET_RECEIVERS},
   1709      * {@link #GET_SERVICES},
   1710      * {@link #GET_SIGNATURES}, to modify the data returned.
   1711      *
   1712      * @return Returns the information about the package. Returns
   1713      * null if the package could not be successfully parsed.
   1714      *
   1715      * @see #GET_ACTIVITIES
   1716      * @see #GET_GIDS
   1717      * @see #GET_CONFIGURATIONS
   1718      * @see #GET_INSTRUMENTATION
   1719      * @see #GET_PERMISSIONS
   1720      * @see #GET_PROVIDERS
   1721      * @see #GET_RECEIVERS
   1722      * @see #GET_SERVICES
   1723      * @see #GET_SIGNATURES
   1724      *
   1725      */
   1726     public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
   1727         PackageParser packageParser = new PackageParser(archiveFilePath);
   1728         DisplayMetrics metrics = new DisplayMetrics();
   1729         metrics.setToDefaults();
   1730         final File sourceFile = new File(archiveFilePath);
   1731         PackageParser.Package pkg = packageParser.parsePackage(
   1732                 sourceFile, archiveFilePath, metrics, 0);
   1733         if (pkg == null) {
   1734             return null;
   1735         }
   1736         return PackageParser.generatePackageInfo(pkg, null, flags);
   1737     }
   1738 
   1739     /**
   1740      * @hide
   1741      *
   1742      * Install a package. Since this may take a little while, the result will
   1743      * be posted back to the given observer.  An installation will fail if the calling context
   1744      * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
   1745      * package named in the package file's manifest is already installed, or if there's no space
   1746      * available on the device.
   1747      *
   1748      * @param packageURI The location of the package file to install.  This can be a 'file:' or a
   1749      * 'content:' URI.
   1750      * @param observer An observer callback to get notified when the package installation is
   1751      * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
   1752      * called when that happens.  observer may be null to indicate that no callback is desired.
   1753      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   1754      * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
   1755      * @param installerPackageName Optional package name of the application that is performing the
   1756      * installation. This identifies which market the package came from.
   1757      */
   1758     public abstract void installPackage(
   1759             Uri packageURI, IPackageInstallObserver observer, int flags,
   1760             String installerPackageName);
   1761 
   1762     /**
   1763      * Attempts to delete a package.  Since this may take a little while, the result will
   1764      * be posted back to the given observer.  A deletion will fail if the calling context
   1765      * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
   1766      * named package cannot be found, or if the named package is a "system package".
   1767      * (TODO: include pointer to documentation on "system packages")
   1768      *
   1769      * @param packageName The name of the package to delete
   1770      * @param observer An observer callback to get notified when the package deletion is
   1771      * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
   1772      * called when that happens.  observer may be null to indicate that no callback is desired.
   1773      * @param flags - possible values: {@link #DONT_DELETE_DATA}
   1774      *
   1775      * @hide
   1776      */
   1777     public abstract void deletePackage(
   1778             String packageName, IPackageDeleteObserver observer, int flags);
   1779 
   1780     /**
   1781      * Retrieve the package name of the application that installed a package. This identifies
   1782      * which market the package came from.
   1783      *
   1784      * @param packageName The name of the package to query
   1785      */
   1786     public abstract String getInstallerPackageName(String packageName);
   1787 
   1788     /**
   1789      * Attempts to clear the user data directory of an application.
   1790      * Since this may take a little while, the result will
   1791      * be posted back to the given observer.  A deletion will fail if the
   1792      * named package cannot be found, or if the named package is a "system package".
   1793      *
   1794      * @param packageName The name of the package
   1795      * @param observer An observer callback to get notified when the operation is finished
   1796      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
   1797      * will be called when that happens.  observer may be null to indicate that
   1798      * no callback is desired.
   1799      *
   1800      * @hide
   1801      */
   1802     public abstract void clearApplicationUserData(String packageName,
   1803             IPackageDataObserver observer);
   1804     /**
   1805      * Attempts to delete the cache files associated with an application.
   1806      * Since this may take a little while, the result will
   1807      * be posted back to the given observer.  A deletion will fail if the calling context
   1808      * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
   1809      * named package cannot be found, or if the named package is a "system package".
   1810      *
   1811      * @param packageName The name of the package to delete
   1812      * @param observer An observer callback to get notified when the cache file deletion
   1813      * is complete.
   1814      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
   1815      * will be called when that happens.  observer may be null to indicate that
   1816      * no callback is desired.
   1817      *
   1818      * @hide
   1819      */
   1820     public abstract void deleteApplicationCacheFiles(String packageName,
   1821             IPackageDataObserver observer);
   1822 
   1823     /**
   1824      * Free storage by deleting LRU sorted list of cache files across
   1825      * all applications. If the currently available free storage
   1826      * on the device is greater than or equal to the requested
   1827      * free storage, no cache files are cleared. If the currently
   1828      * available storage on the device is less than the requested
   1829      * free storage, some or all of the cache files across
   1830      * all applications are deleted (based on last accessed time)
   1831      * to increase the free storage space on the device to
   1832      * the requested value. There is no guarantee that clearing all
   1833      * the cache files from all applications will clear up
   1834      * enough storage to achieve the desired value.
   1835      * @param freeStorageSize The number of bytes of storage to be
   1836      * freed by the system. Say if freeStorageSize is XX,
   1837      * and the current free storage is YY,
   1838      * if XX is less than YY, just return. if not free XX-YY number
   1839      * of bytes if possible.
   1840      * @param observer call back used to notify when
   1841      * the operation is completed
   1842      *
   1843      * @hide
   1844      */
   1845     public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
   1846 
   1847     /**
   1848      * Free storage by deleting LRU sorted list of cache files across
   1849      * all applications. If the currently available free storage
   1850      * on the device is greater than or equal to the requested
   1851      * free storage, no cache files are cleared. If the currently
   1852      * available storage on the device is less than the requested
   1853      * free storage, some or all of the cache files across
   1854      * all applications are deleted (based on last accessed time)
   1855      * to increase the free storage space on the device to
   1856      * the requested value. There is no guarantee that clearing all
   1857      * the cache files from all applications will clear up
   1858      * enough storage to achieve the desired value.
   1859      * @param freeStorageSize The number of bytes of storage to be
   1860      * freed by the system. Say if freeStorageSize is XX,
   1861      * and the current free storage is YY,
   1862      * if XX is less than YY, just return. if not free XX-YY number
   1863      * of bytes if possible.
   1864      * @param pi IntentSender call back used to
   1865      * notify when the operation is completed.May be null
   1866      * to indicate that no call back is desired.
   1867      *
   1868      * @hide
   1869      */
   1870     public abstract void freeStorage(long freeStorageSize, IntentSender pi);
   1871 
   1872     /**
   1873      * Retrieve the size information for a package.
   1874      * Since this may take a little while, the result will
   1875      * be posted back to the given observer.  The calling context
   1876      * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
   1877      *
   1878      * @param packageName The name of the package whose size information is to be retrieved
   1879      * @param observer An observer callback to get notified when the operation
   1880      * is complete.
   1881      * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
   1882      * The observer's callback is invoked with a PackageStats object(containing the
   1883      * code, data and cache sizes of the package) and a boolean value representing
   1884      * the status of the operation. observer may be null to indicate that
   1885      * no callback is desired.
   1886      *
   1887      * @hide
   1888      */
   1889     public abstract void getPackageSizeInfo(String packageName,
   1890             IPackageStatsObserver observer);
   1891 
   1892     /**
   1893      * @deprecated This function no longer does anything; it was an old
   1894      * approach to managing preferred activities, which has been superceeded
   1895      * (and conflicts with) the modern activity-based preferences.
   1896      */
   1897     @Deprecated
   1898     public abstract void addPackageToPreferred(String packageName);
   1899 
   1900     /**
   1901      * @deprecated This function no longer does anything; it was an old
   1902      * approach to managing preferred activities, which has been superceeded
   1903      * (and conflicts with) the modern activity-based preferences.
   1904      */
   1905     @Deprecated
   1906     public abstract void removePackageFromPreferred(String packageName);
   1907 
   1908     /**
   1909      * Retrieve the list of all currently configured preferred packages.  The
   1910      * first package on the list is the most preferred, the last is the
   1911      * least preferred.
   1912      *
   1913      * @param flags Additional option flags. Use any combination of
   1914      * {@link #GET_ACTIVITIES},
   1915      * {@link #GET_GIDS},
   1916      * {@link #GET_CONFIGURATIONS},
   1917      * {@link #GET_INSTRUMENTATION},
   1918      * {@link #GET_PERMISSIONS},
   1919      * {@link #GET_PROVIDERS},
   1920      * {@link #GET_RECEIVERS},
   1921      * {@link #GET_SERVICES},
   1922      * {@link #GET_SIGNATURES}, to modify the data returned.
   1923      *
   1924      * @return Returns a list of PackageInfo objects describing each
   1925      * preferred application, in order of preference.
   1926      *
   1927      * @see #GET_ACTIVITIES
   1928      * @see #GET_GIDS
   1929      * @see #GET_CONFIGURATIONS
   1930      * @see #GET_INSTRUMENTATION
   1931      * @see #GET_PERMISSIONS
   1932      * @see #GET_PROVIDERS
   1933      * @see #GET_RECEIVERS
   1934      * @see #GET_SERVICES
   1935      * @see #GET_SIGNATURES
   1936      */
   1937     public abstract List<PackageInfo> getPreferredPackages(int flags);
   1938 
   1939     /**
   1940      * @deprecated This is a protected API that should not have been available
   1941      * to third party applications.  It is the platform's responsibility for
   1942      * assigning preferred activities and this can not be directly modified.
   1943      *
   1944      * Add a new preferred activity mapping to the system.  This will be used
   1945      * to automatically select the given activity component when
   1946      * {@link Context#startActivity(Intent) Context.startActivity()} finds
   1947      * multiple matching activities and also matches the given filter.
   1948      *
   1949      * @param filter The set of intents under which this activity will be
   1950      * made preferred.
   1951      * @param match The IntentFilter match category that this preference
   1952      * applies to.
   1953      * @param set The set of activities that the user was picking from when
   1954      * this preference was made.
   1955      * @param activity The component name of the activity that is to be
   1956      * preferred.
   1957      */
   1958     @Deprecated
   1959     public abstract void addPreferredActivity(IntentFilter filter, int match,
   1960             ComponentName[] set, ComponentName activity);
   1961 
   1962     /**
   1963      * @deprecated This is a protected API that should not have been available
   1964      * to third party applications.  It is the platform's responsibility for
   1965      * assigning preferred activities and this can not be directly modified.
   1966      *
   1967      * Replaces an existing preferred activity mapping to the system, and if that were not present
   1968      * adds a new preferred activity.  This will be used
   1969      * to automatically select the given activity component when
   1970      * {@link Context#startActivity(Intent) Context.startActivity()} finds
   1971      * multiple matching activities and also matches the given filter.
   1972      *
   1973      * @param filter The set of intents under which this activity will be
   1974      * made preferred.
   1975      * @param match The IntentFilter match category that this preference
   1976      * applies to.
   1977      * @param set The set of activities that the user was picking from when
   1978      * this preference was made.
   1979      * @param activity The component name of the activity that is to be
   1980      * preferred.
   1981      * @hide
   1982      */
   1983     @Deprecated
   1984     public abstract void replacePreferredActivity(IntentFilter filter, int match,
   1985             ComponentName[] set, ComponentName activity);
   1986 
   1987     /**
   1988      * Remove all preferred activity mappings, previously added with
   1989      * {@link #addPreferredActivity}, from the
   1990      * system whose activities are implemented in the given package name.
   1991      * An application can only clear its own package(s).
   1992      *
   1993      * @param packageName The name of the package whose preferred activity
   1994      * mappings are to be removed.
   1995      */
   1996     public abstract void clearPackagePreferredActivities(String packageName);
   1997 
   1998     /**
   1999      * Retrieve all preferred activities, previously added with
   2000      * {@link #addPreferredActivity}, that are
   2001      * currently registered with the system.
   2002      *
   2003      * @param outFilters A list in which to place the filters of all of the
   2004      * preferred activities, or null for none.
   2005      * @param outActivities A list in which to place the component names of
   2006      * all of the preferred activities, or null for none.
   2007      * @param packageName An option package in which you would like to limit
   2008      * the list.  If null, all activities will be returned; if non-null, only
   2009      * those activities in the given package are returned.
   2010      *
   2011      * @return Returns the total number of registered preferred activities
   2012      * (the number of distinct IntentFilter records, not the number of unique
   2013      * activity components) that were found.
   2014      */
   2015     public abstract int getPreferredActivities(List<IntentFilter> outFilters,
   2016             List<ComponentName> outActivities, String packageName);
   2017 
   2018     /**
   2019      * Set the enabled setting for a package component (activity, receiver, service, provider).
   2020      * This setting will override any enabled state which may have been set by the component in its
   2021      * manifest.
   2022      *
   2023      * @param componentName The component to enable
   2024      * @param newState The new enabled state for the component.  The legal values for this state
   2025      *                 are:
   2026      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2027      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
   2028      *                   and
   2029      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
   2030      *                 The last one removes the setting, thereby restoring the component's state to
   2031      *                 whatever was set in it's manifest (or enabled, by default).
   2032      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
   2033      */
   2034     public abstract void setComponentEnabledSetting(ComponentName componentName,
   2035             int newState, int flags);
   2036 
   2037 
   2038     /**
   2039      * Return the the enabled setting for a package component (activity,
   2040      * receiver, service, provider).  This returns the last value set by
   2041      * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
   2042      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
   2043      * the value originally specified in the manifest has not been modified.
   2044      *
   2045      * @param componentName The component to retrieve.
   2046      * @return Returns the current enabled state for the component.  May
   2047      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2048      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
   2049      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
   2050      * component's enabled state is based on the original information in
   2051      * the manifest as found in {@link ComponentInfo}.
   2052      */
   2053     public abstract int getComponentEnabledSetting(ComponentName componentName);
   2054 
   2055     /**
   2056      * Set the enabled setting for an application
   2057      * This setting will override any enabled state which may have been set by the application in
   2058      * its manifest.  It also overrides the enabled state set in the manifest for any of the
   2059      * application's components.  It does not override any enabled state set by
   2060      * {@link #setComponentEnabledSetting} for any of the application's components.
   2061      *
   2062      * @param packageName The package name of the application to enable
   2063      * @param newState The new enabled state for the component.  The legal values for this state
   2064      *                 are:
   2065      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2066      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
   2067      *                   and
   2068      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
   2069      *                 The last one removes the setting, thereby restoring the applications's state to
   2070      *                 whatever was set in its manifest (or enabled, by default).
   2071      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
   2072      */
   2073     public abstract void setApplicationEnabledSetting(String packageName,
   2074             int newState, int flags);
   2075 
   2076     /**
   2077      * Return the the enabled setting for an application.  This returns
   2078      * the last value set by
   2079      * {@link #setApplicationEnabledSetting(String, int, int)}; in most
   2080      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
   2081      * the value originally specified in the manifest has not been modified.
   2082      *
   2083      * @param packageName The component to retrieve.
   2084      * @return Returns the current enabled state for the component.  May
   2085      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
   2086      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
   2087      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
   2088      * application's enabled state is based on the original information in
   2089      * the manifest as found in {@link ComponentInfo}.
   2090      */
   2091     public abstract int getApplicationEnabledSetting(String packageName);
   2092 
   2093     /**
   2094      * Return whether the device has been booted into safe mode.
   2095      */
   2096     public abstract boolean isSafeMode();
   2097 
   2098     /**
   2099      * Attempts to move package resources from internal to external media or vice versa.
   2100      * Since this may take a little while, the result will
   2101      * be posted back to the given observer.   This call may fail if the calling context
   2102      * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
   2103      * named package cannot be found, or if the named package is a "system package".
   2104      *
   2105      * @param packageName The name of the package to delete
   2106      * @param observer An observer callback to get notified when the package move is
   2107      * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
   2108      * called when that happens.  observer may be null to indicate that no callback is desired.
   2109      * @param flags To indicate install location {@link #MOVE_INTERNAL} or
   2110      * {@link #MOVE_EXTERNAL_MEDIA}
   2111      *
   2112      * @hide
   2113      */
   2114     public abstract void movePackage(
   2115             String packageName, IPackageMoveObserver observer, int flags);
   2116 }
   2117