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