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