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