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