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