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