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