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