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