PackageManager.java revision 3a9b5fbb97e65019abec97f172b4cbf2100d1225
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     * Used as the {@code verificationCode} argument for
729     * {@link PackageManager#verifyPendingInstall} to indicate that the calling
730     * package verifier allows the installation to proceed.
731     */
732    public static final int VERIFICATION_ALLOW = 1;
733
734    /**
735     * Used as the {@code verificationCode} argument for
736     * {@link PackageManager#verifyPendingInstall} to indicate the calling
737     * package verifier does not vote to allow the installation to proceed.
738     */
739    public static final int VERIFICATION_REJECT = -1;
740
741    /**
742     * Range of IDs allocated for a user.
743     *
744     * @hide
745     */
746    public static final int PER_USER_RANGE = 100000;
747
748    /**
749     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
750     * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
751     * lag in sound input or output.
752     */
753    @SdkConstant(SdkConstantType.FEATURE)
754    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
755
756    /**
757     * Feature for {@link #getSystemAvailableFeatures} and
758     * {@link #hasSystemFeature}: The device is capable of communicating with
759     * other devices via Bluetooth.
760     */
761    @SdkConstant(SdkConstantType.FEATURE)
762    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
763
764    /**
765     * Feature for {@link #getSystemAvailableFeatures} and
766     * {@link #hasSystemFeature}: The device has a camera facing away
767     * from the screen.
768     */
769    @SdkConstant(SdkConstantType.FEATURE)
770    public static final String FEATURE_CAMERA = "android.hardware.camera";
771
772    /**
773     * Feature for {@link #getSystemAvailableFeatures} and
774     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
775     */
776    @SdkConstant(SdkConstantType.FEATURE)
777    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
778
779    /**
780     * Feature for {@link #getSystemAvailableFeatures} and
781     * {@link #hasSystemFeature}: The device's camera supports flash.
782     */
783    @SdkConstant(SdkConstantType.FEATURE)
784    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
785
786    /**
787     * Feature for {@link #getSystemAvailableFeatures} and
788     * {@link #hasSystemFeature}: The device has a front facing camera.
789     */
790    @SdkConstant(SdkConstantType.FEATURE)
791    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
792
793    /**
794     * Feature for {@link #getSystemAvailableFeatures} and
795     * {@link #hasSystemFeature}: The device supports one or more methods of
796     * reporting current location.
797     */
798    @SdkConstant(SdkConstantType.FEATURE)
799    public static final String FEATURE_LOCATION = "android.hardware.location";
800
801    /**
802     * Feature for {@link #getSystemAvailableFeatures} and
803     * {@link #hasSystemFeature}: The device has a Global Positioning System
804     * receiver and can report precise location.
805     */
806    @SdkConstant(SdkConstantType.FEATURE)
807    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
808
809    /**
810     * Feature for {@link #getSystemAvailableFeatures} and
811     * {@link #hasSystemFeature}: The device can report location with coarse
812     * accuracy using a network-based geolocation system.
813     */
814    @SdkConstant(SdkConstantType.FEATURE)
815    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
816
817    /**
818     * Feature for {@link #getSystemAvailableFeatures} and
819     * {@link #hasSystemFeature}: The device can record audio via a
820     * microphone.
821     */
822    @SdkConstant(SdkConstantType.FEATURE)
823    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
824
825    /**
826     * Feature for {@link #getSystemAvailableFeatures} and
827     * {@link #hasSystemFeature}: The device can communicate using Near-Field
828     * Communications (NFC).
829     */
830    @SdkConstant(SdkConstantType.FEATURE)
831    public static final String FEATURE_NFC = "android.hardware.nfc";
832
833    /**
834     * Feature for {@link #getSystemAvailableFeatures} and
835     * {@link #hasSystemFeature}: The device includes an accelerometer.
836     */
837    @SdkConstant(SdkConstantType.FEATURE)
838    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
839
840    /**
841     * Feature for {@link #getSystemAvailableFeatures} and
842     * {@link #hasSystemFeature}: The device includes a barometer (air
843     * pressure sensor.)
844     */
845    @SdkConstant(SdkConstantType.FEATURE)
846    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
847
848    /**
849     * Feature for {@link #getSystemAvailableFeatures} and
850     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
851     */
852    @SdkConstant(SdkConstantType.FEATURE)
853    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
854
855    /**
856     * Feature for {@link #getSystemAvailableFeatures} and
857     * {@link #hasSystemFeature}: The device includes a gyroscope.
858     */
859    @SdkConstant(SdkConstantType.FEATURE)
860    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
861
862    /**
863     * Feature for {@link #getSystemAvailableFeatures} and
864     * {@link #hasSystemFeature}: The device includes a light sensor.
865     */
866    @SdkConstant(SdkConstantType.FEATURE)
867    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
868
869    /**
870     * Feature for {@link #getSystemAvailableFeatures} and
871     * {@link #hasSystemFeature}: The device includes a proximity sensor.
872     */
873    @SdkConstant(SdkConstantType.FEATURE)
874    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
875
876    /**
877     * Feature for {@link #getSystemAvailableFeatures} and
878     * {@link #hasSystemFeature}: The device has a telephony radio with data
879     * communication support.
880     */
881    @SdkConstant(SdkConstantType.FEATURE)
882    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
883
884    /**
885     * Feature for {@link #getSystemAvailableFeatures} and
886     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
887     */
888    @SdkConstant(SdkConstantType.FEATURE)
889    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
890
891    /**
892     * Feature for {@link #getSystemAvailableFeatures} and
893     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
894     */
895    @SdkConstant(SdkConstantType.FEATURE)
896    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
897
898    /**
899     * Feature for {@link #getSystemAvailableFeatures} and
900     * {@link #hasSystemFeature}: The device supports connecting to USB devices
901     * as the USB host.
902     */
903    @SdkConstant(SdkConstantType.FEATURE)
904    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
905
906    /**
907     * Feature for {@link #getSystemAvailableFeatures} and
908     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
909     */
910    @SdkConstant(SdkConstantType.FEATURE)
911    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
912
913    /**
914     * Feature for {@link #getSystemAvailableFeatures} and
915     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
916     */
917    @SdkConstant(SdkConstantType.FEATURE)
918    public static final String FEATURE_SIP = "android.software.sip";
919
920    /**
921     * Feature for {@link #getSystemAvailableFeatures} and
922     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
923     */
924    @SdkConstant(SdkConstantType.FEATURE)
925    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
926
927    /**
928     * Feature for {@link #getSystemAvailableFeatures} and
929     * {@link #hasSystemFeature}: The device's display has a touch screen.
930     */
931    @SdkConstant(SdkConstantType.FEATURE)
932    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
933
934
935    /**
936     * Feature for {@link #getSystemAvailableFeatures} and
937     * {@link #hasSystemFeature}: The device's touch screen supports
938     * multitouch sufficient for basic two-finger gesture detection.
939     */
940    @SdkConstant(SdkConstantType.FEATURE)
941    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
942
943    /**
944     * Feature for {@link #getSystemAvailableFeatures} and
945     * {@link #hasSystemFeature}: The device's touch screen is capable of
946     * tracking two or more fingers fully independently.
947     */
948    @SdkConstant(SdkConstantType.FEATURE)
949    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
950
951    /**
952     * Feature for {@link #getSystemAvailableFeatures} and
953     * {@link #hasSystemFeature}: The device's touch screen is capable of
954     * tracking a full hand of fingers fully independently -- that is, 5 or
955     * more simultaneous independent pointers.
956     */
957    @SdkConstant(SdkConstantType.FEATURE)
958    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
959
960    /**
961     * Feature for {@link #getSystemAvailableFeatures} and
962     * {@link #hasSystemFeature}: The device does not have a touch screen, but
963     * does support touch emulation for basic events. For instance, the
964     * device might use a mouse or remote control to drive a cursor, and
965     * emulate basic touch pointer events like down, up, drag, etc. All
966     * devices that support android.hardware.touchscreen or a sub-feature are
967     * presumed to also support faketouch.
968     */
969    @SdkConstant(SdkConstantType.FEATURE)
970    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
971
972    /**
973     * Feature for {@link #getSystemAvailableFeatures} and
974     * {@link #hasSystemFeature}: The device does not have a touch screen, but
975     * does support touch emulation for basic events that supports distinct
976     * tracking of two or more fingers.  This is an extension of
977     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
978     * that unlike a distinct multitouch screen as defined by
979     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
980     * devices will not actually provide full two-finger gestures since the
981     * input is being transformed to cursor movement on the screen.  That is,
982     * single finger gestures will move a cursor; two-finger swipes will
983     * result in single-finger touch events; other two-finger gestures will
984     * result in the corresponding two-finger touch event.
985     */
986    @SdkConstant(SdkConstantType.FEATURE)
987    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
988
989    /**
990     * Feature for {@link #getSystemAvailableFeatures} and
991     * {@link #hasSystemFeature}: The device does not have a touch screen, but
992     * does support touch emulation for basic events that supports tracking
993     * a hand of fingers (5 or more fingers) fully independently.
994     * This is an extension of
995     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
996     * that unlike a multitouch screen as defined by
997     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
998     * gestures can be detected due to the limitations described for
999     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1000     */
1001    @SdkConstant(SdkConstantType.FEATURE)
1002    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1003
1004    /**
1005     * Feature for {@link #getSystemAvailableFeatures} and
1006     * {@link #hasSystemFeature}: The device supports portrait orientation
1007     * screens.  For backwards compatibility, you can assume that if neither
1008     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1009     * both portrait and landscape.
1010     */
1011    @SdkConstant(SdkConstantType.FEATURE)
1012    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1013
1014    /**
1015     * Feature for {@link #getSystemAvailableFeatures} and
1016     * {@link #hasSystemFeature}: The device supports landscape orientation
1017     * screens.  For backwards compatibility, you can assume that if neither
1018     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1019     * both portrait and landscape.
1020     */
1021    @SdkConstant(SdkConstantType.FEATURE)
1022    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1023
1024    /**
1025     * Feature for {@link #getSystemAvailableFeatures} and
1026     * {@link #hasSystemFeature}: The device supports live wallpapers.
1027     */
1028    @SdkConstant(SdkConstantType.FEATURE)
1029    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1030
1031    /**
1032     * Feature for {@link #getSystemAvailableFeatures} and
1033     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1034     */
1035    @SdkConstant(SdkConstantType.FEATURE)
1036    public static final String FEATURE_WIFI = "android.hardware.wifi";
1037
1038    /**
1039     * Feature for {@link #getSystemAvailableFeatures} and
1040     * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1041     */
1042    @SdkConstant(SdkConstantType.FEATURE)
1043    public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1044
1045    /**
1046     * Action to external storage service to clean out removed apps.
1047     * @hide
1048     */
1049    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1050            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1051
1052    /**
1053     * Extra field name for the URI to a verification file. Passed to a package
1054     * verifier.
1055     *
1056     * @hide
1057     */
1058    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1059
1060    /**
1061     * Extra field name for the ID of a package pending verification. Passed to
1062     * a package verifier and is used to call back to
1063     * {@link PackageManager#verifyPendingInstall(int, int)}
1064     */
1065    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1066
1067    /**
1068     * Extra field name for the package identifier which is trying to install
1069     * the package.
1070     *
1071     * @hide
1072     */
1073    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1074            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1075
1076    /**
1077     * Extra field name for the requested install flags for a package pending
1078     * verification. Passed to a package verifier.
1079     *
1080     * @hide
1081     */
1082    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1083            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1084
1085    /**
1086     * Retrieve overall information about an application package that is
1087     * installed on the system.
1088     * <p>
1089     * Throws {@link NameNotFoundException} if a package with the given name can
1090     * not be found on the system.
1091     *
1092     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1093     *            desired package.
1094     * @param flags Additional option flags. Use any combination of
1095     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1096     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1097     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1098     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1099     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1100     *            modify the data returned.
1101     * @return Returns a PackageInfo object containing information about the
1102     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1103     *         package is not found in the list of installed applications, the
1104     *         package information is retrieved from the list of uninstalled
1105     *         applications(which includes installed applications as well as
1106     *         applications with data directory ie applications which had been
1107     *         deleted with DONT_DELTE_DATA flag set).
1108     * @see #GET_ACTIVITIES
1109     * @see #GET_GIDS
1110     * @see #GET_CONFIGURATIONS
1111     * @see #GET_INSTRUMENTATION
1112     * @see #GET_PERMISSIONS
1113     * @see #GET_PROVIDERS
1114     * @see #GET_RECEIVERS
1115     * @see #GET_SERVICES
1116     * @see #GET_SIGNATURES
1117     * @see #GET_UNINSTALLED_PACKAGES
1118     */
1119    public abstract PackageInfo getPackageInfo(String packageName, int flags)
1120            throws NameNotFoundException;
1121
1122    /**
1123     * Map from the current package names in use on the device to whatever
1124     * the current canonical name of that package is.
1125     * @param names Array of current names to be mapped.
1126     * @return Returns an array of the same size as the original, containing
1127     * the canonical name for each package.
1128     */
1129    public abstract String[] currentToCanonicalPackageNames(String[] names);
1130
1131    /**
1132     * Map from a packages canonical name to the current name in use on the device.
1133     * @param names Array of new names to be mapped.
1134     * @return Returns an array of the same size as the original, containing
1135     * the current name for each package.
1136     */
1137    public abstract String[] canonicalToCurrentPackageNames(String[] names);
1138
1139    /**
1140     * Return a "good" intent to launch a front-door activity in a package,
1141     * for use for example to implement an "open" button when browsing through
1142     * packages.  The current implementation will look first for a main
1143     * activity in the category {@link Intent#CATEGORY_INFO}, next for a
1144     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
1145     * null if neither are found.
1146     *
1147     * <p>Throws {@link NameNotFoundException} if a package with the given
1148     * name can not be found on the system.
1149     *
1150     * @param packageName The name of the package to inspect.
1151     *
1152     * @return Returns either a fully-qualified Intent that can be used to
1153     * launch the main activity in the package, or null if the package does
1154     * not contain such an activity.
1155     */
1156    public abstract Intent getLaunchIntentForPackage(String packageName);
1157
1158    /**
1159     * Return an array of all of the secondary group-ids that have been
1160     * assigned to a package.
1161     *
1162     * <p>Throws {@link NameNotFoundException} if a package with the given
1163     * name can not be found on the system.
1164     *
1165     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1166     *                    desired package.
1167     *
1168     * @return Returns an int array of the assigned gids, or null if there
1169     * are none.
1170     */
1171    public abstract int[] getPackageGids(String packageName)
1172            throws NameNotFoundException;
1173
1174    /**
1175     * Retrieve all of the information we know about a particular permission.
1176     *
1177     * <p>Throws {@link NameNotFoundException} if a permission with the given
1178     * name can not be found on the system.
1179     *
1180     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1181     *             of the permission you are interested in.
1182     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1183     * retrieve any meta-data associated with the permission.
1184     *
1185     * @return Returns a {@link PermissionInfo} containing information about the
1186     *         permission.
1187     */
1188    public abstract PermissionInfo getPermissionInfo(String name, int flags)
1189            throws NameNotFoundException;
1190
1191    /**
1192     * Query for all of the permissions associated with a particular group.
1193     *
1194     * <p>Throws {@link NameNotFoundException} if the given group does not
1195     * exist.
1196     *
1197     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1198     *             of the permission group you are interested in.  Use null to
1199     *             find all of the permissions not associated with a group.
1200     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1201     * retrieve any meta-data associated with the permissions.
1202     *
1203     * @return Returns a list of {@link PermissionInfo} containing information
1204     * about all of the permissions in the given group.
1205     */
1206    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1207            int flags) throws NameNotFoundException;
1208
1209    /**
1210     * Retrieve all of the information we know about a particular group of
1211     * permissions.
1212     *
1213     * <p>Throws {@link NameNotFoundException} if a permission group with the given
1214     * name can not be found on the system.
1215     *
1216     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1217     *             of the permission you are interested in.
1218     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1219     * retrieve any meta-data associated with the permission group.
1220     *
1221     * @return Returns a {@link PermissionGroupInfo} containing information
1222     * about the permission.
1223     */
1224    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1225            int flags) throws NameNotFoundException;
1226
1227    /**
1228     * Retrieve all of the known permission groups in the system.
1229     *
1230     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1231     * retrieve any meta-data associated with the permission group.
1232     *
1233     * @return Returns a list of {@link PermissionGroupInfo} containing
1234     * information about all of the known permission groups.
1235     */
1236    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1237
1238    /**
1239     * Retrieve all of the information we know about a particular
1240     * package/application.
1241     *
1242     * <p>Throws {@link NameNotFoundException} if an application with the given
1243     * package name can not be found on the system.
1244     *
1245     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1246     *                    application.
1247     * @param flags Additional option flags. Use any combination of
1248     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1249     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1250     *
1251     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1252     *         information about the package.
1253     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1254     *         found in the list of installed applications,
1255     *         the application information is retrieved from the
1256     *         list of uninstalled applications(which includes
1257     *         installed applications as well as applications
1258     *         with data directory ie applications which had been
1259     *         deleted with DONT_DELTE_DATA flag set).
1260     *
1261     * @see #GET_META_DATA
1262     * @see #GET_SHARED_LIBRARY_FILES
1263     * @see #GET_UNINSTALLED_PACKAGES
1264     */
1265    public abstract ApplicationInfo getApplicationInfo(String packageName,
1266            int flags) throws NameNotFoundException;
1267
1268    /**
1269     * Retrieve all of the information we know about a particular activity
1270     * class.
1271     *
1272     * <p>Throws {@link NameNotFoundException} if an activity with the given
1273     * class name can not be found on the system.
1274     *
1275     * @param component The full component name (i.e.
1276     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1277     * class.
1278     * @param flags Additional option flags. Use any combination of
1279     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1280     * to modify the data (in ApplicationInfo) returned.
1281     *
1282     * @return {@link ActivityInfo} containing information about the activity.
1283     *
1284     * @see #GET_INTENT_FILTERS
1285     * @see #GET_META_DATA
1286     * @see #GET_SHARED_LIBRARY_FILES
1287     */
1288    public abstract ActivityInfo getActivityInfo(ComponentName component,
1289            int flags) throws NameNotFoundException;
1290
1291    /**
1292     * Retrieve all of the information we know about a particular receiver
1293     * class.
1294     *
1295     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1296     * class name can not be found on the system.
1297     *
1298     * @param component The full component name (i.e.
1299     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1300     * class.
1301     * @param flags Additional option flags.  Use any combination of
1302     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1303     * to modify the data returned.
1304     *
1305     * @return {@link ActivityInfo} containing information about the receiver.
1306     *
1307     * @see #GET_INTENT_FILTERS
1308     * @see #GET_META_DATA
1309     * @see #GET_SHARED_LIBRARY_FILES
1310     */
1311    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1312            int flags) throws NameNotFoundException;
1313
1314    /**
1315     * Retrieve all of the information we know about a particular service
1316     * class.
1317     *
1318     * <p>Throws {@link NameNotFoundException} if a service with the given
1319     * class name can not be found on the system.
1320     *
1321     * @param component The full component name (i.e.
1322     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1323     * class.
1324     * @param flags Additional option flags.  Use any combination of
1325     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1326     * to modify the data returned.
1327     *
1328     * @return ServiceInfo containing information about the service.
1329     *
1330     * @see #GET_META_DATA
1331     * @see #GET_SHARED_LIBRARY_FILES
1332     */
1333    public abstract ServiceInfo getServiceInfo(ComponentName component,
1334            int flags) throws NameNotFoundException;
1335
1336    /**
1337     * Retrieve all of the information we know about a particular content
1338     * provider class.
1339     *
1340     * <p>Throws {@link NameNotFoundException} if a provider with the given
1341     * class name can not be found on the system.
1342     *
1343     * @param component The full component name (i.e.
1344     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1345     * ContentProvider class.
1346     * @param flags Additional option flags.  Use any combination of
1347     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1348     * to modify the data returned.
1349     *
1350     * @return ProviderInfo containing information about the service.
1351     *
1352     * @see #GET_META_DATA
1353     * @see #GET_SHARED_LIBRARY_FILES
1354     */
1355    public abstract ProviderInfo getProviderInfo(ComponentName component,
1356            int flags) throws NameNotFoundException;
1357
1358    /**
1359     * Return a List of all packages that are installed
1360     * on the device.
1361     *
1362     * @param flags Additional option flags. Use any combination of
1363     * {@link #GET_ACTIVITIES},
1364     * {@link #GET_GIDS},
1365     * {@link #GET_CONFIGURATIONS},
1366     * {@link #GET_INSTRUMENTATION},
1367     * {@link #GET_PERMISSIONS},
1368     * {@link #GET_PROVIDERS},
1369     * {@link #GET_RECEIVERS},
1370     * {@link #GET_SERVICES},
1371     * {@link #GET_SIGNATURES},
1372     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1373     *
1374     * @return A List of PackageInfo objects, one for each package that is
1375     *         installed on the device.  In the unlikely case of there being no
1376     *         installed packages, an empty list is returned.
1377     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1378     *         applications including those deleted with DONT_DELETE_DATA
1379     *         (partially installed apps with data directory) will be returned.
1380     *
1381     * @see #GET_ACTIVITIES
1382     * @see #GET_GIDS
1383     * @see #GET_CONFIGURATIONS
1384     * @see #GET_INSTRUMENTATION
1385     * @see #GET_PERMISSIONS
1386     * @see #GET_PROVIDERS
1387     * @see #GET_RECEIVERS
1388     * @see #GET_SERVICES
1389     * @see #GET_SIGNATURES
1390     * @see #GET_UNINSTALLED_PACKAGES
1391     *
1392     */
1393    public abstract List<PackageInfo> getInstalledPackages(int flags);
1394
1395    /**
1396     * Check whether a particular package has been granted a particular
1397     * permission.
1398     *
1399     * @param permName The name of the permission you are checking for,
1400     * @param pkgName The name of the package you are checking against.
1401     *
1402     * @return If the package has the permission, PERMISSION_GRANTED is
1403     * returned.  If it does not have the permission, PERMISSION_DENIED
1404     * is returned.
1405     *
1406     * @see #PERMISSION_GRANTED
1407     * @see #PERMISSION_DENIED
1408     */
1409    public abstract int checkPermission(String permName, String pkgName);
1410
1411    /**
1412     * Add a new dynamic permission to the system.  For this to work, your
1413     * package must have defined a permission tree through the
1414     * {@link android.R.styleable#AndroidManifestPermissionTree
1415     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
1416     * permissions to trees that were defined by either its own package or
1417     * another with the same user id; a permission is in a tree if it
1418     * matches the name of the permission tree + ".": for example,
1419     * "com.foo.bar" is a member of the permission tree "com.foo".
1420     *
1421     * <p>It is good to make your permission tree name descriptive, because you
1422     * are taking possession of that entire set of permission names.  Thus, it
1423     * must be under a domain you control, with a suffix that will not match
1424     * any normal permissions that may be declared in any applications that
1425     * are part of that domain.
1426     *
1427     * <p>New permissions must be added before
1428     * any .apks are installed that use those permissions.  Permissions you
1429     * add through this method are remembered across reboots of the device.
1430     * If the given permission already exists, the info you supply here
1431     * will be used to update it.
1432     *
1433     * @param info Description of the permission to be added.
1434     *
1435     * @return Returns true if a new permission was created, false if an
1436     * existing one was updated.
1437     *
1438     * @throws SecurityException if you are not allowed to add the
1439     * given permission name.
1440     *
1441     * @see #removePermission(String)
1442     */
1443    public abstract boolean addPermission(PermissionInfo info);
1444
1445    /**
1446     * Like {@link #addPermission(PermissionInfo)} but asynchronously
1447     * persists the package manager state after returning from the call,
1448     * allowing it to return quicker and batch a series of adds at the
1449     * expense of no guarantee the added permission will be retained if
1450     * the device is rebooted before it is written.
1451     */
1452    public abstract boolean addPermissionAsync(PermissionInfo info);
1453
1454    /**
1455     * Removes a permission that was previously added with
1456     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
1457     * -- you are only allowed to remove permissions that you are allowed
1458     * to add.
1459     *
1460     * @param name The name of the permission to remove.
1461     *
1462     * @throws SecurityException if you are not allowed to remove the
1463     * given permission name.
1464     *
1465     * @see #addPermission(PermissionInfo)
1466     */
1467    public abstract void removePermission(String name);
1468
1469    /**
1470     * Compare the signatures of two packages to determine if the same
1471     * signature appears in both of them.  If they do contain the same
1472     * signature, then they are allowed special privileges when working
1473     * with each other: they can share the same user-id, run instrumentation
1474     * against each other, etc.
1475     *
1476     * @param pkg1 First package name whose signature will be compared.
1477     * @param pkg2 Second package name whose signature will be compared.
1478     *
1479     * @return Returns an integer indicating whether all signatures on the
1480     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1481     * all signatures match or < 0 if there is not a match ({@link
1482     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1483     *
1484     * @see #checkSignatures(int, int)
1485     * @see #SIGNATURE_MATCH
1486     * @see #SIGNATURE_NO_MATCH
1487     * @see #SIGNATURE_UNKNOWN_PACKAGE
1488     */
1489    public abstract int checkSignatures(String pkg1, String pkg2);
1490
1491    /**
1492     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
1493     * the two packages to be checked.  This can be useful, for example,
1494     * when doing the check in an IPC, where the UID is the only identity
1495     * available.  It is functionally identical to determining the package
1496     * associated with the UIDs and checking their signatures.
1497     *
1498     * @param uid1 First UID whose signature will be compared.
1499     * @param uid2 Second UID whose signature will be compared.
1500     *
1501     * @return Returns an integer indicating whether all signatures on the
1502     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1503     * all signatures match or < 0 if there is not a match ({@link
1504     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1505     *
1506     * @see #checkSignatures(String, String)
1507     * @see #SIGNATURE_MATCH
1508     * @see #SIGNATURE_NO_MATCH
1509     * @see #SIGNATURE_UNKNOWN_PACKAGE
1510     */
1511    public abstract int checkSignatures(int uid1, int uid2);
1512
1513    /**
1514     * Retrieve the names of all packages that are associated with a particular
1515     * user id.  In most cases, this will be a single package name, the package
1516     * that has been assigned that user id.  Where there are multiple packages
1517     * sharing the same user id through the "sharedUserId" mechanism, all
1518     * packages with that id will be returned.
1519     *
1520     * @param uid The user id for which you would like to retrieve the
1521     * associated packages.
1522     *
1523     * @return Returns an array of one or more packages assigned to the user
1524     * id, or null if there are no known packages with the given id.
1525     */
1526    public abstract String[] getPackagesForUid(int uid);
1527
1528    /**
1529     * Retrieve the official name associated with a user id.  This name is
1530     * guaranteed to never change, though it is possibly for the underlying
1531     * user id to be changed.  That is, if you are storing information about
1532     * user ids in persistent storage, you should use the string returned
1533     * by this function instead of the raw user-id.
1534     *
1535     * @param uid The user id for which you would like to retrieve a name.
1536     * @return Returns a unique name for the given user id, or null if the
1537     * user id is not currently assigned.
1538     */
1539    public abstract String getNameForUid(int uid);
1540
1541    /**
1542     * Return the user id associated with a shared user name. Multiple
1543     * applications can specify a shared user name in their manifest and thus
1544     * end up using a common uid. This might be used for new applications
1545     * that use an existing shared user name and need to know the uid of the
1546     * shared user.
1547     *
1548     * @param sharedUserName The shared user name whose uid is to be retrieved.
1549     * @return Returns the uid associated with the shared user, or  NameNotFoundException
1550     * if the shared user name is not being used by any installed packages
1551     * @hide
1552     */
1553    public abstract int getUidForSharedUser(String sharedUserName)
1554            throws NameNotFoundException;
1555
1556    /**
1557     * Return a List of all application packages that are installed on the
1558     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
1559     * applications including those deleted with DONT_DELETE_DATA(partially
1560     * installed apps with data directory) will be returned.
1561     *
1562     * @param flags Additional option flags. Use any combination of
1563     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1564     * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1565     *
1566     * @return A List of ApplicationInfo objects, one for each application that
1567     *         is installed on the device.  In the unlikely case of there being
1568     *         no installed applications, an empty list is returned.
1569     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1570     *         applications including those deleted with DONT_DELETE_DATA
1571     *         (partially installed apps with data directory) will be returned.
1572     *
1573     * @see #GET_META_DATA
1574     * @see #GET_SHARED_LIBRARY_FILES
1575     * @see #GET_UNINSTALLED_PACKAGES
1576     */
1577    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
1578
1579    /**
1580     * Get a list of shared libraries that are available on the
1581     * system.
1582     *
1583     * @return An array of shared library names that are
1584     * available on the system, or null if none are installed.
1585     *
1586     */
1587    public abstract String[] getSystemSharedLibraryNames();
1588
1589    /**
1590     * Get a list of features that are available on the
1591     * system.
1592     *
1593     * @return An array of FeatureInfo classes describing the features
1594     * that are available on the system, or null if there are none(!!).
1595     */
1596    public abstract FeatureInfo[] getSystemAvailableFeatures();
1597
1598    /**
1599     * Check whether the given feature name is one of the available
1600     * features as returned by {@link #getSystemAvailableFeatures()}.
1601     *
1602     * @return Returns true if the devices supports the feature, else
1603     * false.
1604     */
1605    public abstract boolean hasSystemFeature(String name);
1606
1607    /**
1608     * Determine the best action to perform for a given Intent.  This is how
1609     * {@link Intent#resolveActivity} finds an activity if a class has not
1610     * been explicitly specified.
1611     *
1612     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
1613     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
1614     * only flag.  You need to do so to resolve the activity in the same way
1615     * that {@link android.content.Context#startActivity(Intent)} and
1616     * {@link android.content.Intent#resolveActivity(PackageManager)
1617     * Intent.resolveActivity(PackageManager)} do.</p>
1618     *
1619     * @param intent An intent containing all of the desired specification
1620     *               (action, data, type, category, and/or component).
1621     * @param flags Additional option flags.  The most important is
1622     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1623     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1624     *
1625     * @return Returns a ResolveInfo containing the final activity intent that
1626     *         was determined to be the best action.  Returns null if no
1627     *         matching activity was found. If multiple matching activities are
1628     *         found and there is no default set, returns a ResolveInfo
1629     *         containing something else, such as the activity resolver.
1630     *
1631     * @see #MATCH_DEFAULT_ONLY
1632     * @see #GET_INTENT_FILTERS
1633     * @see #GET_RESOLVED_FILTER
1634     */
1635    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1636
1637    /**
1638     * Retrieve all activities that can be performed for the given intent.
1639     *
1640     * @param intent The desired intent as per resolveActivity().
1641     * @param flags Additional option flags.  The most important is
1642     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1643     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1644     *
1645     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1646     *         Activity. These are ordered from best to worst match -- that
1647     *         is, the first item in the list is what is returned by
1648     *         {@link #resolveActivity}.  If there are no matching activities, an empty
1649     *         list is returned.
1650     *
1651     * @see #MATCH_DEFAULT_ONLY
1652     * @see #GET_INTENT_FILTERS
1653     * @see #GET_RESOLVED_FILTER
1654     */
1655    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
1656            int flags);
1657
1658    /**
1659     * Retrieve a set of activities that should be presented to the user as
1660     * similar options.  This is like {@link #queryIntentActivities}, except it
1661     * also allows you to supply a list of more explicit Intents that you would
1662     * like to resolve to particular options, and takes care of returning the
1663     * final ResolveInfo list in a reasonable order, with no duplicates, based
1664     * on those inputs.
1665     *
1666     * @param caller The class name of the activity that is making the
1667     *               request.  This activity will never appear in the output
1668     *               list.  Can be null.
1669     * @param specifics An array of Intents that should be resolved to the
1670     *                  first specific results.  Can be null.
1671     * @param intent The desired intent as per resolveActivity().
1672     * @param flags Additional option flags.  The most important is
1673     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1674     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1675     *
1676     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1677     *         Activity. These are ordered first by all of the intents resolved
1678     *         in <var>specifics</var> and then any additional activities that
1679     *         can handle <var>intent</var> but did not get included by one of
1680     *         the <var>specifics</var> intents.  If there are no matching
1681     *         activities, an empty list is returned.
1682     *
1683     * @see #MATCH_DEFAULT_ONLY
1684     * @see #GET_INTENT_FILTERS
1685     * @see #GET_RESOLVED_FILTER
1686     */
1687    public abstract List<ResolveInfo> queryIntentActivityOptions(
1688            ComponentName caller, Intent[] specifics, Intent intent, int flags);
1689
1690    /**
1691     * Retrieve all receivers that can handle a broadcast of the given intent.
1692     *
1693     * @param intent The desired intent as per resolveActivity().
1694     * @param flags Additional option flags.
1695     *
1696     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1697     *         Receiver. These are ordered from first to last in priority.  If
1698     *         there are no matching receivers, an empty list is returned.
1699     *
1700     * @see #MATCH_DEFAULT_ONLY
1701     * @see #GET_INTENT_FILTERS
1702     * @see #GET_RESOLVED_FILTER
1703     */
1704    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
1705            int flags);
1706
1707    /**
1708     * Determine the best service to handle for a given Intent.
1709     *
1710     * @param intent An intent containing all of the desired specification
1711     *               (action, data, type, category, and/or component).
1712     * @param flags Additional option flags.
1713     *
1714     * @return Returns a ResolveInfo containing the final service intent that
1715     *         was determined to be the best action.  Returns null if no
1716     *         matching service was found.
1717     *
1718     * @see #GET_INTENT_FILTERS
1719     * @see #GET_RESOLVED_FILTER
1720     */
1721    public abstract ResolveInfo resolveService(Intent intent, int flags);
1722
1723    /**
1724     * Retrieve all services that can match the given intent.
1725     *
1726     * @param intent The desired intent as per resolveService().
1727     * @param flags Additional option flags.
1728     *
1729     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1730     *         ServiceInfo. These are ordered from best to worst match -- that
1731     *         is, the first item in the list is what is returned by
1732     *         resolveService().  If there are no matching services, an empty
1733     *         list is returned.
1734     *
1735     * @see #GET_INTENT_FILTERS
1736     * @see #GET_RESOLVED_FILTER
1737     */
1738    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
1739            int flags);
1740
1741    /**
1742     * Find a single content provider by its base path name.
1743     *
1744     * @param name The name of the provider to find.
1745     * @param flags Additional option flags.  Currently should always be 0.
1746     *
1747     * @return ContentProviderInfo Information about the provider, if found,
1748     *         else null.
1749     */
1750    public abstract ProviderInfo resolveContentProvider(String name,
1751            int flags);
1752
1753    /**
1754     * Retrieve content provider information.
1755     *
1756     * <p><em>Note: unlike most other methods, an empty result set is indicated
1757     * by a null return instead of an empty list.</em>
1758     *
1759     * @param processName If non-null, limits the returned providers to only
1760     *                    those that are hosted by the given process.  If null,
1761     *                    all content providers are returned.
1762     * @param uid If <var>processName</var> is non-null, this is the required
1763     *        uid owning the requested content providers.
1764     * @param flags Additional option flags.  Currently should always be 0.
1765     *
1766     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
1767     *         content provider either patching <var>processName</var> or, if
1768     *         <var>processName</var> is null, all known content providers.
1769     *         <em>If there are no matching providers, null is returned.</em>
1770     */
1771    public abstract List<ProviderInfo> queryContentProviders(
1772            String processName, int uid, int flags);
1773
1774    /**
1775     * Retrieve all of the information we know about a particular
1776     * instrumentation class.
1777     *
1778     * <p>Throws {@link NameNotFoundException} if instrumentation with the
1779     * given class name can not be found on the system.
1780     *
1781     * @param className The full name (i.e.
1782     *                  com.google.apps.contacts.InstrumentList) of an
1783     *                  Instrumentation class.
1784     * @param flags Additional option flags.  Currently should always be 0.
1785     *
1786     * @return InstrumentationInfo containing information about the
1787     *         instrumentation.
1788     */
1789    public abstract InstrumentationInfo getInstrumentationInfo(
1790            ComponentName className, int flags) throws NameNotFoundException;
1791
1792    /**
1793     * Retrieve information about available instrumentation code.  May be used
1794     * to retrieve either all instrumentation code, or only the code targeting
1795     * a particular package.
1796     *
1797     * @param targetPackage If null, all instrumentation is returned; only the
1798     *                      instrumentation targeting this package name is
1799     *                      returned.
1800     * @param flags Additional option flags.  Currently should always be 0.
1801     *
1802     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
1803     *         matching available Instrumentation.  Returns an empty list if
1804     *         there is no instrumentation available for the given package.
1805     */
1806    public abstract List<InstrumentationInfo> queryInstrumentation(
1807            String targetPackage, int flags);
1808
1809    /**
1810     * Retrieve an image from a package.  This is a low-level API used by
1811     * the various package manager info structures (such as
1812     * {@link ComponentInfo} to implement retrieval of their associated
1813     * icon.
1814     *
1815     * @param packageName The name of the package that this icon is coming from.
1816     * Can not be null.
1817     * @param resid The resource identifier of the desired image.  Can not be 0.
1818     * @param appInfo Overall information about <var>packageName</var>.  This
1819     * may be null, in which case the application information will be retrieved
1820     * for you if needed; if you already have this information around, it can
1821     * be much more efficient to supply it here.
1822     *
1823     * @return Returns a Drawable holding the requested image.  Returns null if
1824     * an image could not be found for any reason.
1825     */
1826    public abstract Drawable getDrawable(String packageName, int resid,
1827            ApplicationInfo appInfo);
1828
1829    /**
1830     * Retrieve the icon associated with an activity.  Given the full name of
1831     * an activity, retrieves the information about it and calls
1832     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
1833     * If the activity can not be found, NameNotFoundException is thrown.
1834     *
1835     * @param activityName Name of the activity whose icon is to be retrieved.
1836     *
1837     * @return Returns the image of the icon, or the default activity icon if
1838     * it could not be found.  Does not return null.
1839     * @throws NameNotFoundException Thrown if the resources for the given
1840     * activity could not be loaded.
1841     *
1842     * @see #getActivityIcon(Intent)
1843     */
1844    public abstract Drawable getActivityIcon(ComponentName activityName)
1845            throws NameNotFoundException;
1846
1847    /**
1848     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
1849     * set, this simply returns the result of
1850     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
1851     * component and returns the icon associated with the resolved component.
1852     * If intent.getClassName() can not be found or the Intent can not be resolved
1853     * to a component, NameNotFoundException is thrown.
1854     *
1855     * @param intent The intent for which you would like to retrieve an icon.
1856     *
1857     * @return Returns the image of the icon, or the default activity icon if
1858     * it could not be found.  Does not return null.
1859     * @throws NameNotFoundException Thrown if the resources for application
1860     * matching the given intent could not be loaded.
1861     *
1862     * @see #getActivityIcon(ComponentName)
1863     */
1864    public abstract Drawable getActivityIcon(Intent intent)
1865            throws NameNotFoundException;
1866
1867    /**
1868     * Return the generic icon for an activity that is used when no specific
1869     * icon is defined.
1870     *
1871     * @return Drawable Image of the icon.
1872     */
1873    public abstract Drawable getDefaultActivityIcon();
1874
1875    /**
1876     * Retrieve the icon associated with an application.  If it has not defined
1877     * an icon, the default app icon is returned.  Does not return null.
1878     *
1879     * @param info Information about application being queried.
1880     *
1881     * @return Returns the image of the icon, or the default application icon
1882     * if it could not be found.
1883     *
1884     * @see #getApplicationIcon(String)
1885     */
1886    public abstract Drawable getApplicationIcon(ApplicationInfo info);
1887
1888    /**
1889     * Retrieve the icon associated with an application.  Given the name of the
1890     * application's package, retrieves the information about it and calls
1891     * getApplicationIcon() to return its icon. If the application can not be
1892     * found, NameNotFoundException is thrown.
1893     *
1894     * @param packageName Name of the package whose application icon is to be
1895     *                    retrieved.
1896     *
1897     * @return Returns the image of the icon, or the default application icon
1898     * if it could not be found.  Does not return null.
1899     * @throws NameNotFoundException Thrown if the resources for the given
1900     * application could not be loaded.
1901     *
1902     * @see #getApplicationIcon(ApplicationInfo)
1903     */
1904    public abstract Drawable getApplicationIcon(String packageName)
1905            throws NameNotFoundException;
1906
1907    /**
1908     * Retrieve the logo associated with an activity.  Given the full name of
1909     * an activity, retrieves the information about it and calls
1910     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
1911     * If the activity can not be found, NameNotFoundException is thrown.
1912     *
1913     * @param activityName Name of the activity whose logo is to be retrieved.
1914     *
1915     * @return Returns the image of the logo or null if the activity has no
1916     * logo specified.
1917     *
1918     * @throws NameNotFoundException Thrown if the resources for the given
1919     * activity could not be loaded.
1920     *
1921     * @see #getActivityLogo(Intent)
1922     */
1923    public abstract Drawable getActivityLogo(ComponentName activityName)
1924            throws NameNotFoundException;
1925
1926    /**
1927     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
1928     * set, this simply returns the result of
1929     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
1930     * component and returns the logo associated with the resolved component.
1931     * If intent.getClassName() can not be found or the Intent can not be resolved
1932     * to a component, NameNotFoundException is thrown.
1933     *
1934     * @param intent The intent for which you would like to retrieve a logo.
1935     *
1936     * @return Returns the image of the logo, or null if the activity has no
1937     * logo specified.
1938     *
1939     * @throws NameNotFoundException Thrown if the resources for application
1940     * matching the given intent could not be loaded.
1941     *
1942     * @see #getActivityLogo(ComponentName)
1943     */
1944    public abstract Drawable getActivityLogo(Intent intent)
1945            throws NameNotFoundException;
1946
1947    /**
1948     * Retrieve the logo associated with an application.  If it has not specified
1949     * a logo, this method returns null.
1950     *
1951     * @param info Information about application being queried.
1952     *
1953     * @return Returns the image of the logo, or null if no logo is specified
1954     * by the application.
1955     *
1956     * @see #getApplicationLogo(String)
1957     */
1958    public abstract Drawable getApplicationLogo(ApplicationInfo info);
1959
1960    /**
1961     * Retrieve the logo associated with an application.  Given the name of the
1962     * application's package, retrieves the information about it and calls
1963     * getApplicationLogo() to return its logo. If the application can not be
1964     * found, NameNotFoundException is thrown.
1965     *
1966     * @param packageName Name of the package whose application logo is to be
1967     *                    retrieved.
1968     *
1969     * @return Returns the image of the logo, or null if no application logo
1970     * has been specified.
1971     *
1972     * @throws NameNotFoundException Thrown if the resources for the given
1973     * application could not be loaded.
1974     *
1975     * @see #getApplicationLogo(ApplicationInfo)
1976     */
1977    public abstract Drawable getApplicationLogo(String packageName)
1978            throws NameNotFoundException;
1979
1980    /**
1981     * Retrieve text from a package.  This is a low-level API used by
1982     * the various package manager info structures (such as
1983     * {@link ComponentInfo} to implement retrieval of their associated
1984     * labels and other text.
1985     *
1986     * @param packageName The name of the package that this text is coming from.
1987     * Can not be null.
1988     * @param resid The resource identifier of the desired text.  Can not be 0.
1989     * @param appInfo Overall information about <var>packageName</var>.  This
1990     * may be null, in which case the application information will be retrieved
1991     * for you if needed; if you already have this information around, it can
1992     * be much more efficient to supply it here.
1993     *
1994     * @return Returns a CharSequence holding the requested text.  Returns null
1995     * if the text could not be found for any reason.
1996     */
1997    public abstract CharSequence getText(String packageName, int resid,
1998            ApplicationInfo appInfo);
1999
2000    /**
2001     * Retrieve an XML file from a package.  This is a low-level API used to
2002     * retrieve XML meta data.
2003     *
2004     * @param packageName The name of the package that this xml is coming from.
2005     * Can not be null.
2006     * @param resid The resource identifier of the desired xml.  Can not be 0.
2007     * @param appInfo Overall information about <var>packageName</var>.  This
2008     * may be null, in which case the application information will be retrieved
2009     * for you if needed; if you already have this information around, it can
2010     * be much more efficient to supply it here.
2011     *
2012     * @return Returns an XmlPullParser allowing you to parse out the XML
2013     * data.  Returns null if the xml resource could not be found for any
2014     * reason.
2015     */
2016    public abstract XmlResourceParser getXml(String packageName, int resid,
2017            ApplicationInfo appInfo);
2018
2019    /**
2020     * Return the label to use for this application.
2021     *
2022     * @return Returns the label associated with this application, or null if
2023     * it could not be found for any reason.
2024     * @param info The application to get the label of
2025     */
2026    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
2027
2028    /**
2029     * Retrieve the resources associated with an activity.  Given the full
2030     * name of an activity, retrieves the information about it and calls
2031     * getResources() to return its application's resources.  If the activity
2032     * can not be found, NameNotFoundException is thrown.
2033     *
2034     * @param activityName Name of the activity whose resources are to be
2035     *                     retrieved.
2036     *
2037     * @return Returns the application's Resources.
2038     * @throws NameNotFoundException Thrown if the resources for the given
2039     * application could not be loaded.
2040     *
2041     * @see #getResourcesForApplication(ApplicationInfo)
2042     */
2043    public abstract Resources getResourcesForActivity(ComponentName activityName)
2044            throws NameNotFoundException;
2045
2046    /**
2047     * Retrieve the resources for an application.  Throws NameNotFoundException
2048     * if the package is no longer installed.
2049     *
2050     * @param app Information about the desired application.
2051     *
2052     * @return Returns the application's Resources.
2053     * @throws NameNotFoundException Thrown if the resources for the given
2054     * application could not be loaded (most likely because it was uninstalled).
2055     */
2056    public abstract Resources getResourcesForApplication(ApplicationInfo app)
2057            throws NameNotFoundException;
2058
2059    /**
2060     * Retrieve the resources associated with an application.  Given the full
2061     * package name of an application, retrieves the information about it and
2062     * calls getResources() to return its application's resources.  If the
2063     * appPackageName can not be found, NameNotFoundException is thrown.
2064     *
2065     * @param appPackageName Package name of the application whose resources
2066     *                       are to be retrieved.
2067     *
2068     * @return Returns the application's Resources.
2069     * @throws NameNotFoundException Thrown if the resources for the given
2070     * application could not be loaded.
2071     *
2072     * @see #getResourcesForApplication(ApplicationInfo)
2073     */
2074    public abstract Resources getResourcesForApplication(String appPackageName)
2075            throws NameNotFoundException;
2076
2077    /**
2078     * Retrieve overall information about an application package defined
2079     * in a package archive file
2080     *
2081     * @param archiveFilePath The path to the archive file
2082     * @param flags Additional option flags. Use any combination of
2083     * {@link #GET_ACTIVITIES},
2084     * {@link #GET_GIDS},
2085     * {@link #GET_CONFIGURATIONS},
2086     * {@link #GET_INSTRUMENTATION},
2087     * {@link #GET_PERMISSIONS},
2088     * {@link #GET_PROVIDERS},
2089     * {@link #GET_RECEIVERS},
2090     * {@link #GET_SERVICES},
2091     * {@link #GET_SIGNATURES}, to modify the data returned.
2092     *
2093     * @return Returns the information about the package. Returns
2094     * null if the package could not be successfully parsed.
2095     *
2096     * @see #GET_ACTIVITIES
2097     * @see #GET_GIDS
2098     * @see #GET_CONFIGURATIONS
2099     * @see #GET_INSTRUMENTATION
2100     * @see #GET_PERMISSIONS
2101     * @see #GET_PROVIDERS
2102     * @see #GET_RECEIVERS
2103     * @see #GET_SERVICES
2104     * @see #GET_SIGNATURES
2105     *
2106     */
2107    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
2108        PackageParser packageParser = new PackageParser(archiveFilePath);
2109        DisplayMetrics metrics = new DisplayMetrics();
2110        metrics.setToDefaults();
2111        final File sourceFile = new File(archiveFilePath);
2112        PackageParser.Package pkg = packageParser.parsePackage(
2113                sourceFile, archiveFilePath, metrics, 0);
2114        if (pkg == null) {
2115            return null;
2116        }
2117        return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0);
2118    }
2119
2120    /**
2121     * @hide
2122     *
2123     * Install a package. Since this may take a little while, the result will
2124     * be posted back to the given observer.  An installation will fail if the calling context
2125     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
2126     * package named in the package file's manifest is already installed, or if there's no space
2127     * available on the device.
2128     *
2129     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
2130     * 'content:' URI.
2131     * @param observer An observer callback to get notified when the package installation is
2132     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
2133     * called when that happens.  observer may be null to indicate that no callback is desired.
2134     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2135     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2136     * @param installerPackageName Optional package name of the application that is performing the
2137     * installation. This identifies which market the package came from.
2138     */
2139    public abstract void installPackage(
2140            Uri packageURI, IPackageInstallObserver observer, int flags,
2141            String installerPackageName);
2142
2143    /**
2144     * Similar to
2145     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
2146     * with an extra verification file provided.
2147     *
2148     * @param packageURI The location of the package file to install. This can
2149     *            be a 'file:' or a 'content:' URI.
2150     * @param observer An observer callback to get notified when the package
2151     *            installation is complete.
2152     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
2153     *            will be called when that happens. observer may be null to
2154     *            indicate that no callback is desired.
2155     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2156     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}
2157     *            .
2158     * @param installerPackageName Optional package name of the application that
2159     *            is performing the installation. This identifies which market
2160     *            the package came from.
2161     * @param verificationURI The location of the supplementary verification
2162     *            file. This can be a 'file:' or a 'content:' URI.
2163     * @hide
2164     */
2165    public abstract void installPackageWithVerification(Uri packageURI,
2166            IPackageInstallObserver observer, int flags, String installerPackageName,
2167            Uri verificationURI, ManifestDigest manifestDigest);
2168
2169    /**
2170     * Allows a package listening to the
2171     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
2172     * broadcast} to respond to the package manager. The response must include
2173     * the {@code verificationCode} which is one of
2174     * {@link PackageManager#VERIFICATION_ALLOW} or
2175     * {@link PackageManager#VERIFICATION_REJECT}.
2176     *
2177     * @param id pending package identifier as passed via the
2178     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra
2179     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
2180     *            or {@link PackageManager#VERIFICATION_REJECT}.
2181     */
2182    public abstract void verifyPendingInstall(int id, int verificationCode);
2183
2184    /**
2185     * Change the installer associated with a given package.  There are limitations
2186     * on how the installer package can be changed; in particular:
2187     * <ul>
2188     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
2189     * is not signed with the same certificate as the calling application.
2190     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
2191     * has an installer package, and that installer package is not signed with
2192     * the same certificate as the calling application.
2193     * </ul>
2194     *
2195     * @param targetPackage The installed package whose installer will be changed.
2196     * @param installerPackageName The package name of the new installer.  May be
2197     * null to clear the association.
2198     */
2199    public abstract void setInstallerPackageName(String targetPackage,
2200            String installerPackageName);
2201
2202    /**
2203     * Attempts to delete a package.  Since this may take a little while, the result will
2204     * be posted back to the given observer.  A deletion will fail if the calling context
2205     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
2206     * named package cannot be found, or if the named package is a "system package".
2207     * (TODO: include pointer to documentation on "system packages")
2208     *
2209     * @param packageName The name of the package to delete
2210     * @param observer An observer callback to get notified when the package deletion is
2211     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
2212     * called when that happens.  observer may be null to indicate that no callback is desired.
2213     * @param flags - possible values: {@link #DONT_DELETE_DATA}
2214     *
2215     * @hide
2216     */
2217    public abstract void deletePackage(
2218            String packageName, IPackageDeleteObserver observer, int flags);
2219
2220    /**
2221     * Retrieve the package name of the application that installed a package. This identifies
2222     * which market the package came from.
2223     *
2224     * @param packageName The name of the package to query
2225     */
2226    public abstract String getInstallerPackageName(String packageName);
2227
2228    /**
2229     * Attempts to clear the user data directory of an application.
2230     * Since this may take a little while, the result will
2231     * be posted back to the given observer.  A deletion will fail if the
2232     * named package cannot be found, or if the named package is a "system package".
2233     *
2234     * @param packageName The name of the package
2235     * @param observer An observer callback to get notified when the operation is finished
2236     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2237     * will be called when that happens.  observer may be null to indicate that
2238     * no callback is desired.
2239     *
2240     * @hide
2241     */
2242    public abstract void clearApplicationUserData(String packageName,
2243            IPackageDataObserver observer);
2244    /**
2245     * Attempts to delete the cache files associated with an application.
2246     * Since this may take a little while, the result will
2247     * be posted back to the given observer.  A deletion will fail if the calling context
2248     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
2249     * named package cannot be found, or if the named package is a "system package".
2250     *
2251     * @param packageName The name of the package to delete
2252     * @param observer An observer callback to get notified when the cache file deletion
2253     * is complete.
2254     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2255     * will be called when that happens.  observer may be null to indicate that
2256     * no callback is desired.
2257     *
2258     * @hide
2259     */
2260    public abstract void deleteApplicationCacheFiles(String packageName,
2261            IPackageDataObserver observer);
2262
2263    /**
2264     * Free storage by deleting LRU sorted list of cache files across
2265     * all applications. If the currently available free storage
2266     * on the device is greater than or equal to the requested
2267     * free storage, no cache files are cleared. If the currently
2268     * available storage on the device is less than the requested
2269     * free storage, some or all of the cache files across
2270     * all applications are deleted (based on last accessed time)
2271     * to increase the free storage space on the device to
2272     * the requested value. There is no guarantee that clearing all
2273     * the cache files from all applications will clear up
2274     * enough storage to achieve the desired value.
2275     * @param freeStorageSize The number of bytes of storage to be
2276     * freed by the system. Say if freeStorageSize is XX,
2277     * and the current free storage is YY,
2278     * if XX is less than YY, just return. if not free XX-YY number
2279     * of bytes if possible.
2280     * @param observer call back used to notify when
2281     * the operation is completed
2282     *
2283     * @hide
2284     */
2285    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
2286
2287    /**
2288     * Free storage by deleting LRU sorted list of cache files across
2289     * all applications. If the currently available free storage
2290     * on the device is greater than or equal to the requested
2291     * free storage, no cache files are cleared. If the currently
2292     * available storage on the device is less than the requested
2293     * free storage, some or all of the cache files across
2294     * all applications are deleted (based on last accessed time)
2295     * to increase the free storage space on the device to
2296     * the requested value. There is no guarantee that clearing all
2297     * the cache files from all applications will clear up
2298     * enough storage to achieve the desired value.
2299     * @param freeStorageSize The number of bytes of storage to be
2300     * freed by the system. Say if freeStorageSize is XX,
2301     * and the current free storage is YY,
2302     * if XX is less than YY, just return. if not free XX-YY number
2303     * of bytes if possible.
2304     * @param pi IntentSender call back used to
2305     * notify when the operation is completed.May be null
2306     * to indicate that no call back is desired.
2307     *
2308     * @hide
2309     */
2310    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
2311
2312    /**
2313     * Retrieve the size information for a package.
2314     * Since this may take a little while, the result will
2315     * be posted back to the given observer.  The calling context
2316     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
2317     *
2318     * @param packageName The name of the package whose size information is to be retrieved
2319     * @param observer An observer callback to get notified when the operation
2320     * is complete.
2321     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
2322     * The observer's callback is invoked with a PackageStats object(containing the
2323     * code, data and cache sizes of the package) and a boolean value representing
2324     * the status of the operation. observer may be null to indicate that
2325     * no callback is desired.
2326     *
2327     * @hide
2328     */
2329    public abstract void getPackageSizeInfo(String packageName,
2330            IPackageStatsObserver observer);
2331
2332    /**
2333     * @deprecated This function no longer does anything; it was an old
2334     * approach to managing preferred activities, which has been superceeded
2335     * (and conflicts with) the modern activity-based preferences.
2336     */
2337    @Deprecated
2338    public abstract void addPackageToPreferred(String packageName);
2339
2340    /**
2341     * @deprecated This function no longer does anything; it was an old
2342     * approach to managing preferred activities, which has been superceeded
2343     * (and conflicts with) the modern activity-based preferences.
2344     */
2345    @Deprecated
2346    public abstract void removePackageFromPreferred(String packageName);
2347
2348    /**
2349     * Retrieve the list of all currently configured preferred packages.  The
2350     * first package on the list is the most preferred, the last is the
2351     * least preferred.
2352     *
2353     * @param flags Additional option flags. Use any combination of
2354     * {@link #GET_ACTIVITIES},
2355     * {@link #GET_GIDS},
2356     * {@link #GET_CONFIGURATIONS},
2357     * {@link #GET_INSTRUMENTATION},
2358     * {@link #GET_PERMISSIONS},
2359     * {@link #GET_PROVIDERS},
2360     * {@link #GET_RECEIVERS},
2361     * {@link #GET_SERVICES},
2362     * {@link #GET_SIGNATURES}, to modify the data returned.
2363     *
2364     * @return Returns a list of PackageInfo objects describing each
2365     * preferred application, in order of preference.
2366     *
2367     * @see #GET_ACTIVITIES
2368     * @see #GET_GIDS
2369     * @see #GET_CONFIGURATIONS
2370     * @see #GET_INSTRUMENTATION
2371     * @see #GET_PERMISSIONS
2372     * @see #GET_PROVIDERS
2373     * @see #GET_RECEIVERS
2374     * @see #GET_SERVICES
2375     * @see #GET_SIGNATURES
2376     */
2377    public abstract List<PackageInfo> getPreferredPackages(int flags);
2378
2379    /**
2380     * @deprecated This is a protected API that should not have been available
2381     * to third party applications.  It is the platform's responsibility for
2382     * assigning preferred activities and this can not be directly modified.
2383     *
2384     * Add a new preferred activity mapping to the system.  This will be used
2385     * to automatically select the given activity component when
2386     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2387     * multiple matching activities and also matches the given filter.
2388     *
2389     * @param filter The set of intents under which this activity will be
2390     * made preferred.
2391     * @param match The IntentFilter match category that this preference
2392     * applies to.
2393     * @param set The set of activities that the user was picking from when
2394     * this preference was made.
2395     * @param activity The component name of the activity that is to be
2396     * preferred.
2397     */
2398    @Deprecated
2399    public abstract void addPreferredActivity(IntentFilter filter, int match,
2400            ComponentName[] set, ComponentName activity);
2401
2402    /**
2403     * @deprecated This is a protected API that should not have been available
2404     * to third party applications.  It is the platform's responsibility for
2405     * assigning preferred activities and this can not be directly modified.
2406     *
2407     * Replaces an existing preferred activity mapping to the system, and if that were not present
2408     * adds a new preferred activity.  This will be used
2409     * to automatically select the given activity component when
2410     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2411     * multiple matching activities and also matches the given filter.
2412     *
2413     * @param filter The set of intents under which this activity will be
2414     * made preferred.
2415     * @param match The IntentFilter match category that this preference
2416     * applies to.
2417     * @param set The set of activities that the user was picking from when
2418     * this preference was made.
2419     * @param activity The component name of the activity that is to be
2420     * preferred.
2421     * @hide
2422     */
2423    @Deprecated
2424    public abstract void replacePreferredActivity(IntentFilter filter, int match,
2425            ComponentName[] set, ComponentName activity);
2426
2427    /**
2428     * Remove all preferred activity mappings, previously added with
2429     * {@link #addPreferredActivity}, from the
2430     * system whose activities are implemented in the given package name.
2431     * An application can only clear its own package(s).
2432     *
2433     * @param packageName The name of the package whose preferred activity
2434     * mappings are to be removed.
2435     */
2436    public abstract void clearPackagePreferredActivities(String packageName);
2437
2438    /**
2439     * Retrieve all preferred activities, previously added with
2440     * {@link #addPreferredActivity}, that are
2441     * currently registered with the system.
2442     *
2443     * @param outFilters A list in which to place the filters of all of the
2444     * preferred activities, or null for none.
2445     * @param outActivities A list in which to place the component names of
2446     * all of the preferred activities, or null for none.
2447     * @param packageName An option package in which you would like to limit
2448     * the list.  If null, all activities will be returned; if non-null, only
2449     * those activities in the given package are returned.
2450     *
2451     * @return Returns the total number of registered preferred activities
2452     * (the number of distinct IntentFilter records, not the number of unique
2453     * activity components) that were found.
2454     */
2455    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
2456            List<ComponentName> outActivities, String packageName);
2457
2458    /**
2459     * Set the enabled setting for a package component (activity, receiver, service, provider).
2460     * This setting will override any enabled state which may have been set by the component in its
2461     * manifest.
2462     *
2463     * @param componentName The component to enable
2464     * @param newState The new enabled state for the component.  The legal values for this state
2465     *                 are:
2466     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2467     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2468     *                   and
2469     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2470     *                 The last one removes the setting, thereby restoring the component's state to
2471     *                 whatever was set in it's manifest (or enabled, by default).
2472     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2473     */
2474    public abstract void setComponentEnabledSetting(ComponentName componentName,
2475            int newState, int flags);
2476
2477
2478    /**
2479     * Return the the enabled setting for a package component (activity,
2480     * receiver, service, provider).  This returns the last value set by
2481     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
2482     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2483     * the value originally specified in the manifest has not been modified.
2484     *
2485     * @param componentName The component to retrieve.
2486     * @return Returns the current enabled state for the component.  May
2487     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2488     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2489     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2490     * component's enabled state is based on the original information in
2491     * the manifest as found in {@link ComponentInfo}.
2492     */
2493    public abstract int getComponentEnabledSetting(ComponentName componentName);
2494
2495    /**
2496     * Set the enabled setting for an application
2497     * This setting will override any enabled state which may have been set by the application in
2498     * its manifest.  It also overrides the enabled state set in the manifest for any of the
2499     * application's components.  It does not override any enabled state set by
2500     * {@link #setComponentEnabledSetting} for any of the application's components.
2501     *
2502     * @param packageName The package name of the application to enable
2503     * @param newState The new enabled state for the component.  The legal values for this state
2504     *                 are:
2505     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2506     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2507     *                   and
2508     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2509     *                 The last one removes the setting, thereby restoring the applications's state to
2510     *                 whatever was set in its manifest (or enabled, by default).
2511     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2512     */
2513    public abstract void setApplicationEnabledSetting(String packageName,
2514            int newState, int flags);
2515
2516    /**
2517     * Return the the enabled setting for an application.  This returns
2518     * the last value set by
2519     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
2520     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2521     * the value originally specified in the manifest has not been modified.
2522     *
2523     * @param packageName The component to retrieve.
2524     * @return Returns the current enabled state for the component.  May
2525     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2526     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2527     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2528     * application's enabled state is based on the original information in
2529     * the manifest as found in {@link ComponentInfo}.
2530     */
2531    public abstract int getApplicationEnabledSetting(String packageName);
2532
2533    /**
2534     * Return whether the device has been booted into safe mode.
2535     */
2536    public abstract boolean isSafeMode();
2537
2538    /**
2539     * Attempts to move package resources from internal to external media or vice versa.
2540     * Since this may take a little while, the result will
2541     * be posted back to the given observer.   This call may fail if the calling context
2542     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
2543     * named package cannot be found, or if the named package is a "system package".
2544     *
2545     * @param packageName The name of the package to delete
2546     * @param observer An observer callback to get notified when the package move is
2547     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
2548     * called when that happens.  observer may be null to indicate that no callback is desired.
2549     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
2550     * {@link #MOVE_EXTERNAL_MEDIA}
2551     *
2552     * @hide
2553     */
2554    public abstract void movePackage(
2555            String packageName, IPackageMoveObserver observer, int flags);
2556
2557    /**
2558     * Creates a user with the specified name and options.
2559     *
2560     * @param name the user's name
2561     * @param flags flags that identify the type of user and other properties.
2562     * @see UserInfo
2563     *
2564     * @return the UserInfo object for the created user, or null if the user could not be created.
2565     * @hide
2566     */
2567    public abstract UserInfo createUser(String name, int flags);
2568
2569    /**
2570     * @return the list of users that were created
2571     * @hide
2572     */
2573    public abstract List<UserInfo> getUsers();
2574
2575    /**
2576     * @param id the ID of the user, where 0 is the primary user.
2577     * @hide
2578     */
2579    public abstract boolean removeUser(int id);
2580
2581    /**
2582     * Updates the user's name.
2583     *
2584     * @param id the user's id
2585     * @param name the new name for the user
2586     * @hide
2587     */
2588    public abstract void updateUserName(int id, String name);
2589
2590    /**
2591     * Changes the user's properties specified by the flags.
2592     *
2593     * @param id the user's id
2594     * @param flags the new flags for the user
2595     * @hide
2596     */
2597    public abstract void updateUserFlags(int id, int flags);
2598
2599    /**
2600     * Checks to see if the user id is the same for the two uids, i.e., they belong to the same
2601     * user.
2602     * @hide
2603     */
2604    public static boolean isSameUser(int uid1, int uid2) {
2605        return getUserId(uid1) == getUserId(uid2);
2606    }
2607
2608    /**
2609     * Returns the user id for a given uid.
2610     * @hide
2611     */
2612    public static int getUserId(int uid) {
2613        return uid / PER_USER_RANGE;
2614    }
2615
2616    /**
2617     * Returns the uid that is composed from the userId and the appId.
2618     * @hide
2619     */
2620    public static int getUid(int userId, int appId) {
2621        return userId * PER_USER_RANGE + (appId % PER_USER_RANGE);
2622    }
2623
2624    /**
2625     * Returns the app id (or base uid) for a given uid, stripping out the user id from it.
2626     * @hide
2627     */
2628    public static int getAppId(int uid) {
2629        return uid % PER_USER_RANGE;
2630    }
2631
2632    /**
2633     * Returns the device identity that verifiers can use to associate their
2634     * scheme to a particular device. This should not be used by anything other
2635     * than a package verifier.
2636     *
2637     * @return identity that uniquely identifies current device
2638     * @hide
2639     */
2640    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
2641}
2642