PackageManager.java revision 45b8b464992bbfa9bd2a587f05c1e1723aedcecd
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.pm.ManifestDigest;
27import android.content.res.Resources;
28import android.content.res.XmlResourceParser;
29import android.graphics.drawable.Drawable;
30import android.net.Uri;
31import android.util.AndroidException;
32import android.util.DisplayMetrics;
33
34import java.io.File;
35import java.util.List;
36
37/**
38 * Class for retrieving various kinds of information related to the application
39 * packages that are currently installed on the device.
40 *
41 * You can find this class through {@link Context#getPackageManager}.
42 */
43public abstract class PackageManager {
44
45    /**
46     * This exception is thrown when a given package, application, or component
47     * name can not be found.
48     */
49    public static class NameNotFoundException extends AndroidException {
50        public NameNotFoundException() {
51        }
52
53        public NameNotFoundException(String name) {
54            super(name);
55        }
56    }
57
58    /**
59     * {@link PackageInfo} flag: return information about
60     * activities in the package in {@link PackageInfo#activities}.
61     */
62    public static final int GET_ACTIVITIES              = 0x00000001;
63
64    /**
65     * {@link PackageInfo} flag: return information about
66     * intent receivers in the package in
67     * {@link PackageInfo#receivers}.
68     */
69    public static final int GET_RECEIVERS               = 0x00000002;
70
71    /**
72     * {@link PackageInfo} flag: return information about
73     * services in the package in {@link PackageInfo#services}.
74     */
75    public static final int GET_SERVICES                = 0x00000004;
76
77    /**
78     * {@link PackageInfo} flag: return information about
79     * content providers in the package in
80     * {@link PackageInfo#providers}.
81     */
82    public static final int GET_PROVIDERS               = 0x00000008;
83
84    /**
85     * {@link PackageInfo} flag: return information about
86     * instrumentation in the package in
87     * {@link PackageInfo#instrumentation}.
88     */
89    public static final int GET_INSTRUMENTATION         = 0x00000010;
90
91    /**
92     * {@link PackageInfo} flag: return information about the
93     * intent filters supported by the activity.
94     */
95    public static final int GET_INTENT_FILTERS          = 0x00000020;
96
97    /**
98     * {@link PackageInfo} flag: return information about the
99     * signatures included in the package.
100     */
101    public static final int GET_SIGNATURES          = 0x00000040;
102
103    /**
104     * {@link ResolveInfo} flag: return the IntentFilter that
105     * was matched for a particular ResolveInfo in
106     * {@link ResolveInfo#filter}.
107     */
108    public static final int GET_RESOLVED_FILTER         = 0x00000040;
109
110    /**
111     * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
112     * data {@link android.os.Bundle}s that are associated with a component.
113     * This applies for any API returning a ComponentInfo subclass.
114     */
115    public static final int GET_META_DATA               = 0x00000080;
116
117    /**
118     * {@link PackageInfo} flag: return the
119     * {@link PackageInfo#gids group ids} that are associated with an
120     * application.
121     * This applies for any API returning an PackageInfo class, either
122     * directly or nested inside of another.
123     */
124    public static final int GET_GIDS                    = 0x00000100;
125
126    /**
127     * {@link PackageInfo} flag: include disabled components in the returned info.
128     */
129    public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
130
131    /**
132     * {@link ApplicationInfo} flag: return the
133     * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
134     * that are associated with an application.
135     * This applies for any API returning an ApplicationInfo class, either
136     * directly or nested inside of another.
137     */
138    public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
139
140    /**
141     * {@link ProviderInfo} flag: return the
142     * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
143     * that are associated with a content provider.
144     * This applies for any API returning an ProviderInfo class, either
145     * directly or nested inside of another.
146     */
147    public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
148    /**
149     * {@link PackageInfo} flag: return information about
150     * permissions in the package in
151     * {@link PackageInfo#permissions}.
152     */
153    public static final int GET_PERMISSIONS               = 0x00001000;
154
155    /**
156     * Flag parameter to retrieve all applications(even uninstalled ones) with data directories.
157     * This state could have resulted if applications have been deleted with flag
158     * DONT_DELETE_DATA
159     * with a possibility of being replaced or reinstalled in future
160     */
161    public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
162
163    /**
164     * {@link PackageInfo} flag: return information about
165     * hardware preferences in
166     * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
167     * requested features in {@link PackageInfo#reqFeatures
168     * PackageInfo.reqFeatures}.
169     */
170    public static final int GET_CONFIGURATIONS = 0x00004000;
171
172    /**
173     * Resolution and querying flag: if set, only filters that support the
174     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
175     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
176     * supplied Intent.
177     */
178    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
179
180    /**
181     * Permission check result: this is returned by {@link #checkPermission}
182     * if the permission has been granted to the given package.
183     */
184    public static final int PERMISSION_GRANTED = 0;
185
186    /**
187     * Permission check result: this is returned by {@link #checkPermission}
188     * if the permission has not been granted to the given package.
189     */
190    public static final int PERMISSION_DENIED = -1;
191
192    /**
193     * Signature check result: this is returned by {@link #checkSignatures}
194     * if all signatures on the two packages match.
195     */
196    public static final int SIGNATURE_MATCH = 0;
197
198    /**
199     * Signature check result: this is returned by {@link #checkSignatures}
200     * if neither of the two packages is signed.
201     */
202    public static final int SIGNATURE_NEITHER_SIGNED = 1;
203
204    /**
205     * Signature check result: this is returned by {@link #checkSignatures}
206     * if the first package is not signed but the second is.
207     */
208    public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
209
210    /**
211     * Signature check result: this is returned by {@link #checkSignatures}
212     * if the second package is not signed but the first is.
213     */
214    public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
215
216    /**
217     * Signature check result: this is returned by {@link #checkSignatures}
218     * if not all signatures on both packages match.
219     */
220    public static final int SIGNATURE_NO_MATCH = -3;
221
222    /**
223     * Signature check result: this is returned by {@link #checkSignatures}
224     * if either of the packages are not valid.
225     */
226    public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
227
228    /**
229     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
230     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
231     * component or application is in its default enabled state (as specified
232     * in its manifest).
233     */
234    public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
235
236    /**
237     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
238     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
239     * component or application has been explictily enabled, regardless of
240     * what it has specified in its manifest.
241     */
242    public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
243
244    /**
245     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
246     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
247     * component or application has been explicitly disabled, regardless of
248     * what it has specified in its manifest.
249     */
250    public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
251
252    /**
253     * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
254     * user has explicitly disabled the application, regardless of what it has
255     * specified in its manifest.  Because this is due to the user's request,
256     * they may re-enable it if desired through the appropriate system UI.  This
257     * option currently <strong>can not</strong> be used with
258     * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
259     */
260    public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
261
262    /**
263     * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
264     * indicate that this package should be installed as forward locked, i.e. only the app itself
265     * should have access to its code and non-resource assets.
266     * @hide
267     */
268    public static final int INSTALL_FORWARD_LOCK = 0x00000001;
269
270    /**
271     * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
272     * installed package, if one exists.
273     * @hide
274     */
275    public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
276
277    /**
278     * Flag parameter for {@link #installPackage} to indicate that you want to
279     * allow test packages (those that have set android:testOnly in their
280     * manifest) to be installed.
281     * @hide
282     */
283    public static final int INSTALL_ALLOW_TEST = 0x00000004;
284
285    /**
286     * Flag parameter for {@link #installPackage} to indicate that this
287     * package has to be installed on the sdcard.
288     * @hide
289     */
290    public static final int INSTALL_EXTERNAL = 0x00000008;
291
292    /**
293     * Flag parameter for {@link #installPackage} to indicate that this package
294     * has to be installed on the sdcard.
295     * @hide
296     */
297    public static final int INSTALL_INTERNAL = 0x00000010;
298
299    /**
300     * Flag parameter for {@link #installPackage} to indicate that this install
301     * was initiated via ADB.
302     *
303     * @hide
304     */
305    public static final int INSTALL_FROM_ADB = 0x00000020;
306
307    /**
308     * Flag parameter for
309     * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
310     * that you don't want to kill the app containing the component.  Be careful when you set this
311     * since changing component states can make the containing application's behavior unpredictable.
312     */
313    public static final int DONT_KILL_APP = 0x00000001;
314
315    /**
316     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
317     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
318     * @hide
319     */
320    public static final int INSTALL_SUCCEEDED = 1;
321
322    /**
323     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
324     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
325     * already installed.
326     * @hide
327     */
328    public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
329
330    /**
331     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
332     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
333     * file is invalid.
334     * @hide
335     */
336    public static final int INSTALL_FAILED_INVALID_APK = -2;
337
338    /**
339     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
340     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
341     * is invalid.
342     * @hide
343     */
344    public static final int INSTALL_FAILED_INVALID_URI = -3;
345
346    /**
347     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
348     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
349     * service found that the device didn't have enough storage space to install the app.
350     * @hide
351     */
352    public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
353
354    /**
355     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
356     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
357     * package is already installed with the same name.
358     * @hide
359     */
360    public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
361
362    /**
363     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
364     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
365     * the requested shared user does not exist.
366     * @hide
367     */
368    public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
369
370    /**
371     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
372     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
373     * a previously installed package of the same name has a different signature
374     * than the new package (and the old package's data was not removed).
375     * @hide
376     */
377    public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
378
379    /**
380     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
381     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
382     * the new package is requested a shared user which is already installed on the
383     * device and does not have matching signature.
384     * @hide
385     */
386    public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
387
388    /**
389     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
390     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
391     * the new package uses a shared library that is not available.
392     * @hide
393     */
394    public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
395
396    /**
397     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
398     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
399     * the new package uses a shared library that is not available.
400     * @hide
401     */
402    public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
403
404    /**
405     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
406     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
407     * the new package failed while optimizing and validating its dex files,
408     * either because there was not enough storage or the validation failed.
409     * @hide
410     */
411    public static final int INSTALL_FAILED_DEXOPT = -11;
412
413    /**
414     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
415     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
416     * the new package failed because the current SDK version is older than
417     * that required by the package.
418     * @hide
419     */
420    public static final int INSTALL_FAILED_OLDER_SDK = -12;
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 failed because it contains a content provider with the
426     * same authority as a provider already installed in the system.
427     * @hide
428     */
429    public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
430
431    /**
432     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
433     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
434     * the new package failed because the current SDK version is newer than
435     * that required by the package.
436     * @hide
437     */
438    public static final int INSTALL_FAILED_NEWER_SDK = -14;
439
440    /**
441     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
442     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
443     * the new package failed because it has specified that it is a test-only
444     * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
445     * flag.
446     * @hide
447     */
448    public static final int INSTALL_FAILED_TEST_ONLY = -15;
449
450    /**
451     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
452     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
453     * the package being installed contains native code, but none that is
454     * compatible with the the device's CPU_ABI.
455     * @hide
456     */
457    public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
458
459    /**
460     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
461     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
462     * the new package uses a feature that is not available.
463     * @hide
464     */
465    public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
466
467    // ------ Errors related to sdcard
468    /**
469     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
470     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
471     * a secure container mount point couldn't be accessed on external media.
472     * @hide
473     */
474    public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
475
476    /**
477     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
478     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
479     * the new package couldn't be installed in the specified install
480     * location.
481     * @hide
482     */
483    public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
484
485    /**
486     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
487     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
488     * the new package couldn't be installed in the specified install
489     * location because the media is not available.
490     * @hide
491     */
492    public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
493
494    /**
495     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
496     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
497     * the new package couldn't be installed because the verification timed out.
498     * @hide
499     */
500    public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
501
502    /**
503     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
504     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
505     * the new package couldn't be installed because the verification did not succeed.
506     * @hide
507     */
508    public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
509
510    /**
511     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
512     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
513     * the package changed from what the calling program expected.
514     * @hide
515     */
516    public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
517
518    /**
519     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
520     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
521     * if the parser was given a path that is not a file, or does not end with the expected
522     * '.apk' extension.
523     * @hide
524     */
525    public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
526
527    /**
528     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
529     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
530     * if the parser was unable to retrieve the AndroidManifest.xml file.
531     * @hide
532     */
533    public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
534
535    /**
536     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
537     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
538     * if the parser encountered an unexpected exception.
539     * @hide
540     */
541    public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
542
543    /**
544     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
545     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
546     * if the parser did not find any certificates in the .apk.
547     * @hide
548     */
549    public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
550
551    /**
552     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
553     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
554     * if the parser found inconsistent certificates on the files in the .apk.
555     * @hide
556     */
557    public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
558
559    /**
560     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
561     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
562     * if the parser encountered a CertificateEncodingException in one of the
563     * files in the .apk.
564     * @hide
565     */
566    public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
567
568    /**
569     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
570     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
571     * if the parser encountered a bad or missing package name in the manifest.
572     * @hide
573     */
574    public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
575
576    /**
577     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
578     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
579     * if the parser encountered a bad shared user id name in the manifest.
580     * @hide
581     */
582    public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
583
584    /**
585     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
586     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
587     * if the parser encountered some structural problem in the manifest.
588     * @hide
589     */
590    public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
591
592    /**
593     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
594     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
595     * if the parser did not find any actionable tags (instrumentation or application)
596     * in the manifest.
597     * @hide
598     */
599    public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
600
601    /**
602     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
603     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
604     * if the system failed to install the package because of system issues.
605     * @hide
606     */
607    public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
608
609    /**
610     * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
611     * package's data directory.
612     *
613     * @hide
614     */
615    public static final int DONT_DELETE_DATA = 0x00000001;
616
617    /**
618     * Return code for when package deletion succeeds. This is passed to the
619     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
620     * succeeded in deleting the package.
621     *
622     * @hide
623     */
624    public static final int DELETE_SUCCEEDED = 1;
625
626    /**
627     * Deletion failed return code: this is passed to the
628     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
629     * failed to delete the package for an unspecified reason.
630     *
631     * @hide
632     */
633    public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
634
635    /**
636     * Deletion failed return code: this is passed to the
637     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
638     * failed to delete the package because it is the active DevicePolicy
639     * manager.
640     *
641     * @hide
642     */
643    public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
644
645    /**
646     * Return code that is passed to the {@link IPackageMoveObserver} by
647     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
648     * package has been successfully moved by the system.
649     *
650     * @hide
651     */
652    public static final int MOVE_SUCCEEDED = 1;
653    /**
654     * Error code that is passed to the {@link IPackageMoveObserver} by
655     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
656     * when the package hasn't been successfully moved by the system
657     * because of insufficient memory on specified media.
658     * @hide
659     */
660    public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
661
662    /**
663     * Error code that is passed to the {@link IPackageMoveObserver} by
664     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
665     * if the specified package doesn't exist.
666     * @hide
667     */
668    public static final int MOVE_FAILED_DOESNT_EXIST = -2;
669
670    /**
671     * Error code that is passed to the {@link IPackageMoveObserver} by
672     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
673     * if the specified package cannot be moved since its a system package.
674     * @hide
675     */
676    public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
677
678    /**
679     * Error code that is passed to the {@link IPackageMoveObserver} by
680     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
681     * if the specified package cannot be moved since its forward locked.
682     * @hide
683     */
684    public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
685
686    /**
687     * Error code that is passed to the {@link IPackageMoveObserver} by
688     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
689     * if the specified package cannot be moved to the specified location.
690     * @hide
691     */
692    public static final int MOVE_FAILED_INVALID_LOCATION = -5;
693
694    /**
695     * Error code that is passed to the {@link IPackageMoveObserver} by
696     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
697     * if the specified package cannot be moved to the specified location.
698     * @hide
699     */
700    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
701
702    /**
703     * Error code that is passed to the {@link IPackageMoveObserver} by
704     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
705     * specified package already has an operation pending in the
706     * {@link PackageHandler} queue.
707     *
708     * @hide
709     */
710    public static final int MOVE_FAILED_OPERATION_PENDING = -7;
711
712    /**
713     * Flag parameter for {@link #movePackage} to indicate that
714     * the package should be moved to internal storage if its
715     * been installed on external media.
716     * @hide
717     */
718    public static final int MOVE_INTERNAL = 0x00000001;
719
720    /**
721     * Flag parameter for {@link #movePackage} to indicate that
722     * the package should be moved to external media.
723     * @hide
724     */
725    public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
726
727    /**
728     * Range of IDs allocated for a user.
729     * @hide
730     */
731    public static final int PER_USER_RANGE = 100000;
732
733    /**
734     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
735     * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
736     * lag in sound input or output.
737     */
738    @SdkConstant(SdkConstantType.FEATURE)
739    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
740
741    /**
742     * Feature for {@link #getSystemAvailableFeatures} and
743     * {@link #hasSystemFeature}: The device is capable of communicating with
744     * other devices via Bluetooth.
745     */
746    @SdkConstant(SdkConstantType.FEATURE)
747    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
748
749    /**
750     * Feature for {@link #getSystemAvailableFeatures} and
751     * {@link #hasSystemFeature}: The device has a camera facing away
752     * from the screen.
753     */
754    @SdkConstant(SdkConstantType.FEATURE)
755    public static final String FEATURE_CAMERA = "android.hardware.camera";
756
757    /**
758     * Feature for {@link #getSystemAvailableFeatures} and
759     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
760     */
761    @SdkConstant(SdkConstantType.FEATURE)
762    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
763
764    /**
765     * Feature for {@link #getSystemAvailableFeatures} and
766     * {@link #hasSystemFeature}: The device's camera supports flash.
767     */
768    @SdkConstant(SdkConstantType.FEATURE)
769    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
770
771    /**
772     * Feature for {@link #getSystemAvailableFeatures} and
773     * {@link #hasSystemFeature}: The device has a front facing camera.
774     */
775    @SdkConstant(SdkConstantType.FEATURE)
776    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
777
778    /**
779     * Feature for {@link #getSystemAvailableFeatures} and
780     * {@link #hasSystemFeature}: The device supports one or more methods of
781     * reporting current location.
782     */
783    @SdkConstant(SdkConstantType.FEATURE)
784    public static final String FEATURE_LOCATION = "android.hardware.location";
785
786    /**
787     * Feature for {@link #getSystemAvailableFeatures} and
788     * {@link #hasSystemFeature}: The device has a Global Positioning System
789     * receiver and can report precise location.
790     */
791    @SdkConstant(SdkConstantType.FEATURE)
792    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
793
794    /**
795     * Feature for {@link #getSystemAvailableFeatures} and
796     * {@link #hasSystemFeature}: The device can report location with coarse
797     * accuracy using a network-based geolocation system.
798     */
799    @SdkConstant(SdkConstantType.FEATURE)
800    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
801
802    /**
803     * Feature for {@link #getSystemAvailableFeatures} and
804     * {@link #hasSystemFeature}: The device can record audio via a
805     * microphone.
806     */
807    @SdkConstant(SdkConstantType.FEATURE)
808    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
809
810    /**
811     * Feature for {@link #getSystemAvailableFeatures} and
812     * {@link #hasSystemFeature}: The device can communicate using Near-Field
813     * Communications (NFC).
814     */
815    @SdkConstant(SdkConstantType.FEATURE)
816    public static final String FEATURE_NFC = "android.hardware.nfc";
817
818    /**
819     * Feature for {@link #getSystemAvailableFeatures} and
820     * {@link #hasSystemFeature}: The device includes an accelerometer.
821     */
822    @SdkConstant(SdkConstantType.FEATURE)
823    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
824
825    /**
826     * Feature for {@link #getSystemAvailableFeatures} and
827     * {@link #hasSystemFeature}: The device includes a barometer (air
828     * pressure sensor.)
829     */
830    @SdkConstant(SdkConstantType.FEATURE)
831    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
832
833    /**
834     * Feature for {@link #getSystemAvailableFeatures} and
835     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
836     */
837    @SdkConstant(SdkConstantType.FEATURE)
838    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
839
840    /**
841     * Feature for {@link #getSystemAvailableFeatures} and
842     * {@link #hasSystemFeature}: The device includes a gyroscope.
843     */
844    @SdkConstant(SdkConstantType.FEATURE)
845    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
846
847    /**
848     * Feature for {@link #getSystemAvailableFeatures} and
849     * {@link #hasSystemFeature}: The device includes a light sensor.
850     */
851    @SdkConstant(SdkConstantType.FEATURE)
852    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
853
854    /**
855     * Feature for {@link #getSystemAvailableFeatures} and
856     * {@link #hasSystemFeature}: The device includes a proximity sensor.
857     */
858    @SdkConstant(SdkConstantType.FEATURE)
859    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
860
861    /**
862     * Feature for {@link #getSystemAvailableFeatures} and
863     * {@link #hasSystemFeature}: The device has a telephony radio with data
864     * communication support.
865     */
866    @SdkConstant(SdkConstantType.FEATURE)
867    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
868
869    /**
870     * Feature for {@link #getSystemAvailableFeatures} and
871     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
872     */
873    @SdkConstant(SdkConstantType.FEATURE)
874    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
875
876    /**
877     * Feature for {@link #getSystemAvailableFeatures} and
878     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
879     */
880    @SdkConstant(SdkConstantType.FEATURE)
881    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
882
883    /**
884     * Feature for {@link #getSystemAvailableFeatures} and
885     * {@link #hasSystemFeature}: The device supports connecting to USB devices
886     * as the USB host.
887     */
888    @SdkConstant(SdkConstantType.FEATURE)
889    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
890
891    /**
892     * Feature for {@link #getSystemAvailableFeatures} and
893     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
894     */
895    @SdkConstant(SdkConstantType.FEATURE)
896    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
897
898    /**
899     * Feature for {@link #getSystemAvailableFeatures} and
900     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
901     */
902    @SdkConstant(SdkConstantType.FEATURE)
903    public static final String FEATURE_SIP = "android.software.sip";
904
905    /**
906     * Feature for {@link #getSystemAvailableFeatures} and
907     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
908     */
909    @SdkConstant(SdkConstantType.FEATURE)
910    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
911
912    /**
913     * Feature for {@link #getSystemAvailableFeatures} and
914     * {@link #hasSystemFeature}: The device's display has a touch screen.
915     */
916    @SdkConstant(SdkConstantType.FEATURE)
917    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
918
919
920    /**
921     * Feature for {@link #getSystemAvailableFeatures} and
922     * {@link #hasSystemFeature}: The device's touch screen supports
923     * multitouch sufficient for basic two-finger gesture detection.
924     */
925    @SdkConstant(SdkConstantType.FEATURE)
926    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
927
928    /**
929     * Feature for {@link #getSystemAvailableFeatures} and
930     * {@link #hasSystemFeature}: The device's touch screen is capable of
931     * tracking two or more fingers fully independently.
932     */
933    @SdkConstant(SdkConstantType.FEATURE)
934    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
935
936    /**
937     * Feature for {@link #getSystemAvailableFeatures} and
938     * {@link #hasSystemFeature}: The device's touch screen is capable of
939     * tracking a full hand of fingers fully independently -- that is, 5 or
940     * more simultaneous independent pointers.
941     */
942    @SdkConstant(SdkConstantType.FEATURE)
943    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
944
945    /**
946     * Feature for {@link #getSystemAvailableFeatures} and
947     * {@link #hasSystemFeature}: The device does not have a touch screen, but
948     * does support touch emulation for basic events. For instance, the
949     * device might use a mouse or remote control to drive a cursor, and
950     * emulate basic touch pointer events like down, up, drag, etc. All
951     * devices that support android.hardware.touchscreen or a sub-feature are
952     * presumed to also support faketouch.
953     */
954    @SdkConstant(SdkConstantType.FEATURE)
955    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
956
957    /**
958     * Feature for {@link #getSystemAvailableFeatures} and
959     * {@link #hasSystemFeature}: The device does not have a touch screen, but
960     * does support touch emulation for basic events that supports distinct
961     * tracking of two or more fingers.  This is an extension of
962     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
963     * that unlike a distinct multitouch screen as defined by
964     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
965     * devices will not actually provide full two-finger gestures since the
966     * input is being transformed to cursor movement on the screen.  That is,
967     * single finger gestures will move a cursor; two-finger swipes will
968     * result in single-finger touch events; other two-finger gestures will
969     * result in the corresponding two-finger touch event.
970     */
971    @SdkConstant(SdkConstantType.FEATURE)
972    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
973
974    /**
975     * Feature for {@link #getSystemAvailableFeatures} and
976     * {@link #hasSystemFeature}: The device does not have a touch screen, but
977     * does support touch emulation for basic events that supports tracking
978     * a hand of fingers (5 or more fingers) fully independently.
979     * This is an extension of
980     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
981     * that unlike a multitouch screen as defined by
982     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
983     * gestures can be detected due to the limitations described for
984     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
985     */
986    @SdkConstant(SdkConstantType.FEATURE)
987    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
988
989    /**
990     * Feature for {@link #getSystemAvailableFeatures} and
991     * {@link #hasSystemFeature}: The device supports portrait orientation
992     * screens.  For backwards compatibility, you can assume that if neither
993     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
994     * both portrait and landscape.
995     */
996    @SdkConstant(SdkConstantType.FEATURE)
997    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
998
999    /**
1000     * Feature for {@link #getSystemAvailableFeatures} and
1001     * {@link #hasSystemFeature}: The device supports landscape orientation
1002     * screens.  For backwards compatibility, you can assume that if neither
1003     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1004     * both portrait and landscape.
1005     */
1006    @SdkConstant(SdkConstantType.FEATURE)
1007    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1008
1009    /**
1010     * Feature for {@link #getSystemAvailableFeatures} and
1011     * {@link #hasSystemFeature}: The device supports live wallpapers.
1012     */
1013    @SdkConstant(SdkConstantType.FEATURE)
1014    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1015
1016    /**
1017     * Feature for {@link #getSystemAvailableFeatures} and
1018     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1019     */
1020    @SdkConstant(SdkConstantType.FEATURE)
1021    public static final String FEATURE_WIFI = "android.hardware.wifi";
1022
1023    /**
1024     * Feature for {@link #getSystemAvailableFeatures} and
1025     * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1026     */
1027    @SdkConstant(SdkConstantType.FEATURE)
1028    public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1029
1030    /**
1031     * Action to external storage service to clean out removed apps.
1032     * @hide
1033     */
1034    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1035            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1036
1037    /**
1038     * Extra field name for the URI to a verification file. Passed to a package
1039     * verifier.
1040     *
1041     * @hide
1042     */
1043    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1044
1045    /**
1046     * Extra field name for the ID of a package pending verification. Passed to
1047     * a package verifier and is used to call back to
1048     * {@link PackageManager#verifyPendingInstall(int, boolean)}
1049     *
1050     * @hide
1051     */
1052    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1053
1054    /**
1055     * Extra field name for the package identifier which is trying to install
1056     * the package.
1057     *
1058     * @hide
1059     */
1060    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1061            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1062
1063    /**
1064     * Extra field name for the requested install flags for a package pending
1065     * verification. Passed to a package verifier.
1066     *
1067     * @hide
1068     */
1069    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1070            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1071
1072    /**
1073     * Retrieve overall information about an application package that is
1074     * installed on the system.
1075     * <p>
1076     * Throws {@link NameNotFoundException} if a package with the given name can
1077     * not be found on the system.
1078     *
1079     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1080     *            desired package.
1081     * @param flags Additional option flags. Use any combination of
1082     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1083     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1084     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1085     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1086     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1087     *            modify the data returned.
1088     * @return Returns a PackageInfo object containing information about the
1089     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1090     *         package is not found in the list of installed applications, the
1091     *         package information is retrieved from the list of uninstalled
1092     *         applications(which includes installed applications as well as
1093     *         applications with data directory ie applications which had been
1094     *         deleted with DONT_DELTE_DATA flag set).
1095     * @see #GET_ACTIVITIES
1096     * @see #GET_GIDS
1097     * @see #GET_CONFIGURATIONS
1098     * @see #GET_INSTRUMENTATION
1099     * @see #GET_PERMISSIONS
1100     * @see #GET_PROVIDERS
1101     * @see #GET_RECEIVERS
1102     * @see #GET_SERVICES
1103     * @see #GET_SIGNATURES
1104     * @see #GET_UNINSTALLED_PACKAGES
1105     */
1106    public abstract PackageInfo getPackageInfo(String packageName, int flags)
1107            throws NameNotFoundException;
1108
1109    /**
1110     * Map from the current package names in use on the device to whatever
1111     * the current canonical name of that package is.
1112     * @param names Array of current names to be mapped.
1113     * @return Returns an array of the same size as the original, containing
1114     * the canonical name for each package.
1115     */
1116    public abstract String[] currentToCanonicalPackageNames(String[] names);
1117
1118    /**
1119     * Map from a packages canonical name to the current name in use on the device.
1120     * @param names Array of new names to be mapped.
1121     * @return Returns an array of the same size as the original, containing
1122     * the current name for each package.
1123     */
1124    public abstract String[] canonicalToCurrentPackageNames(String[] names);
1125
1126    /**
1127     * Return a "good" intent to launch a front-door activity in a package,
1128     * for use for example to implement an "open" button when browsing through
1129     * packages.  The current implementation will look first for a main
1130     * activity in the category {@link Intent#CATEGORY_INFO}, next for a
1131     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
1132     * null if neither are found.
1133     *
1134     * <p>Throws {@link NameNotFoundException} if a package with the given
1135     * name can not be found on the system.
1136     *
1137     * @param packageName The name of the package to inspect.
1138     *
1139     * @return Returns either a fully-qualified Intent that can be used to
1140     * launch the main activity in the package, or null if the package does
1141     * not contain such an activity.
1142     */
1143    public abstract Intent getLaunchIntentForPackage(String packageName);
1144
1145    /**
1146     * Return an array of all of the secondary group-ids that have been
1147     * assigned to a package.
1148     *
1149     * <p>Throws {@link NameNotFoundException} if a package with the given
1150     * name can not be found on the system.
1151     *
1152     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1153     *                    desired package.
1154     *
1155     * @return Returns an int array of the assigned gids, or null if there
1156     * are none.
1157     */
1158    public abstract int[] getPackageGids(String packageName)
1159            throws NameNotFoundException;
1160
1161    /**
1162     * Retrieve all of the information we know about a particular permission.
1163     *
1164     * <p>Throws {@link NameNotFoundException} if a permission with the given
1165     * name can not be found on the system.
1166     *
1167     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1168     *             of the permission you are interested in.
1169     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1170     * retrieve any meta-data associated with the permission.
1171     *
1172     * @return Returns a {@link PermissionInfo} containing information about the
1173     *         permission.
1174     */
1175    public abstract PermissionInfo getPermissionInfo(String name, int flags)
1176            throws NameNotFoundException;
1177
1178    /**
1179     * Query for all of the permissions associated with a particular group.
1180     *
1181     * <p>Throws {@link NameNotFoundException} if the given group does not
1182     * exist.
1183     *
1184     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1185     *             of the permission group you are interested in.  Use null to
1186     *             find all of the permissions not associated with a group.
1187     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1188     * retrieve any meta-data associated with the permissions.
1189     *
1190     * @return Returns a list of {@link PermissionInfo} containing information
1191     * about all of the permissions in the given group.
1192     */
1193    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1194            int flags) throws NameNotFoundException;
1195
1196    /**
1197     * Retrieve all of the information we know about a particular group of
1198     * permissions.
1199     *
1200     * <p>Throws {@link NameNotFoundException} if a permission group with the given
1201     * name can not be found on the system.
1202     *
1203     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1204     *             of the permission you are interested in.
1205     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1206     * retrieve any meta-data associated with the permission group.
1207     *
1208     * @return Returns a {@link PermissionGroupInfo} containing information
1209     * about the permission.
1210     */
1211    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1212            int flags) throws NameNotFoundException;
1213
1214    /**
1215     * Retrieve all of the known permission groups in the system.
1216     *
1217     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1218     * retrieve any meta-data associated with the permission group.
1219     *
1220     * @return Returns a list of {@link PermissionGroupInfo} containing
1221     * information about all of the known permission groups.
1222     */
1223    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1224
1225    /**
1226     * Retrieve all of the information we know about a particular
1227     * package/application.
1228     *
1229     * <p>Throws {@link NameNotFoundException} if an application with the given
1230     * package name can not be found on the system.
1231     *
1232     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1233     *                    application.
1234     * @param flags Additional option flags. Use any combination of
1235     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1236     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1237     *
1238     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1239     *         information about the package.
1240     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1241     *         found in the list of installed applications,
1242     *         the application information is retrieved from the
1243     *         list of uninstalled applications(which includes
1244     *         installed applications as well as applications
1245     *         with data directory ie applications which had been
1246     *         deleted with DONT_DELTE_DATA flag set).
1247     *
1248     * @see #GET_META_DATA
1249     * @see #GET_SHARED_LIBRARY_FILES
1250     * @see #GET_UNINSTALLED_PACKAGES
1251     */
1252    public abstract ApplicationInfo getApplicationInfo(String packageName,
1253            int flags) throws NameNotFoundException;
1254
1255    /**
1256     * Retrieve all of the information we know about a particular activity
1257     * class.
1258     *
1259     * <p>Throws {@link NameNotFoundException} if an activity with the given
1260     * class name can not be found on the system.
1261     *
1262     * @param component The full component name (i.e.
1263     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1264     * class.
1265     * @param flags Additional option flags. Use any combination of
1266     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1267     * to modify the data (in ApplicationInfo) returned.
1268     *
1269     * @return {@link ActivityInfo} containing information about the activity.
1270     *
1271     * @see #GET_INTENT_FILTERS
1272     * @see #GET_META_DATA
1273     * @see #GET_SHARED_LIBRARY_FILES
1274     */
1275    public abstract ActivityInfo getActivityInfo(ComponentName component,
1276            int flags) throws NameNotFoundException;
1277
1278    /**
1279     * Retrieve all of the information we know about a particular receiver
1280     * class.
1281     *
1282     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1283     * class name can not be found on the system.
1284     *
1285     * @param component The full component name (i.e.
1286     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1287     * class.
1288     * @param flags Additional option flags.  Use any combination of
1289     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1290     * to modify the data returned.
1291     *
1292     * @return {@link ActivityInfo} containing information about the receiver.
1293     *
1294     * @see #GET_INTENT_FILTERS
1295     * @see #GET_META_DATA
1296     * @see #GET_SHARED_LIBRARY_FILES
1297     */
1298    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1299            int flags) throws NameNotFoundException;
1300
1301    /**
1302     * Retrieve all of the information we know about a particular service
1303     * class.
1304     *
1305     * <p>Throws {@link NameNotFoundException} if a service with the given
1306     * class name can not be found on the system.
1307     *
1308     * @param component The full component name (i.e.
1309     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1310     * class.
1311     * @param flags Additional option flags.  Use any combination of
1312     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1313     * to modify the data returned.
1314     *
1315     * @return ServiceInfo containing information about the service.
1316     *
1317     * @see #GET_META_DATA
1318     * @see #GET_SHARED_LIBRARY_FILES
1319     */
1320    public abstract ServiceInfo getServiceInfo(ComponentName component,
1321            int flags) throws NameNotFoundException;
1322
1323    /**
1324     * Retrieve all of the information we know about a particular content
1325     * provider class.
1326     *
1327     * <p>Throws {@link NameNotFoundException} if a provider with the given
1328     * class name can not be found on the system.
1329     *
1330     * @param component The full component name (i.e.
1331     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1332     * ContentProvider class.
1333     * @param flags Additional option flags.  Use any combination of
1334     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1335     * to modify the data returned.
1336     *
1337     * @return ProviderInfo containing information about the service.
1338     *
1339     * @see #GET_META_DATA
1340     * @see #GET_SHARED_LIBRARY_FILES
1341     */
1342    public abstract ProviderInfo getProviderInfo(ComponentName component,
1343            int flags) throws NameNotFoundException;
1344
1345    /**
1346     * Return a List of all packages that are installed
1347     * on the device.
1348     *
1349     * @param flags Additional option flags. Use any combination of
1350     * {@link #GET_ACTIVITIES},
1351     * {@link #GET_GIDS},
1352     * {@link #GET_CONFIGURATIONS},
1353     * {@link #GET_INSTRUMENTATION},
1354     * {@link #GET_PERMISSIONS},
1355     * {@link #GET_PROVIDERS},
1356     * {@link #GET_RECEIVERS},
1357     * {@link #GET_SERVICES},
1358     * {@link #GET_SIGNATURES},
1359     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1360     *
1361     * @return A List of PackageInfo objects, one for each package that is
1362     *         installed on the device.  In the unlikely case of there being no
1363     *         installed packages, an empty list is returned.
1364     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1365     *         applications including those deleted with DONT_DELETE_DATA
1366     *         (partially installed apps with data directory) will be returned.
1367     *
1368     * @see #GET_ACTIVITIES
1369     * @see #GET_GIDS
1370     * @see #GET_CONFIGURATIONS
1371     * @see #GET_INSTRUMENTATION
1372     * @see #GET_PERMISSIONS
1373     * @see #GET_PROVIDERS
1374     * @see #GET_RECEIVERS
1375     * @see #GET_SERVICES
1376     * @see #GET_SIGNATURES
1377     * @see #GET_UNINSTALLED_PACKAGES
1378     *
1379     */
1380    public abstract List<PackageInfo> getInstalledPackages(int flags);
1381
1382    /**
1383     * Check whether a particular package has been granted a particular
1384     * permission.
1385     *
1386     * @param permName The name of the permission you are checking for,
1387     * @param pkgName The name of the package you are checking against.
1388     *
1389     * @return If the package has the permission, PERMISSION_GRANTED is
1390     * returned.  If it does not have the permission, PERMISSION_DENIED
1391     * is returned.
1392     *
1393     * @see #PERMISSION_GRANTED
1394     * @see #PERMISSION_DENIED
1395     */
1396    public abstract int checkPermission(String permName, String pkgName);
1397
1398    /**
1399     * Add a new dynamic permission to the system.  For this to work, your
1400     * package must have defined a permission tree through the
1401     * {@link android.R.styleable#AndroidManifestPermissionTree
1402     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
1403     * permissions to trees that were defined by either its own package or
1404     * another with the same user id; a permission is in a tree if it
1405     * matches the name of the permission tree + ".": for example,
1406     * "com.foo.bar" is a member of the permission tree "com.foo".
1407     *
1408     * <p>It is good to make your permission tree name descriptive, because you
1409     * are taking possession of that entire set of permission names.  Thus, it
1410     * must be under a domain you control, with a suffix that will not match
1411     * any normal permissions that may be declared in any applications that
1412     * are part of that domain.
1413     *
1414     * <p>New permissions must be added before
1415     * any .apks are installed that use those permissions.  Permissions you
1416     * add through this method are remembered across reboots of the device.
1417     * If the given permission already exists, the info you supply here
1418     * will be used to update it.
1419     *
1420     * @param info Description of the permission to be added.
1421     *
1422     * @return Returns true if a new permission was created, false if an
1423     * existing one was updated.
1424     *
1425     * @throws SecurityException if you are not allowed to add the
1426     * given permission name.
1427     *
1428     * @see #removePermission(String)
1429     */
1430    public abstract boolean addPermission(PermissionInfo info);
1431
1432    /**
1433     * Like {@link #addPermission(PermissionInfo)} but asynchronously
1434     * persists the package manager state after returning from the call,
1435     * allowing it to return quicker and batch a series of adds at the
1436     * expense of no guarantee the added permission will be retained if
1437     * the device is rebooted before it is written.
1438     */
1439    public abstract boolean addPermissionAsync(PermissionInfo info);
1440
1441    /**
1442     * Removes a permission that was previously added with
1443     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
1444     * -- you are only allowed to remove permissions that you are allowed
1445     * to add.
1446     *
1447     * @param name The name of the permission to remove.
1448     *
1449     * @throws SecurityException if you are not allowed to remove the
1450     * given permission name.
1451     *
1452     * @see #addPermission(PermissionInfo)
1453     */
1454    public abstract void removePermission(String name);
1455
1456    /**
1457     * Compare the signatures of two packages to determine if the same
1458     * signature appears in both of them.  If they do contain the same
1459     * signature, then they are allowed special privileges when working
1460     * with each other: they can share the same user-id, run instrumentation
1461     * against each other, etc.
1462     *
1463     * @param pkg1 First package name whose signature will be compared.
1464     * @param pkg2 Second package name whose signature will be compared.
1465     *
1466     * @return Returns an integer indicating whether all signatures on the
1467     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1468     * all signatures match or < 0 if there is not a match ({@link
1469     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1470     *
1471     * @see #checkSignatures(int, int)
1472     * @see #SIGNATURE_MATCH
1473     * @see #SIGNATURE_NO_MATCH
1474     * @see #SIGNATURE_UNKNOWN_PACKAGE
1475     */
1476    public abstract int checkSignatures(String pkg1, String pkg2);
1477
1478    /**
1479     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
1480     * the two packages to be checked.  This can be useful, for example,
1481     * when doing the check in an IPC, where the UID is the only identity
1482     * available.  It is functionally identical to determining the package
1483     * associated with the UIDs and checking their signatures.
1484     *
1485     * @param uid1 First UID whose signature will be compared.
1486     * @param uid2 Second UID whose signature will be compared.
1487     *
1488     * @return Returns an integer indicating whether all signatures on the
1489     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1490     * all signatures match or < 0 if there is not a match ({@link
1491     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1492     *
1493     * @see #checkSignatures(String, String)
1494     * @see #SIGNATURE_MATCH
1495     * @see #SIGNATURE_NO_MATCH
1496     * @see #SIGNATURE_UNKNOWN_PACKAGE
1497     */
1498    public abstract int checkSignatures(int uid1, int uid2);
1499
1500    /**
1501     * Retrieve the names of all packages that are associated with a particular
1502     * user id.  In most cases, this will be a single package name, the package
1503     * that has been assigned that user id.  Where there are multiple packages
1504     * sharing the same user id through the "sharedUserId" mechanism, all
1505     * packages with that id will be returned.
1506     *
1507     * @param uid The user id for which you would like to retrieve the
1508     * associated packages.
1509     *
1510     * @return Returns an array of one or more packages assigned to the user
1511     * id, or null if there are no known packages with the given id.
1512     */
1513    public abstract String[] getPackagesForUid(int uid);
1514
1515    /**
1516     * Retrieve the official name associated with a user id.  This name is
1517     * guaranteed to never change, though it is possibly for the underlying
1518     * user id to be changed.  That is, if you are storing information about
1519     * user ids in persistent storage, you should use the string returned
1520     * by this function instead of the raw user-id.
1521     *
1522     * @param uid The user id for which you would like to retrieve a name.
1523     * @return Returns a unique name for the given user id, or null if the
1524     * user id is not currently assigned.
1525     */
1526    public abstract String getNameForUid(int uid);
1527
1528    /**
1529     * Return the user id associated with a shared user name. Multiple
1530     * applications can specify a shared user name in their manifest and thus
1531     * end up using a common uid. This might be used for new applications
1532     * that use an existing shared user name and need to know the uid of the
1533     * shared user.
1534     *
1535     * @param sharedUserName The shared user name whose uid is to be retrieved.
1536     * @return Returns the uid associated with the shared user, or  NameNotFoundException
1537     * if the shared user name is not being used by any installed packages
1538     * @hide
1539     */
1540    public abstract int getUidForSharedUser(String sharedUserName)
1541            throws NameNotFoundException;
1542
1543    /**
1544     * Return a List of all application packages that are installed on the
1545     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
1546     * applications including those deleted with DONT_DELETE_DATA(partially
1547     * installed apps with data directory) will be returned.
1548     *
1549     * @param flags Additional option flags. Use any combination of
1550     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1551     * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1552     *
1553     * @return A List of ApplicationInfo objects, one for each application that
1554     *         is installed on the device.  In the unlikely case of there being
1555     *         no installed applications, an empty list is returned.
1556     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1557     *         applications including those deleted with DONT_DELETE_DATA
1558     *         (partially installed apps with data directory) will be returned.
1559     *
1560     * @see #GET_META_DATA
1561     * @see #GET_SHARED_LIBRARY_FILES
1562     * @see #GET_UNINSTALLED_PACKAGES
1563     */
1564    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
1565
1566    /**
1567     * Get a list of shared libraries that are available on the
1568     * system.
1569     *
1570     * @return An array of shared library names that are
1571     * available on the system, or null if none are installed.
1572     *
1573     */
1574    public abstract String[] getSystemSharedLibraryNames();
1575
1576    /**
1577     * Get a list of features that are available on the
1578     * system.
1579     *
1580     * @return An array of FeatureInfo classes describing the features
1581     * that are available on the system, or null if there are none(!!).
1582     */
1583    public abstract FeatureInfo[] getSystemAvailableFeatures();
1584
1585    /**
1586     * Check whether the given feature name is one of the available
1587     * features as returned by {@link #getSystemAvailableFeatures()}.
1588     *
1589     * @return Returns true if the devices supports the feature, else
1590     * false.
1591     */
1592    public abstract boolean hasSystemFeature(String name);
1593
1594    /**
1595     * Determine the best action to perform for a given Intent.  This is how
1596     * {@link Intent#resolveActivity} finds an activity if a class has not
1597     * been explicitly specified.
1598     *
1599     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
1600     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
1601     * only flag.  You need to do so to resolve the activity in the same way
1602     * that {@link android.content.Context#startActivity(Intent)} and
1603     * {@link android.content.Intent#resolveActivity(PackageManager)
1604     * Intent.resolveActivity(PackageManager)} do.</p>
1605     *
1606     * @param intent An intent containing all of the desired specification
1607     *               (action, data, type, category, and/or component).
1608     * @param flags Additional option flags.  The most important is
1609     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1610     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1611     *
1612     * @return Returns a ResolveInfo containing the final activity intent that
1613     *         was determined to be the best action.  Returns null if no
1614     *         matching activity was found. If multiple matching activities are
1615     *         found and there is no default set, returns a ResolveInfo
1616     *         containing something else, such as the activity resolver.
1617     *
1618     * @see #MATCH_DEFAULT_ONLY
1619     * @see #GET_INTENT_FILTERS
1620     * @see #GET_RESOLVED_FILTER
1621     */
1622    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1623
1624    /**
1625     * Retrieve all activities that can be performed for the given intent.
1626     *
1627     * @param intent The desired intent as per resolveActivity().
1628     * @param flags Additional option flags.  The most important is
1629     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1630     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1631     *
1632     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1633     *         Activity. These are ordered from best to worst match -- that
1634     *         is, the first item in the list is what is returned by
1635     *         {@link #resolveActivity}.  If there are no matching activities, an empty
1636     *         list is returned.
1637     *
1638     * @see #MATCH_DEFAULT_ONLY
1639     * @see #GET_INTENT_FILTERS
1640     * @see #GET_RESOLVED_FILTER
1641     */
1642    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
1643            int flags);
1644
1645    /**
1646     * Retrieve a set of activities that should be presented to the user as
1647     * similar options.  This is like {@link #queryIntentActivities}, except it
1648     * also allows you to supply a list of more explicit Intents that you would
1649     * like to resolve to particular options, and takes care of returning the
1650     * final ResolveInfo list in a reasonable order, with no duplicates, based
1651     * on those inputs.
1652     *
1653     * @param caller The class name of the activity that is making the
1654     *               request.  This activity will never appear in the output
1655     *               list.  Can be null.
1656     * @param specifics An array of Intents that should be resolved to the
1657     *                  first specific results.  Can be null.
1658     * @param intent The desired intent as per resolveActivity().
1659     * @param flags Additional option flags.  The most important is
1660     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1661     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1662     *
1663     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1664     *         Activity. These are ordered first by all of the intents resolved
1665     *         in <var>specifics</var> and then any additional activities that
1666     *         can handle <var>intent</var> but did not get included by one of
1667     *         the <var>specifics</var> intents.  If there are no matching
1668     *         activities, an empty list is returned.
1669     *
1670     * @see #MATCH_DEFAULT_ONLY
1671     * @see #GET_INTENT_FILTERS
1672     * @see #GET_RESOLVED_FILTER
1673     */
1674    public abstract List<ResolveInfo> queryIntentActivityOptions(
1675            ComponentName caller, Intent[] specifics, Intent intent, int flags);
1676
1677    /**
1678     * Retrieve all receivers that can handle a broadcast of the given intent.
1679     *
1680     * @param intent The desired intent as per resolveActivity().
1681     * @param flags Additional option flags.
1682     *
1683     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1684     *         Receiver. These are ordered from first to last in priority.  If
1685     *         there are no matching receivers, an empty list is returned.
1686     *
1687     * @see #MATCH_DEFAULT_ONLY
1688     * @see #GET_INTENT_FILTERS
1689     * @see #GET_RESOLVED_FILTER
1690     */
1691    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
1692            int flags);
1693
1694    /**
1695     * Determine the best service to handle for a given Intent.
1696     *
1697     * @param intent An intent containing all of the desired specification
1698     *               (action, data, type, category, and/or component).
1699     * @param flags Additional option flags.
1700     *
1701     * @return Returns a ResolveInfo containing the final service intent that
1702     *         was determined to be the best action.  Returns null if no
1703     *         matching service was found.
1704     *
1705     * @see #GET_INTENT_FILTERS
1706     * @see #GET_RESOLVED_FILTER
1707     */
1708    public abstract ResolveInfo resolveService(Intent intent, int flags);
1709
1710    /**
1711     * Retrieve all services that can match the given intent.
1712     *
1713     * @param intent The desired intent as per resolveService().
1714     * @param flags Additional option flags.
1715     *
1716     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1717     *         ServiceInfo. These are ordered from best to worst match -- that
1718     *         is, the first item in the list is what is returned by
1719     *         resolveService().  If there are no matching services, an empty
1720     *         list is returned.
1721     *
1722     * @see #GET_INTENT_FILTERS
1723     * @see #GET_RESOLVED_FILTER
1724     */
1725    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
1726            int flags);
1727
1728    /**
1729     * Find a single content provider by its base path name.
1730     *
1731     * @param name The name of the provider to find.
1732     * @param flags Additional option flags.  Currently should always be 0.
1733     *
1734     * @return ContentProviderInfo Information about the provider, if found,
1735     *         else null.
1736     */
1737    public abstract ProviderInfo resolveContentProvider(String name,
1738            int flags);
1739
1740    /**
1741     * Retrieve content provider information.
1742     *
1743     * <p><em>Note: unlike most other methods, an empty result set is indicated
1744     * by a null return instead of an empty list.</em>
1745     *
1746     * @param processName If non-null, limits the returned providers to only
1747     *                    those that are hosted by the given process.  If null,
1748     *                    all content providers are returned.
1749     * @param uid If <var>processName</var> is non-null, this is the required
1750     *        uid owning the requested content providers.
1751     * @param flags Additional option flags.  Currently should always be 0.
1752     *
1753     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
1754     *         content provider either patching <var>processName</var> or, if
1755     *         <var>processName</var> is null, all known content providers.
1756     *         <em>If there are no matching providers, null is returned.</em>
1757     */
1758    public abstract List<ProviderInfo> queryContentProviders(
1759            String processName, int uid, int flags);
1760
1761    /**
1762     * Retrieve all of the information we know about a particular
1763     * instrumentation class.
1764     *
1765     * <p>Throws {@link NameNotFoundException} if instrumentation with the
1766     * given class name can not be found on the system.
1767     *
1768     * @param className The full name (i.e.
1769     *                  com.google.apps.contacts.InstrumentList) of an
1770     *                  Instrumentation class.
1771     * @param flags Additional option flags.  Currently should always be 0.
1772     *
1773     * @return InstrumentationInfo containing information about the
1774     *         instrumentation.
1775     */
1776    public abstract InstrumentationInfo getInstrumentationInfo(
1777            ComponentName className, int flags) throws NameNotFoundException;
1778
1779    /**
1780     * Retrieve information about available instrumentation code.  May be used
1781     * to retrieve either all instrumentation code, or only the code targeting
1782     * a particular package.
1783     *
1784     * @param targetPackage If null, all instrumentation is returned; only the
1785     *                      instrumentation targeting this package name is
1786     *                      returned.
1787     * @param flags Additional option flags.  Currently should always be 0.
1788     *
1789     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
1790     *         matching available Instrumentation.  Returns an empty list if
1791     *         there is no instrumentation available for the given package.
1792     */
1793    public abstract List<InstrumentationInfo> queryInstrumentation(
1794            String targetPackage, int flags);
1795
1796    /**
1797     * Retrieve an image from a package.  This is a low-level API used by
1798     * the various package manager info structures (such as
1799     * {@link ComponentInfo} to implement retrieval of their associated
1800     * icon.
1801     *
1802     * @param packageName The name of the package that this icon is coming from.
1803     * Can not be null.
1804     * @param resid The resource identifier of the desired image.  Can not be 0.
1805     * @param appInfo Overall information about <var>packageName</var>.  This
1806     * may be null, in which case the application information will be retrieved
1807     * for you if needed; if you already have this information around, it can
1808     * be much more efficient to supply it here.
1809     *
1810     * @return Returns a Drawable holding the requested image.  Returns null if
1811     * an image could not be found for any reason.
1812     */
1813    public abstract Drawable getDrawable(String packageName, int resid,
1814            ApplicationInfo appInfo);
1815
1816    /**
1817     * Retrieve the icon associated with an activity.  Given the full name of
1818     * an activity, retrieves the information about it and calls
1819     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
1820     * If the activity can not be found, NameNotFoundException is thrown.
1821     *
1822     * @param activityName Name of the activity whose icon is to be retrieved.
1823     *
1824     * @return Returns the image of the icon, or the default activity icon if
1825     * it could not be found.  Does not return null.
1826     * @throws NameNotFoundException Thrown if the resources for the given
1827     * activity could not be loaded.
1828     *
1829     * @see #getActivityIcon(Intent)
1830     */
1831    public abstract Drawable getActivityIcon(ComponentName activityName)
1832            throws NameNotFoundException;
1833
1834    /**
1835     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
1836     * set, this simply returns the result of
1837     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
1838     * component and returns the icon associated with the resolved component.
1839     * If intent.getClassName() can not be found or the Intent can not be resolved
1840     * to a component, NameNotFoundException is thrown.
1841     *
1842     * @param intent The intent for which you would like to retrieve an icon.
1843     *
1844     * @return Returns the image of the icon, or the default activity icon if
1845     * it could not be found.  Does not return null.
1846     * @throws NameNotFoundException Thrown if the resources for application
1847     * matching the given intent could not be loaded.
1848     *
1849     * @see #getActivityIcon(ComponentName)
1850     */
1851    public abstract Drawable getActivityIcon(Intent intent)
1852            throws NameNotFoundException;
1853
1854    /**
1855     * Return the generic icon for an activity that is used when no specific
1856     * icon is defined.
1857     *
1858     * @return Drawable Image of the icon.
1859     */
1860    public abstract Drawable getDefaultActivityIcon();
1861
1862    /**
1863     * Retrieve the icon associated with an application.  If it has not defined
1864     * an icon, the default app icon is returned.  Does not return null.
1865     *
1866     * @param info Information about application being queried.
1867     *
1868     * @return Returns the image of the icon, or the default application icon
1869     * if it could not be found.
1870     *
1871     * @see #getApplicationIcon(String)
1872     */
1873    public abstract Drawable getApplicationIcon(ApplicationInfo info);
1874
1875    /**
1876     * Retrieve the icon associated with an application.  Given the name of the
1877     * application's package, retrieves the information about it and calls
1878     * getApplicationIcon() to return its icon. If the application can not be
1879     * found, NameNotFoundException is thrown.
1880     *
1881     * @param packageName Name of the package whose application icon is to be
1882     *                    retrieved.
1883     *
1884     * @return Returns the image of the icon, or the default application icon
1885     * if it could not be found.  Does not return null.
1886     * @throws NameNotFoundException Thrown if the resources for the given
1887     * application could not be loaded.
1888     *
1889     * @see #getApplicationIcon(ApplicationInfo)
1890     */
1891    public abstract Drawable getApplicationIcon(String packageName)
1892            throws NameNotFoundException;
1893
1894    /**
1895     * Retrieve the logo associated with an activity.  Given the full name of
1896     * an activity, retrieves the information about it and calls
1897     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
1898     * If the activity can not be found, NameNotFoundException is thrown.
1899     *
1900     * @param activityName Name of the activity whose logo is to be retrieved.
1901     *
1902     * @return Returns the image of the logo or null if the activity has no
1903     * logo specified.
1904     *
1905     * @throws NameNotFoundException Thrown if the resources for the given
1906     * activity could not be loaded.
1907     *
1908     * @see #getActivityLogo(Intent)
1909     */
1910    public abstract Drawable getActivityLogo(ComponentName activityName)
1911            throws NameNotFoundException;
1912
1913    /**
1914     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
1915     * set, this simply returns the result of
1916     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
1917     * component and returns the logo associated with the resolved component.
1918     * If intent.getClassName() can not be found or the Intent can not be resolved
1919     * to a component, NameNotFoundException is thrown.
1920     *
1921     * @param intent The intent for which you would like to retrieve a logo.
1922     *
1923     * @return Returns the image of the logo, or null if the activity has no
1924     * logo specified.
1925     *
1926     * @throws NameNotFoundException Thrown if the resources for application
1927     * matching the given intent could not be loaded.
1928     *
1929     * @see #getActivityLogo(ComponentName)
1930     */
1931    public abstract Drawable getActivityLogo(Intent intent)
1932            throws NameNotFoundException;
1933
1934    /**
1935     * Retrieve the logo associated with an application.  If it has not specified
1936     * a logo, this method returns null.
1937     *
1938     * @param info Information about application being queried.
1939     *
1940     * @return Returns the image of the logo, or null if no logo is specified
1941     * by the application.
1942     *
1943     * @see #getApplicationLogo(String)
1944     */
1945    public abstract Drawable getApplicationLogo(ApplicationInfo info);
1946
1947    /**
1948     * Retrieve the logo associated with an application.  Given the name of the
1949     * application's package, retrieves the information about it and calls
1950     * getApplicationLogo() to return its logo. If the application can not be
1951     * found, NameNotFoundException is thrown.
1952     *
1953     * @param packageName Name of the package whose application logo is to be
1954     *                    retrieved.
1955     *
1956     * @return Returns the image of the logo, or null if no application logo
1957     * has been specified.
1958     *
1959     * @throws NameNotFoundException Thrown if the resources for the given
1960     * application could not be loaded.
1961     *
1962     * @see #getApplicationLogo(ApplicationInfo)
1963     */
1964    public abstract Drawable getApplicationLogo(String packageName)
1965            throws NameNotFoundException;
1966
1967    /**
1968     * Retrieve text from a package.  This is a low-level API used by
1969     * the various package manager info structures (such as
1970     * {@link ComponentInfo} to implement retrieval of their associated
1971     * labels and other text.
1972     *
1973     * @param packageName The name of the package that this text is coming from.
1974     * Can not be null.
1975     * @param resid The resource identifier of the desired text.  Can not be 0.
1976     * @param appInfo Overall information about <var>packageName</var>.  This
1977     * may be null, in which case the application information will be retrieved
1978     * for you if needed; if you already have this information around, it can
1979     * be much more efficient to supply it here.
1980     *
1981     * @return Returns a CharSequence holding the requested text.  Returns null
1982     * if the text could not be found for any reason.
1983     */
1984    public abstract CharSequence getText(String packageName, int resid,
1985            ApplicationInfo appInfo);
1986
1987    /**
1988     * Retrieve an XML file from a package.  This is a low-level API used to
1989     * retrieve XML meta data.
1990     *
1991     * @param packageName The name of the package that this xml is coming from.
1992     * Can not be null.
1993     * @param resid The resource identifier of the desired xml.  Can not be 0.
1994     * @param appInfo Overall information about <var>packageName</var>.  This
1995     * may be null, in which case the application information will be retrieved
1996     * for you if needed; if you already have this information around, it can
1997     * be much more efficient to supply it here.
1998     *
1999     * @return Returns an XmlPullParser allowing you to parse out the XML
2000     * data.  Returns null if the xml resource could not be found for any
2001     * reason.
2002     */
2003    public abstract XmlResourceParser getXml(String packageName, int resid,
2004            ApplicationInfo appInfo);
2005
2006    /**
2007     * Return the label to use for this application.
2008     *
2009     * @return Returns the label associated with this application, or null if
2010     * it could not be found for any reason.
2011     * @param info The application to get the label of
2012     */
2013    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
2014
2015    /**
2016     * Retrieve the resources associated with an activity.  Given the full
2017     * name of an activity, retrieves the information about it and calls
2018     * getResources() to return its application's resources.  If the activity
2019     * can not be found, NameNotFoundException is thrown.
2020     *
2021     * @param activityName Name of the activity whose resources are to be
2022     *                     retrieved.
2023     *
2024     * @return Returns the application's Resources.
2025     * @throws NameNotFoundException Thrown if the resources for the given
2026     * application could not be loaded.
2027     *
2028     * @see #getResourcesForApplication(ApplicationInfo)
2029     */
2030    public abstract Resources getResourcesForActivity(ComponentName activityName)
2031            throws NameNotFoundException;
2032
2033    /**
2034     * Retrieve the resources for an application.  Throws NameNotFoundException
2035     * if the package is no longer installed.
2036     *
2037     * @param app Information about the desired application.
2038     *
2039     * @return Returns the application's Resources.
2040     * @throws NameNotFoundException Thrown if the resources for the given
2041     * application could not be loaded (most likely because it was uninstalled).
2042     */
2043    public abstract Resources getResourcesForApplication(ApplicationInfo app)
2044            throws NameNotFoundException;
2045
2046    /**
2047     * Retrieve the resources associated with an application.  Given the full
2048     * package name of an application, retrieves the information about it and
2049     * calls getResources() to return its application's resources.  If the
2050     * appPackageName can not be found, NameNotFoundException is thrown.
2051     *
2052     * @param appPackageName Package name of the application whose resources
2053     *                       are to be retrieved.
2054     *
2055     * @return Returns the application's Resources.
2056     * @throws NameNotFoundException Thrown if the resources for the given
2057     * application could not be loaded.
2058     *
2059     * @see #getResourcesForApplication(ApplicationInfo)
2060     */
2061    public abstract Resources getResourcesForApplication(String appPackageName)
2062            throws NameNotFoundException;
2063
2064    /**
2065     * Retrieve overall information about an application package defined
2066     * in a package archive file
2067     *
2068     * @param archiveFilePath The path to the archive file
2069     * @param flags Additional option flags. Use any combination of
2070     * {@link #GET_ACTIVITIES},
2071     * {@link #GET_GIDS},
2072     * {@link #GET_CONFIGURATIONS},
2073     * {@link #GET_INSTRUMENTATION},
2074     * {@link #GET_PERMISSIONS},
2075     * {@link #GET_PROVIDERS},
2076     * {@link #GET_RECEIVERS},
2077     * {@link #GET_SERVICES},
2078     * {@link #GET_SIGNATURES}, to modify the data returned.
2079     *
2080     * @return Returns the information about the package. Returns
2081     * null if the package could not be successfully parsed.
2082     *
2083     * @see #GET_ACTIVITIES
2084     * @see #GET_GIDS
2085     * @see #GET_CONFIGURATIONS
2086     * @see #GET_INSTRUMENTATION
2087     * @see #GET_PERMISSIONS
2088     * @see #GET_PROVIDERS
2089     * @see #GET_RECEIVERS
2090     * @see #GET_SERVICES
2091     * @see #GET_SIGNATURES
2092     *
2093     */
2094    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
2095        PackageParser packageParser = new PackageParser(archiveFilePath);
2096        DisplayMetrics metrics = new DisplayMetrics();
2097        metrics.setToDefaults();
2098        final File sourceFile = new File(archiveFilePath);
2099        PackageParser.Package pkg = packageParser.parsePackage(
2100                sourceFile, archiveFilePath, metrics, 0);
2101        if (pkg == null) {
2102            return null;
2103        }
2104        return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0);
2105    }
2106
2107    /**
2108     * @hide
2109     *
2110     * Install a package. Since this may take a little while, the result will
2111     * be posted back to the given observer.  An installation will fail if the calling context
2112     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
2113     * package named in the package file's manifest is already installed, or if there's no space
2114     * available on the device.
2115     *
2116     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
2117     * 'content:' URI.
2118     * @param observer An observer callback to get notified when the package installation is
2119     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
2120     * called when that happens.  observer may be null to indicate that no callback is desired.
2121     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2122     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2123     * @param installerPackageName Optional package name of the application that is performing the
2124     * installation. This identifies which market the package came from.
2125     */
2126    public abstract void installPackage(
2127            Uri packageURI, IPackageInstallObserver observer, int flags,
2128            String installerPackageName);
2129
2130    /**
2131     * Similar to
2132     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
2133     * with an extra verification file provided.
2134     *
2135     * @param packageURI The location of the package file to install. This can
2136     *            be a 'file:' or a 'content:' URI.
2137     * @param observer An observer callback to get notified when the package
2138     *            installation is complete.
2139     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
2140     *            will be called when that happens. observer may be null to
2141     *            indicate that no callback is desired.
2142     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2143     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}
2144     *            .
2145     * @param installerPackageName Optional package name of the application that
2146     *            is performing the installation. This identifies which market
2147     *            the package came from.
2148     * @param verificationURI The location of the supplementary verification
2149     *            file. This can be a 'file:' or a 'content:' URI.
2150     * @hide
2151     */
2152    public abstract void installPackageWithVerification(Uri packageURI,
2153            IPackageInstallObserver observer, int flags, String installerPackageName,
2154            Uri verificationURI, ManifestDigest manifestDigest);
2155
2156    /**
2157     * Allows a package listening to the
2158     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
2159     * broadcast} to respond to the package manager.
2160     *
2161     * @param id pending package identifier as passed via the
2162     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra
2163     * @param verified whether the package was verified as valid
2164     * @param failureMessage if verification was false, this is the error
2165     *            message that may be shown to the user
2166     * @hide
2167     */
2168    public abstract void verifyPendingInstall(int id, boolean verified, String failureMessage);
2169
2170    /**
2171     * Change the installer associated with a given package.  There are limitations
2172     * on how the installer package can be changed; in particular:
2173     * <ul>
2174     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
2175     * is not signed with the same certificate as the calling application.
2176     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
2177     * has an installer package, and that installer package is not signed with
2178     * the same certificate as the calling application.
2179     * </ul>
2180     *
2181     * @param targetPackage The installed package whose installer will be changed.
2182     * @param installerPackageName The package name of the new installer.  May be
2183     * null to clear the association.
2184     */
2185    public abstract void setInstallerPackageName(String targetPackage,
2186            String installerPackageName);
2187
2188    /**
2189     * Attempts to delete a package.  Since this may take a little while, the result will
2190     * be posted back to the given observer.  A deletion will fail if the calling context
2191     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
2192     * named package cannot be found, or if the named package is a "system package".
2193     * (TODO: include pointer to documentation on "system packages")
2194     *
2195     * @param packageName The name of the package to delete
2196     * @param observer An observer callback to get notified when the package deletion is
2197     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
2198     * called when that happens.  observer may be null to indicate that no callback is desired.
2199     * @param flags - possible values: {@link #DONT_DELETE_DATA}
2200     *
2201     * @hide
2202     */
2203    public abstract void deletePackage(
2204            String packageName, IPackageDeleteObserver observer, int flags);
2205
2206    /**
2207     * Retrieve the package name of the application that installed a package. This identifies
2208     * which market the package came from.
2209     *
2210     * @param packageName The name of the package to query
2211     */
2212    public abstract String getInstallerPackageName(String packageName);
2213
2214    /**
2215     * Attempts to clear the user data directory of an application.
2216     * Since this may take a little while, the result will
2217     * be posted back to the given observer.  A deletion will fail if the
2218     * named package cannot be found, or if the named package is a "system package".
2219     *
2220     * @param packageName The name of the package
2221     * @param observer An observer callback to get notified when the operation is finished
2222     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2223     * will be called when that happens.  observer may be null to indicate that
2224     * no callback is desired.
2225     *
2226     * @hide
2227     */
2228    public abstract void clearApplicationUserData(String packageName,
2229            IPackageDataObserver observer);
2230    /**
2231     * Attempts to delete the cache files associated with an application.
2232     * Since this may take a little while, the result will
2233     * be posted back to the given observer.  A deletion will fail if the calling context
2234     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
2235     * named package cannot be found, or if the named package is a "system package".
2236     *
2237     * @param packageName The name of the package to delete
2238     * @param observer An observer callback to get notified when the cache file deletion
2239     * is complete.
2240     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2241     * will be called when that happens.  observer may be null to indicate that
2242     * no callback is desired.
2243     *
2244     * @hide
2245     */
2246    public abstract void deleteApplicationCacheFiles(String packageName,
2247            IPackageDataObserver observer);
2248
2249    /**
2250     * Free storage by deleting LRU sorted list of cache files across
2251     * all applications. If the currently available free storage
2252     * on the device is greater than or equal to the requested
2253     * free storage, no cache files are cleared. If the currently
2254     * available storage on the device is less than the requested
2255     * free storage, some or all of the cache files across
2256     * all applications are deleted (based on last accessed time)
2257     * to increase the free storage space on the device to
2258     * the requested value. There is no guarantee that clearing all
2259     * the cache files from all applications will clear up
2260     * enough storage to achieve the desired value.
2261     * @param freeStorageSize The number of bytes of storage to be
2262     * freed by the system. Say if freeStorageSize is XX,
2263     * and the current free storage is YY,
2264     * if XX is less than YY, just return. if not free XX-YY number
2265     * of bytes if possible.
2266     * @param observer call back used to notify when
2267     * the operation is completed
2268     *
2269     * @hide
2270     */
2271    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
2272
2273    /**
2274     * Free storage by deleting LRU sorted list of cache files across
2275     * all applications. If the currently available free storage
2276     * on the device is greater than or equal to the requested
2277     * free storage, no cache files are cleared. If the currently
2278     * available storage on the device is less than the requested
2279     * free storage, some or all of the cache files across
2280     * all applications are deleted (based on last accessed time)
2281     * to increase the free storage space on the device to
2282     * the requested value. There is no guarantee that clearing all
2283     * the cache files from all applications will clear up
2284     * enough storage to achieve the desired value.
2285     * @param freeStorageSize The number of bytes of storage to be
2286     * freed by the system. Say if freeStorageSize is XX,
2287     * and the current free storage is YY,
2288     * if XX is less than YY, just return. if not free XX-YY number
2289     * of bytes if possible.
2290     * @param pi IntentSender call back used to
2291     * notify when the operation is completed.May be null
2292     * to indicate that no call back is desired.
2293     *
2294     * @hide
2295     */
2296    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
2297
2298    /**
2299     * Retrieve the size information for a package.
2300     * Since this may take a little while, the result will
2301     * be posted back to the given observer.  The calling context
2302     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
2303     *
2304     * @param packageName The name of the package whose size information is to be retrieved
2305     * @param observer An observer callback to get notified when the operation
2306     * is complete.
2307     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
2308     * The observer's callback is invoked with a PackageStats object(containing the
2309     * code, data and cache sizes of the package) and a boolean value representing
2310     * the status of the operation. observer may be null to indicate that
2311     * no callback is desired.
2312     *
2313     * @hide
2314     */
2315    public abstract void getPackageSizeInfo(String packageName,
2316            IPackageStatsObserver observer);
2317
2318    /**
2319     * @deprecated This function no longer does anything; it was an old
2320     * approach to managing preferred activities, which has been superceeded
2321     * (and conflicts with) the modern activity-based preferences.
2322     */
2323    @Deprecated
2324    public abstract void addPackageToPreferred(String packageName);
2325
2326    /**
2327     * @deprecated This function no longer does anything; it was an old
2328     * approach to managing preferred activities, which has been superceeded
2329     * (and conflicts with) the modern activity-based preferences.
2330     */
2331    @Deprecated
2332    public abstract void removePackageFromPreferred(String packageName);
2333
2334    /**
2335     * Retrieve the list of all currently configured preferred packages.  The
2336     * first package on the list is the most preferred, the last is the
2337     * least preferred.
2338     *
2339     * @param flags Additional option flags. Use any combination of
2340     * {@link #GET_ACTIVITIES},
2341     * {@link #GET_GIDS},
2342     * {@link #GET_CONFIGURATIONS},
2343     * {@link #GET_INSTRUMENTATION},
2344     * {@link #GET_PERMISSIONS},
2345     * {@link #GET_PROVIDERS},
2346     * {@link #GET_RECEIVERS},
2347     * {@link #GET_SERVICES},
2348     * {@link #GET_SIGNATURES}, to modify the data returned.
2349     *
2350     * @return Returns a list of PackageInfo objects describing each
2351     * preferred application, in order of preference.
2352     *
2353     * @see #GET_ACTIVITIES
2354     * @see #GET_GIDS
2355     * @see #GET_CONFIGURATIONS
2356     * @see #GET_INSTRUMENTATION
2357     * @see #GET_PERMISSIONS
2358     * @see #GET_PROVIDERS
2359     * @see #GET_RECEIVERS
2360     * @see #GET_SERVICES
2361     * @see #GET_SIGNATURES
2362     */
2363    public abstract List<PackageInfo> getPreferredPackages(int flags);
2364
2365    /**
2366     * @deprecated This is a protected API that should not have been available
2367     * to third party applications.  It is the platform's responsibility for
2368     * assigning preferred activities and this can not be directly modified.
2369     *
2370     * Add a new preferred activity mapping to the system.  This will be used
2371     * to automatically select the given activity component when
2372     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2373     * multiple matching activities and also matches the given filter.
2374     *
2375     * @param filter The set of intents under which this activity will be
2376     * made preferred.
2377     * @param match The IntentFilter match category that this preference
2378     * applies to.
2379     * @param set The set of activities that the user was picking from when
2380     * this preference was made.
2381     * @param activity The component name of the activity that is to be
2382     * preferred.
2383     */
2384    @Deprecated
2385    public abstract void addPreferredActivity(IntentFilter filter, int match,
2386            ComponentName[] set, ComponentName activity);
2387
2388    /**
2389     * @deprecated This is a protected API that should not have been available
2390     * to third party applications.  It is the platform's responsibility for
2391     * assigning preferred activities and this can not be directly modified.
2392     *
2393     * Replaces an existing preferred activity mapping to the system, and if that were not present
2394     * adds a new preferred activity.  This will be used
2395     * to automatically select the given activity component when
2396     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2397     * multiple matching activities and also matches the given filter.
2398     *
2399     * @param filter The set of intents under which this activity will be
2400     * made preferred.
2401     * @param match The IntentFilter match category that this preference
2402     * applies to.
2403     * @param set The set of activities that the user was picking from when
2404     * this preference was made.
2405     * @param activity The component name of the activity that is to be
2406     * preferred.
2407     * @hide
2408     */
2409    @Deprecated
2410    public abstract void replacePreferredActivity(IntentFilter filter, int match,
2411            ComponentName[] set, ComponentName activity);
2412
2413    /**
2414     * Remove all preferred activity mappings, previously added with
2415     * {@link #addPreferredActivity}, from the
2416     * system whose activities are implemented in the given package name.
2417     * An application can only clear its own package(s).
2418     *
2419     * @param packageName The name of the package whose preferred activity
2420     * mappings are to be removed.
2421     */
2422    public abstract void clearPackagePreferredActivities(String packageName);
2423
2424    /**
2425     * Retrieve all preferred activities, previously added with
2426     * {@link #addPreferredActivity}, that are
2427     * currently registered with the system.
2428     *
2429     * @param outFilters A list in which to place the filters of all of the
2430     * preferred activities, or null for none.
2431     * @param outActivities A list in which to place the component names of
2432     * all of the preferred activities, or null for none.
2433     * @param packageName An option package in which you would like to limit
2434     * the list.  If null, all activities will be returned; if non-null, only
2435     * those activities in the given package are returned.
2436     *
2437     * @return Returns the total number of registered preferred activities
2438     * (the number of distinct IntentFilter records, not the number of unique
2439     * activity components) that were found.
2440     */
2441    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
2442            List<ComponentName> outActivities, String packageName);
2443
2444    /**
2445     * Set the enabled setting for a package component (activity, receiver, service, provider).
2446     * This setting will override any enabled state which may have been set by the component in its
2447     * manifest.
2448     *
2449     * @param componentName The component to enable
2450     * @param newState The new enabled state for the component.  The legal values for this state
2451     *                 are:
2452     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2453     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2454     *                   and
2455     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2456     *                 The last one removes the setting, thereby restoring the component's state to
2457     *                 whatever was set in it's manifest (or enabled, by default).
2458     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2459     */
2460    public abstract void setComponentEnabledSetting(ComponentName componentName,
2461            int newState, int flags);
2462
2463
2464    /**
2465     * Return the the enabled setting for a package component (activity,
2466     * receiver, service, provider).  This returns the last value set by
2467     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
2468     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2469     * the value originally specified in the manifest has not been modified.
2470     *
2471     * @param componentName The component to retrieve.
2472     * @return Returns the current enabled state for the component.  May
2473     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2474     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2475     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2476     * component's enabled state is based on the original information in
2477     * the manifest as found in {@link ComponentInfo}.
2478     */
2479    public abstract int getComponentEnabledSetting(ComponentName componentName);
2480
2481    /**
2482     * Set the enabled setting for an application
2483     * This setting will override any enabled state which may have been set by the application in
2484     * its manifest.  It also overrides the enabled state set in the manifest for any of the
2485     * application's components.  It does not override any enabled state set by
2486     * {@link #setComponentEnabledSetting} for any of the application's components.
2487     *
2488     * @param packageName The package name of the application to enable
2489     * @param newState The new enabled state for the component.  The legal values for this state
2490     *                 are:
2491     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2492     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2493     *                   and
2494     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2495     *                 The last one removes the setting, thereby restoring the applications's state to
2496     *                 whatever was set in its manifest (or enabled, by default).
2497     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2498     */
2499    public abstract void setApplicationEnabledSetting(String packageName,
2500            int newState, int flags);
2501
2502    /**
2503     * Return the the enabled setting for an application.  This returns
2504     * the last value set by
2505     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
2506     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2507     * the value originally specified in the manifest has not been modified.
2508     *
2509     * @param packageName The component to retrieve.
2510     * @return Returns the current enabled state for the component.  May
2511     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2512     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2513     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2514     * application's enabled state is based on the original information in
2515     * the manifest as found in {@link ComponentInfo}.
2516     */
2517    public abstract int getApplicationEnabledSetting(String packageName);
2518
2519    /**
2520     * Return whether the device has been booted into safe mode.
2521     */
2522    public abstract boolean isSafeMode();
2523
2524    /**
2525     * Attempts to move package resources from internal to external media or vice versa.
2526     * Since this may take a little while, the result will
2527     * be posted back to the given observer.   This call may fail if the calling context
2528     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
2529     * named package cannot be found, or if the named package is a "system package".
2530     *
2531     * @param packageName The name of the package to delete
2532     * @param observer An observer callback to get notified when the package move is
2533     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
2534     * called when that happens.  observer may be null to indicate that no callback is desired.
2535     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
2536     * {@link #MOVE_EXTERNAL_MEDIA}
2537     *
2538     * @hide
2539     */
2540    public abstract void movePackage(
2541            String packageName, IPackageMoveObserver observer, int flags);
2542
2543    /**
2544     * Creates a user with the specified name and options.
2545     *
2546     * @param name the user's name
2547     * @param flags flags that identify the type of user and other properties.
2548     * @see UserInfo
2549     *
2550     * @return the UserInfo object for the created user, or null if the user could not be created.
2551     * @hide
2552     */
2553    public abstract UserInfo createUser(String name, int flags);
2554
2555    /**
2556     * @return the list of users that were created
2557     * @hide
2558     */
2559    public abstract List<UserInfo> getUsers();
2560
2561    /**
2562     * @param id the ID of the user, where 0 is the primary user.
2563     * @hide
2564     */
2565    public abstract boolean removeUser(int id);
2566
2567    /**
2568     * Updates the user's name.
2569     *
2570     * @param id the user's id
2571     * @param name the new name for the user
2572     * @hide
2573     */
2574    public abstract void updateUserName(int id, String name);
2575
2576    /**
2577     * Changes the user's properties specified by the flags.
2578     *
2579     * @param id the user's id
2580     * @param flags the new flags for the user
2581     * @hide
2582     */
2583    public abstract void updateUserFlags(int id, int flags);
2584
2585    /**
2586     * Checks to see if the user id is the same for the two uids, i.e., they belong to the same
2587     * user.
2588     * @hide
2589     */
2590    public static boolean isSameUser(int uid1, int uid2) {
2591        return getUserId(uid1) == getUserId(uid2);
2592    }
2593
2594    /**
2595     * Returns the user id for a given uid.
2596     * @hide
2597     */
2598    public static int getUserId(int uid) {
2599        return uid / PER_USER_RANGE;
2600    }
2601
2602    /**
2603     * Returns the uid that is composed from the userId and the appId.
2604     * @hide
2605     */
2606    public static int getUid(int userId, int appId) {
2607        return userId * PER_USER_RANGE + (appId % PER_USER_RANGE);
2608    }
2609
2610    /**
2611     * Returns the app id (or base uid) for a given uid, stripping out the user id from it.
2612     * @hide
2613     */
2614    public static int getAppId(int uid) {
2615        return uid % PER_USER_RANGE;
2616    }
2617}
2618