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