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