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