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