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