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