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