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