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