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