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