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