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