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.Manifest;
     20 import android.annotation.CheckResult;
     21 import android.annotation.DrawableRes;
     22 import android.annotation.IntDef;
     23 import android.annotation.NonNull;
     24 import android.annotation.Nullable;
     25 import android.annotation.RequiresPermission;
     26 import android.annotation.SdkConstant;
     27 import android.annotation.SdkConstant.SdkConstantType;
     28 import android.annotation.StringRes;
     29 import android.annotation.SystemApi;
     30 import android.annotation.XmlRes;
     31 import android.app.PackageDeleteObserver;
     32 import android.app.PackageInstallObserver;
     33 import android.app.admin.DevicePolicyManager;
     34 import android.content.ComponentName;
     35 import android.content.Context;
     36 import android.content.Intent;
     37 import android.content.IntentFilter;
     38 import android.content.IntentSender;
     39 import android.content.pm.PackageParser.PackageParserException;
     40 import android.content.res.Resources;
     41 import android.content.res.XmlResourceParser;
     42 import android.graphics.Rect;
     43 import android.graphics.drawable.Drawable;
     44 import android.net.Uri;
     45 import android.os.Bundle;
     46 import android.os.Environment;
     47 import android.os.Handler;
     48 import android.os.RemoteException;
     49 import android.os.UserHandle;
     50 import android.os.storage.VolumeInfo;
     51 import android.text.TextUtils;
     52 import android.util.AndroidException;
     53 
     54 import com.android.internal.util.ArrayUtils;
     55 
     56 import java.io.File;
     57 import java.lang.annotation.Retention;
     58 import java.lang.annotation.RetentionPolicy;
     59 import java.util.List;
     60 
     61 /**
     62  * Class for retrieving various kinds of information related to the application
     63  * packages that are currently installed on the device.
     64  *
     65  * You can find this class through {@link Context#getPackageManager}.
     66  */
     67 public abstract class PackageManager {
     68 
     69     /**
     70      * This exception is thrown when a given package, application, or component
     71      * name cannot be found.
     72      */
     73     public static class NameNotFoundException extends AndroidException {
     74         public NameNotFoundException() {
     75         }
     76 
     77         public NameNotFoundException(String name) {
     78             super(name);
     79         }
     80     }
     81 
     82     /**
     83      * Listener for changes in permissions granted to a UID.
     84      *
     85      * @hide
     86      */
     87     @SystemApi
     88     public interface OnPermissionsChangedListener {
     89 
     90         /**
     91          * Called when the permissions for a UID change.
     92          * @param uid The UID with a change.
     93          */
     94         public void onPermissionsChanged(int uid);
     95     }
     96 
     97     /**
     98      * {@link PackageInfo} flag: return information about
     99      * activities in the package in {@link PackageInfo#activities}.
    100      */
    101     public static final int GET_ACTIVITIES              = 0x00000001;
    102 
    103     /**
    104      * {@link PackageInfo} flag: return information about
    105      * intent receivers in the package in
    106      * {@link PackageInfo#receivers}.
    107      */
    108     public static final int GET_RECEIVERS               = 0x00000002;
    109 
    110     /**
    111      * {@link PackageInfo} flag: return information about
    112      * services in the package in {@link PackageInfo#services}.
    113      */
    114     public static final int GET_SERVICES                = 0x00000004;
    115 
    116     /**
    117      * {@link PackageInfo} flag: return information about
    118      * content providers in the package in
    119      * {@link PackageInfo#providers}.
    120      */
    121     public static final int GET_PROVIDERS               = 0x00000008;
    122 
    123     /**
    124      * {@link PackageInfo} flag: return information about
    125      * instrumentation in the package in
    126      * {@link PackageInfo#instrumentation}.
    127      */
    128     public static final int GET_INSTRUMENTATION         = 0x00000010;
    129 
    130     /**
    131      * {@link PackageInfo} flag: return information about the
    132      * intent filters supported by the activity.
    133      */
    134     public static final int GET_INTENT_FILTERS          = 0x00000020;
    135 
    136     /**
    137      * {@link PackageInfo} flag: return information about the
    138      * signatures included in the package.
    139      */
    140     public static final int GET_SIGNATURES          = 0x00000040;
    141 
    142     /**
    143      * {@link ResolveInfo} flag: return the IntentFilter that
    144      * was matched for a particular ResolveInfo in
    145      * {@link ResolveInfo#filter}.
    146      */
    147     public static final int GET_RESOLVED_FILTER         = 0x00000040;
    148 
    149     /**
    150      * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
    151      * data {@link android.os.Bundle}s that are associated with a component.
    152      * This applies for any API returning a ComponentInfo subclass.
    153      */
    154     public static final int GET_META_DATA               = 0x00000080;
    155 
    156     /**
    157      * {@link PackageInfo} flag: return the
    158      * {@link PackageInfo#gids group ids} that are associated with an
    159      * application.
    160      * This applies for any API returning a PackageInfo class, either
    161      * directly or nested inside of another.
    162      */
    163     public static final int GET_GIDS                    = 0x00000100;
    164 
    165     /**
    166      * {@link PackageInfo} flag: include disabled components in the returned info.
    167      */
    168     public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
    169 
    170     /**
    171      * {@link ApplicationInfo} flag: return the
    172      * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
    173      * that are associated with an application.
    174      * This applies for any API returning an ApplicationInfo class, either
    175      * directly or nested inside of another.
    176      */
    177     public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
    178 
    179     /**
    180      * {@link ProviderInfo} flag: return the
    181      * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
    182      * that are associated with a content provider.
    183      * This applies for any API returning a ProviderInfo class, either
    184      * directly or nested inside of another.
    185      */
    186     public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
    187     /**
    188      * {@link PackageInfo} flag: return information about
    189      * permissions in the package in
    190      * {@link PackageInfo#permissions}.
    191      */
    192     public static final int GET_PERMISSIONS               = 0x00001000;
    193 
    194     /**
    195      * Flag parameter to retrieve some information about all applications (even
    196      * uninstalled ones) which have data directories. This state could have
    197      * resulted if applications have been deleted with flag
    198      * {@code DONT_DELETE_DATA} with a possibility of being replaced or
    199      * reinstalled in future.
    200      * <p>
    201      * Note: this flag may cause less information about currently installed
    202      * applications to be returned.
    203      */
    204     public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
    205 
    206     /**
    207      * {@link PackageInfo} flag: return information about
    208      * hardware preferences in
    209      * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
    210      * and requested features in {@link PackageInfo#reqFeatures} and
    211      * {@link PackageInfo#featureGroups}.
    212      */
    213     public static final int GET_CONFIGURATIONS = 0x00004000;
    214 
    215     /**
    216      * {@link PackageInfo} flag: include disabled components which are in
    217      * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
    218      * in the returned info.  Note that if you set this flag, applications
    219      * that are in this disabled state will be reported as enabled.
    220      */
    221     public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
    222 
    223     /**
    224      * Resolution and querying flag: if set, only filters that support the
    225      * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
    226      * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
    227      * supplied Intent.
    228      */
    229     public static final int MATCH_DEFAULT_ONLY  = 0x00010000;
    230 
    231     /**
    232      * Querying flag: if set and if the platform is doing any filtering of the results, then
    233      * the filtering will not happen. This is a synonym for saying that all results should
    234      * be returned.
    235      */
    236     public static final int MATCH_ALL = 0x00020000;
    237 
    238     /**
    239      * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
    240      * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
    241      * profile will be skipped.
    242      * Only activities in the target user can respond to the intent.
    243      * @hide
    244      */
    245     public static final int SKIP_CURRENT_PROFILE = 0x00000002;
    246 
    247     /** @hide */
    248     @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
    249     @Retention(RetentionPolicy.SOURCE)
    250     public @interface PermissionResult {}
    251 
    252     /**
    253      * Permission check result: this is returned by {@link #checkPermission}
    254      * if the permission has been granted to the given package.
    255      */
    256     public static final int PERMISSION_GRANTED = 0;
    257 
    258     /**
    259      * Permission check result: this is returned by {@link #checkPermission}
    260      * if the permission has not been granted to the given package.
    261      */
    262     public static final int PERMISSION_DENIED = -1;
    263 
    264     /**
    265      * Signature check result: this is returned by {@link #checkSignatures}
    266      * if all signatures on the two packages match.
    267      */
    268     public static final int SIGNATURE_MATCH = 0;
    269 
    270     /**
    271      * Signature check result: this is returned by {@link #checkSignatures}
    272      * if neither of the two packages is signed.
    273      */
    274     public static final int SIGNATURE_NEITHER_SIGNED = 1;
    275 
    276     /**
    277      * Signature check result: this is returned by {@link #checkSignatures}
    278      * if the first package is not signed but the second is.
    279      */
    280     public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
    281 
    282     /**
    283      * Signature check result: this is returned by {@link #checkSignatures}
    284      * if the second package is not signed but the first is.
    285      */
    286     public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
    287 
    288     /**
    289      * Signature check result: this is returned by {@link #checkSignatures}
    290      * if not all signatures on both packages match.
    291      */
    292     public static final int SIGNATURE_NO_MATCH = -3;
    293 
    294     /**
    295      * Signature check result: this is returned by {@link #checkSignatures}
    296      * if either of the packages are not valid.
    297      */
    298     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
    299 
    300     /**
    301      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
    302      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
    303      * component or application is in its default enabled state (as specified
    304      * in its manifest).
    305      */
    306     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
    307 
    308     /**
    309      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
    310      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
    311      * component or application has been explictily enabled, regardless of
    312      * what it has specified in its manifest.
    313      */
    314     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
    315 
    316     /**
    317      * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
    318      * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
    319      * component or application has been explicitly disabled, regardless of
    320      * what it has specified in its manifest.
    321      */
    322     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
    323 
    324     /**
    325      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
    326      * user has explicitly disabled the application, regardless of what it has
    327      * specified in its manifest.  Because this is due to the user's request,
    328      * they may re-enable it if desired through the appropriate system UI.  This
    329      * option currently <strong>cannot</strong> be used with
    330      * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
    331      */
    332     public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
    333 
    334     /**
    335      * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
    336      * application should be considered, until the point where the user actually
    337      * wants to use it.  This means that it will not normally show up to the user
    338      * (such as in the launcher), but various parts of the user interface can
    339      * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
    340      * the user to select it (as for example an IME, device admin, etc).  Such code,
    341      * once the user has selected the app, should at that point also make it enabled.
    342      * This option currently <strong>can not</strong> be used with
    343      * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
    344      */
    345     public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
    346 
    347     /**
    348      * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
    349      * indicate that this package should be installed as forward locked, i.e. only the app itself
    350      * should have access to its code and non-resource assets.
    351      * @hide
    352      */
    353     public static final int INSTALL_FORWARD_LOCK = 0x00000001;
    354 
    355     /**
    356      * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
    357      * installed package, if one exists.
    358      * @hide
    359      */
    360     public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
    361 
    362     /**
    363      * Flag parameter for {@link #installPackage} to indicate that you want to
    364      * allow test packages (those that have set android:testOnly in their
    365      * manifest) to be installed.
    366      * @hide
    367      */
    368     public static final int INSTALL_ALLOW_TEST = 0x00000004;
    369 
    370     /**
    371      * Flag parameter for {@link #installPackage} to indicate that this package
    372      * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}.
    373      *
    374      * @hide
    375      */
    376     public static final int INSTALL_EXTERNAL = 0x00000008;
    377 
    378     /**
    379      * Flag parameter for {@link #installPackage} to indicate that this package
    380      * must be installed to internal storage.
    381      *
    382      * @hide
    383      */
    384     public static final int INSTALL_INTERNAL = 0x00000010;
    385 
    386     /**
    387      * Flag parameter for {@link #installPackage} to indicate that this install
    388      * was initiated via ADB.
    389      *
    390      * @hide
    391      */
    392     public static final int INSTALL_FROM_ADB = 0x00000020;
    393 
    394     /**
    395      * Flag parameter for {@link #installPackage} to indicate that this install
    396      * should immediately be visible to all users.
    397      *
    398      * @hide
    399      */
    400     public static final int INSTALL_ALL_USERS = 0x00000040;
    401 
    402     /**
    403      * Flag parameter for {@link #installPackage} to indicate that it is okay
    404      * to install an update to an app where the newly installed app has a lower
    405      * version code than the currently installed app.
    406      *
    407      * @hide
    408      */
    409     public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
    410 
    411     /**
    412      * Flag parameter for {@link #installPackage} to indicate that all runtime
    413      * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
    414      * is set the runtime permissions will be granted to all users, otherwise
    415      * only to the owner.
    416      *
    417      * @hide
    418      */
    419     public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
    420 
    421     /** {@hide} */
    422     public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
    423 
    424     /**
    425      * Flag parameter for
    426      * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
    427      * that you don't want to kill the app containing the component.  Be careful when you set this
    428      * since changing component states can make the containing application's behavior unpredictable.
    429      */
    430     public static final int DONT_KILL_APP = 0x00000001;
    431 
    432     /**
    433      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    434      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
    435      * @hide
    436      */
    437     @SystemApi
    438     public static final int INSTALL_SUCCEEDED = 1;
    439 
    440     /**
    441      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    442      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
    443      * already installed.
    444      * @hide
    445      */
    446     @SystemApi
    447     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
    448 
    449     /**
    450      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    451      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
    452      * file is invalid.
    453      * @hide
    454      */
    455     @SystemApi
    456     public static final int INSTALL_FAILED_INVALID_APK = -2;
    457 
    458     /**
    459      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    460      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
    461      * is invalid.
    462      * @hide
    463      */
    464     @SystemApi
    465     public static final int INSTALL_FAILED_INVALID_URI = -3;
    466 
    467     /**
    468      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    469      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
    470      * service found that the device didn't have enough storage space to install the app.
    471      * @hide
    472      */
    473     @SystemApi
    474     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
    475 
    476     /**
    477      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    478      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
    479      * package is already installed with the same name.
    480      * @hide
    481      */
    482     @SystemApi
    483     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
    484 
    485     /**
    486      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    487      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    488      * the requested shared user does not exist.
    489      * @hide
    490      */
    491     @SystemApi
    492     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
    493 
    494     /**
    495      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    496      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    497      * a previously installed package of the same name has a different signature
    498      * than the new package (and the old package's data was not removed).
    499      * @hide
    500      */
    501     @SystemApi
    502     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
    503 
    504     /**
    505      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    506      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    507      * the new package is requested a shared user which is already installed on the
    508      * device and does not have matching signature.
    509      * @hide
    510      */
    511     @SystemApi
    512     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
    513 
    514     /**
    515      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    516      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    517      * the new package uses a shared library that is not available.
    518      * @hide
    519      */
    520     @SystemApi
    521     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
    522 
    523     /**
    524      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    525      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    526      * the new package uses a shared library that is not available.
    527      * @hide
    528      */
    529     @SystemApi
    530     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
    531 
    532     /**
    533      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    534      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    535      * the new package failed while optimizing and validating its dex files,
    536      * either because there was not enough storage or the validation failed.
    537      * @hide
    538      */
    539     @SystemApi
    540     public static final int INSTALL_FAILED_DEXOPT = -11;
    541 
    542     /**
    543      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    544      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    545      * the new package failed because the current SDK version is older than
    546      * that required by the package.
    547      * @hide
    548      */
    549     @SystemApi
    550     public static final int INSTALL_FAILED_OLDER_SDK = -12;
    551 
    552     /**
    553      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    554      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    555      * the new package failed because it contains a content provider with the
    556      * same authority as a provider already installed in the system.
    557      * @hide
    558      */
    559     @SystemApi
    560     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
    561 
    562     /**
    563      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    564      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    565      * the new package failed because the current SDK version is newer than
    566      * that required by the package.
    567      * @hide
    568      */
    569     @SystemApi
    570     public static final int INSTALL_FAILED_NEWER_SDK = -14;
    571 
    572     /**
    573      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    574      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    575      * the new package failed because it has specified that it is a test-only
    576      * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
    577      * flag.
    578      * @hide
    579      */
    580     @SystemApi
    581     public static final int INSTALL_FAILED_TEST_ONLY = -15;
    582 
    583     /**
    584      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    585      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    586      * the package being installed contains native code, but none that is
    587      * compatible with the device's CPU_ABI.
    588      * @hide
    589      */
    590     @SystemApi
    591     public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
    592 
    593     /**
    594      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    595      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    596      * the new package uses a feature that is not available.
    597      * @hide
    598      */
    599     @SystemApi
    600     public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
    601 
    602     // ------ Errors related to sdcard
    603     /**
    604      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    605      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    606      * a secure container mount point couldn't be accessed on external media.
    607      * @hide
    608      */
    609     @SystemApi
    610     public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
    611 
    612     /**
    613      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    614      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    615      * the new package couldn't be installed in the specified install
    616      * location.
    617      * @hide
    618      */
    619     @SystemApi
    620     public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
    621 
    622     /**
    623      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    624      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    625      * the new package couldn't be installed in the specified install
    626      * location because the media is not available.
    627      * @hide
    628      */
    629     @SystemApi
    630     public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
    631 
    632     /**
    633      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    634      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    635      * the new package couldn't be installed because the verification timed out.
    636      * @hide
    637      */
    638     @SystemApi
    639     public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
    640 
    641     /**
    642      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    643      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    644      * the new package couldn't be installed because the verification did not succeed.
    645      * @hide
    646      */
    647     @SystemApi
    648     public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
    649 
    650     /**
    651      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    652      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    653      * the package changed from what the calling program expected.
    654      * @hide
    655      */
    656     @SystemApi
    657     public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
    658 
    659     /**
    660      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    661      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    662      * the new package is assigned a different UID than it previously held.
    663      * @hide
    664      */
    665     public static final int INSTALL_FAILED_UID_CHANGED = -24;
    666 
    667     /**
    668      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    669      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    670      * the new package has an older version code than the currently installed package.
    671      * @hide
    672      */
    673     public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
    674 
    675     /**
    676      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
    677      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
    678      * the old package has target SDK high enough to support runtime permission and
    679      * the new package has target SDK low enough to not support runtime permissions.
    680      * @hide
    681      */
    682     @SystemApi
    683     public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
    684 
    685     /**
    686      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    687      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    688      * if the parser was given a path that is not a file, or does not end with the expected
    689      * '.apk' extension.
    690      * @hide
    691      */
    692     @SystemApi
    693     public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
    694 
    695     /**
    696      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    697      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    698      * if the parser was unable to retrieve the AndroidManifest.xml file.
    699      * @hide
    700      */
    701     @SystemApi
    702     public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
    703 
    704     /**
    705      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    706      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    707      * if the parser encountered an unexpected exception.
    708      * @hide
    709      */
    710     @SystemApi
    711     public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
    712 
    713     /**
    714      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    715      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    716      * if the parser did not find any certificates in the .apk.
    717      * @hide
    718      */
    719     @SystemApi
    720     public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
    721 
    722     /**
    723      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    724      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    725      * if the parser found inconsistent certificates on the files in the .apk.
    726      * @hide
    727      */
    728     @SystemApi
    729     public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
    730 
    731     /**
    732      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    733      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    734      * if the parser encountered a CertificateEncodingException in one of the
    735      * files in the .apk.
    736      * @hide
    737      */
    738     @SystemApi
    739     public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
    740 
    741     /**
    742      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    743      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    744      * if the parser encountered a bad or missing package name in the manifest.
    745      * @hide
    746      */
    747     @SystemApi
    748     public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
    749 
    750     /**
    751      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    752      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    753      * if the parser encountered a bad shared user id name in the manifest.
    754      * @hide
    755      */
    756     @SystemApi
    757     public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
    758 
    759     /**
    760      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    761      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    762      * if the parser encountered some structural problem in the manifest.
    763      * @hide
    764      */
    765     @SystemApi
    766     public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
    767 
    768     /**
    769      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
    770      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    771      * if the parser did not find any actionable tags (instrumentation or application)
    772      * in the manifest.
    773      * @hide
    774      */
    775     @SystemApi
    776     public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
    777 
    778     /**
    779      * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
    780      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    781      * if the system failed to install the package because of system issues.
    782      * @hide
    783      */
    784     @SystemApi
    785     public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
    786 
    787     /**
    788      * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
    789      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    790      * if the system failed to install the package because the user is restricted from installing
    791      * apps.
    792      * @hide
    793      */
    794     public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
    795 
    796     /**
    797      * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
    798      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    799      * if the system failed to install the package because it is attempting to define a
    800      * permission that is already defined by some existing package.
    801      *
    802      * <p>The package name of the app which has already defined the permission is passed to
    803      * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE}
    804      * string extra; and the name of the permission being redefined is passed in the
    805      * {@link #EXTRA_EXISTING_PERMISSION} string extra.
    806      * @hide
    807      */
    808     public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
    809 
    810     /**
    811      * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
    812      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
    813      * if the system failed to install the package because its packaged native code did not
    814      * match any of the ABIs supported by the system.
    815      *
    816      * @hide
    817      */
    818     public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
    819 
    820     /**
    821      * Internal return code for NativeLibraryHelper methods to indicate that the package
    822      * being processed did not contain any native code. This is placed here only so that
    823      * it can belong to the same value space as the other install failure codes.
    824      *
    825      * @hide
    826      */
    827     public static final int NO_NATIVE_LIBRARIES = -114;
    828 
    829     /** {@hide} */
    830     public static final int INSTALL_FAILED_ABORTED = -115;
    831 
    832     /**
    833      * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
    834      * package's data directory.
    835      *
    836      * @hide
    837      */
    838     public static final int DELETE_KEEP_DATA = 0x00000001;
    839 
    840     /**
    841      * Flag parameter for {@link #deletePackage} to indicate that you want the
    842      * package deleted for all users.
    843      *
    844      * @hide
    845      */
    846     public static final int DELETE_ALL_USERS = 0x00000002;
    847 
    848     /**
    849      * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
    850      * uninstall on a system that has been updated, then don't do the normal process
    851      * of uninstalling the update and rolling back to the older system version (which
    852      * needs to happen for all users); instead, just mark the app as uninstalled for
    853      * the current user.
    854      *
    855      * @hide
    856      */
    857     public static final int DELETE_SYSTEM_APP = 0x00000004;
    858 
    859     /**
    860      * Return code for when package deletion succeeds. This is passed to the
    861      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    862      * succeeded in deleting the package.
    863      *
    864      * @hide
    865      */
    866     public static final int DELETE_SUCCEEDED = 1;
    867 
    868     /**
    869      * Deletion failed return code: this is passed to the
    870      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    871      * failed to delete the package for an unspecified reason.
    872      *
    873      * @hide
    874      */
    875     public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
    876 
    877     /**
    878      * Deletion failed return code: this is passed to the
    879      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    880      * failed to delete the package because it is the active DevicePolicy
    881      * manager.
    882      *
    883      * @hide
    884      */
    885     public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
    886 
    887     /**
    888      * Deletion failed return code: this is passed to the
    889      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    890      * failed to delete the package since the user is restricted.
    891      *
    892      * @hide
    893      */
    894     public static final int DELETE_FAILED_USER_RESTRICTED = -3;
    895 
    896     /**
    897      * Deletion failed return code: this is passed to the
    898      * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
    899      * failed to delete the package because a profile
    900      * or device owner has marked the package as uninstallable.
    901      *
    902      * @hide
    903      */
    904     public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
    905 
    906     /** {@hide} */
    907     public static final int DELETE_FAILED_ABORTED = -5;
    908 
    909     /**
    910      * Return code that is passed to the {@link IPackageMoveObserver} by
    911      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
    912      * package has been successfully moved by the system.
    913      *
    914      * @hide
    915      */
    916     public static final int MOVE_SUCCEEDED = -100;
    917 
    918     /**
    919      * Error code that is passed to the {@link IPackageMoveObserver} by
    920      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    921      * when the package hasn't been successfully moved by the system
    922      * because of insufficient memory on specified media.
    923      * @hide
    924      */
    925     public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
    926 
    927     /**
    928      * Error code that is passed to the {@link IPackageMoveObserver} by
    929      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    930      * if the specified package doesn't exist.
    931      * @hide
    932      */
    933     public static final int MOVE_FAILED_DOESNT_EXIST = -2;
    934 
    935     /**
    936      * Error code that is passed to the {@link IPackageMoveObserver} by
    937      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    938      * if the specified package cannot be moved since its a system package.
    939      * @hide
    940      */
    941     public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
    942 
    943     /**
    944      * Error code that is passed to the {@link IPackageMoveObserver} by
    945      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    946      * if the specified package cannot be moved since its forward locked.
    947      * @hide
    948      */
    949     public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
    950 
    951     /**
    952      * Error code that is passed to the {@link IPackageMoveObserver} by
    953      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    954      * if the specified package cannot be moved to the specified location.
    955      * @hide
    956      */
    957     public static final int MOVE_FAILED_INVALID_LOCATION = -5;
    958 
    959     /**
    960      * Error code that is passed to the {@link IPackageMoveObserver} by
    961      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
    962      * if the specified package cannot be moved to the specified location.
    963      * @hide
    964      */
    965     public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
    966 
    967     /**
    968      * Error code that is passed to the {@link IPackageMoveObserver} by
    969      * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
    970      * specified package already has an operation pending in the
    971      * {@link PackageHandler} queue.
    972      *
    973      * @hide
    974      */
    975     public static final int MOVE_FAILED_OPERATION_PENDING = -7;
    976 
    977     /**
    978      * Flag parameter for {@link #movePackage} to indicate that
    979      * the package should be moved to internal storage if its
    980      * been installed on external media.
    981      * @hide
    982      */
    983     @Deprecated
    984     public static final int MOVE_INTERNAL = 0x00000001;
    985 
    986     /**
    987      * Flag parameter for {@link #movePackage} to indicate that
    988      * the package should be moved to external media.
    989      * @hide
    990      */
    991     @Deprecated
    992     public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
    993 
    994     /** {@hide} */
    995     public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
    996 
    997     /**
    998      * Usable by the required verifier as the {@code verificationCode} argument
    999      * for {@link PackageManager#verifyPendingInstall} to indicate that it will
   1000      * allow the installation to proceed without any of the optional verifiers
   1001      * needing to vote.
   1002      *
   1003      * @hide
   1004      */
   1005     public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
   1006 
   1007     /**
   1008      * Used as the {@code verificationCode} argument for
   1009      * {@link PackageManager#verifyPendingInstall} to indicate that the calling
   1010      * package verifier allows the installation to proceed.
   1011      */
   1012     public static final int VERIFICATION_ALLOW = 1;
   1013 
   1014     /**
   1015      * Used as the {@code verificationCode} argument for
   1016      * {@link PackageManager#verifyPendingInstall} to indicate the calling
   1017      * package verifier does not vote to allow the installation to proceed.
   1018      */
   1019     public static final int VERIFICATION_REJECT = -1;
   1020 
   1021     /**
   1022      * Used as the {@code verificationCode} argument for
   1023      * {@link PackageManager#verifyIntentFilter} to indicate that the calling
   1024      * IntentFilter Verifier confirms that the IntentFilter is verified.
   1025      *
   1026      * @hide
   1027      */
   1028     public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
   1029 
   1030     /**
   1031      * Used as the {@code verificationCode} argument for
   1032      * {@link PackageManager#verifyIntentFilter} to indicate that the calling
   1033      * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
   1034      *
   1035      * @hide
   1036      */
   1037     public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
   1038 
   1039     /**
   1040      * Internal status code to indicate that an IntentFilter verification result is not specified.
   1041      *
   1042      * @hide
   1043      */
   1044     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
   1045 
   1046     /**
   1047      * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
   1048      * to indicate that the User will always be prompted the Intent Disambiguation Dialog if there
   1049      * are two or more Intent resolved for the IntentFilter's domain(s).
   1050      *
   1051      * @hide
   1052      */
   1053     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
   1054 
   1055     /**
   1056      * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
   1057      * to indicate that the User will never be prompted the Intent Disambiguation Dialog if there
   1058      * are two or more resolution of the Intent. The default App for the domain(s) specified in the
   1059      * IntentFilter will also ALWAYS be used.
   1060      *
   1061      * @hide
   1062      */
   1063     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
   1064 
   1065     /**
   1066      * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
   1067      * to indicate that the User may be prompted the Intent Disambiguation Dialog if there
   1068      * are two or more Intent resolved. The default App for the domain(s) specified in the
   1069      * IntentFilter will also NEVER be presented to the User.
   1070      *
   1071      * @hide
   1072      */
   1073     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
   1074 
   1075     /**
   1076      * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
   1077      * to indicate that this app should always be considered as an ambiguous candidate for
   1078      * handling the matching Intent even if there are other candidate apps in the "always"
   1079      * state.  Put another way: if there are any 'always ask' apps in a set of more than
   1080      * one candidate app, then a disambiguation is *always* presented even if there is
   1081      * another candidate app with the 'always' state.
   1082      *
   1083      * @hide
   1084      */
   1085     public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
   1086 
   1087     /**
   1088      * Can be used as the {@code millisecondsToDelay} argument for
   1089      * {@link PackageManager#extendVerificationTimeout}. This is the
   1090      * maximum time {@code PackageManager} waits for the verification
   1091      * agent to return (in milliseconds).
   1092      */
   1093     public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
   1094 
   1095     /**
   1096      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
   1097      * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
   1098      * lag in sound input or output.
   1099      */
   1100     @SdkConstant(SdkConstantType.FEATURE)
   1101     public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
   1102 
   1103     /**
   1104      * Feature for {@link #getSystemAvailableFeatures} and
   1105      * {@link #hasSystemFeature}: The device includes at least one form of audio
   1106      * output, such as speakers, audio jack or streaming over bluetooth
   1107      */
   1108     @SdkConstant(SdkConstantType.FEATURE)
   1109     public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
   1110 
   1111     /**
   1112      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1113      * The device has professional audio level of functionality, performance, and acoustics.
   1114      */
   1115     @SdkConstant(SdkConstantType.FEATURE)
   1116     public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
   1117 
   1118     /**
   1119      * Feature for {@link #getSystemAvailableFeatures} and
   1120      * {@link #hasSystemFeature}: The device is capable of communicating with
   1121      * other devices via Bluetooth.
   1122      */
   1123     @SdkConstant(SdkConstantType.FEATURE)
   1124     public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
   1125 
   1126     /**
   1127      * Feature for {@link #getSystemAvailableFeatures} and
   1128      * {@link #hasSystemFeature}: The device is capable of communicating with
   1129      * other devices via Bluetooth Low Energy radio.
   1130      */
   1131     @SdkConstant(SdkConstantType.FEATURE)
   1132     public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
   1133 
   1134     /**
   1135      * Feature for {@link #getSystemAvailableFeatures} and
   1136      * {@link #hasSystemFeature}: The device has a camera facing away
   1137      * from the screen.
   1138      */
   1139     @SdkConstant(SdkConstantType.FEATURE)
   1140     public static final String FEATURE_CAMERA = "android.hardware.camera";
   1141 
   1142     /**
   1143      * Feature for {@link #getSystemAvailableFeatures} and
   1144      * {@link #hasSystemFeature}: The device's camera supports auto-focus.
   1145      */
   1146     @SdkConstant(SdkConstantType.FEATURE)
   1147     public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
   1148 
   1149     /**
   1150      * Feature for {@link #getSystemAvailableFeatures} and
   1151      * {@link #hasSystemFeature}: The device has at least one camera pointing in
   1152      * some direction, or can support an external camera being connected to it.
   1153      */
   1154     @SdkConstant(SdkConstantType.FEATURE)
   1155     public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
   1156 
   1157     /**
   1158      * Feature for {@link #getSystemAvailableFeatures} and
   1159      * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
   1160      * The external camera may not always be connected or available to applications to use.
   1161      */
   1162     @SdkConstant(SdkConstantType.FEATURE)
   1163     public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
   1164 
   1165     /**
   1166      * Feature for {@link #getSystemAvailableFeatures} and
   1167      * {@link #hasSystemFeature}: The device's camera supports flash.
   1168      */
   1169     @SdkConstant(SdkConstantType.FEATURE)
   1170     public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
   1171 
   1172     /**
   1173      * Feature for {@link #getSystemAvailableFeatures} and
   1174      * {@link #hasSystemFeature}: The device has a front facing camera.
   1175      */
   1176     @SdkConstant(SdkConstantType.FEATURE)
   1177     public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
   1178 
   1179     /**
   1180      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
   1181      * of the cameras on the device supports the
   1182      * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
   1183      * capability level.
   1184      */
   1185     @SdkConstant(SdkConstantType.FEATURE)
   1186     public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
   1187 
   1188     /**
   1189      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
   1190      * of the cameras on the device supports the
   1191      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
   1192      * capability level.
   1193      */
   1194     @SdkConstant(SdkConstantType.FEATURE)
   1195     public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
   1196             "android.hardware.camera.capability.manual_sensor";
   1197 
   1198     /**
   1199      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
   1200      * of the cameras on the device supports the
   1201      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
   1202      * capability level.
   1203      */
   1204     @SdkConstant(SdkConstantType.FEATURE)
   1205     public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
   1206             "android.hardware.camera.capability.manual_post_processing";
   1207 
   1208     /**
   1209      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
   1210      * of the cameras on the device supports the
   1211      * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
   1212      * capability level.
   1213      */
   1214     @SdkConstant(SdkConstantType.FEATURE)
   1215     public static final String FEATURE_CAMERA_CAPABILITY_RAW =
   1216             "android.hardware.camera.capability.raw";
   1217 
   1218     /**
   1219      * Feature for {@link #getSystemAvailableFeatures} and
   1220      * {@link #hasSystemFeature}: The device is capable of communicating with
   1221      * consumer IR devices.
   1222      */
   1223     @SdkConstant(SdkConstantType.FEATURE)
   1224     public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
   1225 
   1226     /**
   1227      * Feature for {@link #getSystemAvailableFeatures} and
   1228      * {@link #hasSystemFeature}: The device supports one or more methods of
   1229      * reporting current location.
   1230      */
   1231     @SdkConstant(SdkConstantType.FEATURE)
   1232     public static final String FEATURE_LOCATION = "android.hardware.location";
   1233 
   1234     /**
   1235      * Feature for {@link #getSystemAvailableFeatures} and
   1236      * {@link #hasSystemFeature}: The device has a Global Positioning System
   1237      * receiver and can report precise location.
   1238      */
   1239     @SdkConstant(SdkConstantType.FEATURE)
   1240     public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
   1241 
   1242     /**
   1243      * Feature for {@link #getSystemAvailableFeatures} and
   1244      * {@link #hasSystemFeature}: The device can report location with coarse
   1245      * accuracy using a network-based geolocation system.
   1246      */
   1247     @SdkConstant(SdkConstantType.FEATURE)
   1248     public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
   1249 
   1250     /**
   1251      * Feature for {@link #getSystemAvailableFeatures} and
   1252      * {@link #hasSystemFeature}: The device can record audio via a
   1253      * microphone.
   1254      */
   1255     @SdkConstant(SdkConstantType.FEATURE)
   1256     public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
   1257 
   1258     /**
   1259      * Feature for {@link #getSystemAvailableFeatures} and
   1260      * {@link #hasSystemFeature}: The device can communicate using Near-Field
   1261      * Communications (NFC).
   1262      */
   1263     @SdkConstant(SdkConstantType.FEATURE)
   1264     public static final String FEATURE_NFC = "android.hardware.nfc";
   1265 
   1266     /**
   1267      * Feature for {@link #getSystemAvailableFeatures} and
   1268      * {@link #hasSystemFeature}: The device supports host-
   1269      * based NFC card emulation.
   1270      *
   1271      * TODO remove when depending apps have moved to new constant.
   1272      * @hide
   1273      * @deprecated
   1274      */
   1275     @Deprecated
   1276     @SdkConstant(SdkConstantType.FEATURE)
   1277     public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
   1278 
   1279     /**
   1280      * Feature for {@link #getSystemAvailableFeatures} and
   1281      * {@link #hasSystemFeature}: The device supports host-
   1282      * based NFC card emulation.
   1283      */
   1284     @SdkConstant(SdkConstantType.FEATURE)
   1285     public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
   1286 
   1287     /**
   1288      * Feature for {@link #getSystemAvailableFeatures} and
   1289      * {@link #hasSystemFeature}: The device supports the OpenGL ES
   1290      * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
   1291      * Android Extension Pack</a>.
   1292      */
   1293     @SdkConstant(SdkConstantType.FEATURE)
   1294     public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
   1295 
   1296     /**
   1297      * Feature for {@link #getSystemAvailableFeatures} and
   1298      * {@link #hasSystemFeature}: The device includes an accelerometer.
   1299      */
   1300     @SdkConstant(SdkConstantType.FEATURE)
   1301     public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
   1302 
   1303     /**
   1304      * Feature for {@link #getSystemAvailableFeatures} and
   1305      * {@link #hasSystemFeature}: The device includes a barometer (air
   1306      * pressure sensor.)
   1307      */
   1308     @SdkConstant(SdkConstantType.FEATURE)
   1309     public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
   1310 
   1311     /**
   1312      * Feature for {@link #getSystemAvailableFeatures} and
   1313      * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
   1314      */
   1315     @SdkConstant(SdkConstantType.FEATURE)
   1316     public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
   1317 
   1318     /**
   1319      * Feature for {@link #getSystemAvailableFeatures} and
   1320      * {@link #hasSystemFeature}: The device includes a gyroscope.
   1321      */
   1322     @SdkConstant(SdkConstantType.FEATURE)
   1323     public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
   1324 
   1325     /**
   1326      * Feature for {@link #getSystemAvailableFeatures} and
   1327      * {@link #hasSystemFeature}: The device includes a light sensor.
   1328      */
   1329     @SdkConstant(SdkConstantType.FEATURE)
   1330     public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
   1331 
   1332     /**
   1333      * Feature for {@link #getSystemAvailableFeatures} and
   1334      * {@link #hasSystemFeature}: The device includes a proximity sensor.
   1335      */
   1336     @SdkConstant(SdkConstantType.FEATURE)
   1337     public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
   1338 
   1339     /**
   1340      * Feature for {@link #getSystemAvailableFeatures} and
   1341      * {@link #hasSystemFeature}: The device includes a hardware step counter.
   1342      */
   1343     @SdkConstant(SdkConstantType.FEATURE)
   1344     public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
   1345 
   1346     /**
   1347      * Feature for {@link #getSystemAvailableFeatures} and
   1348      * {@link #hasSystemFeature}: The device includes a hardware step detector.
   1349      */
   1350     @SdkConstant(SdkConstantType.FEATURE)
   1351     public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
   1352 
   1353     /**
   1354      * Feature for {@link #getSystemAvailableFeatures} and
   1355      * {@link #hasSystemFeature}: The device includes a heart rate monitor.
   1356      */
   1357     @SdkConstant(SdkConstantType.FEATURE)
   1358     public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
   1359 
   1360     /**
   1361      * Feature for {@link #getSystemAvailableFeatures} and
   1362      * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram.
   1363      */
   1364     @SdkConstant(SdkConstantType.FEATURE)
   1365     public static final String FEATURE_SENSOR_HEART_RATE_ECG =
   1366             "android.hardware.sensor.heartrate.ecg";
   1367 
   1368     /**
   1369      * Feature for {@link #getSystemAvailableFeatures} and
   1370      * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
   1371      */
   1372     @SdkConstant(SdkConstantType.FEATURE)
   1373     public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
   1374             "android.hardware.sensor.relative_humidity";
   1375 
   1376     /**
   1377      * Feature for {@link #getSystemAvailableFeatures} and
   1378      * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
   1379      */
   1380     @SdkConstant(SdkConstantType.FEATURE)
   1381     public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
   1382             "android.hardware.sensor.ambient_temperature";
   1383 
   1384     /**
   1385      * Feature for {@link #getSystemAvailableFeatures} and
   1386      * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
   1387      * capabilities.
   1388      */
   1389     @SdkConstant(SdkConstantType.FEATURE)
   1390     public static final String FEATURE_HIFI_SENSORS =
   1391             "android.hardware.sensor.hifi_sensors";
   1392 
   1393     /**
   1394      * Feature for {@link #getSystemAvailableFeatures} and
   1395      * {@link #hasSystemFeature}: The device has a telephony radio with data
   1396      * communication support.
   1397      */
   1398     @SdkConstant(SdkConstantType.FEATURE)
   1399     public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
   1400 
   1401     /**
   1402      * Feature for {@link #getSystemAvailableFeatures} and
   1403      * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
   1404      */
   1405     @SdkConstant(SdkConstantType.FEATURE)
   1406     public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
   1407 
   1408     /**
   1409      * Feature for {@link #getSystemAvailableFeatures} and
   1410      * {@link #hasSystemFeature}: The device has a GSM telephony stack.
   1411      */
   1412     @SdkConstant(SdkConstantType.FEATURE)
   1413     public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
   1414 
   1415     /**
   1416      * Feature for {@link #getSystemAvailableFeatures} and
   1417      * {@link #hasSystemFeature}: The device supports connecting to USB devices
   1418      * as the USB host.
   1419      */
   1420     @SdkConstant(SdkConstantType.FEATURE)
   1421     public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
   1422 
   1423     /**
   1424      * Feature for {@link #getSystemAvailableFeatures} and
   1425      * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
   1426      */
   1427     @SdkConstant(SdkConstantType.FEATURE)
   1428     public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
   1429 
   1430     /**
   1431      * Feature for {@link #getSystemAvailableFeatures} and
   1432      * {@link #hasSystemFeature}: The SIP API is enabled on the device.
   1433      */
   1434     @SdkConstant(SdkConstantType.FEATURE)
   1435     public static final String FEATURE_SIP = "android.software.sip";
   1436 
   1437     /**
   1438      * Feature for {@link #getSystemAvailableFeatures} and
   1439      * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
   1440      */
   1441     @SdkConstant(SdkConstantType.FEATURE)
   1442     public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
   1443 
   1444     /**
   1445      * Feature for {@link #getSystemAvailableFeatures} and
   1446      * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
   1447      */
   1448     @SdkConstant(SdkConstantType.FEATURE)
   1449     public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
   1450 
   1451     /**
   1452      * Feature for {@link #getSystemAvailableFeatures} and
   1453      * {@link #hasSystemFeature}: The device's display has a touch screen.
   1454      */
   1455     @SdkConstant(SdkConstantType.FEATURE)
   1456     public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
   1457 
   1458     /**
   1459      * Feature for {@link #getSystemAvailableFeatures} and
   1460      * {@link #hasSystemFeature}: The device's touch screen supports
   1461      * multitouch sufficient for basic two-finger gesture detection.
   1462      */
   1463     @SdkConstant(SdkConstantType.FEATURE)
   1464     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
   1465 
   1466     /**
   1467      * Feature for {@link #getSystemAvailableFeatures} and
   1468      * {@link #hasSystemFeature}: The device's touch screen is capable of
   1469      * tracking two or more fingers fully independently.
   1470      */
   1471     @SdkConstant(SdkConstantType.FEATURE)
   1472     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
   1473 
   1474     /**
   1475      * Feature for {@link #getSystemAvailableFeatures} and
   1476      * {@link #hasSystemFeature}: The device's touch screen is capable of
   1477      * tracking a full hand of fingers fully independently -- that is, 5 or
   1478      * more simultaneous independent pointers.
   1479      */
   1480     @SdkConstant(SdkConstantType.FEATURE)
   1481     public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
   1482 
   1483     /**
   1484      * Feature for {@link #getSystemAvailableFeatures} and
   1485      * {@link #hasSystemFeature}: The device does not have a touch screen, but
   1486      * does support touch emulation for basic events. For instance, the
   1487      * device might use a mouse or remote control to drive a cursor, and
   1488      * emulate basic touch pointer events like down, up, drag, etc. All
   1489      * devices that support android.hardware.touchscreen or a sub-feature are
   1490      * presumed to also support faketouch.
   1491      */
   1492     @SdkConstant(SdkConstantType.FEATURE)
   1493     public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
   1494 
   1495     /**
   1496      * Feature for {@link #getSystemAvailableFeatures} and
   1497      * {@link #hasSystemFeature}: The device does not have a touch screen, but
   1498      * does support touch emulation for basic events that supports distinct
   1499      * tracking of two or more fingers.  This is an extension of
   1500      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
   1501      * that unlike a distinct multitouch screen as defined by
   1502      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
   1503      * devices will not actually provide full two-finger gestures since the
   1504      * input is being transformed to cursor movement on the screen.  That is,
   1505      * single finger gestures will move a cursor; two-finger swipes will
   1506      * result in single-finger touch events; other two-finger gestures will
   1507      * result in the corresponding two-finger touch event.
   1508      */
   1509     @SdkConstant(SdkConstantType.FEATURE)
   1510     public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
   1511 
   1512     /**
   1513      * Feature for {@link #getSystemAvailableFeatures} and
   1514      * {@link #hasSystemFeature}: The device does not have a touch screen, but
   1515      * does support touch emulation for basic events that supports tracking
   1516      * a hand of fingers (5 or more fingers) fully independently.
   1517      * This is an extension of
   1518      * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
   1519      * that unlike a multitouch screen as defined by
   1520      * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
   1521      * gestures can be detected due to the limitations described for
   1522      * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
   1523      */
   1524     @SdkConstant(SdkConstantType.FEATURE)
   1525     public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
   1526 
   1527     /**
   1528      * Feature for {@link #getSystemAvailableFeatures} and
   1529      * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
   1530       */
   1531     @SdkConstant(SdkConstantType.FEATURE)
   1532     public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
   1533 
   1534     /**
   1535      * Feature for {@link #getSystemAvailableFeatures} and
   1536      * {@link #hasSystemFeature}: The device supports portrait orientation
   1537      * screens.  For backwards compatibility, you can assume that if neither
   1538      * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
   1539      * both portrait and landscape.
   1540      */
   1541     @SdkConstant(SdkConstantType.FEATURE)
   1542     public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
   1543 
   1544     /**
   1545      * Feature for {@link #getSystemAvailableFeatures} and
   1546      * {@link #hasSystemFeature}: The device supports landscape orientation
   1547      * screens.  For backwards compatibility, you can assume that if neither
   1548      * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
   1549      * both portrait and landscape.
   1550      */
   1551     @SdkConstant(SdkConstantType.FEATURE)
   1552     public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
   1553 
   1554     /**
   1555      * Feature for {@link #getSystemAvailableFeatures} and
   1556      * {@link #hasSystemFeature}: The device supports live wallpapers.
   1557      */
   1558     @SdkConstant(SdkConstantType.FEATURE)
   1559     public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
   1560     /**
   1561      * Feature for {@link #getSystemAvailableFeatures} and
   1562      * {@link #hasSystemFeature}: The device supports app widgets.
   1563      */
   1564     @SdkConstant(SdkConstantType.FEATURE)
   1565     public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
   1566 
   1567     /**
   1568      * @hide
   1569      * Feature for {@link #getSystemAvailableFeatures} and
   1570      * {@link #hasSystemFeature}: The device supports
   1571      * {@link android.service.voice.VoiceInteractionService} and
   1572      * {@link android.app.VoiceInteractor}.
   1573      */
   1574     @SdkConstant(SdkConstantType.FEATURE)
   1575     public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
   1576 
   1577 
   1578     /**
   1579      * Feature for {@link #getSystemAvailableFeatures} and
   1580      * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
   1581      * by third party applications.
   1582      */
   1583     @SdkConstant(SdkConstantType.FEATURE)
   1584     public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
   1585 
   1586     /**
   1587      * Feature for {@link #getSystemAvailableFeatures} and
   1588      * {@link #hasSystemFeature}: The device supports adding new input methods implemented
   1589      * with the {@link android.inputmethodservice.InputMethodService} API.
   1590      */
   1591     @SdkConstant(SdkConstantType.FEATURE)
   1592     public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
   1593 
   1594     /**
   1595      * Feature for {@link #getSystemAvailableFeatures} and
   1596      * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
   1597      */
   1598     @SdkConstant(SdkConstantType.FEATURE)
   1599     public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
   1600 
   1601     /**
   1602      * Feature for {@link #getSystemAvailableFeatures} and
   1603      * {@link #hasSystemFeature}: The device supports leanback UI. This is
   1604      * typically used in a living room television experience, but is a software
   1605      * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
   1606      * feature will use resources associated with the "television" UI mode.
   1607      */
   1608     @SdkConstant(SdkConstantType.FEATURE)
   1609     public static final String FEATURE_LEANBACK = "android.software.leanback";
   1610 
   1611     /**
   1612      * Feature for {@link #getSystemAvailableFeatures} and
   1613      * {@link #hasSystemFeature}: The device supports only leanback UI. Only
   1614      * applications designed for this experience should be run, though this is
   1615      * not enforced by the system.
   1616      * @hide
   1617      */
   1618     @SdkConstant(SdkConstantType.FEATURE)
   1619     public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
   1620 
   1621     /**
   1622      * Feature for {@link #getSystemAvailableFeatures} and
   1623      * {@link #hasSystemFeature}: The device supports live TV and can display
   1624      * contents from TV inputs implemented with the
   1625      * {@link android.media.tv.TvInputService} API.
   1626      */
   1627     @SdkConstant(SdkConstantType.FEATURE)
   1628     public static final String FEATURE_LIVE_TV = "android.software.live_tv";
   1629 
   1630     /**
   1631      * Feature for {@link #getSystemAvailableFeatures} and
   1632      * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
   1633      */
   1634     @SdkConstant(SdkConstantType.FEATURE)
   1635     public static final String FEATURE_WIFI = "android.hardware.wifi";
   1636 
   1637     /**
   1638      * Feature for {@link #getSystemAvailableFeatures} and
   1639      * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
   1640      */
   1641     @SdkConstant(SdkConstantType.FEATURE)
   1642     public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
   1643 
   1644     /**
   1645      * Feature for {@link #getSystemAvailableFeatures} and
   1646      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
   1647      * on a vehicle headunit. A headunit here is defined to be inside a
   1648      * vehicle that may or may not be moving. A headunit uses either a
   1649      * primary display in the center console and/or additional displays in
   1650      * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
   1651      * have limited size and resolution. The user will likely be focused on
   1652      * driving so limiting driver distraction is a primary concern. User input
   1653      * can be a variety of hard buttons, touch, rotary controllers and even mouse-
   1654      * like interfaces.
   1655      */
   1656     @SdkConstant(SdkConstantType.FEATURE)
   1657     public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
   1658 
   1659     /**
   1660      * Feature for {@link #getSystemAvailableFeatures} and
   1661      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
   1662      * on a television.  Television here is defined to be a typical living
   1663      * room television experience: displayed on a big screen, where the user
   1664      * is sitting far away from it, and the dominant form of input will be
   1665      * something like a DPAD, not through touch or mouse.
   1666      * @deprecated use {@link #FEATURE_LEANBACK} instead.
   1667      */
   1668     @Deprecated
   1669     @SdkConstant(SdkConstantType.FEATURE)
   1670     public static final String FEATURE_TELEVISION = "android.hardware.type.television";
   1671 
   1672     /**
   1673      * Feature for {@link #getSystemAvailableFeatures} and
   1674      * {@link #hasSystemFeature}: This is a device dedicated to showing UI
   1675      * on a watch. A watch here is defined to be a device worn on the body, perhaps on
   1676      * the wrist. The user is very close when interacting with the device.
   1677      */
   1678     @SdkConstant(SdkConstantType.FEATURE)
   1679     public static final String FEATURE_WATCH = "android.hardware.type.watch";
   1680 
   1681     /**
   1682      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1683      * The device supports printing.
   1684      */
   1685     @SdkConstant(SdkConstantType.FEATURE)
   1686     public static final String FEATURE_PRINTING = "android.software.print";
   1687 
   1688     /**
   1689      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1690      * The device can perform backup and restore operations on installed applications.
   1691      */
   1692     @SdkConstant(SdkConstantType.FEATURE)
   1693     public static final String FEATURE_BACKUP = "android.software.backup";
   1694 
   1695     /**
   1696      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1697      * The device supports creating secondary users and managed profiles via
   1698      * {@link DevicePolicyManager}.
   1699      */
   1700     @SdkConstant(SdkConstantType.FEATURE)
   1701     public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
   1702 
   1703     /**
   1704      * @hide
   1705      * TODO: Remove after dependencies updated b/17392243
   1706      */
   1707     public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
   1708 
   1709     /**
   1710      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1711      * The device supports verified boot.
   1712      */
   1713     @SdkConstant(SdkConstantType.FEATURE)
   1714     public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
   1715 
   1716     /**
   1717      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1718      * The device supports secure removal of users. When a user is deleted the data associated
   1719      * with that user is securely deleted and no longer available.
   1720      */
   1721     @SdkConstant(SdkConstantType.FEATURE)
   1722     public static final String FEATURE_SECURELY_REMOVES_USERS
   1723             = "android.software.securely_removes_users";
   1724 
   1725     /**
   1726      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1727      * The device has a full implementation of the android.webkit.* APIs. Devices
   1728      * lacking this feature will not have a functioning WebView implementation.
   1729      */
   1730     @SdkConstant(SdkConstantType.FEATURE)
   1731     public static final String FEATURE_WEBVIEW = "android.software.webview";
   1732 
   1733     /**
   1734      * Feature for {@link #getSystemAvailableFeatures} and
   1735      * {@link #hasSystemFeature}: This device supports ethernet.
   1736      * @hide
   1737      */
   1738     @SdkConstant(SdkConstantType.FEATURE)
   1739     public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
   1740 
   1741     /**
   1742      * Feature for {@link #getSystemAvailableFeatures} and
   1743      * {@link #hasSystemFeature}: This device supports HDMI-CEC.
   1744      * @hide
   1745      */
   1746     @SdkConstant(SdkConstantType.FEATURE)
   1747     public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
   1748 
   1749     /**
   1750      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1751      * The device has all of the inputs necessary to be considered a compatible game controller, or
   1752      * includes a compatible game controller in the box.
   1753      */
   1754     @SdkConstant(SdkConstantType.FEATURE)
   1755     public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
   1756 
   1757     /**
   1758      * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
   1759      * The device has a full implementation of the android.media.midi.* APIs.
   1760      */
   1761     @SdkConstant(SdkConstantType.FEATURE)
   1762     public static final String FEATURE_MIDI = "android.software.midi";
   1763 
   1764     /**
   1765      * Action to external storage service to clean out removed apps.
   1766      * @hide
   1767      */
   1768     public static final String ACTION_CLEAN_EXTERNAL_STORAGE
   1769             = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
   1770 
   1771     /**
   1772      * Extra field name for the URI to a verification file. Passed to a package
   1773      * verifier.
   1774      *
   1775      * @hide
   1776      */
   1777     public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
   1778 
   1779     /**
   1780      * Extra field name for the ID of a package pending verification. Passed to
   1781      * a package verifier and is used to call back to
   1782      * {@link PackageManager#verifyPendingInstall(int, int)}
   1783      */
   1784     public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
   1785 
   1786     /**
   1787      * Extra field name for the package identifier which is trying to install
   1788      * the package.
   1789      *
   1790      * @hide
   1791      */
   1792     public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
   1793             = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
   1794 
   1795     /**
   1796      * Extra field name for the requested install flags for a package pending
   1797      * verification. Passed to a package verifier.
   1798      *
   1799      * @hide
   1800      */
   1801     public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
   1802             = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
   1803 
   1804     /**
   1805      * Extra field name for the uid of who is requesting to install
   1806      * the package.
   1807      *
   1808      * @hide
   1809      */
   1810     public static final String EXTRA_VERIFICATION_INSTALLER_UID
   1811             = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
   1812 
   1813     /**
   1814      * Extra field name for the package name of a package pending verification.
   1815      *
   1816      * @hide
   1817      */
   1818     public static final String EXTRA_VERIFICATION_PACKAGE_NAME
   1819             = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
   1820     /**
   1821      * Extra field name for the result of a verification, either
   1822      * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
   1823      * Passed to package verifiers after a package is verified.
   1824      */
   1825     public static final String EXTRA_VERIFICATION_RESULT
   1826             = "android.content.pm.extra.VERIFICATION_RESULT";
   1827 
   1828     /**
   1829      * Extra field name for the version code of a package pending verification.
   1830      *
   1831      * @hide
   1832      */
   1833     public static final String EXTRA_VERIFICATION_VERSION_CODE
   1834             = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
   1835 
   1836     /**
   1837      * Extra field name for the ID of a intent filter pending verification. Passed to
   1838      * an intent filter verifier and is used to call back to
   1839      * {@link PackageManager#verifyIntentFilter(int, int)}
   1840      *
   1841      * @hide
   1842      */
   1843     public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
   1844             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
   1845 
   1846     /**
   1847      * Extra field name for the scheme used for an intent filter pending verification. Passed to
   1848      * an intent filter verifier and is used to construct the URI to verify against.
   1849      *
   1850      * Usually this is "https"
   1851      *
   1852      * @hide
   1853      */
   1854     public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
   1855             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
   1856 
   1857     /**
   1858      * Extra field name for the host names to be used for an intent filter pending verification.
   1859      * Passed to an intent filter verifier and is used to construct the URI to verify the
   1860      * intent filter.
   1861      *
   1862      * This is a space delimited list of hosts.
   1863      *
   1864      * @hide
   1865      */
   1866     public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
   1867             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
   1868 
   1869     /**
   1870      * Extra field name for the package name to be used for an intent filter pending verification.
   1871      * Passed to an intent filter verifier and is used to check the verification responses coming
   1872      * from the hosts. Each host response will need to include the package name of APK containing
   1873      * the intent filter.
   1874      *
   1875      * @hide
   1876      */
   1877     public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
   1878             = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
   1879 
   1880     /**
   1881      * The action used to request that the user approve a permission request
   1882      * from the application.
   1883      *
   1884      * @hide
   1885      */
   1886     @SystemApi
   1887     public static final String ACTION_REQUEST_PERMISSIONS =
   1888             "android.content.pm.action.REQUEST_PERMISSIONS";
   1889 
   1890     /**
   1891      * The names of the requested permissions.
   1892      * <p>
   1893      * <strong>Type:</strong> String[]
   1894      * </p>
   1895      *
   1896      * @hide
   1897      */
   1898     @SystemApi
   1899     public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
   1900             "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
   1901 
   1902     /**
   1903      * The results from the permissions request.
   1904      * <p>
   1905      * <strong>Type:</strong> int[] of #PermissionResult
   1906      * </p>
   1907      *
   1908      * @hide
   1909      */
   1910     @SystemApi
   1911     public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
   1912             = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
   1913 
   1914     /**
   1915      * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
   1916      * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
   1917      * the existing definition for the permission.
   1918      * @hide
   1919      */
   1920     public static final String EXTRA_FAILURE_EXISTING_PACKAGE
   1921             = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
   1922 
   1923     /**
   1924      * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
   1925      * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
   1926      * being redundantly defined by the package being installed.
   1927      * @hide
   1928      */
   1929     public static final String EXTRA_FAILURE_EXISTING_PERMISSION
   1930             = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
   1931 
   1932    /**
   1933     * Permission flag: The permission is set in its current state
   1934     * by the user and apps can still request it at runtime.
   1935     *
   1936     * @hide
   1937     */
   1938     public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
   1939 
   1940     /**
   1941      * Permission flag: The permission is set in its current state
   1942      * by the user and it is fixed, i.e. apps can no longer request
   1943      * this permission.
   1944      *
   1945      * @hide
   1946      */
   1947     public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
   1948 
   1949     /**
   1950      * Permission flag: The permission is set in its current state
   1951      * by device policy and neither apps nor the user can change
   1952      * its state.
   1953      *
   1954      * @hide
   1955      */
   1956     public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
   1957 
   1958     /**
   1959      * Permission flag: The permission is set in a granted state but
   1960      * access to resources it guards is restricted by other means to
   1961      * enable revoking a permission on legacy apps that do not support
   1962      * runtime permissions. If this permission is upgraded to runtime
   1963      * because the app was updated to support runtime permissions, the
   1964      * the permission will be revoked in the upgrade process.
   1965      *
   1966      * @hide
   1967      */
   1968     public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
   1969 
   1970     /**
   1971      * Permission flag: The permission is set in its current state
   1972      * because the app is a component that is a part of the system.
   1973      *
   1974      * @hide
   1975      */
   1976     public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
   1977 
   1978 
   1979     /**
   1980      * Permission flag: The permission is granted by default because it
   1981      * enables app functionality that is expected to work out-of-the-box
   1982      * for providing a smooth user experience. For example, the phone app
   1983      * is expected to have the phone permission.
   1984      *
   1985      * @hide
   1986      */
   1987     public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
   1988 
   1989     /**
   1990      * Mask for all permission flags.
   1991      *
   1992      * @hide
   1993      */
   1994     @SystemApi
   1995     public static final int MASK_PERMISSION_FLAGS = 0xFF;
   1996 
   1997     /**
   1998      * Retrieve overall information about an application package that is
   1999      * installed on the system.
   2000      * <p>
   2001      * Throws {@link NameNotFoundException} if a package with the given name can
   2002      * not be found on the system.
   2003      *
   2004      * @param packageName The full name (i.e. com.google.apps.contacts) of the
   2005      *            desired package.
   2006      * @param flags Additional option flags. Use any combination of
   2007      *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
   2008      *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
   2009      *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
   2010      *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
   2011      *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
   2012      *            modify the data returned.
   2013      * @return Returns a PackageInfo object containing information about the
   2014      *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
   2015      *         package is not found in the list of installed applications, the
   2016      *         package information is retrieved from the list of uninstalled
   2017      *         applications (which includes installed applications as well as
   2018      *         applications with data directory i.e. applications which had been
   2019      *         deleted with {@code DONT_DELETE_DATA} flag set).
   2020      * @see #GET_ACTIVITIES
   2021      * @see #GET_GIDS
   2022      * @see #GET_CONFIGURATIONS
   2023      * @see #GET_INSTRUMENTATION
   2024      * @see #GET_PERMISSIONS
   2025      * @see #GET_PROVIDERS
   2026      * @see #GET_RECEIVERS
   2027      * @see #GET_SERVICES
   2028      * @see #GET_SIGNATURES
   2029      * @see #GET_UNINSTALLED_PACKAGES
   2030      */
   2031     public abstract PackageInfo getPackageInfo(String packageName, int flags)
   2032             throws NameNotFoundException;
   2033 
   2034     /**
   2035      * Map from the current package names in use on the device to whatever
   2036      * the current canonical name of that package is.
   2037      * @param names Array of current names to be mapped.
   2038      * @return Returns an array of the same size as the original, containing
   2039      * the canonical name for each package.
   2040      */
   2041     public abstract String[] currentToCanonicalPackageNames(String[] names);
   2042 
   2043     /**
   2044      * Map from a packages canonical name to the current name in use on the device.
   2045      * @param names Array of new names to be mapped.
   2046      * @return Returns an array of the same size as the original, containing
   2047      * the current name for each package.
   2048      */
   2049     public abstract String[] canonicalToCurrentPackageNames(String[] names);
   2050 
   2051     /**
   2052      * Returns a "good" intent to launch a front-door activity in a package.
   2053      * This is used, for example, to implement an "open" button when browsing
   2054      * through packages.  The current implementation looks first for a main
   2055      * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
   2056      * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
   2057      * <code>null</code> if neither are found.
   2058      *
   2059      * @param packageName The name of the package to inspect.
   2060      *
   2061      * @return A fully-qualified {@link Intent} that can be used to launch the
   2062      * main activity in the package. Returns <code>null</code> if the package
   2063      * does not contain such an activity, or if <em>packageName</em> is not
   2064      * recognized.
   2065      */
   2066     public abstract Intent getLaunchIntentForPackage(String packageName);
   2067 
   2068     /**
   2069      * Return a "good" intent to launch a front-door Leanback activity in a
   2070      * package, for use for example to implement an "open" button when browsing
   2071      * through packages. The current implementation will look for a main
   2072      * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
   2073      * return null if no main leanback activities are found.
   2074      * <p>
   2075      * Throws {@link NameNotFoundException} if a package with the given name
   2076      * cannot be found on the system.
   2077      *
   2078      * @param packageName The name of the package to inspect.
   2079      * @return Returns either a fully-qualified Intent that can be used to launch
   2080      *         the main Leanback activity in the package, or null if the package
   2081      *         does not contain such an activity.
   2082      */
   2083     public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
   2084 
   2085     /**
   2086      * Return an array of all of the secondary group-ids that have been assigned
   2087      * to a package.
   2088      * <p>
   2089      * Throws {@link NameNotFoundException} if a package with the given name
   2090      * cannot be found on the system.
   2091      *
   2092      * @param packageName The full name (i.e. com.google.apps.contacts) of the
   2093      *            desired package.
   2094      * @return Returns an int array of the assigned gids, or null if there are
   2095      *         none.
   2096      */
   2097     public abstract int[] getPackageGids(String packageName)
   2098             throws NameNotFoundException;
   2099 
   2100     /**
   2101      * @hide Return the uid associated with the given package name for the
   2102      * given user.
   2103      *
   2104      * <p>Throws {@link NameNotFoundException} if a package with the given
   2105      * name can not be found on the system.
   2106      *
   2107      * @param packageName The full name (i.e. com.google.apps.contacts) of the
   2108      *                    desired package.
   2109      * @param userHandle The user handle identifier to look up the package under.
   2110      *
   2111      * @return Returns an integer uid who owns the given package name.
   2112      */
   2113     public abstract int getPackageUid(String packageName, int userHandle)
   2114             throws NameNotFoundException;
   2115 
   2116     /**
   2117      * Retrieve all of the information we know about a particular permission.
   2118      *
   2119      * <p>Throws {@link NameNotFoundException} if a permission with the given
   2120      * name cannot be found on the system.
   2121      *
   2122      * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
   2123      *             of the permission you are interested in.
   2124      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   2125      * retrieve any meta-data associated with the permission.
   2126      *
   2127      * @return Returns a {@link PermissionInfo} containing information about the
   2128      *         permission.
   2129      */
   2130     public abstract PermissionInfo getPermissionInfo(String name, int flags)
   2131             throws NameNotFoundException;
   2132 
   2133     /**
   2134      * Query for all of the permissions associated with a particular group.
   2135      *
   2136      * <p>Throws {@link NameNotFoundException} if the given group does not
   2137      * exist.
   2138      *
   2139      * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
   2140      *             of the permission group you are interested in.  Use null to
   2141      *             find all of the permissions not associated with a group.
   2142      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   2143      * retrieve any meta-data associated with the permissions.
   2144      *
   2145      * @return Returns a list of {@link PermissionInfo} containing information
   2146      * about all of the permissions in the given group.
   2147      */
   2148     public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
   2149             int flags) throws NameNotFoundException;
   2150 
   2151     /**
   2152      * Retrieve all of the information we know about a particular group of
   2153      * permissions.
   2154      *
   2155      * <p>Throws {@link NameNotFoundException} if a permission group with the given
   2156      * name cannot be found on the system.
   2157      *
   2158      * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
   2159      *             of the permission you are interested in.
   2160      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   2161      * retrieve any meta-data associated with the permission group.
   2162      *
   2163      * @return Returns a {@link PermissionGroupInfo} containing information
   2164      * about the permission.
   2165      */
   2166     public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
   2167             int flags) throws NameNotFoundException;
   2168 
   2169     /**
   2170      * Retrieve all of the known permission groups in the system.
   2171      *
   2172      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
   2173      * retrieve any meta-data associated with the permission group.
   2174      *
   2175      * @return Returns a list of {@link PermissionGroupInfo} containing
   2176      * information about all of the known permission groups.
   2177      */
   2178     public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
   2179 
   2180     /**
   2181      * Retrieve all of the information we know about a particular
   2182      * package/application.
   2183      *
   2184      * <p>Throws {@link NameNotFoundException} if an application with the given
   2185      * package name cannot be found on the system.
   2186      *
   2187      * @param packageName The full name (i.e. com.google.apps.contacts) of an
   2188      *                    application.
   2189      * @param flags Additional option flags. Use any combination of
   2190      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   2191      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   2192      *
   2193      * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
   2194      *         information about the package.
   2195      *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
   2196      *         found in the list of installed applications,
   2197      *         the application information is retrieved from the
   2198      *         list of uninstalled applications(which includes
   2199      *         installed applications as well as applications
   2200      *         with data directory ie applications which had been
   2201      *         deleted with {@code DONT_DELETE_DATA} flag set).
   2202      *
   2203      * @see #GET_META_DATA
   2204      * @see #GET_SHARED_LIBRARY_FILES
   2205      * @see #GET_UNINSTALLED_PACKAGES
   2206      */
   2207     public abstract ApplicationInfo getApplicationInfo(String packageName,
   2208             int flags) throws NameNotFoundException;
   2209 
   2210     /**
   2211      * Retrieve all of the information we know about a particular activity
   2212      * class.
   2213      *
   2214      * <p>Throws {@link NameNotFoundException} if an activity with the given
   2215      * class name cannot be found on the system.
   2216      *
   2217      * @param component The full component name (i.e.
   2218      * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
   2219      * class.
   2220      * @param flags Additional option flags. Use any combination of
   2221      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   2222      * to modify the data (in ApplicationInfo) returned.
   2223      *
   2224      * @return {@link ActivityInfo} containing information about the activity.
   2225      *
   2226      * @see #GET_INTENT_FILTERS
   2227      * @see #GET_META_DATA
   2228      * @see #GET_SHARED_LIBRARY_FILES
   2229      */
   2230     public abstract ActivityInfo getActivityInfo(ComponentName component,
   2231             int flags) throws NameNotFoundException;
   2232 
   2233     /**
   2234      * Retrieve all of the information we know about a particular receiver
   2235      * class.
   2236      *
   2237      * <p>Throws {@link NameNotFoundException} if a receiver with the given
   2238      * class name cannot be found on the system.
   2239      *
   2240      * @param component The full component name (i.e.
   2241      * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
   2242      * class.
   2243      * @param flags Additional option flags.  Use any combination of
   2244      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   2245      * to modify the data returned.
   2246      *
   2247      * @return {@link ActivityInfo} containing information about the receiver.
   2248      *
   2249      * @see #GET_INTENT_FILTERS
   2250      * @see #GET_META_DATA
   2251      * @see #GET_SHARED_LIBRARY_FILES
   2252      */
   2253     public abstract ActivityInfo getReceiverInfo(ComponentName component,
   2254             int flags) throws NameNotFoundException;
   2255 
   2256     /**
   2257      * Retrieve all of the information we know about a particular service
   2258      * class.
   2259      *
   2260      * <p>Throws {@link NameNotFoundException} if a service with the given
   2261      * class name cannot be found on the system.
   2262      *
   2263      * @param component The full component name (i.e.
   2264      * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
   2265      * class.
   2266      * @param flags Additional option flags.  Use any combination of
   2267      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   2268      * to modify the data returned.
   2269      *
   2270      * @return ServiceInfo containing information about the service.
   2271      *
   2272      * @see #GET_META_DATA
   2273      * @see #GET_SHARED_LIBRARY_FILES
   2274      */
   2275     public abstract ServiceInfo getServiceInfo(ComponentName component,
   2276             int flags) throws NameNotFoundException;
   2277 
   2278     /**
   2279      * Retrieve all of the information we know about a particular content
   2280      * provider class.
   2281      *
   2282      * <p>Throws {@link NameNotFoundException} if a provider with the given
   2283      * class name cannot be found on the system.
   2284      *
   2285      * @param component The full component name (i.e.
   2286      * com.google.providers.media/com.google.providers.media.MediaProvider) of a
   2287      * ContentProvider class.
   2288      * @param flags Additional option flags.  Use any combination of
   2289      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   2290      * to modify the data returned.
   2291      *
   2292      * @return ProviderInfo containing information about the service.
   2293      *
   2294      * @see #GET_META_DATA
   2295      * @see #GET_SHARED_LIBRARY_FILES
   2296      */
   2297     public abstract ProviderInfo getProviderInfo(ComponentName component,
   2298             int flags) throws NameNotFoundException;
   2299 
   2300     /**
   2301      * Return a List of all packages that are installed
   2302      * on the device.
   2303      *
   2304      * @param flags Additional option flags. Use any combination of
   2305      * {@link #GET_ACTIVITIES},
   2306      * {@link #GET_GIDS},
   2307      * {@link #GET_CONFIGURATIONS},
   2308      * {@link #GET_INSTRUMENTATION},
   2309      * {@link #GET_PERMISSIONS},
   2310      * {@link #GET_PROVIDERS},
   2311      * {@link #GET_RECEIVERS},
   2312      * {@link #GET_SERVICES},
   2313      * {@link #GET_SIGNATURES},
   2314      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   2315      *
   2316      * @return A List of PackageInfo objects, one for each package that is
   2317      *         installed on the device.  In the unlikely case of there being no
   2318      *         installed packages, an empty list is returned.
   2319      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
   2320      *         applications including those deleted with {@code DONT_DELETE_DATA}
   2321      *         (partially installed apps with data directory) will be returned.
   2322      *
   2323      * @see #GET_ACTIVITIES
   2324      * @see #GET_GIDS
   2325      * @see #GET_CONFIGURATIONS
   2326      * @see #GET_INSTRUMENTATION
   2327      * @see #GET_PERMISSIONS
   2328      * @see #GET_PROVIDERS
   2329      * @see #GET_RECEIVERS
   2330      * @see #GET_SERVICES
   2331      * @see #GET_SIGNATURES
   2332      * @see #GET_UNINSTALLED_PACKAGES
   2333      */
   2334     public abstract List<PackageInfo> getInstalledPackages(int flags);
   2335 
   2336     /**
   2337      * Return a List of all installed packages that are currently
   2338      * holding any of the given permissions.
   2339      *
   2340      * @param flags Additional option flags. Use any combination of
   2341      * {@link #GET_ACTIVITIES},
   2342      * {@link #GET_GIDS},
   2343      * {@link #GET_CONFIGURATIONS},
   2344      * {@link #GET_INSTRUMENTATION},
   2345      * {@link #GET_PERMISSIONS},
   2346      * {@link #GET_PROVIDERS},
   2347      * {@link #GET_RECEIVERS},
   2348      * {@link #GET_SERVICES},
   2349      * {@link #GET_SIGNATURES},
   2350      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   2351      *
   2352      * @return Returns a List of PackageInfo objects, one for each installed
   2353      * application that is holding any of the permissions that were provided.
   2354      *
   2355      * @see #GET_ACTIVITIES
   2356      * @see #GET_GIDS
   2357      * @see #GET_CONFIGURATIONS
   2358      * @see #GET_INSTRUMENTATION
   2359      * @see #GET_PERMISSIONS
   2360      * @see #GET_PROVIDERS
   2361      * @see #GET_RECEIVERS
   2362      * @see #GET_SERVICES
   2363      * @see #GET_SIGNATURES
   2364      * @see #GET_UNINSTALLED_PACKAGES
   2365      */
   2366     public abstract List<PackageInfo> getPackagesHoldingPermissions(
   2367             String[] permissions, int flags);
   2368 
   2369     /**
   2370      * Return a List of all packages that are installed on the device, for a specific user.
   2371      * Requesting a list of installed packages for another user
   2372      * will require the permission INTERACT_ACROSS_USERS_FULL.
   2373      * @param flags Additional option flags. Use any combination of
   2374      * {@link #GET_ACTIVITIES},
   2375      * {@link #GET_GIDS},
   2376      * {@link #GET_CONFIGURATIONS},
   2377      * {@link #GET_INSTRUMENTATION},
   2378      * {@link #GET_PERMISSIONS},
   2379      * {@link #GET_PROVIDERS},
   2380      * {@link #GET_RECEIVERS},
   2381      * {@link #GET_SERVICES},
   2382      * {@link #GET_SIGNATURES},
   2383      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   2384      * @param userId The user for whom the installed packages are to be listed
   2385      *
   2386      * @return A List of PackageInfo objects, one for each package that is
   2387      *         installed on the device.  In the unlikely case of there being no
   2388      *         installed packages, an empty list is returned.
   2389      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
   2390      *         applications including those deleted with {@code DONT_DELETE_DATA}
   2391      *         (partially installed apps with data directory) will be returned.
   2392      *
   2393      * @see #GET_ACTIVITIES
   2394      * @see #GET_GIDS
   2395      * @see #GET_CONFIGURATIONS
   2396      * @see #GET_INSTRUMENTATION
   2397      * @see #GET_PERMISSIONS
   2398      * @see #GET_PROVIDERS
   2399      * @see #GET_RECEIVERS
   2400      * @see #GET_SERVICES
   2401      * @see #GET_SIGNATURES
   2402      * @see #GET_UNINSTALLED_PACKAGES
   2403      *
   2404      * @hide
   2405      */
   2406     public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
   2407 
   2408     /**
   2409      * Check whether a particular package has been granted a particular
   2410      * permission.
   2411      *
   2412      * @param permName The name of the permission you are checking for.
   2413      * @param pkgName The name of the package you are checking against.
   2414      *
   2415      * @return If the package has the permission, PERMISSION_GRANTED is
   2416      * returned.  If it does not have the permission, PERMISSION_DENIED
   2417      * is returned.
   2418      *
   2419      * @see #PERMISSION_GRANTED
   2420      * @see #PERMISSION_DENIED
   2421      */
   2422     @CheckResult
   2423     public abstract int checkPermission(String permName, String pkgName);
   2424 
   2425     /**
   2426      * Checks whether a particular permissions has been revoked for a
   2427      * package by policy. Typically the device owner or the profile owner
   2428      * may apply such a policy. The user cannot grant policy revoked
   2429      * permissions, hence the only way for an app to get such a permission
   2430      * is by a policy change.
   2431      *
   2432      * @param permName The name of the permission you are checking for.
   2433      * @param pkgName The name of the package you are checking against.
   2434      *
   2435      * @return Whether the permission is restricted by policy.
   2436      */
   2437     @CheckResult
   2438     public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
   2439             @NonNull String pkgName);
   2440 
   2441     /**
   2442      * Gets the package name of the component controlling runtime permissions.
   2443      *
   2444      * @return The package name.
   2445      *
   2446      * @hide
   2447      */
   2448     public abstract String getPermissionControllerPackageName();
   2449 
   2450     /**
   2451      * Add a new dynamic permission to the system.  For this to work, your
   2452      * package must have defined a permission tree through the
   2453      * {@link android.R.styleable#AndroidManifestPermissionTree
   2454      * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
   2455      * permissions to trees that were defined by either its own package or
   2456      * another with the same user id; a permission is in a tree if it
   2457      * matches the name of the permission tree + ".": for example,
   2458      * "com.foo.bar" is a member of the permission tree "com.foo".
   2459      *
   2460      * <p>It is good to make your permission tree name descriptive, because you
   2461      * are taking possession of that entire set of permission names.  Thus, it
   2462      * must be under a domain you control, with a suffix that will not match
   2463      * any normal permissions that may be declared in any applications that
   2464      * are part of that domain.
   2465      *
   2466      * <p>New permissions must be added before
   2467      * any .apks are installed that use those permissions.  Permissions you
   2468      * add through this method are remembered across reboots of the device.
   2469      * If the given permission already exists, the info you supply here
   2470      * will be used to update it.
   2471      *
   2472      * @param info Description of the permission to be added.
   2473      *
   2474      * @return Returns true if a new permission was created, false if an
   2475      * existing one was updated.
   2476      *
   2477      * @throws SecurityException if you are not allowed to add the
   2478      * given permission name.
   2479      *
   2480      * @see #removePermission(String)
   2481      */
   2482     public abstract boolean addPermission(PermissionInfo info);
   2483 
   2484     /**
   2485      * Like {@link #addPermission(PermissionInfo)} but asynchronously
   2486      * persists the package manager state after returning from the call,
   2487      * allowing it to return quicker and batch a series of adds at the
   2488      * expense of no guarantee the added permission will be retained if
   2489      * the device is rebooted before it is written.
   2490      */
   2491     public abstract boolean addPermissionAsync(PermissionInfo info);
   2492 
   2493     /**
   2494      * Removes a permission that was previously added with
   2495      * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
   2496      * -- you are only allowed to remove permissions that you are allowed
   2497      * to add.
   2498      *
   2499      * @param name The name of the permission to remove.
   2500      *
   2501      * @throws SecurityException if you are not allowed to remove the
   2502      * given permission name.
   2503      *
   2504      * @see #addPermission(PermissionInfo)
   2505      */
   2506     public abstract void removePermission(String name);
   2507 
   2508 
   2509     /**
   2510      * Permission flags set when granting or revoking a permission.
   2511      *
   2512      * @hide
   2513      */
   2514     @SystemApi
   2515     @IntDef({FLAG_PERMISSION_USER_SET,
   2516             FLAG_PERMISSION_USER_FIXED,
   2517             FLAG_PERMISSION_POLICY_FIXED,
   2518             FLAG_PERMISSION_REVOKE_ON_UPGRADE,
   2519             FLAG_PERMISSION_SYSTEM_FIXED,
   2520             FLAG_PERMISSION_GRANTED_BY_DEFAULT})
   2521     @Retention(RetentionPolicy.SOURCE)
   2522     public @interface PermissionFlags {}
   2523 
   2524     /**
   2525      * Grant a runtime permission to an application which the application does not
   2526      * already have. The permission must have been requested by the application.
   2527      * If the application is not allowed to hold the permission, a {@link
   2528      * java.lang.SecurityException} is thrown.
   2529      * <p>
   2530      * <strong>Note: </strong>Using this API requires holding
   2531      * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
   2532      * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
   2533      * </p>
   2534      *
   2535      * @param packageName The package to which to grant the permission.
   2536      * @param permissionName The permission name to grant.
   2537      * @param user The user for which to grant the permission.
   2538      *
   2539      * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
   2540      * @see android.content.pm.PackageManager.PermissionFlags
   2541      *
   2542      * @hide
   2543      */
   2544     @SystemApi
   2545     public abstract void grantRuntimePermission(@NonNull String packageName,
   2546             @NonNull String permissionName, @NonNull UserHandle user);
   2547 
   2548     /**
   2549      * Revoke a runtime permission that was previously granted by {@link
   2550      * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
   2551      * permission must have been requested by and granted to the application.
   2552      * If the application is not allowed to hold the permission, a {@link
   2553      * java.lang.SecurityException} is thrown.
   2554      * <p>
   2555      * <strong>Note: </strong>Using this API requires holding
   2556      * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
   2557      * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
   2558      * </p>
   2559      *
   2560      * @param packageName The package from which to revoke the permission.
   2561      * @param permissionName The permission name to revoke.
   2562      * @param user The user for which to revoke the permission.
   2563      *
   2564      * @see #grantRuntimePermission(String, String, android.os.UserHandle)
   2565      * @see android.content.pm.PackageManager.PermissionFlags
   2566      *
   2567      * @hide
   2568      */
   2569     @SystemApi
   2570     public abstract void revokeRuntimePermission(@NonNull String packageName,
   2571             @NonNull String permissionName, @NonNull UserHandle user);
   2572 
   2573     /**
   2574      * Gets the state flags associated with a permission.
   2575      *
   2576      * @param permissionName The permission for which to get the flags.
   2577      * @param packageName The package name for which to get the flags.
   2578      * @param user The user for which to get permission flags.
   2579      * @return The permission flags.
   2580      *
   2581      * @hide
   2582      */
   2583     @SystemApi
   2584     public abstract @PermissionFlags int getPermissionFlags(String permissionName,
   2585             String packageName, @NonNull UserHandle user);
   2586 
   2587     /**
   2588      * Updates the flags associated with a permission by replacing the flags in
   2589      * the specified mask with the provided flag values.
   2590      *
   2591      * @param permissionName The permission for which to update the flags.
   2592      * @param packageName The package name for which to update the flags.
   2593      * @param flagMask The flags which to replace.
   2594      * @param flagValues The flags with which to replace.
   2595      * @param user The user for which to update the permission flags.
   2596      *
   2597      * @hide
   2598      */
   2599     @SystemApi
   2600     public abstract void updatePermissionFlags(String permissionName,
   2601             String packageName, @PermissionFlags int flagMask, int flagValues,
   2602             @NonNull UserHandle user);
   2603 
   2604     /**
   2605      * Gets whether you should show UI with rationale for requesting a permission.
   2606      * You should do this only if you do not have the permission and the context in
   2607      * which the permission is requested does not clearly communicate to the user
   2608      * what would be the benefit from grating this permission.
   2609      *
   2610      * @param permission A permission your app wants to request.
   2611      * @return Whether you can show permission rationale UI.
   2612      *
   2613      * @hide
   2614      */
   2615     public abstract boolean shouldShowRequestPermissionRationale(String permission);
   2616 
   2617     /**
   2618      * Returns an {@link android.content.Intent} suitable for passing to
   2619      * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
   2620      * which prompts the user to grant permissions to this application.
   2621      *
   2622      * @throws NullPointerException if {@code permissions} is {@code null} or empty.
   2623      *
   2624      * @hide
   2625      */
   2626     public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
   2627         if (ArrayUtils.isEmpty(permissions)) {
   2628            throw new NullPointerException("permission cannot be null or empty");
   2629         }
   2630         Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
   2631         intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
   2632         intent.setPackage(getPermissionControllerPackageName());
   2633         return intent;
   2634     }
   2635 
   2636     /**
   2637      * Compare the signatures of two packages to determine if the same
   2638      * signature appears in both of them.  If they do contain the same
   2639      * signature, then they are allowed special privileges when working
   2640      * with each other: they can share the same user-id, run instrumentation
   2641      * against each other, etc.
   2642      *
   2643      * @param pkg1 First package name whose signature will be compared.
   2644      * @param pkg2 Second package name whose signature will be compared.
   2645      *
   2646      * @return Returns an integer indicating whether all signatures on the
   2647      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
   2648      * all signatures match or < 0 if there is not a match ({@link
   2649      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
   2650      *
   2651      * @see #checkSignatures(int, int)
   2652      * @see #SIGNATURE_MATCH
   2653      * @see #SIGNATURE_NO_MATCH
   2654      * @see #SIGNATURE_UNKNOWN_PACKAGE
   2655      */
   2656     @CheckResult
   2657     public abstract int checkSignatures(String pkg1, String pkg2);
   2658 
   2659     /**
   2660      * Like {@link #checkSignatures(String, String)}, but takes UIDs of
   2661      * the two packages to be checked.  This can be useful, for example,
   2662      * when doing the check in an IPC, where the UID is the only identity
   2663      * available.  It is functionally identical to determining the package
   2664      * associated with the UIDs and checking their signatures.
   2665      *
   2666      * @param uid1 First UID whose signature will be compared.
   2667      * @param uid2 Second UID whose signature will be compared.
   2668      *
   2669      * @return Returns an integer indicating whether all signatures on the
   2670      * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
   2671      * all signatures match or < 0 if there is not a match ({@link
   2672      * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
   2673      *
   2674      * @see #checkSignatures(String, String)
   2675      * @see #SIGNATURE_MATCH
   2676      * @see #SIGNATURE_NO_MATCH
   2677      * @see #SIGNATURE_UNKNOWN_PACKAGE
   2678      */
   2679     @CheckResult
   2680     public abstract int checkSignatures(int uid1, int uid2);
   2681 
   2682     /**
   2683      * Retrieve the names of all packages that are associated with a particular
   2684      * user id.  In most cases, this will be a single package name, the package
   2685      * that has been assigned that user id.  Where there are multiple packages
   2686      * sharing the same user id through the "sharedUserId" mechanism, all
   2687      * packages with that id will be returned.
   2688      *
   2689      * @param uid The user id for which you would like to retrieve the
   2690      * associated packages.
   2691      *
   2692      * @return Returns an array of one or more packages assigned to the user
   2693      * id, or null if there are no known packages with the given id.
   2694      */
   2695     public abstract String[] getPackagesForUid(int uid);
   2696 
   2697     /**
   2698      * Retrieve the official name associated with a user id.  This name is
   2699      * guaranteed to never change, though it is possible for the underlying
   2700      * user id to be changed.  That is, if you are storing information about
   2701      * user ids in persistent storage, you should use the string returned
   2702      * by this function instead of the raw user-id.
   2703      *
   2704      * @param uid The user id for which you would like to retrieve a name.
   2705      * @return Returns a unique name for the given user id, or null if the
   2706      * user id is not currently assigned.
   2707      */
   2708     public abstract String getNameForUid(int uid);
   2709 
   2710     /**
   2711      * Return the user id associated with a shared user name. Multiple
   2712      * applications can specify a shared user name in their manifest and thus
   2713      * end up using a common uid. This might be used for new applications
   2714      * that use an existing shared user name and need to know the uid of the
   2715      * shared user.
   2716      *
   2717      * @param sharedUserName The shared user name whose uid is to be retrieved.
   2718      * @return Returns the uid associated with the shared user, or  NameNotFoundException
   2719      * if the shared user name is not being used by any installed packages
   2720      * @hide
   2721      */
   2722     public abstract int getUidForSharedUser(String sharedUserName)
   2723             throws NameNotFoundException;
   2724 
   2725     /**
   2726      * Return a List of all application packages that are installed on the
   2727      * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
   2728      * applications including those deleted with {@code DONT_DELETE_DATA} (partially
   2729      * installed apps with data directory) will be returned.
   2730      *
   2731      * @param flags Additional option flags. Use any combination of
   2732      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
   2733      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
   2734      *
   2735      * @return Returns a List of ApplicationInfo objects, one for each application that
   2736      *         is installed on the device.  In the unlikely case of there being
   2737      *         no installed applications, an empty list is returned.
   2738      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
   2739      *         applications including those deleted with {@code DONT_DELETE_DATA}
   2740      *         (partially installed apps with data directory) will be returned.
   2741      *
   2742      * @see #GET_META_DATA
   2743      * @see #GET_SHARED_LIBRARY_FILES
   2744      * @see #GET_UNINSTALLED_PACKAGES
   2745      */
   2746     public abstract List<ApplicationInfo> getInstalledApplications(int flags);
   2747 
   2748     /**
   2749      * Get a list of shared libraries that are available on the
   2750      * system.
   2751      *
   2752      * @return An array of shared library names that are
   2753      * available on the system, or null if none are installed.
   2754      *
   2755      */
   2756     public abstract String[] getSystemSharedLibraryNames();
   2757 
   2758     /**
   2759      * Get a list of features that are available on the
   2760      * system.
   2761      *
   2762      * @return An array of FeatureInfo classes describing the features
   2763      * that are available on the system, or null if there are none(!!).
   2764      */
   2765     public abstract FeatureInfo[] getSystemAvailableFeatures();
   2766 
   2767     /**
   2768      * Check whether the given feature name is one of the available
   2769      * features as returned by {@link #getSystemAvailableFeatures()}.
   2770      *
   2771      * @return Returns true if the devices supports the feature, else
   2772      * false.
   2773      */
   2774     public abstract boolean hasSystemFeature(String name);
   2775 
   2776     /**
   2777      * Determine the best action to perform for a given Intent.  This is how
   2778      * {@link Intent#resolveActivity} finds an activity if a class has not
   2779      * been explicitly specified.
   2780      *
   2781      * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
   2782      * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
   2783      * only flag.  You need to do so to resolve the activity in the same way
   2784      * that {@link android.content.Context#startActivity(Intent)} and
   2785      * {@link android.content.Intent#resolveActivity(PackageManager)
   2786      * Intent.resolveActivity(PackageManager)} do.</p>
   2787      *
   2788      * @param intent An intent containing all of the desired specification
   2789      *               (action, data, type, category, and/or component).
   2790      * @param flags Additional option flags.  The most important is
   2791      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   2792      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   2793      *
   2794      * @return Returns a ResolveInfo containing the final activity intent that
   2795      *         was determined to be the best action.  Returns null if no
   2796      *         matching activity was found. If multiple matching activities are
   2797      *         found and there is no default set, returns a ResolveInfo
   2798      *         containing something else, such as the activity resolver.
   2799      *
   2800      * @see #MATCH_DEFAULT_ONLY
   2801      * @see #GET_INTENT_FILTERS
   2802      * @see #GET_RESOLVED_FILTER
   2803      */
   2804     public abstract ResolveInfo resolveActivity(Intent intent, int flags);
   2805 
   2806     /**
   2807      * Determine the best action to perform for a given Intent for a given user. This
   2808      * is how {@link Intent#resolveActivity} finds an activity if a class has not
   2809      * been explicitly specified.
   2810      *
   2811      * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
   2812      * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
   2813      * only flag.  You need to do so to resolve the activity in the same way
   2814      * that {@link android.content.Context#startActivity(Intent)} and
   2815      * {@link android.content.Intent#resolveActivity(PackageManager)
   2816      * Intent.resolveActivity(PackageManager)} do.</p>
   2817      *
   2818      * @param intent An intent containing all of the desired specification
   2819      *               (action, data, type, category, and/or component).
   2820      * @param flags Additional option flags.  The most important is
   2821      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   2822      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   2823      * @param userId The user id.
   2824      *
   2825      * @return Returns a ResolveInfo containing the final activity intent that
   2826      *         was determined to be the best action.  Returns null if no
   2827      *         matching activity was found. If multiple matching activities are
   2828      *         found and there is no default set, returns a ResolveInfo
   2829      *         containing something else, such as the activity resolver.
   2830      *
   2831      * @see #MATCH_DEFAULT_ONLY
   2832      * @see #GET_INTENT_FILTERS
   2833      * @see #GET_RESOLVED_FILTER
   2834      *
   2835      * @hide
   2836      */
   2837     public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
   2838 
   2839     /**
   2840      * Retrieve all activities that can be performed for the given intent.
   2841      *
   2842      * @param intent The desired intent as per resolveActivity().
   2843      * @param flags Additional option flags.  The most important is
   2844      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   2845      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   2846      *
   2847      * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
   2848      *
   2849      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   2850      *         Activity. These are ordered from best to worst match -- that
   2851      *         is, the first item in the list is what is returned by
   2852      *         {@link #resolveActivity}.  If there are no matching activities, an empty
   2853      *         list is returned.
   2854      *
   2855      * @see #MATCH_DEFAULT_ONLY
   2856      * @see #GET_INTENT_FILTERS
   2857      * @see #GET_RESOLVED_FILTER
   2858      */
   2859     public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
   2860             int flags);
   2861 
   2862     /**
   2863      * Retrieve all activities that can be performed for the given intent, for a specific user.
   2864      *
   2865      * @param intent The desired intent as per resolveActivity().
   2866      * @param flags Additional option flags.  The most important is
   2867      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   2868      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   2869      *
   2870      * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
   2871      *
   2872      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   2873      *         Activity. These are ordered from best to worst match -- that
   2874      *         is, the first item in the list is what is returned by
   2875      *         {@link #resolveActivity}.  If there are no matching activities, an empty
   2876      *         list is returned.
   2877      *
   2878      * @see #MATCH_DEFAULT_ONLY
   2879      * @see #GET_INTENT_FILTERS
   2880      * @see #GET_RESOLVED_FILTER
   2881      * @hide
   2882      */
   2883     public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
   2884             int flags, int userId);
   2885 
   2886 
   2887     /**
   2888      * Retrieve a set of activities that should be presented to the user as
   2889      * similar options.  This is like {@link #queryIntentActivities}, except it
   2890      * also allows you to supply a list of more explicit Intents that you would
   2891      * like to resolve to particular options, and takes care of returning the
   2892      * final ResolveInfo list in a reasonable order, with no duplicates, based
   2893      * on those inputs.
   2894      *
   2895      * @param caller The class name of the activity that is making the
   2896      *               request.  This activity will never appear in the output
   2897      *               list.  Can be null.
   2898      * @param specifics An array of Intents that should be resolved to the
   2899      *                  first specific results.  Can be null.
   2900      * @param intent The desired intent as per resolveActivity().
   2901      * @param flags Additional option flags.  The most important is
   2902      * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
   2903      * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
   2904      *
   2905      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   2906      *         Activity. These are ordered first by all of the intents resolved
   2907      *         in <var>specifics</var> and then any additional activities that
   2908      *         can handle <var>intent</var> but did not get included by one of
   2909      *         the <var>specifics</var> intents.  If there are no matching
   2910      *         activities, an empty list is returned.
   2911      *
   2912      * @see #MATCH_DEFAULT_ONLY
   2913      * @see #GET_INTENT_FILTERS
   2914      * @see #GET_RESOLVED_FILTER
   2915      */
   2916     public abstract List<ResolveInfo> queryIntentActivityOptions(
   2917             ComponentName caller, Intent[] specifics, Intent intent, int flags);
   2918 
   2919     /**
   2920      * Retrieve all receivers that can handle a broadcast of the given intent.
   2921      *
   2922      * @param intent The desired intent as per resolveActivity().
   2923      * @param flags Additional option flags.
   2924      *
   2925      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   2926      *         Receiver. These are ordered from first to last in priority.  If
   2927      *         there are no matching receivers, an empty list is returned.
   2928      *
   2929      * @see #MATCH_DEFAULT_ONLY
   2930      * @see #GET_INTENT_FILTERS
   2931      * @see #GET_RESOLVED_FILTER
   2932      */
   2933     public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
   2934             int flags);
   2935 
   2936     /**
   2937      * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
   2938      * user.
   2939      *
   2940      * @param intent The desired intent as per resolveActivity().
   2941      * @param flags Additional option flags.
   2942      * @param userId The userId of the user being queried.
   2943      *
   2944      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   2945      *         Receiver. These are ordered from first to last in priority.  If
   2946      *         there are no matching receivers, an empty list or {@code null} is returned.
   2947      *
   2948      * @see #MATCH_DEFAULT_ONLY
   2949      * @see #GET_INTENT_FILTERS
   2950      * @see #GET_RESOLVED_FILTER
   2951      * @hide
   2952      */
   2953     public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
   2954             int flags, int userId);
   2955 
   2956     /**
   2957      * Determine the best service to handle for a given Intent.
   2958      *
   2959      * @param intent An intent containing all of the desired specification
   2960      *               (action, data, type, category, and/or component).
   2961      * @param flags Additional option flags.
   2962      *
   2963      * @return Returns a ResolveInfo containing the final service intent that
   2964      *         was determined to be the best action.  Returns null if no
   2965      *         matching service was found.
   2966      *
   2967      * @see #GET_INTENT_FILTERS
   2968      * @see #GET_RESOLVED_FILTER
   2969      */
   2970     public abstract ResolveInfo resolveService(Intent intent, int flags);
   2971 
   2972     /**
   2973      * Retrieve all services that can match the given intent.
   2974      *
   2975      * @param intent The desired intent as per resolveService().
   2976      * @param flags Additional option flags.
   2977      *
   2978      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   2979      *         ServiceInfo. These are ordered from best to worst match -- that
   2980      *         is, the first item in the list is what is returned by
   2981      *         resolveService().  If there are no matching services, an empty
   2982      *         list or {@code null} is returned.
   2983      *
   2984      * @see #GET_INTENT_FILTERS
   2985      * @see #GET_RESOLVED_FILTER
   2986      */
   2987     public abstract List<ResolveInfo> queryIntentServices(Intent intent,
   2988             int flags);
   2989 
   2990     /**
   2991      * Retrieve all services that can match the given intent for a given user.
   2992      *
   2993      * @param intent The desired intent as per resolveService().
   2994      * @param flags Additional option flags.
   2995      * @param userId The user id.
   2996      *
   2997      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   2998      *         ServiceInfo. These are ordered from best to worst match -- that
   2999      *         is, the first item in the list is what is returned by
   3000      *         resolveService().  If there are no matching services, an empty
   3001      *         list or {@code null} is returned.
   3002      *
   3003      * @see #GET_INTENT_FILTERS
   3004      * @see #GET_RESOLVED_FILTER
   3005      *
   3006      * @hide
   3007      */
   3008     public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
   3009             int flags, int userId);
   3010 
   3011     /** {@hide} */
   3012     public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
   3013             Intent intent, int flags, int userId);
   3014 
   3015     /**
   3016      * Retrieve all providers that can match the given intent.
   3017      *
   3018      * @param intent An intent containing all of the desired specification
   3019      *            (action, data, type, category, and/or component).
   3020      * @param flags Additional option flags.
   3021      * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
   3022      *         ProviderInfo. These are ordered from best to worst match. If
   3023      *         there are no matching providers, an empty list or {@code null} is returned.
   3024      * @see #GET_INTENT_FILTERS
   3025      * @see #GET_RESOLVED_FILTER
   3026      */
   3027     public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
   3028 
   3029     /**
   3030      * Find a single content provider by its base path name.
   3031      *
   3032      * @param name The name of the provider to find.
   3033      * @param flags Additional option flags.  Currently should always be 0.
   3034      *
   3035      * @return ContentProviderInfo Information about the provider, if found,
   3036      *         else null.
   3037      */
   3038     public abstract ProviderInfo resolveContentProvider(String name,
   3039             int flags);
   3040 
   3041     /**
   3042      * Find a single content provider by its base path name.
   3043      *
   3044      * @param name The name of the provider to find.
   3045      * @param flags Additional option flags.  Currently should always be 0.
   3046      * @param userId The user id.
   3047      *
   3048      * @return ContentProviderInfo Information about the provider, if found,
   3049      *         else null.
   3050      * @hide
   3051      */
   3052     public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
   3053 
   3054     /**
   3055      * Retrieve content provider information.
   3056      *
   3057      * <p><em>Note: unlike most other methods, an empty result set is indicated
   3058      * by a null return instead of an empty list.</em>
   3059      *
   3060      * @param processName If non-null, limits the returned providers to only
   3061      *                    those that are hosted by the given process.  If null,
   3062      *                    all content providers are returned.
   3063      * @param uid If <var>processName</var> is non-null, this is the required
   3064      *        uid owning the requested content providers.
   3065      * @param flags Additional option flags.  Currently should always be 0.
   3066      *
   3067      * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
   3068      *         content provider either patching <var>processName</var> or, if
   3069      *         <var>processName</var> is null, all known content providers.
   3070      *         <em>If there are no matching providers, null is returned.</em>
   3071      */
   3072     public abstract List<ProviderInfo> queryContentProviders(
   3073             String processName, int uid, int flags);
   3074 
   3075     /**
   3076      * Retrieve all of the information we know about a particular
   3077      * instrumentation class.
   3078      *
   3079      * <p>Throws {@link NameNotFoundException} if instrumentation with the
   3080      * given class name cannot be found on the system.
   3081      *
   3082      * @param className The full name (i.e.
   3083      *                  com.google.apps.contacts.InstrumentList) of an
   3084      *                  Instrumentation class.
   3085      * @param flags Additional option flags.  Currently should always be 0.
   3086      *
   3087      * @return InstrumentationInfo containing information about the
   3088      *         instrumentation.
   3089      */
   3090     public abstract InstrumentationInfo getInstrumentationInfo(
   3091             ComponentName className, int flags) throws NameNotFoundException;
   3092 
   3093     /**
   3094      * Retrieve information about available instrumentation code.  May be used
   3095      * to retrieve either all instrumentation code, or only the code targeting
   3096      * a particular package.
   3097      *
   3098      * @param targetPackage If null, all instrumentation is returned; only the
   3099      *                      instrumentation targeting this package name is
   3100      *                      returned.
   3101      * @param flags Additional option flags.  Currently should always be 0.
   3102      *
   3103      * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
   3104      *         matching available Instrumentation.  Returns an empty list if
   3105      *         there is no instrumentation available for the given package.
   3106      */
   3107     public abstract List<InstrumentationInfo> queryInstrumentation(
   3108             String targetPackage, int flags);
   3109 
   3110     /**
   3111      * Retrieve an image from a package.  This is a low-level API used by
   3112      * the various package manager info structures (such as
   3113      * {@link ComponentInfo} to implement retrieval of their associated
   3114      * icon.
   3115      *
   3116      * @param packageName The name of the package that this icon is coming from.
   3117      * Cannot be null.
   3118      * @param resid The resource identifier of the desired image.  Cannot be 0.
   3119      * @param appInfo Overall information about <var>packageName</var>.  This
   3120      * may be null, in which case the application information will be retrieved
   3121      * for you if needed; if you already have this information around, it can
   3122      * be much more efficient to supply it here.
   3123      *
   3124      * @return Returns a Drawable holding the requested image.  Returns null if
   3125      * an image could not be found for any reason.
   3126      */
   3127     public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
   3128             ApplicationInfo appInfo);
   3129 
   3130     /**
   3131      * Retrieve the icon associated with an activity.  Given the full name of
   3132      * an activity, retrieves the information about it and calls
   3133      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
   3134      * If the activity cannot be found, NameNotFoundException is thrown.
   3135      *
   3136      * @param activityName Name of the activity whose icon is to be retrieved.
   3137      *
   3138      * @return Returns the image of the icon, or the default activity icon if
   3139      * it could not be found.  Does not return null.
   3140      * @throws NameNotFoundException Thrown if the resources for the given
   3141      * activity could not be loaded.
   3142      *
   3143      * @see #getActivityIcon(Intent)
   3144      */
   3145     public abstract Drawable getActivityIcon(ComponentName activityName)
   3146             throws NameNotFoundException;
   3147 
   3148     /**
   3149      * Retrieve the icon associated with an Intent.  If intent.getClassName() is
   3150      * set, this simply returns the result of
   3151      * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
   3152      * component and returns the icon associated with the resolved component.
   3153      * If intent.getClassName() cannot be found or the Intent cannot be resolved
   3154      * to a component, NameNotFoundException is thrown.
   3155      *
   3156      * @param intent The intent for which you would like to retrieve an icon.
   3157      *
   3158      * @return Returns the image of the icon, or the default activity icon if
   3159      * it could not be found.  Does not return null.
   3160      * @throws NameNotFoundException Thrown if the resources for application
   3161      * matching the given intent could not be loaded.
   3162      *
   3163      * @see #getActivityIcon(ComponentName)
   3164      */
   3165     public abstract Drawable getActivityIcon(Intent intent)
   3166             throws NameNotFoundException;
   3167 
   3168     /**
   3169      * Retrieve the banner associated with an activity. Given the full name of
   3170      * an activity, retrieves the information about it and calls
   3171      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
   3172      * banner. If the activity cannot be found, NameNotFoundException is thrown.
   3173      *
   3174      * @param activityName Name of the activity whose banner is to be retrieved.
   3175      * @return Returns the image of the banner, or null if the activity has no
   3176      *         banner specified.
   3177      * @throws NameNotFoundException Thrown if the resources for the given
   3178      *             activity could not be loaded.
   3179      * @see #getActivityBanner(Intent)
   3180      */
   3181     public abstract Drawable getActivityBanner(ComponentName activityName)
   3182             throws NameNotFoundException;
   3183 
   3184     /**
   3185      * Retrieve the banner associated with an Intent. If intent.getClassName()
   3186      * is set, this simply returns the result of
   3187      * getActivityBanner(intent.getClassName()). Otherwise it resolves the
   3188      * intent's component and returns the banner associated with the resolved
   3189      * component. If intent.getClassName() cannot be found or the Intent cannot
   3190      * be resolved to a component, NameNotFoundException is thrown.
   3191      *
   3192      * @param intent The intent for which you would like to retrieve a banner.
   3193      * @return Returns the image of the banner, or null if the activity has no
   3194      *         banner specified.
   3195      * @throws NameNotFoundException Thrown if the resources for application
   3196      *             matching the given intent could not be loaded.
   3197      * @see #getActivityBanner(ComponentName)
   3198      */
   3199     public abstract Drawable getActivityBanner(Intent intent)
   3200             throws NameNotFoundException;
   3201 
   3202     /**
   3203      * Return the generic icon for an activity that is used when no specific
   3204      * icon is defined.
   3205      *
   3206      * @return Drawable Image of the icon.
   3207      */
   3208     public abstract Drawable getDefaultActivityIcon();
   3209 
   3210     /**
   3211      * Retrieve the icon associated with an application.  If it has not defined
   3212      * an icon, the default app icon is returned.  Does not return null.
   3213      *
   3214      * @param info Information about application being queried.
   3215      *
   3216      * @return Returns the image of the icon, or the default application icon
   3217      * if it could not be found.
   3218      *
   3219      * @see #getApplicationIcon(String)
   3220      */
   3221     public abstract Drawable getApplicationIcon(ApplicationInfo info);
   3222 
   3223     /**
   3224      * Retrieve the icon associated with an application.  Given the name of the
   3225      * application's package, retrieves the information about it and calls
   3226      * getApplicationIcon() to return its icon. If the application cannot be
   3227      * found, NameNotFoundException is thrown.
   3228      *
   3229      * @param packageName Name of the package whose application icon is to be
   3230      *                    retrieved.
   3231      *
   3232      * @return Returns the image of the icon, or the default application icon
   3233      * if it could not be found.  Does not return null.
   3234      * @throws NameNotFoundException Thrown if the resources for the given
   3235      * application could not be loaded.
   3236      *
   3237      * @see #getApplicationIcon(ApplicationInfo)
   3238      */
   3239     public abstract Drawable getApplicationIcon(String packageName)
   3240             throws NameNotFoundException;
   3241 
   3242     /**
   3243      * Retrieve the banner associated with an application.
   3244      *
   3245      * @param info Information about application being queried.
   3246      * @return Returns the image of the banner or null if the application has no
   3247      *         banner specified.
   3248      * @see #getApplicationBanner(String)
   3249      */
   3250     public abstract Drawable getApplicationBanner(ApplicationInfo info);
   3251 
   3252     /**
   3253      * Retrieve the banner associated with an application. Given the name of the
   3254      * application's package, retrieves the information about it and calls
   3255      * getApplicationIcon() to return its banner. If the application cannot be
   3256      * found, NameNotFoundException is thrown.
   3257      *
   3258      * @param packageName Name of the package whose application banner is to be
   3259      *            retrieved.
   3260      * @return Returns the image of the banner or null if the application has no
   3261      *         banner specified.
   3262      * @throws NameNotFoundException Thrown if the resources for the given
   3263      *             application could not be loaded.
   3264      * @see #getApplicationBanner(ApplicationInfo)
   3265      */
   3266     public abstract Drawable getApplicationBanner(String packageName)
   3267             throws NameNotFoundException;
   3268 
   3269     /**
   3270      * Retrieve the logo associated with an activity. Given the full name of an
   3271      * activity, retrieves the information about it and calls
   3272      * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
   3273      * logo. If the activity cannot be found, NameNotFoundException is thrown.
   3274      *
   3275      * @param activityName Name of the activity whose logo is to be retrieved.
   3276      * @return Returns the image of the logo or null if the activity has no logo
   3277      *         specified.
   3278      * @throws NameNotFoundException Thrown if the resources for the given
   3279      *             activity could not be loaded.
   3280      * @see #getActivityLogo(Intent)
   3281      */
   3282     public abstract Drawable getActivityLogo(ComponentName activityName)
   3283             throws NameNotFoundException;
   3284 
   3285     /**
   3286      * Retrieve the logo associated with an Intent.  If intent.getClassName() is
   3287      * set, this simply returns the result of
   3288      * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
   3289      * component and returns the logo associated with the resolved component.
   3290      * If intent.getClassName() cannot be found or the Intent cannot be resolved
   3291      * to a component, NameNotFoundException is thrown.
   3292      *
   3293      * @param intent The intent for which you would like to retrieve a logo.
   3294      *
   3295      * @return Returns the image of the logo, or null if the activity has no
   3296      * logo specified.
   3297      *
   3298      * @throws NameNotFoundException Thrown if the resources for application
   3299      * matching the given intent could not be loaded.
   3300      *
   3301      * @see #getActivityLogo(ComponentName)
   3302      */
   3303     public abstract Drawable getActivityLogo(Intent intent)
   3304             throws NameNotFoundException;
   3305 
   3306     /**
   3307      * Retrieve the logo associated with an application.  If it has not specified
   3308      * a logo, this method returns null.
   3309      *
   3310      * @param info Information about application being queried.
   3311      *
   3312      * @return Returns the image of the logo, or null if no logo is specified
   3313      * by the application.
   3314      *
   3315      * @see #getApplicationLogo(String)
   3316      */
   3317     public abstract Drawable getApplicationLogo(ApplicationInfo info);
   3318 
   3319     /**
   3320      * Retrieve the logo associated with an application.  Given the name of the
   3321      * application's package, retrieves the information about it and calls
   3322      * getApplicationLogo() to return its logo. If the application cannot be
   3323      * found, NameNotFoundException is thrown.
   3324      *
   3325      * @param packageName Name of the package whose application logo is to be
   3326      *                    retrieved.
   3327      *
   3328      * @return Returns the image of the logo, or null if no application logo
   3329      * has been specified.
   3330      *
   3331      * @throws NameNotFoundException Thrown if the resources for the given
   3332      * application could not be loaded.
   3333      *
   3334      * @see #getApplicationLogo(ApplicationInfo)
   3335      */
   3336     public abstract Drawable getApplicationLogo(String packageName)
   3337             throws NameNotFoundException;
   3338 
   3339     /**
   3340      * If the target user is a managed profile of the calling user or if the
   3341      * target user is the caller and is itself a managed profile, then this
   3342      * returns a badged copy of the given icon to be able to distinguish it from
   3343      * the original icon. For badging an arbitrary drawable use
   3344      * {@link #getUserBadgedDrawableForDensity(
   3345      * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
   3346      * <p>
   3347      * If the original drawable is a BitmapDrawable and the backing bitmap is
   3348      * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
   3349      * is performed in place and the original drawable is returned.
   3350      * </p>
   3351      *
   3352      * @param icon The icon to badge.
   3353      * @param user The target user.
   3354      * @return A drawable that combines the original icon and a badge as
   3355      *         determined by the system.
   3356      */
   3357     public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
   3358 
   3359     /**
   3360      * If the target user is a managed profile of the calling user or the caller
   3361      * is itself a managed profile, then this returns a badged copy of the given
   3362      * drawable allowing the user to distinguish it from the original drawable.
   3363      * The caller can specify the location in the bounds of the drawable to be
   3364      * badged where the badge should be applied as well as the density of the
   3365      * badge to be used.
   3366      * <p>
   3367      * If the original drawable is a BitmapDrawable and the backing bitmap is
   3368      * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
   3369      * is performed in place and the original drawable is returned.
   3370      * </p>
   3371      *
   3372      * @param drawable The drawable to badge.
   3373      * @param user The target user.
   3374      * @param badgeLocation Where in the bounds of the badged drawable to place
   3375      *         the badge. If not provided, the badge is applied on top of the entire
   3376      *         drawable being badged.
   3377      * @param badgeDensity The optional desired density for the badge as per
   3378      *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
   3379      *         the density of the display is used.
   3380      * @return A drawable that combines the original drawable and a badge as
   3381      *         determined by the system.
   3382      */
   3383     public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
   3384             UserHandle user, Rect badgeLocation, int badgeDensity);
   3385 
   3386     /**
   3387      * If the target user is a managed profile of the calling user or the caller
   3388      * is itself a managed profile, then this returns a drawable to use as a small
   3389      * icon to include in a view to distinguish it from the original icon.
   3390      *
   3391      * @param user The target user.
   3392      * @param density The optional desired density for the badge as per
   3393      *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
   3394      *         the density of the current display is used.
   3395      * @return the drawable or null if no drawable is required.
   3396      * @hide
   3397      */
   3398     public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
   3399 
   3400     /**
   3401      * If the target user is a managed profile of the calling user or the caller
   3402      * is itself a managed profile, then this returns a copy of the label with
   3403      * badging for accessibility services like talkback. E.g. passing in "Email"
   3404      * and it might return "Work Email" for Email in the work profile.
   3405      *
   3406      * @param label The label to change.
   3407      * @param user The target user.
   3408      * @return A label that combines the original label and a badge as
   3409      *         determined by the system.
   3410      */
   3411     public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
   3412 
   3413     /**
   3414      * Retrieve text from a package.  This is a low-level API used by
   3415      * the various package manager info structures (such as
   3416      * {@link ComponentInfo} to implement retrieval of their associated
   3417      * labels and other text.
   3418      *
   3419      * @param packageName The name of the package that this text is coming from.
   3420      * Cannot be null.
   3421      * @param resid The resource identifier of the desired text.  Cannot be 0.
   3422      * @param appInfo Overall information about <var>packageName</var>.  This
   3423      * may be null, in which case the application information will be retrieved
   3424      * for you if needed; if you already have this information around, it can
   3425      * be much more efficient to supply it here.
   3426      *
   3427      * @return Returns a CharSequence holding the requested text.  Returns null
   3428      * if the text could not be found for any reason.
   3429      */
   3430     public abstract CharSequence getText(String packageName, @StringRes int resid,
   3431             ApplicationInfo appInfo);
   3432 
   3433     /**
   3434      * Retrieve an XML file from a package.  This is a low-level API used to
   3435      * retrieve XML meta data.
   3436      *
   3437      * @param packageName The name of the package that this xml is coming from.
   3438      * Cannot be null.
   3439      * @param resid The resource identifier of the desired xml.  Cannot be 0.
   3440      * @param appInfo Overall information about <var>packageName</var>.  This
   3441      * may be null, in which case the application information will be retrieved
   3442      * for you if needed; if you already have this information around, it can
   3443      * be much more efficient to supply it here.
   3444      *
   3445      * @return Returns an XmlPullParser allowing you to parse out the XML
   3446      * data.  Returns null if the xml resource could not be found for any
   3447      * reason.
   3448      */
   3449     public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
   3450             ApplicationInfo appInfo);
   3451 
   3452     /**
   3453      * Return the label to use for this application.
   3454      *
   3455      * @return Returns the label associated with this application, or null if
   3456      * it could not be found for any reason.
   3457      * @param info The application to get the label of.
   3458      */
   3459     public abstract CharSequence getApplicationLabel(ApplicationInfo info);
   3460 
   3461     /**
   3462      * Retrieve the resources associated with an activity.  Given the full
   3463      * name of an activity, retrieves the information about it and calls
   3464      * getResources() to return its application's resources.  If the activity
   3465      * cannot be found, NameNotFoundException is thrown.
   3466      *
   3467      * @param activityName Name of the activity whose resources are to be
   3468      *                     retrieved.
   3469      *
   3470      * @return Returns the application's Resources.
   3471      * @throws NameNotFoundException Thrown if the resources for the given
   3472      * application could not be loaded.
   3473      *
   3474      * @see #getResourcesForApplication(ApplicationInfo)
   3475      */
   3476     public abstract Resources getResourcesForActivity(ComponentName activityName)
   3477             throws NameNotFoundException;
   3478 
   3479     /**
   3480      * Retrieve the resources for an application.  Throws NameNotFoundException
   3481      * if the package is no longer installed.
   3482      *
   3483      * @param app Information about the desired application.
   3484      *
   3485      * @return Returns the application's Resources.
   3486      * @throws NameNotFoundException Thrown if the resources for the given
   3487      * application could not be loaded (most likely because it was uninstalled).
   3488      */
   3489     public abstract Resources getResourcesForApplication(ApplicationInfo app)
   3490             throws NameNotFoundException;
   3491 
   3492     /**
   3493      * Retrieve the resources associated with an application.  Given the full
   3494      * package name of an application, retrieves the information about it and
   3495      * calls getResources() to return its application's resources.  If the
   3496      * appPackageName cannot be found, NameNotFoundException is thrown.
   3497      *
   3498      * @param appPackageName Package name of the application whose resources
   3499      *                       are to be retrieved.
   3500      *
   3501      * @return Returns the application's Resources.
   3502      * @throws NameNotFoundException Thrown if the resources for the given
   3503      * application could not be loaded.
   3504      *
   3505      * @see #getResourcesForApplication(ApplicationInfo)
   3506      */
   3507     public abstract Resources getResourcesForApplication(String appPackageName)
   3508             throws NameNotFoundException;
   3509 
   3510     /** @hide */
   3511     public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
   3512             throws NameNotFoundException;
   3513 
   3514     /**
   3515      * Retrieve overall information about an application package defined
   3516      * in a package archive file
   3517      *
   3518      * @param archiveFilePath The path to the archive file
   3519      * @param flags Additional option flags. Use any combination of
   3520      * {@link #GET_ACTIVITIES},
   3521      * {@link #GET_GIDS},
   3522      * {@link #GET_CONFIGURATIONS},
   3523      * {@link #GET_INSTRUMENTATION},
   3524      * {@link #GET_PERMISSIONS},
   3525      * {@link #GET_PROVIDERS},
   3526      * {@link #GET_RECEIVERS},
   3527      * {@link #GET_SERVICES},
   3528      * {@link #GET_SIGNATURES}, to modify the data returned.
   3529      *
   3530      * @return Returns the information about the package. Returns
   3531      * null if the package could not be successfully parsed.
   3532      *
   3533      * @see #GET_ACTIVITIES
   3534      * @see #GET_GIDS
   3535      * @see #GET_CONFIGURATIONS
   3536      * @see #GET_INSTRUMENTATION
   3537      * @see #GET_PERMISSIONS
   3538      * @see #GET_PROVIDERS
   3539      * @see #GET_RECEIVERS
   3540      * @see #GET_SERVICES
   3541      * @see #GET_SIGNATURES
   3542      *
   3543      */
   3544     public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
   3545         final PackageParser parser = new PackageParser();
   3546         final File apkFile = new File(archiveFilePath);
   3547         try {
   3548             PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
   3549             if ((flags & GET_SIGNATURES) != 0) {
   3550                 parser.collectCertificates(pkg, 0);
   3551                 parser.collectManifestDigest(pkg);
   3552             }
   3553             PackageUserState state = new PackageUserState();
   3554             return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
   3555         } catch (PackageParserException e) {
   3556             return null;
   3557         }
   3558     }
   3559 
   3560     /**
   3561      * @hide Install a package. Since this may take a little while, the result
   3562      *       will be posted back to the given observer. An installation will
   3563      *       fail if the calling context lacks the
   3564      *       {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
   3565      *       the package named in the package file's manifest is already
   3566      *       installed, or if there's no space available on the device.
   3567      * @param packageURI The location of the package file to install. This can
   3568      *            be a 'file:' or a 'content:' URI.
   3569      * @param observer An observer callback to get notified when the package
   3570      *            installation is complete.
   3571      *            {@link IPackageInstallObserver#packageInstalled(String, int)}
   3572      *            will be called when that happens. This parameter must not be
   3573      *            null.
   3574      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   3575      *            {@link #INSTALL_REPLACE_EXISTING},
   3576      *            {@link #INSTALL_ALLOW_TEST}.
   3577      * @param installerPackageName Optional package name of the application that
   3578      *            is performing the installation. This identifies which market
   3579      *            the package came from.
   3580      * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
   3581      *             String)} instead. This method will continue to be supported
   3582      *             but the older observer interface will not get additional
   3583      *             failure details.
   3584      */
   3585     // @SystemApi
   3586     public abstract void installPackage(
   3587             Uri packageURI, IPackageInstallObserver observer, int flags,
   3588             String installerPackageName);
   3589 
   3590     /**
   3591      * Similar to
   3592      * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
   3593      * with an extra verification file provided.
   3594      *
   3595      * @param packageURI The location of the package file to install. This can
   3596      *            be a 'file:' or a 'content:' URI.
   3597      * @param observer An observer callback to get notified when the package
   3598      *            installation is complete.
   3599      *            {@link IPackageInstallObserver#packageInstalled(String, int)}
   3600      *            will be called when that happens. This parameter must not be
   3601      *            null.
   3602      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   3603      *            {@link #INSTALL_REPLACE_EXISTING},
   3604      *            {@link #INSTALL_ALLOW_TEST}.
   3605      * @param installerPackageName Optional package name of the application that
   3606      *            is performing the installation. This identifies which market
   3607      *            the package came from.
   3608      * @param verificationURI The location of the supplementary verification
   3609      *            file. This can be a 'file:' or a 'content:' URI. May be
   3610      *            {@code null}.
   3611      * @param manifestDigest an object that holds the digest of the package
   3612      *            which can be used to verify ownership. May be {@code null}.
   3613      * @param encryptionParams if the package to be installed is encrypted,
   3614      *            these parameters describing the encryption and authentication
   3615      *            used. May be {@code null}.
   3616      * @hide
   3617      * @deprecated Use {@link #installPackageWithVerification(Uri,
   3618      *             PackageInstallObserver, int, String, Uri, ManifestDigest,
   3619      *             ContainerEncryptionParams)} instead. This method will
   3620      *             continue to be supported but the older observer interface
   3621      *             will not get additional failure details.
   3622      */
   3623     // @SystemApi
   3624     public abstract void installPackageWithVerification(Uri packageURI,
   3625             IPackageInstallObserver observer, int flags, String installerPackageName,
   3626             Uri verificationURI, ManifestDigest manifestDigest,
   3627             ContainerEncryptionParams encryptionParams);
   3628 
   3629     /**
   3630      * Similar to
   3631      * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
   3632      * with an extra verification information provided.
   3633      *
   3634      * @param packageURI The location of the package file to install. This can
   3635      *            be a 'file:' or a 'content:' URI.
   3636      * @param observer An observer callback to get notified when the package
   3637      *            installation is complete.
   3638      *            {@link IPackageInstallObserver#packageInstalled(String, int)}
   3639      *            will be called when that happens. This parameter must not be
   3640      *            null.
   3641      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   3642      *            {@link #INSTALL_REPLACE_EXISTING},
   3643      *            {@link #INSTALL_ALLOW_TEST}.
   3644      * @param installerPackageName Optional package name of the application that
   3645      *            is performing the installation. This identifies which market
   3646      *            the package came from.
   3647      * @param verificationParams an object that holds signal information to
   3648      *            assist verification. May be {@code null}.
   3649      * @param encryptionParams if the package to be installed is encrypted,
   3650      *            these parameters describing the encryption and authentication
   3651      *            used. May be {@code null}.
   3652      * @hide
   3653      * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
   3654      *             PackageInstallObserver, int, String, VerificationParams,
   3655      *             ContainerEncryptionParams)} instead. This method will
   3656      *             continue to be supported but the older observer interface
   3657      *             will not get additional failure details.
   3658      */
   3659     @Deprecated
   3660     public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
   3661             IPackageInstallObserver observer, int flags, String installerPackageName,
   3662             VerificationParams verificationParams,
   3663             ContainerEncryptionParams encryptionParams);
   3664 
   3665     // Package-install variants that take the new, expanded form of observer interface.
   3666     // Note that these *also* take the original observer type and will redundantly
   3667     // report the same information to that observer if supplied; but it is not required.
   3668 
   3669     /**
   3670      * @hide
   3671      *
   3672      * Install a package. Since this may take a little while, the result will
   3673      * be posted back to the given observer.  An installation will fail if the calling context
   3674      * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
   3675      * package named in the package file's manifest is already installed, or if there's no space
   3676      * available on the device.
   3677      *
   3678      * @param packageURI The location of the package file to install.  This can be a 'file:' or a
   3679      * 'content:' URI.
   3680      * @param observer An observer callback to get notified when the package installation is
   3681      * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
   3682      * called when that happens. This parameter must not be null.
   3683      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   3684      * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
   3685      * @param installerPackageName Optional package name of the application that is performing the
   3686      * installation. This identifies which market the package came from.
   3687      */
   3688     public abstract void installPackage(
   3689             Uri packageURI, PackageInstallObserver observer,
   3690             int flags, String installerPackageName);
   3691 
   3692     /**
   3693      * Similar to
   3694      * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
   3695      * with an extra verification file provided.
   3696      *
   3697      * @param packageURI The location of the package file to install. This can
   3698      *            be a 'file:' or a 'content:' URI.
   3699      * @param observer An observer callback to get notified when the package installation is
   3700      * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
   3701      * called when that happens. This parameter must not be null.
   3702      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   3703      *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
   3704      * @param installerPackageName Optional package name of the application that
   3705      *            is performing the installation. This identifies which market
   3706      *            the package came from.
   3707      * @param verificationURI The location of the supplementary verification
   3708      *            file. This can be a 'file:' or a 'content:' URI. May be
   3709      *            {@code null}.
   3710      * @param manifestDigest an object that holds the digest of the package
   3711      *            which can be used to verify ownership. May be {@code null}.
   3712      * @param encryptionParams if the package to be installed is encrypted,
   3713      *            these parameters describing the encryption and authentication
   3714      *            used. May be {@code null}.
   3715      * @hide
   3716      */
   3717     public abstract void installPackageWithVerification(Uri packageURI,
   3718             PackageInstallObserver observer, int flags, String installerPackageName,
   3719             Uri verificationURI, ManifestDigest manifestDigest,
   3720             ContainerEncryptionParams encryptionParams);
   3721 
   3722     /**
   3723      * Similar to
   3724      * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
   3725      * with an extra verification information provided.
   3726      *
   3727      * @param packageURI The location of the package file to install. This can
   3728      *            be a 'file:' or a 'content:' URI.
   3729      * @param observer An observer callback to get notified when the package installation is
   3730      * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
   3731      * called when that happens. This parameter must not be null.
   3732      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
   3733      *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
   3734      * @param installerPackageName Optional package name of the application that
   3735      *            is performing the installation. This identifies which market
   3736      *            the package came from.
   3737      * @param verificationParams an object that holds signal information to
   3738      *            assist verification. May be {@code null}.
   3739      * @param encryptionParams if the package to be installed is encrypted,
   3740      *            these parameters describing the encryption and authentication
   3741      *            used. May be {@code null}.
   3742      *
   3743      * @hide
   3744      */
   3745     public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
   3746             PackageInstallObserver observer, int flags, String installerPackageName,
   3747             VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
   3748 
   3749     /**
   3750      * If there is already an application with the given package name installed
   3751      * on the system for other users, also install it for the calling user.
   3752      * @hide
   3753      */
   3754     // @SystemApi
   3755     public abstract int installExistingPackage(String packageName)
   3756             throws NameNotFoundException;
   3757 
   3758     /**
   3759      * Allows a package listening to the
   3760      * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
   3761      * broadcast} to respond to the package manager. The response must include
   3762      * the {@code verificationCode} which is one of
   3763      * {@link PackageManager#VERIFICATION_ALLOW} or
   3764      * {@link PackageManager#VERIFICATION_REJECT}.
   3765      *
   3766      * @param id pending package identifier as passed via the
   3767      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
   3768      * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
   3769      *            or {@link PackageManager#VERIFICATION_REJECT}.
   3770      * @throws SecurityException if the caller does not have the
   3771      *            PACKAGE_VERIFICATION_AGENT permission.
   3772      */
   3773     public abstract void verifyPendingInstall(int id, int verificationCode);
   3774 
   3775     /**
   3776      * Allows a package listening to the
   3777      * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
   3778      * broadcast} to extend the default timeout for a response and declare what
   3779      * action to perform after the timeout occurs. The response must include
   3780      * the {@code verificationCodeAtTimeout} which is one of
   3781      * {@link PackageManager#VERIFICATION_ALLOW} or
   3782      * {@link PackageManager#VERIFICATION_REJECT}.
   3783      *
   3784      * This method may only be called once per package id. Additional calls
   3785      * will have no effect.
   3786      *
   3787      * @param id pending package identifier as passed via the
   3788      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
   3789      * @param verificationCodeAtTimeout either
   3790      *            {@link PackageManager#VERIFICATION_ALLOW} or
   3791      *            {@link PackageManager#VERIFICATION_REJECT}. If
   3792      *            {@code verificationCodeAtTimeout} is neither
   3793      *            {@link PackageManager#VERIFICATION_ALLOW} or
   3794      *            {@link PackageManager#VERIFICATION_REJECT}, then
   3795      *            {@code verificationCodeAtTimeout} will default to
   3796      *            {@link PackageManager#VERIFICATION_REJECT}.
   3797      * @param millisecondsToDelay the amount of time requested for the timeout.
   3798      *            Must be positive and less than
   3799      *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
   3800      *            {@code millisecondsToDelay} is out of bounds,
   3801      *            {@code millisecondsToDelay} will be set to the closest in
   3802      *            bounds value; namely, 0 or
   3803      *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
   3804      * @throws SecurityException if the caller does not have the
   3805      *            PACKAGE_VERIFICATION_AGENT permission.
   3806      */
   3807     public abstract void extendVerificationTimeout(int id,
   3808             int verificationCodeAtTimeout, long millisecondsToDelay);
   3809 
   3810     /**
   3811      * Allows a package listening to the
   3812      * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification
   3813      * broadcast} to respond to the package manager. The response must include
   3814      * the {@code verificationCode} which is one of
   3815      * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
   3816      * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
   3817      *
   3818      * @param verificationId pending package identifier as passed via the
   3819      *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
   3820      * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
   3821      *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
   3822      * @param outFailedDomains a list of failed domains if the verificationCode is
   3823      *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
   3824      * @throws SecurityException if the caller does not have the
   3825      *            INTENT_FILTER_VERIFICATION_AGENT permission.
   3826      *
   3827      * @hide
   3828      */
   3829     @SystemApi
   3830     public abstract void verifyIntentFilter(int verificationId, int verificationCode,
   3831             List<String> outFailedDomains);
   3832 
   3833     /**
   3834      * Get the status of a Domain Verification Result for an IntentFilter. This is
   3835      * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
   3836      * {@link android.content.IntentFilter#getAutoVerify()}
   3837      *
   3838      * This is used by the ResolverActivity to change the status depending on what the User select
   3839      * in the Disambiguation Dialog and also used by the Settings App for changing the default App
   3840      * for a domain.
   3841      *
   3842      * @param packageName The package name of the Activity associated with the IntentFilter.
   3843      * @param userId The user id.
   3844      *
   3845      * @return The status to set to. This can be
   3846      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
   3847      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
   3848      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
   3849      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
   3850      *
   3851      * @hide
   3852      */
   3853     public abstract int getIntentVerificationStatus(String packageName, int userId);
   3854 
   3855     /**
   3856      * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
   3857      * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
   3858      * {@link android.content.IntentFilter#getAutoVerify()}
   3859      *
   3860      * This is used by the ResolverActivity to change the status depending on what the User select
   3861      * in the Disambiguation Dialog and also used by the Settings App for changing the default App
   3862      * for a domain.
   3863      *
   3864      * @param packageName The package name of the Activity associated with the IntentFilter.
   3865      * @param status The status to set to. This can be
   3866      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
   3867      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
   3868      *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
   3869      * @param userId The user id.
   3870      *
   3871      * @return true if the status has been set. False otherwise.
   3872      *
   3873      * @hide
   3874      */
   3875     public abstract boolean updateIntentVerificationStatus(String packageName, int status,
   3876             int userId);
   3877 
   3878     /**
   3879      * Get the list of IntentFilterVerificationInfo for a specific package and User.
   3880      *
   3881      * @param packageName the package name. When this parameter is set to a non null value,
   3882      *                    the results will be filtered by the package name provided.
   3883      *                    Otherwise, there will be no filtering and it will return a list
   3884      *                    corresponding for all packages
   3885      *
   3886      * @return a list of IntentFilterVerificationInfo for a specific package.
   3887      *
   3888      * @hide
   3889      */
   3890     public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
   3891             String packageName);
   3892 
   3893     /**
   3894      * Get the list of IntentFilter for a specific package.
   3895      *
   3896      * @param packageName the package name. This parameter is set to a non null value,
   3897      *                    the list will contain all the IntentFilter for that package.
   3898      *                    Otherwise, the list will be empty.
   3899      *
   3900      * @return a list of IntentFilter for a specific package.
   3901      *
   3902      * @hide
   3903      */
   3904     public abstract List<IntentFilter> getAllIntentFilters(String packageName);
   3905 
   3906     /**
   3907      * Get the default Browser package name for a specific user.
   3908      *
   3909      * @param userId The user id.
   3910      *
   3911      * @return the package name of the default Browser for the specified user. If the user id passed
   3912      *         is -1 (all users) it will return a null value.
   3913      *
   3914      * @hide
   3915      */
   3916     public abstract String getDefaultBrowserPackageName(int userId);
   3917 
   3918     /**
   3919      * Set the default Browser package name for a specific user.
   3920      *
   3921      * @param packageName The package name of the default Browser.
   3922      * @param userId The user id.
   3923      *
   3924      * @return true if the default Browser for the specified user has been set,
   3925      *         otherwise return false. If the user id passed is -1 (all users) this call will not
   3926      *         do anything and just return false.
   3927      *
   3928      * @hide
   3929      */
   3930     public abstract boolean setDefaultBrowserPackageName(String packageName, int userId);
   3931 
   3932     /**
   3933      * Change the installer associated with a given package.  There are limitations
   3934      * on how the installer package can be changed; in particular:
   3935      * <ul>
   3936      * <li> A SecurityException will be thrown if <var>installerPackageName</var>
   3937      * is not signed with the same certificate as the calling application.
   3938      * <li> A SecurityException will be thrown if <var>targetPackage</var> already
   3939      * has an installer package, and that installer package is not signed with
   3940      * the same certificate as the calling application.
   3941      * </ul>
   3942      *
   3943      * @param targetPackage The installed package whose installer will be changed.
   3944      * @param installerPackageName The package name of the new installer.  May be
   3945      * null to clear the association.
   3946      */
   3947     public abstract void setInstallerPackageName(String targetPackage,
   3948             String installerPackageName);
   3949 
   3950     /**
   3951      * Attempts to delete a package.  Since this may take a little while, the result will
   3952      * be posted back to the given observer.  A deletion will fail if the calling context
   3953      * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
   3954      * named package cannot be found, or if the named package is a "system package".
   3955      * (TODO: include pointer to documentation on "system packages")
   3956      *
   3957      * @param packageName The name of the package to delete
   3958      * @param observer An observer callback to get notified when the package deletion is
   3959      * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
   3960      * called when that happens.  observer may be null to indicate that no callback is desired.
   3961      * @param flags - possible values: {@link #DELETE_KEEP_DATA},
   3962      * {@link #DELETE_ALL_USERS}.
   3963      *
   3964      * @hide
   3965      */
   3966     // @SystemApi
   3967     public abstract void deletePackage(
   3968             String packageName, IPackageDeleteObserver observer, int flags);
   3969 
   3970     /**
   3971      * Retrieve the package name of the application that installed a package. This identifies
   3972      * which market the package came from.
   3973      *
   3974      * @param packageName The name of the package to query
   3975      */
   3976     public abstract String getInstallerPackageName(String packageName);
   3977 
   3978     /**
   3979      * Attempts to clear the user data directory of an application.
   3980      * Since this may take a little while, the result will
   3981      * be posted back to the given observer.  A deletion will fail if the
   3982      * named package cannot be found, or if the named package is a "system package".
   3983      *
   3984      * @param packageName The name of the package
   3985      * @param observer An observer callback to get notified when the operation is finished
   3986      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
   3987      * will be called when that happens.  observer may be null to indicate that
   3988      * no callback is desired.
   3989      *
   3990      * @hide
   3991      */
   3992     public abstract void clearApplicationUserData(String packageName,
   3993             IPackageDataObserver observer);
   3994     /**
   3995      * Attempts to delete the cache files associated with an application.
   3996      * Since this may take a little while, the result will
   3997      * be posted back to the given observer.  A deletion will fail if the calling context
   3998      * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
   3999      * named package cannot be found, or if the named package is a "system package".
   4000      *
   4001      * @param packageName The name of the package to delete
   4002      * @param observer An observer callback to get notified when the cache file deletion
   4003      * is complete.
   4004      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
   4005      * will be called when that happens.  observer may be null to indicate that
   4006      * no callback is desired.
   4007      *
   4008      * @hide
   4009      */
   4010     public abstract void deleteApplicationCacheFiles(String packageName,
   4011             IPackageDataObserver observer);
   4012 
   4013     /**
   4014      * Free storage by deleting LRU sorted list of cache files across
   4015      * all applications. If the currently available free storage
   4016      * on the device is greater than or equal to the requested
   4017      * free storage, no cache files are cleared. If the currently
   4018      * available storage on the device is less than the requested
   4019      * free storage, some or all of the cache files across
   4020      * all applications are deleted (based on last accessed time)
   4021      * to increase the free storage space on the device to
   4022      * the requested value. There is no guarantee that clearing all
   4023      * the cache files from all applications will clear up
   4024      * enough storage to achieve the desired value.
   4025      * @param freeStorageSize The number of bytes of storage to be
   4026      * freed by the system. Say if freeStorageSize is XX,
   4027      * and the current free storage is YY,
   4028      * if XX is less than YY, just return. if not free XX-YY number
   4029      * of bytes if possible.
   4030      * @param observer call back used to notify when
   4031      * the operation is completed
   4032      *
   4033      * @hide
   4034      */
   4035     // @SystemApi
   4036     public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
   4037         freeStorageAndNotify(null, freeStorageSize, observer);
   4038     }
   4039 
   4040     /** {@hide} */
   4041     public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
   4042             IPackageDataObserver observer);
   4043 
   4044     /**
   4045      * Free storage by deleting LRU sorted list of cache files across
   4046      * all applications. If the currently available free storage
   4047      * on the device is greater than or equal to the requested
   4048      * free storage, no cache files are cleared. If the currently
   4049      * available storage on the device is less than the requested
   4050      * free storage, some or all of the cache files across
   4051      * all applications are deleted (based on last accessed time)
   4052      * to increase the free storage space on the device to
   4053      * the requested value. There is no guarantee that clearing all
   4054      * the cache files from all applications will clear up
   4055      * enough storage to achieve the desired value.
   4056      * @param freeStorageSize The number of bytes of storage to be
   4057      * freed by the system. Say if freeStorageSize is XX,
   4058      * and the current free storage is YY,
   4059      * if XX is less than YY, just return. if not free XX-YY number
   4060      * of bytes if possible.
   4061      * @param pi IntentSender call back used to
   4062      * notify when the operation is completed.May be null
   4063      * to indicate that no call back is desired.
   4064      *
   4065      * @hide
   4066      */
   4067     public void freeStorage(long freeStorageSize, IntentSender pi) {
   4068         freeStorage(null, freeStorageSize, pi);
   4069     }
   4070 
   4071     /** {@hide} */
   4072     public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
   4073 
   4074     /**
   4075      * Retrieve the size information for a package.
   4076      * Since this may take a little while, the result will
   4077      * be posted back to the given observer.  The calling context
   4078      * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
   4079      *
   4080      * @param packageName The name of the package whose size information is to be retrieved
   4081      * @param userHandle The user whose size information should be retrieved.
   4082      * @param observer An observer callback to get notified when the operation
   4083      * is complete.
   4084      * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
   4085      * The observer's callback is invoked with a PackageStats object(containing the
   4086      * code, data and cache sizes of the package) and a boolean value representing
   4087      * the status of the operation. observer may be null to indicate that
   4088      * no callback is desired.
   4089      *
   4090      * @hide
   4091      */
   4092     public abstract void getPackageSizeInfo(String packageName, int userHandle,
   4093             IPackageStatsObserver observer);
   4094 
   4095     /**
   4096      * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
   4097      * returns the size for the calling user.
   4098      *
   4099      * @hide
   4100      */
   4101     public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
   4102         getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
   4103     }
   4104 
   4105     /**
   4106      * @deprecated This function no longer does anything; it was an old
   4107      * approach to managing preferred activities, which has been superseded
   4108      * by (and conflicts with) the modern activity-based preferences.
   4109      */
   4110     @Deprecated
   4111     public abstract void addPackageToPreferred(String packageName);
   4112 
   4113     /**
   4114      * @deprecated This function no longer does anything; it was an old
   4115      * approach to managing preferred activities, which has been superseded
   4116      * by (and conflicts with) the modern activity-based preferences.
   4117      */
   4118     @Deprecated
   4119     public abstract void removePackageFromPreferred(String packageName);
   4120 
   4121     /**
   4122      * Retrieve the list of all currently configured preferred packages.  The
   4123      * first package on the list is the most preferred, the last is the
   4124      * least preferred.
   4125      *
   4126      * @param flags Additional option flags. Use any combination of
   4127      * {@link #GET_ACTIVITIES},
   4128      * {@link #GET_GIDS},
   4129      * {@link #GET_CONFIGURATIONS},
   4130      * {@link #GET_INSTRUMENTATION},
   4131      * {@link #GET_PERMISSIONS},
   4132      * {@link #GET_PROVIDERS},
   4133      * {@link #GET_RECEIVERS},
   4134      * {@link #GET_SERVICES},
   4135      * {@link #GET_SIGNATURES}, to modify the data returned.
   4136      *
   4137      * @return Returns a list of PackageInfo objects describing each
   4138      * preferred application, in order of preference.
   4139      *
   4140      * @see #GET_ACTIVITIES
   4141      * @see #GET_GIDS
   4142      * @see #GET_CONFIGURATIONS
   4143      * @see #GET_INSTRUMENTATION
   4144      * @see #GET_PERMISSIONS
   4145      * @see #GET_PROVIDERS
   4146      * @see #GET_RECEIVERS
   4147      * @see #GET_SERVICES
   4148      * @see #GET_SIGNATURES
   4149      */
   4150     public abstract List<PackageInfo> getPreferredPackages(int flags);
   4151 
   4152     /**
   4153      * @deprecated This is a protected API that should not have been available
   4154      * to third party applications.  It is the platform's responsibility for
   4155      * assigning preferred activities and this cannot be directly modified.
   4156      *
   4157      * Add a new preferred activity mapping to the system.  This will be used
   4158      * to automatically select the given activity component when
   4159      * {@link Context#startActivity(Intent) Context.startActivity()} finds
   4160      * multiple matching activities and also matches the given filter.
   4161      *
   4162      * @param filter The set of intents under which this activity will be
   4163      * made preferred.
   4164      * @param match The IntentFilter match category that this preference
   4165      * applies to.
   4166      * @param set The set of activities that the user was picking from when
   4167      * this preference was made.
   4168      * @param activity The component name of the activity that is to be
   4169      * preferred.
   4170      */
   4171     @Deprecated
   4172     public abstract void addPreferredActivity(IntentFilter filter, int match,
   4173             ComponentName[] set, ComponentName activity);
   4174 
   4175     /**
   4176      * Same as {@link #addPreferredActivity(IntentFilter, int,
   4177             ComponentName[], ComponentName)}, but with a specific userId to apply the preference
   4178             to.
   4179      * @hide
   4180      */
   4181     public void addPreferredActivity(IntentFilter filter, int match,
   4182             ComponentName[] set, ComponentName activity, int userId) {
   4183         throw new RuntimeException("Not implemented. Must override in a subclass.");
   4184     }
   4185 
   4186     /**
   4187      * @deprecated This is a protected API that should not have been available
   4188      * to third party applications.  It is the platform's responsibility for
   4189      * assigning preferred activities and this cannot be directly modified.
   4190      *
   4191      * Replaces an existing preferred activity mapping to the system, and if that were not present
   4192      * adds a new preferred activity.  This will be used
   4193      * to automatically select the given activity component when
   4194      * {@link Context#startActivity(Intent) Context.startActivity()} finds
   4195      * multiple matching activities and also matches the given filter.
   4196      *
   4197      * @param filter The set of intents under which this activity will be
   4198      * made preferred.
   4199      * @param match The IntentFilter match category that this preference
   4200      * applies to.
   4201      * @param set The set of activities that the user was picking from when
   4202      * this preference was made.
   4203      * @param activity The component name of the activity that is to be
   4204      * preferred.
   4205      * @hide
   4206      */
   4207     @Deprecated
   4208     public abstract void replacePreferredActivity(IntentFilter filter, int match,
   4209             ComponentName[] set, ComponentName activity);
   4210 
   4211     /**
   4212      * @hide
   4213      */
   4214     @Deprecated
   4215     public void replacePreferredActivityAsUser(IntentFilter filter, int match,
   4216            ComponentName[] set, ComponentName activity, int userId) {
   4217         throw new RuntimeException("Not implemented. Must override in a subclass.");
   4218     }
   4219 
   4220     /**
   4221      * Remove all preferred activity mappings, previously added with
   4222      * {@link #addPreferredActivity}, from the
   4223      * system whose activities are implemented in the given package name.
   4224      * An application can only clear its own package(s).
   4225      *
   4226      * @param packageName The name of the package whose preferred activity
   4227      * mappings are to be removed.
   4228      */
   4229     public abstract void clearPackagePreferredActivities(String packageName);
   4230 
   4231     /**
   4232      * Retrieve all preferred activities, previously added with
   4233      * {@link #addPreferredActivity}, that are
   4234      * currently registered with the system.
   4235      *
   4236      * @param outFilters A required list in which to place the filters of all of the
   4237      * preferred activities.
   4238      * @param outActivities A required list in which to place the component names of
   4239      * all of the preferred activities.
   4240      * @param packageName An optional package in which you would like to limit
   4241      * the list.  If null, all activities will be returned; if non-null, only
   4242      * those activities in the given package are returned.
   4243      *
   4244      * @return Returns the total number of registered preferred activities
   4245      * (the number of distinct IntentFilter records, not the number of unique
   4246      * activity components) that were found.
   4247      */
   4248     public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
   4249             @NonNull List<ComponentName> outActivities, String packageName);
   4250 
   4251     /**
   4252      * Ask for the set of available 'home' activities and the current explicit
   4253      * default, if any.
   4254      * @hide
   4255      */
   4256     public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
   4257 
   4258     /**
   4259      * Set the enabled setting for a package component (activity, receiver, service, provider).
   4260      * This setting will override any enabled state which may have been set by the component in its
   4261      * manifest.
   4262      *
   4263      * @param componentName The component to enable
   4264      * @param newState The new enabled state for the component.  The legal values for this state
   4265      *                 are:
   4266      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
   4267      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
   4268      *                   and
   4269      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
   4270      *                 The last one removes the setting, thereby restoring the component's state to
   4271      *                 whatever was set in it's manifest (or enabled, by default).
   4272      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
   4273      */
   4274     public abstract void setComponentEnabledSetting(ComponentName componentName,
   4275             int newState, int flags);
   4276 
   4277 
   4278     /**
   4279      * Return the enabled setting for a package component (activity,
   4280      * receiver, service, provider).  This returns the last value set by
   4281      * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
   4282      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
   4283      * the value originally specified in the manifest has not been modified.
   4284      *
   4285      * @param componentName The component to retrieve.
   4286      * @return Returns the current enabled state for the component.  May
   4287      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
   4288      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
   4289      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
   4290      * component's enabled state is based on the original information in
   4291      * the manifest as found in {@link ComponentInfo}.
   4292      */
   4293     public abstract int getComponentEnabledSetting(ComponentName componentName);
   4294 
   4295     /**
   4296      * Set the enabled setting for an application
   4297      * This setting will override any enabled state which may have been set by the application in
   4298      * its manifest.  It also overrides the enabled state set in the manifest for any of the
   4299      * application's components.  It does not override any enabled state set by
   4300      * {@link #setComponentEnabledSetting} for any of the application's components.
   4301      *
   4302      * @param packageName The package name of the application to enable
   4303      * @param newState The new enabled state for the component.  The legal values for this state
   4304      *                 are:
   4305      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
   4306      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
   4307      *                   and
   4308      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
   4309      *                 The last one removes the setting, thereby restoring the applications's state to
   4310      *                 whatever was set in its manifest (or enabled, by default).
   4311      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
   4312      */
   4313     public abstract void setApplicationEnabledSetting(String packageName,
   4314             int newState, int flags);
   4315 
   4316     /**
   4317      * Return the enabled setting for an application. This returns
   4318      * the last value set by
   4319      * {@link #setApplicationEnabledSetting(String, int, int)}; in most
   4320      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
   4321      * the value originally specified in the manifest has not been modified.
   4322      *
   4323      * @param packageName The package name of the application to retrieve.
   4324      * @return Returns the current enabled state for the application.  May
   4325      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
   4326      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
   4327      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
   4328      * application's enabled state is based on the original information in
   4329      * the manifest as found in {@link ComponentInfo}.
   4330      * @throws IllegalArgumentException if the named package does not exist.
   4331      */
   4332     public abstract int getApplicationEnabledSetting(String packageName);
   4333 
   4334     /**
   4335      * Puts the package in a hidden state, which is almost like an uninstalled state,
   4336      * making the package unavailable, but it doesn't remove the data or the actual
   4337      * package file. Application can be unhidden by either resetting the hidden state
   4338      * or by installing it, such as with {@link #installExistingPackage(String)}
   4339      * @hide
   4340      */
   4341     public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
   4342             UserHandle userHandle);
   4343 
   4344     /**
   4345      * Returns the hidden state of a package.
   4346      * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
   4347      * @hide
   4348      */
   4349     public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
   4350             UserHandle userHandle);
   4351 
   4352     /**
   4353      * Return whether the device has been booted into safe mode.
   4354      */
   4355     public abstract boolean isSafeMode();
   4356 
   4357     /**
   4358      * Adds a listener for permission changes for installed packages.
   4359      *
   4360      * @param listener The listener to add.
   4361      *
   4362      * @hide
   4363      */
   4364     @SystemApi
   4365     @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
   4366     public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
   4367 
   4368     /**
   4369      * Remvoes a listener for permission changes for installed packages.
   4370      *
   4371      * @param listener The listener to remove.
   4372      *
   4373      * @hide
   4374      */
   4375     @SystemApi
   4376     public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
   4377 
   4378     /**
   4379      * Return the {@link KeySet} associated with the String alias for this
   4380      * application.
   4381      *
   4382      * @param alias The alias for a given {@link KeySet} as defined in the
   4383      *        application's AndroidManifest.xml.
   4384      * @hide
   4385      */
   4386     public abstract KeySet getKeySetByAlias(String packageName, String alias);
   4387 
   4388     /** Return the signing {@link KeySet} for this application.
   4389      * @hide
   4390      */
   4391     public abstract KeySet getSigningKeySet(String packageName);
   4392 
   4393     /**
   4394      * Return whether the package denoted by packageName has been signed by all
   4395      * of the keys specified by the {@link KeySet} ks.  This will return true if
   4396      * the package has been signed by additional keys (a superset) as well.
   4397      * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
   4398      * @hide
   4399      */
   4400     public abstract boolean isSignedBy(String packageName, KeySet ks);
   4401 
   4402     /**
   4403      * Return whether the package denoted by packageName has been signed by all
   4404      * of, and only, the keys specified by the {@link KeySet} ks. Compare to
   4405      * {@link #isSignedBy(String packageName, KeySet ks)}.
   4406      * @hide
   4407      */
   4408     public abstract boolean isSignedByExactly(String packageName, KeySet ks);
   4409 
   4410     /**
   4411      * Attempts to move package resources from internal to external media or vice versa.
   4412      * Since this may take a little while, the result will
   4413      * be posted back to the given observer.   This call may fail if the calling context
   4414      * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
   4415      * named package cannot be found, or if the named package is a "system package".
   4416      *
   4417      * @param packageName The name of the package to delete
   4418      * @param observer An observer callback to get notified when the package move is
   4419      * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
   4420      * called when that happens.  observer may be null to indicate that no callback is desired.
   4421      * @param flags To indicate install location {@link #MOVE_INTERNAL} or
   4422      * {@link #MOVE_EXTERNAL_MEDIA}
   4423      *
   4424      * @hide
   4425      */
   4426     @Deprecated
   4427     public void movePackage(String packageName, IPackageMoveObserver observer, int flags) {
   4428         throw new UnsupportedOperationException();
   4429     }
   4430 
   4431     /** {@hide} */
   4432     public static boolean isMoveStatusFinished(int status) {
   4433         return (status < 0 || status > 100);
   4434     }
   4435 
   4436     /** {@hide} */
   4437     public static abstract class MoveCallback {
   4438         public void onCreated(int moveId, Bundle extras) {}
   4439         public abstract void onStatusChanged(int moveId, int status, long estMillis);
   4440     }
   4441 
   4442     /** {@hide} */
   4443     public abstract int getMoveStatus(int moveId);
   4444 
   4445     /** {@hide} */
   4446     public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
   4447     /** {@hide} */
   4448     public abstract void unregisterMoveCallback(MoveCallback callback);
   4449 
   4450     /** {@hide} */
   4451     public abstract int movePackage(String packageName, VolumeInfo vol);
   4452     /** {@hide} */
   4453     public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
   4454     /** {@hide} */
   4455     public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
   4456 
   4457     /** {@hide} */
   4458     public abstract int movePrimaryStorage(VolumeInfo vol);
   4459     /** {@hide} */
   4460     public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
   4461     /** {@hide} */
   4462     public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
   4463 
   4464     /**
   4465      * Returns the device identity that verifiers can use to associate their scheme to a particular
   4466      * device. This should not be used by anything other than a package verifier.
   4467      *
   4468      * @return identity that uniquely identifies current device
   4469      * @hide
   4470      */
   4471     public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
   4472 
   4473     /**
   4474      * Returns true if the device is upgrading, such as first boot after OTA.
   4475      *
   4476      * @hide
   4477      */
   4478     public abstract boolean isUpgrade();
   4479 
   4480     /**
   4481      * Return interface that offers the ability to install, upgrade, and remove
   4482      * applications on the device.
   4483      */
   4484     public abstract @NonNull PackageInstaller getPackageInstaller();
   4485 
   4486     /**
   4487      * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
   4488      * user with id sourceUserId can also be be resolved by activities in the user with id
   4489      * targetUserId if they match the specified intent filter.
   4490      * @param filter The {@link IntentFilter} the intent has to match
   4491      * @param sourceUserId The source user id.
   4492      * @param targetUserId The target user id.
   4493      * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
   4494      * @hide
   4495      */
   4496     public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
   4497             int targetUserId, int flags);
   4498 
   4499     /**
   4500      * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
   4501      * source, and have been set by the app calling this method.
   4502      * @param sourceUserId The source user id.
   4503      * @hide
   4504      */
   4505     public abstract void clearCrossProfileIntentFilters(int sourceUserId);
   4506 
   4507     /**
   4508      * @hide
   4509      */
   4510     public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
   4511 
   4512     /**
   4513      * @hide
   4514      */
   4515     public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
   4516 
   4517     /** {@hide} */
   4518     public abstract boolean isPackageAvailable(String packageName);
   4519 
   4520     /** {@hide} */
   4521     public static String installStatusToString(int status, String msg) {
   4522         final String str = installStatusToString(status);
   4523         if (msg != null) {
   4524             return str + ": " + msg;
   4525         } else {
   4526             return str;
   4527         }
   4528     }
   4529 
   4530     /** {@hide} */
   4531     public static String installStatusToString(int status) {
   4532         switch (status) {
   4533             case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
   4534             case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
   4535             case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
   4536             case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
   4537             case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
   4538             case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
   4539             case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
   4540             case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
   4541             case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
   4542             case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
   4543             case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
   4544             case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
   4545             case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
   4546             case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
   4547             case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
   4548             case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
   4549             case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
   4550             case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
   4551             case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
   4552             case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
   4553             case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
   4554             case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
   4555             case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
   4556             case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
   4557             case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
   4558             case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
   4559             case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
   4560             case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
   4561             case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
   4562             case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
   4563             case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
   4564             case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
   4565             case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
   4566             case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
   4567             case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
   4568             case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
   4569             case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
   4570             case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
   4571             case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
   4572             case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
   4573             case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
   4574             default: return Integer.toString(status);
   4575         }
   4576     }
   4577 
   4578     /** {@hide} */
   4579     public static int installStatusToPublicStatus(int status) {
   4580         switch (status) {
   4581             case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
   4582             case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4583             case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
   4584             case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
   4585             case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
   4586             case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4587             case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4588             case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4589             case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4590             case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
   4591             case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4592             case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
   4593             case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
   4594             case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4595             case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
   4596             case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
   4597             case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
   4598             case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
   4599             case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
   4600             case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
   4601             case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
   4602             case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
   4603             case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
   4604             case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
   4605             case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
   4606             case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
   4607             case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
   4608             case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
   4609             case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
   4610             case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
   4611             case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
   4612             case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
   4613             case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
   4614             case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
   4615             case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
   4616             case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
   4617             case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
   4618             case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
   4619             case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
   4620             case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
   4621             case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
   4622             case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
   4623             default: return PackageInstaller.STATUS_FAILURE;
   4624         }
   4625     }
   4626 
   4627     /** {@hide} */
   4628     public static String deleteStatusToString(int status, String msg) {
   4629         final String str = deleteStatusToString(status);
   4630         if (msg != null) {
   4631             return str + ": " + msg;
   4632         } else {
   4633             return str;
   4634         }
   4635     }
   4636 
   4637     /** {@hide} */
   4638     public static String deleteStatusToString(int status) {
   4639         switch (status) {
   4640             case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
   4641             case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
   4642             case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
   4643             case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
   4644             case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
   4645             case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
   4646             default: return Integer.toString(status);
   4647         }
   4648     }
   4649 
   4650     /** {@hide} */
   4651     public static int deleteStatusToPublicStatus(int status) {
   4652         switch (status) {
   4653             case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
   4654             case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
   4655             case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
   4656             case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
   4657             case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
   4658             case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
   4659             default: return PackageInstaller.STATUS_FAILURE;
   4660         }
   4661     }
   4662 
   4663     /** {@hide} */
   4664     public static String permissionFlagToString(int flag) {
   4665         switch (flag) {
   4666             case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
   4667             case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
   4668             case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
   4669             case FLAG_PERMISSION_USER_SET: return "USER_SET";
   4670             case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
   4671             case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
   4672             default: return Integer.toString(flag);
   4673         }
   4674     }
   4675 
   4676     /** {@hide} */
   4677     public static class LegacyPackageInstallObserver extends PackageInstallObserver {
   4678         private final IPackageInstallObserver mLegacy;
   4679 
   4680         public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
   4681             mLegacy = legacy;
   4682         }
   4683 
   4684         @Override
   4685         public void onPackageInstalled(String basePackageName, int returnCode, String msg,
   4686                 Bundle extras) {
   4687             if (mLegacy == null) return;
   4688             try {
   4689                 mLegacy.packageInstalled(basePackageName, returnCode);
   4690             } catch (RemoteException ignored) {
   4691             }
   4692         }
   4693     }
   4694 
   4695     /** {@hide} */
   4696     public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
   4697         private final IPackageDeleteObserver mLegacy;
   4698 
   4699         public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
   4700             mLegacy = legacy;
   4701         }
   4702 
   4703         @Override
   4704         public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
   4705             if (mLegacy == null) return;
   4706             try {
   4707                 mLegacy.packageDeleted(basePackageName, returnCode);
   4708             } catch (RemoteException ignored) {
   4709             }
   4710         }
   4711     }
   4712 }
   4713