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