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