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