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