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