PackageManager.java revision 1d653272a2847c0cda10482f70e991e7afdaee4b
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
1082     * {@link #hasSystemFeature}: The device is capable of communicating with
1083     * consumer IR devices.
1084     */
1085    @SdkConstant(SdkConstantType.FEATURE)
1086    public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1087
1088    /**
1089     * Feature for {@link #getSystemAvailableFeatures} and
1090     * {@link #hasSystemFeature}: The device supports one or more methods of
1091     * reporting current location.
1092     */
1093    @SdkConstant(SdkConstantType.FEATURE)
1094    public static final String FEATURE_LOCATION = "android.hardware.location";
1095
1096    /**
1097     * Feature for {@link #getSystemAvailableFeatures} and
1098     * {@link #hasSystemFeature}: The device has a Global Positioning System
1099     * receiver and can report precise location.
1100     */
1101    @SdkConstant(SdkConstantType.FEATURE)
1102    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1103
1104    /**
1105     * Feature for {@link #getSystemAvailableFeatures} and
1106     * {@link #hasSystemFeature}: The device can report location with coarse
1107     * accuracy using a network-based geolocation system.
1108     */
1109    @SdkConstant(SdkConstantType.FEATURE)
1110    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1111
1112    /**
1113     * Feature for {@link #getSystemAvailableFeatures} and
1114     * {@link #hasSystemFeature}: The device can record audio via a
1115     * microphone.
1116     */
1117    @SdkConstant(SdkConstantType.FEATURE)
1118    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1119
1120    /**
1121     * Feature for {@link #getSystemAvailableFeatures} and
1122     * {@link #hasSystemFeature}: The device can communicate using Near-Field
1123     * Communications (NFC).
1124     */
1125    @SdkConstant(SdkConstantType.FEATURE)
1126    public static final String FEATURE_NFC = "android.hardware.nfc";
1127
1128    /**
1129     * Feature for {@link #getSystemAvailableFeatures} and
1130     * {@link #hasSystemFeature}: The device supports host-
1131     * based NFC card emulation.
1132     *
1133     * TODO remove when depending apps have moved to new constant.
1134     * @hide
1135     * @deprecated
1136     */
1137    @Deprecated
1138    @SdkConstant(SdkConstantType.FEATURE)
1139    public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1140
1141    /**
1142     * Feature for {@link #getSystemAvailableFeatures} and
1143     * {@link #hasSystemFeature}: The device supports host-
1144     * based NFC card emulation.
1145     */
1146    @SdkConstant(SdkConstantType.FEATURE)
1147    public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1148
1149    /**
1150     * Feature for {@link #getSystemAvailableFeatures} and
1151     * {@link #hasSystemFeature}: The device supports the OpenGL ES
1152     * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1153     * Android Extension Pack</a>.
1154     */
1155    @SdkConstant(SdkConstantType.FEATURE)
1156    public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1157
1158    /**
1159     * Feature for {@link #getSystemAvailableFeatures} and
1160     * {@link #hasSystemFeature}: The device includes an accelerometer.
1161     */
1162    @SdkConstant(SdkConstantType.FEATURE)
1163    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1164
1165    /**
1166     * Feature for {@link #getSystemAvailableFeatures} and
1167     * {@link #hasSystemFeature}: The device includes a barometer (air
1168     * pressure sensor.)
1169     */
1170    @SdkConstant(SdkConstantType.FEATURE)
1171    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1172
1173    /**
1174     * Feature for {@link #getSystemAvailableFeatures} and
1175     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1176     */
1177    @SdkConstant(SdkConstantType.FEATURE)
1178    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1179
1180    /**
1181     * Feature for {@link #getSystemAvailableFeatures} and
1182     * {@link #hasSystemFeature}: The device includes a gyroscope.
1183     */
1184    @SdkConstant(SdkConstantType.FEATURE)
1185    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1186
1187    /**
1188     * Feature for {@link #getSystemAvailableFeatures} and
1189     * {@link #hasSystemFeature}: The device includes a light sensor.
1190     */
1191    @SdkConstant(SdkConstantType.FEATURE)
1192    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1193
1194    /**
1195     * Feature for {@link #getSystemAvailableFeatures} and
1196     * {@link #hasSystemFeature}: The device includes a proximity sensor.
1197     */
1198    @SdkConstant(SdkConstantType.FEATURE)
1199    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1200
1201    /**
1202     * Feature for {@link #getSystemAvailableFeatures} and
1203     * {@link #hasSystemFeature}: The device includes a hardware step counter.
1204     */
1205    @SdkConstant(SdkConstantType.FEATURE)
1206    public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1207
1208    /**
1209     * Feature for {@link #getSystemAvailableFeatures} and
1210     * {@link #hasSystemFeature}: The device includes a hardware step detector.
1211     */
1212    @SdkConstant(SdkConstantType.FEATURE)
1213    public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1214
1215    /**
1216     * Feature for {@link #getSystemAvailableFeatures} and
1217     * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1218     */
1219    @SdkConstant(SdkConstantType.FEATURE)
1220    public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1221
1222    /**
1223     * Feature for {@link #getSystemAvailableFeatures} and
1224     * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram.
1225     */
1226    @SdkConstant(SdkConstantType.FEATURE)
1227    public static final String FEATURE_SENSOR_HEART_RATE_ECG =
1228            "android.hardware.sensor.heartrate.ecg";
1229
1230    /**
1231     * Feature for {@link #getSystemAvailableFeatures} and
1232     * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
1233     */
1234    @SdkConstant(SdkConstantType.FEATURE)
1235    public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
1236            "android.hardware.sensor.relative_humidity";
1237
1238    /**
1239     * Feature for {@link #getSystemAvailableFeatures} and
1240     * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
1241     */
1242    @SdkConstant(SdkConstantType.FEATURE)
1243    public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
1244            "android.hardware.sensor.ambient_temperature";
1245
1246    /**
1247     * Feature for {@link #getSystemAvailableFeatures} and
1248     * {@link #hasSystemFeature}: The device has a telephony radio with data
1249     * communication support.
1250     */
1251    @SdkConstant(SdkConstantType.FEATURE)
1252    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1253
1254    /**
1255     * Feature for {@link #getSystemAvailableFeatures} and
1256     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1257     */
1258    @SdkConstant(SdkConstantType.FEATURE)
1259    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1260
1261    /**
1262     * Feature for {@link #getSystemAvailableFeatures} and
1263     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1264     */
1265    @SdkConstant(SdkConstantType.FEATURE)
1266    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1267
1268    /**
1269     * Feature for {@link #getSystemAvailableFeatures} and
1270     * {@link #hasSystemFeature}: The device supports connecting to USB devices
1271     * as the USB host.
1272     */
1273    @SdkConstant(SdkConstantType.FEATURE)
1274    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1275
1276    /**
1277     * Feature for {@link #getSystemAvailableFeatures} and
1278     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1279     */
1280    @SdkConstant(SdkConstantType.FEATURE)
1281    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1282
1283    /**
1284     * Feature for {@link #getSystemAvailableFeatures} and
1285     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1286     */
1287    @SdkConstant(SdkConstantType.FEATURE)
1288    public static final String FEATURE_SIP = "android.software.sip";
1289
1290    /**
1291     * Feature for {@link #getSystemAvailableFeatures} and
1292     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1293     */
1294    @SdkConstant(SdkConstantType.FEATURE)
1295    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1296
1297    /**
1298     * Feature for {@link #getSystemAvailableFeatures} and
1299     * {@link #hasSystemFeature}: The device's display has a touch screen.
1300     */
1301    @SdkConstant(SdkConstantType.FEATURE)
1302    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1303
1304
1305    /**
1306     * Feature for {@link #getSystemAvailableFeatures} and
1307     * {@link #hasSystemFeature}: The device's touch screen supports
1308     * multitouch sufficient for basic two-finger gesture detection.
1309     */
1310    @SdkConstant(SdkConstantType.FEATURE)
1311    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1312
1313    /**
1314     * Feature for {@link #getSystemAvailableFeatures} and
1315     * {@link #hasSystemFeature}: The device's touch screen is capable of
1316     * tracking two or more fingers fully independently.
1317     */
1318    @SdkConstant(SdkConstantType.FEATURE)
1319    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1320
1321    /**
1322     * Feature for {@link #getSystemAvailableFeatures} and
1323     * {@link #hasSystemFeature}: The device's touch screen is capable of
1324     * tracking a full hand of fingers fully independently -- that is, 5 or
1325     * more simultaneous independent pointers.
1326     */
1327    @SdkConstant(SdkConstantType.FEATURE)
1328    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1329
1330    /**
1331     * Feature for {@link #getSystemAvailableFeatures} and
1332     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1333     * does support touch emulation for basic events. For instance, the
1334     * device might use a mouse or remote control to drive a cursor, and
1335     * emulate basic touch pointer events like down, up, drag, etc. All
1336     * devices that support android.hardware.touchscreen or a sub-feature are
1337     * presumed to also support faketouch.
1338     */
1339    @SdkConstant(SdkConstantType.FEATURE)
1340    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1341
1342    /**
1343     * Feature for {@link #getSystemAvailableFeatures} and
1344     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1345     * does support touch emulation for basic events that supports distinct
1346     * tracking of two or more fingers.  This is an extension of
1347     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1348     * that unlike a distinct multitouch screen as defined by
1349     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1350     * devices will not actually provide full two-finger gestures since the
1351     * input is being transformed to cursor movement on the screen.  That is,
1352     * single finger gestures will move a cursor; two-finger swipes will
1353     * result in single-finger touch events; other two-finger gestures will
1354     * result in the corresponding two-finger touch event.
1355     */
1356    @SdkConstant(SdkConstantType.FEATURE)
1357    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1358
1359    /**
1360     * Feature for {@link #getSystemAvailableFeatures} and
1361     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1362     * does support touch emulation for basic events that supports tracking
1363     * a hand of fingers (5 or more fingers) fully independently.
1364     * This is an extension of
1365     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1366     * that unlike a multitouch screen as defined by
1367     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1368     * gestures can be detected due to the limitations described for
1369     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1370     */
1371    @SdkConstant(SdkConstantType.FEATURE)
1372    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1373
1374    /**
1375     * Feature for {@link #getSystemAvailableFeatures} and
1376     * {@link #hasSystemFeature}: The device supports portrait orientation
1377     * screens.  For backwards compatibility, you can assume that if neither
1378     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1379     * both portrait and landscape.
1380     */
1381    @SdkConstant(SdkConstantType.FEATURE)
1382    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1383
1384    /**
1385     * Feature for {@link #getSystemAvailableFeatures} and
1386     * {@link #hasSystemFeature}: The device supports landscape orientation
1387     * screens.  For backwards compatibility, you can assume that if neither
1388     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1389     * both portrait and landscape.
1390     */
1391    @SdkConstant(SdkConstantType.FEATURE)
1392    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1393
1394    /**
1395     * Feature for {@link #getSystemAvailableFeatures} and
1396     * {@link #hasSystemFeature}: The device supports live wallpapers.
1397     */
1398    @SdkConstant(SdkConstantType.FEATURE)
1399    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1400    /**
1401     * Feature for {@link #getSystemAvailableFeatures} and
1402     * {@link #hasSystemFeature}: The device supports app widgets.
1403     */
1404    @SdkConstant(SdkConstantType.FEATURE)
1405    public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1406
1407    /**
1408     * @hide
1409     * Feature for {@link #getSystemAvailableFeatures} and
1410     * {@link #hasSystemFeature}: The device supports
1411     * {@link android.service.voice.VoiceInteractionService} and
1412     * {@link android.app.VoiceInteractor}.
1413     */
1414    @SdkConstant(SdkConstantType.FEATURE)
1415    public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1416
1417
1418    /**
1419     * Feature for {@link #getSystemAvailableFeatures} and
1420     * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1421     * by third party applications.
1422     */
1423    @SdkConstant(SdkConstantType.FEATURE)
1424    public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1425
1426    /**
1427     * Feature for {@link #getSystemAvailableFeatures} and
1428     * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1429     * with the {@link android.inputmethodservice.InputMethodService} API.
1430     */
1431    @SdkConstant(SdkConstantType.FEATURE)
1432    public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1433
1434    /**
1435     * Feature for {@link #getSystemAvailableFeatures} and
1436     * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1437     */
1438    @SdkConstant(SdkConstantType.FEATURE)
1439    public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1440
1441    /**
1442     * Feature for {@link #getSystemAvailableFeatures} and
1443     * {@link #hasSystemFeature}: The device supports leanback UI. This is
1444     * typically used in a living room television experience, but is a software
1445     * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
1446     * feature will use resources associated with the "television" UI mode.
1447     */
1448    @SdkConstant(SdkConstantType.FEATURE)
1449    public static final String FEATURE_LEANBACK = "android.software.leanback";
1450
1451    /**
1452     * Feature for {@link #getSystemAvailableFeatures} and
1453     * {@link #hasSystemFeature}: The device supports only leanback UI. Only
1454     * applications designed for this experience should be run, though this is
1455     * not enforced by the system.
1456     * @hide
1457     */
1458    @SdkConstant(SdkConstantType.FEATURE)
1459    public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
1460
1461    /**
1462     * Feature for {@link #getSystemAvailableFeatures} and
1463     * {@link #hasSystemFeature}: The device supports live TV and can display
1464     * contents from TV inputs implemented with the
1465     * {@link android.media.tv.TvInputService} API.
1466     */
1467    @SdkConstant(SdkConstantType.FEATURE)
1468    public static final String FEATURE_LIVE_TV = "android.software.live_tv";
1469
1470    /**
1471     * Feature for {@link #getSystemAvailableFeatures} and
1472     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1473     */
1474    @SdkConstant(SdkConstantType.FEATURE)
1475    public static final String FEATURE_WIFI = "android.hardware.wifi";
1476
1477    /**
1478     * Feature for {@link #getSystemAvailableFeatures} and
1479     * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1480     */
1481    @SdkConstant(SdkConstantType.FEATURE)
1482    public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1483
1484    /**
1485     * Feature for {@link #getSystemAvailableFeatures} and
1486     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1487     * on a television.  Television here is defined to be a typical living
1488     * room television experience: displayed on a big screen, where the user
1489     * is sitting far away from it, and the dominant form of input will be
1490     * something like a DPAD, not through touch or mouse.
1491     * @deprecated use {@link #FEATURE_LEANBACK} instead.
1492     */
1493    @Deprecated
1494    @SdkConstant(SdkConstantType.FEATURE)
1495    public static final String FEATURE_TELEVISION = "android.hardware.type.television";
1496
1497    /**
1498     * Feature for {@link #getSystemAvailableFeatures} and
1499     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1500     * on a watch. A watch here is defined to be a device worn on the body, perhaps on
1501     * the wrist. The user is very close when interacting with the device.
1502     */
1503    @SdkConstant(SdkConstantType.FEATURE)
1504    public static final String FEATURE_WATCH = "android.hardware.type.watch";
1505
1506    /**
1507     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1508     * The device supports printing.
1509     */
1510    @SdkConstant(SdkConstantType.FEATURE)
1511    public static final String FEATURE_PRINTING = "android.software.print";
1512
1513    /**
1514     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1515     * The device can perform backup and restore operations on installed applications.
1516     */
1517    @SdkConstant(SdkConstantType.FEATURE)
1518    public static final String FEATURE_BACKUP = "android.software.backup";
1519
1520    /**
1521     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1522     * The device supports creating secondary users and managed profiles via
1523     * {@link DevicePolicyManager}.
1524     */
1525    @SdkConstant(SdkConstantType.FEATURE)
1526    public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
1527
1528    /**
1529     * @hide
1530     * TODO: Remove after dependencies updated b/17392243
1531     */
1532    public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
1533
1534    /**
1535     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1536     * The device supports verified boot.
1537     */
1538    @SdkConstant(SdkConstantType.FEATURE)
1539    public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
1540
1541    /**
1542     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1543     * The device supports secure removal of users. When a user is deleted the data associated
1544     * with that user is securely deleted and no longer available.
1545     */
1546    @SdkConstant(SdkConstantType.FEATURE)
1547    public static final String FEATURE_SECURELY_REMOVES_USERS
1548            = "android.software.securely_removes_users";
1549
1550    /**
1551     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1552     * The device has a full implementation of the android.webkit.* APIs. Devices
1553     * lacking this feature will not have a functioning WebView implementation.
1554     */
1555    @SdkConstant(SdkConstantType.FEATURE)
1556    public static final String FEATURE_WEBVIEW = "android.software.webview";
1557
1558    /**
1559     * Feature for {@link #getSystemAvailableFeatures} and
1560     * {@link #hasSystemFeature}: This device supports ethernet.
1561     * @hide
1562     */
1563    @SdkConstant(SdkConstantType.FEATURE)
1564    public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
1565
1566    /**
1567     * Feature for {@link #getSystemAvailableFeatures} and
1568     * {@link #hasSystemFeature}: This device supports HDMI-CEC.
1569     * @hide
1570     */
1571    @SdkConstant(SdkConstantType.FEATURE)
1572    public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
1573
1574    /**
1575     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1576     * The device has all of the inputs necessary to be considered a compatible game controller, or
1577     * includes a compatible game controller in the box.
1578     */
1579    @SdkConstant(SdkConstantType.FEATURE)
1580    public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
1581
1582
1583    /**
1584     * Action to external storage service to clean out removed apps.
1585     * @hide
1586     */
1587    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1588            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1589
1590    /**
1591     * Extra field name for the URI to a verification file. Passed to a package
1592     * verifier.
1593     *
1594     * @hide
1595     */
1596    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1597
1598    /**
1599     * Extra field name for the ID of a package pending verification. Passed to
1600     * a package verifier and is used to call back to
1601     * {@link PackageManager#verifyPendingInstall(int, int)}
1602     */
1603    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1604
1605    /**
1606     * Extra field name for the package identifier which is trying to install
1607     * the package.
1608     *
1609     * @hide
1610     */
1611    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1612            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1613
1614    /**
1615     * Extra field name for the requested install flags for a package pending
1616     * verification. Passed to a package verifier.
1617     *
1618     * @hide
1619     */
1620    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1621            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1622
1623    /**
1624     * Extra field name for the uid of who is requesting to install
1625     * the package.
1626     *
1627     * @hide
1628     */
1629    public static final String EXTRA_VERIFICATION_INSTALLER_UID
1630            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1631
1632    /**
1633     * Extra field name for the package name of a package pending verification.
1634     *
1635     * @hide
1636     */
1637    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1638            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1639    /**
1640     * Extra field name for the result of a verification, either
1641     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1642     * Passed to package verifiers after a package is verified.
1643     */
1644    public static final String EXTRA_VERIFICATION_RESULT
1645            = "android.content.pm.extra.VERIFICATION_RESULT";
1646
1647    /**
1648     * Extra field name for the version code of a package pending verification.
1649     *
1650     * @hide
1651     */
1652    public static final String EXTRA_VERIFICATION_VERSION_CODE
1653            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1654
1655    /**
1656     * The action used to request that the user approve a permission request
1657     * from the application.
1658     *
1659     * @hide
1660     */
1661    public static final String ACTION_REQUEST_PERMISSION
1662            = "android.content.pm.action.REQUEST_PERMISSION";
1663
1664    /**
1665     * Extra field name for the list of permissions, which the user must approve.
1666     *
1667     * @hide
1668     */
1669    public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST
1670            = "android.content.pm.extra.PERMISSION_LIST";
1671
1672    /**
1673     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1674     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
1675     * the existing definition for the permission.
1676     * @hide
1677     */
1678    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1679            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1680
1681    /**
1682     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1683     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
1684     * being redundantly defined by the package being installed.
1685     * @hide
1686     */
1687    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1688            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1689
1690    /**
1691     * Retrieve overall information about an application package that is
1692     * installed on the system.
1693     * <p>
1694     * Throws {@link NameNotFoundException} if a package with the given name can
1695     * not be found on the system.
1696     *
1697     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1698     *            desired package.
1699     * @param flags Additional option flags. Use any combination of
1700     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1701     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1702     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1703     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1704     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1705     *            modify the data returned.
1706     * @return Returns a PackageInfo object containing information about the
1707     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1708     *         package is not found in the list of installed applications, the
1709     *         package information is retrieved from the list of uninstalled
1710     *         applications (which includes installed applications as well as
1711     *         applications with data directory i.e. applications which had been
1712     *         deleted with {@code DONT_DELETE_DATA} flag set).
1713     * @see #GET_ACTIVITIES
1714     * @see #GET_GIDS
1715     * @see #GET_CONFIGURATIONS
1716     * @see #GET_INSTRUMENTATION
1717     * @see #GET_PERMISSIONS
1718     * @see #GET_PROVIDERS
1719     * @see #GET_RECEIVERS
1720     * @see #GET_SERVICES
1721     * @see #GET_SIGNATURES
1722     * @see #GET_UNINSTALLED_PACKAGES
1723     */
1724    public abstract PackageInfo getPackageInfo(String packageName, int flags)
1725            throws NameNotFoundException;
1726
1727    /**
1728     * Map from the current package names in use on the device to whatever
1729     * the current canonical name of that package is.
1730     * @param names Array of current names to be mapped.
1731     * @return Returns an array of the same size as the original, containing
1732     * the canonical name for each package.
1733     */
1734    public abstract String[] currentToCanonicalPackageNames(String[] names);
1735
1736    /**
1737     * Map from a packages canonical name to the current name in use on the device.
1738     * @param names Array of new names to be mapped.
1739     * @return Returns an array of the same size as the original, containing
1740     * the current name for each package.
1741     */
1742    public abstract String[] canonicalToCurrentPackageNames(String[] names);
1743
1744    /**
1745     * Returns a "good" intent to launch a front-door activity in a package.
1746     * This is used, for example, to implement an "open" button when browsing
1747     * through packages.  The current implementation looks first for a main
1748     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
1749     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
1750     * <code>null</code> if neither are found.
1751     *
1752     * @param packageName The name of the package to inspect.
1753     *
1754     * @return A fully-qualified {@link Intent} that can be used to launch the
1755     * main activity in the package. Returns <code>null</code> if the package
1756     * does not contain such an activity, or if <em>packageName</em> is not
1757     * recognized.
1758     */
1759    public abstract Intent getLaunchIntentForPackage(String packageName);
1760
1761    /**
1762     * Return a "good" intent to launch a front-door Leanback activity in a
1763     * package, for use for example to implement an "open" button when browsing
1764     * through packages. The current implementation will look for a main
1765     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
1766     * return null if no main leanback activities are found.
1767     * <p>
1768     * Throws {@link NameNotFoundException} if a package with the given name
1769     * cannot be found on the system.
1770     *
1771     * @param packageName The name of the package to inspect.
1772     * @return Returns either a fully-qualified Intent that can be used to launch
1773     *         the main Leanback activity in the package, or null if the package
1774     *         does not contain such an activity.
1775     */
1776    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
1777
1778    /**
1779     * Return an array of all of the secondary group-ids that have been assigned
1780     * to a package.
1781     * <p>
1782     * Throws {@link NameNotFoundException} if a package with the given name
1783     * cannot be found on the system.
1784     *
1785     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1786     *            desired package.
1787     * @return Returns an int array of the assigned gids, or null if there are
1788     *         none.
1789     */
1790    public abstract int[] getPackageGids(String packageName)
1791            throws NameNotFoundException;
1792
1793    /**
1794     * @hide Return the uid associated with the given package name for the
1795     * given user.
1796     *
1797     * <p>Throws {@link NameNotFoundException} if a package with the given
1798     * name can not be found on the system.
1799     *
1800     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1801     *                    desired package.
1802     * @param userHandle The user handle identifier to look up the package under.
1803     *
1804     * @return Returns an integer uid who owns the given package name.
1805     */
1806    public abstract int getPackageUid(String packageName, int userHandle)
1807            throws NameNotFoundException;
1808
1809    /**
1810     * Retrieve all of the information we know about a particular permission.
1811     *
1812     * <p>Throws {@link NameNotFoundException} if a permission with the given
1813     * name cannot be found on the system.
1814     *
1815     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1816     *             of the permission you are interested in.
1817     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1818     * retrieve any meta-data associated with the permission.
1819     *
1820     * @return Returns a {@link PermissionInfo} containing information about the
1821     *         permission.
1822     */
1823    public abstract PermissionInfo getPermissionInfo(String name, int flags)
1824            throws NameNotFoundException;
1825
1826    /**
1827     * Query for all of the permissions associated with a particular group.
1828     *
1829     * <p>Throws {@link NameNotFoundException} if the given group does not
1830     * exist.
1831     *
1832     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1833     *             of the permission group you are interested in.  Use null to
1834     *             find all of the permissions not associated with a group.
1835     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1836     * retrieve any meta-data associated with the permissions.
1837     *
1838     * @return Returns a list of {@link PermissionInfo} containing information
1839     * about all of the permissions in the given group.
1840     */
1841    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1842            int flags) throws NameNotFoundException;
1843
1844    /**
1845     * Retrieve all of the information we know about a particular group of
1846     * permissions.
1847     *
1848     * <p>Throws {@link NameNotFoundException} if a permission group with the given
1849     * name cannot be found on the system.
1850     *
1851     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1852     *             of the permission you are interested in.
1853     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1854     * retrieve any meta-data associated with the permission group.
1855     *
1856     * @return Returns a {@link PermissionGroupInfo} containing information
1857     * about the permission.
1858     */
1859    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1860            int flags) throws NameNotFoundException;
1861
1862    /**
1863     * Retrieve all of the known permission groups in the system.
1864     *
1865     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1866     * retrieve any meta-data associated with the permission group.
1867     *
1868     * @return Returns a list of {@link PermissionGroupInfo} containing
1869     * information about all of the known permission groups.
1870     */
1871    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1872
1873    /**
1874     * Retrieve all of the information we know about a particular
1875     * package/application.
1876     *
1877     * <p>Throws {@link NameNotFoundException} if an application with the given
1878     * package name cannot be found on the system.
1879     *
1880     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1881     *                    application.
1882     * @param flags Additional option flags. Use any combination of
1883     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1884     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1885     *
1886     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1887     *         information about the package.
1888     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1889     *         found in the list of installed applications,
1890     *         the application information is retrieved from the
1891     *         list of uninstalled applications(which includes
1892     *         installed applications as well as applications
1893     *         with data directory ie applications which had been
1894     *         deleted with {@code DONT_DELETE_DATA} flag set).
1895     *
1896     * @see #GET_META_DATA
1897     * @see #GET_SHARED_LIBRARY_FILES
1898     * @see #GET_UNINSTALLED_PACKAGES
1899     */
1900    public abstract ApplicationInfo getApplicationInfo(String packageName,
1901            int flags) throws NameNotFoundException;
1902
1903    /**
1904     * Retrieve all of the information we know about a particular activity
1905     * class.
1906     *
1907     * <p>Throws {@link NameNotFoundException} if an activity with the given
1908     * class name cannot be found on the system.
1909     *
1910     * @param component The full component name (i.e.
1911     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1912     * class.
1913     * @param flags Additional option flags. Use any combination of
1914     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1915     * to modify the data (in ApplicationInfo) returned.
1916     *
1917     * @return {@link ActivityInfo} containing information about the activity.
1918     *
1919     * @see #GET_INTENT_FILTERS
1920     * @see #GET_META_DATA
1921     * @see #GET_SHARED_LIBRARY_FILES
1922     */
1923    public abstract ActivityInfo getActivityInfo(ComponentName component,
1924            int flags) throws NameNotFoundException;
1925
1926    /**
1927     * Retrieve all of the information we know about a particular receiver
1928     * class.
1929     *
1930     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1931     * class name cannot be found on the system.
1932     *
1933     * @param component The full component name (i.e.
1934     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1935     * class.
1936     * @param flags Additional option flags.  Use any combination of
1937     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1938     * to modify the data returned.
1939     *
1940     * @return {@link ActivityInfo} containing information about the receiver.
1941     *
1942     * @see #GET_INTENT_FILTERS
1943     * @see #GET_META_DATA
1944     * @see #GET_SHARED_LIBRARY_FILES
1945     */
1946    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1947            int flags) throws NameNotFoundException;
1948
1949    /**
1950     * Retrieve all of the information we know about a particular service
1951     * class.
1952     *
1953     * <p>Throws {@link NameNotFoundException} if a service with the given
1954     * class name cannot be found on the system.
1955     *
1956     * @param component The full component name (i.e.
1957     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1958     * class.
1959     * @param flags Additional option flags.  Use any combination of
1960     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1961     * to modify the data returned.
1962     *
1963     * @return ServiceInfo containing information about the service.
1964     *
1965     * @see #GET_META_DATA
1966     * @see #GET_SHARED_LIBRARY_FILES
1967     */
1968    public abstract ServiceInfo getServiceInfo(ComponentName component,
1969            int flags) throws NameNotFoundException;
1970
1971    /**
1972     * Retrieve all of the information we know about a particular content
1973     * provider class.
1974     *
1975     * <p>Throws {@link NameNotFoundException} if a provider with the given
1976     * class name cannot be found on the system.
1977     *
1978     * @param component The full component name (i.e.
1979     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1980     * ContentProvider class.
1981     * @param flags Additional option flags.  Use any combination of
1982     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1983     * to modify the data returned.
1984     *
1985     * @return ProviderInfo containing information about the service.
1986     *
1987     * @see #GET_META_DATA
1988     * @see #GET_SHARED_LIBRARY_FILES
1989     */
1990    public abstract ProviderInfo getProviderInfo(ComponentName component,
1991            int flags) throws NameNotFoundException;
1992
1993    /**
1994     * Return a List of all packages that are installed
1995     * on the device.
1996     *
1997     * @param flags Additional option flags. Use any combination of
1998     * {@link #GET_ACTIVITIES},
1999     * {@link #GET_GIDS},
2000     * {@link #GET_CONFIGURATIONS},
2001     * {@link #GET_INSTRUMENTATION},
2002     * {@link #GET_PERMISSIONS},
2003     * {@link #GET_PROVIDERS},
2004     * {@link #GET_RECEIVERS},
2005     * {@link #GET_SERVICES},
2006     * {@link #GET_SIGNATURES},
2007     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2008     *
2009     * @return A List of PackageInfo objects, one for each package that is
2010     *         installed on the device.  In the unlikely case of there being no
2011     *         installed packages, an empty list is returned.
2012     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2013     *         applications including those deleted with {@code DONT_DELETE_DATA}
2014     *         (partially installed apps with data directory) will be returned.
2015     *
2016     * @see #GET_ACTIVITIES
2017     * @see #GET_GIDS
2018     * @see #GET_CONFIGURATIONS
2019     * @see #GET_INSTRUMENTATION
2020     * @see #GET_PERMISSIONS
2021     * @see #GET_PROVIDERS
2022     * @see #GET_RECEIVERS
2023     * @see #GET_SERVICES
2024     * @see #GET_SIGNATURES
2025     * @see #GET_UNINSTALLED_PACKAGES
2026     */
2027    public abstract List<PackageInfo> getInstalledPackages(int flags);
2028
2029    /**
2030     * Return a List of all installed packages that are currently
2031     * holding any of the given permissions.
2032     *
2033     * @param flags Additional option flags. Use any combination of
2034     * {@link #GET_ACTIVITIES},
2035     * {@link #GET_GIDS},
2036     * {@link #GET_CONFIGURATIONS},
2037     * {@link #GET_INSTRUMENTATION},
2038     * {@link #GET_PERMISSIONS},
2039     * {@link #GET_PROVIDERS},
2040     * {@link #GET_RECEIVERS},
2041     * {@link #GET_SERVICES},
2042     * {@link #GET_SIGNATURES},
2043     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2044     *
2045     * @return Returns a List of PackageInfo objects, one for each installed
2046     * application that is holding any of the permissions that were provided.
2047     *
2048     * @see #GET_ACTIVITIES
2049     * @see #GET_GIDS
2050     * @see #GET_CONFIGURATIONS
2051     * @see #GET_INSTRUMENTATION
2052     * @see #GET_PERMISSIONS
2053     * @see #GET_PROVIDERS
2054     * @see #GET_RECEIVERS
2055     * @see #GET_SERVICES
2056     * @see #GET_SIGNATURES
2057     * @see #GET_UNINSTALLED_PACKAGES
2058     */
2059    public abstract List<PackageInfo> getPackagesHoldingPermissions(
2060            String[] permissions, int flags);
2061
2062    /**
2063     * Return a List of all packages that are installed on the device, for a specific user.
2064     * Requesting a list of installed packages for another user
2065     * will require the permission INTERACT_ACROSS_USERS_FULL.
2066     * @param flags Additional option flags. Use any combination of
2067     * {@link #GET_ACTIVITIES},
2068     * {@link #GET_GIDS},
2069     * {@link #GET_CONFIGURATIONS},
2070     * {@link #GET_INSTRUMENTATION},
2071     * {@link #GET_PERMISSIONS},
2072     * {@link #GET_PROVIDERS},
2073     * {@link #GET_RECEIVERS},
2074     * {@link #GET_SERVICES},
2075     * {@link #GET_SIGNATURES},
2076     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2077     * @param userId The user for whom the installed packages are to be listed
2078     *
2079     * @return A List of PackageInfo objects, one for each package that is
2080     *         installed on the device.  In the unlikely case of there being no
2081     *         installed packages, an empty list is returned.
2082     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2083     *         applications including those deleted with {@code DONT_DELETE_DATA}
2084     *         (partially installed apps with data directory) will be returned.
2085     *
2086     * @see #GET_ACTIVITIES
2087     * @see #GET_GIDS
2088     * @see #GET_CONFIGURATIONS
2089     * @see #GET_INSTRUMENTATION
2090     * @see #GET_PERMISSIONS
2091     * @see #GET_PROVIDERS
2092     * @see #GET_RECEIVERS
2093     * @see #GET_SERVICES
2094     * @see #GET_SIGNATURES
2095     * @see #GET_UNINSTALLED_PACKAGES
2096     *
2097     * @hide
2098     */
2099    public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2100
2101    /**
2102     * Check whether a particular package has been granted a particular
2103     * permission.
2104     *
2105     * @param permName The name of the permission you are checking for,
2106     * @param pkgName The name of the package you are checking against.
2107     *
2108     * @return If the package has the permission, PERMISSION_GRANTED is
2109     * returned.  If it does not have the permission, PERMISSION_DENIED
2110     * is returned.
2111     *
2112     * @see #PERMISSION_GRANTED
2113     * @see #PERMISSION_DENIED
2114     */
2115    public abstract int checkPermission(String permName, String pkgName);
2116
2117    /**
2118     * Add a new dynamic permission to the system.  For this to work, your
2119     * package must have defined a permission tree through the
2120     * {@link android.R.styleable#AndroidManifestPermissionTree
2121     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
2122     * permissions to trees that were defined by either its own package or
2123     * another with the same user id; a permission is in a tree if it
2124     * matches the name of the permission tree + ".": for example,
2125     * "com.foo.bar" is a member of the permission tree "com.foo".
2126     *
2127     * <p>It is good to make your permission tree name descriptive, because you
2128     * are taking possession of that entire set of permission names.  Thus, it
2129     * must be under a domain you control, with a suffix that will not match
2130     * any normal permissions that may be declared in any applications that
2131     * are part of that domain.
2132     *
2133     * <p>New permissions must be added before
2134     * any .apks are installed that use those permissions.  Permissions you
2135     * add through this method are remembered across reboots of the device.
2136     * If the given permission already exists, the info you supply here
2137     * will be used to update it.
2138     *
2139     * @param info Description of the permission to be added.
2140     *
2141     * @return Returns true if a new permission was created, false if an
2142     * existing one was updated.
2143     *
2144     * @throws SecurityException if you are not allowed to add the
2145     * given permission name.
2146     *
2147     * @see #removePermission(String)
2148     */
2149    public abstract boolean addPermission(PermissionInfo info);
2150
2151    /**
2152     * Like {@link #addPermission(PermissionInfo)} but asynchronously
2153     * persists the package manager state after returning from the call,
2154     * allowing it to return quicker and batch a series of adds at the
2155     * expense of no guarantee the added permission will be retained if
2156     * the device is rebooted before it is written.
2157     */
2158    public abstract boolean addPermissionAsync(PermissionInfo info);
2159
2160    /**
2161     * Removes a permission that was previously added with
2162     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
2163     * -- you are only allowed to remove permissions that you are allowed
2164     * to add.
2165     *
2166     * @param name The name of the permission to remove.
2167     *
2168     * @throws SecurityException if you are not allowed to remove the
2169     * given permission name.
2170     *
2171     * @see #addPermission(PermissionInfo)
2172     */
2173    public abstract void removePermission(String name);
2174
2175    /**
2176     * Returns an {@link Intent} suitable for passing to {@code startActivityForResult}
2177     * which prompts the user to grant {@code permissions} to this application.
2178     * @hide
2179     *
2180     * @throws NullPointerException if {@code permissions} is {@code null}.
2181     * @throws IllegalArgumentException if {@code permissions} contains {@code null}.
2182     */
2183    public Intent buildPermissionRequestIntent(String... permissions) {
2184        if (permissions == null) {
2185            throw new NullPointerException("permissions cannot be null");
2186        }
2187        for (String permission : permissions) {
2188            if (permission == null) {
2189                throw new IllegalArgumentException("permissions cannot contain null");
2190            }
2191        }
2192
2193        Intent i = new Intent(ACTION_REQUEST_PERMISSION);
2194        i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions);
2195        i.setPackage("com.android.packageinstaller");
2196        return i;
2197    }
2198
2199    /**
2200     * Grant a permission to an application which the application does not
2201     * already have.  The permission must have been requested by the application,
2202     * but as an optional permission.  If the application is not allowed to
2203     * hold the permission, a SecurityException is thrown.
2204     * @hide
2205     *
2206     * @param packageName The name of the package that the permission will be
2207     * granted to.
2208     * @param permissionName The name of the permission.
2209     */
2210    public abstract void grantPermission(String packageName, String permissionName);
2211
2212    /**
2213     * Revoke a permission that was previously granted by {@link #grantPermission}.
2214     * @hide
2215     *
2216     * @param packageName The name of the package that the permission will be
2217     * granted to.
2218     * @param permissionName The name of the permission.
2219     */
2220    public abstract void revokePermission(String packageName, String permissionName);
2221
2222    /**
2223     * Compare the signatures of two packages to determine if the same
2224     * signature appears in both of them.  If they do contain the same
2225     * signature, then they are allowed special privileges when working
2226     * with each other: they can share the same user-id, run instrumentation
2227     * against each other, etc.
2228     *
2229     * @param pkg1 First package name whose signature will be compared.
2230     * @param pkg2 Second package name whose signature will be compared.
2231     *
2232     * @return Returns an integer indicating whether all signatures on the
2233     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2234     * all signatures match or < 0 if there is not a match ({@link
2235     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2236     *
2237     * @see #checkSignatures(int, int)
2238     * @see #SIGNATURE_MATCH
2239     * @see #SIGNATURE_NO_MATCH
2240     * @see #SIGNATURE_UNKNOWN_PACKAGE
2241     */
2242    public abstract int checkSignatures(String pkg1, String pkg2);
2243
2244    /**
2245     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2246     * the two packages to be checked.  This can be useful, for example,
2247     * when doing the check in an IPC, where the UID is the only identity
2248     * available.  It is functionally identical to determining the package
2249     * associated with the UIDs and checking their signatures.
2250     *
2251     * @param uid1 First UID whose signature will be compared.
2252     * @param uid2 Second UID whose signature will be compared.
2253     *
2254     * @return Returns an integer indicating whether all signatures on the
2255     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2256     * all signatures match or < 0 if there is not a match ({@link
2257     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2258     *
2259     * @see #checkSignatures(String, String)
2260     * @see #SIGNATURE_MATCH
2261     * @see #SIGNATURE_NO_MATCH
2262     * @see #SIGNATURE_UNKNOWN_PACKAGE
2263     */
2264    public abstract int checkSignatures(int uid1, int uid2);
2265
2266    /**
2267     * Retrieve the names of all packages that are associated with a particular
2268     * user id.  In most cases, this will be a single package name, the package
2269     * that has been assigned that user id.  Where there are multiple packages
2270     * sharing the same user id through the "sharedUserId" mechanism, all
2271     * packages with that id will be returned.
2272     *
2273     * @param uid The user id for which you would like to retrieve the
2274     * associated packages.
2275     *
2276     * @return Returns an array of one or more packages assigned to the user
2277     * id, or null if there are no known packages with the given id.
2278     */
2279    public abstract String[] getPackagesForUid(int uid);
2280
2281    /**
2282     * Retrieve the official name associated with a user id.  This name is
2283     * guaranteed to never change, though it is possibly for the underlying
2284     * user id to be changed.  That is, if you are storing information about
2285     * user ids in persistent storage, you should use the string returned
2286     * by this function instead of the raw user-id.
2287     *
2288     * @param uid The user id for which you would like to retrieve a name.
2289     * @return Returns a unique name for the given user id, or null if the
2290     * user id is not currently assigned.
2291     */
2292    public abstract String getNameForUid(int uid);
2293
2294    /**
2295     * Return the user id associated with a shared user name. Multiple
2296     * applications can specify a shared user name in their manifest and thus
2297     * end up using a common uid. This might be used for new applications
2298     * that use an existing shared user name and need to know the uid of the
2299     * shared user.
2300     *
2301     * @param sharedUserName The shared user name whose uid is to be retrieved.
2302     * @return Returns the uid associated with the shared user, or  NameNotFoundException
2303     * if the shared user name is not being used by any installed packages
2304     * @hide
2305     */
2306    public abstract int getUidForSharedUser(String sharedUserName)
2307            throws NameNotFoundException;
2308
2309    /**
2310     * Return a List of all application packages that are installed on the
2311     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2312     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2313     * installed apps with data directory) will be returned.
2314     *
2315     * @param flags Additional option flags. Use any combination of
2316     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2317     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2318     *
2319     * @return Returns a List of ApplicationInfo objects, one for each application that
2320     *         is installed on the device.  In the unlikely case of there being
2321     *         no installed applications, an empty list is returned.
2322     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2323     *         applications including those deleted with {@code DONT_DELETE_DATA}
2324     *         (partially installed apps with data directory) will be returned.
2325     *
2326     * @see #GET_META_DATA
2327     * @see #GET_SHARED_LIBRARY_FILES
2328     * @see #GET_UNINSTALLED_PACKAGES
2329     */
2330    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2331
2332    /**
2333     * Get a list of shared libraries that are available on the
2334     * system.
2335     *
2336     * @return An array of shared library names that are
2337     * available on the system, or null if none are installed.
2338     *
2339     */
2340    public abstract String[] getSystemSharedLibraryNames();
2341
2342    /**
2343     * Get a list of features that are available on the
2344     * system.
2345     *
2346     * @return An array of FeatureInfo classes describing the features
2347     * that are available on the system, or null if there are none(!!).
2348     */
2349    public abstract FeatureInfo[] getSystemAvailableFeatures();
2350
2351    /**
2352     * Check whether the given feature name is one of the available
2353     * features as returned by {@link #getSystemAvailableFeatures()}.
2354     *
2355     * @return Returns true if the devices supports the feature, else
2356     * false.
2357     */
2358    public abstract boolean hasSystemFeature(String name);
2359
2360    /**
2361     * Determine the best action to perform for a given Intent.  This is how
2362     * {@link Intent#resolveActivity} finds an activity if a class has not
2363     * been explicitly specified.
2364     *
2365     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2366     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2367     * only flag.  You need to do so to resolve the activity in the same way
2368     * that {@link android.content.Context#startActivity(Intent)} and
2369     * {@link android.content.Intent#resolveActivity(PackageManager)
2370     * Intent.resolveActivity(PackageManager)} do.</p>
2371     *
2372     * @param intent An intent containing all of the desired specification
2373     *               (action, data, type, category, and/or component).
2374     * @param flags Additional option flags.  The most important is
2375     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2376     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2377     *
2378     * @return Returns a ResolveInfo containing the final activity intent that
2379     *         was determined to be the best action.  Returns null if no
2380     *         matching activity was found. If multiple matching activities are
2381     *         found and there is no default set, returns a ResolveInfo
2382     *         containing something else, such as the activity resolver.
2383     *
2384     * @see #MATCH_DEFAULT_ONLY
2385     * @see #GET_INTENT_FILTERS
2386     * @see #GET_RESOLVED_FILTER
2387     */
2388    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2389
2390    /**
2391     * Determine the best action to perform for a given Intent for a given user. This
2392     * is how {@link Intent#resolveActivity} finds an activity if a class has not
2393     * been explicitly specified.
2394     *
2395     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2396     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2397     * only flag.  You need to do so to resolve the activity in the same way
2398     * that {@link android.content.Context#startActivity(Intent)} and
2399     * {@link android.content.Intent#resolveActivity(PackageManager)
2400     * Intent.resolveActivity(PackageManager)} do.</p>
2401     *
2402     * @param intent An intent containing all of the desired specification
2403     *               (action, data, type, category, and/or component).
2404     * @param flags Additional option flags.  The most important is
2405     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2406     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2407     * @param userId The user id.
2408     *
2409     * @return Returns a ResolveInfo containing the final activity intent that
2410     *         was determined to be the best action.  Returns null if no
2411     *         matching activity was found. If multiple matching activities are
2412     *         found and there is no default set, returns a ResolveInfo
2413     *         containing something else, such as the activity resolver.
2414     *
2415     * @see #MATCH_DEFAULT_ONLY
2416     * @see #GET_INTENT_FILTERS
2417     * @see #GET_RESOLVED_FILTER
2418     *
2419     * @hide
2420     */
2421    public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2422
2423    /**
2424     * Retrieve all activities that can be performed for the given intent.
2425     *
2426     * @param intent The desired intent as per resolveActivity().
2427     * @param flags Additional option flags.  The most important is
2428     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2429     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2430     *
2431     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2432     *         Activity. These are ordered from best to worst match -- that
2433     *         is, the first item in the list is what is returned by
2434     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2435     *         list is returned.
2436     *
2437     * @see #MATCH_DEFAULT_ONLY
2438     * @see #GET_INTENT_FILTERS
2439     * @see #GET_RESOLVED_FILTER
2440     */
2441    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2442            int flags);
2443
2444    /**
2445     * Retrieve all activities that can be performed for the given intent, for a specific user.
2446     *
2447     * @param intent The desired intent as per resolveActivity().
2448     * @param flags Additional option flags.  The most important is
2449     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2450     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2451     *
2452     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2453     *         Activity. These are ordered from best to worst match -- that
2454     *         is, the first item in the list is what is returned by
2455     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2456     *         list is returned.
2457     *
2458     * @see #MATCH_DEFAULT_ONLY
2459     * @see #GET_INTENT_FILTERS
2460     * @see #GET_RESOLVED_FILTER
2461     * @hide
2462     */
2463    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2464            int flags, int userId);
2465
2466
2467    /**
2468     * Retrieve a set of activities that should be presented to the user as
2469     * similar options.  This is like {@link #queryIntentActivities}, except it
2470     * also allows you to supply a list of more explicit Intents that you would
2471     * like to resolve to particular options, and takes care of returning the
2472     * final ResolveInfo list in a reasonable order, with no duplicates, based
2473     * on those inputs.
2474     *
2475     * @param caller The class name of the activity that is making the
2476     *               request.  This activity will never appear in the output
2477     *               list.  Can be null.
2478     * @param specifics An array of Intents that should be resolved to the
2479     *                  first specific results.  Can be null.
2480     * @param intent The desired intent as per resolveActivity().
2481     * @param flags Additional option flags.  The most important is
2482     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2483     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2484     *
2485     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2486     *         Activity. These are ordered first by all of the intents resolved
2487     *         in <var>specifics</var> and then any additional activities that
2488     *         can handle <var>intent</var> but did not get included by one of
2489     *         the <var>specifics</var> intents.  If there are no matching
2490     *         activities, an empty list is returned.
2491     *
2492     * @see #MATCH_DEFAULT_ONLY
2493     * @see #GET_INTENT_FILTERS
2494     * @see #GET_RESOLVED_FILTER
2495     */
2496    public abstract List<ResolveInfo> queryIntentActivityOptions(
2497            ComponentName caller, Intent[] specifics, Intent intent, int flags);
2498
2499    /**
2500     * Retrieve all receivers that can handle a broadcast of the given intent.
2501     *
2502     * @param intent The desired intent as per resolveActivity().
2503     * @param flags Additional option flags.
2504     *
2505     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2506     *         Receiver. These are ordered from first to last in priority.  If
2507     *         there are no matching receivers, an empty list is returned.
2508     *
2509     * @see #MATCH_DEFAULT_ONLY
2510     * @see #GET_INTENT_FILTERS
2511     * @see #GET_RESOLVED_FILTER
2512     */
2513    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2514            int flags);
2515
2516    /**
2517     * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
2518     * user.
2519     *
2520     * @param intent The desired intent as per resolveActivity().
2521     * @param flags Additional option flags.
2522     * @param userId The userId of the user being queried.
2523     *
2524     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2525     *         Receiver. These are ordered from first to last in priority.  If
2526     *         there are no matching receivers, an empty list is returned.
2527     *
2528     * @see #MATCH_DEFAULT_ONLY
2529     * @see #GET_INTENT_FILTERS
2530     * @see #GET_RESOLVED_FILTER
2531     * @hide
2532     */
2533    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2534            int flags, int userId);
2535
2536    /**
2537     * Determine the best service to handle for a given Intent.
2538     *
2539     * @param intent An intent containing all of the desired specification
2540     *               (action, data, type, category, and/or component).
2541     * @param flags Additional option flags.
2542     *
2543     * @return Returns a ResolveInfo containing the final service intent that
2544     *         was determined to be the best action.  Returns null if no
2545     *         matching service was found.
2546     *
2547     * @see #GET_INTENT_FILTERS
2548     * @see #GET_RESOLVED_FILTER
2549     */
2550    public abstract ResolveInfo resolveService(Intent intent, int flags);
2551
2552    /**
2553     * Retrieve all services that can match the given intent.
2554     *
2555     * @param intent The desired intent as per resolveService().
2556     * @param flags Additional option flags.
2557     *
2558     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2559     *         ServiceInfo. These are ordered from best to worst match -- that
2560     *         is, the first item in the list is what is returned by
2561     *         resolveService().  If there are no matching services, an empty
2562     *         list is returned.
2563     *
2564     * @see #GET_INTENT_FILTERS
2565     * @see #GET_RESOLVED_FILTER
2566     */
2567    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
2568            int flags);
2569
2570    /**
2571     * Retrieve all services that can match the given intent for a given user.
2572     *
2573     * @param intent The desired intent as per resolveService().
2574     * @param flags Additional option flags.
2575     * @param userId The user id.
2576     *
2577     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2578     *         ServiceInfo. These are ordered from best to worst match -- that
2579     *         is, the first item in the list is what is returned by
2580     *         resolveService().  If there are no matching services, an empty
2581     *         list is returned.
2582     *
2583     * @see #GET_INTENT_FILTERS
2584     * @see #GET_RESOLVED_FILTER
2585     *
2586     * @hide
2587     */
2588    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
2589            int flags, int userId);
2590
2591    /** {@hide} */
2592    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
2593            Intent intent, int flags, int userId);
2594
2595    /**
2596     * Retrieve all providers that can match the given intent.
2597     *
2598     * @param intent An intent containing all of the desired specification
2599     *            (action, data, type, category, and/or component).
2600     * @param flags Additional option flags.
2601     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2602     *         ProviderInfo. These are ordered from best to worst match. If
2603     *         there are no matching providers, an empty list is returned.
2604     * @see #GET_INTENT_FILTERS
2605     * @see #GET_RESOLVED_FILTER
2606     */
2607    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
2608
2609    /**
2610     * Find a single content provider by its base path name.
2611     *
2612     * @param name The name of the provider to find.
2613     * @param flags Additional option flags.  Currently should always be 0.
2614     *
2615     * @return ContentProviderInfo Information about the provider, if found,
2616     *         else null.
2617     */
2618    public abstract ProviderInfo resolveContentProvider(String name,
2619            int flags);
2620
2621    /**
2622     * Find a single content provider by its base path name.
2623     *
2624     * @param name The name of the provider to find.
2625     * @param flags Additional option flags.  Currently should always be 0.
2626     * @param userId The user id.
2627     *
2628     * @return ContentProviderInfo Information about the provider, if found,
2629     *         else null.
2630     * @hide
2631     */
2632    public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
2633
2634    /**
2635     * Retrieve content provider information.
2636     *
2637     * <p><em>Note: unlike most other methods, an empty result set is indicated
2638     * by a null return instead of an empty list.</em>
2639     *
2640     * @param processName If non-null, limits the returned providers to only
2641     *                    those that are hosted by the given process.  If null,
2642     *                    all content providers are returned.
2643     * @param uid If <var>processName</var> is non-null, this is the required
2644     *        uid owning the requested content providers.
2645     * @param flags Additional option flags.  Currently should always be 0.
2646     *
2647     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
2648     *         content provider either patching <var>processName</var> or, if
2649     *         <var>processName</var> is null, all known content providers.
2650     *         <em>If there are no matching providers, null is returned.</em>
2651     */
2652    public abstract List<ProviderInfo> queryContentProviders(
2653            String processName, int uid, int flags);
2654
2655    /**
2656     * Retrieve all of the information we know about a particular
2657     * instrumentation class.
2658     *
2659     * <p>Throws {@link NameNotFoundException} if instrumentation with the
2660     * given class name cannot be found on the system.
2661     *
2662     * @param className The full name (i.e.
2663     *                  com.google.apps.contacts.InstrumentList) of an
2664     *                  Instrumentation class.
2665     * @param flags Additional option flags.  Currently should always be 0.
2666     *
2667     * @return InstrumentationInfo containing information about the
2668     *         instrumentation.
2669     */
2670    public abstract InstrumentationInfo getInstrumentationInfo(
2671            ComponentName className, int flags) throws NameNotFoundException;
2672
2673    /**
2674     * Retrieve information about available instrumentation code.  May be used
2675     * to retrieve either all instrumentation code, or only the code targeting
2676     * a particular package.
2677     *
2678     * @param targetPackage If null, all instrumentation is returned; only the
2679     *                      instrumentation targeting this package name is
2680     *                      returned.
2681     * @param flags Additional option flags.  Currently should always be 0.
2682     *
2683     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
2684     *         matching available Instrumentation.  Returns an empty list if
2685     *         there is no instrumentation available for the given package.
2686     */
2687    public abstract List<InstrumentationInfo> queryInstrumentation(
2688            String targetPackage, int flags);
2689
2690    /**
2691     * Retrieve an image from a package.  This is a low-level API used by
2692     * the various package manager info structures (such as
2693     * {@link ComponentInfo} to implement retrieval of their associated
2694     * icon.
2695     *
2696     * @param packageName The name of the package that this icon is coming from.
2697     * Cannot be null.
2698     * @param resid The resource identifier of the desired image.  Cannot be 0.
2699     * @param appInfo Overall information about <var>packageName</var>.  This
2700     * may be null, in which case the application information will be retrieved
2701     * for you if needed; if you already have this information around, it can
2702     * be much more efficient to supply it here.
2703     *
2704     * @return Returns a Drawable holding the requested image.  Returns null if
2705     * an image could not be found for any reason.
2706     */
2707    public abstract Drawable getDrawable(String packageName, int resid,
2708            ApplicationInfo appInfo);
2709
2710    /**
2711     * Retrieve the icon associated with an activity.  Given the full name of
2712     * an activity, retrieves the information about it and calls
2713     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
2714     * If the activity cannot be found, NameNotFoundException is thrown.
2715     *
2716     * @param activityName Name of the activity whose icon is to be retrieved.
2717     *
2718     * @return Returns the image of the icon, or the default activity icon if
2719     * it could not be found.  Does not return null.
2720     * @throws NameNotFoundException Thrown if the resources for the given
2721     * activity could not be loaded.
2722     *
2723     * @see #getActivityIcon(Intent)
2724     */
2725    public abstract Drawable getActivityIcon(ComponentName activityName)
2726            throws NameNotFoundException;
2727
2728    /**
2729     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
2730     * set, this simply returns the result of
2731     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
2732     * component and returns the icon associated with the resolved component.
2733     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2734     * to a component, NameNotFoundException is thrown.
2735     *
2736     * @param intent The intent for which you would like to retrieve an icon.
2737     *
2738     * @return Returns the image of the icon, or the default activity icon if
2739     * it could not be found.  Does not return null.
2740     * @throws NameNotFoundException Thrown if the resources for application
2741     * matching the given intent could not be loaded.
2742     *
2743     * @see #getActivityIcon(ComponentName)
2744     */
2745    public abstract Drawable getActivityIcon(Intent intent)
2746            throws NameNotFoundException;
2747
2748    /**
2749     * Retrieve the banner associated with an activity. Given the full name of
2750     * an activity, retrieves the information about it and calls
2751     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
2752     * banner. If the activity cannot be found, NameNotFoundException is thrown.
2753     *
2754     * @param activityName Name of the activity whose banner is to be retrieved.
2755     * @return Returns the image of the banner, or null if the activity has no
2756     *         banner specified.
2757     * @throws NameNotFoundException Thrown if the resources for the given
2758     *             activity could not be loaded.
2759     * @see #getActivityBanner(Intent)
2760     */
2761    public abstract Drawable getActivityBanner(ComponentName activityName)
2762            throws NameNotFoundException;
2763
2764    /**
2765     * Retrieve the banner associated with an Intent. If intent.getClassName()
2766     * is set, this simply returns the result of
2767     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
2768     * intent's component and returns the banner associated with the resolved
2769     * component. If intent.getClassName() cannot be found or the Intent cannot
2770     * be resolved to a component, NameNotFoundException is thrown.
2771     *
2772     * @param intent The intent for which you would like to retrieve a banner.
2773     * @return Returns the image of the banner, or null if the activity has no
2774     *         banner specified.
2775     * @throws NameNotFoundException Thrown if the resources for application
2776     *             matching the given intent could not be loaded.
2777     * @see #getActivityBanner(ComponentName)
2778     */
2779    public abstract Drawable getActivityBanner(Intent intent)
2780            throws NameNotFoundException;
2781
2782    /**
2783     * Return the generic icon for an activity that is used when no specific
2784     * icon is defined.
2785     *
2786     * @return Drawable Image of the icon.
2787     */
2788    public abstract Drawable getDefaultActivityIcon();
2789
2790    /**
2791     * Retrieve the icon associated with an application.  If it has not defined
2792     * an icon, the default app icon is returned.  Does not return null.
2793     *
2794     * @param info Information about application being queried.
2795     *
2796     * @return Returns the image of the icon, or the default application icon
2797     * if it could not be found.
2798     *
2799     * @see #getApplicationIcon(String)
2800     */
2801    public abstract Drawable getApplicationIcon(ApplicationInfo info);
2802
2803    /**
2804     * Retrieve the icon associated with an application.  Given the name of the
2805     * application's package, retrieves the information about it and calls
2806     * getApplicationIcon() to return its icon. If the application cannot be
2807     * found, NameNotFoundException is thrown.
2808     *
2809     * @param packageName Name of the package whose application icon is to be
2810     *                    retrieved.
2811     *
2812     * @return Returns the image of the icon, or the default application icon
2813     * if it could not be found.  Does not return null.
2814     * @throws NameNotFoundException Thrown if the resources for the given
2815     * application could not be loaded.
2816     *
2817     * @see #getApplicationIcon(ApplicationInfo)
2818     */
2819    public abstract Drawable getApplicationIcon(String packageName)
2820            throws NameNotFoundException;
2821
2822    /**
2823     * Retrieve the banner associated with an application.
2824     *
2825     * @param info Information about application being queried.
2826     * @return Returns the image of the banner or null if the application has no
2827     *         banner specified.
2828     * @see #getApplicationBanner(String)
2829     */
2830    public abstract Drawable getApplicationBanner(ApplicationInfo info);
2831
2832    /**
2833     * Retrieve the banner associated with an application. Given the name of the
2834     * application's package, retrieves the information about it and calls
2835     * getApplicationIcon() to return its banner. If the application cannot be
2836     * found, NameNotFoundException is thrown.
2837     *
2838     * @param packageName Name of the package whose application banner is to be
2839     *            retrieved.
2840     * @return Returns the image of the banner or null if the application has no
2841     *         banner specified.
2842     * @throws NameNotFoundException Thrown if the resources for the given
2843     *             application could not be loaded.
2844     * @see #getApplicationBanner(ApplicationInfo)
2845     */
2846    public abstract Drawable getApplicationBanner(String packageName)
2847            throws NameNotFoundException;
2848
2849    /**
2850     * Retrieve the logo associated with an activity. Given the full name of an
2851     * activity, retrieves the information about it and calls
2852     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
2853     * logo. If the activity cannot be found, NameNotFoundException is thrown.
2854     *
2855     * @param activityName Name of the activity whose logo is to be retrieved.
2856     * @return Returns the image of the logo or null if the activity has no logo
2857     *         specified.
2858     * @throws NameNotFoundException Thrown if the resources for the given
2859     *             activity could not be loaded.
2860     * @see #getActivityLogo(Intent)
2861     */
2862    public abstract Drawable getActivityLogo(ComponentName activityName)
2863            throws NameNotFoundException;
2864
2865    /**
2866     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
2867     * set, this simply returns the result of
2868     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
2869     * component and returns the logo associated with the resolved component.
2870     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2871     * to a component, NameNotFoundException is thrown.
2872     *
2873     * @param intent The intent for which you would like to retrieve a logo.
2874     *
2875     * @return Returns the image of the logo, or null if the activity has no
2876     * logo specified.
2877     *
2878     * @throws NameNotFoundException Thrown if the resources for application
2879     * matching the given intent could not be loaded.
2880     *
2881     * @see #getActivityLogo(ComponentName)
2882     */
2883    public abstract Drawable getActivityLogo(Intent intent)
2884            throws NameNotFoundException;
2885
2886    /**
2887     * Retrieve the logo associated with an application.  If it has not specified
2888     * a logo, this method returns null.
2889     *
2890     * @param info Information about application being queried.
2891     *
2892     * @return Returns the image of the logo, or null if no logo is specified
2893     * by the application.
2894     *
2895     * @see #getApplicationLogo(String)
2896     */
2897    public abstract Drawable getApplicationLogo(ApplicationInfo info);
2898
2899    /**
2900     * Retrieve the logo associated with an application.  Given the name of the
2901     * application's package, retrieves the information about it and calls
2902     * getApplicationLogo() to return its logo. If the application cannot be
2903     * found, NameNotFoundException is thrown.
2904     *
2905     * @param packageName Name of the package whose application logo is to be
2906     *                    retrieved.
2907     *
2908     * @return Returns the image of the logo, or null if no application logo
2909     * has been specified.
2910     *
2911     * @throws NameNotFoundException Thrown if the resources for the given
2912     * application could not be loaded.
2913     *
2914     * @see #getApplicationLogo(ApplicationInfo)
2915     */
2916    public abstract Drawable getApplicationLogo(String packageName)
2917            throws NameNotFoundException;
2918
2919    /**
2920     * If the target user is a managed profile of the calling user or the caller
2921     * is itself a managed profile, then this returns a badged copy of the given
2922     * icon to be able to distinguish it from the original icon. For badging an
2923     * arbitrary drawable use {@link #getUserBadgedDrawableForDensity(
2924     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
2925     * <p>
2926     * If the original drawable is a BitmapDrawable and the backing bitmap is
2927     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
2928     * is performed in place and the original drawable is returned.
2929     * </p>
2930     *
2931     * @param icon The icon to badge.
2932     * @param user The target user.
2933     * @return A drawable that combines the original icon and a badge as
2934     *         determined by the system.
2935     */
2936    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
2937
2938    /**
2939     * If the target user is a managed profile of the calling user or the caller
2940     * is itself a managed profile, then this returns a badged copy of the given
2941     * drawable allowing the user to distinguish it from the original drawable.
2942     * The caller can specify the location in the bounds of the drawable to be
2943     * badged where the badge should be applied as well as the density of the
2944     * badge to be used.
2945     * <p>
2946     * If the original drawable is a BitmapDrawable and the backing bitmap is
2947     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
2948     * is performed in place and the original drawable is returned.
2949     * </p>
2950     *
2951     * @param drawable The drawable to badge.
2952     * @param user The target user.
2953     * @param badgeLocation Where in the bounds of the badged drawable to place
2954     *         the badge. If not provided, the badge is applied on top of the entire
2955     *         drawable being badged.
2956     * @param badgeDensity The optional desired density for the badge as per
2957     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
2958     *         the density of the display is used.
2959     * @return A drawable that combines the original drawable and a badge as
2960     *         determined by the system.
2961     */
2962    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
2963            UserHandle user, Rect badgeLocation, int badgeDensity);
2964
2965    /**
2966     * If the target user is a managed profile of the calling user or the caller
2967     * is itself a managed profile, then this returns a drawable to use as a small
2968     * icon to include in a view to distinguish it from the original icon.
2969     *
2970     * @param user The target user.
2971     * @param density The optional desired density for the badge as per
2972     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
2973     *         the density of the current display is used.
2974     * @return the drawable or null if no drawable is required.
2975     * @hide
2976     */
2977    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
2978
2979    /**
2980     * If the target user is a managed profile of the calling user or the caller
2981     * is itself a managed profile, then this returns a copy of the label with
2982     * badging for accessibility services like talkback. E.g. passing in "Email"
2983     * and it might return "Work Email" for Email in the work profile.
2984     *
2985     * @param label The label to change.
2986     * @param user The target user.
2987     * @return A label that combines the original label and a badge as
2988     *         determined by the system.
2989     */
2990    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
2991
2992    /**
2993     * Retrieve text from a package.  This is a low-level API used by
2994     * the various package manager info structures (such as
2995     * {@link ComponentInfo} to implement retrieval of their associated
2996     * labels and other text.
2997     *
2998     * @param packageName The name of the package that this text is coming from.
2999     * Cannot be null.
3000     * @param resid The resource identifier of the desired text.  Cannot be 0.
3001     * @param appInfo Overall information about <var>packageName</var>.  This
3002     * may be null, in which case the application information will be retrieved
3003     * for you if needed; if you already have this information around, it can
3004     * be much more efficient to supply it here.
3005     *
3006     * @return Returns a CharSequence holding the requested text.  Returns null
3007     * if the text could not be found for any reason.
3008     */
3009    public abstract CharSequence getText(String packageName, int resid,
3010            ApplicationInfo appInfo);
3011
3012    /**
3013     * Retrieve an XML file from a package.  This is a low-level API used to
3014     * retrieve XML meta data.
3015     *
3016     * @param packageName The name of the package that this xml is coming from.
3017     * Cannot be null.
3018     * @param resid The resource identifier of the desired xml.  Cannot be 0.
3019     * @param appInfo Overall information about <var>packageName</var>.  This
3020     * may be null, in which case the application information will be retrieved
3021     * for you if needed; if you already have this information around, it can
3022     * be much more efficient to supply it here.
3023     *
3024     * @return Returns an XmlPullParser allowing you to parse out the XML
3025     * data.  Returns null if the xml resource could not be found for any
3026     * reason.
3027     */
3028    public abstract XmlResourceParser getXml(String packageName, int resid,
3029            ApplicationInfo appInfo);
3030
3031    /**
3032     * Return the label to use for this application.
3033     *
3034     * @return Returns the label associated with this application, or null if
3035     * it could not be found for any reason.
3036     * @param info The application to get the label of.
3037     */
3038    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
3039
3040    /**
3041     * Retrieve the resources associated with an activity.  Given the full
3042     * name of an activity, retrieves the information about it and calls
3043     * getResources() to return its application's resources.  If the activity
3044     * cannot be found, NameNotFoundException is thrown.
3045     *
3046     * @param activityName Name of the activity whose resources are to be
3047     *                     retrieved.
3048     *
3049     * @return Returns the application's Resources.
3050     * @throws NameNotFoundException Thrown if the resources for the given
3051     * application could not be loaded.
3052     *
3053     * @see #getResourcesForApplication(ApplicationInfo)
3054     */
3055    public abstract Resources getResourcesForActivity(ComponentName activityName)
3056            throws NameNotFoundException;
3057
3058    /**
3059     * Retrieve the resources for an application.  Throws NameNotFoundException
3060     * if the package is no longer installed.
3061     *
3062     * @param app Information about the desired application.
3063     *
3064     * @return Returns the application's Resources.
3065     * @throws NameNotFoundException Thrown if the resources for the given
3066     * application could not be loaded (most likely because it was uninstalled).
3067     */
3068    public abstract Resources getResourcesForApplication(ApplicationInfo app)
3069            throws NameNotFoundException;
3070
3071    /**
3072     * Retrieve the resources associated with an application.  Given the full
3073     * package name of an application, retrieves the information about it and
3074     * calls getResources() to return its application's resources.  If the
3075     * appPackageName cannot be found, NameNotFoundException is thrown.
3076     *
3077     * @param appPackageName Package name of the application whose resources
3078     *                       are to be retrieved.
3079     *
3080     * @return Returns the application's Resources.
3081     * @throws NameNotFoundException Thrown if the resources for the given
3082     * application could not be loaded.
3083     *
3084     * @see #getResourcesForApplication(ApplicationInfo)
3085     */
3086    public abstract Resources getResourcesForApplication(String appPackageName)
3087            throws NameNotFoundException;
3088
3089    /** @hide */
3090    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
3091            throws NameNotFoundException;
3092
3093    /**
3094     * Retrieve overall information about an application package defined
3095     * in a package archive file
3096     *
3097     * @param archiveFilePath The path to the archive file
3098     * @param flags Additional option flags. Use any combination of
3099     * {@link #GET_ACTIVITIES},
3100     * {@link #GET_GIDS},
3101     * {@link #GET_CONFIGURATIONS},
3102     * {@link #GET_INSTRUMENTATION},
3103     * {@link #GET_PERMISSIONS},
3104     * {@link #GET_PROVIDERS},
3105     * {@link #GET_RECEIVERS},
3106     * {@link #GET_SERVICES},
3107     * {@link #GET_SIGNATURES}, to modify the data returned.
3108     *
3109     * @return Returns the information about the package. Returns
3110     * null if the package could not be successfully parsed.
3111     *
3112     * @see #GET_ACTIVITIES
3113     * @see #GET_GIDS
3114     * @see #GET_CONFIGURATIONS
3115     * @see #GET_INSTRUMENTATION
3116     * @see #GET_PERMISSIONS
3117     * @see #GET_PROVIDERS
3118     * @see #GET_RECEIVERS
3119     * @see #GET_SERVICES
3120     * @see #GET_SIGNATURES
3121     *
3122     */
3123    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3124        final PackageParser parser = new PackageParser();
3125        final File apkFile = new File(archiveFilePath);
3126        try {
3127            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3128            if ((flags & GET_SIGNATURES) != 0) {
3129                parser.collectCertificates(pkg, 0);
3130                parser.collectManifestDigest(pkg);
3131            }
3132            PackageUserState state = new PackageUserState();
3133            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3134        } catch (PackageParserException e) {
3135            return null;
3136        }
3137    }
3138
3139    /**
3140     * @hide Install a package. Since this may take a little while, the result
3141     *       will be posted back to the given observer. An installation will
3142     *       fail if the calling context lacks the
3143     *       {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3144     *       the package named in the package file's manifest is already
3145     *       installed, or if there's no space available on the device.
3146     * @param packageURI The location of the package file to install. This can
3147     *            be a 'file:' or a 'content:' URI.
3148     * @param observer An observer callback to get notified when the package
3149     *            installation is complete.
3150     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3151     *            will be called when that happens. This parameter must not be
3152     *            null.
3153     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3154     *            {@link #INSTALL_REPLACE_EXISTING},
3155     *            {@link #INSTALL_ALLOW_TEST}.
3156     * @param installerPackageName Optional package name of the application that
3157     *            is performing the installation. This identifies which market
3158     *            the package came from.
3159     * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3160     *             String)} instead. This method will continue to be supported
3161     *             but the older observer interface will not get additional
3162     *             failure details.
3163     */
3164    // @SystemApi
3165    public abstract void installPackage(
3166            Uri packageURI, IPackageInstallObserver observer, int flags,
3167            String installerPackageName);
3168
3169    /**
3170     * Similar to
3171     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3172     * with an extra verification file provided.
3173     *
3174     * @param packageURI The location of the package file to install. This can
3175     *            be a 'file:' or a 'content:' URI.
3176     * @param observer An observer callback to get notified when the package
3177     *            installation is complete.
3178     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3179     *            will be called when that happens. This parameter must not be
3180     *            null.
3181     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3182     *            {@link #INSTALL_REPLACE_EXISTING},
3183     *            {@link #INSTALL_ALLOW_TEST}.
3184     * @param installerPackageName Optional package name of the application that
3185     *            is performing the installation. This identifies which market
3186     *            the package came from.
3187     * @param verificationURI The location of the supplementary verification
3188     *            file. This can be a 'file:' or a 'content:' URI. May be
3189     *            {@code null}.
3190     * @param manifestDigest an object that holds the digest of the package
3191     *            which can be used to verify ownership. May be {@code null}.
3192     * @param encryptionParams if the package to be installed is encrypted,
3193     *            these parameters describing the encryption and authentication
3194     *            used. May be {@code null}.
3195     * @hide
3196     * @deprecated Use {@link #installPackageWithVerification(Uri,
3197     *             PackageInstallObserver, int, String, Uri, ManifestDigest,
3198     *             ContainerEncryptionParams)} instead. This method will
3199     *             continue to be supported but the older observer interface
3200     *             will not get additional failure details.
3201     */
3202    // @SystemApi
3203    public abstract void installPackageWithVerification(Uri packageURI,
3204            IPackageInstallObserver observer, int flags, String installerPackageName,
3205            Uri verificationURI, ManifestDigest manifestDigest,
3206            ContainerEncryptionParams encryptionParams);
3207
3208    /**
3209     * Similar to
3210     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3211     * with an extra verification information provided.
3212     *
3213     * @param packageURI The location of the package file to install. This can
3214     *            be a 'file:' or a 'content:' URI.
3215     * @param observer An observer callback to get notified when the package
3216     *            installation is complete.
3217     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3218     *            will be called when that happens. This parameter must not be
3219     *            null.
3220     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3221     *            {@link #INSTALL_REPLACE_EXISTING},
3222     *            {@link #INSTALL_ALLOW_TEST}.
3223     * @param installerPackageName Optional package name of the application that
3224     *            is performing the installation. This identifies which market
3225     *            the package came from.
3226     * @param verificationParams an object that holds signal information to
3227     *            assist verification. May be {@code null}.
3228     * @param encryptionParams if the package to be installed is encrypted,
3229     *            these parameters describing the encryption and authentication
3230     *            used. May be {@code null}.
3231     * @hide
3232     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3233     *             PackageInstallObserver, int, String, VerificationParams,
3234     *             ContainerEncryptionParams)} instead. This method will
3235     *             continue to be supported but the older observer interface
3236     *             will not get additional failure details.
3237     */
3238    @Deprecated
3239    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3240            IPackageInstallObserver observer, int flags, String installerPackageName,
3241            VerificationParams verificationParams,
3242            ContainerEncryptionParams encryptionParams);
3243
3244    // Package-install variants that take the new, expanded form of observer interface.
3245    // Note that these *also* take the original observer type and will redundantly
3246    // report the same information to that observer if supplied; but it is not required.
3247
3248    /**
3249     * @hide
3250     *
3251     * Install a package. Since this may take a little while, the result will
3252     * be posted back to the given observer.  An installation will fail if the calling context
3253     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3254     * package named in the package file's manifest is already installed, or if there's no space
3255     * available on the device.
3256     *
3257     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3258     * 'content:' URI.
3259     * @param observer An observer callback to get notified when the package installation is
3260     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3261     * called when that happens. This parameter must not be null.
3262     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3263     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3264     * @param installerPackageName Optional package name of the application that is performing the
3265     * installation. This identifies which market the package came from.
3266     */
3267    public abstract void installPackage(
3268            Uri packageURI, PackageInstallObserver observer,
3269            int flags, String installerPackageName);
3270
3271    /**
3272     * Similar to
3273     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3274     * with an extra verification file provided.
3275     *
3276     * @param packageURI The location of the package file to install. This can
3277     *            be a 'file:' or a 'content:' URI.
3278     * @param observer An observer callback to get notified when the package installation is
3279     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3280     * called when that happens. This parameter must not be null.
3281     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3282     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3283     * @param installerPackageName Optional package name of the application that
3284     *            is performing the installation. This identifies which market
3285     *            the package came from.
3286     * @param verificationURI The location of the supplementary verification
3287     *            file. This can be a 'file:' or a 'content:' URI. May be
3288     *            {@code null}.
3289     * @param manifestDigest an object that holds the digest of the package
3290     *            which can be used to verify ownership. May be {@code null}.
3291     * @param encryptionParams if the package to be installed is encrypted,
3292     *            these parameters describing the encryption and authentication
3293     *            used. May be {@code null}.
3294     * @hide
3295     */
3296    public abstract void installPackageWithVerification(Uri packageURI,
3297            PackageInstallObserver observer, int flags, String installerPackageName,
3298            Uri verificationURI, ManifestDigest manifestDigest,
3299            ContainerEncryptionParams encryptionParams);
3300
3301    /**
3302     * Similar to
3303     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3304     * with an extra verification information provided.
3305     *
3306     * @param packageURI The location of the package file to install. This can
3307     *            be a 'file:' or a 'content:' URI.
3308     * @param observer An observer callback to get notified when the package installation is
3309     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3310     * called when that happens. This parameter must not be null.
3311     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3312     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3313     * @param installerPackageName Optional package name of the application that
3314     *            is performing the installation. This identifies which market
3315     *            the package came from.
3316     * @param verificationParams an object that holds signal information to
3317     *            assist verification. May be {@code null}.
3318     * @param encryptionParams if the package to be installed is encrypted,
3319     *            these parameters describing the encryption and authentication
3320     *            used. May be {@code null}.
3321     *
3322     * @hide
3323     */
3324    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3325            PackageInstallObserver observer, int flags, String installerPackageName,
3326            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3327
3328    /**
3329     * If there is already an application with the given package name installed
3330     * on the system for other users, also install it for the calling user.
3331     * @hide
3332     */
3333    // @SystemApi
3334    public abstract int installExistingPackage(String packageName)
3335            throws NameNotFoundException;
3336
3337    /**
3338     * Allows a package listening to the
3339     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3340     * broadcast} to respond to the package manager. The response must include
3341     * the {@code verificationCode} which is one of
3342     * {@link PackageManager#VERIFICATION_ALLOW} or
3343     * {@link PackageManager#VERIFICATION_REJECT}.
3344     *
3345     * @param id pending package identifier as passed via the
3346     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3347     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3348     *            or {@link PackageManager#VERIFICATION_REJECT}.
3349     * @throws SecurityException if the caller does not have the
3350     *            PACKAGE_VERIFICATION_AGENT permission.
3351     */
3352    public abstract void verifyPendingInstall(int id, int verificationCode);
3353
3354    /**
3355     * Allows a package listening to the
3356     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3357     * broadcast} to extend the default timeout for a response and declare what
3358     * action to perform after the timeout occurs. The response must include
3359     * the {@code verificationCodeAtTimeout} which is one of
3360     * {@link PackageManager#VERIFICATION_ALLOW} or
3361     * {@link PackageManager#VERIFICATION_REJECT}.
3362     *
3363     * This method may only be called once per package id. Additional calls
3364     * will have no effect.
3365     *
3366     * @param id pending package identifier as passed via the
3367     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3368     * @param verificationCodeAtTimeout either
3369     *            {@link PackageManager#VERIFICATION_ALLOW} or
3370     *            {@link PackageManager#VERIFICATION_REJECT}. If
3371     *            {@code verificationCodeAtTimeout} is neither
3372     *            {@link PackageManager#VERIFICATION_ALLOW} or
3373     *            {@link PackageManager#VERIFICATION_REJECT}, then
3374     *            {@code verificationCodeAtTimeout} will default to
3375     *            {@link PackageManager#VERIFICATION_REJECT}.
3376     * @param millisecondsToDelay the amount of time requested for the timeout.
3377     *            Must be positive and less than
3378     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3379     *            {@code millisecondsToDelay} is out of bounds,
3380     *            {@code millisecondsToDelay} will be set to the closest in
3381     *            bounds value; namely, 0 or
3382     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3383     * @throws SecurityException if the caller does not have the
3384     *            PACKAGE_VERIFICATION_AGENT permission.
3385     */
3386    public abstract void extendVerificationTimeout(int id,
3387            int verificationCodeAtTimeout, long millisecondsToDelay);
3388
3389    /**
3390     * Change the installer associated with a given package.  There are limitations
3391     * on how the installer package can be changed; in particular:
3392     * <ul>
3393     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3394     * is not signed with the same certificate as the calling application.
3395     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3396     * has an installer package, and that installer package is not signed with
3397     * the same certificate as the calling application.
3398     * </ul>
3399     *
3400     * @param targetPackage The installed package whose installer will be changed.
3401     * @param installerPackageName The package name of the new installer.  May be
3402     * null to clear the association.
3403     */
3404    public abstract void setInstallerPackageName(String targetPackage,
3405            String installerPackageName);
3406
3407    /**
3408     * Attempts to delete a package.  Since this may take a little while, the result will
3409     * be posted back to the given observer.  A deletion will fail if the calling context
3410     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3411     * named package cannot be found, or if the named package is a "system package".
3412     * (TODO: include pointer to documentation on "system packages")
3413     *
3414     * @param packageName The name of the package to delete
3415     * @param observer An observer callback to get notified when the package deletion is
3416     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3417     * called when that happens.  observer may be null to indicate that no callback is desired.
3418     * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3419     * {@link #DELETE_ALL_USERS}.
3420     *
3421     * @hide
3422     */
3423    // @SystemApi
3424    public abstract void deletePackage(
3425            String packageName, IPackageDeleteObserver observer, int flags);
3426
3427    /**
3428     * Retrieve the package name of the application that installed a package. This identifies
3429     * which market the package came from.
3430     *
3431     * @param packageName The name of the package to query
3432     */
3433    public abstract String getInstallerPackageName(String packageName);
3434
3435    /**
3436     * Attempts to clear the user data directory of an application.
3437     * Since this may take a little while, the result will
3438     * be posted back to the given observer.  A deletion will fail if the
3439     * named package cannot be found, or if the named package is a "system package".
3440     *
3441     * @param packageName The name of the package
3442     * @param observer An observer callback to get notified when the operation is finished
3443     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3444     * will be called when that happens.  observer may be null to indicate that
3445     * no callback is desired.
3446     *
3447     * @hide
3448     */
3449    public abstract void clearApplicationUserData(String packageName,
3450            IPackageDataObserver observer);
3451    /**
3452     * Attempts to delete the cache files associated with an application.
3453     * Since this may take a little while, the result will
3454     * be posted back to the given observer.  A deletion will fail if the calling context
3455     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3456     * named package cannot be found, or if the named package is a "system package".
3457     *
3458     * @param packageName The name of the package to delete
3459     * @param observer An observer callback to get notified when the cache file deletion
3460     * is complete.
3461     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3462     * will be called when that happens.  observer may be null to indicate that
3463     * no callback is desired.
3464     *
3465     * @hide
3466     */
3467    public abstract void deleteApplicationCacheFiles(String packageName,
3468            IPackageDataObserver observer);
3469
3470    /**
3471     * Free storage by deleting LRU sorted list of cache files across
3472     * all applications. If the currently available free storage
3473     * on the device is greater than or equal to the requested
3474     * free storage, no cache files are cleared. If the currently
3475     * available storage on the device is less than the requested
3476     * free storage, some or all of the cache files across
3477     * all applications are deleted (based on last accessed time)
3478     * to increase the free storage space on the device to
3479     * the requested value. There is no guarantee that clearing all
3480     * the cache files from all applications will clear up
3481     * enough storage to achieve the desired value.
3482     * @param freeStorageSize The number of bytes of storage to be
3483     * freed by the system. Say if freeStorageSize is XX,
3484     * and the current free storage is YY,
3485     * if XX is less than YY, just return. if not free XX-YY number
3486     * of bytes if possible.
3487     * @param observer call back used to notify when
3488     * the operation is completed
3489     *
3490     * @hide
3491     */
3492    // @SystemApi
3493    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
3494
3495    /**
3496     * Free storage by deleting LRU sorted list of cache files across
3497     * all applications. If the currently available free storage
3498     * on the device is greater than or equal to the requested
3499     * free storage, no cache files are cleared. If the currently
3500     * available storage on the device is less than the requested
3501     * free storage, some or all of the cache files across
3502     * all applications are deleted (based on last accessed time)
3503     * to increase the free storage space on the device to
3504     * the requested value. There is no guarantee that clearing all
3505     * the cache files from all applications will clear up
3506     * enough storage to achieve the desired value.
3507     * @param freeStorageSize The number of bytes of storage to be
3508     * freed by the system. Say if freeStorageSize is XX,
3509     * and the current free storage is YY,
3510     * if XX is less than YY, just return. if not free XX-YY number
3511     * of bytes if possible.
3512     * @param pi IntentSender call back used to
3513     * notify when the operation is completed.May be null
3514     * to indicate that no call back is desired.
3515     *
3516     * @hide
3517     */
3518    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
3519
3520    /**
3521     * Retrieve the size information for a package.
3522     * Since this may take a little while, the result will
3523     * be posted back to the given observer.  The calling context
3524     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
3525     *
3526     * @param packageName The name of the package whose size information is to be retrieved
3527     * @param userHandle The user whose size information should be retrieved.
3528     * @param observer An observer callback to get notified when the operation
3529     * is complete.
3530     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
3531     * The observer's callback is invoked with a PackageStats object(containing the
3532     * code, data and cache sizes of the package) and a boolean value representing
3533     * the status of the operation. observer may be null to indicate that
3534     * no callback is desired.
3535     *
3536     * @hide
3537     */
3538    public abstract void getPackageSizeInfo(String packageName, int userHandle,
3539            IPackageStatsObserver observer);
3540
3541    /**
3542     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
3543     * returns the size for the calling user.
3544     *
3545     * @hide
3546     */
3547    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
3548        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
3549    }
3550
3551    /**
3552     * @deprecated This function no longer does anything; it was an old
3553     * approach to managing preferred activities, which has been superseded
3554     * by (and conflicts with) the modern activity-based preferences.
3555     */
3556    @Deprecated
3557    public abstract void addPackageToPreferred(String packageName);
3558
3559    /**
3560     * @deprecated This function no longer does anything; it was an old
3561     * approach to managing preferred activities, which has been superseded
3562     * by (and conflicts with) the modern activity-based preferences.
3563     */
3564    @Deprecated
3565    public abstract void removePackageFromPreferred(String packageName);
3566
3567    /**
3568     * Retrieve the list of all currently configured preferred packages.  The
3569     * first package on the list is the most preferred, the last is the
3570     * least preferred.
3571     *
3572     * @param flags Additional option flags. Use any combination of
3573     * {@link #GET_ACTIVITIES},
3574     * {@link #GET_GIDS},
3575     * {@link #GET_CONFIGURATIONS},
3576     * {@link #GET_INSTRUMENTATION},
3577     * {@link #GET_PERMISSIONS},
3578     * {@link #GET_PROVIDERS},
3579     * {@link #GET_RECEIVERS},
3580     * {@link #GET_SERVICES},
3581     * {@link #GET_SIGNATURES}, to modify the data returned.
3582     *
3583     * @return Returns a list of PackageInfo objects describing each
3584     * preferred application, in order of preference.
3585     *
3586     * @see #GET_ACTIVITIES
3587     * @see #GET_GIDS
3588     * @see #GET_CONFIGURATIONS
3589     * @see #GET_INSTRUMENTATION
3590     * @see #GET_PERMISSIONS
3591     * @see #GET_PROVIDERS
3592     * @see #GET_RECEIVERS
3593     * @see #GET_SERVICES
3594     * @see #GET_SIGNATURES
3595     */
3596    public abstract List<PackageInfo> getPreferredPackages(int flags);
3597
3598    /**
3599     * @deprecated This is a protected API that should not have been available
3600     * to third party applications.  It is the platform's responsibility for
3601     * assigning preferred activities and this cannot be directly modified.
3602     *
3603     * Add a new preferred activity mapping to the system.  This will be used
3604     * to automatically select the given activity component when
3605     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3606     * multiple matching activities and also matches the given filter.
3607     *
3608     * @param filter The set of intents under which this activity will be
3609     * made preferred.
3610     * @param match The IntentFilter match category that this preference
3611     * applies to.
3612     * @param set The set of activities that the user was picking from when
3613     * this preference was made.
3614     * @param activity The component name of the activity that is to be
3615     * preferred.
3616     */
3617    @Deprecated
3618    public abstract void addPreferredActivity(IntentFilter filter, int match,
3619            ComponentName[] set, ComponentName activity);
3620
3621    /**
3622     * Same as {@link #addPreferredActivity(IntentFilter, int,
3623            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
3624            to.
3625     * @hide
3626     */
3627    public void addPreferredActivity(IntentFilter filter, int match,
3628            ComponentName[] set, ComponentName activity, int userId) {
3629        throw new RuntimeException("Not implemented. Must override in a subclass.");
3630    }
3631
3632    /**
3633     * @deprecated This is a protected API that should not have been available
3634     * to third party applications.  It is the platform's responsibility for
3635     * assigning preferred activities and this cannot be directly modified.
3636     *
3637     * Replaces an existing preferred activity mapping to the system, and if that were not present
3638     * adds a new preferred activity.  This will be used
3639     * to automatically select the given activity component when
3640     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3641     * multiple matching activities and also matches the given filter.
3642     *
3643     * @param filter The set of intents under which this activity will be
3644     * made preferred.
3645     * @param match The IntentFilter match category that this preference
3646     * applies to.
3647     * @param set The set of activities that the user was picking from when
3648     * this preference was made.
3649     * @param activity The component name of the activity that is to be
3650     * preferred.
3651     * @hide
3652     */
3653    @Deprecated
3654    public abstract void replacePreferredActivity(IntentFilter filter, int match,
3655            ComponentName[] set, ComponentName activity);
3656
3657    /**
3658     * @hide
3659     */
3660    @Deprecated
3661    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
3662           ComponentName[] set, ComponentName activity, int userId) {
3663        throw new RuntimeException("Not implemented. Must override in a subclass.");
3664    }
3665
3666    /**
3667     * Remove all preferred activity mappings, previously added with
3668     * {@link #addPreferredActivity}, from the
3669     * system whose activities are implemented in the given package name.
3670     * An application can only clear its own package(s).
3671     *
3672     * @param packageName The name of the package whose preferred activity
3673     * mappings are to be removed.
3674     */
3675    public abstract void clearPackagePreferredActivities(String packageName);
3676
3677    /**
3678     * Retrieve all preferred activities, previously added with
3679     * {@link #addPreferredActivity}, that are
3680     * currently registered with the system.
3681     *
3682     * @param outFilters A list in which to place the filters of all of the
3683     * preferred activities, or null for none.
3684     * @param outActivities A list in which to place the component names of
3685     * all of the preferred activities, or null for none.
3686     * @param packageName An option package in which you would like to limit
3687     * the list.  If null, all activities will be returned; if non-null, only
3688     * those activities in the given package are returned.
3689     *
3690     * @return Returns the total number of registered preferred activities
3691     * (the number of distinct IntentFilter records, not the number of unique
3692     * activity components) that were found.
3693     */
3694    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
3695            List<ComponentName> outActivities, String packageName);
3696
3697    /**
3698     * Ask for the set of available 'home' activities and the current explicit
3699     * default, if any.
3700     * @hide
3701     */
3702    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
3703
3704    /**
3705     * Set the enabled setting for a package component (activity, receiver, service, provider).
3706     * This setting will override any enabled state which may have been set by the component in its
3707     * manifest.
3708     *
3709     * @param componentName The component to enable
3710     * @param newState The new enabled state for the component.  The legal values for this state
3711     *                 are:
3712     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3713     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3714     *                   and
3715     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3716     *                 The last one removes the setting, thereby restoring the component's state to
3717     *                 whatever was set in it's manifest (or enabled, by default).
3718     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3719     */
3720    public abstract void setComponentEnabledSetting(ComponentName componentName,
3721            int newState, int flags);
3722
3723
3724    /**
3725     * Return the enabled setting for a package component (activity,
3726     * receiver, service, provider).  This returns the last value set by
3727     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
3728     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3729     * the value originally specified in the manifest has not been modified.
3730     *
3731     * @param componentName The component to retrieve.
3732     * @return Returns the current enabled state for the component.  May
3733     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3734     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3735     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3736     * component's enabled state is based on the original information in
3737     * the manifest as found in {@link ComponentInfo}.
3738     */
3739    public abstract int getComponentEnabledSetting(ComponentName componentName);
3740
3741    /**
3742     * Set the enabled setting for an application
3743     * This setting will override any enabled state which may have been set by the application in
3744     * its manifest.  It also overrides the enabled state set in the manifest for any of the
3745     * application's components.  It does not override any enabled state set by
3746     * {@link #setComponentEnabledSetting} for any of the application's components.
3747     *
3748     * @param packageName The package name of the application to enable
3749     * @param newState The new enabled state for the component.  The legal values for this state
3750     *                 are:
3751     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3752     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3753     *                   and
3754     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3755     *                 The last one removes the setting, thereby restoring the applications's state to
3756     *                 whatever was set in its manifest (or enabled, by default).
3757     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3758     */
3759    public abstract void setApplicationEnabledSetting(String packageName,
3760            int newState, int flags);
3761
3762    /**
3763     * Return the enabled setting for an application. This returns
3764     * the last value set by
3765     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
3766     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3767     * the value originally specified in the manifest has not been modified.
3768     *
3769     * @param packageName The package name of the application to retrieve.
3770     * @return Returns the current enabled state for the application.  May
3771     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3772     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3773     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3774     * application's enabled state is based on the original information in
3775     * the manifest as found in {@link ComponentInfo}.
3776     * @throws IllegalArgumentException if the named package does not exist.
3777     */
3778    public abstract int getApplicationEnabledSetting(String packageName);
3779
3780    /**
3781     * Puts the package in a hidden state, which is almost like an uninstalled state,
3782     * making the package unavailable, but it doesn't remove the data or the actual
3783     * package file. Application can be unhidden by either resetting the hidden state
3784     * or by installing it, such as with {@link #installExistingPackage(String)}
3785     * @hide
3786     */
3787    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
3788            UserHandle userHandle);
3789
3790    /**
3791     * Returns the hidden state of a package.
3792     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
3793     * @hide
3794     */
3795    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
3796            UserHandle userHandle);
3797
3798    /**
3799     * Return whether the device has been booted into safe mode.
3800     */
3801    public abstract boolean isSafeMode();
3802
3803    /**
3804     * Return the {@link KeySet} associated with the String alias for this
3805     * application.
3806     *
3807     * @param alias The alias for a given {@link KeySet} as defined in the
3808     *        application's AndroidManifest.xml.
3809     * @hide
3810     */
3811    public abstract KeySet getKeySetByAlias(String packageName, String alias);
3812
3813    /** Return the signing {@link KeySet} for this application.
3814     * @hide
3815     */
3816    public abstract KeySet getSigningKeySet(String packageName);
3817
3818    /**
3819     * Return whether the package denoted by packageName has been signed by all
3820     * of the keys specified by the {@link KeySet} ks.  This will return true if
3821     * the package has been signed by additional keys (a superset) as well.
3822     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
3823     * @hide
3824     */
3825    public abstract boolean isSignedBy(String packageName, KeySet ks);
3826
3827    /**
3828     * Return whether the package denoted by packageName has been signed by all
3829     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
3830     * {@link #isSignedBy(String packageName, KeySet ks)}.
3831     * @hide
3832     */
3833    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
3834
3835    /**
3836     * Attempts to move package resources from internal to external media or vice versa.
3837     * Since this may take a little while, the result will
3838     * be posted back to the given observer.   This call may fail if the calling context
3839     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
3840     * named package cannot be found, or if the named package is a "system package".
3841     *
3842     * @param packageName The name of the package to delete
3843     * @param observer An observer callback to get notified when the package move is
3844     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
3845     * called when that happens.  observer may be null to indicate that no callback is desired.
3846     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
3847     * {@link #MOVE_EXTERNAL_MEDIA}
3848     *
3849     * @hide
3850     */
3851    public abstract void movePackage(
3852            String packageName, IPackageMoveObserver observer, int flags);
3853
3854    /**
3855     * Returns the device identity that verifiers can use to associate their scheme to a particular
3856     * device. This should not be used by anything other than a package verifier.
3857     *
3858     * @return identity that uniquely identifies current device
3859     * @hide
3860     */
3861    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
3862
3863    /**
3864     * Return interface that offers the ability to install, upgrade, and remove
3865     * applications on the device.
3866     */
3867    public abstract @NonNull PackageInstaller getPackageInstaller();
3868
3869    /**
3870     * Returns the data directory for a particular user and package, given the uid of the package.
3871     * @param uid uid of the package, including the userId and appId
3872     * @param packageName name of the package
3873     * @return the user-specific data directory for the package
3874     * @hide
3875     */
3876    public static String getDataDirForUser(int userId, String packageName) {
3877        // TODO: This should be shared with Installer's knowledge of user directory
3878        return Environment.getDataDirectory().toString() + "/user/" + userId
3879                + "/" + packageName;
3880    }
3881
3882    /**
3883     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
3884     * user with id sourceUserId can also be be resolved by activities in the user with id
3885     * targetUserId if they match the specified intent filter.
3886     * @param filter The {@link IntentFilter} the intent has to match
3887     * @param sourceUserId The source user id.
3888     * @param targetUserId The target user id.
3889     * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
3890     * @hide
3891     */
3892    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
3893            int targetUserId, int flags);
3894
3895    /**
3896     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
3897     * source, and have been set by the app calling this method.
3898     * @param sourceUserId The source user id.
3899     * @hide
3900     */
3901    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
3902
3903    /**
3904     * @hide
3905     */
3906    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
3907
3908    /** {@hide} */
3909    public abstract boolean isPackageAvailable(String packageName);
3910
3911    /** {@hide} */
3912    public static String installStatusToString(int status, String msg) {
3913        final String str = installStatusToString(status);
3914        if (msg != null) {
3915            return str + ": " + msg;
3916        } else {
3917            return str;
3918        }
3919    }
3920
3921    /** {@hide} */
3922    public static String installStatusToString(int status) {
3923        switch (status) {
3924            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
3925            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
3926            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
3927            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
3928            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
3929            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
3930            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
3931            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
3932            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
3933            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
3934            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
3935            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
3936            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
3937            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
3938            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
3939            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
3940            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
3941            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
3942            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
3943            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
3944            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
3945            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
3946            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
3947            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
3948            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
3949            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
3950            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
3951            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
3952            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
3953            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
3954            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
3955            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
3956            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
3957            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
3958            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
3959            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
3960            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
3961            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
3962            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
3963            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
3964            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
3965            default: return Integer.toString(status);
3966        }
3967    }
3968
3969    /** {@hide} */
3970    public static int installStatusToPublicStatus(int status) {
3971        switch (status) {
3972            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
3973            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3974            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
3975            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
3976            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
3977            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3978            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3979            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3980            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3981            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3982            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3983            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
3984            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3985            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
3986            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3987            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
3988            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3989            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
3990            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
3991            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
3992            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
3993            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
3994            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
3995            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
3996            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
3997            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
3998            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
3999            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
4000            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
4001            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4002            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4003            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
4004            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
4005            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
4006            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
4007            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
4008            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4009            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4010            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4011            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4012            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4013            default: return PackageInstaller.STATUS_FAILURE;
4014        }
4015    }
4016
4017    /** {@hide} */
4018    public static String deleteStatusToString(int status, String msg) {
4019        final String str = deleteStatusToString(status);
4020        if (msg != null) {
4021            return str + ": " + msg;
4022        } else {
4023            return str;
4024        }
4025    }
4026
4027    /** {@hide} */
4028    public static String deleteStatusToString(int status) {
4029        switch (status) {
4030            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
4031            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
4032            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
4033            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
4034            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
4035            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
4036            default: return Integer.toString(status);
4037        }
4038    }
4039
4040    /** {@hide} */
4041    public static int deleteStatusToPublicStatus(int status) {
4042        switch (status) {
4043            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4044            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4045            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4046            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4047            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4048            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4049            default: return PackageInstaller.STATUS_FAILURE;
4050        }
4051    }
4052
4053    /** {@hide} */
4054    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
4055        private final IPackageInstallObserver mLegacy;
4056
4057        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
4058            mLegacy = legacy;
4059        }
4060
4061        @Override
4062        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
4063                Bundle extras) {
4064            if (mLegacy == null) return;
4065            try {
4066                mLegacy.packageInstalled(basePackageName, returnCode);
4067            } catch (RemoteException ignored) {
4068            }
4069        }
4070    }
4071
4072    /** {@hide} */
4073    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
4074        private final IPackageDeleteObserver mLegacy;
4075
4076        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
4077            mLegacy = legacy;
4078        }
4079
4080        @Override
4081        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
4082            if (mLegacy == null) return;
4083            try {
4084                mLegacy.packageDeleted(basePackageName, returnCode);
4085            } catch (RemoteException ignored) {
4086            }
4087        }
4088    }
4089}
4090