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