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