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