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