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