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