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