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