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