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