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