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