PackageManager.java revision 19ccb5fd759dc9284da32320ed1219bee3e031be
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.IntDef;
20import android.annotation.NonNull;
21import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
23import android.annotation.SystemApi;
24import android.app.PackageDeleteObserver;
25import android.app.PackageInstallObserver;
26import android.content.ComponentName;
27import android.content.Context;
28import android.content.Intent;
29import android.content.IntentFilter;
30import android.content.IntentSender;
31import android.content.pm.PackageParser.PackageParserException;
32import android.content.res.Resources;
33import android.content.res.XmlResourceParser;
34import android.graphics.Rect;
35import android.graphics.drawable.Drawable;
36import android.net.Uri;
37import android.os.Bundle;
38import android.os.Environment;
39import android.os.RemoteException;
40import android.os.UserHandle;
41import android.util.AndroidException;
42
43import java.io.File;
44import java.lang.annotation.Retention;
45import java.lang.annotation.RetentionPolicy;
46import java.util.List;
47
48/**
49 * Class for retrieving various kinds of information related to the application
50 * packages that are currently installed on the device.
51 *
52 * You can find this class through {@link Context#getPackageManager}.
53 */
54public abstract class PackageManager {
55
56    /**
57     * This exception is thrown when a given package, application, or component
58     * name cannot be found.
59     */
60    public static class NameNotFoundException extends AndroidException {
61        public NameNotFoundException() {
62        }
63
64        public NameNotFoundException(String name) {
65            super(name);
66        }
67    }
68
69    /**
70     * {@link PackageInfo} flag: return information about
71     * activities in the package in {@link PackageInfo#activities}.
72     */
73    public static final int GET_ACTIVITIES              = 0x00000001;
74
75    /**
76     * {@link PackageInfo} flag: return information about
77     * intent receivers in the package in
78     * {@link PackageInfo#receivers}.
79     */
80    public static final int GET_RECEIVERS               = 0x00000002;
81
82    /**
83     * {@link PackageInfo} flag: return information about
84     * services in the package in {@link PackageInfo#services}.
85     */
86    public static final int GET_SERVICES                = 0x00000004;
87
88    /**
89     * {@link PackageInfo} flag: return information about
90     * content providers in the package in
91     * {@link PackageInfo#providers}.
92     */
93    public static final int GET_PROVIDERS               = 0x00000008;
94
95    /**
96     * {@link PackageInfo} flag: return information about
97     * instrumentation in the package in
98     * {@link PackageInfo#instrumentation}.
99     */
100    public static final int GET_INSTRUMENTATION         = 0x00000010;
101
102    /**
103     * {@link PackageInfo} flag: return information about the
104     * intent filters supported by the activity.
105     */
106    public static final int GET_INTENT_FILTERS          = 0x00000020;
107
108    /**
109     * {@link PackageInfo} flag: return information about the
110     * signatures included in the package.
111     */
112    public static final int GET_SIGNATURES          = 0x00000040;
113
114    /**
115     * {@link ResolveInfo} flag: return the IntentFilter that
116     * was matched for a particular ResolveInfo in
117     * {@link ResolveInfo#filter}.
118     */
119    public static final int GET_RESOLVED_FILTER         = 0x00000040;
120
121    /**
122     * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
123     * data {@link android.os.Bundle}s that are associated with a component.
124     * This applies for any API returning a ComponentInfo subclass.
125     */
126    public static final int GET_META_DATA               = 0x00000080;
127
128    /**
129     * {@link PackageInfo} flag: return the
130     * {@link PackageInfo#gids group ids} that are associated with an
131     * application.
132     * This applies for any API returning a PackageInfo class, either
133     * directly or nested inside of another.
134     */
135    public static final int GET_GIDS                    = 0x00000100;
136
137    /**
138     * {@link PackageInfo} flag: include disabled components in the returned info.
139     */
140    public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
141
142    /**
143     * {@link ApplicationInfo} flag: return the
144     * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
145     * that are associated with an application.
146     * This applies for any API returning an ApplicationInfo class, either
147     * directly or nested inside of another.
148     */
149    public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
150
151    /**
152     * {@link ProviderInfo} flag: return the
153     * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
154     * that are associated with a content provider.
155     * This applies for any API returning a ProviderInfo class, either
156     * directly or nested inside of another.
157     */
158    public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
159    /**
160     * {@link PackageInfo} flag: return information about
161     * permissions in the package in
162     * {@link PackageInfo#permissions}.
163     */
164    public static final int GET_PERMISSIONS               = 0x00001000;
165
166    /**
167     * Flag parameter to retrieve some information about all applications (even
168     * uninstalled ones) which have data directories. This state could have
169     * resulted if applications have been deleted with flag
170     * {@code DONT_DELETE_DATA} with a possibility of being replaced or
171     * reinstalled in future.
172     * <p>
173     * Note: this flag may cause less information about currently installed
174     * applications to be returned.
175     */
176    public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
177
178    /**
179     * {@link PackageInfo} flag: return information about
180     * hardware preferences in
181     * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
182     * and requested features in {@link PackageInfo#reqFeatures} and
183     * {@link PackageInfo#featureGroups}.
184     */
185    public static final int GET_CONFIGURATIONS = 0x00004000;
186
187    /**
188     * {@link PackageInfo} flag: include disabled components which are in
189     * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
190     * in the returned info.  Note that if you set this flag, applications
191     * that are in this disabled state will be reported as enabled.
192     */
193    public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
194
195    /**
196     * Resolution and querying flag: if set, only filters that support the
197     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
198     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
199     * supplied Intent.
200     */
201    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
202
203    /**
204     * Resolution and querying flag: do not resolve intents cross-profile.
205     * @hide
206     */
207    public static final int NO_CROSS_PROFILE = 0x00020000;
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 device's display has a touch screen.
1305     */
1306    @SdkConstant(SdkConstantType.FEATURE)
1307    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1308
1309
1310    /**
1311     * Feature for {@link #getSystemAvailableFeatures} and
1312     * {@link #hasSystemFeature}: The device's touch screen supports
1313     * multitouch sufficient for basic two-finger gesture detection.
1314     */
1315    @SdkConstant(SdkConstantType.FEATURE)
1316    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1317
1318    /**
1319     * Feature for {@link #getSystemAvailableFeatures} and
1320     * {@link #hasSystemFeature}: The device's touch screen is capable of
1321     * tracking two or more fingers fully independently.
1322     */
1323    @SdkConstant(SdkConstantType.FEATURE)
1324    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1325
1326    /**
1327     * Feature for {@link #getSystemAvailableFeatures} and
1328     * {@link #hasSystemFeature}: The device's touch screen is capable of
1329     * tracking a full hand of fingers fully independently -- that is, 5 or
1330     * more simultaneous independent pointers.
1331     */
1332    @SdkConstant(SdkConstantType.FEATURE)
1333    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1334
1335    /**
1336     * Feature for {@link #getSystemAvailableFeatures} and
1337     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1338     * does support touch emulation for basic events. For instance, the
1339     * device might use a mouse or remote control to drive a cursor, and
1340     * emulate basic touch pointer events like down, up, drag, etc. All
1341     * devices that support android.hardware.touchscreen or a sub-feature are
1342     * presumed to also support faketouch.
1343     */
1344    @SdkConstant(SdkConstantType.FEATURE)
1345    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1346
1347    /**
1348     * Feature for {@link #getSystemAvailableFeatures} and
1349     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1350     * does support touch emulation for basic events that supports distinct
1351     * tracking of two or more fingers.  This is an extension of
1352     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1353     * that unlike a distinct multitouch screen as defined by
1354     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1355     * devices will not actually provide full two-finger gestures since the
1356     * input is being transformed to cursor movement on the screen.  That is,
1357     * single finger gestures will move a cursor; two-finger swipes will
1358     * result in single-finger touch events; other two-finger gestures will
1359     * result in the corresponding two-finger touch event.
1360     */
1361    @SdkConstant(SdkConstantType.FEATURE)
1362    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1363
1364    /**
1365     * Feature for {@link #getSystemAvailableFeatures} and
1366     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1367     * does support touch emulation for basic events that supports tracking
1368     * a hand of fingers (5 or more fingers) fully independently.
1369     * This is an extension of
1370     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1371     * that unlike a multitouch screen as defined by
1372     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1373     * gestures can be detected due to the limitations described for
1374     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1375     */
1376    @SdkConstant(SdkConstantType.FEATURE)
1377    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1378
1379    /**
1380     * Feature for {@link #getSystemAvailableFeatures} and
1381     * {@link #hasSystemFeature}: The device supports portrait orientation
1382     * screens.  For backwards compatibility, you can assume that if neither
1383     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1384     * both portrait and landscape.
1385     */
1386    @SdkConstant(SdkConstantType.FEATURE)
1387    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1388
1389    /**
1390     * Feature for {@link #getSystemAvailableFeatures} and
1391     * {@link #hasSystemFeature}: The device supports landscape orientation
1392     * screens.  For backwards compatibility, you can assume that if neither
1393     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1394     * both portrait and landscape.
1395     */
1396    @SdkConstant(SdkConstantType.FEATURE)
1397    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1398
1399    /**
1400     * Feature for {@link #getSystemAvailableFeatures} and
1401     * {@link #hasSystemFeature}: The device supports live wallpapers.
1402     */
1403    @SdkConstant(SdkConstantType.FEATURE)
1404    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1405    /**
1406     * Feature for {@link #getSystemAvailableFeatures} and
1407     * {@link #hasSystemFeature}: The device supports app widgets.
1408     */
1409    @SdkConstant(SdkConstantType.FEATURE)
1410    public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1411
1412    /**
1413     * @hide
1414     * Feature for {@link #getSystemAvailableFeatures} and
1415     * {@link #hasSystemFeature}: The device supports
1416     * {@link android.service.voice.VoiceInteractionService} and
1417     * {@link android.app.VoiceInteractor}.
1418     */
1419    @SdkConstant(SdkConstantType.FEATURE)
1420    public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1421
1422
1423    /**
1424     * Feature for {@link #getSystemAvailableFeatures} and
1425     * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1426     * by third party applications.
1427     */
1428    @SdkConstant(SdkConstantType.FEATURE)
1429    public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1430
1431    /**
1432     * Feature for {@link #getSystemAvailableFeatures} and
1433     * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1434     * with the {@link android.inputmethodservice.InputMethodService} API.
1435     */
1436    @SdkConstant(SdkConstantType.FEATURE)
1437    public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1438
1439    /**
1440     * Feature for {@link #getSystemAvailableFeatures} and
1441     * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1442     */
1443    @SdkConstant(SdkConstantType.FEATURE)
1444    public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1445
1446    /**
1447     * Feature for {@link #getSystemAvailableFeatures} and
1448     * {@link #hasSystemFeature}: The device supports leanback UI. This is
1449     * typically used in a living room television experience, but is a software
1450     * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
1451     * feature will use resources associated with the "television" UI mode.
1452     */
1453    @SdkConstant(SdkConstantType.FEATURE)
1454    public static final String FEATURE_LEANBACK = "android.software.leanback";
1455
1456    /**
1457     * Feature for {@link #getSystemAvailableFeatures} and
1458     * {@link #hasSystemFeature}: The device supports only leanback UI. Only
1459     * applications designed for this experience should be run, though this is
1460     * not enforced by the system.
1461     * @hide
1462     */
1463    @SdkConstant(SdkConstantType.FEATURE)
1464    public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
1465
1466    /**
1467     * Feature for {@link #getSystemAvailableFeatures} and
1468     * {@link #hasSystemFeature}: The device supports live TV and can display
1469     * contents from TV inputs implemented with the
1470     * {@link android.media.tv.TvInputService} API.
1471     */
1472    @SdkConstant(SdkConstantType.FEATURE)
1473    public static final String FEATURE_LIVE_TV = "android.software.live_tv";
1474
1475    /**
1476     * Feature for {@link #getSystemAvailableFeatures} and
1477     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1478     */
1479    @SdkConstant(SdkConstantType.FEATURE)
1480    public static final String FEATURE_WIFI = "android.hardware.wifi";
1481
1482    /**
1483     * Feature for {@link #getSystemAvailableFeatures} and
1484     * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1485     */
1486    @SdkConstant(SdkConstantType.FEATURE)
1487    public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1488
1489    /**
1490     * Feature for {@link #getSystemAvailableFeatures} and
1491     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1492     * on a television.  Television here is defined to be a typical living
1493     * room television experience: displayed on a big screen, where the user
1494     * is sitting far away from it, and the dominant form of input will be
1495     * something like a DPAD, not through touch or mouse.
1496     * @deprecated use {@link #FEATURE_LEANBACK} instead.
1497     */
1498    @Deprecated
1499    @SdkConstant(SdkConstantType.FEATURE)
1500    public static final String FEATURE_TELEVISION = "android.hardware.type.television";
1501
1502    /**
1503     * Feature for {@link #getSystemAvailableFeatures} and
1504     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1505     * on a watch. A watch here is defined to be a device worn on the body, perhaps on
1506     * the wrist. The user is very close when interacting with the device.
1507     */
1508    @SdkConstant(SdkConstantType.FEATURE)
1509    public static final String FEATURE_WATCH = "android.hardware.type.watch";
1510
1511    /**
1512     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1513     * The device supports printing.
1514     */
1515    @SdkConstant(SdkConstantType.FEATURE)
1516    public static final String FEATURE_PRINTING = "android.software.print";
1517
1518    /**
1519     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1520     * The device can perform backup and restore operations on installed applications.
1521     */
1522    @SdkConstant(SdkConstantType.FEATURE)
1523    public static final String FEATURE_BACKUP = "android.software.backup";
1524
1525    /**
1526     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1527     * The device supports managed profiles for enterprise users.
1528     */
1529    @SdkConstant(SdkConstantType.FEATURE)
1530    public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_profiles";
1531
1532    /**
1533     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1534     * The device supports verified boot.
1535     */
1536    @SdkConstant(SdkConstantType.FEATURE)
1537    public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
1538
1539    /**
1540     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1541     * The device supports secure removal of users. When a user is deleted the data associated
1542     * with that user is securely deleted and no longer available.
1543     */
1544    @SdkConstant(SdkConstantType.FEATURE)
1545    public static final String FEATURE_SECURELY_REMOVES_USERS
1546            = "android.software.securely_removes_users";
1547
1548    /**
1549     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1550     * The device has a full implementation of the android.webkit.* APIs. Devices
1551     * lacking this feature will not have a functioning WebView implementation.
1552     */
1553    @SdkConstant(SdkConstantType.FEATURE)
1554    public static final String FEATURE_WEBVIEW = "android.software.webview";
1555
1556    /**
1557     * Feature for {@link #getSystemAvailableFeatures} and
1558     * {@link #hasSystemFeature}: This device supports ethernet.
1559     * @hide
1560     */
1561    @SdkConstant(SdkConstantType.FEATURE)
1562    public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
1563
1564    /**
1565     * Feature for {@link #getSystemAvailableFeatures} and
1566     * {@link #hasSystemFeature}: This device supports HDMI-CEC.
1567     * @hide
1568     */
1569    @SdkConstant(SdkConstantType.FEATURE)
1570    public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
1571
1572    /**
1573     * Action to external storage service to clean out removed apps.
1574     * @hide
1575     */
1576    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1577            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1578
1579    /**
1580     * Extra field name for the URI to a verification file. Passed to a package
1581     * verifier.
1582     *
1583     * @hide
1584     */
1585    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1586
1587    /**
1588     * Extra field name for the ID of a package pending verification. Passed to
1589     * a package verifier and is used to call back to
1590     * {@link PackageManager#verifyPendingInstall(int, int)}
1591     */
1592    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1593
1594    /**
1595     * Extra field name for the package identifier which is trying to install
1596     * the package.
1597     *
1598     * @hide
1599     */
1600    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1601            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1602
1603    /**
1604     * Extra field name for the requested install flags for a package pending
1605     * verification. Passed to a package verifier.
1606     *
1607     * @hide
1608     */
1609    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1610            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1611
1612    /**
1613     * Extra field name for the uid of who is requesting to install
1614     * the package.
1615     *
1616     * @hide
1617     */
1618    public static final String EXTRA_VERIFICATION_INSTALLER_UID
1619            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1620
1621    /**
1622     * Extra field name for the package name of a package pending verification.
1623     *
1624     * @hide
1625     */
1626    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1627            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1628    /**
1629     * Extra field name for the result of a verification, either
1630     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1631     * Passed to package verifiers after a package is verified.
1632     */
1633    public static final String EXTRA_VERIFICATION_RESULT
1634            = "android.content.pm.extra.VERIFICATION_RESULT";
1635
1636    /**
1637     * Extra field name for the version code of a package pending verification.
1638     *
1639     * @hide
1640     */
1641    public static final String EXTRA_VERIFICATION_VERSION_CODE
1642            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1643
1644    /**
1645     * The action used to request that the user approve a permission request
1646     * from the application.
1647     *
1648     * @hide
1649     */
1650    public static final String ACTION_REQUEST_PERMISSION
1651            = "android.content.pm.action.REQUEST_PERMISSION";
1652
1653    /**
1654     * Extra field name for the list of permissions, which the user must approve.
1655     *
1656     * @hide
1657     */
1658    public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST
1659            = "android.content.pm.extra.PERMISSION_LIST";
1660
1661    /**
1662     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1663     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
1664     * the existing definition for the permission.
1665     * @hide
1666     */
1667    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1668            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1669
1670    /**
1671     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1672     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
1673     * being redundantly defined by the package being installed.
1674     * @hide
1675     */
1676    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1677            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1678
1679    /**
1680     * Retrieve overall information about an application package that is
1681     * installed on the system.
1682     * <p>
1683     * Throws {@link NameNotFoundException} if a package with the given name can
1684     * not be found on the system.
1685     *
1686     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1687     *            desired package.
1688     * @param flags Additional option flags. Use any combination of
1689     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1690     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1691     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1692     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1693     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1694     *            modify the data returned.
1695     * @return Returns a PackageInfo object containing information about the
1696     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1697     *         package is not found in the list of installed applications, the
1698     *         package information is retrieved from the list of uninstalled
1699     *         applications (which includes installed applications as well as
1700     *         applications with data directory i.e. applications which had been
1701     *         deleted with {@code DONT_DELETE_DATA} flag set).
1702     * @see #GET_ACTIVITIES
1703     * @see #GET_GIDS
1704     * @see #GET_CONFIGURATIONS
1705     * @see #GET_INSTRUMENTATION
1706     * @see #GET_PERMISSIONS
1707     * @see #GET_PROVIDERS
1708     * @see #GET_RECEIVERS
1709     * @see #GET_SERVICES
1710     * @see #GET_SIGNATURES
1711     * @see #GET_UNINSTALLED_PACKAGES
1712     */
1713    public abstract PackageInfo getPackageInfo(String packageName, int flags)
1714            throws NameNotFoundException;
1715
1716    /**
1717     * Map from the current package names in use on the device to whatever
1718     * the current canonical name of that package is.
1719     * @param names Array of current names to be mapped.
1720     * @return Returns an array of the same size as the original, containing
1721     * the canonical name for each package.
1722     */
1723    public abstract String[] currentToCanonicalPackageNames(String[] names);
1724
1725    /**
1726     * Map from a packages canonical name to the current name in use on the device.
1727     * @param names Array of new names to be mapped.
1728     * @return Returns an array of the same size as the original, containing
1729     * the current name for each package.
1730     */
1731    public abstract String[] canonicalToCurrentPackageNames(String[] names);
1732
1733    /**
1734     * Returns a "good" intent to launch a front-door activity in a package.
1735     * This is used, for example, to implement an "open" button when browsing
1736     * through packages.  The current implementation looks first for a main
1737     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
1738     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
1739     * <code>null</code> if neither are found.
1740     *
1741     * @param packageName The name of the package to inspect.
1742     *
1743     * @return A fully-qualified {@link Intent} that can be used to launch the
1744     * main activity in the package. Returns <code>null</code> if the package
1745     * does not contain such an activity, or if <em>packageName</em> is not
1746     * recognized.
1747     */
1748    public abstract Intent getLaunchIntentForPackage(String packageName);
1749
1750    /**
1751     * Return a "good" intent to launch a front-door Leanback activity in a
1752     * package, for use for example to implement an "open" button when browsing
1753     * through packages. The current implementation will look for a main
1754     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
1755     * return null if no main leanback activities are found.
1756     * <p>
1757     * Throws {@link NameNotFoundException} if a package with the given name
1758     * cannot be found on the system.
1759     *
1760     * @param packageName The name of the package to inspect.
1761     * @return Returns either a fully-qualified Intent that can be used to launch
1762     *         the main Leanback activity in the package, or null if the package
1763     *         does not contain such an activity.
1764     */
1765    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
1766
1767    /**
1768     * Return an array of all of the secondary group-ids that have been assigned
1769     * to a package.
1770     * <p>
1771     * Throws {@link NameNotFoundException} if a package with the given name
1772     * cannot be found on the system.
1773     *
1774     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1775     *            desired package.
1776     * @return Returns an int array of the assigned gids, or null if there are
1777     *         none.
1778     */
1779    public abstract int[] getPackageGids(String packageName)
1780            throws NameNotFoundException;
1781
1782    /**
1783     * @hide Return the uid associated with the given package name for the
1784     * given user.
1785     *
1786     * <p>Throws {@link NameNotFoundException} if a package with the given
1787     * name can not be found on the system.
1788     *
1789     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1790     *                    desired package.
1791     * @param userHandle The user handle identifier to look up the package under.
1792     *
1793     * @return Returns an integer uid who owns the given package name.
1794     */
1795    public abstract int getPackageUid(String packageName, int userHandle)
1796            throws NameNotFoundException;
1797
1798    /**
1799     * Retrieve all of the information we know about a particular permission.
1800     *
1801     * <p>Throws {@link NameNotFoundException} if a permission with the given
1802     * name cannot be found on the system.
1803     *
1804     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1805     *             of the permission you are interested in.
1806     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1807     * retrieve any meta-data associated with the permission.
1808     *
1809     * @return Returns a {@link PermissionInfo} containing information about the
1810     *         permission.
1811     */
1812    public abstract PermissionInfo getPermissionInfo(String name, int flags)
1813            throws NameNotFoundException;
1814
1815    /**
1816     * Query for all of the permissions associated with a particular group.
1817     *
1818     * <p>Throws {@link NameNotFoundException} if the given group does not
1819     * exist.
1820     *
1821     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1822     *             of the permission group you are interested in.  Use null to
1823     *             find all of the permissions not associated with a group.
1824     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1825     * retrieve any meta-data associated with the permissions.
1826     *
1827     * @return Returns a list of {@link PermissionInfo} containing information
1828     * about all of the permissions in the given group.
1829     */
1830    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1831            int flags) throws NameNotFoundException;
1832
1833    /**
1834     * Retrieve all of the information we know about a particular group of
1835     * permissions.
1836     *
1837     * <p>Throws {@link NameNotFoundException} if a permission group with the given
1838     * name cannot be found on the system.
1839     *
1840     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1841     *             of the permission you are interested in.
1842     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1843     * retrieve any meta-data associated with the permission group.
1844     *
1845     * @return Returns a {@link PermissionGroupInfo} containing information
1846     * about the permission.
1847     */
1848    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1849            int flags) throws NameNotFoundException;
1850
1851    /**
1852     * Retrieve all of the known permission groups in the system.
1853     *
1854     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1855     * retrieve any meta-data associated with the permission group.
1856     *
1857     * @return Returns a list of {@link PermissionGroupInfo} containing
1858     * information about all of the known permission groups.
1859     */
1860    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1861
1862    /**
1863     * Retrieve all of the information we know about a particular
1864     * package/application.
1865     *
1866     * <p>Throws {@link NameNotFoundException} if an application with the given
1867     * package name cannot be found on the system.
1868     *
1869     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1870     *                    application.
1871     * @param flags Additional option flags. Use any combination of
1872     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1873     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1874     *
1875     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1876     *         information about the package.
1877     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1878     *         found in the list of installed applications,
1879     *         the application information is retrieved from the
1880     *         list of uninstalled applications(which includes
1881     *         installed applications as well as applications
1882     *         with data directory ie applications which had been
1883     *         deleted with {@code DONT_DELETE_DATA} flag set).
1884     *
1885     * @see #GET_META_DATA
1886     * @see #GET_SHARED_LIBRARY_FILES
1887     * @see #GET_UNINSTALLED_PACKAGES
1888     */
1889    public abstract ApplicationInfo getApplicationInfo(String packageName,
1890            int flags) throws NameNotFoundException;
1891
1892    /**
1893     * Retrieve all of the information we know about a particular activity
1894     * class.
1895     *
1896     * <p>Throws {@link NameNotFoundException} if an activity with the given
1897     * class name cannot be found on the system.
1898     *
1899     * @param component The full component name (i.e.
1900     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1901     * class.
1902     * @param flags Additional option flags. Use any combination of
1903     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1904     * to modify the data (in ApplicationInfo) returned.
1905     *
1906     * @return {@link ActivityInfo} containing information about the activity.
1907     *
1908     * @see #GET_INTENT_FILTERS
1909     * @see #GET_META_DATA
1910     * @see #GET_SHARED_LIBRARY_FILES
1911     */
1912    public abstract ActivityInfo getActivityInfo(ComponentName component,
1913            int flags) throws NameNotFoundException;
1914
1915    /**
1916     * Retrieve all of the information we know about a particular receiver
1917     * class.
1918     *
1919     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1920     * class name cannot be found on the system.
1921     *
1922     * @param component The full component name (i.e.
1923     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1924     * class.
1925     * @param flags Additional option flags.  Use any combination of
1926     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1927     * to modify the data returned.
1928     *
1929     * @return {@link ActivityInfo} containing information about the receiver.
1930     *
1931     * @see #GET_INTENT_FILTERS
1932     * @see #GET_META_DATA
1933     * @see #GET_SHARED_LIBRARY_FILES
1934     */
1935    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1936            int flags) throws NameNotFoundException;
1937
1938    /**
1939     * Retrieve all of the information we know about a particular service
1940     * class.
1941     *
1942     * <p>Throws {@link NameNotFoundException} if a service with the given
1943     * class name cannot be found on the system.
1944     *
1945     * @param component The full component name (i.e.
1946     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1947     * class.
1948     * @param flags Additional option flags.  Use any combination of
1949     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1950     * to modify the data returned.
1951     *
1952     * @return ServiceInfo containing information about the service.
1953     *
1954     * @see #GET_META_DATA
1955     * @see #GET_SHARED_LIBRARY_FILES
1956     */
1957    public abstract ServiceInfo getServiceInfo(ComponentName component,
1958            int flags) throws NameNotFoundException;
1959
1960    /**
1961     * Retrieve all of the information we know about a particular content
1962     * provider class.
1963     *
1964     * <p>Throws {@link NameNotFoundException} if a provider with the given
1965     * class name cannot be found on the system.
1966     *
1967     * @param component The full component name (i.e.
1968     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1969     * ContentProvider class.
1970     * @param flags Additional option flags.  Use any combination of
1971     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1972     * to modify the data returned.
1973     *
1974     * @return ProviderInfo containing information about the service.
1975     *
1976     * @see #GET_META_DATA
1977     * @see #GET_SHARED_LIBRARY_FILES
1978     */
1979    public abstract ProviderInfo getProviderInfo(ComponentName component,
1980            int flags) throws NameNotFoundException;
1981
1982    /**
1983     * Return a List of all packages that are installed
1984     * on the device.
1985     *
1986     * @param flags Additional option flags. Use any combination of
1987     * {@link #GET_ACTIVITIES},
1988     * {@link #GET_GIDS},
1989     * {@link #GET_CONFIGURATIONS},
1990     * {@link #GET_INSTRUMENTATION},
1991     * {@link #GET_PERMISSIONS},
1992     * {@link #GET_PROVIDERS},
1993     * {@link #GET_RECEIVERS},
1994     * {@link #GET_SERVICES},
1995     * {@link #GET_SIGNATURES},
1996     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1997     *
1998     * @return A List of PackageInfo objects, one for each package that is
1999     *         installed on the device.  In the unlikely case of there being no
2000     *         installed packages, an empty list is returned.
2001     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2002     *         applications including those deleted with {@code DONT_DELETE_DATA}
2003     *         (partially installed apps with data directory) will be returned.
2004     *
2005     * @see #GET_ACTIVITIES
2006     * @see #GET_GIDS
2007     * @see #GET_CONFIGURATIONS
2008     * @see #GET_INSTRUMENTATION
2009     * @see #GET_PERMISSIONS
2010     * @see #GET_PROVIDERS
2011     * @see #GET_RECEIVERS
2012     * @see #GET_SERVICES
2013     * @see #GET_SIGNATURES
2014     * @see #GET_UNINSTALLED_PACKAGES
2015     */
2016    public abstract List<PackageInfo> getInstalledPackages(int flags);
2017
2018    /**
2019     * Return a List of all installed packages that are currently
2020     * holding any of the given permissions.
2021     *
2022     * @param flags Additional option flags. Use any combination of
2023     * {@link #GET_ACTIVITIES},
2024     * {@link #GET_GIDS},
2025     * {@link #GET_CONFIGURATIONS},
2026     * {@link #GET_INSTRUMENTATION},
2027     * {@link #GET_PERMISSIONS},
2028     * {@link #GET_PROVIDERS},
2029     * {@link #GET_RECEIVERS},
2030     * {@link #GET_SERVICES},
2031     * {@link #GET_SIGNATURES},
2032     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2033     *
2034     * @return Returns a List of PackageInfo objects, one for each installed
2035     * application that is holding any of the permissions that were provided.
2036     *
2037     * @see #GET_ACTIVITIES
2038     * @see #GET_GIDS
2039     * @see #GET_CONFIGURATIONS
2040     * @see #GET_INSTRUMENTATION
2041     * @see #GET_PERMISSIONS
2042     * @see #GET_PROVIDERS
2043     * @see #GET_RECEIVERS
2044     * @see #GET_SERVICES
2045     * @see #GET_SIGNATURES
2046     * @see #GET_UNINSTALLED_PACKAGES
2047     */
2048    public abstract List<PackageInfo> getPackagesHoldingPermissions(
2049            String[] permissions, int flags);
2050
2051    /**
2052     * Return a List of all packages that are installed on the device, for a specific user.
2053     * Requesting a list of installed packages for another user
2054     * will require the permission INTERACT_ACROSS_USERS_FULL.
2055     * @param flags Additional option flags. Use any combination of
2056     * {@link #GET_ACTIVITIES},
2057     * {@link #GET_GIDS},
2058     * {@link #GET_CONFIGURATIONS},
2059     * {@link #GET_INSTRUMENTATION},
2060     * {@link #GET_PERMISSIONS},
2061     * {@link #GET_PROVIDERS},
2062     * {@link #GET_RECEIVERS},
2063     * {@link #GET_SERVICES},
2064     * {@link #GET_SIGNATURES},
2065     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2066     * @param userId The user for whom the installed packages are to be listed
2067     *
2068     * @return A List of PackageInfo objects, one for each package that is
2069     *         installed on the device.  In the unlikely case of there being no
2070     *         installed packages, an empty list is returned.
2071     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2072     *         applications including those deleted with {@code DONT_DELETE_DATA}
2073     *         (partially installed apps with data directory) will be returned.
2074     *
2075     * @see #GET_ACTIVITIES
2076     * @see #GET_GIDS
2077     * @see #GET_CONFIGURATIONS
2078     * @see #GET_INSTRUMENTATION
2079     * @see #GET_PERMISSIONS
2080     * @see #GET_PROVIDERS
2081     * @see #GET_RECEIVERS
2082     * @see #GET_SERVICES
2083     * @see #GET_SIGNATURES
2084     * @see #GET_UNINSTALLED_PACKAGES
2085     *
2086     * @hide
2087     */
2088    public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2089
2090    /**
2091     * Check whether a particular package has been granted a particular
2092     * permission.
2093     *
2094     * @param permName The name of the permission you are checking for,
2095     * @param pkgName The name of the package you are checking against.
2096     *
2097     * @return If the package has the permission, PERMISSION_GRANTED is
2098     * returned.  If it does not have the permission, PERMISSION_DENIED
2099     * is returned.
2100     *
2101     * @see #PERMISSION_GRANTED
2102     * @see #PERMISSION_DENIED
2103     */
2104    public abstract int checkPermission(String permName, String pkgName);
2105
2106    /**
2107     * Add a new dynamic permission to the system.  For this to work, your
2108     * package must have defined a permission tree through the
2109     * {@link android.R.styleable#AndroidManifestPermissionTree
2110     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
2111     * permissions to trees that were defined by either its own package or
2112     * another with the same user id; a permission is in a tree if it
2113     * matches the name of the permission tree + ".": for example,
2114     * "com.foo.bar" is a member of the permission tree "com.foo".
2115     *
2116     * <p>It is good to make your permission tree name descriptive, because you
2117     * are taking possession of that entire set of permission names.  Thus, it
2118     * must be under a domain you control, with a suffix that will not match
2119     * any normal permissions that may be declared in any applications that
2120     * are part of that domain.
2121     *
2122     * <p>New permissions must be added before
2123     * any .apks are installed that use those permissions.  Permissions you
2124     * add through this method are remembered across reboots of the device.
2125     * If the given permission already exists, the info you supply here
2126     * will be used to update it.
2127     *
2128     * @param info Description of the permission to be added.
2129     *
2130     * @return Returns true if a new permission was created, false if an
2131     * existing one was updated.
2132     *
2133     * @throws SecurityException if you are not allowed to add the
2134     * given permission name.
2135     *
2136     * @see #removePermission(String)
2137     */
2138    public abstract boolean addPermission(PermissionInfo info);
2139
2140    /**
2141     * Like {@link #addPermission(PermissionInfo)} but asynchronously
2142     * persists the package manager state after returning from the call,
2143     * allowing it to return quicker and batch a series of adds at the
2144     * expense of no guarantee the added permission will be retained if
2145     * the device is rebooted before it is written.
2146     */
2147    public abstract boolean addPermissionAsync(PermissionInfo info);
2148
2149    /**
2150     * Removes a permission that was previously added with
2151     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
2152     * -- you are only allowed to remove permissions that you are allowed
2153     * to add.
2154     *
2155     * @param name The name of the permission to remove.
2156     *
2157     * @throws SecurityException if you are not allowed to remove the
2158     * given permission name.
2159     *
2160     * @see #addPermission(PermissionInfo)
2161     */
2162    public abstract void removePermission(String name);
2163
2164    /**
2165     * Returns an {@link Intent} suitable for passing to {@code startActivityForResult}
2166     * which prompts the user to grant {@code permissions} to this application.
2167     * @hide
2168     *
2169     * @throws NullPointerException if {@code permissions} is {@code null}.
2170     * @throws IllegalArgumentException if {@code permissions} contains {@code null}.
2171     */
2172    public Intent buildPermissionRequestIntent(String... permissions) {
2173        if (permissions == null) {
2174            throw new NullPointerException("permissions cannot be null");
2175        }
2176        for (String permission : permissions) {
2177            if (permission == null) {
2178                throw new IllegalArgumentException("permissions cannot contain null");
2179            }
2180        }
2181
2182        Intent i = new Intent(ACTION_REQUEST_PERMISSION);
2183        i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions);
2184        i.setPackage("com.android.packageinstaller");
2185        return i;
2186    }
2187
2188    /**
2189     * Grant a permission to an application which the application does not
2190     * already have.  The permission must have been requested by the application,
2191     * but as an optional permission.  If the application is not allowed to
2192     * hold the permission, a SecurityException is thrown.
2193     * @hide
2194     *
2195     * @param packageName The name of the package that the permission will be
2196     * granted to.
2197     * @param permissionName The name of the permission.
2198     */
2199    public abstract void grantPermission(String packageName, String permissionName);
2200
2201    /**
2202     * Revoke a permission that was previously granted by {@link #grantPermission}.
2203     * @hide
2204     *
2205     * @param packageName The name of the package that the permission will be
2206     * granted to.
2207     * @param permissionName The name of the permission.
2208     */
2209    public abstract void revokePermission(String packageName, String permissionName);
2210
2211    /**
2212     * Compare the signatures of two packages to determine if the same
2213     * signature appears in both of them.  If they do contain the same
2214     * signature, then they are allowed special privileges when working
2215     * with each other: they can share the same user-id, run instrumentation
2216     * against each other, etc.
2217     *
2218     * @param pkg1 First package name whose signature will be compared.
2219     * @param pkg2 Second package name whose signature will be compared.
2220     *
2221     * @return Returns an integer indicating whether all signatures on the
2222     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2223     * all signatures match or < 0 if there is not a match ({@link
2224     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2225     *
2226     * @see #checkSignatures(int, int)
2227     * @see #SIGNATURE_MATCH
2228     * @see #SIGNATURE_NO_MATCH
2229     * @see #SIGNATURE_UNKNOWN_PACKAGE
2230     */
2231    public abstract int checkSignatures(String pkg1, String pkg2);
2232
2233    /**
2234     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2235     * the two packages to be checked.  This can be useful, for example,
2236     * when doing the check in an IPC, where the UID is the only identity
2237     * available.  It is functionally identical to determining the package
2238     * associated with the UIDs and checking their signatures.
2239     *
2240     * @param uid1 First UID whose signature will be compared.
2241     * @param uid2 Second UID whose signature will be compared.
2242     *
2243     * @return Returns an integer indicating whether all signatures on the
2244     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2245     * all signatures match or < 0 if there is not a match ({@link
2246     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2247     *
2248     * @see #checkSignatures(String, String)
2249     * @see #SIGNATURE_MATCH
2250     * @see #SIGNATURE_NO_MATCH
2251     * @see #SIGNATURE_UNKNOWN_PACKAGE
2252     */
2253    public abstract int checkSignatures(int uid1, int uid2);
2254
2255    /**
2256     * Retrieve the names of all packages that are associated with a particular
2257     * user id.  In most cases, this will be a single package name, the package
2258     * that has been assigned that user id.  Where there are multiple packages
2259     * sharing the same user id through the "sharedUserId" mechanism, all
2260     * packages with that id will be returned.
2261     *
2262     * @param uid The user id for which you would like to retrieve the
2263     * associated packages.
2264     *
2265     * @return Returns an array of one or more packages assigned to the user
2266     * id, or null if there are no known packages with the given id.
2267     */
2268    public abstract String[] getPackagesForUid(int uid);
2269
2270    /**
2271     * Retrieve the official name associated with a user id.  This name is
2272     * guaranteed to never change, though it is possibly for the underlying
2273     * user id to be changed.  That is, if you are storing information about
2274     * user ids in persistent storage, you should use the string returned
2275     * by this function instead of the raw user-id.
2276     *
2277     * @param uid The user id for which you would like to retrieve a name.
2278     * @return Returns a unique name for the given user id, or null if the
2279     * user id is not currently assigned.
2280     */
2281    public abstract String getNameForUid(int uid);
2282
2283    /**
2284     * Return the user id associated with a shared user name. Multiple
2285     * applications can specify a shared user name in their manifest and thus
2286     * end up using a common uid. This might be used for new applications
2287     * that use an existing shared user name and need to know the uid of the
2288     * shared user.
2289     *
2290     * @param sharedUserName The shared user name whose uid is to be retrieved.
2291     * @return Returns the uid associated with the shared user, or  NameNotFoundException
2292     * if the shared user name is not being used by any installed packages
2293     * @hide
2294     */
2295    public abstract int getUidForSharedUser(String sharedUserName)
2296            throws NameNotFoundException;
2297
2298    /**
2299     * Return a List of all application packages that are installed on the
2300     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2301     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2302     * installed apps with data directory) will be returned.
2303     *
2304     * @param flags Additional option flags. Use any combination of
2305     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2306     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2307     *
2308     * @return Returns a List of ApplicationInfo objects, one for each application that
2309     *         is installed on the device.  In the unlikely case of there being
2310     *         no installed applications, an empty list is returned.
2311     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2312     *         applications including those deleted with {@code DONT_DELETE_DATA}
2313     *         (partially installed apps with data directory) will be returned.
2314     *
2315     * @see #GET_META_DATA
2316     * @see #GET_SHARED_LIBRARY_FILES
2317     * @see #GET_UNINSTALLED_PACKAGES
2318     */
2319    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2320
2321    /**
2322     * Get a list of shared libraries that are available on the
2323     * system.
2324     *
2325     * @return An array of shared library names that are
2326     * available on the system, or null if none are installed.
2327     *
2328     */
2329    public abstract String[] getSystemSharedLibraryNames();
2330
2331    /**
2332     * Get a list of features that are available on the
2333     * system.
2334     *
2335     * @return An array of FeatureInfo classes describing the features
2336     * that are available on the system, or null if there are none(!!).
2337     */
2338    public abstract FeatureInfo[] getSystemAvailableFeatures();
2339
2340    /**
2341     * Check whether the given feature name is one of the available
2342     * features as returned by {@link #getSystemAvailableFeatures()}.
2343     *
2344     * @return Returns true if the devices supports the feature, else
2345     * false.
2346     */
2347    public abstract boolean hasSystemFeature(String name);
2348
2349    /**
2350     * Determine the best action to perform for a given Intent.  This is how
2351     * {@link Intent#resolveActivity} finds an activity if a class has not
2352     * been explicitly specified.
2353     *
2354     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2355     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2356     * only flag.  You need to do so to resolve the activity in the same way
2357     * that {@link android.content.Context#startActivity(Intent)} and
2358     * {@link android.content.Intent#resolveActivity(PackageManager)
2359     * Intent.resolveActivity(PackageManager)} do.</p>
2360     *
2361     * @param intent An intent containing all of the desired specification
2362     *               (action, data, type, category, and/or component).
2363     * @param flags Additional option flags.  The most important is
2364     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2365     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2366     *
2367     * @return Returns a ResolveInfo containing the final activity intent that
2368     *         was determined to be the best action.  Returns null if no
2369     *         matching activity was found. If multiple matching activities are
2370     *         found and there is no default set, returns a ResolveInfo
2371     *         containing something else, such as the activity resolver.
2372     *
2373     * @see #MATCH_DEFAULT_ONLY
2374     * @see #GET_INTENT_FILTERS
2375     * @see #GET_RESOLVED_FILTER
2376     */
2377    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2378
2379    /**
2380     * Determine the best action to perform for a given Intent for a given user. This
2381     * is how {@link Intent#resolveActivity} finds an activity if a class has not
2382     * been explicitly specified.
2383     *
2384     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2385     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2386     * only flag.  You need to do so to resolve the activity in the same way
2387     * that {@link android.content.Context#startActivity(Intent)} and
2388     * {@link android.content.Intent#resolveActivity(PackageManager)
2389     * Intent.resolveActivity(PackageManager)} do.</p>
2390     *
2391     * @param intent An intent containing all of the desired specification
2392     *               (action, data, type, category, and/or component).
2393     * @param flags Additional option flags.  The most important is
2394     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2395     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2396     * @param userId The user id.
2397     *
2398     * @return Returns a ResolveInfo containing the final activity intent that
2399     *         was determined to be the best action.  Returns null if no
2400     *         matching activity was found. If multiple matching activities are
2401     *         found and there is no default set, returns a ResolveInfo
2402     *         containing something else, such as the activity resolver.
2403     *
2404     * @see #MATCH_DEFAULT_ONLY
2405     * @see #GET_INTENT_FILTERS
2406     * @see #GET_RESOLVED_FILTER
2407     *
2408     * @hide
2409     */
2410    public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2411
2412    /**
2413     * Retrieve all activities that can be performed for the given intent.
2414     *
2415     * @param intent The desired intent as per resolveActivity().
2416     * @param flags Additional option flags.  The most important is
2417     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2418     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2419     *
2420     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2421     *         Activity. These are ordered from best to worst match -- that
2422     *         is, the first item in the list is what is returned by
2423     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2424     *         list is returned.
2425     *
2426     * @see #MATCH_DEFAULT_ONLY
2427     * @see #GET_INTENT_FILTERS
2428     * @see #GET_RESOLVED_FILTER
2429     */
2430    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2431            int flags);
2432
2433    /**
2434     * Retrieve all activities that can be performed for the given intent, for a specific user.
2435     *
2436     * @param intent The desired intent as per resolveActivity().
2437     * @param flags Additional option flags.  The most important is
2438     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2439     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2440     *
2441     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2442     *         Activity. These are ordered from best to worst match -- that
2443     *         is, the first item in the list is what is returned by
2444     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2445     *         list is returned.
2446     *
2447     * @see #MATCH_DEFAULT_ONLY
2448     * @see #GET_INTENT_FILTERS
2449     * @see #GET_RESOLVED_FILTER
2450     * @see #NO_CROSS_PROFILE
2451     * @hide
2452     */
2453    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2454            int flags, int userId);
2455
2456
2457    /**
2458     * Retrieve a set of activities that should be presented to the user as
2459     * similar options.  This is like {@link #queryIntentActivities}, except it
2460     * also allows you to supply a list of more explicit Intents that you would
2461     * like to resolve to particular options, and takes care of returning the
2462     * final ResolveInfo list in a reasonable order, with no duplicates, based
2463     * on those inputs.
2464     *
2465     * @param caller The class name of the activity that is making the
2466     *               request.  This activity will never appear in the output
2467     *               list.  Can be null.
2468     * @param specifics An array of Intents that should be resolved to the
2469     *                  first specific results.  Can be null.
2470     * @param intent The desired intent as per resolveActivity().
2471     * @param flags Additional option flags.  The most important is
2472     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2473     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2474     *
2475     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2476     *         Activity. These are ordered first by all of the intents resolved
2477     *         in <var>specifics</var> and then any additional activities that
2478     *         can handle <var>intent</var> but did not get included by one of
2479     *         the <var>specifics</var> intents.  If there are no matching
2480     *         activities, an empty list is returned.
2481     *
2482     * @see #MATCH_DEFAULT_ONLY
2483     * @see #GET_INTENT_FILTERS
2484     * @see #GET_RESOLVED_FILTER
2485     */
2486    public abstract List<ResolveInfo> queryIntentActivityOptions(
2487            ComponentName caller, Intent[] specifics, Intent intent, int flags);
2488
2489    /**
2490     * Retrieve all receivers that can handle a broadcast of the given intent.
2491     *
2492     * @param intent The desired intent as per resolveActivity().
2493     * @param flags Additional option flags.
2494     *
2495     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2496     *         Receiver. These are ordered from first to last in priority.  If
2497     *         there are no matching receivers, an empty list is returned.
2498     *
2499     * @see #MATCH_DEFAULT_ONLY
2500     * @see #GET_INTENT_FILTERS
2501     * @see #GET_RESOLVED_FILTER
2502     */
2503    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2504            int flags);
2505
2506    /**
2507     * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
2508     * user.
2509     *
2510     * @param intent The desired intent as per resolveActivity().
2511     * @param flags Additional option flags.
2512     * @param userId The userId of the user being queried.
2513     *
2514     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2515     *         Receiver. These are ordered from first to last in priority.  If
2516     *         there are no matching receivers, an empty list is returned.
2517     *
2518     * @see #MATCH_DEFAULT_ONLY
2519     * @see #GET_INTENT_FILTERS
2520     * @see #GET_RESOLVED_FILTER
2521     * @hide
2522     */
2523    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2524            int flags, int userId);
2525
2526    /**
2527     * Determine the best service to handle for a given Intent.
2528     *
2529     * @param intent An intent containing all of the desired specification
2530     *               (action, data, type, category, and/or component).
2531     * @param flags Additional option flags.
2532     *
2533     * @return Returns a ResolveInfo containing the final service intent that
2534     *         was determined to be the best action.  Returns null if no
2535     *         matching service was found.
2536     *
2537     * @see #GET_INTENT_FILTERS
2538     * @see #GET_RESOLVED_FILTER
2539     */
2540    public abstract ResolveInfo resolveService(Intent intent, int flags);
2541
2542    /**
2543     * Retrieve all services that can match the given intent.
2544     *
2545     * @param intent The desired intent as per resolveService().
2546     * @param flags Additional option flags.
2547     *
2548     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2549     *         ServiceInfo. These are ordered from best to worst match -- that
2550     *         is, the first item in the list is what is returned by
2551     *         resolveService().  If there are no matching services, an empty
2552     *         list is returned.
2553     *
2554     * @see #GET_INTENT_FILTERS
2555     * @see #GET_RESOLVED_FILTER
2556     */
2557    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
2558            int flags);
2559
2560    /**
2561     * Retrieve all services that can match the given intent for a given user.
2562     *
2563     * @param intent The desired intent as per resolveService().
2564     * @param flags Additional option flags.
2565     * @param userId The user id.
2566     *
2567     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2568     *         ServiceInfo. These are ordered from best to worst match -- that
2569     *         is, the first item in the list is what is returned by
2570     *         resolveService().  If there are no matching services, an empty
2571     *         list is returned.
2572     *
2573     * @see #GET_INTENT_FILTERS
2574     * @see #GET_RESOLVED_FILTER
2575     *
2576     * @hide
2577     */
2578    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
2579            int flags, int userId);
2580
2581    /** {@hide} */
2582    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
2583            Intent intent, int flags, int userId);
2584
2585    /**
2586     * Retrieve all providers that can match the given intent.
2587     *
2588     * @param intent An intent containing all of the desired specification
2589     *            (action, data, type, category, and/or component).
2590     * @param flags Additional option flags.
2591     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2592     *         ProviderInfo. These are ordered from best to worst match. If
2593     *         there are no matching providers, an empty list is returned.
2594     * @see #GET_INTENT_FILTERS
2595     * @see #GET_RESOLVED_FILTER
2596     */
2597    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
2598
2599    /**
2600     * Find a single content provider by its base path name.
2601     *
2602     * @param name The name of the provider to find.
2603     * @param flags Additional option flags.  Currently should always be 0.
2604     *
2605     * @return ContentProviderInfo Information about the provider, if found,
2606     *         else null.
2607     */
2608    public abstract ProviderInfo resolveContentProvider(String name,
2609            int flags);
2610
2611    /**
2612     * Find a single content provider by its base path name.
2613     *
2614     * @param name The name of the provider to find.
2615     * @param flags Additional option flags.  Currently should always be 0.
2616     * @param userId The user id.
2617     *
2618     * @return ContentProviderInfo Information about the provider, if found,
2619     *         else null.
2620     * @hide
2621     */
2622    public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
2623
2624    /**
2625     * Retrieve content provider information.
2626     *
2627     * <p><em>Note: unlike most other methods, an empty result set is indicated
2628     * by a null return instead of an empty list.</em>
2629     *
2630     * @param processName If non-null, limits the returned providers to only
2631     *                    those that are hosted by the given process.  If null,
2632     *                    all content providers are returned.
2633     * @param uid If <var>processName</var> is non-null, this is the required
2634     *        uid owning the requested content providers.
2635     * @param flags Additional option flags.  Currently should always be 0.
2636     *
2637     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
2638     *         content provider either patching <var>processName</var> or, if
2639     *         <var>processName</var> is null, all known content providers.
2640     *         <em>If there are no matching providers, null is returned.</em>
2641     */
2642    public abstract List<ProviderInfo> queryContentProviders(
2643            String processName, int uid, int flags);
2644
2645    /**
2646     * Retrieve all of the information we know about a particular
2647     * instrumentation class.
2648     *
2649     * <p>Throws {@link NameNotFoundException} if instrumentation with the
2650     * given class name cannot be found on the system.
2651     *
2652     * @param className The full name (i.e.
2653     *                  com.google.apps.contacts.InstrumentList) of an
2654     *                  Instrumentation class.
2655     * @param flags Additional option flags.  Currently should always be 0.
2656     *
2657     * @return InstrumentationInfo containing information about the
2658     *         instrumentation.
2659     */
2660    public abstract InstrumentationInfo getInstrumentationInfo(
2661            ComponentName className, int flags) throws NameNotFoundException;
2662
2663    /**
2664     * Retrieve information about available instrumentation code.  May be used
2665     * to retrieve either all instrumentation code, or only the code targeting
2666     * a particular package.
2667     *
2668     * @param targetPackage If null, all instrumentation is returned; only the
2669     *                      instrumentation targeting this package name is
2670     *                      returned.
2671     * @param flags Additional option flags.  Currently should always be 0.
2672     *
2673     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
2674     *         matching available Instrumentation.  Returns an empty list if
2675     *         there is no instrumentation available for the given package.
2676     */
2677    public abstract List<InstrumentationInfo> queryInstrumentation(
2678            String targetPackage, int flags);
2679
2680    /**
2681     * Retrieve an image from a package.  This is a low-level API used by
2682     * the various package manager info structures (such as
2683     * {@link ComponentInfo} to implement retrieval of their associated
2684     * icon.
2685     *
2686     * @param packageName The name of the package that this icon is coming from.
2687     * Cannot be null.
2688     * @param resid The resource identifier of the desired image.  Cannot be 0.
2689     * @param appInfo Overall information about <var>packageName</var>.  This
2690     * may be null, in which case the application information will be retrieved
2691     * for you if needed; if you already have this information around, it can
2692     * be much more efficient to supply it here.
2693     *
2694     * @return Returns a Drawable holding the requested image.  Returns null if
2695     * an image could not be found for any reason.
2696     */
2697    public abstract Drawable getDrawable(String packageName, int resid,
2698            ApplicationInfo appInfo);
2699
2700    /**
2701     * Retrieve the icon associated with an activity.  Given the full name of
2702     * an activity, retrieves the information about it and calls
2703     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
2704     * If the activity cannot be found, NameNotFoundException is thrown.
2705     *
2706     * @param activityName Name of the activity whose icon is to be retrieved.
2707     *
2708     * @return Returns the image of the icon, or the default activity icon if
2709     * it could not be found.  Does not return null.
2710     * @throws NameNotFoundException Thrown if the resources for the given
2711     * activity could not be loaded.
2712     *
2713     * @see #getActivityIcon(Intent)
2714     */
2715    public abstract Drawable getActivityIcon(ComponentName activityName)
2716            throws NameNotFoundException;
2717
2718    /**
2719     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
2720     * set, this simply returns the result of
2721     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
2722     * component and returns the icon associated with the resolved component.
2723     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2724     * to a component, NameNotFoundException is thrown.
2725     *
2726     * @param intent The intent for which you would like to retrieve an icon.
2727     *
2728     * @return Returns the image of the icon, or the default activity icon if
2729     * it could not be found.  Does not return null.
2730     * @throws NameNotFoundException Thrown if the resources for application
2731     * matching the given intent could not be loaded.
2732     *
2733     * @see #getActivityIcon(ComponentName)
2734     */
2735    public abstract Drawable getActivityIcon(Intent intent)
2736            throws NameNotFoundException;
2737
2738    /**
2739     * Retrieve the banner associated with an activity. Given the full name of
2740     * an activity, retrieves the information about it and calls
2741     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
2742     * banner. If the activity cannot be found, NameNotFoundException is thrown.
2743     *
2744     * @param activityName Name of the activity whose banner is to be retrieved.
2745     * @return Returns the image of the banner, or null if the activity has no
2746     *         banner specified.
2747     * @throws NameNotFoundException Thrown if the resources for the given
2748     *             activity could not be loaded.
2749     * @see #getActivityBanner(Intent)
2750     */
2751    public abstract Drawable getActivityBanner(ComponentName activityName)
2752            throws NameNotFoundException;
2753
2754    /**
2755     * Retrieve the banner associated with an Intent. If intent.getClassName()
2756     * is set, this simply returns the result of
2757     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
2758     * intent's component and returns the banner associated with the resolved
2759     * component. If intent.getClassName() cannot be found or the Intent cannot
2760     * be resolved to a component, NameNotFoundException is thrown.
2761     *
2762     * @param intent The intent for which you would like to retrieve a banner.
2763     * @return Returns the image of the banner, or null if the activity has no
2764     *         banner specified.
2765     * @throws NameNotFoundException Thrown if the resources for application
2766     *             matching the given intent could not be loaded.
2767     * @see #getActivityBanner(ComponentName)
2768     */
2769    public abstract Drawable getActivityBanner(Intent intent)
2770            throws NameNotFoundException;
2771
2772    /**
2773     * Return the generic icon for an activity that is used when no specific
2774     * icon is defined.
2775     *
2776     * @return Drawable Image of the icon.
2777     */
2778    public abstract Drawable getDefaultActivityIcon();
2779
2780    /**
2781     * Retrieve the icon associated with an application.  If it has not defined
2782     * an icon, the default app icon is returned.  Does not return null.
2783     *
2784     * @param info Information about application being queried.
2785     *
2786     * @return Returns the image of the icon, or the default application icon
2787     * if it could not be found.
2788     *
2789     * @see #getApplicationIcon(String)
2790     */
2791    public abstract Drawable getApplicationIcon(ApplicationInfo info);
2792
2793    /**
2794     * Retrieve the icon associated with an application.  Given the name of the
2795     * application's package, retrieves the information about it and calls
2796     * getApplicationIcon() to return its icon. If the application cannot be
2797     * found, NameNotFoundException is thrown.
2798     *
2799     * @param packageName Name of the package whose application icon is to be
2800     *                    retrieved.
2801     *
2802     * @return Returns the image of the icon, or the default application icon
2803     * if it could not be found.  Does not return null.
2804     * @throws NameNotFoundException Thrown if the resources for the given
2805     * application could not be loaded.
2806     *
2807     * @see #getApplicationIcon(ApplicationInfo)
2808     */
2809    public abstract Drawable getApplicationIcon(String packageName)
2810            throws NameNotFoundException;
2811
2812    /**
2813     * Retrieve the banner associated with an application.
2814     *
2815     * @param info Information about application being queried.
2816     * @return Returns the image of the banner or null if the application has no
2817     *         banner specified.
2818     * @see #getApplicationBanner(String)
2819     */
2820    public abstract Drawable getApplicationBanner(ApplicationInfo info);
2821
2822    /**
2823     * Retrieve the banner associated with an application. Given the name of the
2824     * application's package, retrieves the information about it and calls
2825     * getApplicationIcon() to return its banner. If the application cannot be
2826     * found, NameNotFoundException is thrown.
2827     *
2828     * @param packageName Name of the package whose application banner is to be
2829     *            retrieved.
2830     * @return Returns the image of the banner or null if the application has no
2831     *         banner specified.
2832     * @throws NameNotFoundException Thrown if the resources for the given
2833     *             application could not be loaded.
2834     * @see #getApplicationBanner(ApplicationInfo)
2835     */
2836    public abstract Drawable getApplicationBanner(String packageName)
2837            throws NameNotFoundException;
2838
2839    /**
2840     * Retrieve the logo associated with an activity. Given the full name of an
2841     * activity, retrieves the information about it and calls
2842     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
2843     * logo. If the activity cannot be found, NameNotFoundException is thrown.
2844     *
2845     * @param activityName Name of the activity whose logo is to be retrieved.
2846     * @return Returns the image of the logo or null if the activity has no logo
2847     *         specified.
2848     * @throws NameNotFoundException Thrown if the resources for the given
2849     *             activity could not be loaded.
2850     * @see #getActivityLogo(Intent)
2851     */
2852    public abstract Drawable getActivityLogo(ComponentName activityName)
2853            throws NameNotFoundException;
2854
2855    /**
2856     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
2857     * set, this simply returns the result of
2858     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
2859     * component and returns the logo associated with the resolved component.
2860     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2861     * to a component, NameNotFoundException is thrown.
2862     *
2863     * @param intent The intent for which you would like to retrieve a logo.
2864     *
2865     * @return Returns the image of the logo, or null if the activity has no
2866     * logo specified.
2867     *
2868     * @throws NameNotFoundException Thrown if the resources for application
2869     * matching the given intent could not be loaded.
2870     *
2871     * @see #getActivityLogo(ComponentName)
2872     */
2873    public abstract Drawable getActivityLogo(Intent intent)
2874            throws NameNotFoundException;
2875
2876    /**
2877     * Retrieve the logo associated with an application.  If it has not specified
2878     * a logo, this method returns null.
2879     *
2880     * @param info Information about application being queried.
2881     *
2882     * @return Returns the image of the logo, or null if no logo is specified
2883     * by the application.
2884     *
2885     * @see #getApplicationLogo(String)
2886     */
2887    public abstract Drawable getApplicationLogo(ApplicationInfo info);
2888
2889    /**
2890     * Retrieve the logo associated with an application.  Given the name of the
2891     * application's package, retrieves the information about it and calls
2892     * getApplicationLogo() to return its logo. If the application cannot be
2893     * found, NameNotFoundException is thrown.
2894     *
2895     * @param packageName Name of the package whose application logo is to be
2896     *                    retrieved.
2897     *
2898     * @return Returns the image of the logo, or null if no application logo
2899     * has been specified.
2900     *
2901     * @throws NameNotFoundException Thrown if the resources for the given
2902     * application could not be loaded.
2903     *
2904     * @see #getApplicationLogo(ApplicationInfo)
2905     */
2906    public abstract Drawable getApplicationLogo(String packageName)
2907            throws NameNotFoundException;
2908
2909    /**
2910     * If the target user is a managed profile of the calling user or the caller
2911     * is itself a managed profile, then this returns a badged copy of the given
2912     * icon to be able to distinguish it from the original icon. For badging an
2913     * arbitrary drawable use {@link #getUserBadgedDrawableForDensity(
2914     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
2915     * <p>
2916     * If the original drawable is a BitmapDrawable and the backing bitmap is
2917     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
2918     * is performed in place and the original drawable is returned.
2919     * </p>
2920     *
2921     * @param icon The icon to badge.
2922     * @param user The target user.
2923     * @return A drawable that combines the original icon and a badge as
2924     *         determined by the system.
2925     */
2926    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
2927
2928    /**
2929     * If the target user is a managed profile of the calling user or the caller
2930     * is itself a managed profile, then this returns a badged copy of the given
2931     * drawable allowing the user to distinguish it from the original drawable.
2932     * The caller can specify the location in the bounds of the drawable to be
2933     * badged where the badge should be applied as well as the density of the
2934     * badge to be used.
2935     * <p>
2936     * If the original drawable is a BitmapDrawable and the backing bitmap is
2937     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
2938     * is performed in place and the original drawable is returned.
2939     * </p>
2940     *
2941     * @param drawable The drawable to badge.
2942     * @param user The target user.
2943     * @param badgeLocation Where in the bounds of the badged drawable to place
2944     *         the badge. If not provided, the badge is applied on top of the entire
2945     *         drawable being badged.
2946     * @param badgeDensity The optional desired density for the badge as per
2947     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
2948     *         the density of the display is used.
2949     * @return A drawable that combines the original drawable and a badge as
2950     *         determined by the system.
2951     */
2952    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
2953            UserHandle user, Rect badgeLocation, int badgeDensity);
2954
2955    /**
2956     * If the target user is a managed profile of the calling user or the caller
2957     * is itself a managed profile, then this returns a drawable to use as a small
2958     * icon to include in a view to distinguish it from the original icon.
2959     *
2960     * @param user The target user.
2961     * @param density The optional desired density for the badge as per
2962     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
2963     *         the density of the current display is used.
2964     * @return the drawable or null if no drawable is required.
2965     * @hide
2966     */
2967    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
2968
2969    /**
2970     * If the target user is a managed profile of the calling user or the caller
2971     * is itself a managed profile, then this returns a copy of the label with
2972     * badging for accessibility services like talkback. E.g. passing in "Email"
2973     * and it might return "Work Email" for Email in the work profile.
2974     *
2975     * @param label The label to change.
2976     * @param user The target user.
2977     * @return A label that combines the original label and a badge as
2978     *         determined by the system.
2979     */
2980    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
2981
2982    /**
2983     * Retrieve text from a package.  This is a low-level API used by
2984     * the various package manager info structures (such as
2985     * {@link ComponentInfo} to implement retrieval of their associated
2986     * labels and other text.
2987     *
2988     * @param packageName The name of the package that this text is coming from.
2989     * Cannot be null.
2990     * @param resid The resource identifier of the desired text.  Cannot be 0.
2991     * @param appInfo Overall information about <var>packageName</var>.  This
2992     * may be null, in which case the application information will be retrieved
2993     * for you if needed; if you already have this information around, it can
2994     * be much more efficient to supply it here.
2995     *
2996     * @return Returns a CharSequence holding the requested text.  Returns null
2997     * if the text could not be found for any reason.
2998     */
2999    public abstract CharSequence getText(String packageName, int resid,
3000            ApplicationInfo appInfo);
3001
3002    /**
3003     * Retrieve an XML file from a package.  This is a low-level API used to
3004     * retrieve XML meta data.
3005     *
3006     * @param packageName The name of the package that this xml is coming from.
3007     * Cannot be null.
3008     * @param resid The resource identifier of the desired xml.  Cannot be 0.
3009     * @param appInfo Overall information about <var>packageName</var>.  This
3010     * may be null, in which case the application information will be retrieved
3011     * for you if needed; if you already have this information around, it can
3012     * be much more efficient to supply it here.
3013     *
3014     * @return Returns an XmlPullParser allowing you to parse out the XML
3015     * data.  Returns null if the xml resource could not be found for any
3016     * reason.
3017     */
3018    public abstract XmlResourceParser getXml(String packageName, int resid,
3019            ApplicationInfo appInfo);
3020
3021    /**
3022     * Return the label to use for this application.
3023     *
3024     * @return Returns the label associated with this application, or null if
3025     * it could not be found for any reason.
3026     * @param info The application to get the label of.
3027     */
3028    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
3029
3030    /**
3031     * Retrieve the resources associated with an activity.  Given the full
3032     * name of an activity, retrieves the information about it and calls
3033     * getResources() to return its application's resources.  If the activity
3034     * cannot be found, NameNotFoundException is thrown.
3035     *
3036     * @param activityName Name of the activity whose resources are to be
3037     *                     retrieved.
3038     *
3039     * @return Returns the application's Resources.
3040     * @throws NameNotFoundException Thrown if the resources for the given
3041     * application could not be loaded.
3042     *
3043     * @see #getResourcesForApplication(ApplicationInfo)
3044     */
3045    public abstract Resources getResourcesForActivity(ComponentName activityName)
3046            throws NameNotFoundException;
3047
3048    /**
3049     * Retrieve the resources for an application.  Throws NameNotFoundException
3050     * if the package is no longer installed.
3051     *
3052     * @param app Information about the desired application.
3053     *
3054     * @return Returns the application's Resources.
3055     * @throws NameNotFoundException Thrown if the resources for the given
3056     * application could not be loaded (most likely because it was uninstalled).
3057     */
3058    public abstract Resources getResourcesForApplication(ApplicationInfo app)
3059            throws NameNotFoundException;
3060
3061    /**
3062     * Retrieve the resources associated with an application.  Given the full
3063     * package name of an application, retrieves the information about it and
3064     * calls getResources() to return its application's resources.  If the
3065     * appPackageName cannot be found, NameNotFoundException is thrown.
3066     *
3067     * @param appPackageName Package name of the application whose resources
3068     *                       are to be retrieved.
3069     *
3070     * @return Returns the application's Resources.
3071     * @throws NameNotFoundException Thrown if the resources for the given
3072     * application could not be loaded.
3073     *
3074     * @see #getResourcesForApplication(ApplicationInfo)
3075     */
3076    public abstract Resources getResourcesForApplication(String appPackageName)
3077            throws NameNotFoundException;
3078
3079    /** @hide */
3080    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
3081            throws NameNotFoundException;
3082
3083    /**
3084     * Retrieve overall information about an application package defined
3085     * in a package archive file
3086     *
3087     * @param archiveFilePath The path to the archive file
3088     * @param flags Additional option flags. Use any combination of
3089     * {@link #GET_ACTIVITIES},
3090     * {@link #GET_GIDS},
3091     * {@link #GET_CONFIGURATIONS},
3092     * {@link #GET_INSTRUMENTATION},
3093     * {@link #GET_PERMISSIONS},
3094     * {@link #GET_PROVIDERS},
3095     * {@link #GET_RECEIVERS},
3096     * {@link #GET_SERVICES},
3097     * {@link #GET_SIGNATURES}, to modify the data returned.
3098     *
3099     * @return Returns the information about the package. Returns
3100     * null if the package could not be successfully parsed.
3101     *
3102     * @see #GET_ACTIVITIES
3103     * @see #GET_GIDS
3104     * @see #GET_CONFIGURATIONS
3105     * @see #GET_INSTRUMENTATION
3106     * @see #GET_PERMISSIONS
3107     * @see #GET_PROVIDERS
3108     * @see #GET_RECEIVERS
3109     * @see #GET_SERVICES
3110     * @see #GET_SIGNATURES
3111     *
3112     */
3113    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3114        final PackageParser parser = new PackageParser();
3115        final File apkFile = new File(archiveFilePath);
3116        try {
3117            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3118            if ((flags & GET_SIGNATURES) != 0) {
3119                parser.collectCertificates(pkg, 0);
3120                parser.collectManifestDigest(pkg);
3121            }
3122            PackageUserState state = new PackageUserState();
3123            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3124        } catch (PackageParserException e) {
3125            return null;
3126        }
3127    }
3128
3129    /**
3130     * @hide Install a package. Since this may take a little while, the result
3131     *       will be posted back to the given observer. An installation will
3132     *       fail if the calling context lacks the
3133     *       {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3134     *       the package named in the package file's manifest is already
3135     *       installed, or if there's no space available on the device.
3136     * @param packageURI The location of the package file to install. This can
3137     *            be a 'file:' or a 'content:' URI.
3138     * @param observer An observer callback to get notified when the package
3139     *            installation is complete.
3140     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3141     *            will be called when that happens. This parameter must not be
3142     *            null.
3143     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3144     *            {@link #INSTALL_REPLACE_EXISTING},
3145     *            {@link #INSTALL_ALLOW_TEST}.
3146     * @param installerPackageName Optional package name of the application that
3147     *            is performing the installation. This identifies which market
3148     *            the package came from.
3149     * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3150     *             String)} instead. This method will continue to be supported
3151     *             but the older observer interface will not get additional
3152     *             failure details.
3153     */
3154    // @SystemApi
3155    public abstract void installPackage(
3156            Uri packageURI, IPackageInstallObserver observer, int flags,
3157            String installerPackageName);
3158
3159    /**
3160     * Similar to
3161     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3162     * with an extra verification file provided.
3163     *
3164     * @param packageURI The location of the package file to install. This can
3165     *            be a 'file:' or a 'content:' URI.
3166     * @param observer An observer callback to get notified when the package
3167     *            installation is complete.
3168     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3169     *            will be called when that happens. This parameter must not be
3170     *            null.
3171     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3172     *            {@link #INSTALL_REPLACE_EXISTING},
3173     *            {@link #INSTALL_ALLOW_TEST}.
3174     * @param installerPackageName Optional package name of the application that
3175     *            is performing the installation. This identifies which market
3176     *            the package came from.
3177     * @param verificationURI The location of the supplementary verification
3178     *            file. This can be a 'file:' or a 'content:' URI. May be
3179     *            {@code null}.
3180     * @param manifestDigest an object that holds the digest of the package
3181     *            which can be used to verify ownership. May be {@code null}.
3182     * @param encryptionParams if the package to be installed is encrypted,
3183     *            these parameters describing the encryption and authentication
3184     *            used. May be {@code null}.
3185     * @hide
3186     * @deprecated Use {@link #installPackageWithVerification(Uri,
3187     *             PackageInstallObserver, int, String, Uri, ManifestDigest,
3188     *             ContainerEncryptionParams)} instead. This method will
3189     *             continue to be supported but the older observer interface
3190     *             will not get additional failure details.
3191     */
3192    // @SystemApi
3193    public abstract void installPackageWithVerification(Uri packageURI,
3194            IPackageInstallObserver observer, int flags, String installerPackageName,
3195            Uri verificationURI, ManifestDigest manifestDigest,
3196            ContainerEncryptionParams encryptionParams);
3197
3198    /**
3199     * Similar to
3200     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3201     * with an extra verification information provided.
3202     *
3203     * @param packageURI The location of the package file to install. This can
3204     *            be a 'file:' or a 'content:' URI.
3205     * @param observer An observer callback to get notified when the package
3206     *            installation is complete.
3207     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3208     *            will be called when that happens. This parameter must not be
3209     *            null.
3210     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3211     *            {@link #INSTALL_REPLACE_EXISTING},
3212     *            {@link #INSTALL_ALLOW_TEST}.
3213     * @param installerPackageName Optional package name of the application that
3214     *            is performing the installation. This identifies which market
3215     *            the package came from.
3216     * @param verificationParams an object that holds signal information to
3217     *            assist verification. May be {@code null}.
3218     * @param encryptionParams if the package to be installed is encrypted,
3219     *            these parameters describing the encryption and authentication
3220     *            used. May be {@code null}.
3221     * @hide
3222     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3223     *             PackageInstallObserver, int, String, VerificationParams,
3224     *             ContainerEncryptionParams)} instead. This method will
3225     *             continue to be supported but the older observer interface
3226     *             will not get additional failure details.
3227     */
3228    @Deprecated
3229    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3230            IPackageInstallObserver observer, int flags, String installerPackageName,
3231            VerificationParams verificationParams,
3232            ContainerEncryptionParams encryptionParams);
3233
3234    // Package-install variants that take the new, expanded form of observer interface.
3235    // Note that these *also* take the original observer type and will redundantly
3236    // report the same information to that observer if supplied; but it is not required.
3237
3238    /**
3239     * @hide
3240     *
3241     * Install a package. Since this may take a little while, the result will
3242     * be posted back to the given observer.  An installation will fail if the calling context
3243     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3244     * package named in the package file's manifest is already installed, or if there's no space
3245     * available on the device.
3246     *
3247     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3248     * 'content:' URI.
3249     * @param observer An observer callback to get notified when the package installation is
3250     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3251     * called when that happens. This parameter must not be null.
3252     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3253     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3254     * @param installerPackageName Optional package name of the application that is performing the
3255     * installation. This identifies which market the package came from.
3256     */
3257    public abstract void installPackage(
3258            Uri packageURI, PackageInstallObserver observer,
3259            int flags, String installerPackageName);
3260
3261    /**
3262     * Similar to
3263     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3264     * with an extra verification file provided.
3265     *
3266     * @param packageURI The location of the package file to install. This can
3267     *            be a 'file:' or a 'content:' URI.
3268     * @param observer An observer callback to get notified when the package installation is
3269     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3270     * called when that happens. This parameter must not be null.
3271     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3272     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3273     * @param installerPackageName Optional package name of the application that
3274     *            is performing the installation. This identifies which market
3275     *            the package came from.
3276     * @param verificationURI The location of the supplementary verification
3277     *            file. This can be a 'file:' or a 'content:' URI. May be
3278     *            {@code null}.
3279     * @param manifestDigest an object that holds the digest of the package
3280     *            which can be used to verify ownership. May be {@code null}.
3281     * @param encryptionParams if the package to be installed is encrypted,
3282     *            these parameters describing the encryption and authentication
3283     *            used. May be {@code null}.
3284     * @hide
3285     */
3286    public abstract void installPackageWithVerification(Uri packageURI,
3287            PackageInstallObserver observer, int flags, String installerPackageName,
3288            Uri verificationURI, ManifestDigest manifestDigest,
3289            ContainerEncryptionParams encryptionParams);
3290
3291    /**
3292     * Similar to
3293     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3294     * with an extra verification information provided.
3295     *
3296     * @param packageURI The location of the package file to install. This can
3297     *            be a 'file:' or a 'content:' URI.
3298     * @param observer An observer callback to get notified when the package installation is
3299     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3300     * called when that happens. This parameter must not be null.
3301     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3302     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3303     * @param installerPackageName Optional package name of the application that
3304     *            is performing the installation. This identifies which market
3305     *            the package came from.
3306     * @param verificationParams an object that holds signal information to
3307     *            assist verification. May be {@code null}.
3308     * @param encryptionParams if the package to be installed is encrypted,
3309     *            these parameters describing the encryption and authentication
3310     *            used. May be {@code null}.
3311     *
3312     * @hide
3313     */
3314    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3315            PackageInstallObserver observer, int flags, String installerPackageName,
3316            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3317
3318    /**
3319     * If there is already an application with the given package name installed
3320     * on the system for other users, also install it for the calling user.
3321     * @hide
3322     */
3323    // @SystemApi
3324    public abstract int installExistingPackage(String packageName)
3325            throws NameNotFoundException;
3326
3327    /**
3328     * Allows a package listening to the
3329     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3330     * broadcast} to respond to the package manager. The response must include
3331     * the {@code verificationCode} which is one of
3332     * {@link PackageManager#VERIFICATION_ALLOW} or
3333     * {@link PackageManager#VERIFICATION_REJECT}.
3334     *
3335     * @param id pending package identifier as passed via the
3336     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3337     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3338     *            or {@link PackageManager#VERIFICATION_REJECT}.
3339     * @throws SecurityException if the caller does not have the
3340     *            PACKAGE_VERIFICATION_AGENT permission.
3341     */
3342    public abstract void verifyPendingInstall(int id, int verificationCode);
3343
3344    /**
3345     * Allows a package listening to the
3346     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3347     * broadcast} to extend the default timeout for a response and declare what
3348     * action to perform after the timeout occurs. The response must include
3349     * the {@code verificationCodeAtTimeout} which is one of
3350     * {@link PackageManager#VERIFICATION_ALLOW} or
3351     * {@link PackageManager#VERIFICATION_REJECT}.
3352     *
3353     * This method may only be called once per package id. Additional calls
3354     * will have no effect.
3355     *
3356     * @param id pending package identifier as passed via the
3357     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3358     * @param verificationCodeAtTimeout either
3359     *            {@link PackageManager#VERIFICATION_ALLOW} or
3360     *            {@link PackageManager#VERIFICATION_REJECT}. If
3361     *            {@code verificationCodeAtTimeout} is neither
3362     *            {@link PackageManager#VERIFICATION_ALLOW} or
3363     *            {@link PackageManager#VERIFICATION_REJECT}, then
3364     *            {@code verificationCodeAtTimeout} will default to
3365     *            {@link PackageManager#VERIFICATION_REJECT}.
3366     * @param millisecondsToDelay the amount of time requested for the timeout.
3367     *            Must be positive and less than
3368     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3369     *            {@code millisecondsToDelay} is out of bounds,
3370     *            {@code millisecondsToDelay} will be set to the closest in
3371     *            bounds value; namely, 0 or
3372     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3373     * @throws SecurityException if the caller does not have the
3374     *            PACKAGE_VERIFICATION_AGENT permission.
3375     */
3376    public abstract void extendVerificationTimeout(int id,
3377            int verificationCodeAtTimeout, long millisecondsToDelay);
3378
3379    /**
3380     * Change the installer associated with a given package.  There are limitations
3381     * on how the installer package can be changed; in particular:
3382     * <ul>
3383     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3384     * is not signed with the same certificate as the calling application.
3385     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3386     * has an installer package, and that installer package is not signed with
3387     * the same certificate as the calling application.
3388     * </ul>
3389     *
3390     * @param targetPackage The installed package whose installer will be changed.
3391     * @param installerPackageName The package name of the new installer.  May be
3392     * null to clear the association.
3393     */
3394    public abstract void setInstallerPackageName(String targetPackage,
3395            String installerPackageName);
3396
3397    /**
3398     * Attempts to delete a package.  Since this may take a little while, the result will
3399     * be posted back to the given observer.  A deletion will fail if the calling context
3400     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3401     * named package cannot be found, or if the named package is a "system package".
3402     * (TODO: include pointer to documentation on "system packages")
3403     *
3404     * @param packageName The name of the package to delete
3405     * @param observer An observer callback to get notified when the package deletion is
3406     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3407     * called when that happens.  observer may be null to indicate that no callback is desired.
3408     * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3409     * {@link #DELETE_ALL_USERS}.
3410     *
3411     * @hide
3412     */
3413    // @SystemApi
3414    public abstract void deletePackage(
3415            String packageName, IPackageDeleteObserver observer, int flags);
3416
3417    /**
3418     * Retrieve the package name of the application that installed a package. This identifies
3419     * which market the package came from.
3420     *
3421     * @param packageName The name of the package to query
3422     */
3423    public abstract String getInstallerPackageName(String packageName);
3424
3425    /**
3426     * Attempts to clear the user data directory of an application.
3427     * Since this may take a little while, the result will
3428     * be posted back to the given observer.  A deletion will fail if the
3429     * named package cannot be found, or if the named package is a "system package".
3430     *
3431     * @param packageName The name of the package
3432     * @param observer An observer callback to get notified when the operation is finished
3433     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3434     * will be called when that happens.  observer may be null to indicate that
3435     * no callback is desired.
3436     *
3437     * @hide
3438     */
3439    public abstract void clearApplicationUserData(String packageName,
3440            IPackageDataObserver observer);
3441    /**
3442     * Attempts to delete the cache files associated with an application.
3443     * Since this may take a little while, the result will
3444     * be posted back to the given observer.  A deletion will fail if the calling context
3445     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3446     * named package cannot be found, or if the named package is a "system package".
3447     *
3448     * @param packageName The name of the package to delete
3449     * @param observer An observer callback to get notified when the cache file deletion
3450     * is complete.
3451     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3452     * will be called when that happens.  observer may be null to indicate that
3453     * no callback is desired.
3454     *
3455     * @hide
3456     */
3457    public abstract void deleteApplicationCacheFiles(String packageName,
3458            IPackageDataObserver observer);
3459
3460    /**
3461     * Free storage by deleting LRU sorted list of cache files across
3462     * all applications. If the currently available free storage
3463     * on the device is greater than or equal to the requested
3464     * free storage, no cache files are cleared. If the currently
3465     * available storage on the device is less than the requested
3466     * free storage, some or all of the cache files across
3467     * all applications are deleted (based on last accessed time)
3468     * to increase the free storage space on the device to
3469     * the requested value. There is no guarantee that clearing all
3470     * the cache files from all applications will clear up
3471     * enough storage to achieve the desired value.
3472     * @param freeStorageSize The number of bytes of storage to be
3473     * freed by the system. Say if freeStorageSize is XX,
3474     * and the current free storage is YY,
3475     * if XX is less than YY, just return. if not free XX-YY number
3476     * of bytes if possible.
3477     * @param observer call back used to notify when
3478     * the operation is completed
3479     *
3480     * @hide
3481     */
3482    // @SystemApi
3483    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
3484
3485    /**
3486     * Free storage by deleting LRU sorted list of cache files across
3487     * all applications. If the currently available free storage
3488     * on the device is greater than or equal to the requested
3489     * free storage, no cache files are cleared. If the currently
3490     * available storage on the device is less than the requested
3491     * free storage, some or all of the cache files across
3492     * all applications are deleted (based on last accessed time)
3493     * to increase the free storage space on the device to
3494     * the requested value. There is no guarantee that clearing all
3495     * the cache files from all applications will clear up
3496     * enough storage to achieve the desired value.
3497     * @param freeStorageSize The number of bytes of storage to be
3498     * freed by the system. Say if freeStorageSize is XX,
3499     * and the current free storage is YY,
3500     * if XX is less than YY, just return. if not free XX-YY number
3501     * of bytes if possible.
3502     * @param pi IntentSender call back used to
3503     * notify when the operation is completed.May be null
3504     * to indicate that no call back is desired.
3505     *
3506     * @hide
3507     */
3508    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
3509
3510    /**
3511     * Retrieve the size information for a package.
3512     * Since this may take a little while, the result will
3513     * be posted back to the given observer.  The calling context
3514     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
3515     *
3516     * @param packageName The name of the package whose size information is to be retrieved
3517     * @param userHandle The user whose size information should be retrieved.
3518     * @param observer An observer callback to get notified when the operation
3519     * is complete.
3520     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
3521     * The observer's callback is invoked with a PackageStats object(containing the
3522     * code, data and cache sizes of the package) and a boolean value representing
3523     * the status of the operation. observer may be null to indicate that
3524     * no callback is desired.
3525     *
3526     * @hide
3527     */
3528    public abstract void getPackageSizeInfo(String packageName, int userHandle,
3529            IPackageStatsObserver observer);
3530
3531    /**
3532     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
3533     * returns the size for the calling user.
3534     *
3535     * @hide
3536     */
3537    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
3538        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
3539    }
3540
3541    /**
3542     * @deprecated This function no longer does anything; it was an old
3543     * approach to managing preferred activities, which has been superseded
3544     * by (and conflicts with) the modern activity-based preferences.
3545     */
3546    @Deprecated
3547    public abstract void addPackageToPreferred(String packageName);
3548
3549    /**
3550     * @deprecated This function no longer does anything; it was an old
3551     * approach to managing preferred activities, which has been superseded
3552     * by (and conflicts with) the modern activity-based preferences.
3553     */
3554    @Deprecated
3555    public abstract void removePackageFromPreferred(String packageName);
3556
3557    /**
3558     * Retrieve the list of all currently configured preferred packages.  The
3559     * first package on the list is the most preferred, the last is the
3560     * least preferred.
3561     *
3562     * @param flags Additional option flags. Use any combination of
3563     * {@link #GET_ACTIVITIES},
3564     * {@link #GET_GIDS},
3565     * {@link #GET_CONFIGURATIONS},
3566     * {@link #GET_INSTRUMENTATION},
3567     * {@link #GET_PERMISSIONS},
3568     * {@link #GET_PROVIDERS},
3569     * {@link #GET_RECEIVERS},
3570     * {@link #GET_SERVICES},
3571     * {@link #GET_SIGNATURES}, to modify the data returned.
3572     *
3573     * @return Returns a list of PackageInfo objects describing each
3574     * preferred application, in order of preference.
3575     *
3576     * @see #GET_ACTIVITIES
3577     * @see #GET_GIDS
3578     * @see #GET_CONFIGURATIONS
3579     * @see #GET_INSTRUMENTATION
3580     * @see #GET_PERMISSIONS
3581     * @see #GET_PROVIDERS
3582     * @see #GET_RECEIVERS
3583     * @see #GET_SERVICES
3584     * @see #GET_SIGNATURES
3585     */
3586    public abstract List<PackageInfo> getPreferredPackages(int flags);
3587
3588    /**
3589     * @deprecated This is a protected API that should not have been available
3590     * to third party applications.  It is the platform's responsibility for
3591     * assigning preferred activities and this cannot be directly modified.
3592     *
3593     * Add a new preferred activity mapping to the system.  This will be used
3594     * to automatically select the given activity component when
3595     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3596     * multiple matching activities and also matches the given filter.
3597     *
3598     * @param filter The set of intents under which this activity will be
3599     * made preferred.
3600     * @param match The IntentFilter match category that this preference
3601     * applies to.
3602     * @param set The set of activities that the user was picking from when
3603     * this preference was made.
3604     * @param activity The component name of the activity that is to be
3605     * preferred.
3606     */
3607    @Deprecated
3608    public abstract void addPreferredActivity(IntentFilter filter, int match,
3609            ComponentName[] set, ComponentName activity);
3610
3611    /**
3612     * Same as {@link #addPreferredActivity(IntentFilter, int,
3613            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
3614            to.
3615     * @hide
3616     */
3617    public void addPreferredActivity(IntentFilter filter, int match,
3618            ComponentName[] set, ComponentName activity, int userId) {
3619        throw new RuntimeException("Not implemented. Must override in a subclass.");
3620    }
3621
3622    /**
3623     * @deprecated This is a protected API that should not have been available
3624     * to third party applications.  It is the platform's responsibility for
3625     * assigning preferred activities and this cannot be directly modified.
3626     *
3627     * Replaces an existing preferred activity mapping to the system, and if that were not present
3628     * adds a new preferred activity.  This will be used
3629     * to automatically select the given activity component when
3630     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3631     * multiple matching activities and also matches the given filter.
3632     *
3633     * @param filter The set of intents under which this activity will be
3634     * made preferred.
3635     * @param match The IntentFilter match category that this preference
3636     * applies to.
3637     * @param set The set of activities that the user was picking from when
3638     * this preference was made.
3639     * @param activity The component name of the activity that is to be
3640     * preferred.
3641     * @hide
3642     */
3643    @Deprecated
3644    public abstract void replacePreferredActivity(IntentFilter filter, int match,
3645            ComponentName[] set, ComponentName activity);
3646
3647    /**
3648     * @hide
3649     */
3650    @Deprecated
3651    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
3652           ComponentName[] set, ComponentName activity, int userId) {
3653        throw new RuntimeException("Not implemented. Must override in a subclass.");
3654    }
3655
3656    /**
3657     * Remove all preferred activity mappings, previously added with
3658     * {@link #addPreferredActivity}, from the
3659     * system whose activities are implemented in the given package name.
3660     * An application can only clear its own package(s).
3661     *
3662     * @param packageName The name of the package whose preferred activity
3663     * mappings are to be removed.
3664     */
3665    public abstract void clearPackagePreferredActivities(String packageName);
3666
3667    /**
3668     * Retrieve all preferred activities, previously added with
3669     * {@link #addPreferredActivity}, that are
3670     * currently registered with the system.
3671     *
3672     * @param outFilters A list in which to place the filters of all of the
3673     * preferred activities, or null for none.
3674     * @param outActivities A list in which to place the component names of
3675     * all of the preferred activities, or null for none.
3676     * @param packageName An option package in which you would like to limit
3677     * the list.  If null, all activities will be returned; if non-null, only
3678     * those activities in the given package are returned.
3679     *
3680     * @return Returns the total number of registered preferred activities
3681     * (the number of distinct IntentFilter records, not the number of unique
3682     * activity components) that were found.
3683     */
3684    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
3685            List<ComponentName> outActivities, String packageName);
3686
3687    /**
3688     * Ask for the set of available 'home' activities and the current explicit
3689     * default, if any.
3690     * @hide
3691     */
3692    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
3693
3694    /**
3695     * Set the enabled setting for a package component (activity, receiver, service, provider).
3696     * This setting will override any enabled state which may have been set by the component in its
3697     * manifest.
3698     *
3699     * @param componentName The component to enable
3700     * @param newState The new enabled state for the component.  The legal values for this state
3701     *                 are:
3702     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3703     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3704     *                   and
3705     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3706     *                 The last one removes the setting, thereby restoring the component's state to
3707     *                 whatever was set in it's manifest (or enabled, by default).
3708     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3709     */
3710    public abstract void setComponentEnabledSetting(ComponentName componentName,
3711            int newState, int flags);
3712
3713
3714    /**
3715     * Return the enabled setting for a package component (activity,
3716     * receiver, service, provider).  This returns the last value set by
3717     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
3718     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3719     * the value originally specified in the manifest has not been modified.
3720     *
3721     * @param componentName The component to retrieve.
3722     * @return Returns the current enabled state for the component.  May
3723     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3724     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3725     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3726     * component's enabled state is based on the original information in
3727     * the manifest as found in {@link ComponentInfo}.
3728     */
3729    public abstract int getComponentEnabledSetting(ComponentName componentName);
3730
3731    /**
3732     * Set the enabled setting for an application
3733     * This setting will override any enabled state which may have been set by the application in
3734     * its manifest.  It also overrides the enabled state set in the manifest for any of the
3735     * application's components.  It does not override any enabled state set by
3736     * {@link #setComponentEnabledSetting} for any of the application's components.
3737     *
3738     * @param packageName The package name of the application to enable
3739     * @param newState The new enabled state for the component.  The legal values for this state
3740     *                 are:
3741     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3742     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3743     *                   and
3744     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3745     *                 The last one removes the setting, thereby restoring the applications's state to
3746     *                 whatever was set in its manifest (or enabled, by default).
3747     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3748     */
3749    public abstract void setApplicationEnabledSetting(String packageName,
3750            int newState, int flags);
3751
3752    /**
3753     * Return the enabled setting for an application. This returns
3754     * the last value set by
3755     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
3756     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3757     * the value originally specified in the manifest has not been modified.
3758     *
3759     * @param packageName The package name of the application to retrieve.
3760     * @return Returns the current enabled state for the application.  May
3761     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3762     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3763     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3764     * application's enabled state is based on the original information in
3765     * the manifest as found in {@link ComponentInfo}.
3766     * @throws IllegalArgumentException if the named package does not exist.
3767     */
3768    public abstract int getApplicationEnabledSetting(String packageName);
3769
3770    /**
3771     * Puts the package in a hidden state, which is almost like an uninstalled state,
3772     * making the package unavailable, but it doesn't remove the data or the actual
3773     * package file. Application can be unhidden by either resetting the hidden state
3774     * or by installing it, such as with {@link #installExistingPackage(String)}
3775     * @hide
3776     */
3777    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
3778            UserHandle userHandle);
3779
3780    /**
3781     * Returns the hidden state of a package.
3782     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
3783     * @hide
3784     */
3785    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
3786            UserHandle userHandle);
3787
3788    /**
3789     * Return whether the device has been booted into safe mode.
3790     */
3791    public abstract boolean isSafeMode();
3792
3793    /**
3794     * Return the {@link KeySet} associated with the String alias for this
3795     * application.
3796     *
3797     * @param alias The alias for a given {@link KeySet} as defined in the
3798     *        application's AndroidManifest.xml.
3799     * @hide
3800     */
3801    public abstract KeySet getKeySetByAlias(String packageName, String alias);
3802
3803    /** Return the signing {@link KeySet} for this application.
3804     * @hide
3805     */
3806    public abstract KeySet getSigningKeySet(String packageName);
3807
3808    /**
3809     * Return whether the package denoted by packageName has been signed by all
3810     * of the keys specified by the {@link KeySet} ks.  This will return true if
3811     * the package has been signed by additional keys (a superset) as well.
3812     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
3813     * @hide
3814     */
3815    public abstract boolean isSignedBy(String packageName, KeySet ks);
3816
3817    /**
3818     * Return whether the package denoted by packageName has been signed by all
3819     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
3820     * {@link #isSignedBy(String packageName, KeySet ks)}.
3821     * @hide
3822     */
3823    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
3824
3825    /**
3826     * Attempts to move package resources from internal to external media or vice versa.
3827     * Since this may take a little while, the result will
3828     * be posted back to the given observer.   This call may fail if the calling context
3829     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
3830     * named package cannot be found, or if the named package is a "system package".
3831     *
3832     * @param packageName The name of the package to delete
3833     * @param observer An observer callback to get notified when the package move is
3834     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
3835     * called when that happens.  observer may be null to indicate that no callback is desired.
3836     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
3837     * {@link #MOVE_EXTERNAL_MEDIA}
3838     *
3839     * @hide
3840     */
3841    public abstract void movePackage(
3842            String packageName, IPackageMoveObserver observer, int flags);
3843
3844    /**
3845     * Returns the device identity that verifiers can use to associate their scheme to a particular
3846     * device. This should not be used by anything other than a package verifier.
3847     *
3848     * @return identity that uniquely identifies current device
3849     * @hide
3850     */
3851    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
3852
3853    /**
3854     * Return interface that offers the ability to install, upgrade, and remove
3855     * applications on the device.
3856     */
3857    public abstract @NonNull PackageInstaller getPackageInstaller();
3858
3859    /**
3860     * Returns the data directory for a particular user and package, given the uid of the package.
3861     * @param uid uid of the package, including the userId and appId
3862     * @param packageName name of the package
3863     * @return the user-specific data directory for the package
3864     * @hide
3865     */
3866    public static String getDataDirForUser(int userId, String packageName) {
3867        // TODO: This should be shared with Installer's knowledge of user directory
3868        return Environment.getDataDirectory().toString() + "/user/" + userId
3869                + "/" + packageName;
3870    }
3871
3872    /**
3873     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
3874     * user with id sourceUserId can also be be resolved by activities in the user with id
3875     * targetUserId if they match the specified intent filter.
3876     * @param filter The {@link IntentFilter} the intent has to match
3877     * @param sourceUserId The source user id.
3878     * @param targetUserId The target user id.
3879     * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
3880     * @hide
3881     */
3882    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
3883            int targetUserId, int flags);
3884
3885    /**
3886     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
3887     * source, and have been set by the app calling this method.
3888     * @param sourceUserId The source user id.
3889     * @hide
3890     */
3891    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
3892
3893    /**
3894     * Forwards all intents for {@link packageName} for user {@link sourceUserId} to user
3895     * {@link targetUserId}.
3896     * @hide
3897     */
3898    public abstract void addCrossProfileIntentsForPackage(String packageName,
3899            int sourceUserId, int targetUserId);
3900
3901    /**
3902     * Removes all intents for {@link packageName} for user {@link sourceUserId} to user
3903     * {@link targetUserId}.
3904     * @hide
3905     */
3906    public abstract void removeCrossProfileIntentsForPackage(String packageName,
3907            int sourceUserId, int targetUserId);
3908
3909    /**
3910     * @hide
3911     */
3912    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
3913
3914    /** {@hide} */
3915    public abstract boolean isPackageAvailable(String packageName);
3916
3917    /** {@hide} */
3918    public static String installStatusToString(int status, String msg) {
3919        final String str = installStatusToString(status);
3920        if (msg != null) {
3921            return str + ": " + msg;
3922        } else {
3923            return str;
3924        }
3925    }
3926
3927    /** {@hide} */
3928    public static String installStatusToString(int status) {
3929        switch (status) {
3930            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
3931            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
3932            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
3933            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
3934            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
3935            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
3936            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
3937            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
3938            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
3939            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
3940            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
3941            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
3942            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
3943            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
3944            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
3945            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
3946            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
3947            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
3948            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
3949            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
3950            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
3951            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
3952            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
3953            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
3954            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
3955            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
3956            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
3957            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
3958            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
3959            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
3960            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
3961            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
3962            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
3963            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
3964            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
3965            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
3966            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
3967            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
3968            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
3969            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
3970            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
3971            default: return Integer.toString(status);
3972        }
3973    }
3974
3975    /** {@hide} */
3976    public static int installStatusToPublicStatus(int status) {
3977        switch (status) {
3978            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
3979            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3980            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
3981            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
3982            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
3983            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3984            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3985            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3986            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3987            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3988            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3989            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
3990            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3991            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3992            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3993            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
3994            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3995            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3996            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
3997            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
3998            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
3999            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
4000            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
4001            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4002            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4003            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4004            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4005            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
4006            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
4007            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4008            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4009            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
4010            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
4011            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
4012            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
4013            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
4014            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4015            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4016            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4017            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4018            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4019            default: return PackageInstaller.STATUS_FAILURE;
4020        }
4021    }
4022
4023    /** {@hide} */
4024    public static String deleteStatusToString(int status, String msg) {
4025        final String str = deleteStatusToString(status);
4026        if (msg != null) {
4027            return str + ": " + msg;
4028        } else {
4029            return str;
4030        }
4031    }
4032
4033    /** {@hide} */
4034    public static String deleteStatusToString(int status) {
4035        switch (status) {
4036            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
4037            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
4038            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
4039            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
4040            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
4041            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
4042            default: return Integer.toString(status);
4043        }
4044    }
4045
4046    /** {@hide} */
4047    public static int deleteStatusToPublicStatus(int status) {
4048        switch (status) {
4049            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4050            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4051            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4052            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4053            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4054            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4055            default: return PackageInstaller.STATUS_FAILURE;
4056        }
4057    }
4058
4059    /** {@hide} */
4060    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
4061        private final IPackageInstallObserver mLegacy;
4062
4063        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
4064            mLegacy = legacy;
4065        }
4066
4067        @Override
4068        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
4069                Bundle extras) {
4070            if (mLegacy == null) return;
4071            try {
4072                mLegacy.packageInstalled(basePackageName, returnCode);
4073            } catch (RemoteException ignored) {
4074            }
4075        }
4076    }
4077
4078    /** {@hide} */
4079    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
4080        private final IPackageDeleteObserver mLegacy;
4081
4082        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
4083            mLegacy = legacy;
4084        }
4085
4086        @Override
4087        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
4088            if (mLegacy == null) return;
4089            try {
4090                mLegacy.packageDeleted(basePackageName, returnCode);
4091            } catch (RemoteException ignored) {
4092            }
4093        }
4094    }
4095}
4096