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