PackageManager.java revision 880119bf43d738ca632b5d3861eb52d655c1c0fc
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 that is passed to the {@link IPackageMoveObserver} by
556     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
557     * when the package has been successfully moved by the system.
558     * @hide
559     */
560    public static final int MOVE_SUCCEEDED = 1;
561    /**
562     * Error code that is passed to the {@link IPackageMoveObserver} by
563     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
564     * when the package hasn't been successfully moved by the system
565     * because of insufficient memory on specified media.
566     * @hide
567     */
568    public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
569
570    /**
571     * Error code that is passed to the {@link IPackageMoveObserver} by
572     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
573     * if the specified package doesn't exist.
574     * @hide
575     */
576    public static final int MOVE_FAILED_DOESNT_EXIST = -2;
577
578    /**
579     * Error code that is passed to the {@link IPackageMoveObserver} by
580     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
581     * if the specified package cannot be moved since its a system package.
582     * @hide
583     */
584    public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
585
586    /**
587     * Error code that is passed to the {@link IPackageMoveObserver} by
588     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
589     * if the specified package cannot be moved since its forward locked.
590     * @hide
591     */
592    public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
593
594    /**
595     * Error code that is passed to the {@link IPackageMoveObserver} by
596     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
597     * if the specified package cannot be moved to the specified location.
598     * @hide
599     */
600    public static final int MOVE_FAILED_INVALID_LOCATION = -5;
601
602    /**
603     * Error code that is passed to the {@link IPackageMoveObserver} by
604     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
605     * if the specified package cannot be moved to the specified location.
606     * @hide
607     */
608    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
609
610    /**
611     * Error code that is passed to the {@link IPackageMoveObserver} by
612     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
613     * specified package already has an operation pending in the
614     * {@link PackageHandler} queue.
615     *
616     * @hide
617     */
618    public static final int MOVE_FAILED_OPERATION_PENDING = -7;
619
620    /**
621     * Flag parameter for {@link #movePackage} to indicate that
622     * the package should be moved to internal storage if its
623     * been installed on external media.
624     * @hide
625     */
626    public static final int MOVE_INTERNAL = 0x00000001;
627
628    /**
629     * Flag parameter for {@link #movePackage} to indicate that
630     * the package should be moved to external media.
631     * @hide
632     */
633    public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
634
635    /**
636     * Feature for {@link #getSystemAvailableFeatures} and
637     * {@link #hasSystemFeature}: The device's audio pipeline is low-latency,
638     * more suitable for audio applications sensitive to delays or lag in
639     * sound input or output.
640     */
641    @SdkConstant(SdkConstantType.FEATURE)
642    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
643
644    /**
645     * Feature for {@link #getSystemAvailableFeatures} and
646     * {@link #hasSystemFeature}: The device is capable of communicating with
647     * other devices via Bluetooth.
648     */
649    @SdkConstant(SdkConstantType.FEATURE)
650    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
651
652    /**
653     * Feature for {@link #getSystemAvailableFeatures} and
654     * {@link #hasSystemFeature}: The device has a camera facing away
655     * from the screen.
656     */
657    @SdkConstant(SdkConstantType.FEATURE)
658    public static final String FEATURE_CAMERA = "android.hardware.camera";
659
660    /**
661     * Feature for {@link #getSystemAvailableFeatures} and
662     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
663     */
664    @SdkConstant(SdkConstantType.FEATURE)
665    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
666
667    /**
668     * Feature for {@link #getSystemAvailableFeatures} and
669     * {@link #hasSystemFeature}: The device's camera supports flash.
670     */
671    @SdkConstant(SdkConstantType.FEATURE)
672    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
673
674    /**
675     * Feature for {@link #getSystemAvailableFeatures} and
676     * {@link #hasSystemFeature}: The device has a front facing camera.
677     */
678    @SdkConstant(SdkConstantType.FEATURE)
679    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
680
681    /**
682     * Feature for {@link #getSystemAvailableFeatures} and
683     * {@link #hasSystemFeature}: The device supports one or more methods of
684     * reporting current location.
685     */
686    @SdkConstant(SdkConstantType.FEATURE)
687    public static final String FEATURE_LOCATION = "android.hardware.location";
688
689    /**
690     * Feature for {@link #getSystemAvailableFeatures} and
691     * {@link #hasSystemFeature}: The device has a Global Positioning System
692     * receiver and can report precise location.
693     */
694    @SdkConstant(SdkConstantType.FEATURE)
695    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
696
697    /**
698     * Feature for {@link #getSystemAvailableFeatures} and
699     * {@link #hasSystemFeature}: The device can report location with coarse
700     * accuracy using a network-based geolocation system.
701     */
702    @SdkConstant(SdkConstantType.FEATURE)
703    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
704
705    /**
706     * Feature for {@link #getSystemAvailableFeatures} and
707     * {@link #hasSystemFeature}: The device can record audio via a
708     * microphone.
709     */
710    @SdkConstant(SdkConstantType.FEATURE)
711    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
712
713    /**
714     * Feature for {@link #getSystemAvailableFeatures} and
715     * {@link #hasSystemFeature}: The device can communicate using Near-Field
716     * Communications (NFC).
717     */
718    @SdkConstant(SdkConstantType.FEATURE)
719    public static final String FEATURE_NFC = "android.hardware.nfc";
720
721    /**
722     * Feature for {@link #getSystemAvailableFeatures} and
723     * {@link #hasSystemFeature}: The device includes an accelerometer.
724     */
725    @SdkConstant(SdkConstantType.FEATURE)
726    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
727
728    /**
729     * Feature for {@link #getSystemAvailableFeatures} and
730     * {@link #hasSystemFeature}: The device includes a barometer (air
731     * pressure sensor.)
732     */
733    @SdkConstant(SdkConstantType.FEATURE)
734    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
735
736    /**
737     * Feature for {@link #getSystemAvailableFeatures} and
738     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
739     */
740    @SdkConstant(SdkConstantType.FEATURE)
741    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
742
743    /**
744     * Feature for {@link #getSystemAvailableFeatures} and
745     * {@link #hasSystemFeature}: The device includes a gyroscope.
746     */
747    @SdkConstant(SdkConstantType.FEATURE)
748    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
749
750    /**
751     * Feature for {@link #getSystemAvailableFeatures} and
752     * {@link #hasSystemFeature}: The device includes a light sensor.
753     */
754    @SdkConstant(SdkConstantType.FEATURE)
755    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
756
757    /**
758     * Feature for {@link #getSystemAvailableFeatures} and
759     * {@link #hasSystemFeature}: The device includes a proximity sensor.
760     */
761    @SdkConstant(SdkConstantType.FEATURE)
762    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
763
764    /**
765     * Feature for {@link #getSystemAvailableFeatures} and
766     * {@link #hasSystemFeature}: The device has a telephony radio with data
767     * communication support.
768     */
769    @SdkConstant(SdkConstantType.FEATURE)
770    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
771
772    /**
773     * Feature for {@link #getSystemAvailableFeatures} and
774     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
775     */
776    @SdkConstant(SdkConstantType.FEATURE)
777    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
778
779    /**
780     * Feature for {@link #getSystemAvailableFeatures} and
781     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
782     */
783    @SdkConstant(SdkConstantType.FEATURE)
784    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
785
786    /**
787     * Feature for {@link #getSystemAvailableFeatures} and
788     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
789     */
790    @SdkConstant(SdkConstantType.FEATURE)
791    public static final String FEATURE_SIP = "android.software.sip";
792
793    /**
794     * Feature for {@link #getSystemAvailableFeatures} and
795     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
796     */
797    @SdkConstant(SdkConstantType.FEATURE)
798    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
799
800    /**
801     * Feature for {@link #getSystemAvailableFeatures} and
802     * {@link #hasSystemFeature}: The device's display has a touch screen.
803     */
804    @SdkConstant(SdkConstantType.FEATURE)
805    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
806
807
808    /**
809     * Feature for {@link #getSystemAvailableFeatures} and
810     * {@link #hasSystemFeature}: The device's touch screen supports
811     * multitouch sufficient for basic two-finger gesture detection.
812     */
813    @SdkConstant(SdkConstantType.FEATURE)
814    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
815
816    /**
817     * Feature for {@link #getSystemAvailableFeatures} and
818     * {@link #hasSystemFeature}: The device's touch screen is capable of
819     * tracking two or more fingers fully independently.
820     */
821    @SdkConstant(SdkConstantType.FEATURE)
822    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
823
824    /**
825     * Feature for {@link #getSystemAvailableFeatures} and
826     * {@link #hasSystemFeature}: The device's touch screen is capable of
827     * tracking a full hand of fingers fully independently -- that is, 5 or
828     * more simultaneous independent pointers.
829     */
830    @SdkConstant(SdkConstantType.FEATURE)
831    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
832
833    /**
834     * Feature for {@link #getSystemAvailableFeatures} and
835     * {@link #hasSystemFeature}: The device supports live wallpapers.
836     */
837    @SdkConstant(SdkConstantType.FEATURE)
838    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
839
840    /**
841     * Feature for {@link #getSystemAvailableFeatures} and
842     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
843     */
844    @SdkConstant(SdkConstantType.FEATURE)
845    public static final String FEATURE_WIFI = "android.hardware.wifi";
846
847    /**
848     * Action to external storage service to clean out removed apps.
849     * @hide
850     */
851    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
852            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
853
854    /**
855     * Retrieve overall information about an application package that is
856     * installed on the system.
857     *
858     * <p>Throws {@link NameNotFoundException} if a package with the given
859     * name can not be found on the system.
860     *
861     * @param packageName The full name (i.e. com.google.apps.contacts) of the
862     *                    desired package.
863
864     * @param flags Additional option flags. Use any combination of
865     * {@link #GET_ACTIVITIES},
866     * {@link #GET_GIDS},
867     * {@link #GET_CONFIGURATIONS},
868     * {@link #GET_INSTRUMENTATION},
869     * {@link #GET_PERMISSIONS},
870     * {@link #GET_PROVIDERS},
871     * {@link #GET_RECEIVERS},
872     * {@link #GET_SERVICES},
873     * {@link #GET_SIGNATURES},
874     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
875     *
876     * @return Returns a PackageInfo object containing information about the package.
877     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
878     *         found in the list of installed applications, the package information is
879     *         retrieved from the list of uninstalled applications(which includes
880     *         installed applications as well as applications
881     *         with data directory ie applications which had been
882     *         deleted with DONT_DELTE_DATA flag set).
883     *
884     * @see #GET_ACTIVITIES
885     * @see #GET_GIDS
886     * @see #GET_CONFIGURATIONS
887     * @see #GET_INSTRUMENTATION
888     * @see #GET_PERMISSIONS
889     * @see #GET_PROVIDERS
890     * @see #GET_RECEIVERS
891     * @see #GET_SERVICES
892     * @see #GET_SIGNATURES
893     * @see #GET_UNINSTALLED_PACKAGES
894     *
895     */
896    public abstract PackageInfo getPackageInfo(String packageName, int flags)
897            throws NameNotFoundException;
898
899    /**
900     * Map from the current package names in use on the device to whatever
901     * the current canonical name of that package is.
902     * @param names Array of current names to be mapped.
903     * @return Returns an array of the same size as the original, containing
904     * the canonical name for each package.
905     */
906    public abstract String[] currentToCanonicalPackageNames(String[] names);
907
908    /**
909     * Map from a packages canonical name to the current name in use on the device.
910     * @param names Array of new names to be mapped.
911     * @return Returns an array of the same size as the original, containing
912     * the current name for each package.
913     */
914    public abstract String[] canonicalToCurrentPackageNames(String[] names);
915
916    /**
917     * Return a "good" intent to launch a front-door activity in a package,
918     * for use for example to implement an "open" button when browsing through
919     * packages.  The current implementation will look first for a main
920     * activity in the category {@link Intent#CATEGORY_INFO}, next for a
921     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
922     * null if neither are found.
923     *
924     * <p>Throws {@link NameNotFoundException} if a package with the given
925     * name can not be found on the system.
926     *
927     * @param packageName The name of the package to inspect.
928     *
929     * @return Returns either a fully-qualified Intent that can be used to
930     * launch the main activity in the package, or null if the package does
931     * not contain such an activity.
932     */
933    public abstract Intent getLaunchIntentForPackage(String packageName);
934
935    /**
936     * Return an array of all of the secondary group-ids that have been
937     * assigned to a package.
938     *
939     * <p>Throws {@link NameNotFoundException} if a package with the given
940     * name can not be found on the system.
941     *
942     * @param packageName The full name (i.e. com.google.apps.contacts) of the
943     *                    desired package.
944     *
945     * @return Returns an int array of the assigned gids, or null if there
946     * are none.
947     */
948    public abstract int[] getPackageGids(String packageName)
949            throws NameNotFoundException;
950
951    /**
952     * Retrieve all of the information we know about a particular permission.
953     *
954     * <p>Throws {@link NameNotFoundException} if a permission with the given
955     * name can not be found on the system.
956     *
957     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
958     *             of the permission you are interested in.
959     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
960     * retrieve any meta-data associated with the permission.
961     *
962     * @return Returns a {@link PermissionInfo} containing information about the
963     *         permission.
964     */
965    public abstract PermissionInfo getPermissionInfo(String name, int flags)
966            throws NameNotFoundException;
967
968    /**
969     * Query for all of the permissions associated with a particular group.
970     *
971     * <p>Throws {@link NameNotFoundException} if the given group does not
972     * exist.
973     *
974     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
975     *             of the permission group you are interested in.  Use null to
976     *             find all of the permissions not associated with a group.
977     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
978     * retrieve any meta-data associated with the permissions.
979     *
980     * @return Returns a list of {@link PermissionInfo} containing information
981     * about all of the permissions in the given group.
982     */
983    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
984            int flags) throws NameNotFoundException;
985
986    /**
987     * Retrieve all of the information we know about a particular group of
988     * permissions.
989     *
990     * <p>Throws {@link NameNotFoundException} if a permission group with the given
991     * name can not be found on the system.
992     *
993     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
994     *             of the permission you are interested in.
995     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
996     * retrieve any meta-data associated with the permission group.
997     *
998     * @return Returns a {@link PermissionGroupInfo} containing information
999     * about the permission.
1000     */
1001    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1002            int flags) throws NameNotFoundException;
1003
1004    /**
1005     * Retrieve all of the known permission groups in the system.
1006     *
1007     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1008     * retrieve any meta-data associated with the permission group.
1009     *
1010     * @return Returns a list of {@link PermissionGroupInfo} containing
1011     * information about all of the known permission groups.
1012     */
1013    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1014
1015    /**
1016     * Retrieve all of the information we know about a particular
1017     * package/application.
1018     *
1019     * <p>Throws {@link NameNotFoundException} if an application with the given
1020     * package name can not be found on the system.
1021     *
1022     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1023     *                    application.
1024     * @param flags Additional option flags. Use any combination of
1025     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1026     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1027     *
1028     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1029     *         information about the package.
1030     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1031     *         found in the list of installed applications,
1032     *         the application information is retrieved from the
1033     *         list of uninstalled applications(which includes
1034     *         installed applications as well as applications
1035     *         with data directory ie applications which had been
1036     *         deleted with DONT_DELTE_DATA flag set).
1037     *
1038     * @see #GET_META_DATA
1039     * @see #GET_SHARED_LIBRARY_FILES
1040     * @see #GET_UNINSTALLED_PACKAGES
1041     */
1042    public abstract ApplicationInfo getApplicationInfo(String packageName,
1043            int flags) throws NameNotFoundException;
1044
1045    /**
1046     * Retrieve all of the information we know about a particular activity
1047     * class.
1048     *
1049     * <p>Throws {@link NameNotFoundException} if an activity with the given
1050     * class name can not be found on the system.
1051     *
1052     * @param component The full component name (i.e.
1053     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1054     * class.
1055     * @param flags Additional option flags. Use any combination of
1056     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1057     * to modify the data (in ApplicationInfo) returned.
1058     *
1059     * @return {@link ActivityInfo} containing information about the activity.
1060     *
1061     * @see #GET_INTENT_FILTERS
1062     * @see #GET_META_DATA
1063     * @see #GET_SHARED_LIBRARY_FILES
1064     */
1065    public abstract ActivityInfo getActivityInfo(ComponentName component,
1066            int flags) throws NameNotFoundException;
1067
1068    /**
1069     * Retrieve all of the information we know about a particular receiver
1070     * class.
1071     *
1072     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1073     * class name can not be found on the system.
1074     *
1075     * @param component The full component name (i.e.
1076     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1077     * class.
1078     * @param flags Additional option flags.  Use any combination of
1079     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1080     * to modify the data returned.
1081     *
1082     * @return {@link ActivityInfo} containing information about the receiver.
1083     *
1084     * @see #GET_INTENT_FILTERS
1085     * @see #GET_META_DATA
1086     * @see #GET_SHARED_LIBRARY_FILES
1087     */
1088    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1089            int flags) throws NameNotFoundException;
1090
1091    /**
1092     * Retrieve all of the information we know about a particular service
1093     * class.
1094     *
1095     * <p>Throws {@link NameNotFoundException} if a service with the given
1096     * class name can not be found on the system.
1097     *
1098     * @param component The full component name (i.e.
1099     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1100     * class.
1101     * @param flags Additional option flags.  Use any combination of
1102     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1103     * to modify the data returned.
1104     *
1105     * @return ServiceInfo containing information about the service.
1106     *
1107     * @see #GET_META_DATA
1108     * @see #GET_SHARED_LIBRARY_FILES
1109     */
1110    public abstract ServiceInfo getServiceInfo(ComponentName component,
1111            int flags) throws NameNotFoundException;
1112
1113    /**
1114     * Retrieve all of the information we know about a particular content
1115     * provider class.
1116     *
1117     * <p>Throws {@link NameNotFoundException} if a provider with the given
1118     * class name can not be found on the system.
1119     *
1120     * @param component The full component name (i.e.
1121     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1122     * ContentProvider class.
1123     * @param flags Additional option flags.  Use any combination of
1124     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1125     * to modify the data returned.
1126     *
1127     * @return ProviderInfo containing information about the service.
1128     *
1129     * @see #GET_META_DATA
1130     * @see #GET_SHARED_LIBRARY_FILES
1131     */
1132    public abstract ProviderInfo getProviderInfo(ComponentName component,
1133            int flags) throws NameNotFoundException;
1134
1135    /**
1136     * Return a List of all packages that are installed
1137     * on the device.
1138     *
1139     * @param flags Additional option flags. Use any combination of
1140     * {@link #GET_ACTIVITIES},
1141     * {@link #GET_GIDS},
1142     * {@link #GET_CONFIGURATIONS},
1143     * {@link #GET_INSTRUMENTATION},
1144     * {@link #GET_PERMISSIONS},
1145     * {@link #GET_PROVIDERS},
1146     * {@link #GET_RECEIVERS},
1147     * {@link #GET_SERVICES},
1148     * {@link #GET_SIGNATURES},
1149     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1150     *
1151     * @return A List of PackageInfo objects, one for each package that is
1152     *         installed on the device.  In the unlikely case of there being no
1153     *         installed packages, an empty list is returned.
1154     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1155     *         applications including those deleted with DONT_DELETE_DATA
1156     *         (partially installed apps with data directory) will be returned.
1157     *
1158     * @see #GET_ACTIVITIES
1159     * @see #GET_GIDS
1160     * @see #GET_CONFIGURATIONS
1161     * @see #GET_INSTRUMENTATION
1162     * @see #GET_PERMISSIONS
1163     * @see #GET_PROVIDERS
1164     * @see #GET_RECEIVERS
1165     * @see #GET_SERVICES
1166     * @see #GET_SIGNATURES
1167     * @see #GET_UNINSTALLED_PACKAGES
1168     *
1169     */
1170    public abstract List<PackageInfo> getInstalledPackages(int flags);
1171
1172    /**
1173     * Check whether a particular package has been granted a particular
1174     * permission.
1175     *
1176     * @param permName The name of the permission you are checking for,
1177     * @param pkgName The name of the package you are checking against.
1178     *
1179     * @return If the package has the permission, PERMISSION_GRANTED is
1180     * returned.  If it does not have the permission, PERMISSION_DENIED
1181     * is returned.
1182     *
1183     * @see #PERMISSION_GRANTED
1184     * @see #PERMISSION_DENIED
1185     */
1186    public abstract int checkPermission(String permName, String pkgName);
1187
1188    /**
1189     * Add a new dynamic permission to the system.  For this to work, your
1190     * package must have defined a permission tree through the
1191     * {@link android.R.styleable#AndroidManifestPermissionTree
1192     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
1193     * permissions to trees that were defined by either its own package or
1194     * another with the same user id; a permission is in a tree if it
1195     * matches the name of the permission tree + ".": for example,
1196     * "com.foo.bar" is a member of the permission tree "com.foo".
1197     *
1198     * <p>It is good to make your permission tree name descriptive, because you
1199     * are taking possession of that entire set of permission names.  Thus, it
1200     * must be under a domain you control, with a suffix that will not match
1201     * any normal permissions that may be declared in any applications that
1202     * are part of that domain.
1203     *
1204     * <p>New permissions must be added before
1205     * any .apks are installed that use those permissions.  Permissions you
1206     * add through this method are remembered across reboots of the device.
1207     * If the given permission already exists, the info you supply here
1208     * will be used to update it.
1209     *
1210     * @param info Description of the permission to be added.
1211     *
1212     * @return Returns true if a new permission was created, false if an
1213     * existing one was updated.
1214     *
1215     * @throws SecurityException if you are not allowed to add the
1216     * given permission name.
1217     *
1218     * @see #removePermission(String)
1219     */
1220    public abstract boolean addPermission(PermissionInfo info);
1221
1222    /**
1223     * Like {@link #addPermission(PermissionInfo)} but asynchronously
1224     * persists the package manager state after returning from the call,
1225     * allowing it to return quicker and batch a series of adds at the
1226     * expense of no guarantee the added permission will be retained if
1227     * the device is rebooted before it is written.
1228     */
1229    public abstract boolean addPermissionAsync(PermissionInfo info);
1230
1231    /**
1232     * Removes a permission that was previously added with
1233     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
1234     * -- you are only allowed to remove permissions that you are allowed
1235     * to add.
1236     *
1237     * @param name The name of the permission to remove.
1238     *
1239     * @throws SecurityException if you are not allowed to remove the
1240     * given permission name.
1241     *
1242     * @see #addPermission(PermissionInfo)
1243     */
1244    public abstract void removePermission(String name);
1245
1246    /**
1247     * Compare the signatures of two packages to determine if the same
1248     * signature appears in both of them.  If they do contain the same
1249     * signature, then they are allowed special privileges when working
1250     * with each other: they can share the same user-id, run instrumentation
1251     * against each other, etc.
1252     *
1253     * @param pkg1 First package name whose signature will be compared.
1254     * @param pkg2 Second package name whose signature will be compared.
1255     *
1256     * @return Returns an integer indicating whether all signatures on the
1257     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1258     * all signatures match or < 0 if there is not a match ({@link
1259     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1260     *
1261     * @see #checkSignatures(int, int)
1262     * @see #SIGNATURE_MATCH
1263     * @see #SIGNATURE_NO_MATCH
1264     * @see #SIGNATURE_UNKNOWN_PACKAGE
1265     */
1266    public abstract int checkSignatures(String pkg1, String pkg2);
1267
1268    /**
1269     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
1270     * the two packages to be checked.  This can be useful, for example,
1271     * when doing the check in an IPC, where the UID is the only identity
1272     * available.  It is functionally identical to determining the package
1273     * associated with the UIDs and checking their signatures.
1274     *
1275     * @param uid1 First UID whose signature will be compared.
1276     * @param uid2 Second UID whose signature will be compared.
1277     *
1278     * @return Returns an integer indicating whether all signatures on the
1279     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1280     * all signatures match or < 0 if there is not a match ({@link
1281     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1282     *
1283     * @see #checkSignatures(String, String)
1284     * @see #SIGNATURE_MATCH
1285     * @see #SIGNATURE_NO_MATCH
1286     * @see #SIGNATURE_UNKNOWN_PACKAGE
1287     */
1288    public abstract int checkSignatures(int uid1, int uid2);
1289
1290    /**
1291     * Retrieve the names of all packages that are associated with a particular
1292     * user id.  In most cases, this will be a single package name, the package
1293     * that has been assigned that user id.  Where there are multiple packages
1294     * sharing the same user id through the "sharedUserId" mechanism, all
1295     * packages with that id will be returned.
1296     *
1297     * @param uid The user id for which you would like to retrieve the
1298     * associated packages.
1299     *
1300     * @return Returns an array of one or more packages assigned to the user
1301     * id, or null if there are no known packages with the given id.
1302     */
1303    public abstract String[] getPackagesForUid(int uid);
1304
1305    /**
1306     * Retrieve the official name associated with a user id.  This name is
1307     * guaranteed to never change, though it is possibly for the underlying
1308     * user id to be changed.  That is, if you are storing information about
1309     * user ids in persistent storage, you should use the string returned
1310     * by this function instead of the raw user-id.
1311     *
1312     * @param uid The user id for which you would like to retrieve a name.
1313     * @return Returns a unique name for the given user id, or null if the
1314     * user id is not currently assigned.
1315     */
1316    public abstract String getNameForUid(int uid);
1317
1318    /**
1319     * Return the user id associated with a shared user name. Multiple
1320     * applications can specify a shared user name in their manifest and thus
1321     * end up using a common uid. This might be used for new applications
1322     * that use an existing shared user name and need to know the uid of the
1323     * shared user.
1324     *
1325     * @param sharedUserName The shared user name whose uid is to be retrieved.
1326     * @return Returns the uid associated with the shared user, or  NameNotFoundException
1327     * if the shared user name is not being used by any installed packages
1328     * @hide
1329     */
1330    public abstract int getUidForSharedUser(String sharedUserName)
1331            throws NameNotFoundException;
1332
1333    /**
1334     * Return a List of all application packages that are installed on the
1335     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
1336     * applications including those deleted with DONT_DELETE_DATA(partially
1337     * installed apps with data directory) will be returned.
1338     *
1339     * @param flags Additional option flags. Use any combination of
1340     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1341     * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1342     *
1343     * @return A List of ApplicationInfo objects, one for each application that
1344     *         is installed on the device.  In the unlikely case of there being
1345     *         no installed applications, an empty list is returned.
1346     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1347     *         applications including those deleted with DONT_DELETE_DATA
1348     *         (partially installed apps with data directory) will be returned.
1349     *
1350     * @see #GET_META_DATA
1351     * @see #GET_SHARED_LIBRARY_FILES
1352     * @see #GET_UNINSTALLED_PACKAGES
1353     */
1354    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
1355
1356    /**
1357     * Get a list of shared libraries that are available on the
1358     * system.
1359     *
1360     * @return An array of shared library names that are
1361     * available on the system, or null if none are installed.
1362     *
1363     */
1364    public abstract String[] getSystemSharedLibraryNames();
1365
1366    /**
1367     * Get a list of features that are available on the
1368     * system.
1369     *
1370     * @return An array of FeatureInfo classes describing the features
1371     * that are available on the system, or null if there are none(!!).
1372     */
1373    public abstract FeatureInfo[] getSystemAvailableFeatures();
1374
1375    /**
1376     * Check whether the given feature name is one of the available
1377     * features as returned by {@link #getSystemAvailableFeatures()}.
1378     *
1379     * @return Returns true if the devices supports the feature, else
1380     * false.
1381     */
1382    public abstract boolean hasSystemFeature(String name);
1383
1384    /**
1385     * Determine the best action to perform for a given Intent.  This is how
1386     * {@link Intent#resolveActivity} finds an activity if a class has not
1387     * been explicitly specified.
1388     *
1389     * <p><em>Note: if using an implicit Intent (without an explicit ComponentName
1390     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
1391     * only flag.  You need to do so to resolve the activity in the same way
1392     * that {@link android.content.Context#startActivity(Intent)} and
1393     * {@link android.content.Intent#resolveActivity(PackageManager)
1394     * Intent.resolveActivity(PackageManager)} do.</p>
1395     *
1396     * @param intent An intent containing all of the desired specification
1397     *               (action, data, type, category, and/or component).
1398     * @param flags Additional option flags.  The most important is
1399     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1400     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1401     *
1402     * @return Returns a ResolveInfo containing the final activity intent that
1403     *         was determined to be the best action.  Returns null if no
1404     *         matching activity was found. If multiple matching activities are
1405     *         found and there is no default set, returns a ResolveInfo
1406     *         containing something else, such as the activity resolver.
1407     *
1408     * @see #MATCH_DEFAULT_ONLY
1409     * @see #GET_INTENT_FILTERS
1410     * @see #GET_RESOLVED_FILTER
1411     */
1412    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1413
1414    /**
1415     * Retrieve all activities that can be performed for the given intent.
1416     *
1417     * @param intent The desired intent as per resolveActivity().
1418     * @param flags Additional option flags.  The most important is
1419     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1420     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1421     *
1422     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1423     *         Activity. These are ordered from best to worst match -- that
1424     *         is, the first item in the list is what is returned by
1425     *         {@link #resolveActivity}.  If there are no matching activities, an empty
1426     *         list is returned.
1427     *
1428     * @see #MATCH_DEFAULT_ONLY
1429     * @see #GET_INTENT_FILTERS
1430     * @see #GET_RESOLVED_FILTER
1431     */
1432    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
1433            int flags);
1434
1435    /**
1436     * Retrieve a set of activities that should be presented to the user as
1437     * similar options.  This is like {@link #queryIntentActivities}, except it
1438     * also allows you to supply a list of more explicit Intents that you would
1439     * like to resolve to particular options, and takes care of returning the
1440     * final ResolveInfo list in a reasonable order, with no duplicates, based
1441     * on those inputs.
1442     *
1443     * @param caller The class name of the activity that is making the
1444     *               request.  This activity will never appear in the output
1445     *               list.  Can be null.
1446     * @param specifics An array of Intents that should be resolved to the
1447     *                  first specific results.  Can be null.
1448     * @param intent The desired intent as per resolveActivity().
1449     * @param flags Additional option flags.  The most important is
1450     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1451     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1452     *
1453     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1454     *         Activity. These are ordered first by all of the intents resolved
1455     *         in <var>specifics</var> and then any additional activities that
1456     *         can handle <var>intent</var> but did not get included by one of
1457     *         the <var>specifics</var> intents.  If there are no matching
1458     *         activities, an empty list is returned.
1459     *
1460     * @see #MATCH_DEFAULT_ONLY
1461     * @see #GET_INTENT_FILTERS
1462     * @see #GET_RESOLVED_FILTER
1463     */
1464    public abstract List<ResolveInfo> queryIntentActivityOptions(
1465            ComponentName caller, Intent[] specifics, Intent intent, int flags);
1466
1467    /**
1468     * Retrieve all receivers that can handle a broadcast of the given intent.
1469     *
1470     * @param intent The desired intent as per resolveActivity().
1471     * @param flags Additional option flags.
1472     *
1473     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1474     *         Receiver. These are ordered from first to last in priority.  If
1475     *         there are no matching receivers, an empty list is returned.
1476     *
1477     * @see #MATCH_DEFAULT_ONLY
1478     * @see #GET_INTENT_FILTERS
1479     * @see #GET_RESOLVED_FILTER
1480     */
1481    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
1482            int flags);
1483
1484    /**
1485     * Determine the best service to handle for a given Intent.
1486     *
1487     * @param intent An intent containing all of the desired specification
1488     *               (action, data, type, category, and/or component).
1489     * @param flags Additional option flags.
1490     *
1491     * @return Returns a ResolveInfo containing the final service intent that
1492     *         was determined to be the best action.  Returns null if no
1493     *         matching service was found.
1494     *
1495     * @see #GET_INTENT_FILTERS
1496     * @see #GET_RESOLVED_FILTER
1497     */
1498    public abstract ResolveInfo resolveService(Intent intent, int flags);
1499
1500    /**
1501     * Retrieve all services that can match the given intent.
1502     *
1503     * @param intent The desired intent as per resolveService().
1504     * @param flags Additional option flags.
1505     *
1506     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1507     *         ServiceInfo. These are ordered from best to worst match -- that
1508     *         is, the first item in the list is what is returned by
1509     *         resolveService().  If there are no matching services, an empty
1510     *         list is returned.
1511     *
1512     * @see #GET_INTENT_FILTERS
1513     * @see #GET_RESOLVED_FILTER
1514     */
1515    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
1516            int flags);
1517
1518    /**
1519     * Find a single content provider by its base path name.
1520     *
1521     * @param name The name of the provider to find.
1522     * @param flags Additional option flags.  Currently should always be 0.
1523     *
1524     * @return ContentProviderInfo Information about the provider, if found,
1525     *         else null.
1526     */
1527    public abstract ProviderInfo resolveContentProvider(String name,
1528            int flags);
1529
1530    /**
1531     * Retrieve content provider information.
1532     *
1533     * <p><em>Note: unlike most other methods, an empty result set is indicated
1534     * by a null return instead of an empty list.</em>
1535     *
1536     * @param processName If non-null, limits the returned providers to only
1537     *                    those that are hosted by the given process.  If null,
1538     *                    all content providers are returned.
1539     * @param uid If <var>processName</var> is non-null, this is the required
1540     *        uid owning the requested content providers.
1541     * @param flags Additional option flags.  Currently should always be 0.
1542     *
1543     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
1544     *         content provider either patching <var>processName</var> or, if
1545     *         <var>processName</var> is null, all known content providers.
1546     *         <em>If there are no matching providers, null is returned.</em>
1547     */
1548    public abstract List<ProviderInfo> queryContentProviders(
1549            String processName, int uid, int flags);
1550
1551    /**
1552     * Retrieve all of the information we know about a particular
1553     * instrumentation class.
1554     *
1555     * <p>Throws {@link NameNotFoundException} if instrumentation with the
1556     * given class name can not be found on the system.
1557     *
1558     * @param className The full name (i.e.
1559     *                  com.google.apps.contacts.InstrumentList) of an
1560     *                  Instrumentation class.
1561     * @param flags Additional option flags.  Currently should always be 0.
1562     *
1563     * @return InstrumentationInfo containing information about the
1564     *         instrumentation.
1565     */
1566    public abstract InstrumentationInfo getInstrumentationInfo(
1567            ComponentName className, int flags) throws NameNotFoundException;
1568
1569    /**
1570     * Retrieve information about available instrumentation code.  May be used
1571     * to retrieve either all instrumentation code, or only the code targeting
1572     * a particular package.
1573     *
1574     * @param targetPackage If null, all instrumentation is returned; only the
1575     *                      instrumentation targeting this package name is
1576     *                      returned.
1577     * @param flags Additional option flags.  Currently should always be 0.
1578     *
1579     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
1580     *         matching available Instrumentation.  Returns an empty list if
1581     *         there is no instrumentation available for the given package.
1582     */
1583    public abstract List<InstrumentationInfo> queryInstrumentation(
1584            String targetPackage, int flags);
1585
1586    /**
1587     * Retrieve an image from a package.  This is a low-level API used by
1588     * the various package manager info structures (such as
1589     * {@link ComponentInfo} to implement retrieval of their associated
1590     * icon.
1591     *
1592     * @param packageName The name of the package that this icon is coming from.
1593     * Can not be null.
1594     * @param resid The resource identifier of the desired image.  Can not be 0.
1595     * @param appInfo Overall information about <var>packageName</var>.  This
1596     * may be null, in which case the application information will be retrieved
1597     * for you if needed; if you already have this information around, it can
1598     * be much more efficient to supply it here.
1599     *
1600     * @return Returns a Drawable holding the requested image.  Returns null if
1601     * an image could not be found for any reason.
1602     */
1603    public abstract Drawable getDrawable(String packageName, int resid,
1604            ApplicationInfo appInfo);
1605
1606    /**
1607     * Retrieve the icon associated with an activity.  Given the full name of
1608     * an activity, retrieves the information about it and calls
1609     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
1610     * If the activity can not be found, NameNotFoundException is thrown.
1611     *
1612     * @param activityName Name of the activity whose icon is to be retrieved.
1613     *
1614     * @return Returns the image of the icon, or the default activity icon if
1615     * it could not be found.  Does not return null.
1616     * @throws NameNotFoundException Thrown if the resources for the given
1617     * activity could not be loaded.
1618     *
1619     * @see #getActivityIcon(Intent)
1620     */
1621    public abstract Drawable getActivityIcon(ComponentName activityName)
1622            throws NameNotFoundException;
1623
1624    /**
1625     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
1626     * set, this simply returns the result of
1627     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
1628     * component and returns the icon associated with the resolved component.
1629     * If intent.getClassName() can not be found or the Intent can not be resolved
1630     * to a component, NameNotFoundException is thrown.
1631     *
1632     * @param intent The intent for which you would like to retrieve an icon.
1633     *
1634     * @return Returns the image of the icon, or the default activity icon if
1635     * it could not be found.  Does not return null.
1636     * @throws NameNotFoundException Thrown if the resources for application
1637     * matching the given intent could not be loaded.
1638     *
1639     * @see #getActivityIcon(ComponentName)
1640     */
1641    public abstract Drawable getActivityIcon(Intent intent)
1642            throws NameNotFoundException;
1643
1644    /**
1645     * Return the generic icon for an activity that is used when no specific
1646     * icon is defined.
1647     *
1648     * @return Drawable Image of the icon.
1649     */
1650    public abstract Drawable getDefaultActivityIcon();
1651
1652    /**
1653     * Retrieve the icon associated with an application.  If it has not defined
1654     * an icon, the default app icon is returned.  Does not return null.
1655     *
1656     * @param info Information about application being queried.
1657     *
1658     * @return Returns the image of the icon, or the default application icon
1659     * if it could not be found.
1660     *
1661     * @see #getApplicationIcon(String)
1662     */
1663    public abstract Drawable getApplicationIcon(ApplicationInfo info);
1664
1665    /**
1666     * Retrieve the icon associated with an application.  Given the name of the
1667     * application's package, retrieves the information about it and calls
1668     * getApplicationIcon() to return its icon. If the application can not be
1669     * found, NameNotFoundException is thrown.
1670     *
1671     * @param packageName Name of the package whose application icon is to be
1672     *                    retrieved.
1673     *
1674     * @return Returns the image of the icon, or the default application icon
1675     * if it could not be found.  Does not return null.
1676     * @throws NameNotFoundException Thrown if the resources for the given
1677     * application could not be loaded.
1678     *
1679     * @see #getApplicationIcon(ApplicationInfo)
1680     */
1681    public abstract Drawable getApplicationIcon(String packageName)
1682            throws NameNotFoundException;
1683
1684    /**
1685     * Retrieve the logo associated with an activity.  Given the full name of
1686     * an activity, retrieves the information about it and calls
1687     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
1688     * If the activity can not be found, NameNotFoundException is thrown.
1689     *
1690     * @param activityName Name of the activity whose logo is to be retrieved.
1691     *
1692     * @return Returns the image of the logo or null if the activity has no
1693     * logo specified.
1694     *
1695     * @throws NameNotFoundException Thrown if the resources for the given
1696     * activity could not be loaded.
1697     *
1698     * @see #getActivityLogo(Intent)
1699     */
1700    public abstract Drawable getActivityLogo(ComponentName activityName)
1701            throws NameNotFoundException;
1702
1703    /**
1704     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
1705     * set, this simply returns the result of
1706     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
1707     * component and returns the logo associated with the resolved component.
1708     * If intent.getClassName() can not be found or the Intent can not be resolved
1709     * to a component, NameNotFoundException is thrown.
1710     *
1711     * @param intent The intent for which you would like to retrieve a logo.
1712     *
1713     * @return Returns the image of the logo, or null if the activity has no
1714     * logo specified.
1715     *
1716     * @throws NameNotFoundException Thrown if the resources for application
1717     * matching the given intent could not be loaded.
1718     *
1719     * @see #getActivityLogo(ComponentName)
1720     */
1721    public abstract Drawable getActivityLogo(Intent intent)
1722            throws NameNotFoundException;
1723
1724    /**
1725     * Retrieve the logo associated with an application.  If it has not specified
1726     * a logo, this method returns null.
1727     *
1728     * @param info Information about application being queried.
1729     *
1730     * @return Returns the image of the logo, or null if no logo is specified
1731     * by the application.
1732     *
1733     * @see #getApplicationLogo(String)
1734     */
1735    public abstract Drawable getApplicationLogo(ApplicationInfo info);
1736
1737    /**
1738     * Retrieve the logo associated with an application.  Given the name of the
1739     * application's package, retrieves the information about it and calls
1740     * getApplicationLogo() to return its logo. If the application can not be
1741     * found, NameNotFoundException is thrown.
1742     *
1743     * @param packageName Name of the package whose application logo is to be
1744     *                    retrieved.
1745     *
1746     * @return Returns the image of the logo, or null if no application logo
1747     * has been specified.
1748     *
1749     * @throws NameNotFoundException Thrown if the resources for the given
1750     * application could not be loaded.
1751     *
1752     * @see #getApplicationLogo(ApplicationInfo)
1753     */
1754    public abstract Drawable getApplicationLogo(String packageName)
1755            throws NameNotFoundException;
1756
1757    /**
1758     * Retrieve text from a package.  This is a low-level API used by
1759     * the various package manager info structures (such as
1760     * {@link ComponentInfo} to implement retrieval of their associated
1761     * labels and other text.
1762     *
1763     * @param packageName The name of the package that this text is coming from.
1764     * Can not be null.
1765     * @param resid The resource identifier of the desired text.  Can not be 0.
1766     * @param appInfo Overall information about <var>packageName</var>.  This
1767     * may be null, in which case the application information will be retrieved
1768     * for you if needed; if you already have this information around, it can
1769     * be much more efficient to supply it here.
1770     *
1771     * @return Returns a CharSequence holding the requested text.  Returns null
1772     * if the text could not be found for any reason.
1773     */
1774    public abstract CharSequence getText(String packageName, int resid,
1775            ApplicationInfo appInfo);
1776
1777    /**
1778     * Retrieve an XML file from a package.  This is a low-level API used to
1779     * retrieve XML meta data.
1780     *
1781     * @param packageName The name of the package that this xml is coming from.
1782     * Can not be null.
1783     * @param resid The resource identifier of the desired xml.  Can not be 0.
1784     * @param appInfo Overall information about <var>packageName</var>.  This
1785     * may be null, in which case the application information will be retrieved
1786     * for you if needed; if you already have this information around, it can
1787     * be much more efficient to supply it here.
1788     *
1789     * @return Returns an XmlPullParser allowing you to parse out the XML
1790     * data.  Returns null if the xml resource could not be found for any
1791     * reason.
1792     */
1793    public abstract XmlResourceParser getXml(String packageName, int resid,
1794            ApplicationInfo appInfo);
1795
1796    /**
1797     * Return the label to use for this application.
1798     *
1799     * @return Returns the label associated with this application, or null if
1800     * it could not be found for any reason.
1801     * @param info The application to get the label of
1802     */
1803    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
1804
1805    /**
1806     * Retrieve the resources associated with an activity.  Given the full
1807     * name of an activity, retrieves the information about it and calls
1808     * getResources() to return its application's resources.  If the activity
1809     * can not be found, NameNotFoundException is thrown.
1810     *
1811     * @param activityName Name of the activity whose resources are to be
1812     *                     retrieved.
1813     *
1814     * @return Returns the application's Resources.
1815     * @throws NameNotFoundException Thrown if the resources for the given
1816     * application could not be loaded.
1817     *
1818     * @see #getResourcesForApplication(ApplicationInfo)
1819     */
1820    public abstract Resources getResourcesForActivity(ComponentName activityName)
1821            throws NameNotFoundException;
1822
1823    /**
1824     * Retrieve the resources for an application.  Throws NameNotFoundException
1825     * if the package is no longer installed.
1826     *
1827     * @param app Information about the desired application.
1828     *
1829     * @return Returns the application's Resources.
1830     * @throws NameNotFoundException Thrown if the resources for the given
1831     * application could not be loaded (most likely because it was uninstalled).
1832     */
1833    public abstract Resources getResourcesForApplication(ApplicationInfo app)
1834            throws NameNotFoundException;
1835
1836    /**
1837     * Retrieve the resources associated with an application.  Given the full
1838     * package name of an application, retrieves the information about it and
1839     * calls getResources() to return its application's resources.  If the
1840     * appPackageName can not be found, NameNotFoundException is thrown.
1841     *
1842     * @param appPackageName Package name of the application whose resources
1843     *                       are to be retrieved.
1844     *
1845     * @return Returns the application's Resources.
1846     * @throws NameNotFoundException Thrown if the resources for the given
1847     * application could not be loaded.
1848     *
1849     * @see #getResourcesForApplication(ApplicationInfo)
1850     */
1851    public abstract Resources getResourcesForApplication(String appPackageName)
1852            throws NameNotFoundException;
1853
1854    /**
1855     * Retrieve overall information about an application package defined
1856     * in a package archive file
1857     *
1858     * @param archiveFilePath The path to the archive file
1859     * @param flags Additional option flags. Use any combination of
1860     * {@link #GET_ACTIVITIES},
1861     * {@link #GET_GIDS},
1862     * {@link #GET_CONFIGURATIONS},
1863     * {@link #GET_INSTRUMENTATION},
1864     * {@link #GET_PERMISSIONS},
1865     * {@link #GET_PROVIDERS},
1866     * {@link #GET_RECEIVERS},
1867     * {@link #GET_SERVICES},
1868     * {@link #GET_SIGNATURES}, to modify the data returned.
1869     *
1870     * @return Returns the information about the package. Returns
1871     * null if the package could not be successfully parsed.
1872     *
1873     * @see #GET_ACTIVITIES
1874     * @see #GET_GIDS
1875     * @see #GET_CONFIGURATIONS
1876     * @see #GET_INSTRUMENTATION
1877     * @see #GET_PERMISSIONS
1878     * @see #GET_PROVIDERS
1879     * @see #GET_RECEIVERS
1880     * @see #GET_SERVICES
1881     * @see #GET_SIGNATURES
1882     *
1883     */
1884    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
1885        PackageParser packageParser = new PackageParser(archiveFilePath);
1886        DisplayMetrics metrics = new DisplayMetrics();
1887        metrics.setToDefaults();
1888        final File sourceFile = new File(archiveFilePath);
1889        PackageParser.Package pkg = packageParser.parsePackage(
1890                sourceFile, archiveFilePath, metrics, 0);
1891        if (pkg == null) {
1892            return null;
1893        }
1894        return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0);
1895    }
1896
1897    /**
1898     * @hide
1899     *
1900     * Install a package. Since this may take a little while, the result will
1901     * be posted back to the given observer.  An installation will fail if the calling context
1902     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
1903     * package named in the package file's manifest is already installed, or if there's no space
1904     * available on the device.
1905     *
1906     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
1907     * 'content:' URI.
1908     * @param observer An observer callback to get notified when the package installation is
1909     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
1910     * called when that happens.  observer may be null to indicate that no callback is desired.
1911     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
1912     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
1913     * @param installerPackageName Optional package name of the application that is performing the
1914     * installation. This identifies which market the package came from.
1915     */
1916    public abstract void installPackage(
1917            Uri packageURI, IPackageInstallObserver observer, int flags,
1918            String installerPackageName);
1919
1920    /**
1921     * Change the installer associated with a given package.  There are limitations
1922     * on how the installer package can be changed; in particular:
1923     * <ul>
1924     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
1925     * is not signed with the same certificate as the calling application.
1926     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
1927     * has an installer package, and that installer package is not signed with
1928     * the same certificate as the calling application.
1929     * </ul>
1930     *
1931     * @param targetPackage The installed package whose installer will be changed.
1932     * @param installerPackageName The package name of the new installer.  May be
1933     * null to clear the association.
1934     */
1935    public abstract void setInstallerPackageName(String targetPackage,
1936            String installerPackageName);
1937
1938    /**
1939     * Attempts to delete a package.  Since this may take a little while, the result will
1940     * be posted back to the given observer.  A deletion will fail if the calling context
1941     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
1942     * named package cannot be found, or if the named package is a "system package".
1943     * (TODO: include pointer to documentation on "system packages")
1944     *
1945     * @param packageName The name of the package to delete
1946     * @param observer An observer callback to get notified when the package deletion is
1947     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
1948     * called when that happens.  observer may be null to indicate that no callback is desired.
1949     * @param flags - possible values: {@link #DONT_DELETE_DATA}
1950     *
1951     * @hide
1952     */
1953    public abstract void deletePackage(
1954            String packageName, IPackageDeleteObserver observer, int flags);
1955
1956    /**
1957     * Retrieve the package name of the application that installed a package. This identifies
1958     * which market the package came from.
1959     *
1960     * @param packageName The name of the package to query
1961     */
1962    public abstract String getInstallerPackageName(String packageName);
1963
1964    /**
1965     * Attempts to clear the user data directory of an application.
1966     * Since this may take a little while, the result will
1967     * be posted back to the given observer.  A deletion will fail if the
1968     * named package cannot be found, or if the named package is a "system package".
1969     *
1970     * @param packageName The name of the package
1971     * @param observer An observer callback to get notified when the operation is finished
1972     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
1973     * will be called when that happens.  observer may be null to indicate that
1974     * no callback is desired.
1975     *
1976     * @hide
1977     */
1978    public abstract void clearApplicationUserData(String packageName,
1979            IPackageDataObserver observer);
1980    /**
1981     * Attempts to delete the cache files associated with an application.
1982     * Since this may take a little while, the result will
1983     * be posted back to the given observer.  A deletion will fail if the calling context
1984     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
1985     * named package cannot be found, or if the named package is a "system package".
1986     *
1987     * @param packageName The name of the package to delete
1988     * @param observer An observer callback to get notified when the cache file deletion
1989     * is complete.
1990     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
1991     * will be called when that happens.  observer may be null to indicate that
1992     * no callback is desired.
1993     *
1994     * @hide
1995     */
1996    public abstract void deleteApplicationCacheFiles(String packageName,
1997            IPackageDataObserver observer);
1998
1999    /**
2000     * Free storage by deleting LRU sorted list of cache files across
2001     * all applications. If the currently available free storage
2002     * on the device is greater than or equal to the requested
2003     * free storage, no cache files are cleared. If the currently
2004     * available storage on the device is less than the requested
2005     * free storage, some or all of the cache files across
2006     * all applications are deleted (based on last accessed time)
2007     * to increase the free storage space on the device to
2008     * the requested value. There is no guarantee that clearing all
2009     * the cache files from all applications will clear up
2010     * enough storage to achieve the desired value.
2011     * @param freeStorageSize The number of bytes of storage to be
2012     * freed by the system. Say if freeStorageSize is XX,
2013     * and the current free storage is YY,
2014     * if XX is less than YY, just return. if not free XX-YY number
2015     * of bytes if possible.
2016     * @param observer call back used to notify when
2017     * the operation is completed
2018     *
2019     * @hide
2020     */
2021    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
2022
2023    /**
2024     * Free storage by deleting LRU sorted list of cache files across
2025     * all applications. If the currently available free storage
2026     * on the device is greater than or equal to the requested
2027     * free storage, no cache files are cleared. If the currently
2028     * available storage on the device is less than the requested
2029     * free storage, some or all of the cache files across
2030     * all applications are deleted (based on last accessed time)
2031     * to increase the free storage space on the device to
2032     * the requested value. There is no guarantee that clearing all
2033     * the cache files from all applications will clear up
2034     * enough storage to achieve the desired value.
2035     * @param freeStorageSize The number of bytes of storage to be
2036     * freed by the system. Say if freeStorageSize is XX,
2037     * and the current free storage is YY,
2038     * if XX is less than YY, just return. if not free XX-YY number
2039     * of bytes if possible.
2040     * @param pi IntentSender call back used to
2041     * notify when the operation is completed.May be null
2042     * to indicate that no call back is desired.
2043     *
2044     * @hide
2045     */
2046    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
2047
2048    /**
2049     * Retrieve the size information for a package.
2050     * Since this may take a little while, the result will
2051     * be posted back to the given observer.  The calling context
2052     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
2053     *
2054     * @param packageName The name of the package whose size information is to be retrieved
2055     * @param observer An observer callback to get notified when the operation
2056     * is complete.
2057     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
2058     * The observer's callback is invoked with a PackageStats object(containing the
2059     * code, data and cache sizes of the package) and a boolean value representing
2060     * the status of the operation. observer may be null to indicate that
2061     * no callback is desired.
2062     *
2063     * @hide
2064     */
2065    public abstract void getPackageSizeInfo(String packageName,
2066            IPackageStatsObserver observer);
2067
2068    /**
2069     * @deprecated This function no longer does anything; it was an old
2070     * approach to managing preferred activities, which has been superceeded
2071     * (and conflicts with) the modern activity-based preferences.
2072     */
2073    @Deprecated
2074    public abstract void addPackageToPreferred(String packageName);
2075
2076    /**
2077     * @deprecated This function no longer does anything; it was an old
2078     * approach to managing preferred activities, which has been superceeded
2079     * (and conflicts with) the modern activity-based preferences.
2080     */
2081    @Deprecated
2082    public abstract void removePackageFromPreferred(String packageName);
2083
2084    /**
2085     * Retrieve the list of all currently configured preferred packages.  The
2086     * first package on the list is the most preferred, the last is the
2087     * least preferred.
2088     *
2089     * @param flags Additional option flags. Use any combination of
2090     * {@link #GET_ACTIVITIES},
2091     * {@link #GET_GIDS},
2092     * {@link #GET_CONFIGURATIONS},
2093     * {@link #GET_INSTRUMENTATION},
2094     * {@link #GET_PERMISSIONS},
2095     * {@link #GET_PROVIDERS},
2096     * {@link #GET_RECEIVERS},
2097     * {@link #GET_SERVICES},
2098     * {@link #GET_SIGNATURES}, to modify the data returned.
2099     *
2100     * @return Returns a list of PackageInfo objects describing each
2101     * preferred application, in order of preference.
2102     *
2103     * @see #GET_ACTIVITIES
2104     * @see #GET_GIDS
2105     * @see #GET_CONFIGURATIONS
2106     * @see #GET_INSTRUMENTATION
2107     * @see #GET_PERMISSIONS
2108     * @see #GET_PROVIDERS
2109     * @see #GET_RECEIVERS
2110     * @see #GET_SERVICES
2111     * @see #GET_SIGNATURES
2112     */
2113    public abstract List<PackageInfo> getPreferredPackages(int flags);
2114
2115    /**
2116     * @deprecated This is a protected API that should not have been available
2117     * to third party applications.  It is the platform's responsibility for
2118     * assigning preferred activities and this can not be directly modified.
2119     *
2120     * Add a new preferred activity mapping to the system.  This will be used
2121     * to automatically select the given activity component when
2122     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2123     * multiple matching activities and also matches the given filter.
2124     *
2125     * @param filter The set of intents under which this activity will be
2126     * made preferred.
2127     * @param match The IntentFilter match category that this preference
2128     * applies to.
2129     * @param set The set of activities that the user was picking from when
2130     * this preference was made.
2131     * @param activity The component name of the activity that is to be
2132     * preferred.
2133     */
2134    @Deprecated
2135    public abstract void addPreferredActivity(IntentFilter filter, int match,
2136            ComponentName[] set, ComponentName activity);
2137
2138    /**
2139     * @deprecated This is a protected API that should not have been available
2140     * to third party applications.  It is the platform's responsibility for
2141     * assigning preferred activities and this can not be directly modified.
2142     *
2143     * Replaces an existing preferred activity mapping to the system, and if that were not present
2144     * adds a new preferred activity.  This will be used
2145     * to automatically select the given activity component when
2146     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2147     * multiple matching activities and also matches the given filter.
2148     *
2149     * @param filter The set of intents under which this activity will be
2150     * made preferred.
2151     * @param match The IntentFilter match category that this preference
2152     * applies to.
2153     * @param set The set of activities that the user was picking from when
2154     * this preference was made.
2155     * @param activity The component name of the activity that is to be
2156     * preferred.
2157     * @hide
2158     */
2159    @Deprecated
2160    public abstract void replacePreferredActivity(IntentFilter filter, int match,
2161            ComponentName[] set, ComponentName activity);
2162
2163    /**
2164     * Remove all preferred activity mappings, previously added with
2165     * {@link #addPreferredActivity}, from the
2166     * system whose activities are implemented in the given package name.
2167     * An application can only clear its own package(s).
2168     *
2169     * @param packageName The name of the package whose preferred activity
2170     * mappings are to be removed.
2171     */
2172    public abstract void clearPackagePreferredActivities(String packageName);
2173
2174    /**
2175     * Retrieve all preferred activities, previously added with
2176     * {@link #addPreferredActivity}, that are
2177     * currently registered with the system.
2178     *
2179     * @param outFilters A list in which to place the filters of all of the
2180     * preferred activities, or null for none.
2181     * @param outActivities A list in which to place the component names of
2182     * all of the preferred activities, or null for none.
2183     * @param packageName An option package in which you would like to limit
2184     * the list.  If null, all activities will be returned; if non-null, only
2185     * those activities in the given package are returned.
2186     *
2187     * @return Returns the total number of registered preferred activities
2188     * (the number of distinct IntentFilter records, not the number of unique
2189     * activity components) that were found.
2190     */
2191    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
2192            List<ComponentName> outActivities, String packageName);
2193
2194    /**
2195     * Set the enabled setting for a package component (activity, receiver, service, provider).
2196     * This setting will override any enabled state which may have been set by the component in its
2197     * manifest.
2198     *
2199     * @param componentName The component to enable
2200     * @param newState The new enabled state for the component.  The legal values for this state
2201     *                 are:
2202     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2203     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2204     *                   and
2205     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2206     *                 The last one removes the setting, thereby restoring the component's state to
2207     *                 whatever was set in it's manifest (or enabled, by default).
2208     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2209     */
2210    public abstract void setComponentEnabledSetting(ComponentName componentName,
2211            int newState, int flags);
2212
2213
2214    /**
2215     * Return the the enabled setting for a package component (activity,
2216     * receiver, service, provider).  This returns the last value set by
2217     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
2218     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2219     * the value originally specified in the manifest has not been modified.
2220     *
2221     * @param componentName The component to retrieve.
2222     * @return Returns the current enabled state for the component.  May
2223     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2224     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2225     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2226     * component's enabled state is based on the original information in
2227     * the manifest as found in {@link ComponentInfo}.
2228     */
2229    public abstract int getComponentEnabledSetting(ComponentName componentName);
2230
2231    /**
2232     * Set the enabled setting for an application
2233     * This setting will override any enabled state which may have been set by the application in
2234     * its manifest.  It also overrides the enabled state set in the manifest for any of the
2235     * application's components.  It does not override any enabled state set by
2236     * {@link #setComponentEnabledSetting} for any of the application's components.
2237     *
2238     * @param packageName The package name of the application to enable
2239     * @param newState The new enabled state for the component.  The legal values for this state
2240     *                 are:
2241     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2242     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2243     *                   and
2244     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2245     *                 The last one removes the setting, thereby restoring the applications's state to
2246     *                 whatever was set in its manifest (or enabled, by default).
2247     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2248     */
2249    public abstract void setApplicationEnabledSetting(String packageName,
2250            int newState, int flags);
2251
2252    /**
2253     * Return the the enabled setting for an application.  This returns
2254     * the last value set by
2255     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
2256     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2257     * the value originally specified in the manifest has not been modified.
2258     *
2259     * @param packageName The component to retrieve.
2260     * @return Returns the current enabled state for the component.  May
2261     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2262     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2263     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2264     * application's enabled state is based on the original information in
2265     * the manifest as found in {@link ComponentInfo}.
2266     */
2267    public abstract int getApplicationEnabledSetting(String packageName);
2268
2269    /**
2270     * Return whether the device has been booted into safe mode.
2271     */
2272    public abstract boolean isSafeMode();
2273
2274    /**
2275     * Attempts to move package resources from internal to external media or vice versa.
2276     * Since this may take a little while, the result will
2277     * be posted back to the given observer.   This call may fail if the calling context
2278     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
2279     * named package cannot be found, or if the named package is a "system package".
2280     *
2281     * @param packageName The name of the package to delete
2282     * @param observer An observer callback to get notified when the package move is
2283     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
2284     * called when that happens.  observer may be null to indicate that no callback is desired.
2285     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
2286     * {@link #MOVE_EXTERNAL_MEDIA}
2287     *
2288     * @hide
2289     */
2290    public abstract void movePackage(
2291            String packageName, IPackageMoveObserver observer, int flags);
2292
2293    /**
2294     * Sets the Opaque Binary Blob (OBB) file location.
2295     * <p>
2296     * NOTE: The existence or format of this file is not currently checked, but
2297     * it may be in the future.
2298     *
2299     * @param packageName Name of the package with which to associate the .obb
2300     *            file
2301     * @param path Path on the filesystem to the .obb file
2302     * @hide
2303     */
2304    public abstract void setPackageObbPath(String packageName, String path);
2305}
2306