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