PackageManager.java revision e22fe9331ad8a9f81470751fdeca7633f654cffa
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.util.AndroidException;
31import android.util.DisplayMetrics;
32
33import java.io.File;
34import java.util.List;
35
36/**
37 * Class for retrieving various kinds of information related to the application
38 * packages that are currently installed on the device.
39 *
40 * You can find this class through {@link Context#getPackageManager}.
41 */
42public abstract class PackageManager {
43
44    /**
45     * This exception is thrown when a given package, application, or component
46     * name can not be found.
47     */
48    public static class NameNotFoundException extends AndroidException {
49        public NameNotFoundException() {
50        }
51
52        public NameNotFoundException(String name) {
53            super(name);
54        }
55    }
56
57    /**
58     * {@link PackageInfo} flag: return information about
59     * activities in the package in {@link PackageInfo#activities}.
60     */
61    public static final int GET_ACTIVITIES              = 0x00000001;
62
63    /**
64     * {@link PackageInfo} flag: return information about
65     * intent receivers in the package in
66     * {@link PackageInfo#receivers}.
67     */
68    public static final int GET_RECEIVERS               = 0x00000002;
69
70    /**
71     * {@link PackageInfo} flag: return information about
72     * services in the package in {@link PackageInfo#services}.
73     */
74    public static final int GET_SERVICES                = 0x00000004;
75
76    /**
77     * {@link PackageInfo} flag: return information about
78     * content providers in the package in
79     * {@link PackageInfo#providers}.
80     */
81    public static final int GET_PROVIDERS               = 0x00000008;
82
83    /**
84     * {@link PackageInfo} flag: return information about
85     * instrumentation in the package in
86     * {@link PackageInfo#instrumentation}.
87     */
88    public static final int GET_INSTRUMENTATION         = 0x00000010;
89
90    /**
91     * {@link PackageInfo} flag: return information about the
92     * intent filters supported by the activity.
93     */
94    public static final int GET_INTENT_FILTERS          = 0x00000020;
95
96    /**
97     * {@link PackageInfo} flag: return information about the
98     * signatures included in the package.
99     */
100    public static final int GET_SIGNATURES          = 0x00000040;
101
102    /**
103     * {@link ResolveInfo} flag: return the IntentFilter that
104     * was matched for a particular ResolveInfo in
105     * {@link ResolveInfo#filter}.
106     */
107    public static final int GET_RESOLVED_FILTER         = 0x00000040;
108
109    /**
110     * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
111     * data {@link android.os.Bundle}s that are associated with a component.
112     * This applies for any API returning a ComponentInfo subclass.
113     */
114    public static final int GET_META_DATA               = 0x00000080;
115
116    /**
117     * {@link PackageInfo} flag: return the
118     * {@link PackageInfo#gids group ids} that are associated with an
119     * application.
120     * This applies for any API returning an PackageInfo class, either
121     * directly or nested inside of another.
122     */
123    public static final int GET_GIDS                    = 0x00000100;
124
125    /**
126     * {@link PackageInfo} flag: include disabled components in the returned info.
127     */
128    public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
129
130    /**
131     * {@link ApplicationInfo} flag: return the
132     * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
133     * that are associated with an application.
134     * This applies for any API returning an ApplicationInfo class, either
135     * directly or nested inside of another.
136     */
137    public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
138
139    /**
140     * {@link ProviderInfo} flag: return the
141     * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
142     * that are associated with a content provider.
143     * This applies for any API returning an ProviderInfo class, either
144     * directly or nested inside of another.
145     */
146    public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
147    /**
148     * {@link PackageInfo} flag: return information about
149     * permissions in the package in
150     * {@link PackageInfo#permissions}.
151     */
152    public static final int GET_PERMISSIONS               = 0x00001000;
153
154    /**
155     * Flag parameter to retrieve all applications(even uninstalled ones) with data directories.
156     * This state could have resulted if applications have been deleted with flag
157     * DONT_DELETE_DATA
158     * with a possibility of being replaced or reinstalled in future
159     */
160    public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
161
162    /**
163     * {@link PackageInfo} flag: return information about
164     * hardware preferences in
165     * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
166     * requested features in {@link PackageInfo#reqFeatures
167     * PackageInfo.reqFeatures}.
168     */
169    public static final int GET_CONFIGURATIONS = 0x00004000;
170
171    /**
172     * Resolution and querying flag: if set, only filters that support the
173     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
174     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
175     * supplied Intent.
176     */
177    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
178
179    /**
180     * Permission check result: this is returned by {@link #checkPermission}
181     * if the permission has been granted to the given package.
182     */
183    public static final int PERMISSION_GRANTED = 0;
184
185    /**
186     * Permission check result: this is returned by {@link #checkPermission}
187     * if the permission has not been granted to the given package.
188     */
189    public static final int PERMISSION_DENIED = -1;
190
191    /**
192     * Signature check result: this is returned by {@link #checkSignatures}
193     * if all signatures on the two packages match.
194     */
195    public static final int SIGNATURE_MATCH = 0;
196
197    /**
198     * Signature check result: this is returned by {@link #checkSignatures}
199     * if neither of the two packages is signed.
200     */
201    public static final int SIGNATURE_NEITHER_SIGNED = 1;
202
203    /**
204     * Signature check result: this is returned by {@link #checkSignatures}
205     * if the first package is not signed but the second is.
206     */
207    public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
208
209    /**
210     * Signature check result: this is returned by {@link #checkSignatures}
211     * if the second package is not signed but the first is.
212     */
213    public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
214
215    /**
216     * Signature check result: this is returned by {@link #checkSignatures}
217     * if not all signatures on both packages match.
218     */
219    public static final int SIGNATURE_NO_MATCH = -3;
220
221    /**
222     * Signature check result: this is returned by {@link #checkSignatures}
223     * if either of the packages are not valid.
224     */
225    public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
226
227    public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
228    public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
229    public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
230
231    /**
232     * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
233     * indicate that this package should be installed as forward locked, i.e. only the app itself
234     * should have access to its code and non-resource assets.
235     * @hide
236     */
237    public static final int INSTALL_FORWARD_LOCK = 0x00000001;
238
239    /**
240     * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
241     * installed package, if one exists.
242     * @hide
243     */
244    public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
245
246    /**
247     * Flag parameter for {@link #installPackage} to indicate that you want to
248     * allow test packages (those that have set android:testOnly in their
249     * manifest) to be installed.
250     * @hide
251     */
252    public static final int INSTALL_ALLOW_TEST = 0x00000004;
253
254    /**
255     * Flag parameter for {@link #installPackage} to indicate that this
256     * package has to be installed on the sdcard.
257     * @hide
258     */
259    public static final int INSTALL_EXTERNAL = 0x00000008;
260
261    /**
262    * Flag parameter for {@link #installPackage} to indicate that this
263    * package has to be installed on the sdcard.
264    * @hide
265    */
266   public static final int INSTALL_INTERNAL = 0x00000010;
267
268    /**
269     * Flag parameter for
270     * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
271     * that you don't want to kill the app containing the component.  Be careful when you set this
272     * since changing component states can make the containing application's behavior unpredictable.
273     */
274    public static final int DONT_KILL_APP = 0x00000001;
275
276    /**
277     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
278     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
279     * @hide
280     */
281    public static final int INSTALL_SUCCEEDED = 1;
282
283    /**
284     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
285     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
286     * already installed.
287     * @hide
288     */
289    public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
290
291    /**
292     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
293     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
294     * file is invalid.
295     * @hide
296     */
297    public static final int INSTALL_FAILED_INVALID_APK = -2;
298
299    /**
300     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
301     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
302     * is invalid.
303     * @hide
304     */
305    public static final int INSTALL_FAILED_INVALID_URI = -3;
306
307    /**
308     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
309     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
310     * service found that the device didn't have enough storage space to install the app.
311     * @hide
312     */
313    public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
314
315    /**
316     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
317     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
318     * package is already installed with the same name.
319     * @hide
320     */
321    public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
322
323    /**
324     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
325     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
326     * the requested shared user does not exist.
327     * @hide
328     */
329    public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
330
331    /**
332     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
333     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
334     * a previously installed package of the same name has a different signature
335     * than the new package (and the old package's data was not removed).
336     * @hide
337     */
338    public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
339
340    /**
341     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
342     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
343     * the new package is requested a shared user which is already installed on the
344     * device and does not have matching signature.
345     * @hide
346     */
347    public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
348
349    /**
350     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
351     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
352     * the new package uses a shared library that is not available.
353     * @hide
354     */
355    public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
356
357    /**
358     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
359     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
360     * the new package uses a shared library that is not available.
361     * @hide
362     */
363    public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
364
365    /**
366     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
367     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
368     * the new package failed while optimizing and validating its dex files,
369     * either because there was not enough storage or the validation failed.
370     * @hide
371     */
372    public static final int INSTALL_FAILED_DEXOPT = -11;
373
374    /**
375     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
376     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
377     * the new package failed because the current SDK version is older than
378     * that required by the package.
379     * @hide
380     */
381    public static final int INSTALL_FAILED_OLDER_SDK = -12;
382
383    /**
384     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
385     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
386     * the new package failed because it contains a content provider with the
387     * same authority as a provider already installed in the system.
388     * @hide
389     */
390    public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
391
392    /**
393     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
394     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
395     * the new package failed because the current SDK version is newer than
396     * that required by the package.
397     * @hide
398     */
399    public static final int INSTALL_FAILED_NEWER_SDK = -14;
400
401    /**
402     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
403     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
404     * the new package failed because it has specified that it is a test-only
405     * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
406     * flag.
407     * @hide
408     */
409    public static final int INSTALL_FAILED_TEST_ONLY = -15;
410
411    /**
412     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
413     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
414     * the package being installed contains native code, but none that is
415     * compatible with the the device's CPU_ABI.
416     * @hide
417     */
418    public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
419
420    /**
421     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
422     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
423     * the new package uses a feature that is not available.
424     * @hide
425     */
426    public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
427
428    // ------ Errors related to sdcard
429    /**
430     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
431     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
432     * a secure container mount point couldn't be accessed on external media.
433     * @hide
434     */
435    public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
436
437    /**
438     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
439     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
440     * the new package couldn't be installed in the specified install
441     * location.
442     * @hide
443     */
444    public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
445
446    /**
447     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
448     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
449     * the new package couldn't be installed in the specified install
450     * location because the media is not available.
451     * @hide
452     */
453    public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
454
455    /**
456     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
457     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
458     * if the parser was given a path that is not a file, or does not end with the expected
459     * '.apk' extension.
460     * @hide
461     */
462    public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
463
464    /**
465     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
466     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
467     * if the parser was unable to retrieve the AndroidManifest.xml file.
468     * @hide
469     */
470    public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
471
472    /**
473     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
474     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
475     * if the parser encountered an unexpected exception.
476     * @hide
477     */
478    public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
479
480    /**
481     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
482     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
483     * if the parser did not find any certificates in the .apk.
484     * @hide
485     */
486    public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
487
488    /**
489     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
490     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
491     * if the parser found inconsistent certificates on the files in the .apk.
492     * @hide
493     */
494    public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
495
496    /**
497     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
498     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
499     * if the parser encountered a CertificateEncodingException in one of the
500     * files in the .apk.
501     * @hide
502     */
503    public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
504
505    /**
506     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
507     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
508     * if the parser encountered a bad or missing package name in the manifest.
509     * @hide
510     */
511    public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
512
513    /**
514     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
515     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
516     * if the parser encountered a bad shared user id name in the manifest.
517     * @hide
518     */
519    public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
520
521    /**
522     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
523     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
524     * if the parser encountered some structural problem in the manifest.
525     * @hide
526     */
527    public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
528
529    /**
530     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
531     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
532     * if the parser did not find any actionable tags (instrumentation or application)
533     * in the manifest.
534     * @hide
535     */
536    public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
537
538    /**
539     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
540     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
541     * if the system failed to install the package because of system issues.
542     * @hide
543     */
544    public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
545
546    /**
547     * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
548     * package's data directory.
549     *
550     * @hide
551     */
552    public static final int DONT_DELETE_DATA = 0x00000001;
553
554    /**
555     * Return code for when package deletion succeeds. This is passed to the
556     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
557     * succeeded in deleting the package.
558     *
559     * @hide
560     */
561    public static final int DELETE_SUCCEEDED = 1;
562
563    /**
564     * Deletion failed return code: this is passed to the
565     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
566     * failed to delete the package for an unspecified reason.
567     *
568     * @hide
569     */
570    public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
571
572    /**
573     * Deletion failed return code: this is passed to the
574     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
575     * failed to delete the package because it is the active DevicePolicy
576     * manager.
577     *
578     * @hide
579     */
580    public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
581
582    /**
583     * Return code that is passed to the {@link IPackageMoveObserver} by
584     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
585     * package has been successfully moved by the system.
586     *
587     * @hide
588     */
589    public static final int MOVE_SUCCEEDED = 1;
590    /**
591     * Error code that is passed to the {@link IPackageMoveObserver} by
592     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
593     * when the package hasn't been successfully moved by the system
594     * because of insufficient memory on specified media.
595     * @hide
596     */
597    public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
598
599    /**
600     * Error code that is passed to the {@link IPackageMoveObserver} by
601     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
602     * if the specified package doesn't exist.
603     * @hide
604     */
605    public static final int MOVE_FAILED_DOESNT_EXIST = -2;
606
607    /**
608     * Error code that is passed to the {@link IPackageMoveObserver} by
609     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
610     * if the specified package cannot be moved since its a system package.
611     * @hide
612     */
613    public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
614
615    /**
616     * Error code that is passed to the {@link IPackageMoveObserver} by
617     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
618     * if the specified package cannot be moved since its forward locked.
619     * @hide
620     */
621    public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
622
623    /**
624     * Error code that is passed to the {@link IPackageMoveObserver} by
625     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
626     * if the specified package cannot be moved to the specified location.
627     * @hide
628     */
629    public static final int MOVE_FAILED_INVALID_LOCATION = -5;
630
631    /**
632     * Error code that is passed to the {@link IPackageMoveObserver} by
633     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
634     * if the specified package cannot be moved to the specified location.
635     * @hide
636     */
637    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
638
639    /**
640     * Error code that is passed to the {@link IPackageMoveObserver} by
641     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
642     * specified package already has an operation pending in the
643     * {@link PackageHandler} queue.
644     *
645     * @hide
646     */
647    public static final int MOVE_FAILED_OPERATION_PENDING = -7;
648
649    /**
650     * Flag parameter for {@link #movePackage} to indicate that
651     * the package should be moved to internal storage if its
652     * been installed on external media.
653     * @hide
654     */
655    public static final int MOVE_INTERNAL = 0x00000001;
656
657    /**
658     * Flag parameter for {@link #movePackage} to indicate that
659     * the package should be moved to external media.
660     * @hide
661     */
662    public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
663
664    /**
665     * Feature for {@link #getSystemAvailableFeatures} and
666     * {@link #hasSystemFeature}: The device's audio pipeline is low-latency,
667     * more suitable for audio applications sensitive to delays or lag in
668     * sound input or output.
669     */
670    @SdkConstant(SdkConstantType.FEATURE)
671    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
672
673    /**
674     * Feature for {@link #getSystemAvailableFeatures} and
675     * {@link #hasSystemFeature}: The device is capable of communicating with
676     * other devices via Bluetooth.
677     */
678    @SdkConstant(SdkConstantType.FEATURE)
679    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
680
681    /**
682     * Feature for {@link #getSystemAvailableFeatures} and
683     * {@link #hasSystemFeature}: The device has a camera facing away
684     * from the screen.
685     */
686    @SdkConstant(SdkConstantType.FEATURE)
687    public static final String FEATURE_CAMERA = "android.hardware.camera";
688
689    /**
690     * Feature for {@link #getSystemAvailableFeatures} and
691     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
692     */
693    @SdkConstant(SdkConstantType.FEATURE)
694    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
695
696    /**
697     * Feature for {@link #getSystemAvailableFeatures} and
698     * {@link #hasSystemFeature}: The device's camera supports flash.
699     */
700    @SdkConstant(SdkConstantType.FEATURE)
701    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
702
703    /**
704     * Feature for {@link #getSystemAvailableFeatures} and
705     * {@link #hasSystemFeature}: The device has a front facing camera.
706     */
707    @SdkConstant(SdkConstantType.FEATURE)
708    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
709
710    /**
711     * Feature for {@link #getSystemAvailableFeatures} and
712     * {@link #hasSystemFeature}: The device supports one or more methods of
713     * reporting current location.
714     */
715    @SdkConstant(SdkConstantType.FEATURE)
716    public static final String FEATURE_LOCATION = "android.hardware.location";
717
718    /**
719     * Feature for {@link #getSystemAvailableFeatures} and
720     * {@link #hasSystemFeature}: The device has a Global Positioning System
721     * receiver and can report precise location.
722     */
723    @SdkConstant(SdkConstantType.FEATURE)
724    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
725
726    /**
727     * Feature for {@link #getSystemAvailableFeatures} and
728     * {@link #hasSystemFeature}: The device can report location with coarse
729     * accuracy using a network-based geolocation system.
730     */
731    @SdkConstant(SdkConstantType.FEATURE)
732    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
733
734    /**
735     * Feature for {@link #getSystemAvailableFeatures} and
736     * {@link #hasSystemFeature}: The device can record audio via a
737     * microphone.
738     */
739    @SdkConstant(SdkConstantType.FEATURE)
740    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
741
742    /**
743     * Feature for {@link #getSystemAvailableFeatures} and
744     * {@link #hasSystemFeature}: The device can communicate using Near-Field
745     * Communications (NFC).
746     */
747    @SdkConstant(SdkConstantType.FEATURE)
748    public static final String FEATURE_NFC = "android.hardware.nfc";
749
750    /**
751     * Feature for {@link #getSystemAvailableFeatures} and
752     * {@link #hasSystemFeature}: The device includes an accelerometer.
753     */
754    @SdkConstant(SdkConstantType.FEATURE)
755    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
756
757    /**
758     * Feature for {@link #getSystemAvailableFeatures} and
759     * {@link #hasSystemFeature}: The device includes a barometer (air
760     * pressure sensor.)
761     */
762    @SdkConstant(SdkConstantType.FEATURE)
763    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
764
765    /**
766     * Feature for {@link #getSystemAvailableFeatures} and
767     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
768     */
769    @SdkConstant(SdkConstantType.FEATURE)
770    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
771
772    /**
773     * Feature for {@link #getSystemAvailableFeatures} and
774     * {@link #hasSystemFeature}: The device includes a gyroscope.
775     */
776    @SdkConstant(SdkConstantType.FEATURE)
777    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
778
779    /**
780     * Feature for {@link #getSystemAvailableFeatures} and
781     * {@link #hasSystemFeature}: The device includes a light sensor.
782     */
783    @SdkConstant(SdkConstantType.FEATURE)
784    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
785
786    /**
787     * Feature for {@link #getSystemAvailableFeatures} and
788     * {@link #hasSystemFeature}: The device includes a proximity sensor.
789     */
790    @SdkConstant(SdkConstantType.FEATURE)
791    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
792
793    /**
794     * Feature for {@link #getSystemAvailableFeatures} and
795     * {@link #hasSystemFeature}: The device has a telephony radio with data
796     * communication support.
797     */
798    @SdkConstant(SdkConstantType.FEATURE)
799    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
800
801    /**
802     * Feature for {@link #getSystemAvailableFeatures} and
803     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
804     */
805    @SdkConstant(SdkConstantType.FEATURE)
806    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
807
808    /**
809     * Feature for {@link #getSystemAvailableFeatures} and
810     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
811     */
812    @SdkConstant(SdkConstantType.FEATURE)
813    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
814
815    /**
816     * Feature for {@link #getSystemAvailableFeatures} and
817     * {@link #hasSystemFeature}: The device supports connecting to USB devices
818     * as the USB host.
819     */
820    @SdkConstant(SdkConstantType.FEATURE)
821    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
822
823    /**
824     * Feature for {@link #getSystemAvailableFeatures} and
825     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
826     */
827    @SdkConstant(SdkConstantType.FEATURE)
828    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
829
830    /**
831     * Feature for {@link #getSystemAvailableFeatures} and
832     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
833     */
834    @SdkConstant(SdkConstantType.FEATURE)
835    public static final String FEATURE_SIP = "android.software.sip";
836
837    /**
838     * Feature for {@link #getSystemAvailableFeatures} and
839     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
840     */
841    @SdkConstant(SdkConstantType.FEATURE)
842    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
843
844    /**
845     * Feature for {@link #getSystemAvailableFeatures} and
846     * {@link #hasSystemFeature}: The device's display has a touch screen.
847     */
848    @SdkConstant(SdkConstantType.FEATURE)
849    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
850
851
852    /**
853     * Feature for {@link #getSystemAvailableFeatures} and
854     * {@link #hasSystemFeature}: The device's touch screen supports
855     * multitouch sufficient for basic two-finger gesture detection.
856     */
857    @SdkConstant(SdkConstantType.FEATURE)
858    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
859
860    /**
861     * Feature for {@link #getSystemAvailableFeatures} and
862     * {@link #hasSystemFeature}: The device's touch screen is capable of
863     * tracking two or more fingers fully independently.
864     */
865    @SdkConstant(SdkConstantType.FEATURE)
866    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
867
868    /**
869     * Feature for {@link #getSystemAvailableFeatures} and
870     * {@link #hasSystemFeature}: The device's touch screen is capable of
871     * tracking a full hand of fingers fully independently -- that is, 5 or
872     * more simultaneous independent pointers.
873     */
874    @SdkConstant(SdkConstantType.FEATURE)
875    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
876
877    /**
878     * Feature for {@link #getSystemAvailableFeatures} and
879     * {@link #hasSystemFeature}: The device does not have a touch screen, but
880     * does support touch emulation for basic events. For instance, the
881     * device might use a mouse or remote control to drive a cursor, and
882     * emulate basic touch pointer events like down, up, drag, etc. All
883     * devices that support android.hardware.touchscreen or a sub-feature are
884     * presumed to also support faketouch.
885     */
886    @SdkConstant(SdkConstantType.FEATURE)
887    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
888
889    /**
890     * Feature for {@link #getSystemAvailableFeatures} and
891     * {@link #hasSystemFeature}: The device does not have a touch screen, but
892     * does support touch emulation for basic events that supports distinct
893     * tracking of two or more fingers.  This is an extension of
894     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
895     * that unlike a distinct multitouch screen as defined by
896     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
897     * devices will not actually provide full two-finger gestures since the
898     * input is being transformed to cursor movement on the screen.  That is,
899     * single finger gestures will move a cursor; two-finger swipes will
900     * result in single-finger touch events; other two-finger gestures will
901     * result in the corresponding two-finger touch event.
902     */
903    @SdkConstant(SdkConstantType.FEATURE)
904    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
905
906    /**
907     * Feature for {@link #getSystemAvailableFeatures} and
908     * {@link #hasSystemFeature}: The device does not have a touch screen, but
909     * does support touch emulation for basic events that supports tracking
910     * a hand of fingers (5 or more fingers) fully independently.
911     * This is an extension of
912     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
913     * that unlike a multitouch screen as defined by
914     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
915     * gestures can be detected due to the limitations described for
916     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
917     */
918    @SdkConstant(SdkConstantType.FEATURE)
919    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
920
921    /**
922     * Feature for {@link #getSystemAvailableFeatures} and
923     * {@link #hasSystemFeature}: The device supports live wallpapers.
924     */
925    @SdkConstant(SdkConstantType.FEATURE)
926    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
927
928    /**
929     * Feature for {@link #getSystemAvailableFeatures} and
930     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
931     */
932    @SdkConstant(SdkConstantType.FEATURE)
933    public static final String FEATURE_WIFI = "android.hardware.wifi";
934
935    /**
936     * Action to external storage service to clean out removed apps.
937     * @hide
938     */
939    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
940            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
941
942    /**
943     * Retrieve overall information about an application package that is
944     * installed on the system.
945     *
946     * <p>Throws {@link NameNotFoundException} if a package with the given
947     * name can not be found on the system.
948     *
949     * @param packageName The full name (i.e. com.google.apps.contacts) of the
950     *                    desired package.
951
952     * @param flags Additional option flags. Use any combination of
953     * {@link #GET_ACTIVITIES},
954     * {@link #GET_GIDS},
955     * {@link #GET_CONFIGURATIONS},
956     * {@link #GET_INSTRUMENTATION},
957     * {@link #GET_PERMISSIONS},
958     * {@link #GET_PROVIDERS},
959     * {@link #GET_RECEIVERS},
960     * {@link #GET_SERVICES},
961     * {@link #GET_SIGNATURES},
962     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
963     *
964     * @return Returns a PackageInfo object containing information about the package.
965     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
966     *         found in the list of installed applications, the package information is
967     *         retrieved from the list of uninstalled applications(which includes
968     *         installed applications as well as applications
969     *         with data directory ie applications which had been
970     *         deleted with DONT_DELTE_DATA flag set).
971     *
972     * @see #GET_ACTIVITIES
973     * @see #GET_GIDS
974     * @see #GET_CONFIGURATIONS
975     * @see #GET_INSTRUMENTATION
976     * @see #GET_PERMISSIONS
977     * @see #GET_PROVIDERS
978     * @see #GET_RECEIVERS
979     * @see #GET_SERVICES
980     * @see #GET_SIGNATURES
981     * @see #GET_UNINSTALLED_PACKAGES
982     *
983     */
984    public abstract PackageInfo getPackageInfo(String packageName, int flags)
985            throws NameNotFoundException;
986
987    /**
988     * Map from the current package names in use on the device to whatever
989     * the current canonical name of that package is.
990     * @param names Array of current names to be mapped.
991     * @return Returns an array of the same size as the original, containing
992     * the canonical name for each package.
993     */
994    public abstract String[] currentToCanonicalPackageNames(String[] names);
995
996    /**
997     * Map from a packages canonical name to the current name in use on the device.
998     * @param names Array of new names to be mapped.
999     * @return Returns an array of the same size as the original, containing
1000     * the current name for each package.
1001     */
1002    public abstract String[] canonicalToCurrentPackageNames(String[] names);
1003
1004    /**
1005     * Return a "good" intent to launch a front-door activity in a package,
1006     * for use for example to implement an "open" button when browsing through
1007     * packages.  The current implementation will look first for a main
1008     * activity in the category {@link Intent#CATEGORY_INFO}, next for a
1009     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
1010     * null if neither are found.
1011     *
1012     * <p>Throws {@link NameNotFoundException} if a package with the given
1013     * name can not be found on the system.
1014     *
1015     * @param packageName The name of the package to inspect.
1016     *
1017     * @return Returns either a fully-qualified Intent that can be used to
1018     * launch the main activity in the package, or null if the package does
1019     * not contain such an activity.
1020     */
1021    public abstract Intent getLaunchIntentForPackage(String packageName);
1022
1023    /**
1024     * Return an array of all of the secondary group-ids that have been
1025     * assigned to a package.
1026     *
1027     * <p>Throws {@link NameNotFoundException} if a package with the given
1028     * name can not be found on the system.
1029     *
1030     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1031     *                    desired package.
1032     *
1033     * @return Returns an int array of the assigned gids, or null if there
1034     * are none.
1035     */
1036    public abstract int[] getPackageGids(String packageName)
1037            throws NameNotFoundException;
1038
1039    /**
1040     * Retrieve all of the information we know about a particular permission.
1041     *
1042     * <p>Throws {@link NameNotFoundException} if a permission with the given
1043     * name can not be found on the system.
1044     *
1045     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1046     *             of the permission you are interested in.
1047     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1048     * retrieve any meta-data associated with the permission.
1049     *
1050     * @return Returns a {@link PermissionInfo} containing information about the
1051     *         permission.
1052     */
1053    public abstract PermissionInfo getPermissionInfo(String name, int flags)
1054            throws NameNotFoundException;
1055
1056    /**
1057     * Query for all of the permissions associated with a particular group.
1058     *
1059     * <p>Throws {@link NameNotFoundException} if the given group does not
1060     * exist.
1061     *
1062     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1063     *             of the permission group you are interested in.  Use null to
1064     *             find all of the permissions not associated with a group.
1065     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1066     * retrieve any meta-data associated with the permissions.
1067     *
1068     * @return Returns a list of {@link PermissionInfo} containing information
1069     * about all of the permissions in the given group.
1070     */
1071    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1072            int flags) throws NameNotFoundException;
1073
1074    /**
1075     * Retrieve all of the information we know about a particular group of
1076     * permissions.
1077     *
1078     * <p>Throws {@link NameNotFoundException} if a permission group with the given
1079     * name can not be found on the system.
1080     *
1081     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1082     *             of the permission you are interested in.
1083     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1084     * retrieve any meta-data associated with the permission group.
1085     *
1086     * @return Returns a {@link PermissionGroupInfo} containing information
1087     * about the permission.
1088     */
1089    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1090            int flags) throws NameNotFoundException;
1091
1092    /**
1093     * Retrieve all of the known permission groups in the system.
1094     *
1095     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1096     * retrieve any meta-data associated with the permission group.
1097     *
1098     * @return Returns a list of {@link PermissionGroupInfo} containing
1099     * information about all of the known permission groups.
1100     */
1101    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1102
1103    /**
1104     * Retrieve all of the information we know about a particular
1105     * package/application.
1106     *
1107     * <p>Throws {@link NameNotFoundException} if an application with the given
1108     * package name can not be found on the system.
1109     *
1110     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1111     *                    application.
1112     * @param flags Additional option flags. Use any combination of
1113     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1114     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1115     *
1116     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1117     *         information about the package.
1118     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1119     *         found in the list of installed applications,
1120     *         the application information is retrieved from the
1121     *         list of uninstalled applications(which includes
1122     *         installed applications as well as applications
1123     *         with data directory ie applications which had been
1124     *         deleted with DONT_DELTE_DATA flag set).
1125     *
1126     * @see #GET_META_DATA
1127     * @see #GET_SHARED_LIBRARY_FILES
1128     * @see #GET_UNINSTALLED_PACKAGES
1129     */
1130    public abstract ApplicationInfo getApplicationInfo(String packageName,
1131            int flags) throws NameNotFoundException;
1132
1133    /**
1134     * Retrieve all of the information we know about a particular activity
1135     * class.
1136     *
1137     * <p>Throws {@link NameNotFoundException} if an activity with the given
1138     * class name can not be found on the system.
1139     *
1140     * @param component The full component name (i.e.
1141     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1142     * class.
1143     * @param flags Additional option flags. Use any combination of
1144     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1145     * to modify the data (in ApplicationInfo) returned.
1146     *
1147     * @return {@link ActivityInfo} containing information about the activity.
1148     *
1149     * @see #GET_INTENT_FILTERS
1150     * @see #GET_META_DATA
1151     * @see #GET_SHARED_LIBRARY_FILES
1152     */
1153    public abstract ActivityInfo getActivityInfo(ComponentName component,
1154            int flags) throws NameNotFoundException;
1155
1156    /**
1157     * Retrieve all of the information we know about a particular receiver
1158     * class.
1159     *
1160     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1161     * class name can not be found on the system.
1162     *
1163     * @param component The full component name (i.e.
1164     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1165     * class.
1166     * @param flags Additional option flags.  Use any combination of
1167     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1168     * to modify the data returned.
1169     *
1170     * @return {@link ActivityInfo} containing information about the receiver.
1171     *
1172     * @see #GET_INTENT_FILTERS
1173     * @see #GET_META_DATA
1174     * @see #GET_SHARED_LIBRARY_FILES
1175     */
1176    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1177            int flags) throws NameNotFoundException;
1178
1179    /**
1180     * Retrieve all of the information we know about a particular service
1181     * class.
1182     *
1183     * <p>Throws {@link NameNotFoundException} if a service with the given
1184     * class name can not be found on the system.
1185     *
1186     * @param component The full component name (i.e.
1187     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1188     * class.
1189     * @param flags Additional option flags.  Use any combination of
1190     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1191     * to modify the data returned.
1192     *
1193     * @return ServiceInfo containing information about the service.
1194     *
1195     * @see #GET_META_DATA
1196     * @see #GET_SHARED_LIBRARY_FILES
1197     */
1198    public abstract ServiceInfo getServiceInfo(ComponentName component,
1199            int flags) throws NameNotFoundException;
1200
1201    /**
1202     * Retrieve all of the information we know about a particular content
1203     * provider class.
1204     *
1205     * <p>Throws {@link NameNotFoundException} if a provider with the given
1206     * class name can not be found on the system.
1207     *
1208     * @param component The full component name (i.e.
1209     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1210     * ContentProvider class.
1211     * @param flags Additional option flags.  Use any combination of
1212     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1213     * to modify the data returned.
1214     *
1215     * @return ProviderInfo containing information about the service.
1216     *
1217     * @see #GET_META_DATA
1218     * @see #GET_SHARED_LIBRARY_FILES
1219     */
1220    public abstract ProviderInfo getProviderInfo(ComponentName component,
1221            int flags) throws NameNotFoundException;
1222
1223    /**
1224     * Return a List of all packages that are installed
1225     * on the device.
1226     *
1227     * @param flags Additional option flags. Use any combination of
1228     * {@link #GET_ACTIVITIES},
1229     * {@link #GET_GIDS},
1230     * {@link #GET_CONFIGURATIONS},
1231     * {@link #GET_INSTRUMENTATION},
1232     * {@link #GET_PERMISSIONS},
1233     * {@link #GET_PROVIDERS},
1234     * {@link #GET_RECEIVERS},
1235     * {@link #GET_SERVICES},
1236     * {@link #GET_SIGNATURES},
1237     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1238     *
1239     * @return A List of PackageInfo objects, one for each package that is
1240     *         installed on the device.  In the unlikely case of there being no
1241     *         installed packages, an empty list is returned.
1242     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1243     *         applications including those deleted with DONT_DELETE_DATA
1244     *         (partially installed apps with data directory) will be returned.
1245     *
1246     * @see #GET_ACTIVITIES
1247     * @see #GET_GIDS
1248     * @see #GET_CONFIGURATIONS
1249     * @see #GET_INSTRUMENTATION
1250     * @see #GET_PERMISSIONS
1251     * @see #GET_PROVIDERS
1252     * @see #GET_RECEIVERS
1253     * @see #GET_SERVICES
1254     * @see #GET_SIGNATURES
1255     * @see #GET_UNINSTALLED_PACKAGES
1256     *
1257     */
1258    public abstract List<PackageInfo> getInstalledPackages(int flags);
1259
1260    /**
1261     * Check whether a particular package has been granted a particular
1262     * permission.
1263     *
1264     * @param permName The name of the permission you are checking for,
1265     * @param pkgName The name of the package you are checking against.
1266     *
1267     * @return If the package has the permission, PERMISSION_GRANTED is
1268     * returned.  If it does not have the permission, PERMISSION_DENIED
1269     * is returned.
1270     *
1271     * @see #PERMISSION_GRANTED
1272     * @see #PERMISSION_DENIED
1273     */
1274    public abstract int checkPermission(String permName, String pkgName);
1275
1276    /**
1277     * Add a new dynamic permission to the system.  For this to work, your
1278     * package must have defined a permission tree through the
1279     * {@link android.R.styleable#AndroidManifestPermissionTree
1280     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
1281     * permissions to trees that were defined by either its own package or
1282     * another with the same user id; a permission is in a tree if it
1283     * matches the name of the permission tree + ".": for example,
1284     * "com.foo.bar" is a member of the permission tree "com.foo".
1285     *
1286     * <p>It is good to make your permission tree name descriptive, because you
1287     * are taking possession of that entire set of permission names.  Thus, it
1288     * must be under a domain you control, with a suffix that will not match
1289     * any normal permissions that may be declared in any applications that
1290     * are part of that domain.
1291     *
1292     * <p>New permissions must be added before
1293     * any .apks are installed that use those permissions.  Permissions you
1294     * add through this method are remembered across reboots of the device.
1295     * If the given permission already exists, the info you supply here
1296     * will be used to update it.
1297     *
1298     * @param info Description of the permission to be added.
1299     *
1300     * @return Returns true if a new permission was created, false if an
1301     * existing one was updated.
1302     *
1303     * @throws SecurityException if you are not allowed to add the
1304     * given permission name.
1305     *
1306     * @see #removePermission(String)
1307     */
1308    public abstract boolean addPermission(PermissionInfo info);
1309
1310    /**
1311     * Like {@link #addPermission(PermissionInfo)} but asynchronously
1312     * persists the package manager state after returning from the call,
1313     * allowing it to return quicker and batch a series of adds at the
1314     * expense of no guarantee the added permission will be retained if
1315     * the device is rebooted before it is written.
1316     */
1317    public abstract boolean addPermissionAsync(PermissionInfo info);
1318
1319    /**
1320     * Removes a permission that was previously added with
1321     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
1322     * -- you are only allowed to remove permissions that you are allowed
1323     * to add.
1324     *
1325     * @param name The name of the permission to remove.
1326     *
1327     * @throws SecurityException if you are not allowed to remove the
1328     * given permission name.
1329     *
1330     * @see #addPermission(PermissionInfo)
1331     */
1332    public abstract void removePermission(String name);
1333
1334    /**
1335     * Compare the signatures of two packages to determine if the same
1336     * signature appears in both of them.  If they do contain the same
1337     * signature, then they are allowed special privileges when working
1338     * with each other: they can share the same user-id, run instrumentation
1339     * against each other, etc.
1340     *
1341     * @param pkg1 First package name whose signature will be compared.
1342     * @param pkg2 Second package name whose signature will be compared.
1343     *
1344     * @return Returns an integer indicating whether all signatures on the
1345     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1346     * all signatures match or < 0 if there is not a match ({@link
1347     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1348     *
1349     * @see #checkSignatures(int, int)
1350     * @see #SIGNATURE_MATCH
1351     * @see #SIGNATURE_NO_MATCH
1352     * @see #SIGNATURE_UNKNOWN_PACKAGE
1353     */
1354    public abstract int checkSignatures(String pkg1, String pkg2);
1355
1356    /**
1357     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
1358     * the two packages to be checked.  This can be useful, for example,
1359     * when doing the check in an IPC, where the UID is the only identity
1360     * available.  It is functionally identical to determining the package
1361     * associated with the UIDs and checking their signatures.
1362     *
1363     * @param uid1 First UID whose signature will be compared.
1364     * @param uid2 Second UID whose signature will be compared.
1365     *
1366     * @return Returns an integer indicating whether all signatures on the
1367     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1368     * all signatures match or < 0 if there is not a match ({@link
1369     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1370     *
1371     * @see #checkSignatures(String, String)
1372     * @see #SIGNATURE_MATCH
1373     * @see #SIGNATURE_NO_MATCH
1374     * @see #SIGNATURE_UNKNOWN_PACKAGE
1375     */
1376    public abstract int checkSignatures(int uid1, int uid2);
1377
1378    /**
1379     * Retrieve the names of all packages that are associated with a particular
1380     * user id.  In most cases, this will be a single package name, the package
1381     * that has been assigned that user id.  Where there are multiple packages
1382     * sharing the same user id through the "sharedUserId" mechanism, all
1383     * packages with that id will be returned.
1384     *
1385     * @param uid The user id for which you would like to retrieve the
1386     * associated packages.
1387     *
1388     * @return Returns an array of one or more packages assigned to the user
1389     * id, or null if there are no known packages with the given id.
1390     */
1391    public abstract String[] getPackagesForUid(int uid);
1392
1393    /**
1394     * Retrieve the official name associated with a user id.  This name is
1395     * guaranteed to never change, though it is possibly for the underlying
1396     * user id to be changed.  That is, if you are storing information about
1397     * user ids in persistent storage, you should use the string returned
1398     * by this function instead of the raw user-id.
1399     *
1400     * @param uid The user id for which you would like to retrieve a name.
1401     * @return Returns a unique name for the given user id, or null if the
1402     * user id is not currently assigned.
1403     */
1404    public abstract String getNameForUid(int uid);
1405
1406    /**
1407     * Return the user id associated with a shared user name. Multiple
1408     * applications can specify a shared user name in their manifest and thus
1409     * end up using a common uid. This might be used for new applications
1410     * that use an existing shared user name and need to know the uid of the
1411     * shared user.
1412     *
1413     * @param sharedUserName The shared user name whose uid is to be retrieved.
1414     * @return Returns the uid associated with the shared user, or  NameNotFoundException
1415     * if the shared user name is not being used by any installed packages
1416     * @hide
1417     */
1418    public abstract int getUidForSharedUser(String sharedUserName)
1419            throws NameNotFoundException;
1420
1421    /**
1422     * Return a List of all application packages that are installed on the
1423     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
1424     * applications including those deleted with DONT_DELETE_DATA(partially
1425     * installed apps with data directory) will be returned.
1426     *
1427     * @param flags Additional option flags. Use any combination of
1428     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1429     * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1430     *
1431     * @return A List of ApplicationInfo objects, one for each application that
1432     *         is installed on the device.  In the unlikely case of there being
1433     *         no installed applications, an empty list is returned.
1434     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1435     *         applications including those deleted with DONT_DELETE_DATA
1436     *         (partially installed apps with data directory) will be returned.
1437     *
1438     * @see #GET_META_DATA
1439     * @see #GET_SHARED_LIBRARY_FILES
1440     * @see #GET_UNINSTALLED_PACKAGES
1441     */
1442    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
1443
1444    /**
1445     * Get a list of shared libraries that are available on the
1446     * system.
1447     *
1448     * @return An array of shared library names that are
1449     * available on the system, or null if none are installed.
1450     *
1451     */
1452    public abstract String[] getSystemSharedLibraryNames();
1453
1454    /**
1455     * Get a list of features that are available on the
1456     * system.
1457     *
1458     * @return An array of FeatureInfo classes describing the features
1459     * that are available on the system, or null if there are none(!!).
1460     */
1461    public abstract FeatureInfo[] getSystemAvailableFeatures();
1462
1463    /**
1464     * Check whether the given feature name is one of the available
1465     * features as returned by {@link #getSystemAvailableFeatures()}.
1466     *
1467     * @return Returns true if the devices supports the feature, else
1468     * false.
1469     */
1470    public abstract boolean hasSystemFeature(String name);
1471
1472    /**
1473     * Determine the best action to perform for a given Intent.  This is how
1474     * {@link Intent#resolveActivity} finds an activity if a class has not
1475     * been explicitly specified.
1476     *
1477     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
1478     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
1479     * only flag.  You need to do so to resolve the activity in the same way
1480     * that {@link android.content.Context#startActivity(Intent)} and
1481     * {@link android.content.Intent#resolveActivity(PackageManager)
1482     * Intent.resolveActivity(PackageManager)} do.</p>
1483     *
1484     * @param intent An intent containing all of the desired specification
1485     *               (action, data, type, category, and/or component).
1486     * @param flags Additional option flags.  The most important is
1487     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1488     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1489     *
1490     * @return Returns a ResolveInfo containing the final activity intent that
1491     *         was determined to be the best action.  Returns null if no
1492     *         matching activity was found. If multiple matching activities are
1493     *         found and there is no default set, returns a ResolveInfo
1494     *         containing something else, such as the activity resolver.
1495     *
1496     * @see #MATCH_DEFAULT_ONLY
1497     * @see #GET_INTENT_FILTERS
1498     * @see #GET_RESOLVED_FILTER
1499     */
1500    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1501
1502    /**
1503     * Retrieve all activities that can be performed for the given intent.
1504     *
1505     * @param intent The desired intent as per resolveActivity().
1506     * @param flags Additional option flags.  The most important is
1507     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1508     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1509     *
1510     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1511     *         Activity. These are ordered from best to worst match -- that
1512     *         is, the first item in the list is what is returned by
1513     *         {@link #resolveActivity}.  If there are no matching activities, an empty
1514     *         list is returned.
1515     *
1516     * @see #MATCH_DEFAULT_ONLY
1517     * @see #GET_INTENT_FILTERS
1518     * @see #GET_RESOLVED_FILTER
1519     */
1520    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
1521            int flags);
1522
1523    /**
1524     * Retrieve a set of activities that should be presented to the user as
1525     * similar options.  This is like {@link #queryIntentActivities}, except it
1526     * also allows you to supply a list of more explicit Intents that you would
1527     * like to resolve to particular options, and takes care of returning the
1528     * final ResolveInfo list in a reasonable order, with no duplicates, based
1529     * on those inputs.
1530     *
1531     * @param caller The class name of the activity that is making the
1532     *               request.  This activity will never appear in the output
1533     *               list.  Can be null.
1534     * @param specifics An array of Intents that should be resolved to the
1535     *                  first specific results.  Can be null.
1536     * @param intent The desired intent as per resolveActivity().
1537     * @param flags Additional option flags.  The most important is
1538     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1539     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1540     *
1541     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1542     *         Activity. These are ordered first by all of the intents resolved
1543     *         in <var>specifics</var> and then any additional activities that
1544     *         can handle <var>intent</var> but did not get included by one of
1545     *         the <var>specifics</var> intents.  If there are no matching
1546     *         activities, an empty list is returned.
1547     *
1548     * @see #MATCH_DEFAULT_ONLY
1549     * @see #GET_INTENT_FILTERS
1550     * @see #GET_RESOLVED_FILTER
1551     */
1552    public abstract List<ResolveInfo> queryIntentActivityOptions(
1553            ComponentName caller, Intent[] specifics, Intent intent, int flags);
1554
1555    /**
1556     * Retrieve all receivers that can handle a broadcast of the given intent.
1557     *
1558     * @param intent The desired intent as per resolveActivity().
1559     * @param flags Additional option flags.
1560     *
1561     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1562     *         Receiver. These are ordered from first to last in priority.  If
1563     *         there are no matching receivers, an empty list is returned.
1564     *
1565     * @see #MATCH_DEFAULT_ONLY
1566     * @see #GET_INTENT_FILTERS
1567     * @see #GET_RESOLVED_FILTER
1568     */
1569    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
1570            int flags);
1571
1572    /**
1573     * Determine the best service to handle for a given Intent.
1574     *
1575     * @param intent An intent containing all of the desired specification
1576     *               (action, data, type, category, and/or component).
1577     * @param flags Additional option flags.
1578     *
1579     * @return Returns a ResolveInfo containing the final service intent that
1580     *         was determined to be the best action.  Returns null if no
1581     *         matching service was found.
1582     *
1583     * @see #GET_INTENT_FILTERS
1584     * @see #GET_RESOLVED_FILTER
1585     */
1586    public abstract ResolveInfo resolveService(Intent intent, int flags);
1587
1588    /**
1589     * Retrieve all services that can match the given intent.
1590     *
1591     * @param intent The desired intent as per resolveService().
1592     * @param flags Additional option flags.
1593     *
1594     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1595     *         ServiceInfo. These are ordered from best to worst match -- that
1596     *         is, the first item in the list is what is returned by
1597     *         resolveService().  If there are no matching services, an empty
1598     *         list is returned.
1599     *
1600     * @see #GET_INTENT_FILTERS
1601     * @see #GET_RESOLVED_FILTER
1602     */
1603    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
1604            int flags);
1605
1606    /**
1607     * Find a single content provider by its base path name.
1608     *
1609     * @param name The name of the provider to find.
1610     * @param flags Additional option flags.  Currently should always be 0.
1611     *
1612     * @return ContentProviderInfo Information about the provider, if found,
1613     *         else null.
1614     */
1615    public abstract ProviderInfo resolveContentProvider(String name,
1616            int flags);
1617
1618    /**
1619     * Retrieve content provider information.
1620     *
1621     * <p><em>Note: unlike most other methods, an empty result set is indicated
1622     * by a null return instead of an empty list.</em>
1623     *
1624     * @param processName If non-null, limits the returned providers to only
1625     *                    those that are hosted by the given process.  If null,
1626     *                    all content providers are returned.
1627     * @param uid If <var>processName</var> is non-null, this is the required
1628     *        uid owning the requested content providers.
1629     * @param flags Additional option flags.  Currently should always be 0.
1630     *
1631     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
1632     *         content provider either patching <var>processName</var> or, if
1633     *         <var>processName</var> is null, all known content providers.
1634     *         <em>If there are no matching providers, null is returned.</em>
1635     */
1636    public abstract List<ProviderInfo> queryContentProviders(
1637            String processName, int uid, int flags);
1638
1639    /**
1640     * Retrieve all of the information we know about a particular
1641     * instrumentation class.
1642     *
1643     * <p>Throws {@link NameNotFoundException} if instrumentation with the
1644     * given class name can not be found on the system.
1645     *
1646     * @param className The full name (i.e.
1647     *                  com.google.apps.contacts.InstrumentList) of an
1648     *                  Instrumentation class.
1649     * @param flags Additional option flags.  Currently should always be 0.
1650     *
1651     * @return InstrumentationInfo containing information about the
1652     *         instrumentation.
1653     */
1654    public abstract InstrumentationInfo getInstrumentationInfo(
1655            ComponentName className, int flags) throws NameNotFoundException;
1656
1657    /**
1658     * Retrieve information about available instrumentation code.  May be used
1659     * to retrieve either all instrumentation code, or only the code targeting
1660     * a particular package.
1661     *
1662     * @param targetPackage If null, all instrumentation is returned; only the
1663     *                      instrumentation targeting this package name is
1664     *                      returned.
1665     * @param flags Additional option flags.  Currently should always be 0.
1666     *
1667     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
1668     *         matching available Instrumentation.  Returns an empty list if
1669     *         there is no instrumentation available for the given package.
1670     */
1671    public abstract List<InstrumentationInfo> queryInstrumentation(
1672            String targetPackage, int flags);
1673
1674    /**
1675     * Retrieve an image from a package.  This is a low-level API used by
1676     * the various package manager info structures (such as
1677     * {@link ComponentInfo} to implement retrieval of their associated
1678     * icon.
1679     *
1680     * @param packageName The name of the package that this icon is coming from.
1681     * Can not be null.
1682     * @param resid The resource identifier of the desired image.  Can not be 0.
1683     * @param appInfo Overall information about <var>packageName</var>.  This
1684     * may be null, in which case the application information will be retrieved
1685     * for you if needed; if you already have this information around, it can
1686     * be much more efficient to supply it here.
1687     *
1688     * @return Returns a Drawable holding the requested image.  Returns null if
1689     * an image could not be found for any reason.
1690     */
1691    public abstract Drawable getDrawable(String packageName, int resid,
1692            ApplicationInfo appInfo);
1693
1694    /**
1695     * Retrieve the icon associated with an activity.  Given the full name of
1696     * an activity, retrieves the information about it and calls
1697     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
1698     * If the activity can not be found, NameNotFoundException is thrown.
1699     *
1700     * @param activityName Name of the activity whose icon is to be retrieved.
1701     *
1702     * @return Returns the image of the icon, or the default activity icon if
1703     * it could not be found.  Does not return null.
1704     * @throws NameNotFoundException Thrown if the resources for the given
1705     * activity could not be loaded.
1706     *
1707     * @see #getActivityIcon(Intent)
1708     */
1709    public abstract Drawable getActivityIcon(ComponentName activityName)
1710            throws NameNotFoundException;
1711
1712    /**
1713     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
1714     * set, this simply returns the result of
1715     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
1716     * component and returns the icon associated with the resolved component.
1717     * If intent.getClassName() can not be found or the Intent can not be resolved
1718     * to a component, NameNotFoundException is thrown.
1719     *
1720     * @param intent The intent for which you would like to retrieve an icon.
1721     *
1722     * @return Returns the image of the icon, or the default activity icon if
1723     * it could not be found.  Does not return null.
1724     * @throws NameNotFoundException Thrown if the resources for application
1725     * matching the given intent could not be loaded.
1726     *
1727     * @see #getActivityIcon(ComponentName)
1728     */
1729    public abstract Drawable getActivityIcon(Intent intent)
1730            throws NameNotFoundException;
1731
1732    /**
1733     * Return the generic icon for an activity that is used when no specific
1734     * icon is defined.
1735     *
1736     * @return Drawable Image of the icon.
1737     */
1738    public abstract Drawable getDefaultActivityIcon();
1739
1740    /**
1741     * Retrieve the icon associated with an application.  If it has not defined
1742     * an icon, the default app icon is returned.  Does not return null.
1743     *
1744     * @param info Information about application being queried.
1745     *
1746     * @return Returns the image of the icon, or the default application icon
1747     * if it could not be found.
1748     *
1749     * @see #getApplicationIcon(String)
1750     */
1751    public abstract Drawable getApplicationIcon(ApplicationInfo info);
1752
1753    /**
1754     * Retrieve the icon associated with an application.  Given the name of the
1755     * application's package, retrieves the information about it and calls
1756     * getApplicationIcon() to return its icon. If the application can not be
1757     * found, NameNotFoundException is thrown.
1758     *
1759     * @param packageName Name of the package whose application icon is to be
1760     *                    retrieved.
1761     *
1762     * @return Returns the image of the icon, or the default application icon
1763     * if it could not be found.  Does not return null.
1764     * @throws NameNotFoundException Thrown if the resources for the given
1765     * application could not be loaded.
1766     *
1767     * @see #getApplicationIcon(ApplicationInfo)
1768     */
1769    public abstract Drawable getApplicationIcon(String packageName)
1770            throws NameNotFoundException;
1771
1772    /**
1773     * Retrieve the logo associated with an activity.  Given the full name of
1774     * an activity, retrieves the information about it and calls
1775     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
1776     * If the activity can not be found, NameNotFoundException is thrown.
1777     *
1778     * @param activityName Name of the activity whose logo is to be retrieved.
1779     *
1780     * @return Returns the image of the logo or null if the activity has no
1781     * logo specified.
1782     *
1783     * @throws NameNotFoundException Thrown if the resources for the given
1784     * activity could not be loaded.
1785     *
1786     * @see #getActivityLogo(Intent)
1787     */
1788    public abstract Drawable getActivityLogo(ComponentName activityName)
1789            throws NameNotFoundException;
1790
1791    /**
1792     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
1793     * set, this simply returns the result of
1794     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
1795     * component and returns the logo associated with the resolved component.
1796     * If intent.getClassName() can not be found or the Intent can not be resolved
1797     * to a component, NameNotFoundException is thrown.
1798     *
1799     * @param intent The intent for which you would like to retrieve a logo.
1800     *
1801     * @return Returns the image of the logo, or null if the activity has no
1802     * logo specified.
1803     *
1804     * @throws NameNotFoundException Thrown if the resources for application
1805     * matching the given intent could not be loaded.
1806     *
1807     * @see #getActivityLogo(ComponentName)
1808     */
1809    public abstract Drawable getActivityLogo(Intent intent)
1810            throws NameNotFoundException;
1811
1812    /**
1813     * Retrieve the logo associated with an application.  If it has not specified
1814     * a logo, this method returns null.
1815     *
1816     * @param info Information about application being queried.
1817     *
1818     * @return Returns the image of the logo, or null if no logo is specified
1819     * by the application.
1820     *
1821     * @see #getApplicationLogo(String)
1822     */
1823    public abstract Drawable getApplicationLogo(ApplicationInfo info);
1824
1825    /**
1826     * Retrieve the logo associated with an application.  Given the name of the
1827     * application's package, retrieves the information about it and calls
1828     * getApplicationLogo() to return its logo. If the application can not be
1829     * found, NameNotFoundException is thrown.
1830     *
1831     * @param packageName Name of the package whose application logo is to be
1832     *                    retrieved.
1833     *
1834     * @return Returns the image of the logo, or null if no application logo
1835     * has been specified.
1836     *
1837     * @throws NameNotFoundException Thrown if the resources for the given
1838     * application could not be loaded.
1839     *
1840     * @see #getApplicationLogo(ApplicationInfo)
1841     */
1842    public abstract Drawable getApplicationLogo(String packageName)
1843            throws NameNotFoundException;
1844
1845    /**
1846     * Retrieve text from a package.  This is a low-level API used by
1847     * the various package manager info structures (such as
1848     * {@link ComponentInfo} to implement retrieval of their associated
1849     * labels and other text.
1850     *
1851     * @param packageName The name of the package that this text is coming from.
1852     * Can not be null.
1853     * @param resid The resource identifier of the desired text.  Can not be 0.
1854     * @param appInfo Overall information about <var>packageName</var>.  This
1855     * may be null, in which case the application information will be retrieved
1856     * for you if needed; if you already have this information around, it can
1857     * be much more efficient to supply it here.
1858     *
1859     * @return Returns a CharSequence holding the requested text.  Returns null
1860     * if the text could not be found for any reason.
1861     */
1862    public abstract CharSequence getText(String packageName, int resid,
1863            ApplicationInfo appInfo);
1864
1865    /**
1866     * Retrieve an XML file from a package.  This is a low-level API used to
1867     * retrieve XML meta data.
1868     *
1869     * @param packageName The name of the package that this xml is coming from.
1870     * Can not be null.
1871     * @param resid The resource identifier of the desired xml.  Can not be 0.
1872     * @param appInfo Overall information about <var>packageName</var>.  This
1873     * may be null, in which case the application information will be retrieved
1874     * for you if needed; if you already have this information around, it can
1875     * be much more efficient to supply it here.
1876     *
1877     * @return Returns an XmlPullParser allowing you to parse out the XML
1878     * data.  Returns null if the xml resource could not be found for any
1879     * reason.
1880     */
1881    public abstract XmlResourceParser getXml(String packageName, int resid,
1882            ApplicationInfo appInfo);
1883
1884    /**
1885     * Return the label to use for this application.
1886     *
1887     * @return Returns the label associated with this application, or null if
1888     * it could not be found for any reason.
1889     * @param info The application to get the label of
1890     */
1891    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
1892
1893    /**
1894     * Retrieve the resources associated with an activity.  Given the full
1895     * name of an activity, retrieves the information about it and calls
1896     * getResources() to return its application's resources.  If the activity
1897     * can not be found, NameNotFoundException is thrown.
1898     *
1899     * @param activityName Name of the activity whose resources are to be
1900     *                     retrieved.
1901     *
1902     * @return Returns the application's Resources.
1903     * @throws NameNotFoundException Thrown if the resources for the given
1904     * application could not be loaded.
1905     *
1906     * @see #getResourcesForApplication(ApplicationInfo)
1907     */
1908    public abstract Resources getResourcesForActivity(ComponentName activityName)
1909            throws NameNotFoundException;
1910
1911    /**
1912     * Retrieve the resources for an application.  Throws NameNotFoundException
1913     * if the package is no longer installed.
1914     *
1915     * @param app Information about the desired application.
1916     *
1917     * @return Returns the application's Resources.
1918     * @throws NameNotFoundException Thrown if the resources for the given
1919     * application could not be loaded (most likely because it was uninstalled).
1920     */
1921    public abstract Resources getResourcesForApplication(ApplicationInfo app)
1922            throws NameNotFoundException;
1923
1924    /**
1925     * Retrieve the resources associated with an application.  Given the full
1926     * package name of an application, retrieves the information about it and
1927     * calls getResources() to return its application's resources.  If the
1928     * appPackageName can not be found, NameNotFoundException is thrown.
1929     *
1930     * @param appPackageName Package name of the application whose resources
1931     *                       are to be retrieved.
1932     *
1933     * @return Returns the application's Resources.
1934     * @throws NameNotFoundException Thrown if the resources for the given
1935     * application could not be loaded.
1936     *
1937     * @see #getResourcesForApplication(ApplicationInfo)
1938     */
1939    public abstract Resources getResourcesForApplication(String appPackageName)
1940            throws NameNotFoundException;
1941
1942    /**
1943     * Retrieve overall information about an application package defined
1944     * in a package archive file
1945     *
1946     * @param archiveFilePath The path to the archive file
1947     * @param flags Additional option flags. Use any combination of
1948     * {@link #GET_ACTIVITIES},
1949     * {@link #GET_GIDS},
1950     * {@link #GET_CONFIGURATIONS},
1951     * {@link #GET_INSTRUMENTATION},
1952     * {@link #GET_PERMISSIONS},
1953     * {@link #GET_PROVIDERS},
1954     * {@link #GET_RECEIVERS},
1955     * {@link #GET_SERVICES},
1956     * {@link #GET_SIGNATURES}, to modify the data returned.
1957     *
1958     * @return Returns the information about the package. Returns
1959     * null if the package could not be successfully parsed.
1960     *
1961     * @see #GET_ACTIVITIES
1962     * @see #GET_GIDS
1963     * @see #GET_CONFIGURATIONS
1964     * @see #GET_INSTRUMENTATION
1965     * @see #GET_PERMISSIONS
1966     * @see #GET_PROVIDERS
1967     * @see #GET_RECEIVERS
1968     * @see #GET_SERVICES
1969     * @see #GET_SIGNATURES
1970     *
1971     */
1972    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
1973        PackageParser packageParser = new PackageParser(archiveFilePath);
1974        DisplayMetrics metrics = new DisplayMetrics();
1975        metrics.setToDefaults();
1976        final File sourceFile = new File(archiveFilePath);
1977        PackageParser.Package pkg = packageParser.parsePackage(
1978                sourceFile, archiveFilePath, metrics, 0);
1979        if (pkg == null) {
1980            return null;
1981        }
1982        return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0);
1983    }
1984
1985    /**
1986     * @hide
1987     *
1988     * Install a package. Since this may take a little while, the result will
1989     * be posted back to the given observer.  An installation will fail if the calling context
1990     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
1991     * package named in the package file's manifest is already installed, or if there's no space
1992     * available on the device.
1993     *
1994     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
1995     * 'content:' URI.
1996     * @param observer An observer callback to get notified when the package installation is
1997     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
1998     * called when that happens.  observer may be null to indicate that no callback is desired.
1999     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2000     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2001     * @param installerPackageName Optional package name of the application that is performing the
2002     * installation. This identifies which market the package came from.
2003     */
2004    public abstract void installPackage(
2005            Uri packageURI, IPackageInstallObserver observer, int flags,
2006            String installerPackageName);
2007
2008    /**
2009     * Change the installer associated with a given package.  There are limitations
2010     * on how the installer package can be changed; in particular:
2011     * <ul>
2012     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
2013     * is not signed with the same certificate as the calling application.
2014     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
2015     * has an installer package, and that installer package is not signed with
2016     * the same certificate as the calling application.
2017     * </ul>
2018     *
2019     * @param targetPackage The installed package whose installer will be changed.
2020     * @param installerPackageName The package name of the new installer.  May be
2021     * null to clear the association.
2022     */
2023    public abstract void setInstallerPackageName(String targetPackage,
2024            String installerPackageName);
2025
2026    /**
2027     * Attempts to delete a package.  Since this may take a little while, the result will
2028     * be posted back to the given observer.  A deletion will fail if the calling context
2029     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
2030     * named package cannot be found, or if the named package is a "system package".
2031     * (TODO: include pointer to documentation on "system packages")
2032     *
2033     * @param packageName The name of the package to delete
2034     * @param observer An observer callback to get notified when the package deletion is
2035     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
2036     * called when that happens.  observer may be null to indicate that no callback is desired.
2037     * @param flags - possible values: {@link #DONT_DELETE_DATA}
2038     *
2039     * @hide
2040     */
2041    public abstract void deletePackage(
2042            String packageName, IPackageDeleteObserver observer, int flags);
2043
2044    /**
2045     * Retrieve the package name of the application that installed a package. This identifies
2046     * which market the package came from.
2047     *
2048     * @param packageName The name of the package to query
2049     */
2050    public abstract String getInstallerPackageName(String packageName);
2051
2052    /**
2053     * Attempts to clear the user data directory of an application.
2054     * Since this may take a little while, the result will
2055     * be posted back to the given observer.  A deletion will fail if the
2056     * named package cannot be found, or if the named package is a "system package".
2057     *
2058     * @param packageName The name of the package
2059     * @param observer An observer callback to get notified when the operation is finished
2060     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2061     * will be called when that happens.  observer may be null to indicate that
2062     * no callback is desired.
2063     *
2064     * @hide
2065     */
2066    public abstract void clearApplicationUserData(String packageName,
2067            IPackageDataObserver observer);
2068    /**
2069     * Attempts to delete the cache files associated with an application.
2070     * Since this may take a little while, the result will
2071     * be posted back to the given observer.  A deletion will fail if the calling context
2072     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
2073     * named package cannot be found, or if the named package is a "system package".
2074     *
2075     * @param packageName The name of the package to delete
2076     * @param observer An observer callback to get notified when the cache file deletion
2077     * is complete.
2078     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2079     * will be called when that happens.  observer may be null to indicate that
2080     * no callback is desired.
2081     *
2082     * @hide
2083     */
2084    public abstract void deleteApplicationCacheFiles(String packageName,
2085            IPackageDataObserver observer);
2086
2087    /**
2088     * Free storage by deleting LRU sorted list of cache files across
2089     * all applications. If the currently available free storage
2090     * on the device is greater than or equal to the requested
2091     * free storage, no cache files are cleared. If the currently
2092     * available storage on the device is less than the requested
2093     * free storage, some or all of the cache files across
2094     * all applications are deleted (based on last accessed time)
2095     * to increase the free storage space on the device to
2096     * the requested value. There is no guarantee that clearing all
2097     * the cache files from all applications will clear up
2098     * enough storage to achieve the desired value.
2099     * @param freeStorageSize The number of bytes of storage to be
2100     * freed by the system. Say if freeStorageSize is XX,
2101     * and the current free storage is YY,
2102     * if XX is less than YY, just return. if not free XX-YY number
2103     * of bytes if possible.
2104     * @param observer call back used to notify when
2105     * the operation is completed
2106     *
2107     * @hide
2108     */
2109    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
2110
2111    /**
2112     * Free storage by deleting LRU sorted list of cache files across
2113     * all applications. If the currently available free storage
2114     * on the device is greater than or equal to the requested
2115     * free storage, no cache files are cleared. If the currently
2116     * available storage on the device is less than the requested
2117     * free storage, some or all of the cache files across
2118     * all applications are deleted (based on last accessed time)
2119     * to increase the free storage space on the device to
2120     * the requested value. There is no guarantee that clearing all
2121     * the cache files from all applications will clear up
2122     * enough storage to achieve the desired value.
2123     * @param freeStorageSize The number of bytes of storage to be
2124     * freed by the system. Say if freeStorageSize is XX,
2125     * and the current free storage is YY,
2126     * if XX is less than YY, just return. if not free XX-YY number
2127     * of bytes if possible.
2128     * @param pi IntentSender call back used to
2129     * notify when the operation is completed.May be null
2130     * to indicate that no call back is desired.
2131     *
2132     * @hide
2133     */
2134    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
2135
2136    /**
2137     * Retrieve the size information for a package.
2138     * Since this may take a little while, the result will
2139     * be posted back to the given observer.  The calling context
2140     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
2141     *
2142     * @param packageName The name of the package whose size information is to be retrieved
2143     * @param observer An observer callback to get notified when the operation
2144     * is complete.
2145     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
2146     * The observer's callback is invoked with a PackageStats object(containing the
2147     * code, data and cache sizes of the package) and a boolean value representing
2148     * the status of the operation. observer may be null to indicate that
2149     * no callback is desired.
2150     *
2151     * @hide
2152     */
2153    public abstract void getPackageSizeInfo(String packageName,
2154            IPackageStatsObserver observer);
2155
2156    /**
2157     * @deprecated This function no longer does anything; it was an old
2158     * approach to managing preferred activities, which has been superceeded
2159     * (and conflicts with) the modern activity-based preferences.
2160     */
2161    @Deprecated
2162    public abstract void addPackageToPreferred(String packageName);
2163
2164    /**
2165     * @deprecated This function no longer does anything; it was an old
2166     * approach to managing preferred activities, which has been superceeded
2167     * (and conflicts with) the modern activity-based preferences.
2168     */
2169    @Deprecated
2170    public abstract void removePackageFromPreferred(String packageName);
2171
2172    /**
2173     * Retrieve the list of all currently configured preferred packages.  The
2174     * first package on the list is the most preferred, the last is the
2175     * least preferred.
2176     *
2177     * @param flags Additional option flags. Use any combination of
2178     * {@link #GET_ACTIVITIES},
2179     * {@link #GET_GIDS},
2180     * {@link #GET_CONFIGURATIONS},
2181     * {@link #GET_INSTRUMENTATION},
2182     * {@link #GET_PERMISSIONS},
2183     * {@link #GET_PROVIDERS},
2184     * {@link #GET_RECEIVERS},
2185     * {@link #GET_SERVICES},
2186     * {@link #GET_SIGNATURES}, to modify the data returned.
2187     *
2188     * @return Returns a list of PackageInfo objects describing each
2189     * preferred application, in order of preference.
2190     *
2191     * @see #GET_ACTIVITIES
2192     * @see #GET_GIDS
2193     * @see #GET_CONFIGURATIONS
2194     * @see #GET_INSTRUMENTATION
2195     * @see #GET_PERMISSIONS
2196     * @see #GET_PROVIDERS
2197     * @see #GET_RECEIVERS
2198     * @see #GET_SERVICES
2199     * @see #GET_SIGNATURES
2200     */
2201    public abstract List<PackageInfo> getPreferredPackages(int flags);
2202
2203    /**
2204     * @deprecated This is a protected API that should not have been available
2205     * to third party applications.  It is the platform's responsibility for
2206     * assigning preferred activities and this can not be directly modified.
2207     *
2208     * Add a new preferred activity mapping to the system.  This will be used
2209     * to automatically select the given activity component when
2210     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2211     * multiple matching activities and also matches the given filter.
2212     *
2213     * @param filter The set of intents under which this activity will be
2214     * made preferred.
2215     * @param match The IntentFilter match category that this preference
2216     * applies to.
2217     * @param set The set of activities that the user was picking from when
2218     * this preference was made.
2219     * @param activity The component name of the activity that is to be
2220     * preferred.
2221     */
2222    @Deprecated
2223    public abstract void addPreferredActivity(IntentFilter filter, int match,
2224            ComponentName[] set, ComponentName activity);
2225
2226    /**
2227     * @deprecated This is a protected API that should not have been available
2228     * to third party applications.  It is the platform's responsibility for
2229     * assigning preferred activities and this can not be directly modified.
2230     *
2231     * Replaces an existing preferred activity mapping to the system, and if that were not present
2232     * adds a new preferred activity.  This will be used
2233     * to automatically select the given activity component when
2234     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2235     * multiple matching activities and also matches the given filter.
2236     *
2237     * @param filter The set of intents under which this activity will be
2238     * made preferred.
2239     * @param match The IntentFilter match category that this preference
2240     * applies to.
2241     * @param set The set of activities that the user was picking from when
2242     * this preference was made.
2243     * @param activity The component name of the activity that is to be
2244     * preferred.
2245     * @hide
2246     */
2247    @Deprecated
2248    public abstract void replacePreferredActivity(IntentFilter filter, int match,
2249            ComponentName[] set, ComponentName activity);
2250
2251    /**
2252     * Remove all preferred activity mappings, previously added with
2253     * {@link #addPreferredActivity}, from the
2254     * system whose activities are implemented in the given package name.
2255     * An application can only clear its own package(s).
2256     *
2257     * @param packageName The name of the package whose preferred activity
2258     * mappings are to be removed.
2259     */
2260    public abstract void clearPackagePreferredActivities(String packageName);
2261
2262    /**
2263     * Retrieve all preferred activities, previously added with
2264     * {@link #addPreferredActivity}, that are
2265     * currently registered with the system.
2266     *
2267     * @param outFilters A list in which to place the filters of all of the
2268     * preferred activities, or null for none.
2269     * @param outActivities A list in which to place the component names of
2270     * all of the preferred activities, or null for none.
2271     * @param packageName An option package in which you would like to limit
2272     * the list.  If null, all activities will be returned; if non-null, only
2273     * those activities in the given package are returned.
2274     *
2275     * @return Returns the total number of registered preferred activities
2276     * (the number of distinct IntentFilter records, not the number of unique
2277     * activity components) that were found.
2278     */
2279    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
2280            List<ComponentName> outActivities, String packageName);
2281
2282    /**
2283     * Set the enabled setting for a package component (activity, receiver, service, provider).
2284     * This setting will override any enabled state which may have been set by the component in its
2285     * manifest.
2286     *
2287     * @param componentName The component to enable
2288     * @param newState The new enabled state for the component.  The legal values for this state
2289     *                 are:
2290     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2291     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2292     *                   and
2293     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2294     *                 The last one removes the setting, thereby restoring the component's state to
2295     *                 whatever was set in it's manifest (or enabled, by default).
2296     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2297     */
2298    public abstract void setComponentEnabledSetting(ComponentName componentName,
2299            int newState, int flags);
2300
2301
2302    /**
2303     * Return the the enabled setting for a package component (activity,
2304     * receiver, service, provider).  This returns the last value set by
2305     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
2306     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2307     * the value originally specified in the manifest has not been modified.
2308     *
2309     * @param componentName The component to retrieve.
2310     * @return Returns the current enabled state for the component.  May
2311     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2312     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2313     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2314     * component's enabled state is based on the original information in
2315     * the manifest as found in {@link ComponentInfo}.
2316     */
2317    public abstract int getComponentEnabledSetting(ComponentName componentName);
2318
2319    /**
2320     * Set the enabled setting for an application
2321     * This setting will override any enabled state which may have been set by the application in
2322     * its manifest.  It also overrides the enabled state set in the manifest for any of the
2323     * application's components.  It does not override any enabled state set by
2324     * {@link #setComponentEnabledSetting} for any of the application's components.
2325     *
2326     * @param packageName The package name of the application to enable
2327     * @param newState The new enabled state for the component.  The legal values for this state
2328     *                 are:
2329     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2330     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2331     *                   and
2332     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2333     *                 The last one removes the setting, thereby restoring the applications's state to
2334     *                 whatever was set in its manifest (or enabled, by default).
2335     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2336     */
2337    public abstract void setApplicationEnabledSetting(String packageName,
2338            int newState, int flags);
2339
2340    /**
2341     * Return the the enabled setting for an application.  This returns
2342     * the last value set by
2343     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
2344     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2345     * the value originally specified in the manifest has not been modified.
2346     *
2347     * @param packageName The component to retrieve.
2348     * @return Returns the current enabled state for the component.  May
2349     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2350     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2351     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2352     * application's enabled state is based on the original information in
2353     * the manifest as found in {@link ComponentInfo}.
2354     */
2355    public abstract int getApplicationEnabledSetting(String packageName);
2356
2357    /**
2358     * Return whether the device has been booted into safe mode.
2359     */
2360    public abstract boolean isSafeMode();
2361
2362    /**
2363     * Attempts to move package resources from internal to external media or vice versa.
2364     * Since this may take a little while, the result will
2365     * be posted back to the given observer.   This call may fail if the calling context
2366     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
2367     * named package cannot be found, or if the named package is a "system package".
2368     *
2369     * @param packageName The name of the package to delete
2370     * @param observer An observer callback to get notified when the package move is
2371     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
2372     * called when that happens.  observer may be null to indicate that no callback is desired.
2373     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
2374     * {@link #MOVE_EXTERNAL_MEDIA}
2375     *
2376     * @hide
2377     */
2378    public abstract void movePackage(
2379            String packageName, IPackageMoveObserver observer, int flags);
2380}
2381