PackageManager.java revision 811dc3b42b4d3c967a2304bf1e01840147b1a528
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    /**
2023     * Permission flag: The permission is granted by default because it
2024     * enables app functionality that is expected to work out-of-the-box
2025     * for providing a smooth user experience. For example, the phone app
2026     * is expected to have the phone permission.
2027     *
2028     * @hide
2029     */
2030    public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
2031
2032    /**
2033     * Mask for all permission flags.
2034     *
2035     * @hide
2036     */
2037    @SystemApi
2038    public static final int MASK_PERMISSION_FLAGS = 0xFF;
2039
2040    /**
2041     * Retrieve overall information about an application package that is
2042     * installed on the system.
2043     * <p>
2044     * Throws {@link NameNotFoundException} if a package with the given name can
2045     * not be found on the system.
2046     *
2047     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2048     *            desired package.
2049     * @param flags Additional option flags. Use any combination of
2050     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2051     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2052     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2053     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2054     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
2055     *            modify the data returned.
2056     * @return A PackageInfo object containing information about the
2057     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
2058     *         package is not found in the list of installed applications, the
2059     *         package information is retrieved from the list of uninstalled
2060     *         applications (which includes installed applications as well as
2061     *         applications with data directory i.e. applications which had been
2062     *         deleted with {@code DONT_DELETE_DATA} flag set).
2063     * @see #GET_ACTIVITIES
2064     * @see #GET_GIDS
2065     * @see #GET_CONFIGURATIONS
2066     * @see #GET_INSTRUMENTATION
2067     * @see #GET_PERMISSIONS
2068     * @see #GET_PROVIDERS
2069     * @see #GET_RECEIVERS
2070     * @see #GET_SERVICES
2071     * @see #GET_SIGNATURES
2072     * @see #GET_UNINSTALLED_PACKAGES
2073     */
2074    public abstract PackageInfo getPackageInfo(String packageName, int flags)
2075            throws NameNotFoundException;
2076
2077    /**
2078     * @hide
2079     * Retrieve overall information about an application package that is
2080     * installed on the system.
2081     * <p>
2082     * Throws {@link NameNotFoundException} if a package with the given name can
2083     * not be found on the system.
2084     *
2085     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2086     *            desired package.
2087     * @param flags Additional option flags. Use any combination of
2088     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2089     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2090     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2091     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2092     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
2093     *            modify the data returned.
2094     * @param userId The user id.
2095     * @return A PackageInfo object containing information about the
2096     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
2097     *         package is not found in the list of installed applications, the
2098     *         package information is retrieved from the list of uninstalled
2099     *         applications (which includes installed applications as well as
2100     *         applications with data directory i.e. applications which had been
2101     *         deleted with {@code DONT_DELETE_DATA} flag set).
2102     * @see #GET_ACTIVITIES
2103     * @see #GET_GIDS
2104     * @see #GET_CONFIGURATIONS
2105     * @see #GET_INSTRUMENTATION
2106     * @see #GET_PERMISSIONS
2107     * @see #GET_PROVIDERS
2108     * @see #GET_RECEIVERS
2109     * @see #GET_SERVICES
2110     * @see #GET_SIGNATURES
2111     * @see #GET_UNINSTALLED_PACKAGES
2112     */
2113    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2114    public abstract PackageInfo getPackageInfoAsUser(String packageName, int flags, int userId)
2115            throws NameNotFoundException;
2116
2117    /**
2118     * Map from the current package names in use on the device to whatever
2119     * the current canonical name of that package is.
2120     * @param names Array of current names to be mapped.
2121     * @return Returns an array of the same size as the original, containing
2122     * the canonical name for each package.
2123     */
2124    public abstract String[] currentToCanonicalPackageNames(String[] names);
2125
2126    /**
2127     * Map from a packages canonical name to the current name in use on the device.
2128     * @param names Array of new names to be mapped.
2129     * @return Returns an array of the same size as the original, containing
2130     * the current name for each package.
2131     */
2132    public abstract String[] canonicalToCurrentPackageNames(String[] names);
2133
2134    /**
2135     * Returns a "good" intent to launch a front-door activity in a package.
2136     * This is used, for example, to implement an "open" button when browsing
2137     * through packages.  The current implementation looks first for a main
2138     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
2139     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
2140     * <code>null</code> if neither are found.
2141     *
2142     * @param packageName The name of the package to inspect.
2143     *
2144     * @return A fully-qualified {@link Intent} that can be used to launch the
2145     * main activity in the package. Returns <code>null</code> if the package
2146     * does not contain such an activity, or if <em>packageName</em> is not
2147     * recognized.
2148     */
2149    public abstract Intent getLaunchIntentForPackage(String packageName);
2150
2151    /**
2152     * Return a "good" intent to launch a front-door Leanback activity in a
2153     * package, for use for example to implement an "open" button when browsing
2154     * through packages. The current implementation will look for a main
2155     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
2156     * return null if no main leanback activities are found.
2157     * <p>
2158     * Throws {@link NameNotFoundException} if a package with the given name
2159     * cannot be found on the system.
2160     *
2161     * @param packageName The name of the package to inspect.
2162     * @return Returns either a fully-qualified Intent that can be used to launch
2163     *         the main Leanback activity in the package, or null if the package
2164     *         does not contain such an activity.
2165     */
2166    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
2167
2168    /**
2169     * Return an array of all of the secondary group-ids that have been assigned
2170     * to a package.
2171     * <p>
2172     * Throws {@link NameNotFoundException} if a package with the given name
2173     * cannot be found on the system.
2174     *
2175     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2176     *            desired package.
2177     * @return Returns an int array of the assigned gids, or null if there are
2178     *         none.
2179     */
2180    public abstract int[] getPackageGids(String packageName)
2181            throws NameNotFoundException;
2182
2183    /**
2184     * @hide Return the uid associated with the given package name for the
2185     * given user.
2186     *
2187     * <p>Throws {@link NameNotFoundException} if a package with the given
2188     * name can not be found on the system.
2189     *
2190     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2191     *                    desired package.
2192     * @param userHandle The user handle identifier to look up the package under.
2193     *
2194     * @return Returns an integer uid who owns the given package name.
2195     */
2196    public abstract int getPackageUid(String packageName, int userHandle)
2197            throws NameNotFoundException;
2198
2199    /**
2200     * Retrieve all of the information we know about a particular permission.
2201     *
2202     * <p>Throws {@link NameNotFoundException} if a permission with the given
2203     * name cannot be found on the system.
2204     *
2205     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
2206     *             of the permission you are interested in.
2207     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2208     * retrieve any meta-data associated with the permission.
2209     *
2210     * @return Returns a {@link PermissionInfo} containing information about the
2211     *         permission.
2212     */
2213    public abstract PermissionInfo getPermissionInfo(String name, int flags)
2214            throws NameNotFoundException;
2215
2216    /**
2217     * Query for all of the permissions associated with a particular group.
2218     *
2219     * <p>Throws {@link NameNotFoundException} if the given group does not
2220     * exist.
2221     *
2222     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
2223     *             of the permission group you are interested in.  Use null to
2224     *             find all of the permissions not associated with a group.
2225     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2226     * retrieve any meta-data associated with the permissions.
2227     *
2228     * @return Returns a list of {@link PermissionInfo} containing information
2229     * about all of the permissions in the given group.
2230     */
2231    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
2232            int flags) throws NameNotFoundException;
2233
2234    /**
2235     * Retrieve all of the information we know about a particular group of
2236     * permissions.
2237     *
2238     * <p>Throws {@link NameNotFoundException} if a permission group with the given
2239     * name cannot be found on the system.
2240     *
2241     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
2242     *             of the permission you are interested in.
2243     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2244     * retrieve any meta-data associated with the permission group.
2245     *
2246     * @return Returns a {@link PermissionGroupInfo} containing information
2247     * about the permission.
2248     */
2249    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
2250            int flags) throws NameNotFoundException;
2251
2252    /**
2253     * Retrieve all of the known permission groups in the system.
2254     *
2255     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2256     * retrieve any meta-data associated with the permission group.
2257     *
2258     * @return Returns a list of {@link PermissionGroupInfo} containing
2259     * information about all of the known permission groups.
2260     */
2261    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
2262
2263    /**
2264     * Retrieve all of the information we know about a particular
2265     * package/application.
2266     *
2267     * <p>Throws {@link NameNotFoundException} if an application with the given
2268     * package name cannot be found on the system.
2269     *
2270     * @param packageName The full name (i.e. com.google.apps.contacts) of an
2271     *                    application.
2272     * @param flags Additional option flags. Use any combination of
2273     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2274     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2275     *
2276     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
2277     *         information about the package.
2278     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
2279     *         found in the list of installed applications,
2280     *         the application information is retrieved from the
2281     *         list of uninstalled applications(which includes
2282     *         installed applications as well as applications
2283     *         with data directory ie applications which had been
2284     *         deleted with {@code DONT_DELETE_DATA} flag set).
2285     *
2286     * @see #GET_META_DATA
2287     * @see #GET_SHARED_LIBRARY_FILES
2288     * @see #GET_UNINSTALLED_PACKAGES
2289     */
2290    public abstract ApplicationInfo getApplicationInfo(String packageName,
2291            int flags) throws NameNotFoundException;
2292
2293    /**
2294     * Retrieve all of the information we know about a particular activity
2295     * class.
2296     *
2297     * <p>Throws {@link NameNotFoundException} if an activity with the given
2298     * class name cannot be found on the system.
2299     *
2300     * @param component The full component name (i.e.
2301     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
2302     * class.
2303     * @param flags Additional option flags. Use any combination of
2304     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2305     * to modify the data (in ApplicationInfo) returned.
2306     *
2307     * @return {@link ActivityInfo} containing information about the activity.
2308     *
2309     * @see #GET_INTENT_FILTERS
2310     * @see #GET_META_DATA
2311     * @see #GET_SHARED_LIBRARY_FILES
2312     */
2313    public abstract ActivityInfo getActivityInfo(ComponentName component,
2314            int flags) throws NameNotFoundException;
2315
2316    /**
2317     * Retrieve all of the information we know about a particular receiver
2318     * class.
2319     *
2320     * <p>Throws {@link NameNotFoundException} if a receiver with the given
2321     * class name cannot be found on the system.
2322     *
2323     * @param component The full component name (i.e.
2324     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
2325     * class.
2326     * @param flags Additional option flags.  Use any combination of
2327     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2328     * to modify the data returned.
2329     *
2330     * @return {@link ActivityInfo} containing information about the receiver.
2331     *
2332     * @see #GET_INTENT_FILTERS
2333     * @see #GET_META_DATA
2334     * @see #GET_SHARED_LIBRARY_FILES
2335     */
2336    public abstract ActivityInfo getReceiverInfo(ComponentName component,
2337            int flags) throws NameNotFoundException;
2338
2339    /**
2340     * Retrieve all of the information we know about a particular service
2341     * class.
2342     *
2343     * <p>Throws {@link NameNotFoundException} if a service with the given
2344     * class name cannot be found on the system.
2345     *
2346     * @param component The full component name (i.e.
2347     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
2348     * class.
2349     * @param flags Additional option flags.  Use any combination of
2350     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2351     * to modify the data returned.
2352     *
2353     * @return ServiceInfo containing information about the service.
2354     *
2355     * @see #GET_META_DATA
2356     * @see #GET_SHARED_LIBRARY_FILES
2357     */
2358    public abstract ServiceInfo getServiceInfo(ComponentName component,
2359            int flags) throws NameNotFoundException;
2360
2361    /**
2362     * Retrieve all of the information we know about a particular content
2363     * provider class.
2364     *
2365     * <p>Throws {@link NameNotFoundException} if a provider with the given
2366     * class name cannot be found on the system.
2367     *
2368     * @param component The full component name (i.e.
2369     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
2370     * ContentProvider class.
2371     * @param flags Additional option flags.  Use any combination of
2372     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2373     * to modify the data returned.
2374     *
2375     * @return ProviderInfo containing information about the service.
2376     *
2377     * @see #GET_META_DATA
2378     * @see #GET_SHARED_LIBRARY_FILES
2379     */
2380    public abstract ProviderInfo getProviderInfo(ComponentName component,
2381            int flags) throws NameNotFoundException;
2382
2383    /**
2384     * Return a List of all packages that are installed
2385     * on the device.
2386     *
2387     * @param flags Additional option flags. Use any combination of
2388     * {@link #GET_ACTIVITIES},
2389     * {@link #GET_GIDS},
2390     * {@link #GET_CONFIGURATIONS},
2391     * {@link #GET_INSTRUMENTATION},
2392     * {@link #GET_PERMISSIONS},
2393     * {@link #GET_PROVIDERS},
2394     * {@link #GET_RECEIVERS},
2395     * {@link #GET_SERVICES},
2396     * {@link #GET_SIGNATURES},
2397     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2398     *
2399     * @return A List of PackageInfo objects, one for each package that is
2400     *         installed on the device.  In the unlikely case of there being no
2401     *         installed packages, an empty list is returned.
2402     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2403     *         applications including those deleted with {@code DONT_DELETE_DATA}
2404     *         (partially installed apps with data directory) will be returned.
2405     *
2406     * @see #GET_ACTIVITIES
2407     * @see #GET_GIDS
2408     * @see #GET_CONFIGURATIONS
2409     * @see #GET_INSTRUMENTATION
2410     * @see #GET_PERMISSIONS
2411     * @see #GET_PROVIDERS
2412     * @see #GET_RECEIVERS
2413     * @see #GET_SERVICES
2414     * @see #GET_SIGNATURES
2415     * @see #GET_UNINSTALLED_PACKAGES
2416     */
2417    public abstract List<PackageInfo> getInstalledPackages(int flags);
2418
2419    /**
2420     * Return a List of all installed packages that are currently
2421     * holding any of the given permissions.
2422     *
2423     * @param flags Additional option flags. Use any combination of
2424     * {@link #GET_ACTIVITIES},
2425     * {@link #GET_GIDS},
2426     * {@link #GET_CONFIGURATIONS},
2427     * {@link #GET_INSTRUMENTATION},
2428     * {@link #GET_PERMISSIONS},
2429     * {@link #GET_PROVIDERS},
2430     * {@link #GET_RECEIVERS},
2431     * {@link #GET_SERVICES},
2432     * {@link #GET_SIGNATURES},
2433     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2434     *
2435     * @return Returns a List of PackageInfo objects, one for each installed
2436     * application that is holding any of the permissions that were provided.
2437     *
2438     * @see #GET_ACTIVITIES
2439     * @see #GET_GIDS
2440     * @see #GET_CONFIGURATIONS
2441     * @see #GET_INSTRUMENTATION
2442     * @see #GET_PERMISSIONS
2443     * @see #GET_PROVIDERS
2444     * @see #GET_RECEIVERS
2445     * @see #GET_SERVICES
2446     * @see #GET_SIGNATURES
2447     * @see #GET_UNINSTALLED_PACKAGES
2448     */
2449    public abstract List<PackageInfo> getPackagesHoldingPermissions(
2450            String[] permissions, int flags);
2451
2452    /**
2453     * Return a List of all packages that are installed on the device, for a specific user.
2454     * Requesting a list of installed packages for another user
2455     * will require the permission INTERACT_ACROSS_USERS_FULL.
2456     * @param flags Additional option flags. Use any combination of
2457     * {@link #GET_ACTIVITIES},
2458     * {@link #GET_GIDS},
2459     * {@link #GET_CONFIGURATIONS},
2460     * {@link #GET_INSTRUMENTATION},
2461     * {@link #GET_PERMISSIONS},
2462     * {@link #GET_PROVIDERS},
2463     * {@link #GET_RECEIVERS},
2464     * {@link #GET_SERVICES},
2465     * {@link #GET_SIGNATURES},
2466     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2467     * @param userId The user for whom the installed packages are to be listed
2468     *
2469     * @return A List of PackageInfo objects, one for each package that is
2470     *         installed on the device.  In the unlikely case of there being no
2471     *         installed packages, an empty list is returned.
2472     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2473     *         applications including those deleted with {@code DONT_DELETE_DATA}
2474     *         (partially installed apps with data directory) will be returned.
2475     *
2476     * @see #GET_ACTIVITIES
2477     * @see #GET_GIDS
2478     * @see #GET_CONFIGURATIONS
2479     * @see #GET_INSTRUMENTATION
2480     * @see #GET_PERMISSIONS
2481     * @see #GET_PROVIDERS
2482     * @see #GET_RECEIVERS
2483     * @see #GET_SERVICES
2484     * @see #GET_SIGNATURES
2485     * @see #GET_UNINSTALLED_PACKAGES
2486     *
2487     * @hide
2488     */
2489    public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2490
2491    /**
2492     * Check whether a particular package has been granted a particular
2493     * permission.
2494     *
2495     * @param permName The name of the permission you are checking for.
2496     * @param pkgName The name of the package you are checking against.
2497     *
2498     * @return If the package has the permission, PERMISSION_GRANTED is
2499     * returned.  If it does not have the permission, PERMISSION_DENIED
2500     * is returned.
2501     *
2502     * @see #PERMISSION_GRANTED
2503     * @see #PERMISSION_DENIED
2504     */
2505    @CheckResult
2506    public abstract int checkPermission(String permName, String pkgName);
2507
2508    /**
2509     * Checks whether a particular permissions has been revoked for a
2510     * package by policy. Typically the device owner or the profile owner
2511     * may apply such a policy. The user cannot grant policy revoked
2512     * permissions, hence the only way for an app to get such a permission
2513     * is by a policy change.
2514     *
2515     * @param permName The name of the permission you are checking for.
2516     * @param pkgName The name of the package you are checking against.
2517     *
2518     * @return Whether the permission is restricted by policy.
2519     */
2520    @CheckResult
2521    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
2522            @NonNull String pkgName);
2523
2524    /**
2525     * Gets the package name of the component controlling runtime permissions.
2526     *
2527     * @return The package name.
2528     *
2529     * @hide
2530     */
2531    public abstract String getPermissionControllerPackageName();
2532
2533    /**
2534     * Add a new dynamic permission to the system.  For this to work, your
2535     * package must have defined a permission tree through the
2536     * {@link android.R.styleable#AndroidManifestPermissionTree
2537     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
2538     * permissions to trees that were defined by either its own package or
2539     * another with the same user id; a permission is in a tree if it
2540     * matches the name of the permission tree + ".": for example,
2541     * "com.foo.bar" is a member of the permission tree "com.foo".
2542     *
2543     * <p>It is good to make your permission tree name descriptive, because you
2544     * are taking possession of that entire set of permission names.  Thus, it
2545     * must be under a domain you control, with a suffix that will not match
2546     * any normal permissions that may be declared in any applications that
2547     * are part of that domain.
2548     *
2549     * <p>New permissions must be added before
2550     * any .apks are installed that use those permissions.  Permissions you
2551     * add through this method are remembered across reboots of the device.
2552     * If the given permission already exists, the info you supply here
2553     * will be used to update it.
2554     *
2555     * @param info Description of the permission to be added.
2556     *
2557     * @return Returns true if a new permission was created, false if an
2558     * existing one was updated.
2559     *
2560     * @throws SecurityException if you are not allowed to add the
2561     * given permission name.
2562     *
2563     * @see #removePermission(String)
2564     */
2565    public abstract boolean addPermission(PermissionInfo info);
2566
2567    /**
2568     * Like {@link #addPermission(PermissionInfo)} but asynchronously
2569     * persists the package manager state after returning from the call,
2570     * allowing it to return quicker and batch a series of adds at the
2571     * expense of no guarantee the added permission will be retained if
2572     * the device is rebooted before it is written.
2573     */
2574    public abstract boolean addPermissionAsync(PermissionInfo info);
2575
2576    /**
2577     * Removes a permission that was previously added with
2578     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
2579     * -- you are only allowed to remove permissions that you are allowed
2580     * to add.
2581     *
2582     * @param name The name of the permission to remove.
2583     *
2584     * @throws SecurityException if you are not allowed to remove the
2585     * given permission name.
2586     *
2587     * @see #addPermission(PermissionInfo)
2588     */
2589    public abstract void removePermission(String name);
2590
2591
2592    /**
2593     * Permission flags set when granting or revoking a permission.
2594     *
2595     * @hide
2596     */
2597    @SystemApi
2598    @IntDef({FLAG_PERMISSION_USER_SET,
2599            FLAG_PERMISSION_USER_FIXED,
2600            FLAG_PERMISSION_POLICY_FIXED,
2601            FLAG_PERMISSION_REVOKE_ON_UPGRADE,
2602            FLAG_PERMISSION_SYSTEM_FIXED,
2603            FLAG_PERMISSION_GRANTED_BY_DEFAULT})
2604    @Retention(RetentionPolicy.SOURCE)
2605    public @interface PermissionFlags {}
2606
2607    /**
2608     * Grant a runtime permission to an application which the application does not
2609     * already have. The permission must have been requested by the application.
2610     * If the application is not allowed to hold the permission, a {@link
2611     * java.lang.SecurityException} is thrown.
2612     * <p>
2613     * <strong>Note: </strong>Using this API requires holding
2614     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
2615     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
2616     * </p>
2617     *
2618     * @param packageName The package to which to grant the permission.
2619     * @param permissionName The permission name to grant.
2620     * @param user The user for which to grant the permission.
2621     *
2622     * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
2623     * @see android.content.pm.PackageManager.PermissionFlags
2624     *
2625     * @hide
2626     */
2627    @SystemApi
2628    public abstract void grantRuntimePermission(@NonNull String packageName,
2629            @NonNull String permissionName, @NonNull UserHandle user);
2630
2631    /**
2632     * Revoke a runtime permission that was previously granted by {@link
2633     * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
2634     * permission must have been requested by and granted to the application.
2635     * If the application is not allowed to hold the permission, a {@link
2636     * java.lang.SecurityException} is thrown.
2637     * <p>
2638     * <strong>Note: </strong>Using this API requires holding
2639     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
2640     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
2641     * </p>
2642     *
2643     * @param packageName The package from which to revoke the permission.
2644     * @param permissionName The permission name to revoke.
2645     * @param user The user for which to revoke the permission.
2646     *
2647     * @see #grantRuntimePermission(String, String, android.os.UserHandle)
2648     * @see android.content.pm.PackageManager.PermissionFlags
2649     *
2650     * @hide
2651     */
2652    @SystemApi
2653    public abstract void revokeRuntimePermission(@NonNull String packageName,
2654            @NonNull String permissionName, @NonNull UserHandle user);
2655
2656    /**
2657     * Gets the state flags associated with a permission.
2658     *
2659     * @param permissionName The permission for which to get the flags.
2660     * @param packageName The package name for which to get the flags.
2661     * @param user The user for which to get permission flags.
2662     * @return The permission flags.
2663     *
2664     * @hide
2665     */
2666    @SystemApi
2667    public abstract @PermissionFlags int getPermissionFlags(String permissionName,
2668            String packageName, @NonNull UserHandle user);
2669
2670    /**
2671     * Updates the flags associated with a permission by replacing the flags in
2672     * the specified mask with the provided flag values.
2673     *
2674     * @param permissionName The permission for which to update the flags.
2675     * @param packageName The package name for which to update the flags.
2676     * @param flagMask The flags which to replace.
2677     * @param flagValues The flags with which to replace.
2678     * @param user The user for which to update the permission flags.
2679     *
2680     * @hide
2681     */
2682    @SystemApi
2683    public abstract void updatePermissionFlags(String permissionName,
2684            String packageName, @PermissionFlags int flagMask, int flagValues,
2685            @NonNull UserHandle user);
2686
2687    /**
2688     * Gets whether you should show UI with rationale for requesting a permission.
2689     * You should do this only if you do not have the permission and the context in
2690     * which the permission is requested does not clearly communicate to the user
2691     * what would be the benefit from grating this permission.
2692     *
2693     * @param permission A permission your app wants to request.
2694     * @return Whether you can show permission rationale UI.
2695     *
2696     * @hide
2697     */
2698    public abstract boolean shouldShowRequestPermissionRationale(String permission);
2699
2700    /**
2701     * Returns an {@link android.content.Intent} suitable for passing to
2702     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
2703     * which prompts the user to grant permissions to this application.
2704     *
2705     * @throws NullPointerException if {@code permissions} is {@code null} or empty.
2706     *
2707     * @hide
2708     */
2709    public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
2710        if (ArrayUtils.isEmpty(permissions)) {
2711           throw new NullPointerException("permission cannot be null or empty");
2712        }
2713        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
2714        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
2715        intent.setPackage(getPermissionControllerPackageName());
2716        return intent;
2717    }
2718
2719    /**
2720     * Compare the signatures of two packages to determine if the same
2721     * signature appears in both of them.  If they do contain the same
2722     * signature, then they are allowed special privileges when working
2723     * with each other: they can share the same user-id, run instrumentation
2724     * against each other, etc.
2725     *
2726     * @param pkg1 First package name whose signature will be compared.
2727     * @param pkg2 Second package name whose signature will be compared.
2728     *
2729     * @return Returns an integer indicating whether all signatures on the
2730     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2731     * all signatures match or < 0 if there is not a match ({@link
2732     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2733     *
2734     * @see #checkSignatures(int, int)
2735     * @see #SIGNATURE_MATCH
2736     * @see #SIGNATURE_NO_MATCH
2737     * @see #SIGNATURE_UNKNOWN_PACKAGE
2738     */
2739    @CheckResult
2740    public abstract int checkSignatures(String pkg1, String pkg2);
2741
2742    /**
2743     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2744     * the two packages to be checked.  This can be useful, for example,
2745     * when doing the check in an IPC, where the UID is the only identity
2746     * available.  It is functionally identical to determining the package
2747     * associated with the UIDs and checking their signatures.
2748     *
2749     * @param uid1 First UID whose signature will be compared.
2750     * @param uid2 Second UID whose signature will be compared.
2751     *
2752     * @return Returns an integer indicating whether all signatures on the
2753     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2754     * all signatures match or < 0 if there is not a match ({@link
2755     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2756     *
2757     * @see #checkSignatures(String, String)
2758     * @see #SIGNATURE_MATCH
2759     * @see #SIGNATURE_NO_MATCH
2760     * @see #SIGNATURE_UNKNOWN_PACKAGE
2761     */
2762    @CheckResult
2763    public abstract int checkSignatures(int uid1, int uid2);
2764
2765    /**
2766     * Retrieve the names of all packages that are associated with a particular
2767     * user id.  In most cases, this will be a single package name, the package
2768     * that has been assigned that user id.  Where there are multiple packages
2769     * sharing the same user id through the "sharedUserId" mechanism, all
2770     * packages with that id will be returned.
2771     *
2772     * @param uid The user id for which you would like to retrieve the
2773     * associated packages.
2774     *
2775     * @return Returns an array of one or more packages assigned to the user
2776     * id, or null if there are no known packages with the given id.
2777     */
2778    public abstract String[] getPackagesForUid(int uid);
2779
2780    /**
2781     * Retrieve the official name associated with a user id.  This name is
2782     * guaranteed to never change, though it is possible for the underlying
2783     * user id to be changed.  That is, if you are storing information about
2784     * user ids in persistent storage, you should use the string returned
2785     * by this function instead of the raw user-id.
2786     *
2787     * @param uid The user id for which you would like to retrieve a name.
2788     * @return Returns a unique name for the given user id, or null if the
2789     * user id is not currently assigned.
2790     */
2791    public abstract String getNameForUid(int uid);
2792
2793    /**
2794     * Return the user id associated with a shared user name. Multiple
2795     * applications can specify a shared user name in their manifest and thus
2796     * end up using a common uid. This might be used for new applications
2797     * that use an existing shared user name and need to know the uid of the
2798     * shared user.
2799     *
2800     * @param sharedUserName The shared user name whose uid is to be retrieved.
2801     * @return Returns the uid associated with the shared user, or  NameNotFoundException
2802     * if the shared user name is not being used by any installed packages
2803     * @hide
2804     */
2805    public abstract int getUidForSharedUser(String sharedUserName)
2806            throws NameNotFoundException;
2807
2808    /**
2809     * Return a List of all application packages that are installed on the
2810     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2811     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2812     * installed apps with data directory) will be returned.
2813     *
2814     * @param flags Additional option flags. Use any combination of
2815     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2816     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2817     *
2818     * @return Returns a List of ApplicationInfo objects, one for each application that
2819     *         is installed on the device.  In the unlikely case of there being
2820     *         no installed applications, an empty list is returned.
2821     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2822     *         applications including those deleted with {@code DONT_DELETE_DATA}
2823     *         (partially installed apps with data directory) will be returned.
2824     *
2825     * @see #GET_META_DATA
2826     * @see #GET_SHARED_LIBRARY_FILES
2827     * @see #GET_UNINSTALLED_PACKAGES
2828     */
2829    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2830
2831    /**
2832     * Get a list of shared libraries that are available on the
2833     * system.
2834     *
2835     * @return An array of shared library names that are
2836     * available on the system, or null if none are installed.
2837     *
2838     */
2839    public abstract String[] getSystemSharedLibraryNames();
2840
2841    /**
2842     * Get a list of features that are available on the
2843     * system.
2844     *
2845     * @return An array of FeatureInfo classes describing the features
2846     * that are available on the system, or null if there are none(!!).
2847     */
2848    public abstract FeatureInfo[] getSystemAvailableFeatures();
2849
2850    /**
2851     * Check whether the given feature name is one of the available
2852     * features as returned by {@link #getSystemAvailableFeatures()}.
2853     *
2854     * @return Returns true if the devices supports the feature, else
2855     * false.
2856     */
2857    public abstract boolean hasSystemFeature(String name);
2858
2859    /**
2860     * Determine the best action to perform for a given Intent.  This is how
2861     * {@link Intent#resolveActivity} finds an activity if a class has not
2862     * been explicitly specified.
2863     *
2864     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2865     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2866     * only flag.  You need to do so to resolve the activity in the same way
2867     * that {@link android.content.Context#startActivity(Intent)} and
2868     * {@link android.content.Intent#resolveActivity(PackageManager)
2869     * Intent.resolveActivity(PackageManager)} do.</p>
2870     *
2871     * @param intent An intent containing all of the desired specification
2872     *               (action, data, type, category, and/or component).
2873     * @param flags Additional option flags.  The most important is
2874     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2875     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2876     *
2877     * @return Returns a ResolveInfo containing the final activity intent that
2878     *         was determined to be the best action.  Returns null if no
2879     *         matching activity was found. If multiple matching activities are
2880     *         found and there is no default set, returns a ResolveInfo
2881     *         containing something else, such as the activity resolver.
2882     *
2883     * @see #MATCH_DEFAULT_ONLY
2884     * @see #GET_INTENT_FILTERS
2885     * @see #GET_RESOLVED_FILTER
2886     */
2887    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2888
2889    /**
2890     * Determine the best action to perform for a given Intent for a given user. This
2891     * is how {@link Intent#resolveActivity} finds an activity if a class has not
2892     * been explicitly specified.
2893     *
2894     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2895     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2896     * only flag.  You need to do so to resolve the activity in the same way
2897     * that {@link android.content.Context#startActivity(Intent)} and
2898     * {@link android.content.Intent#resolveActivity(PackageManager)
2899     * Intent.resolveActivity(PackageManager)} do.</p>
2900     *
2901     * @param intent An intent containing all of the desired specification
2902     *               (action, data, type, category, and/or component).
2903     * @param flags Additional option flags.  The most important is
2904     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2905     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2906     * @param userId The user id.
2907     *
2908     * @return Returns a ResolveInfo containing the final activity intent that
2909     *         was determined to be the best action.  Returns null if no
2910     *         matching activity was found. If multiple matching activities are
2911     *         found and there is no default set, returns a ResolveInfo
2912     *         containing something else, such as the activity resolver.
2913     *
2914     * @see #MATCH_DEFAULT_ONLY
2915     * @see #GET_INTENT_FILTERS
2916     * @see #GET_RESOLVED_FILTER
2917     *
2918     * @hide
2919     */
2920    public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2921
2922    /**
2923     * Retrieve all activities that can be performed for the given intent.
2924     *
2925     * @param intent The desired intent as per resolveActivity().
2926     * @param flags Additional option flags.  The most important is
2927     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2928     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2929     *
2930     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
2931     *
2932     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2933     *         Activity. These are ordered from best to worst match -- that
2934     *         is, the first item in the list is what is returned by
2935     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2936     *         list is returned.
2937     *
2938     * @see #MATCH_DEFAULT_ONLY
2939     * @see #GET_INTENT_FILTERS
2940     * @see #GET_RESOLVED_FILTER
2941     */
2942    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2943            int flags);
2944
2945    /**
2946     * Retrieve all activities that can be performed for the given intent, for a specific user.
2947     *
2948     * @param intent The desired intent as per resolveActivity().
2949     * @param flags Additional option flags.  The most important is
2950     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2951     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2952     *
2953     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
2954     *
2955     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2956     *         Activity. These are ordered from best to worst match -- that
2957     *         is, the first item in the list is what is returned by
2958     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2959     *         list is returned.
2960     *
2961     * @see #MATCH_DEFAULT_ONLY
2962     * @see #GET_INTENT_FILTERS
2963     * @see #GET_RESOLVED_FILTER
2964     * @hide
2965     */
2966    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2967            int flags, int userId);
2968
2969
2970    /**
2971     * Retrieve a set of activities that should be presented to the user as
2972     * similar options.  This is like {@link #queryIntentActivities}, except it
2973     * also allows you to supply a list of more explicit Intents that you would
2974     * like to resolve to particular options, and takes care of returning the
2975     * final ResolveInfo list in a reasonable order, with no duplicates, based
2976     * on those inputs.
2977     *
2978     * @param caller The class name of the activity that is making the
2979     *               request.  This activity will never appear in the output
2980     *               list.  Can be null.
2981     * @param specifics An array of Intents that should be resolved to the
2982     *                  first specific results.  Can be null.
2983     * @param intent The desired intent as per resolveActivity().
2984     * @param flags Additional option flags.  The most important is
2985     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2986     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2987     *
2988     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2989     *         Activity. These are ordered first by all of the intents resolved
2990     *         in <var>specifics</var> and then any additional activities that
2991     *         can handle <var>intent</var> but did not get included by one of
2992     *         the <var>specifics</var> intents.  If there are no matching
2993     *         activities, an empty list is returned.
2994     *
2995     * @see #MATCH_DEFAULT_ONLY
2996     * @see #GET_INTENT_FILTERS
2997     * @see #GET_RESOLVED_FILTER
2998     */
2999    public abstract List<ResolveInfo> queryIntentActivityOptions(
3000            ComponentName caller, Intent[] specifics, Intent intent, int flags);
3001
3002    /**
3003     * Retrieve all receivers that can handle a broadcast of the given intent.
3004     *
3005     * @param intent The desired intent as per resolveActivity().
3006     * @param flags Additional option flags.
3007     *
3008     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3009     *         Receiver. These are ordered from first to last in priority.  If
3010     *         there are no matching receivers, an empty list is returned.
3011     *
3012     * @see #MATCH_DEFAULT_ONLY
3013     * @see #GET_INTENT_FILTERS
3014     * @see #GET_RESOLVED_FILTER
3015     */
3016    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3017            int flags);
3018
3019    /**
3020     * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
3021     * user.
3022     *
3023     * @param intent The desired intent as per resolveActivity().
3024     * @param flags Additional option flags.
3025     * @param userId The userId of the user being queried.
3026     *
3027     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3028     *         Receiver. These are ordered from first to last in priority.  If
3029     *         there are no matching receivers, an empty list or {@code null} is returned.
3030     *
3031     * @see #MATCH_DEFAULT_ONLY
3032     * @see #GET_INTENT_FILTERS
3033     * @see #GET_RESOLVED_FILTER
3034     * @hide
3035     */
3036    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3037            int flags, int userId);
3038
3039    /**
3040     * Determine the best service to handle for a given Intent.
3041     *
3042     * @param intent An intent containing all of the desired specification
3043     *               (action, data, type, category, and/or component).
3044     * @param flags Additional option flags.
3045     *
3046     * @return Returns a ResolveInfo containing the final service intent that
3047     *         was determined to be the best action.  Returns null if no
3048     *         matching service was found.
3049     *
3050     * @see #GET_INTENT_FILTERS
3051     * @see #GET_RESOLVED_FILTER
3052     */
3053    public abstract ResolveInfo resolveService(Intent intent, int flags);
3054
3055    /**
3056     * Retrieve all services that can match the given intent.
3057     *
3058     * @param intent The desired intent as per resolveService().
3059     * @param flags Additional option flags.
3060     *
3061     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3062     *         ServiceInfo. These are ordered from best to worst match -- that
3063     *         is, the first item in the list is what is returned by
3064     *         resolveService().  If there are no matching services, an empty
3065     *         list or {@code null} is returned.
3066     *
3067     * @see #GET_INTENT_FILTERS
3068     * @see #GET_RESOLVED_FILTER
3069     */
3070    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
3071            int flags);
3072
3073    /**
3074     * Retrieve all services that can match the given intent for a given user.
3075     *
3076     * @param intent The desired intent as per resolveService().
3077     * @param flags Additional option flags.
3078     * @param userId The user id.
3079     *
3080     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3081     *         ServiceInfo. These are ordered from best to worst match -- that
3082     *         is, the first item in the list is what is returned by
3083     *         resolveService().  If there are no matching services, an empty
3084     *         list or {@code null} is returned.
3085     *
3086     * @see #GET_INTENT_FILTERS
3087     * @see #GET_RESOLVED_FILTER
3088     *
3089     * @hide
3090     */
3091    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
3092            int flags, int userId);
3093
3094    /** {@hide} */
3095    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
3096            Intent intent, int flags, int userId);
3097
3098    /**
3099     * Retrieve all providers that can match the given intent.
3100     *
3101     * @param intent An intent containing all of the desired specification
3102     *            (action, data, type, category, and/or component).
3103     * @param flags Additional option flags.
3104     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3105     *         ProviderInfo. These are ordered from best to worst match. If
3106     *         there are no matching providers, an empty list or {@code null} is returned.
3107     * @see #GET_INTENT_FILTERS
3108     * @see #GET_RESOLVED_FILTER
3109     */
3110    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
3111
3112    /**
3113     * Find a single content provider by its base path name.
3114     *
3115     * @param name The name of the provider to find.
3116     * @param flags Additional option flags.  Currently should always be 0.
3117     *
3118     * @return ContentProviderInfo Information about the provider, if found,
3119     *         else null.
3120     */
3121    public abstract ProviderInfo resolveContentProvider(String name,
3122            int flags);
3123
3124    /**
3125     * Find a single content provider by its base path name.
3126     *
3127     * @param name The name of the provider to find.
3128     * @param flags Additional option flags.  Currently should always be 0.
3129     * @param userId The user id.
3130     *
3131     * @return ContentProviderInfo Information about the provider, if found,
3132     *         else null.
3133     * @hide
3134     */
3135    public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
3136
3137    /**
3138     * Retrieve content provider information.
3139     *
3140     * <p><em>Note: unlike most other methods, an empty result set is indicated
3141     * by a null return instead of an empty list.</em>
3142     *
3143     * @param processName If non-null, limits the returned providers to only
3144     *                    those that are hosted by the given process.  If null,
3145     *                    all content providers are returned.
3146     * @param uid If <var>processName</var> is non-null, this is the required
3147     *        uid owning the requested content providers.
3148     * @param flags Additional option flags.  Currently should always be 0.
3149     *
3150     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
3151     *         content provider either patching <var>processName</var> or, if
3152     *         <var>processName</var> is null, all known content providers.
3153     *         <em>If there are no matching providers, null is returned.</em>
3154     */
3155    public abstract List<ProviderInfo> queryContentProviders(
3156            String processName, int uid, int flags);
3157
3158    /**
3159     * Retrieve all of the information we know about a particular
3160     * instrumentation class.
3161     *
3162     * <p>Throws {@link NameNotFoundException} if instrumentation with the
3163     * given class name cannot be found on the system.
3164     *
3165     * @param className The full name (i.e.
3166     *                  com.google.apps.contacts.InstrumentList) of an
3167     *                  Instrumentation class.
3168     * @param flags Additional option flags.  Currently should always be 0.
3169     *
3170     * @return InstrumentationInfo containing information about the
3171     *         instrumentation.
3172     */
3173    public abstract InstrumentationInfo getInstrumentationInfo(
3174            ComponentName className, int flags) throws NameNotFoundException;
3175
3176    /**
3177     * Retrieve information about available instrumentation code.  May be used
3178     * to retrieve either all instrumentation code, or only the code targeting
3179     * a particular package.
3180     *
3181     * @param targetPackage If null, all instrumentation is returned; only the
3182     *                      instrumentation targeting this package name is
3183     *                      returned.
3184     * @param flags Additional option flags.  Currently should always be 0.
3185     *
3186     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
3187     *         matching available Instrumentation.  Returns an empty list if
3188     *         there is no instrumentation available for the given package.
3189     */
3190    public abstract List<InstrumentationInfo> queryInstrumentation(
3191            String targetPackage, int flags);
3192
3193    /**
3194     * Retrieve an image from a package.  This is a low-level API used by
3195     * the various package manager info structures (such as
3196     * {@link ComponentInfo} to implement retrieval of their associated
3197     * icon.
3198     *
3199     * @param packageName The name of the package that this icon is coming from.
3200     * Cannot be null.
3201     * @param resid The resource identifier of the desired image.  Cannot be 0.
3202     * @param appInfo Overall information about <var>packageName</var>.  This
3203     * may be null, in which case the application information will be retrieved
3204     * for you if needed; if you already have this information around, it can
3205     * be much more efficient to supply it here.
3206     *
3207     * @return Returns a Drawable holding the requested image.  Returns null if
3208     * an image could not be found for any reason.
3209     */
3210    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
3211            ApplicationInfo appInfo);
3212
3213    /**
3214     * Retrieve the icon associated with an activity.  Given the full name of
3215     * an activity, retrieves the information about it and calls
3216     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
3217     * If the activity cannot be found, NameNotFoundException is thrown.
3218     *
3219     * @param activityName Name of the activity whose icon is to be retrieved.
3220     *
3221     * @return Returns the image of the icon, or the default activity icon if
3222     * it could not be found.  Does not return null.
3223     * @throws NameNotFoundException Thrown if the resources for the given
3224     * activity could not be loaded.
3225     *
3226     * @see #getActivityIcon(Intent)
3227     */
3228    public abstract Drawable getActivityIcon(ComponentName activityName)
3229            throws NameNotFoundException;
3230
3231    /**
3232     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
3233     * set, this simply returns the result of
3234     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
3235     * component and returns the icon associated with the resolved component.
3236     * If intent.getClassName() cannot be found or the Intent cannot be resolved
3237     * to a component, NameNotFoundException is thrown.
3238     *
3239     * @param intent The intent for which you would like to retrieve an icon.
3240     *
3241     * @return Returns the image of the icon, or the default activity icon if
3242     * it could not be found.  Does not return null.
3243     * @throws NameNotFoundException Thrown if the resources for application
3244     * matching the given intent could not be loaded.
3245     *
3246     * @see #getActivityIcon(ComponentName)
3247     */
3248    public abstract Drawable getActivityIcon(Intent intent)
3249            throws NameNotFoundException;
3250
3251    /**
3252     * Retrieve the banner associated with an activity. Given the full name of
3253     * an activity, retrieves the information about it and calls
3254     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
3255     * banner. If the activity cannot be found, NameNotFoundException is thrown.
3256     *
3257     * @param activityName Name of the activity whose banner is to be retrieved.
3258     * @return Returns the image of the banner, or null if the activity has no
3259     *         banner specified.
3260     * @throws NameNotFoundException Thrown if the resources for the given
3261     *             activity could not be loaded.
3262     * @see #getActivityBanner(Intent)
3263     */
3264    public abstract Drawable getActivityBanner(ComponentName activityName)
3265            throws NameNotFoundException;
3266
3267    /**
3268     * Retrieve the banner associated with an Intent. If intent.getClassName()
3269     * is set, this simply returns the result of
3270     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
3271     * intent's component and returns the banner associated with the resolved
3272     * component. If intent.getClassName() cannot be found or the Intent cannot
3273     * be resolved to a component, NameNotFoundException is thrown.
3274     *
3275     * @param intent The intent for which you would like to retrieve a banner.
3276     * @return Returns the image of the banner, or null if the activity has no
3277     *         banner specified.
3278     * @throws NameNotFoundException Thrown if the resources for application
3279     *             matching the given intent could not be loaded.
3280     * @see #getActivityBanner(ComponentName)
3281     */
3282    public abstract Drawable getActivityBanner(Intent intent)
3283            throws NameNotFoundException;
3284
3285    /**
3286     * Return the generic icon for an activity that is used when no specific
3287     * icon is defined.
3288     *
3289     * @return Drawable Image of the icon.
3290     */
3291    public abstract Drawable getDefaultActivityIcon();
3292
3293    /**
3294     * Retrieve the icon associated with an application.  If it has not defined
3295     * an icon, the default app icon is returned.  Does not return null.
3296     *
3297     * @param info Information about application being queried.
3298     *
3299     * @return Returns the image of the icon, or the default application icon
3300     * if it could not be found.
3301     *
3302     * @see #getApplicationIcon(String)
3303     */
3304    public abstract Drawable getApplicationIcon(ApplicationInfo info);
3305
3306    /**
3307     * Retrieve the icon associated with an application.  Given the name of the
3308     * application's package, retrieves the information about it and calls
3309     * getApplicationIcon() to return its icon. If the application cannot be
3310     * found, NameNotFoundException is thrown.
3311     *
3312     * @param packageName Name of the package whose application icon is to be
3313     *                    retrieved.
3314     *
3315     * @return Returns the image of the icon, or the default application icon
3316     * if it could not be found.  Does not return null.
3317     * @throws NameNotFoundException Thrown if the resources for the given
3318     * application could not be loaded.
3319     *
3320     * @see #getApplicationIcon(ApplicationInfo)
3321     */
3322    public abstract Drawable getApplicationIcon(String packageName)
3323            throws NameNotFoundException;
3324
3325    /**
3326     * Retrieve the banner associated with an application.
3327     *
3328     * @param info Information about application being queried.
3329     * @return Returns the image of the banner or null if the application has no
3330     *         banner specified.
3331     * @see #getApplicationBanner(String)
3332     */
3333    public abstract Drawable getApplicationBanner(ApplicationInfo info);
3334
3335    /**
3336     * Retrieve the banner associated with an application. Given the name of the
3337     * application's package, retrieves the information about it and calls
3338     * getApplicationIcon() to return its banner. If the application cannot be
3339     * found, NameNotFoundException is thrown.
3340     *
3341     * @param packageName Name of the package whose application banner is to be
3342     *            retrieved.
3343     * @return Returns the image of the banner or null if the application has no
3344     *         banner specified.
3345     * @throws NameNotFoundException Thrown if the resources for the given
3346     *             application could not be loaded.
3347     * @see #getApplicationBanner(ApplicationInfo)
3348     */
3349    public abstract Drawable getApplicationBanner(String packageName)
3350            throws NameNotFoundException;
3351
3352    /**
3353     * Retrieve the logo associated with an activity. Given the full name of an
3354     * activity, retrieves the information about it and calls
3355     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
3356     * logo. If the activity cannot be found, NameNotFoundException is thrown.
3357     *
3358     * @param activityName Name of the activity whose logo is to be retrieved.
3359     * @return Returns the image of the logo or null if the activity has no logo
3360     *         specified.
3361     * @throws NameNotFoundException Thrown if the resources for the given
3362     *             activity could not be loaded.
3363     * @see #getActivityLogo(Intent)
3364     */
3365    public abstract Drawable getActivityLogo(ComponentName activityName)
3366            throws NameNotFoundException;
3367
3368    /**
3369     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
3370     * set, this simply returns the result of
3371     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
3372     * component and returns the logo associated with the resolved component.
3373     * If intent.getClassName() cannot be found or the Intent cannot be resolved
3374     * to a component, NameNotFoundException is thrown.
3375     *
3376     * @param intent The intent for which you would like to retrieve a logo.
3377     *
3378     * @return Returns the image of the logo, or null if the activity has no
3379     * logo specified.
3380     *
3381     * @throws NameNotFoundException Thrown if the resources for application
3382     * matching the given intent could not be loaded.
3383     *
3384     * @see #getActivityLogo(ComponentName)
3385     */
3386    public abstract Drawable getActivityLogo(Intent intent)
3387            throws NameNotFoundException;
3388
3389    /**
3390     * Retrieve the logo associated with an application.  If it has not specified
3391     * a logo, this method returns null.
3392     *
3393     * @param info Information about application being queried.
3394     *
3395     * @return Returns the image of the logo, or null if no logo is specified
3396     * by the application.
3397     *
3398     * @see #getApplicationLogo(String)
3399     */
3400    public abstract Drawable getApplicationLogo(ApplicationInfo info);
3401
3402    /**
3403     * Retrieve the logo associated with an application.  Given the name of the
3404     * application's package, retrieves the information about it and calls
3405     * getApplicationLogo() to return its logo. If the application cannot be
3406     * found, NameNotFoundException is thrown.
3407     *
3408     * @param packageName Name of the package whose application logo is to be
3409     *                    retrieved.
3410     *
3411     * @return Returns the image of the logo, or null if no application logo
3412     * has been specified.
3413     *
3414     * @throws NameNotFoundException Thrown if the resources for the given
3415     * application could not be loaded.
3416     *
3417     * @see #getApplicationLogo(ApplicationInfo)
3418     */
3419    public abstract Drawable getApplicationLogo(String packageName)
3420            throws NameNotFoundException;
3421
3422    /**
3423     * If the target user is a managed profile of the calling user or if the
3424     * target user is the caller and is itself a managed profile, then this
3425     * returns a badged copy of the given icon to be able to distinguish it from
3426     * the original icon. For badging an arbitrary drawable use
3427     * {@link #getUserBadgedDrawableForDensity(
3428     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
3429     * <p>
3430     * If the original drawable is a BitmapDrawable and the backing bitmap is
3431     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
3432     * is performed in place and the original drawable is returned.
3433     * </p>
3434     *
3435     * @param icon The icon to badge.
3436     * @param user The target user.
3437     * @return A drawable that combines the original icon and a badge as
3438     *         determined by the system.
3439     */
3440    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
3441
3442    /**
3443     * If the target user is a managed profile of the calling user or the caller
3444     * is itself a managed profile, then this returns a badged copy of the given
3445     * drawable allowing the user to distinguish it from the original drawable.
3446     * The caller can specify the location in the bounds of the drawable to be
3447     * badged where the badge should be applied as well as the density of the
3448     * badge to be used.
3449     * <p>
3450     * If the original drawable is a BitmapDrawable and the backing bitmap is
3451     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
3452     * is performed in place and the original drawable is returned.
3453     * </p>
3454     *
3455     * @param drawable The drawable to badge.
3456     * @param user The target user.
3457     * @param badgeLocation Where in the bounds of the badged drawable to place
3458     *         the badge. If not provided, the badge is applied on top of the entire
3459     *         drawable being badged.
3460     * @param badgeDensity The optional desired density for the badge as per
3461     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
3462     *         the density of the display is used.
3463     * @return A drawable that combines the original drawable and a badge as
3464     *         determined by the system.
3465     */
3466    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
3467            UserHandle user, Rect badgeLocation, int badgeDensity);
3468
3469    /**
3470     * If the target user is a managed profile of the calling user or the caller
3471     * is itself a managed profile, then this returns a drawable to use as a small
3472     * icon to include in a view to distinguish it from the original icon.
3473     *
3474     * @param user The target user.
3475     * @param density The optional desired density for the badge as per
3476     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
3477     *         the density of the current display is used.
3478     * @return the drawable or null if no drawable is required.
3479     * @hide
3480     */
3481    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
3482
3483    /**
3484     * If the target user is a managed profile of the calling user or the caller
3485     * is itself a managed profile, then this returns a copy of the label with
3486     * badging for accessibility services like talkback. E.g. passing in "Email"
3487     * and it might return "Work Email" for Email in the work profile.
3488     *
3489     * @param label The label to change.
3490     * @param user The target user.
3491     * @return A label that combines the original label and a badge as
3492     *         determined by the system.
3493     */
3494    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
3495
3496    /**
3497     * Retrieve text from a package.  This is a low-level API used by
3498     * the various package manager info structures (such as
3499     * {@link ComponentInfo} to implement retrieval of their associated
3500     * labels and other text.
3501     *
3502     * @param packageName The name of the package that this text is coming from.
3503     * Cannot be null.
3504     * @param resid The resource identifier of the desired text.  Cannot be 0.
3505     * @param appInfo Overall information about <var>packageName</var>.  This
3506     * may be null, in which case the application information will be retrieved
3507     * for you if needed; if you already have this information around, it can
3508     * be much more efficient to supply it here.
3509     *
3510     * @return Returns a CharSequence holding the requested text.  Returns null
3511     * if the text could not be found for any reason.
3512     */
3513    public abstract CharSequence getText(String packageName, @StringRes int resid,
3514            ApplicationInfo appInfo);
3515
3516    /**
3517     * Retrieve an XML file from a package.  This is a low-level API used to
3518     * retrieve XML meta data.
3519     *
3520     * @param packageName The name of the package that this xml is coming from.
3521     * Cannot be null.
3522     * @param resid The resource identifier of the desired xml.  Cannot be 0.
3523     * @param appInfo Overall information about <var>packageName</var>.  This
3524     * may be null, in which case the application information will be retrieved
3525     * for you if needed; if you already have this information around, it can
3526     * be much more efficient to supply it here.
3527     *
3528     * @return Returns an XmlPullParser allowing you to parse out the XML
3529     * data.  Returns null if the xml resource could not be found for any
3530     * reason.
3531     */
3532    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
3533            ApplicationInfo appInfo);
3534
3535    /**
3536     * Return the label to use for this application.
3537     *
3538     * @return Returns the label associated with this application, or null if
3539     * it could not be found for any reason.
3540     * @param info The application to get the label of.
3541     */
3542    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
3543
3544    /**
3545     * Retrieve the resources associated with an activity.  Given the full
3546     * name of an activity, retrieves the information about it and calls
3547     * getResources() to return its application's resources.  If the activity
3548     * cannot be found, NameNotFoundException is thrown.
3549     *
3550     * @param activityName Name of the activity whose resources are to be
3551     *                     retrieved.
3552     *
3553     * @return Returns the application's Resources.
3554     * @throws NameNotFoundException Thrown if the resources for the given
3555     * application could not be loaded.
3556     *
3557     * @see #getResourcesForApplication(ApplicationInfo)
3558     */
3559    public abstract Resources getResourcesForActivity(ComponentName activityName)
3560            throws NameNotFoundException;
3561
3562    /**
3563     * Retrieve the resources for an application.  Throws NameNotFoundException
3564     * if the package is no longer installed.
3565     *
3566     * @param app Information about the desired application.
3567     *
3568     * @return Returns the application's Resources.
3569     * @throws NameNotFoundException Thrown if the resources for the given
3570     * application could not be loaded (most likely because it was uninstalled).
3571     */
3572    public abstract Resources getResourcesForApplication(ApplicationInfo app)
3573            throws NameNotFoundException;
3574
3575    /**
3576     * Retrieve the resources associated with an application.  Given the full
3577     * package name of an application, retrieves the information about it and
3578     * calls getResources() to return its application's resources.  If the
3579     * appPackageName cannot be found, NameNotFoundException is thrown.
3580     *
3581     * @param appPackageName Package name of the application whose resources
3582     *                       are to be retrieved.
3583     *
3584     * @return Returns the application's Resources.
3585     * @throws NameNotFoundException Thrown if the resources for the given
3586     * application could not be loaded.
3587     *
3588     * @see #getResourcesForApplication(ApplicationInfo)
3589     */
3590    public abstract Resources getResourcesForApplication(String appPackageName)
3591            throws NameNotFoundException;
3592
3593    /** @hide */
3594    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
3595            throws NameNotFoundException;
3596
3597    /**
3598     * Retrieve overall information about an application package defined
3599     * in a package archive file
3600     *
3601     * @param archiveFilePath The path to the archive file
3602     * @param flags Additional option flags. Use any combination of
3603     * {@link #GET_ACTIVITIES},
3604     * {@link #GET_GIDS},
3605     * {@link #GET_CONFIGURATIONS},
3606     * {@link #GET_INSTRUMENTATION},
3607     * {@link #GET_PERMISSIONS},
3608     * {@link #GET_PROVIDERS},
3609     * {@link #GET_RECEIVERS},
3610     * {@link #GET_SERVICES},
3611     * {@link #GET_SIGNATURES}, to modify the data returned.
3612     *
3613     * @return Returns the information about the package. Returns
3614     * null if the package could not be successfully parsed.
3615     *
3616     * @see #GET_ACTIVITIES
3617     * @see #GET_GIDS
3618     * @see #GET_CONFIGURATIONS
3619     * @see #GET_INSTRUMENTATION
3620     * @see #GET_PERMISSIONS
3621     * @see #GET_PROVIDERS
3622     * @see #GET_RECEIVERS
3623     * @see #GET_SERVICES
3624     * @see #GET_SIGNATURES
3625     *
3626     */
3627    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3628        final PackageParser parser = new PackageParser();
3629        final File apkFile = new File(archiveFilePath);
3630        try {
3631            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3632            if ((flags & GET_SIGNATURES) != 0) {
3633                parser.collectCertificates(pkg, 0);
3634                parser.collectManifestDigest(pkg);
3635            }
3636            PackageUserState state = new PackageUserState();
3637            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3638        } catch (PackageParserException e) {
3639            return null;
3640        }
3641    }
3642
3643    /**
3644     * @hide Install a package. Since this may take a little while, the result
3645     *       will be posted back to the given observer. An installation will
3646     *       fail if the calling context lacks the
3647     *       {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3648     *       the package named in the package file's manifest is already
3649     *       installed, or if there's no space available on the device.
3650     * @param packageURI The location of the package file to install. This can
3651     *            be a 'file:' or a 'content:' URI.
3652     * @param observer An observer callback to get notified when the package
3653     *            installation is complete.
3654     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3655     *            will be called when that happens. This parameter must not be
3656     *            null.
3657     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3658     *            {@link #INSTALL_REPLACE_EXISTING},
3659     *            {@link #INSTALL_ALLOW_TEST}.
3660     * @param installerPackageName Optional package name of the application that
3661     *            is performing the installation. This identifies which market
3662     *            the package came from.
3663     * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3664     *             String)} instead. This method will continue to be supported
3665     *             but the older observer interface will not get additional
3666     *             failure details.
3667     */
3668    // @SystemApi
3669    public abstract void installPackage(
3670            Uri packageURI, IPackageInstallObserver observer, int flags,
3671            String installerPackageName);
3672
3673    /**
3674     * Similar to
3675     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3676     * with an extra verification file provided.
3677     *
3678     * @param packageURI The location of the package file to install. This can
3679     *            be a 'file:' or a 'content:' URI.
3680     * @param observer An observer callback to get notified when the package
3681     *            installation is complete.
3682     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3683     *            will be called when that happens. This parameter must not be
3684     *            null.
3685     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3686     *            {@link #INSTALL_REPLACE_EXISTING},
3687     *            {@link #INSTALL_ALLOW_TEST}.
3688     * @param installerPackageName Optional package name of the application that
3689     *            is performing the installation. This identifies which market
3690     *            the package came from.
3691     * @param verificationURI The location of the supplementary verification
3692     *            file. This can be a 'file:' or a 'content:' URI. May be
3693     *            {@code null}.
3694     * @param manifestDigest an object that holds the digest of the package
3695     *            which can be used to verify ownership. May be {@code null}.
3696     * @param encryptionParams if the package to be installed is encrypted,
3697     *            these parameters describing the encryption and authentication
3698     *            used. May be {@code null}.
3699     * @hide
3700     * @deprecated Use {@link #installPackageWithVerification(Uri,
3701     *             PackageInstallObserver, int, String, Uri, ManifestDigest,
3702     *             ContainerEncryptionParams)} instead. This method will
3703     *             continue to be supported but the older observer interface
3704     *             will not get additional failure details.
3705     */
3706    // @SystemApi
3707    public abstract void installPackageWithVerification(Uri packageURI,
3708            IPackageInstallObserver observer, int flags, String installerPackageName,
3709            Uri verificationURI, ManifestDigest manifestDigest,
3710            ContainerEncryptionParams encryptionParams);
3711
3712    /**
3713     * Similar to
3714     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3715     * with an extra verification information provided.
3716     *
3717     * @param packageURI The location of the package file to install. This can
3718     *            be a 'file:' or a 'content:' URI.
3719     * @param observer An observer callback to get notified when the package
3720     *            installation is complete.
3721     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3722     *            will be called when that happens. This parameter must not be
3723     *            null.
3724     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3725     *            {@link #INSTALL_REPLACE_EXISTING},
3726     *            {@link #INSTALL_ALLOW_TEST}.
3727     * @param installerPackageName Optional package name of the application that
3728     *            is performing the installation. This identifies which market
3729     *            the package came from.
3730     * @param verificationParams an object that holds signal information to
3731     *            assist verification. May be {@code null}.
3732     * @param encryptionParams if the package to be installed is encrypted,
3733     *            these parameters describing the encryption and authentication
3734     *            used. May be {@code null}.
3735     * @hide
3736     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3737     *             PackageInstallObserver, int, String, VerificationParams,
3738     *             ContainerEncryptionParams)} instead. This method will
3739     *             continue to be supported but the older observer interface
3740     *             will not get additional failure details.
3741     */
3742    @Deprecated
3743    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3744            IPackageInstallObserver observer, int flags, String installerPackageName,
3745            VerificationParams verificationParams,
3746            ContainerEncryptionParams encryptionParams);
3747
3748    // Package-install variants that take the new, expanded form of observer interface.
3749    // Note that these *also* take the original observer type and will redundantly
3750    // report the same information to that observer if supplied; but it is not required.
3751
3752    /**
3753     * @hide
3754     *
3755     * Install a package. Since this may take a little while, the result will
3756     * be posted back to the given observer.  An installation will fail if the calling context
3757     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3758     * package named in the package file's manifest is already installed, or if there's no space
3759     * available on the device.
3760     *
3761     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3762     * 'content:' URI.
3763     * @param observer An observer callback to get notified when the package installation is
3764     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3765     * called when that happens. This parameter must not be null.
3766     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3767     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3768     * @param installerPackageName Optional package name of the application that is performing the
3769     * installation. This identifies which market the package came from.
3770     */
3771    public abstract void installPackage(
3772            Uri packageURI, PackageInstallObserver observer,
3773            int flags, String installerPackageName);
3774
3775
3776    /**
3777     * @hide
3778     * Install a package. Since this may take a little while, the result will be
3779     * posted back to the given observer. An installation will fail if the package named
3780     * in the package file's manifest is already installed, or if there's no space
3781     * available on the device.
3782     * @param packageURI The location of the package file to install. This can be a 'file:' or a
3783     * 'content:' URI.
3784     * @param observer An observer callback to get notified when the package installation is
3785     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3786     * called when that happens. This parameter must not be null.
3787     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3788     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3789     * @param installerPackageName Optional package name of the application that is performing the
3790     * installation. This identifies which market the package came from.
3791     * @param userId The user id.
3792     */
3793     @RequiresPermission(anyOf = {
3794            Manifest.permission.INSTALL_PACKAGES,
3795            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
3796    public abstract void installPackageAsUser(
3797            Uri packageURI, PackageInstallObserver observer, int flags,
3798            String installerPackageName, int userId);
3799
3800    /**
3801     * Similar to
3802     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3803     * with an extra verification file provided.
3804     *
3805     * @param packageURI The location of the package file to install. This can
3806     *            be a 'file:' or a 'content:' URI.
3807     * @param observer An observer callback to get notified when the package installation is
3808     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3809     * called when that happens. This parameter must not be null.
3810     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3811     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3812     * @param installerPackageName Optional package name of the application that
3813     *            is performing the installation. This identifies which market
3814     *            the package came from.
3815     * @param verificationURI The location of the supplementary verification
3816     *            file. This can be a 'file:' or a 'content:' URI. May be
3817     *            {@code null}.
3818     * @param manifestDigest an object that holds the digest of the package
3819     *            which can be used to verify ownership. May be {@code null}.
3820     * @param encryptionParams if the package to be installed is encrypted,
3821     *            these parameters describing the encryption and authentication
3822     *            used. May be {@code null}.
3823     * @hide
3824     */
3825    public abstract void installPackageWithVerification(Uri packageURI,
3826            PackageInstallObserver observer, int flags, String installerPackageName,
3827            Uri verificationURI, ManifestDigest manifestDigest,
3828            ContainerEncryptionParams encryptionParams);
3829
3830    /**
3831     * Similar to
3832     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3833     * with an extra verification information provided.
3834     *
3835     * @param packageURI The location of the package file to install. This can
3836     *            be a 'file:' or a 'content:' URI.
3837     * @param observer An observer callback to get notified when the package installation is
3838     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3839     * called when that happens. This parameter must not be null.
3840     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3841     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3842     * @param installerPackageName Optional package name of the application that
3843     *            is performing the installation. This identifies which market
3844     *            the package came from.
3845     * @param verificationParams an object that holds signal information to
3846     *            assist verification. May be {@code null}.
3847     * @param encryptionParams if the package to be installed is encrypted,
3848     *            these parameters describing the encryption and authentication
3849     *            used. May be {@code null}.
3850     *
3851     * @hide
3852     */
3853    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3854            PackageInstallObserver observer, int flags, String installerPackageName,
3855            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3856
3857    /**
3858     * If there is already an application with the given package name installed
3859     * on the system for other users, also install it for the calling user.
3860     * @hide
3861     */
3862    // @SystemApi
3863    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
3864
3865    /**
3866     * If there is already an application with the given package name installed
3867     * on the system for other users, also install it for the specified user.
3868     * @hide
3869     */
3870     @RequiresPermission(anyOf = {
3871            Manifest.permission.INSTALL_PACKAGES,
3872            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
3873    public abstract int installExistingPackageAsUser(String packageName, int userId)
3874            throws NameNotFoundException;
3875
3876    /**
3877     * Allows a package listening to the
3878     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3879     * broadcast} to respond to the package manager. The response must include
3880     * the {@code verificationCode} which is one of
3881     * {@link PackageManager#VERIFICATION_ALLOW} or
3882     * {@link PackageManager#VERIFICATION_REJECT}.
3883     *
3884     * @param id pending package identifier as passed via the
3885     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3886     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3887     *            or {@link PackageManager#VERIFICATION_REJECT}.
3888     * @throws SecurityException if the caller does not have the
3889     *            PACKAGE_VERIFICATION_AGENT permission.
3890     */
3891    public abstract void verifyPendingInstall(int id, int verificationCode);
3892
3893    /**
3894     * Allows a package listening to the
3895     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3896     * broadcast} to extend the default timeout for a response and declare what
3897     * action to perform after the timeout occurs. The response must include
3898     * the {@code verificationCodeAtTimeout} which is one of
3899     * {@link PackageManager#VERIFICATION_ALLOW} or
3900     * {@link PackageManager#VERIFICATION_REJECT}.
3901     *
3902     * This method may only be called once per package id. Additional calls
3903     * will have no effect.
3904     *
3905     * @param id pending package identifier as passed via the
3906     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3907     * @param verificationCodeAtTimeout either
3908     *            {@link PackageManager#VERIFICATION_ALLOW} or
3909     *            {@link PackageManager#VERIFICATION_REJECT}. If
3910     *            {@code verificationCodeAtTimeout} is neither
3911     *            {@link PackageManager#VERIFICATION_ALLOW} or
3912     *            {@link PackageManager#VERIFICATION_REJECT}, then
3913     *            {@code verificationCodeAtTimeout} will default to
3914     *            {@link PackageManager#VERIFICATION_REJECT}.
3915     * @param millisecondsToDelay the amount of time requested for the timeout.
3916     *            Must be positive and less than
3917     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3918     *            {@code millisecondsToDelay} is out of bounds,
3919     *            {@code millisecondsToDelay} will be set to the closest in
3920     *            bounds value; namely, 0 or
3921     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3922     * @throws SecurityException if the caller does not have the
3923     *            PACKAGE_VERIFICATION_AGENT permission.
3924     */
3925    public abstract void extendVerificationTimeout(int id,
3926            int verificationCodeAtTimeout, long millisecondsToDelay);
3927
3928    /**
3929     * Allows a package listening to the
3930     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification
3931     * broadcast} to respond to the package manager. The response must include
3932     * the {@code verificationCode} which is one of
3933     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
3934     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
3935     *
3936     * @param verificationId pending package identifier as passed via the
3937     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3938     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
3939     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
3940     * @param outFailedDomains a list of failed domains if the verificationCode is
3941     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
3942     * @throws SecurityException if the caller does not have the
3943     *            INTENT_FILTER_VERIFICATION_AGENT permission.
3944     *
3945     * @hide
3946     */
3947    @SystemApi
3948    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
3949            List<String> outFailedDomains);
3950
3951    /**
3952     * Get the status of a Domain Verification Result for an IntentFilter. This is
3953     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
3954     * {@link android.content.IntentFilter#getAutoVerify()}
3955     *
3956     * This is used by the ResolverActivity to change the status depending on what the User select
3957     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
3958     * for a domain.
3959     *
3960     * @param packageName The package name of the Activity associated with the IntentFilter.
3961     * @param userId The user id.
3962     *
3963     * @return The status to set to. This can be
3964     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
3965     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
3966     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
3967     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
3968     *
3969     * @hide
3970     */
3971    public abstract int getIntentVerificationStatus(String packageName, int userId);
3972
3973    /**
3974     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
3975     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
3976     * {@link android.content.IntentFilter#getAutoVerify()}
3977     *
3978     * This is used by the ResolverActivity to change the status depending on what the User select
3979     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
3980     * for a domain.
3981     *
3982     * @param packageName The package name of the Activity associated with the IntentFilter.
3983     * @param status The status to set to. This can be
3984     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
3985     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
3986     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
3987     * @param userId The user id.
3988     *
3989     * @return true if the status has been set. False otherwise.
3990     *
3991     * @hide
3992     */
3993    public abstract boolean updateIntentVerificationStatus(String packageName, int status,
3994            int userId);
3995
3996    /**
3997     * Get the list of IntentFilterVerificationInfo for a specific package and User.
3998     *
3999     * @param packageName the package name. When this parameter is set to a non null value,
4000     *                    the results will be filtered by the package name provided.
4001     *                    Otherwise, there will be no filtering and it will return a list
4002     *                    corresponding for all packages
4003     *
4004     * @return a list of IntentFilterVerificationInfo for a specific package.
4005     *
4006     * @hide
4007     */
4008    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4009            String packageName);
4010
4011    /**
4012     * Get the list of IntentFilter for a specific package.
4013     *
4014     * @param packageName the package name. This parameter is set to a non null value,
4015     *                    the list will contain all the IntentFilter for that package.
4016     *                    Otherwise, the list will be empty.
4017     *
4018     * @return a list of IntentFilter for a specific package.
4019     *
4020     * @hide
4021     */
4022    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4023
4024    /**
4025     * Get the default Browser package name for a specific user.
4026     *
4027     * @param userId The user id.
4028     *
4029     * @return the package name of the default Browser for the specified user. If the user id passed
4030     *         is -1 (all users) it will return a null value.
4031     *
4032     * @hide
4033     */
4034    public abstract String getDefaultBrowserPackageName(int userId);
4035
4036    /**
4037     * Set the default Browser package name for a specific user.
4038     *
4039     * @param packageName The package name of the default Browser.
4040     * @param userId The user id.
4041     *
4042     * @return true if the default Browser for the specified user has been set,
4043     *         otherwise return false. If the user id passed is -1 (all users) this call will not
4044     *         do anything and just return false.
4045     *
4046     * @hide
4047     */
4048    public abstract boolean setDefaultBrowserPackageName(String packageName, int userId);
4049
4050    /**
4051     * Change the installer associated with a given package.  There are limitations
4052     * on how the installer package can be changed; in particular:
4053     * <ul>
4054     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4055     * is not signed with the same certificate as the calling application.
4056     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4057     * has an installer package, and that installer package is not signed with
4058     * the same certificate as the calling application.
4059     * </ul>
4060     *
4061     * @param targetPackage The installed package whose installer will be changed.
4062     * @param installerPackageName The package name of the new installer.  May be
4063     * null to clear the association.
4064     */
4065    public abstract void setInstallerPackageName(String targetPackage,
4066            String installerPackageName);
4067
4068    /**
4069     * Attempts to delete a package.  Since this may take a little while, the result will
4070     * be posted back to the given observer.  A deletion will fail if the calling context
4071     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
4072     * named package cannot be found, or if the named package is a "system package".
4073     * (TODO: include pointer to documentation on "system packages")
4074     *
4075     * @param packageName The name of the package to delete
4076     * @param observer An observer callback to get notified when the package deletion is
4077     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
4078     * called when that happens.  observer may be null to indicate that no callback is desired.
4079     * @param flags Possible values: {@link #DELETE_KEEP_DATA},
4080     * {@link #DELETE_ALL_USERS}.
4081     *
4082     * @hide
4083     */
4084    // @SystemApi
4085    public abstract void deletePackage(
4086            String packageName, IPackageDeleteObserver observer, int flags);
4087
4088    /**
4089     * Attempts to delete a package.  Since this may take a little while, the result will
4090     * be posted back to the given observer. A deletion will fail if the named package cannot be
4091     * found, or if the named package is a "system package".
4092     * (TODO: include pointer to documentation on "system packages")
4093     *
4094     * @param packageName The name of the package to delete
4095     * @param observer An observer callback to get notified when the package deletion is
4096     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
4097     * called when that happens.  observer may be null to indicate that no callback is desired.
4098     * @param flags Possible values: {@link #DELETE_KEEP_DATA}, {@link #DELETE_ALL_USERS}.
4099     * @param userId The user Id
4100     *
4101     * @hide
4102     */
4103     @RequiresPermission(anyOf = {
4104            Manifest.permission.DELETE_PACKAGES,
4105            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4106    public abstract void deletePackageAsUser(
4107            String packageName, IPackageDeleteObserver observer, int flags, int userId);
4108
4109    /**
4110     * Retrieve the package name of the application that installed a package. This identifies
4111     * which market the package came from.
4112     *
4113     * @param packageName The name of the package to query
4114     */
4115    public abstract String getInstallerPackageName(String packageName);
4116
4117    /**
4118     * Attempts to clear the user data directory of an application.
4119     * Since this may take a little while, the result will
4120     * be posted back to the given observer.  A deletion will fail if the
4121     * named package cannot be found, or if the named package is a "system package".
4122     *
4123     * @param packageName The name of the package
4124     * @param observer An observer callback to get notified when the operation is finished
4125     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4126     * will be called when that happens.  observer may be null to indicate that
4127     * no callback is desired.
4128     *
4129     * @hide
4130     */
4131    public abstract void clearApplicationUserData(String packageName,
4132            IPackageDataObserver observer);
4133    /**
4134     * Attempts to delete the cache files associated with an application.
4135     * Since this may take a little while, the result will
4136     * be posted back to the given observer.  A deletion will fail if the calling context
4137     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
4138     * named package cannot be found, or if the named package is a "system package".
4139     *
4140     * @param packageName The name of the package to delete
4141     * @param observer An observer callback to get notified when the cache file deletion
4142     * is complete.
4143     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4144     * will be called when that happens.  observer may be null to indicate that
4145     * no callback is desired.
4146     *
4147     * @hide
4148     */
4149    public abstract void deleteApplicationCacheFiles(String packageName,
4150            IPackageDataObserver observer);
4151
4152    /**
4153     * Free storage by deleting LRU sorted list of cache files across
4154     * all applications. If the currently available free storage
4155     * on the device is greater than or equal to the requested
4156     * free storage, no cache files are cleared. If the currently
4157     * available storage on the device is less than the requested
4158     * free storage, some or all of the cache files across
4159     * all applications are deleted (based on last accessed time)
4160     * to increase the free storage space on the device to
4161     * the requested value. There is no guarantee that clearing all
4162     * the cache files from all applications will clear up
4163     * enough storage to achieve the desired value.
4164     * @param freeStorageSize The number of bytes of storage to be
4165     * freed by the system. Say if freeStorageSize is XX,
4166     * and the current free storage is YY,
4167     * if XX is less than YY, just return. if not free XX-YY number
4168     * of bytes if possible.
4169     * @param observer call back used to notify when
4170     * the operation is completed
4171     *
4172     * @hide
4173     */
4174    // @SystemApi
4175    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
4176        freeStorageAndNotify(null, freeStorageSize, observer);
4177    }
4178
4179    /** {@hide} */
4180    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
4181            IPackageDataObserver observer);
4182
4183    /**
4184     * Free storage by deleting LRU sorted list of cache files across
4185     * all applications. If the currently available free storage
4186     * on the device is greater than or equal to the requested
4187     * free storage, no cache files are cleared. If the currently
4188     * available storage on the device is less than the requested
4189     * free storage, some or all of the cache files across
4190     * all applications are deleted (based on last accessed time)
4191     * to increase the free storage space on the device to
4192     * the requested value. There is no guarantee that clearing all
4193     * the cache files from all applications will clear up
4194     * enough storage to achieve the desired value.
4195     * @param freeStorageSize The number of bytes of storage to be
4196     * freed by the system. Say if freeStorageSize is XX,
4197     * and the current free storage is YY,
4198     * if XX is less than YY, just return. if not free XX-YY number
4199     * of bytes if possible.
4200     * @param pi IntentSender call back used to
4201     * notify when the operation is completed.May be null
4202     * to indicate that no call back is desired.
4203     *
4204     * @hide
4205     */
4206    public void freeStorage(long freeStorageSize, IntentSender pi) {
4207        freeStorage(null, freeStorageSize, pi);
4208    }
4209
4210    /** {@hide} */
4211    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
4212
4213    /**
4214     * Retrieve the size information for a package.
4215     * Since this may take a little while, the result will
4216     * be posted back to the given observer.  The calling context
4217     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
4218     *
4219     * @param packageName The name of the package whose size information is to be retrieved
4220     * @param userHandle The user whose size information should be retrieved.
4221     * @param observer An observer callback to get notified when the operation
4222     * is complete.
4223     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
4224     * The observer's callback is invoked with a PackageStats object(containing the
4225     * code, data and cache sizes of the package) and a boolean value representing
4226     * the status of the operation. observer may be null to indicate that
4227     * no callback is desired.
4228     *
4229     * @hide
4230     */
4231    public abstract void getPackageSizeInfo(String packageName, int userHandle,
4232            IPackageStatsObserver observer);
4233
4234    /**
4235     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
4236     * returns the size for the calling user.
4237     *
4238     * @hide
4239     */
4240    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
4241        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
4242    }
4243
4244    /**
4245     * @deprecated This function no longer does anything; it was an old
4246     * approach to managing preferred activities, which has been superseded
4247     * by (and conflicts with) the modern activity-based preferences.
4248     */
4249    @Deprecated
4250    public abstract void addPackageToPreferred(String packageName);
4251
4252    /**
4253     * @deprecated This function no longer does anything; it was an old
4254     * approach to managing preferred activities, which has been superseded
4255     * by (and conflicts with) the modern activity-based preferences.
4256     */
4257    @Deprecated
4258    public abstract void removePackageFromPreferred(String packageName);
4259
4260    /**
4261     * Retrieve the list of all currently configured preferred packages.  The
4262     * first package on the list is the most preferred, the last is the
4263     * least preferred.
4264     *
4265     * @param flags Additional option flags. Use any combination of
4266     * {@link #GET_ACTIVITIES},
4267     * {@link #GET_GIDS},
4268     * {@link #GET_CONFIGURATIONS},
4269     * {@link #GET_INSTRUMENTATION},
4270     * {@link #GET_PERMISSIONS},
4271     * {@link #GET_PROVIDERS},
4272     * {@link #GET_RECEIVERS},
4273     * {@link #GET_SERVICES},
4274     * {@link #GET_SIGNATURES}, to modify the data returned.
4275     *
4276     * @return Returns a list of PackageInfo objects describing each
4277     * preferred application, in order of preference.
4278     *
4279     * @see #GET_ACTIVITIES
4280     * @see #GET_GIDS
4281     * @see #GET_CONFIGURATIONS
4282     * @see #GET_INSTRUMENTATION
4283     * @see #GET_PERMISSIONS
4284     * @see #GET_PROVIDERS
4285     * @see #GET_RECEIVERS
4286     * @see #GET_SERVICES
4287     * @see #GET_SIGNATURES
4288     */
4289    public abstract List<PackageInfo> getPreferredPackages(int flags);
4290
4291    /**
4292     * @deprecated This is a protected API that should not have been available
4293     * to third party applications.  It is the platform's responsibility for
4294     * assigning preferred activities and this cannot be directly modified.
4295     *
4296     * Add a new preferred activity mapping to the system.  This will be used
4297     * to automatically select the given activity component when
4298     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4299     * multiple matching activities and also matches the given filter.
4300     *
4301     * @param filter The set of intents under which this activity will be
4302     * made preferred.
4303     * @param match The IntentFilter match category that this preference
4304     * applies to.
4305     * @param set The set of activities that the user was picking from when
4306     * this preference was made.
4307     * @param activity The component name of the activity that is to be
4308     * preferred.
4309     */
4310    @Deprecated
4311    public abstract void addPreferredActivity(IntentFilter filter, int match,
4312            ComponentName[] set, ComponentName activity);
4313
4314    /**
4315     * Same as {@link #addPreferredActivity(IntentFilter, int,
4316            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
4317            to.
4318     * @hide
4319     */
4320    public void addPreferredActivity(IntentFilter filter, int match,
4321            ComponentName[] set, ComponentName activity, int userId) {
4322        throw new RuntimeException("Not implemented. Must override in a subclass.");
4323    }
4324
4325    /**
4326     * @deprecated This is a protected API that should not have been available
4327     * to third party applications.  It is the platform's responsibility for
4328     * assigning preferred activities and this cannot be directly modified.
4329     *
4330     * Replaces an existing preferred activity mapping to the system, and if that were not present
4331     * adds a new preferred activity.  This will be used
4332     * to automatically select the given activity component when
4333     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4334     * multiple matching activities and also matches the given filter.
4335     *
4336     * @param filter The set of intents under which this activity will be
4337     * made preferred.
4338     * @param match The IntentFilter match category that this preference
4339     * applies to.
4340     * @param set The set of activities that the user was picking from when
4341     * this preference was made.
4342     * @param activity The component name of the activity that is to be
4343     * preferred.
4344     * @hide
4345     */
4346    @Deprecated
4347    public abstract void replacePreferredActivity(IntentFilter filter, int match,
4348            ComponentName[] set, ComponentName activity);
4349
4350    /**
4351     * @hide
4352     */
4353    @Deprecated
4354    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
4355           ComponentName[] set, ComponentName activity, int userId) {
4356        throw new RuntimeException("Not implemented. Must override in a subclass.");
4357    }
4358
4359    /**
4360     * Remove all preferred activity mappings, previously added with
4361     * {@link #addPreferredActivity}, from the
4362     * system whose activities are implemented in the given package name.
4363     * An application can only clear its own package(s).
4364     *
4365     * @param packageName The name of the package whose preferred activity
4366     * mappings are to be removed.
4367     */
4368    public abstract void clearPackagePreferredActivities(String packageName);
4369
4370    /**
4371     * Retrieve all preferred activities, previously added with
4372     * {@link #addPreferredActivity}, that are
4373     * currently registered with the system.
4374     *
4375     * @param outFilters A required list in which to place the filters of all of the
4376     * preferred activities.
4377     * @param outActivities A required list in which to place the component names of
4378     * all of the preferred activities.
4379     * @param packageName An optional package in which you would like to limit
4380     * the list.  If null, all activities will be returned; if non-null, only
4381     * those activities in the given package are returned.
4382     *
4383     * @return Returns the total number of registered preferred activities
4384     * (the number of distinct IntentFilter records, not the number of unique
4385     * activity components) that were found.
4386     */
4387    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
4388            @NonNull List<ComponentName> outActivities, String packageName);
4389
4390    /**
4391     * Ask for the set of available 'home' activities and the current explicit
4392     * default, if any.
4393     * @hide
4394     */
4395    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
4396
4397    /**
4398     * Set the enabled setting for a package component (activity, receiver, service, provider).
4399     * This setting will override any enabled state which may have been set by the component in its
4400     * manifest.
4401     *
4402     * @param componentName The component to enable
4403     * @param newState The new enabled state for the component.  The legal values for this state
4404     *                 are:
4405     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4406     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4407     *                   and
4408     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4409     *                 The last one removes the setting, thereby restoring the component's state to
4410     *                 whatever was set in it's manifest (or enabled, by default).
4411     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4412     */
4413    public abstract void setComponentEnabledSetting(ComponentName componentName,
4414            int newState, int flags);
4415
4416
4417    /**
4418     * Return the enabled setting for a package component (activity,
4419     * receiver, service, provider).  This returns the last value set by
4420     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
4421     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4422     * the value originally specified in the manifest has not been modified.
4423     *
4424     * @param componentName The component to retrieve.
4425     * @return Returns the current enabled state for the component.  May
4426     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4427     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4428     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4429     * component's enabled state is based on the original information in
4430     * the manifest as found in {@link ComponentInfo}.
4431     */
4432    public abstract int getComponentEnabledSetting(ComponentName componentName);
4433
4434    /**
4435     * Set the enabled setting for an application
4436     * This setting will override any enabled state which may have been set by the application in
4437     * its manifest.  It also overrides the enabled state set in the manifest for any of the
4438     * application's components.  It does not override any enabled state set by
4439     * {@link #setComponentEnabledSetting} for any of the application's components.
4440     *
4441     * @param packageName The package name of the application to enable
4442     * @param newState The new enabled state for the component.  The legal values for this state
4443     *                 are:
4444     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4445     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4446     *                   and
4447     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4448     *                 The last one removes the setting, thereby restoring the applications's state to
4449     *                 whatever was set in its manifest (or enabled, by default).
4450     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4451     */
4452    public abstract void setApplicationEnabledSetting(String packageName,
4453            int newState, int flags);
4454
4455    /**
4456     * Return the enabled setting for an application. This returns
4457     * the last value set by
4458     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
4459     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4460     * the value originally specified in the manifest has not been modified.
4461     *
4462     * @param packageName The package name of the application to retrieve.
4463     * @return Returns the current enabled state for the application.  May
4464     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4465     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4466     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4467     * application's enabled state is based on the original information in
4468     * the manifest as found in {@link ComponentInfo}.
4469     * @throws IllegalArgumentException if the named package does not exist.
4470     */
4471    public abstract int getApplicationEnabledSetting(String packageName);
4472
4473    /**
4474     * Puts the package in a hidden state, which is almost like an uninstalled state,
4475     * making the package unavailable, but it doesn't remove the data or the actual
4476     * package file. Application can be unhidden by either resetting the hidden state
4477     * or by installing it, such as with {@link #installExistingPackage(String)}
4478     * @hide
4479     */
4480    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
4481            UserHandle userHandle);
4482
4483    /**
4484     * Returns the hidden state of a package.
4485     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
4486     * @hide
4487     */
4488    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
4489            UserHandle userHandle);
4490
4491    /**
4492     * Return whether the device has been booted into safe mode.
4493     */
4494    public abstract boolean isSafeMode();
4495
4496    /**
4497     * Adds a listener for permission changes for installed packages.
4498     *
4499     * @param listener The listener to add.
4500     *
4501     * @hide
4502     */
4503    @SystemApi
4504    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
4505    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
4506
4507    /**
4508     * Remvoes a listener for permission changes for installed packages.
4509     *
4510     * @param listener The listener to remove.
4511     *
4512     * @hide
4513     */
4514    @SystemApi
4515    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
4516
4517    /**
4518     * Return the {@link KeySet} associated with the String alias for this
4519     * application.
4520     *
4521     * @param alias The alias for a given {@link KeySet} as defined in the
4522     *        application's AndroidManifest.xml.
4523     * @hide
4524     */
4525    public abstract KeySet getKeySetByAlias(String packageName, String alias);
4526
4527    /** Return the signing {@link KeySet} for this application.
4528     * @hide
4529     */
4530    public abstract KeySet getSigningKeySet(String packageName);
4531
4532    /**
4533     * Return whether the package denoted by packageName has been signed by all
4534     * of the keys specified by the {@link KeySet} ks.  This will return true if
4535     * the package has been signed by additional keys (a superset) as well.
4536     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
4537     * @hide
4538     */
4539    public abstract boolean isSignedBy(String packageName, KeySet ks);
4540
4541    /**
4542     * Return whether the package denoted by packageName has been signed by all
4543     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
4544     * {@link #isSignedBy(String packageName, KeySet ks)}.
4545     * @hide
4546     */
4547    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
4548
4549    /**
4550     * Attempts to move package resources from internal to external media or vice versa.
4551     * Since this may take a little while, the result will
4552     * be posted back to the given observer.   This call may fail if the calling context
4553     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
4554     * named package cannot be found, or if the named package is a "system package".
4555     *
4556     * @param packageName The name of the package to delete
4557     * @param observer An observer callback to get notified when the package move is
4558     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
4559     * called when that happens.  observer may be null to indicate that no callback is desired.
4560     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
4561     * {@link #MOVE_EXTERNAL_MEDIA}
4562     *
4563     * @hide
4564     */
4565    @Deprecated
4566    public void movePackage(String packageName, IPackageMoveObserver observer, int flags) {
4567        throw new UnsupportedOperationException();
4568    }
4569
4570    /** {@hide} */
4571    public static boolean isMoveStatusFinished(int status) {
4572        return (status < 0 || status > 100);
4573    }
4574
4575    /** {@hide} */
4576    public static abstract class MoveCallback {
4577        public void onCreated(int moveId, Bundle extras) {}
4578        public abstract void onStatusChanged(int moveId, int status, long estMillis);
4579    }
4580
4581    /** {@hide} */
4582    public abstract int getMoveStatus(int moveId);
4583
4584    /** {@hide} */
4585    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
4586    /** {@hide} */
4587    public abstract void unregisterMoveCallback(MoveCallback callback);
4588
4589    /** {@hide} */
4590    public abstract int movePackage(String packageName, VolumeInfo vol);
4591    /** {@hide} */
4592    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
4593    /** {@hide} */
4594    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
4595
4596    /** {@hide} */
4597    public abstract int movePrimaryStorage(VolumeInfo vol);
4598    /** {@hide} */
4599    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
4600    /** {@hide} */
4601    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
4602
4603    /**
4604     * Returns the device identity that verifiers can use to associate their scheme to a particular
4605     * device. This should not be used by anything other than a package verifier.
4606     *
4607     * @return identity that uniquely identifies current device
4608     * @hide
4609     */
4610    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
4611
4612    /**
4613     * Returns true if the device is upgrading, such as first boot after OTA.
4614     *
4615     * @hide
4616     */
4617    public abstract boolean isUpgrade();
4618
4619    /**
4620     * Return interface that offers the ability to install, upgrade, and remove
4621     * applications on the device.
4622     */
4623    public abstract @NonNull PackageInstaller getPackageInstaller();
4624
4625    /**
4626     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
4627     * user with id sourceUserId can also be be resolved by activities in the user with id
4628     * targetUserId if they match the specified intent filter.
4629     * @param filter The {@link IntentFilter} the intent has to match
4630     * @param sourceUserId The source user id.
4631     * @param targetUserId The target user id.
4632     * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
4633     * @hide
4634     */
4635    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
4636            int targetUserId, int flags);
4637
4638    /**
4639     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
4640     * source, and have been set by the app calling this method.
4641     * @param sourceUserId The source user id.
4642     * @hide
4643     */
4644    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
4645
4646    /**
4647     * @hide
4648     */
4649    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4650
4651    /**
4652     * @hide
4653     */
4654    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4655
4656    /** {@hide} */
4657    public abstract boolean isPackageAvailable(String packageName);
4658
4659    /** {@hide} */
4660    public static String installStatusToString(int status, String msg) {
4661        final String str = installStatusToString(status);
4662        if (msg != null) {
4663            return str + ": " + msg;
4664        } else {
4665            return str;
4666        }
4667    }
4668
4669    /** {@hide} */
4670    public static String installStatusToString(int status) {
4671        switch (status) {
4672            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
4673            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
4674            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
4675            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
4676            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
4677            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
4678            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
4679            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
4680            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
4681            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
4682            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
4683            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
4684            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
4685            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
4686            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
4687            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
4688            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
4689            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
4690            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
4691            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
4692            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
4693            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
4694            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
4695            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
4696            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
4697            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
4698            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
4699            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
4700            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
4701            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
4702            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
4703            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
4704            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
4705            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
4706            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
4707            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
4708            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
4709            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
4710            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
4711            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
4712            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
4713            default: return Integer.toString(status);
4714        }
4715    }
4716
4717    /** {@hide} */
4718    public static int installStatusToPublicStatus(int status) {
4719        switch (status) {
4720            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4721            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4722            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4723            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
4724            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4725            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4726            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4727            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4728            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4729            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4730            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4731            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
4732            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4733            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4734            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4735            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
4736            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4737            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4738            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
4739            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
4740            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4741            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
4742            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
4743            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4744            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4745            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4746            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4747            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4748            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
4749            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
4750            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4751            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4752            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
4753            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
4754            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
4755            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
4756            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
4757            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4758            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4759            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4760            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4761            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4762            default: return PackageInstaller.STATUS_FAILURE;
4763        }
4764    }
4765
4766    /** {@hide} */
4767    public static String deleteStatusToString(int status, String msg) {
4768        final String str = deleteStatusToString(status);
4769        if (msg != null) {
4770            return str + ": " + msg;
4771        } else {
4772            return str;
4773        }
4774    }
4775
4776    /** {@hide} */
4777    public static String deleteStatusToString(int status) {
4778        switch (status) {
4779            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
4780            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
4781            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
4782            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
4783            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
4784            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
4785            default: return Integer.toString(status);
4786        }
4787    }
4788
4789    /** {@hide} */
4790    public static int deleteStatusToPublicStatus(int status) {
4791        switch (status) {
4792            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4793            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4794            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4795            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4796            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4797            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4798            default: return PackageInstaller.STATUS_FAILURE;
4799        }
4800    }
4801
4802    /** {@hide} */
4803    public static String permissionFlagToString(int flag) {
4804        switch (flag) {
4805            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
4806            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
4807            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
4808            case FLAG_PERMISSION_USER_SET: return "USER_SET";
4809            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
4810            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
4811            default: return Integer.toString(flag);
4812        }
4813    }
4814
4815    /** {@hide} */
4816    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
4817        private final IPackageInstallObserver mLegacy;
4818
4819        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
4820            mLegacy = legacy;
4821        }
4822
4823        @Override
4824        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
4825                Bundle extras) {
4826            if (mLegacy == null) return;
4827            try {
4828                mLegacy.packageInstalled(basePackageName, returnCode);
4829            } catch (RemoteException ignored) {
4830            }
4831        }
4832    }
4833
4834    /** {@hide} */
4835    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
4836        private final IPackageDeleteObserver mLegacy;
4837
4838        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
4839            mLegacy = legacy;
4840        }
4841
4842        @Override
4843        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
4844            if (mLegacy == null) return;
4845            try {
4846                mLegacy.packageDeleted(basePackageName, returnCode);
4847            } catch (RemoteException ignored) {
4848            }
4849        }
4850    }
4851}
4852