PackageManager.java revision 7f7b0c759e2970178ef68805b21f06a26e24eb76
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     * Return code that is passed to the {@link IPackageMoveObserver} by
845     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
846     * package has been successfully moved by the system.
847     *
848     * @hide
849     */
850    public static final int MOVE_SUCCEEDED = 1;
851    /**
852     * Error code that is passed to the {@link IPackageMoveObserver} by
853     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
854     * when the package hasn't been successfully moved by the system
855     * because of insufficient memory on specified media.
856     * @hide
857     */
858    public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
859
860    /**
861     * Error code that is passed to the {@link IPackageMoveObserver} by
862     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
863     * if the specified package doesn't exist.
864     * @hide
865     */
866    public static final int MOVE_FAILED_DOESNT_EXIST = -2;
867
868    /**
869     * Error code that is passed to the {@link IPackageMoveObserver} by
870     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
871     * if the specified package cannot be moved since its a system package.
872     * @hide
873     */
874    public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
875
876    /**
877     * Error code that is passed to the {@link IPackageMoveObserver} by
878     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
879     * if the specified package cannot be moved since its forward locked.
880     * @hide
881     */
882    public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
883
884    /**
885     * Error code that is passed to the {@link IPackageMoveObserver} by
886     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
887     * if the specified package cannot be moved to the specified location.
888     * @hide
889     */
890    public static final int MOVE_FAILED_INVALID_LOCATION = -5;
891
892    /**
893     * Error code that is passed to the {@link IPackageMoveObserver} by
894     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
895     * if the specified package cannot be moved to the specified location.
896     * @hide
897     */
898    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
899
900    /**
901     * Error code that is passed to the {@link IPackageMoveObserver} by
902     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
903     * specified package already has an operation pending in the
904     * {@link PackageHandler} queue.
905     *
906     * @hide
907     */
908    public static final int MOVE_FAILED_OPERATION_PENDING = -7;
909
910    /**
911     * Flag parameter for {@link #movePackage} to indicate that
912     * the package should be moved to internal storage if its
913     * been installed on external media.
914     * @hide
915     */
916    public static final int MOVE_INTERNAL = 0x00000001;
917
918    /**
919     * Flag parameter for {@link #movePackage} to indicate that
920     * the package should be moved to external media.
921     * @hide
922     */
923    public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
924
925    /**
926     * Usable by the required verifier as the {@code verificationCode} argument
927     * for {@link PackageManager#verifyPendingInstall} to indicate that it will
928     * allow the installation to proceed without any of the optional verifiers
929     * needing to vote.
930     *
931     * @hide
932     */
933    public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
934
935    /**
936     * Used as the {@code verificationCode} argument for
937     * {@link PackageManager#verifyPendingInstall} to indicate that the calling
938     * package verifier allows the installation to proceed.
939     */
940    public static final int VERIFICATION_ALLOW = 1;
941
942    /**
943     * Used as the {@code verificationCode} argument for
944     * {@link PackageManager#verifyPendingInstall} to indicate the calling
945     * package verifier does not vote to allow the installation to proceed.
946     */
947    public static final int VERIFICATION_REJECT = -1;
948
949    /**
950     * Can be used as the {@code millisecondsToDelay} argument for
951     * {@link PackageManager#extendVerificationTimeout}. This is the
952     * maximum time {@code PackageManager} waits for the verification
953     * agent to return (in milliseconds).
954     */
955    public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
956
957    /**
958     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
959     * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
960     * lag in sound input or output.
961     */
962    @SdkConstant(SdkConstantType.FEATURE)
963    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
964
965    /**
966     * Feature for {@link #getSystemAvailableFeatures} and
967     * {@link #hasSystemFeature}: The device is capable of communicating with
968     * other devices via Bluetooth.
969     */
970    @SdkConstant(SdkConstantType.FEATURE)
971    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
972
973    /**
974     * Feature for {@link #getSystemAvailableFeatures} and
975     * {@link #hasSystemFeature}: The device is capable of communicating with
976     * other devices via Bluetooth Low Energy radio.
977     */
978    @SdkConstant(SdkConstantType.FEATURE)
979    public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
980
981    /**
982     * Feature for {@link #getSystemAvailableFeatures} and
983     * {@link #hasSystemFeature}: The device has a camera facing away
984     * from the screen.
985     */
986    @SdkConstant(SdkConstantType.FEATURE)
987    public static final String FEATURE_CAMERA = "android.hardware.camera";
988
989    /**
990     * Feature for {@link #getSystemAvailableFeatures} and
991     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
992     */
993    @SdkConstant(SdkConstantType.FEATURE)
994    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
995
996    /**
997     * Feature for {@link #getSystemAvailableFeatures} and
998     * {@link #hasSystemFeature}: The device has at least one camera pointing in
999     * some direction, or can support an external camera being connected to it.
1000     */
1001    @SdkConstant(SdkConstantType.FEATURE)
1002    public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1003
1004    /**
1005     * Feature for {@link #getSystemAvailableFeatures} and
1006     * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1007     * The external camera may not always be connected or available to applications to use.
1008     */
1009    @SdkConstant(SdkConstantType.FEATURE)
1010    public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1011
1012    /**
1013     * Feature for {@link #getSystemAvailableFeatures} and
1014     * {@link #hasSystemFeature}: The device's camera supports flash.
1015     */
1016    @SdkConstant(SdkConstantType.FEATURE)
1017    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1018
1019    /**
1020     * Feature for {@link #getSystemAvailableFeatures} and
1021     * {@link #hasSystemFeature}: The device has a front facing camera.
1022     */
1023    @SdkConstant(SdkConstantType.FEATURE)
1024    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1025
1026    /**
1027     * Feature for {@link #getSystemAvailableFeatures} and
1028     * {@link #hasSystemFeature}: The device is capable of communicating with
1029     * consumer IR devices.
1030     */
1031    @SdkConstant(SdkConstantType.FEATURE)
1032    public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1033
1034    /**
1035     * Feature for {@link #getSystemAvailableFeatures} and
1036     * {@link #hasSystemFeature}: The device supports one or more methods of
1037     * reporting current location.
1038     */
1039    @SdkConstant(SdkConstantType.FEATURE)
1040    public static final String FEATURE_LOCATION = "android.hardware.location";
1041
1042    /**
1043     * Feature for {@link #getSystemAvailableFeatures} and
1044     * {@link #hasSystemFeature}: The device has a Global Positioning System
1045     * receiver and can report precise location.
1046     */
1047    @SdkConstant(SdkConstantType.FEATURE)
1048    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1049
1050    /**
1051     * Feature for {@link #getSystemAvailableFeatures} and
1052     * {@link #hasSystemFeature}: The device can report location with coarse
1053     * accuracy using a network-based geolocation system.
1054     */
1055    @SdkConstant(SdkConstantType.FEATURE)
1056    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1057
1058    /**
1059     * Feature for {@link #getSystemAvailableFeatures} and
1060     * {@link #hasSystemFeature}: The device can record audio via a
1061     * microphone.
1062     */
1063    @SdkConstant(SdkConstantType.FEATURE)
1064    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1065
1066    /**
1067     * Feature for {@link #getSystemAvailableFeatures} and
1068     * {@link #hasSystemFeature}: The device can communicate using Near-Field
1069     * Communications (NFC).
1070     */
1071    @SdkConstant(SdkConstantType.FEATURE)
1072    public static final String FEATURE_NFC = "android.hardware.nfc";
1073
1074    /**
1075     * Feature for {@link #getSystemAvailableFeatures} and
1076     * {@link #hasSystemFeature}: The device supports host-
1077     * based NFC card emulation.
1078     *
1079     * TODO remove when depending apps have moved to new constant.
1080     * @hide
1081     * @deprecated
1082     */
1083    @Deprecated
1084    @SdkConstant(SdkConstantType.FEATURE)
1085    public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1086
1087    /**
1088     * Feature for {@link #getSystemAvailableFeatures} and
1089     * {@link #hasSystemFeature}: The device supports host-
1090     * based NFC card emulation.
1091     */
1092    @SdkConstant(SdkConstantType.FEATURE)
1093    public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1094
1095    /**
1096     * Feature for {@link #getSystemAvailableFeatures} and
1097     * {@link #hasSystemFeature}: The device includes an accelerometer.
1098     */
1099    @SdkConstant(SdkConstantType.FEATURE)
1100    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1101
1102    /**
1103     * Feature for {@link #getSystemAvailableFeatures} and
1104     * {@link #hasSystemFeature}: The device includes a barometer (air
1105     * pressure sensor.)
1106     */
1107    @SdkConstant(SdkConstantType.FEATURE)
1108    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1109
1110    /**
1111     * Feature for {@link #getSystemAvailableFeatures} and
1112     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1113     */
1114    @SdkConstant(SdkConstantType.FEATURE)
1115    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1116
1117    /**
1118     * Feature for {@link #getSystemAvailableFeatures} and
1119     * {@link #hasSystemFeature}: The device includes a gyroscope.
1120     */
1121    @SdkConstant(SdkConstantType.FEATURE)
1122    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1123
1124    /**
1125     * Feature for {@link #getSystemAvailableFeatures} and
1126     * {@link #hasSystemFeature}: The device includes a light sensor.
1127     */
1128    @SdkConstant(SdkConstantType.FEATURE)
1129    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1130
1131    /**
1132     * Feature for {@link #getSystemAvailableFeatures} and
1133     * {@link #hasSystemFeature}: The device includes a proximity sensor.
1134     */
1135    @SdkConstant(SdkConstantType.FEATURE)
1136    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1137
1138    /**
1139     * Feature for {@link #getSystemAvailableFeatures} and
1140     * {@link #hasSystemFeature}: The device includes a hardware step counter.
1141     */
1142    @SdkConstant(SdkConstantType.FEATURE)
1143    public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1144
1145    /**
1146     * Feature for {@link #getSystemAvailableFeatures} and
1147     * {@link #hasSystemFeature}: The device includes a hardware step detector.
1148     */
1149    @SdkConstant(SdkConstantType.FEATURE)
1150    public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1151
1152    /**
1153     * Feature for {@link #getSystemAvailableFeatures} and
1154     * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1155     */
1156    @SdkConstant(SdkConstantType.FEATURE)
1157    public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1158
1159    /**
1160     * Feature for {@link #getSystemAvailableFeatures} and
1161     * {@link #hasSystemFeature}: The device has a telephony radio with data
1162     * communication support.
1163     */
1164    @SdkConstant(SdkConstantType.FEATURE)
1165    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1166
1167    /**
1168     * Feature for {@link #getSystemAvailableFeatures} and
1169     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1170     */
1171    @SdkConstant(SdkConstantType.FEATURE)
1172    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1173
1174    /**
1175     * Feature for {@link #getSystemAvailableFeatures} and
1176     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1177     */
1178    @SdkConstant(SdkConstantType.FEATURE)
1179    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1180
1181    /**
1182     * Feature for {@link #getSystemAvailableFeatures} and
1183     * {@link #hasSystemFeature}: The device supports connecting to USB devices
1184     * as the USB host.
1185     */
1186    @SdkConstant(SdkConstantType.FEATURE)
1187    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1188
1189    /**
1190     * Feature for {@link #getSystemAvailableFeatures} and
1191     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1192     */
1193    @SdkConstant(SdkConstantType.FEATURE)
1194    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1195
1196    /**
1197     * Feature for {@link #getSystemAvailableFeatures} and
1198     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1199     */
1200    @SdkConstant(SdkConstantType.FEATURE)
1201    public static final String FEATURE_SIP = "android.software.sip";
1202
1203    /**
1204     * Feature for {@link #getSystemAvailableFeatures} and
1205     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1206     */
1207    @SdkConstant(SdkConstantType.FEATURE)
1208    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1209
1210    /**
1211     * Feature for {@link #getSystemAvailableFeatures} and
1212     * {@link #hasSystemFeature}: The device's display has a touch screen.
1213     */
1214    @SdkConstant(SdkConstantType.FEATURE)
1215    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1216
1217
1218    /**
1219     * Feature for {@link #getSystemAvailableFeatures} and
1220     * {@link #hasSystemFeature}: The device's touch screen supports
1221     * multitouch sufficient for basic two-finger gesture detection.
1222     */
1223    @SdkConstant(SdkConstantType.FEATURE)
1224    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1225
1226    /**
1227     * Feature for {@link #getSystemAvailableFeatures} and
1228     * {@link #hasSystemFeature}: The device's touch screen is capable of
1229     * tracking two or more fingers fully independently.
1230     */
1231    @SdkConstant(SdkConstantType.FEATURE)
1232    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1233
1234    /**
1235     * Feature for {@link #getSystemAvailableFeatures} and
1236     * {@link #hasSystemFeature}: The device's touch screen is capable of
1237     * tracking a full hand of fingers fully independently -- that is, 5 or
1238     * more simultaneous independent pointers.
1239     */
1240    @SdkConstant(SdkConstantType.FEATURE)
1241    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1242
1243    /**
1244     * Feature for {@link #getSystemAvailableFeatures} and
1245     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1246     * does support touch emulation for basic events. For instance, the
1247     * device might use a mouse or remote control to drive a cursor, and
1248     * emulate basic touch pointer events like down, up, drag, etc. All
1249     * devices that support android.hardware.touchscreen or a sub-feature are
1250     * presumed to also support faketouch.
1251     */
1252    @SdkConstant(SdkConstantType.FEATURE)
1253    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1254
1255    /**
1256     * Feature for {@link #getSystemAvailableFeatures} and
1257     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1258     * does support touch emulation for basic events that supports distinct
1259     * tracking of two or more fingers.  This is an extension of
1260     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1261     * that unlike a distinct multitouch screen as defined by
1262     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1263     * devices will not actually provide full two-finger gestures since the
1264     * input is being transformed to cursor movement on the screen.  That is,
1265     * single finger gestures will move a cursor; two-finger swipes will
1266     * result in single-finger touch events; other two-finger gestures will
1267     * result in the corresponding two-finger touch event.
1268     */
1269    @SdkConstant(SdkConstantType.FEATURE)
1270    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1271
1272    /**
1273     * Feature for {@link #getSystemAvailableFeatures} and
1274     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1275     * does support touch emulation for basic events that supports tracking
1276     * a hand of fingers (5 or more fingers) fully independently.
1277     * This is an extension of
1278     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1279     * that unlike a multitouch screen as defined by
1280     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1281     * gestures can be detected due to the limitations described for
1282     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1283     */
1284    @SdkConstant(SdkConstantType.FEATURE)
1285    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1286
1287    /**
1288     * Feature for {@link #getSystemAvailableFeatures} and
1289     * {@link #hasSystemFeature}: The device supports portrait orientation
1290     * screens.  For backwards compatibility, you can assume that if neither
1291     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1292     * both portrait and landscape.
1293     */
1294    @SdkConstant(SdkConstantType.FEATURE)
1295    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1296
1297    /**
1298     * Feature for {@link #getSystemAvailableFeatures} and
1299     * {@link #hasSystemFeature}: The device supports landscape orientation
1300     * screens.  For backwards compatibility, you can assume that if neither
1301     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1302     * both portrait and landscape.
1303     */
1304    @SdkConstant(SdkConstantType.FEATURE)
1305    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1306
1307    /**
1308     * Feature for {@link #getSystemAvailableFeatures} and
1309     * {@link #hasSystemFeature}: The device supports live wallpapers.
1310     */
1311    @SdkConstant(SdkConstantType.FEATURE)
1312    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1313    /**
1314     * Feature for {@link #getSystemAvailableFeatures} and
1315     * {@link #hasSystemFeature}: The device supports app widgets.
1316     */
1317    @SdkConstant(SdkConstantType.FEATURE)
1318    public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1319
1320    /**
1321     * @hide
1322     * Feature for {@link #getSystemAvailableFeatures} and
1323     * {@link #hasSystemFeature}: The device supports
1324     * {@link android.service.voice.VoiceInteractionService} and
1325     * {@link android.app.VoiceInteractor}.
1326     */
1327    @SdkConstant(SdkConstantType.FEATURE)
1328    public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1329
1330
1331    /**
1332     * Feature for {@link #getSystemAvailableFeatures} and
1333     * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1334     * by third party applications.
1335     */
1336    @SdkConstant(SdkConstantType.FEATURE)
1337    public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1338
1339    /**
1340     * Feature for {@link #getSystemAvailableFeatures} and
1341     * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1342     * with the {@link android.inputmethodservice.InputMethodService} API.
1343     */
1344    @SdkConstant(SdkConstantType.FEATURE)
1345    public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1346
1347    /**
1348     * Feature for {@link #getSystemAvailableFeatures} and
1349     * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1350     */
1351    @SdkConstant(SdkConstantType.FEATURE)
1352    public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1353
1354    /**
1355     * Feature for {@link #getSystemAvailableFeatures} and
1356     * {@link #hasSystemFeature}: The device supports leanback UI. This is
1357     * typically used in a living room television experience, but is a software
1358     * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
1359     * feature will use resources associated with the "television" UI mode.
1360     */
1361    @SdkConstant(SdkConstantType.FEATURE)
1362    public static final String FEATURE_LEANBACK = "android.software.leanback";
1363
1364    /**
1365     * Feature for {@link #getSystemAvailableFeatures} and
1366     * {@link #hasSystemFeature}: The device supports only leanback UI. Only
1367     * applications designed for this experience should be run, though this is
1368     * not enforced by the system.
1369     * @hide
1370     */
1371    @SdkConstant(SdkConstantType.FEATURE)
1372    public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
1373
1374    /**
1375     * Feature for {@link #getSystemAvailableFeatures} and
1376     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1377     */
1378    @SdkConstant(SdkConstantType.FEATURE)
1379    public static final String FEATURE_WIFI = "android.hardware.wifi";
1380
1381    /**
1382     * Feature for {@link #getSystemAvailableFeatures} and
1383     * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1384     */
1385    @SdkConstant(SdkConstantType.FEATURE)
1386    public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1387
1388    /**
1389     * Feature for {@link #getSystemAvailableFeatures} and
1390     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1391     * on a television.  Television here is defined to be a typical living
1392     * room television experience: displayed on a big screen, where the user
1393     * is sitting far away from it, and the dominant form of input will be
1394     * something like a DPAD, not through touch or mouse.
1395     * @deprecated use {@link #FEATURE_LEANBACK} instead.
1396     */
1397    @Deprecated
1398    @SdkConstant(SdkConstantType.FEATURE)
1399    public static final String FEATURE_TELEVISION = "android.hardware.type.television";
1400
1401    /**
1402     * Feature for {@link #getSystemAvailableFeatures} and
1403     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1404     * on a watch. A watch here is defined to be a device worn on the body, perhaps on
1405     * the wrist. The user is very close when interacting with the device.
1406     */
1407    @SdkConstant(SdkConstantType.FEATURE)
1408    public static final String FEATURE_WATCH = "android.hardware.type.watch";
1409
1410    /**
1411     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1412     * The device supports printing.
1413     */
1414    @SdkConstant(SdkConstantType.FEATURE)
1415    public static final String FEATURE_PRINTING = "android.software.print";
1416
1417    /**
1418     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1419     * The device can perform backup and restore operations on installed applications.
1420     */
1421    @SdkConstant(SdkConstantType.FEATURE)
1422    public static final String FEATURE_BACKUP = "android.software.backup";
1423
1424    /**
1425     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1426     * The device supports managed profiles for enterprise users.
1427     */
1428    @SdkConstant(SdkConstantType.FEATURE)
1429    public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_profiles";
1430
1431    /**
1432     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1433     * The device has a full implementation of the android.webkit.* APIs. Devices
1434     * lacking this feature will not have a functioning WebView implementation.
1435     */
1436    @SdkConstant(SdkConstantType.FEATURE)
1437    public static final String FEATURE_WEBVIEW = "android.software.webview";
1438
1439    /**
1440     * Action to external storage service to clean out removed apps.
1441     * @hide
1442     */
1443    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1444            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1445
1446    /**
1447     * Extra field name for the URI to a verification file. Passed to a package
1448     * verifier.
1449     *
1450     * @hide
1451     */
1452    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1453
1454    /**
1455     * Extra field name for the ID of a package pending verification. Passed to
1456     * a package verifier and is used to call back to
1457     * {@link PackageManager#verifyPendingInstall(int, int)}
1458     */
1459    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1460
1461    /**
1462     * Extra field name for the package identifier which is trying to install
1463     * the package.
1464     *
1465     * @hide
1466     */
1467    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1468            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1469
1470    /**
1471     * Extra field name for the requested install flags for a package pending
1472     * verification. Passed to a package verifier.
1473     *
1474     * @hide
1475     */
1476    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1477            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1478
1479    /**
1480     * Extra field name for the uid of who is requesting to install
1481     * the package.
1482     *
1483     * @hide
1484     */
1485    public static final String EXTRA_VERIFICATION_INSTALLER_UID
1486            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1487
1488    /**
1489     * Extra field name for the package name of a package pending verification.
1490     *
1491     * @hide
1492     */
1493    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1494            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1495    /**
1496     * Extra field name for the result of a verification, either
1497     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1498     * Passed to package verifiers after a package is verified.
1499     */
1500    public static final String EXTRA_VERIFICATION_RESULT
1501            = "android.content.pm.extra.VERIFICATION_RESULT";
1502
1503    /**
1504     * Extra field name for the version code of a package pending verification.
1505     *
1506     * @hide
1507     */
1508    public static final String EXTRA_VERIFICATION_VERSION_CODE
1509            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1510
1511    /**
1512     * The action used to request that the user approve a permission request
1513     * from the application.
1514     *
1515     * @hide
1516     */
1517    public static final String ACTION_REQUEST_PERMISSION
1518            = "android.content.pm.action.REQUEST_PERMISSION";
1519
1520    /**
1521     * Extra field name for the list of permissions, which the user must approve.
1522     *
1523     * @hide
1524     */
1525    public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST
1526            = "android.content.pm.extra.PERMISSION_LIST";
1527
1528    /**
1529     * String extra for {@link IPackageInstallObserver2} in the 'extras' Bundle in case of
1530     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
1531     * the existing definition for the permission.
1532     * @hide
1533     */
1534    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1535            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1536
1537    /**
1538     * String extra for {@link IPackageInstallObserver2} in the 'extras' Bundle in case of
1539     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
1540     * being redundantly defined by the package being installed.
1541     * @hide
1542     */
1543    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1544            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1545
1546    /**
1547     * Retrieve overall information about an application package that is
1548     * installed on the system.
1549     * <p>
1550     * Throws {@link NameNotFoundException} if a package with the given name can
1551     * not be found on the system.
1552     *
1553     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1554     *            desired package.
1555     * @param flags Additional option flags. Use any combination of
1556     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
1557     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
1558     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
1559     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
1560     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
1561     *            modify the data returned.
1562     * @return Returns a PackageInfo object containing information about the
1563     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
1564     *         package is not found in the list of installed applications, the
1565     *         package information is retrieved from the list of uninstalled
1566     *         applications (which includes installed applications as well as
1567     *         applications with data directory i.e. applications which had been
1568     *         deleted with {@code DONT_DELETE_DATA} flag set).
1569     * @see #GET_ACTIVITIES
1570     * @see #GET_GIDS
1571     * @see #GET_CONFIGURATIONS
1572     * @see #GET_INSTRUMENTATION
1573     * @see #GET_PERMISSIONS
1574     * @see #GET_PROVIDERS
1575     * @see #GET_RECEIVERS
1576     * @see #GET_SERVICES
1577     * @see #GET_SIGNATURES
1578     * @see #GET_UNINSTALLED_PACKAGES
1579     */
1580    public abstract PackageInfo getPackageInfo(String packageName, int flags)
1581            throws NameNotFoundException;
1582
1583    /**
1584     * Map from the current package names in use on the device to whatever
1585     * the current canonical name of that package is.
1586     * @param names Array of current names to be mapped.
1587     * @return Returns an array of the same size as the original, containing
1588     * the canonical name for each package.
1589     */
1590    public abstract String[] currentToCanonicalPackageNames(String[] names);
1591
1592    /**
1593     * Map from a packages canonical name to the current name in use on the device.
1594     * @param names Array of new names to be mapped.
1595     * @return Returns an array of the same size as the original, containing
1596     * the current name for each package.
1597     */
1598    public abstract String[] canonicalToCurrentPackageNames(String[] names);
1599
1600    /**
1601     * Return a "good" intent to launch a front-door activity in a package,
1602     * for use for example to implement an "open" button when browsing through
1603     * packages.  The current implementation will look first for a main
1604     * activity in the category {@link Intent#CATEGORY_INFO}, next for a
1605     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
1606     * null if neither are found.
1607     *
1608     * <p>Throws {@link NameNotFoundException} if a package with the given
1609     * name cannot be found on the system.
1610     *
1611     * @param packageName The name of the package to inspect.
1612     *
1613     * @return Returns either a fully-qualified Intent that can be used to
1614     * launch the main activity in the package, or null if the package does
1615     * not contain such an activity.
1616     */
1617    public abstract Intent getLaunchIntentForPackage(String packageName);
1618
1619    /**
1620     * Return a "good" intent to launch a front-door Leanback activity in a
1621     * package, for use for example to implement an "open" button when browsing
1622     * through packages. The current implementation will look for a main
1623     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
1624     * return null if no main leanback activities are found.
1625     * <p>
1626     * Throws {@link NameNotFoundException} if a package with the given name
1627     * cannot be found on the system.
1628     *
1629     * @param packageName The name of the package to inspect.
1630     * @return Returns either a fully-qualified Intent that can be used to launch
1631     *         the main Leanback activity in the package, or null if the package
1632     *         does not contain such an activity.
1633     */
1634    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
1635
1636    /**
1637     * Return an array of all of the secondary group-ids that have been assigned
1638     * to a package.
1639     * <p>
1640     * Throws {@link NameNotFoundException} if a package with the given name
1641     * cannot be found on the system.
1642     *
1643     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1644     *            desired package.
1645     * @return Returns an int array of the assigned gids, or null if there are
1646     *         none.
1647     */
1648    public abstract int[] getPackageGids(String packageName)
1649            throws NameNotFoundException;
1650
1651    /**
1652     * @hide Return the uid associated with the given package name for the
1653     * given user.
1654     *
1655     * <p>Throws {@link NameNotFoundException} if a package with the given
1656     * name can not be found on the system.
1657     *
1658     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1659     *                    desired package.
1660     * @param userHandle The user handle identifier to look up the package under.
1661     *
1662     * @return Returns an integer uid who owns the given package name.
1663     */
1664    public abstract int getPackageUid(String packageName, int userHandle)
1665            throws NameNotFoundException;
1666
1667    /**
1668     * Retrieve all of the information we know about a particular permission.
1669     *
1670     * <p>Throws {@link NameNotFoundException} if a permission with the given
1671     * name cannot be found on the system.
1672     *
1673     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1674     *             of the permission you are interested in.
1675     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1676     * retrieve any meta-data associated with the permission.
1677     *
1678     * @return Returns a {@link PermissionInfo} containing information about the
1679     *         permission.
1680     */
1681    public abstract PermissionInfo getPermissionInfo(String name, int flags)
1682            throws NameNotFoundException;
1683
1684    /**
1685     * Query for all of the permissions associated with a particular group.
1686     *
1687     * <p>Throws {@link NameNotFoundException} if the given group does not
1688     * exist.
1689     *
1690     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1691     *             of the permission group you are interested in.  Use null to
1692     *             find all of the permissions not associated with a group.
1693     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1694     * retrieve any meta-data associated with the permissions.
1695     *
1696     * @return Returns a list of {@link PermissionInfo} containing information
1697     * about all of the permissions in the given group.
1698     */
1699    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1700            int flags) throws NameNotFoundException;
1701
1702    /**
1703     * Retrieve all of the information we know about a particular group of
1704     * permissions.
1705     *
1706     * <p>Throws {@link NameNotFoundException} if a permission group with the given
1707     * name cannot be found on the system.
1708     *
1709     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1710     *             of the permission you are interested in.
1711     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1712     * retrieve any meta-data associated with the permission group.
1713     *
1714     * @return Returns a {@link PermissionGroupInfo} containing information
1715     * about the permission.
1716     */
1717    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1718            int flags) throws NameNotFoundException;
1719
1720    /**
1721     * Retrieve all of the known permission groups in the system.
1722     *
1723     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1724     * retrieve any meta-data associated with the permission group.
1725     *
1726     * @return Returns a list of {@link PermissionGroupInfo} containing
1727     * information about all of the known permission groups.
1728     */
1729    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1730
1731    /**
1732     * Retrieve all of the information we know about a particular
1733     * package/application.
1734     *
1735     * <p>Throws {@link NameNotFoundException} if an application with the given
1736     * package name cannot be found on the system.
1737     *
1738     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1739     *                    application.
1740     * @param flags Additional option flags. Use any combination of
1741     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1742     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1743     *
1744     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1745     *         information about the package.
1746     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1747     *         found in the list of installed applications,
1748     *         the application information is retrieved from the
1749     *         list of uninstalled applications(which includes
1750     *         installed applications as well as applications
1751     *         with data directory ie applications which had been
1752     *         deleted with {@code DONT_DELETE_DATA} flag set).
1753     *
1754     * @see #GET_META_DATA
1755     * @see #GET_SHARED_LIBRARY_FILES
1756     * @see #GET_UNINSTALLED_PACKAGES
1757     */
1758    public abstract ApplicationInfo getApplicationInfo(String packageName,
1759            int flags) throws NameNotFoundException;
1760
1761    /**
1762     * Retrieve all of the information we know about a particular activity
1763     * class.
1764     *
1765     * <p>Throws {@link NameNotFoundException} if an activity with the given
1766     * class name cannot be found on the system.
1767     *
1768     * @param component The full component name (i.e.
1769     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1770     * class.
1771     * @param flags Additional option flags. Use any combination of
1772     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1773     * to modify the data (in ApplicationInfo) returned.
1774     *
1775     * @return {@link ActivityInfo} containing information about the activity.
1776     *
1777     * @see #GET_INTENT_FILTERS
1778     * @see #GET_META_DATA
1779     * @see #GET_SHARED_LIBRARY_FILES
1780     */
1781    public abstract ActivityInfo getActivityInfo(ComponentName component,
1782            int flags) throws NameNotFoundException;
1783
1784    /**
1785     * Retrieve all of the information we know about a particular receiver
1786     * class.
1787     *
1788     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1789     * class name cannot be found on the system.
1790     *
1791     * @param component The full component name (i.e.
1792     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1793     * class.
1794     * @param flags Additional option flags.  Use any combination of
1795     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1796     * to modify the data returned.
1797     *
1798     * @return {@link ActivityInfo} containing information about the receiver.
1799     *
1800     * @see #GET_INTENT_FILTERS
1801     * @see #GET_META_DATA
1802     * @see #GET_SHARED_LIBRARY_FILES
1803     */
1804    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1805            int flags) throws NameNotFoundException;
1806
1807    /**
1808     * Retrieve all of the information we know about a particular service
1809     * class.
1810     *
1811     * <p>Throws {@link NameNotFoundException} if a service with the given
1812     * class name cannot be found on the system.
1813     *
1814     * @param component The full component name (i.e.
1815     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1816     * class.
1817     * @param flags Additional option flags.  Use any combination of
1818     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1819     * to modify the data returned.
1820     *
1821     * @return ServiceInfo containing information about the service.
1822     *
1823     * @see #GET_META_DATA
1824     * @see #GET_SHARED_LIBRARY_FILES
1825     */
1826    public abstract ServiceInfo getServiceInfo(ComponentName component,
1827            int flags) throws NameNotFoundException;
1828
1829    /**
1830     * Retrieve all of the information we know about a particular content
1831     * provider class.
1832     *
1833     * <p>Throws {@link NameNotFoundException} if a provider with the given
1834     * class name cannot be found on the system.
1835     *
1836     * @param component The full component name (i.e.
1837     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1838     * ContentProvider class.
1839     * @param flags Additional option flags.  Use any combination of
1840     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1841     * to modify the data returned.
1842     *
1843     * @return ProviderInfo containing information about the service.
1844     *
1845     * @see #GET_META_DATA
1846     * @see #GET_SHARED_LIBRARY_FILES
1847     */
1848    public abstract ProviderInfo getProviderInfo(ComponentName component,
1849            int flags) throws NameNotFoundException;
1850
1851    /**
1852     * Return a List of all packages that are installed
1853     * on the device.
1854     *
1855     * @param flags Additional option flags. Use any combination of
1856     * {@link #GET_ACTIVITIES},
1857     * {@link #GET_GIDS},
1858     * {@link #GET_CONFIGURATIONS},
1859     * {@link #GET_INSTRUMENTATION},
1860     * {@link #GET_PERMISSIONS},
1861     * {@link #GET_PROVIDERS},
1862     * {@link #GET_RECEIVERS},
1863     * {@link #GET_SERVICES},
1864     * {@link #GET_SIGNATURES},
1865     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1866     *
1867     * @return A List of PackageInfo objects, one for each package that is
1868     *         installed on the device.  In the unlikely case of there being no
1869     *         installed packages, an empty list is returned.
1870     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1871     *         applications including those deleted with {@code DONT_DELETE_DATA}
1872     *         (partially installed apps with data directory) will be returned.
1873     *
1874     * @see #GET_ACTIVITIES
1875     * @see #GET_GIDS
1876     * @see #GET_CONFIGURATIONS
1877     * @see #GET_INSTRUMENTATION
1878     * @see #GET_PERMISSIONS
1879     * @see #GET_PROVIDERS
1880     * @see #GET_RECEIVERS
1881     * @see #GET_SERVICES
1882     * @see #GET_SIGNATURES
1883     * @see #GET_UNINSTALLED_PACKAGES
1884     */
1885    public abstract List<PackageInfo> getInstalledPackages(int flags);
1886
1887    /**
1888     * Return a List of all installed packages that are currently
1889     * holding any of the given permissions.
1890     *
1891     * @param flags Additional option flags. Use any combination of
1892     * {@link #GET_ACTIVITIES},
1893     * {@link #GET_GIDS},
1894     * {@link #GET_CONFIGURATIONS},
1895     * {@link #GET_INSTRUMENTATION},
1896     * {@link #GET_PERMISSIONS},
1897     * {@link #GET_PROVIDERS},
1898     * {@link #GET_RECEIVERS},
1899     * {@link #GET_SERVICES},
1900     * {@link #GET_SIGNATURES},
1901     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1902     *
1903     * @return Returns a List of PackageInfo objects, one for each installed
1904     * application that is holding any of the permissions that were provided.
1905     *
1906     * @see #GET_ACTIVITIES
1907     * @see #GET_GIDS
1908     * @see #GET_CONFIGURATIONS
1909     * @see #GET_INSTRUMENTATION
1910     * @see #GET_PERMISSIONS
1911     * @see #GET_PROVIDERS
1912     * @see #GET_RECEIVERS
1913     * @see #GET_SERVICES
1914     * @see #GET_SIGNATURES
1915     * @see #GET_UNINSTALLED_PACKAGES
1916     */
1917    public abstract List<PackageInfo> getPackagesHoldingPermissions(
1918            String[] permissions, int flags);
1919
1920    /**
1921     * Return a List of all packages that are installed on the device, for a specific user.
1922     * Requesting a list of installed packages for another user
1923     * will require the permission INTERACT_ACROSS_USERS_FULL.
1924     * @param flags Additional option flags. Use any combination of
1925     * {@link #GET_ACTIVITIES},
1926     * {@link #GET_GIDS},
1927     * {@link #GET_CONFIGURATIONS},
1928     * {@link #GET_INSTRUMENTATION},
1929     * {@link #GET_PERMISSIONS},
1930     * {@link #GET_PROVIDERS},
1931     * {@link #GET_RECEIVERS},
1932     * {@link #GET_SERVICES},
1933     * {@link #GET_SIGNATURES},
1934     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1935     * @param userId The user for whom the installed packages are to be listed
1936     *
1937     * @return A List of PackageInfo objects, one for each package that is
1938     *         installed on the device.  In the unlikely case of there being no
1939     *         installed packages, an empty list is returned.
1940     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1941     *         applications including those deleted with {@code DONT_DELETE_DATA}
1942     *         (partially installed apps with data directory) will be returned.
1943     *
1944     * @see #GET_ACTIVITIES
1945     * @see #GET_GIDS
1946     * @see #GET_CONFIGURATIONS
1947     * @see #GET_INSTRUMENTATION
1948     * @see #GET_PERMISSIONS
1949     * @see #GET_PROVIDERS
1950     * @see #GET_RECEIVERS
1951     * @see #GET_SERVICES
1952     * @see #GET_SIGNATURES
1953     * @see #GET_UNINSTALLED_PACKAGES
1954     *
1955     * @hide
1956     */
1957    public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
1958
1959    /**
1960     * Check whether a particular package has been granted a particular
1961     * permission.
1962     *
1963     * @param permName The name of the permission you are checking for,
1964     * @param pkgName The name of the package you are checking against.
1965     *
1966     * @return If the package has the permission, PERMISSION_GRANTED is
1967     * returned.  If it does not have the permission, PERMISSION_DENIED
1968     * is returned.
1969     *
1970     * @see #PERMISSION_GRANTED
1971     * @see #PERMISSION_DENIED
1972     */
1973    public abstract int checkPermission(String permName, String pkgName);
1974
1975    /**
1976     * Add a new dynamic permission to the system.  For this to work, your
1977     * package must have defined a permission tree through the
1978     * {@link android.R.styleable#AndroidManifestPermissionTree
1979     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
1980     * permissions to trees that were defined by either its own package or
1981     * another with the same user id; a permission is in a tree if it
1982     * matches the name of the permission tree + ".": for example,
1983     * "com.foo.bar" is a member of the permission tree "com.foo".
1984     *
1985     * <p>It is good to make your permission tree name descriptive, because you
1986     * are taking possession of that entire set of permission names.  Thus, it
1987     * must be under a domain you control, with a suffix that will not match
1988     * any normal permissions that may be declared in any applications that
1989     * are part of that domain.
1990     *
1991     * <p>New permissions must be added before
1992     * any .apks are installed that use those permissions.  Permissions you
1993     * add through this method are remembered across reboots of the device.
1994     * If the given permission already exists, the info you supply here
1995     * will be used to update it.
1996     *
1997     * @param info Description of the permission to be added.
1998     *
1999     * @return Returns true if a new permission was created, false if an
2000     * existing one was updated.
2001     *
2002     * @throws SecurityException if you are not allowed to add the
2003     * given permission name.
2004     *
2005     * @see #removePermission(String)
2006     */
2007    public abstract boolean addPermission(PermissionInfo info);
2008
2009    /**
2010     * Like {@link #addPermission(PermissionInfo)} but asynchronously
2011     * persists the package manager state after returning from the call,
2012     * allowing it to return quicker and batch a series of adds at the
2013     * expense of no guarantee the added permission will be retained if
2014     * the device is rebooted before it is written.
2015     */
2016    public abstract boolean addPermissionAsync(PermissionInfo info);
2017
2018    /**
2019     * Removes a permission that was previously added with
2020     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
2021     * -- you are only allowed to remove permissions that you are allowed
2022     * to add.
2023     *
2024     * @param name The name of the permission to remove.
2025     *
2026     * @throws SecurityException if you are not allowed to remove the
2027     * given permission name.
2028     *
2029     * @see #addPermission(PermissionInfo)
2030     */
2031    public abstract void removePermission(String name);
2032
2033    /**
2034     * Returns an {@link Intent} suitable for passing to {@code startActivityForResult}
2035     * which prompts the user to grant {@code permissions} to this application.
2036     * @hide
2037     *
2038     * @throws NullPointerException if {@code permissions} is {@code null}.
2039     * @throws IllegalArgumentException if {@code permissions} contains {@code null}.
2040     */
2041    public Intent buildPermissionRequestIntent(String... permissions) {
2042        if (permissions == null) {
2043            throw new NullPointerException("permissions cannot be null");
2044        }
2045        for (String permission : permissions) {
2046            if (permission == null) {
2047                throw new IllegalArgumentException("permissions cannot contain null");
2048            }
2049        }
2050
2051        Intent i = new Intent(ACTION_REQUEST_PERMISSION);
2052        i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions);
2053        i.setPackage("com.android.packageinstaller");
2054        return i;
2055    }
2056
2057    /**
2058     * Grant a permission to an application which the application does not
2059     * already have.  The permission must have been requested by the application,
2060     * but as an optional permission.  If the application is not allowed to
2061     * hold the permission, a SecurityException is thrown.
2062     * @hide
2063     *
2064     * @param packageName The name of the package that the permission will be
2065     * granted to.
2066     * @param permissionName The name of the permission.
2067     */
2068    public abstract void grantPermission(String packageName, String permissionName);
2069
2070    /**
2071     * Revoke a permission that was previously granted by {@link #grantPermission}.
2072     * @hide
2073     *
2074     * @param packageName The name of the package that the permission will be
2075     * granted to.
2076     * @param permissionName The name of the permission.
2077     */
2078    public abstract void revokePermission(String packageName, String permissionName);
2079
2080    /**
2081     * Compare the signatures of two packages to determine if the same
2082     * signature appears in both of them.  If they do contain the same
2083     * signature, then they are allowed special privileges when working
2084     * with each other: they can share the same user-id, run instrumentation
2085     * against each other, etc.
2086     *
2087     * @param pkg1 First package name whose signature will be compared.
2088     * @param pkg2 Second package name whose signature will be compared.
2089     *
2090     * @return Returns an integer indicating whether all signatures on the
2091     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2092     * all signatures match or < 0 if there is not a match ({@link
2093     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2094     *
2095     * @see #checkSignatures(int, int)
2096     * @see #SIGNATURE_MATCH
2097     * @see #SIGNATURE_NO_MATCH
2098     * @see #SIGNATURE_UNKNOWN_PACKAGE
2099     */
2100    public abstract int checkSignatures(String pkg1, String pkg2);
2101
2102    /**
2103     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2104     * the two packages to be checked.  This can be useful, for example,
2105     * when doing the check in an IPC, where the UID is the only identity
2106     * available.  It is functionally identical to determining the package
2107     * associated with the UIDs and checking their signatures.
2108     *
2109     * @param uid1 First UID whose signature will be compared.
2110     * @param uid2 Second UID whose signature will be compared.
2111     *
2112     * @return Returns an integer indicating whether all signatures on the
2113     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2114     * all signatures match or < 0 if there is not a match ({@link
2115     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2116     *
2117     * @see #checkSignatures(String, String)
2118     * @see #SIGNATURE_MATCH
2119     * @see #SIGNATURE_NO_MATCH
2120     * @see #SIGNATURE_UNKNOWN_PACKAGE
2121     */
2122    public abstract int checkSignatures(int uid1, int uid2);
2123
2124    /**
2125     * Retrieve the names of all packages that are associated with a particular
2126     * user id.  In most cases, this will be a single package name, the package
2127     * that has been assigned that user id.  Where there are multiple packages
2128     * sharing the same user id through the "sharedUserId" mechanism, all
2129     * packages with that id will be returned.
2130     *
2131     * @param uid The user id for which you would like to retrieve the
2132     * associated packages.
2133     *
2134     * @return Returns an array of one or more packages assigned to the user
2135     * id, or null if there are no known packages with the given id.
2136     */
2137    public abstract String[] getPackagesForUid(int uid);
2138
2139    /**
2140     * Retrieve the official name associated with a user id.  This name is
2141     * guaranteed to never change, though it is possibly for the underlying
2142     * user id to be changed.  That is, if you are storing information about
2143     * user ids in persistent storage, you should use the string returned
2144     * by this function instead of the raw user-id.
2145     *
2146     * @param uid The user id for which you would like to retrieve a name.
2147     * @return Returns a unique name for the given user id, or null if the
2148     * user id is not currently assigned.
2149     */
2150    public abstract String getNameForUid(int uid);
2151
2152    /**
2153     * Return the user id associated with a shared user name. Multiple
2154     * applications can specify a shared user name in their manifest and thus
2155     * end up using a common uid. This might be used for new applications
2156     * that use an existing shared user name and need to know the uid of the
2157     * shared user.
2158     *
2159     * @param sharedUserName The shared user name whose uid is to be retrieved.
2160     * @return Returns the uid associated with the shared user, or  NameNotFoundException
2161     * if the shared user name is not being used by any installed packages
2162     * @hide
2163     */
2164    public abstract int getUidForSharedUser(String sharedUserName)
2165            throws NameNotFoundException;
2166
2167    /**
2168     * Return a List of all application packages that are installed on the
2169     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2170     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2171     * installed apps with data directory) will be returned.
2172     *
2173     * @param flags Additional option flags. Use any combination of
2174     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2175     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2176     *
2177     * @return Returns a List of ApplicationInfo objects, one for each application that
2178     *         is installed on the device.  In the unlikely case of there being
2179     *         no installed applications, an empty list is returned.
2180     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2181     *         applications including those deleted with {@code DONT_DELETE_DATA}
2182     *         (partially installed apps with data directory) will be returned.
2183     *
2184     * @see #GET_META_DATA
2185     * @see #GET_SHARED_LIBRARY_FILES
2186     * @see #GET_UNINSTALLED_PACKAGES
2187     */
2188    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2189
2190    /**
2191     * Get a list of shared libraries that are available on the
2192     * system.
2193     *
2194     * @return An array of shared library names that are
2195     * available on the system, or null if none are installed.
2196     *
2197     */
2198    public abstract String[] getSystemSharedLibraryNames();
2199
2200    /**
2201     * Get a list of features that are available on the
2202     * system.
2203     *
2204     * @return An array of FeatureInfo classes describing the features
2205     * that are available on the system, or null if there are none(!!).
2206     */
2207    public abstract FeatureInfo[] getSystemAvailableFeatures();
2208
2209    /**
2210     * Check whether the given feature name is one of the available
2211     * features as returned by {@link #getSystemAvailableFeatures()}.
2212     *
2213     * @return Returns true if the devices supports the feature, else
2214     * false.
2215     */
2216    public abstract boolean hasSystemFeature(String name);
2217
2218    /**
2219     * Determine the best action to perform for a given Intent.  This is how
2220     * {@link Intent#resolveActivity} finds an activity if a class has not
2221     * been explicitly specified.
2222     *
2223     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2224     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2225     * only flag.  You need to do so to resolve the activity in the same way
2226     * that {@link android.content.Context#startActivity(Intent)} and
2227     * {@link android.content.Intent#resolveActivity(PackageManager)
2228     * Intent.resolveActivity(PackageManager)} do.</p>
2229     *
2230     * @param intent An intent containing all of the desired specification
2231     *               (action, data, type, category, and/or component).
2232     * @param flags Additional option flags.  The most important is
2233     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2234     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2235     *
2236     * @return Returns a ResolveInfo containing the final activity intent that
2237     *         was determined to be the best action.  Returns null if no
2238     *         matching activity was found. If multiple matching activities are
2239     *         found and there is no default set, returns a ResolveInfo
2240     *         containing something else, such as the activity resolver.
2241     *
2242     * @see #MATCH_DEFAULT_ONLY
2243     * @see #GET_INTENT_FILTERS
2244     * @see #GET_RESOLVED_FILTER
2245     */
2246    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2247
2248    /**
2249     * Determine the best action to perform for a given Intent for a given user. This
2250     * is how {@link Intent#resolveActivity} finds an activity if a class has not
2251     * been explicitly specified.
2252     *
2253     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2254     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2255     * only flag.  You need to do so to resolve the activity in the same way
2256     * that {@link android.content.Context#startActivity(Intent)} and
2257     * {@link android.content.Intent#resolveActivity(PackageManager)
2258     * Intent.resolveActivity(PackageManager)} do.</p>
2259     *
2260     * @param intent An intent containing all of the desired specification
2261     *               (action, data, type, category, and/or component).
2262     * @param flags Additional option flags.  The most important is
2263     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2264     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2265     * @param userId The user id.
2266     *
2267     * @return Returns a ResolveInfo containing the final activity intent that
2268     *         was determined to be the best action.  Returns null if no
2269     *         matching activity was found. If multiple matching activities are
2270     *         found and there is no default set, returns a ResolveInfo
2271     *         containing something else, such as the activity resolver.
2272     *
2273     * @see #MATCH_DEFAULT_ONLY
2274     * @see #GET_INTENT_FILTERS
2275     * @see #GET_RESOLVED_FILTER
2276     *
2277     * @hide
2278     */
2279    public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2280
2281    /**
2282     * Retrieve all activities that can be performed for the given intent.
2283     *
2284     * @param intent The desired intent as per resolveActivity().
2285     * @param flags Additional option flags.  The most important is
2286     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2287     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2288     *
2289     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2290     *         Activity. These are ordered from best to worst match -- that
2291     *         is, the first item in the list is what is returned by
2292     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2293     *         list is returned.
2294     *
2295     * @see #MATCH_DEFAULT_ONLY
2296     * @see #GET_INTENT_FILTERS
2297     * @see #GET_RESOLVED_FILTER
2298     */
2299    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2300            int flags);
2301
2302    /**
2303     * Retrieve all activities that can be performed for the given intent, for a specific user.
2304     *
2305     * @param intent The desired intent as per resolveActivity().
2306     * @param flags Additional option flags.  The most important is
2307     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2308     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2309     *
2310     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2311     *         Activity. These are ordered from best to worst match -- that
2312     *         is, the first item in the list is what is returned by
2313     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2314     *         list is returned.
2315     *
2316     * @see #MATCH_DEFAULT_ONLY
2317     * @see #GET_INTENT_FILTERS
2318     * @see #GET_RESOLVED_FILTER
2319     * @see #NO_CROSS_PROFILE
2320     * @hide
2321     */
2322    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2323            int flags, int userId);
2324
2325
2326    /**
2327     * Retrieve a set of activities that should be presented to the user as
2328     * similar options.  This is like {@link #queryIntentActivities}, except it
2329     * also allows you to supply a list of more explicit Intents that you would
2330     * like to resolve to particular options, and takes care of returning the
2331     * final ResolveInfo list in a reasonable order, with no duplicates, based
2332     * on those inputs.
2333     *
2334     * @param caller The class name of the activity that is making the
2335     *               request.  This activity will never appear in the output
2336     *               list.  Can be null.
2337     * @param specifics An array of Intents that should be resolved to the
2338     *                  first specific results.  Can be null.
2339     * @param intent The desired intent as per resolveActivity().
2340     * @param flags Additional option flags.  The most important is
2341     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2342     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2343     *
2344     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2345     *         Activity. These are ordered first by all of the intents resolved
2346     *         in <var>specifics</var> and then any additional activities that
2347     *         can handle <var>intent</var> but did not get included by one of
2348     *         the <var>specifics</var> intents.  If there are no matching
2349     *         activities, an empty list is returned.
2350     *
2351     * @see #MATCH_DEFAULT_ONLY
2352     * @see #GET_INTENT_FILTERS
2353     * @see #GET_RESOLVED_FILTER
2354     */
2355    public abstract List<ResolveInfo> queryIntentActivityOptions(
2356            ComponentName caller, Intent[] specifics, Intent intent, int flags);
2357
2358    /**
2359     * Retrieve all receivers that can handle a broadcast of the given intent.
2360     *
2361     * @param intent The desired intent as per resolveActivity().
2362     * @param flags Additional option flags.
2363     *
2364     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2365     *         Receiver. These are ordered from first to last in priority.  If
2366     *         there are no matching receivers, an empty list is returned.
2367     *
2368     * @see #MATCH_DEFAULT_ONLY
2369     * @see #GET_INTENT_FILTERS
2370     * @see #GET_RESOLVED_FILTER
2371     */
2372    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2373            int flags);
2374
2375    /**
2376     * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
2377     * user.
2378     *
2379     * @param intent The desired intent as per resolveActivity().
2380     * @param flags Additional option flags.
2381     * @param userId The userId of the user being queried.
2382     *
2383     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2384     *         Receiver. These are ordered from first to last in priority.  If
2385     *         there are no matching receivers, an empty list is returned.
2386     *
2387     * @see #MATCH_DEFAULT_ONLY
2388     * @see #GET_INTENT_FILTERS
2389     * @see #GET_RESOLVED_FILTER
2390     * @hide
2391     */
2392    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
2393            int flags, int userId);
2394
2395    /**
2396     * Determine the best service to handle for a given Intent.
2397     *
2398     * @param intent An intent containing all of the desired specification
2399     *               (action, data, type, category, and/or component).
2400     * @param flags Additional option flags.
2401     *
2402     * @return Returns a ResolveInfo containing the final service intent that
2403     *         was determined to be the best action.  Returns null if no
2404     *         matching service was found.
2405     *
2406     * @see #GET_INTENT_FILTERS
2407     * @see #GET_RESOLVED_FILTER
2408     */
2409    public abstract ResolveInfo resolveService(Intent intent, int flags);
2410
2411    /**
2412     * Retrieve all services that can match the given intent.
2413     *
2414     * @param intent The desired intent as per resolveService().
2415     * @param flags Additional option flags.
2416     *
2417     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2418     *         ServiceInfo. These are ordered from best to worst match -- that
2419     *         is, the first item in the list is what is returned by
2420     *         resolveService().  If there are no matching services, an empty
2421     *         list is returned.
2422     *
2423     * @see #GET_INTENT_FILTERS
2424     * @see #GET_RESOLVED_FILTER
2425     */
2426    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
2427            int flags);
2428
2429    /**
2430     * Retrieve all services that can match the given intent for a given user.
2431     *
2432     * @param intent The desired intent as per resolveService().
2433     * @param flags Additional option flags.
2434     * @param userId The user id.
2435     *
2436     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2437     *         ServiceInfo. These are ordered from best to worst match -- that
2438     *         is, the first item in the list is what is returned by
2439     *         resolveService().  If there are no matching services, an empty
2440     *         list is returned.
2441     *
2442     * @see #GET_INTENT_FILTERS
2443     * @see #GET_RESOLVED_FILTER
2444     *
2445     * @hide
2446     */
2447    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
2448            int flags, int userId);
2449
2450    /** {@hide} */
2451    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
2452            Intent intent, int flags, int userId);
2453
2454    /**
2455     * Retrieve all providers that can match the given intent.
2456     *
2457     * @param intent An intent containing all of the desired specification
2458     *            (action, data, type, category, and/or component).
2459     * @param flags Additional option flags.
2460     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2461     *         ProviderInfo. These are ordered from best to worst match. If
2462     *         there are no matching providers, an empty list is returned.
2463     * @see #GET_INTENT_FILTERS
2464     * @see #GET_RESOLVED_FILTER
2465     */
2466    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
2467
2468    /**
2469     * Find a single content provider by its base path name.
2470     *
2471     * @param name The name of the provider to find.
2472     * @param flags Additional option flags.  Currently should always be 0.
2473     *
2474     * @return ContentProviderInfo Information about the provider, if found,
2475     *         else null.
2476     */
2477    public abstract ProviderInfo resolveContentProvider(String name,
2478            int flags);
2479
2480    /**
2481     * Find a single content provider by its base path name.
2482     *
2483     * @param name The name of the provider to find.
2484     * @param flags Additional option flags.  Currently should always be 0.
2485     * @param userId The user id.
2486     *
2487     * @return ContentProviderInfo Information about the provider, if found,
2488     *         else null.
2489     * @hide
2490     */
2491    public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
2492
2493    /**
2494     * Retrieve content provider information.
2495     *
2496     * <p><em>Note: unlike most other methods, an empty result set is indicated
2497     * by a null return instead of an empty list.</em>
2498     *
2499     * @param processName If non-null, limits the returned providers to only
2500     *                    those that are hosted by the given process.  If null,
2501     *                    all content providers are returned.
2502     * @param uid If <var>processName</var> is non-null, this is the required
2503     *        uid owning the requested content providers.
2504     * @param flags Additional option flags.  Currently should always be 0.
2505     *
2506     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
2507     *         content provider either patching <var>processName</var> or, if
2508     *         <var>processName</var> is null, all known content providers.
2509     *         <em>If there are no matching providers, null is returned.</em>
2510     */
2511    public abstract List<ProviderInfo> queryContentProviders(
2512            String processName, int uid, int flags);
2513
2514    /**
2515     * Retrieve all of the information we know about a particular
2516     * instrumentation class.
2517     *
2518     * <p>Throws {@link NameNotFoundException} if instrumentation with the
2519     * given class name cannot be found on the system.
2520     *
2521     * @param className The full name (i.e.
2522     *                  com.google.apps.contacts.InstrumentList) of an
2523     *                  Instrumentation class.
2524     * @param flags Additional option flags.  Currently should always be 0.
2525     *
2526     * @return InstrumentationInfo containing information about the
2527     *         instrumentation.
2528     */
2529    public abstract InstrumentationInfo getInstrumentationInfo(
2530            ComponentName className, int flags) throws NameNotFoundException;
2531
2532    /**
2533     * Retrieve information about available instrumentation code.  May be used
2534     * to retrieve either all instrumentation code, or only the code targeting
2535     * a particular package.
2536     *
2537     * @param targetPackage If null, all instrumentation is returned; only the
2538     *                      instrumentation targeting this package name is
2539     *                      returned.
2540     * @param flags Additional option flags.  Currently should always be 0.
2541     *
2542     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
2543     *         matching available Instrumentation.  Returns an empty list if
2544     *         there is no instrumentation available for the given package.
2545     */
2546    public abstract List<InstrumentationInfo> queryInstrumentation(
2547            String targetPackage, int flags);
2548
2549    /**
2550     * Retrieve an image from a package.  This is a low-level API used by
2551     * the various package manager info structures (such as
2552     * {@link ComponentInfo} to implement retrieval of their associated
2553     * icon.
2554     *
2555     * @param packageName The name of the package that this icon is coming from.
2556     * Cannot be null.
2557     * @param resid The resource identifier of the desired image.  Cannot be 0.
2558     * @param appInfo Overall information about <var>packageName</var>.  This
2559     * may be null, in which case the application information will be retrieved
2560     * for you if needed; if you already have this information around, it can
2561     * be much more efficient to supply it here.
2562     *
2563     * @return Returns a Drawable holding the requested image.  Returns null if
2564     * an image could not be found for any reason.
2565     */
2566    public abstract Drawable getDrawable(String packageName, int resid,
2567            ApplicationInfo appInfo);
2568
2569    /**
2570     * Retrieve the icon associated with an activity.  Given the full name of
2571     * an activity, retrieves the information about it and calls
2572     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
2573     * If the activity cannot be found, NameNotFoundException is thrown.
2574     *
2575     * @param activityName Name of the activity whose icon is to be retrieved.
2576     *
2577     * @return Returns the image of the icon, or the default activity icon if
2578     * it could not be found.  Does not return null.
2579     * @throws NameNotFoundException Thrown if the resources for the given
2580     * activity could not be loaded.
2581     *
2582     * @see #getActivityIcon(Intent)
2583     */
2584    public abstract Drawable getActivityIcon(ComponentName activityName)
2585            throws NameNotFoundException;
2586
2587    /**
2588     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
2589     * set, this simply returns the result of
2590     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
2591     * component and returns the icon associated with the resolved component.
2592     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2593     * to a component, NameNotFoundException is thrown.
2594     *
2595     * @param intent The intent for which you would like to retrieve an icon.
2596     *
2597     * @return Returns the image of the icon, or the default activity icon if
2598     * it could not be found.  Does not return null.
2599     * @throws NameNotFoundException Thrown if the resources for application
2600     * matching the given intent could not be loaded.
2601     *
2602     * @see #getActivityIcon(ComponentName)
2603     */
2604    public abstract Drawable getActivityIcon(Intent intent)
2605            throws NameNotFoundException;
2606
2607    /**
2608     * Retrieve the banner associated with an activity. Given the full name of
2609     * an activity, retrieves the information about it and calls
2610     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
2611     * banner. If the activity cannot be found, NameNotFoundException is thrown.
2612     *
2613     * @param activityName Name of the activity whose banner is to be retrieved.
2614     * @return Returns the image of the banner, or null if the activity has no
2615     *         banner specified.
2616     * @throws NameNotFoundException Thrown if the resources for the given
2617     *             activity could not be loaded.
2618     * @see #getActivityBanner(Intent)
2619     */
2620    public abstract Drawable getActivityBanner(ComponentName activityName)
2621            throws NameNotFoundException;
2622
2623    /**
2624     * Retrieve the banner associated with an Intent. If intent.getClassName()
2625     * is set, this simply returns the result of
2626     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
2627     * intent's component and returns the banner associated with the resolved
2628     * component. If intent.getClassName() cannot be found or the Intent cannot
2629     * be resolved to a component, NameNotFoundException is thrown.
2630     *
2631     * @param intent The intent for which you would like to retrieve a banner.
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 application
2635     *             matching the given intent could not be loaded.
2636     * @see #getActivityBanner(ComponentName)
2637     */
2638    public abstract Drawable getActivityBanner(Intent intent)
2639            throws NameNotFoundException;
2640
2641    /**
2642     * Return the generic icon for an activity that is used when no specific
2643     * icon is defined.
2644     *
2645     * @return Drawable Image of the icon.
2646     */
2647    public abstract Drawable getDefaultActivityIcon();
2648
2649    /**
2650     * Retrieve the icon associated with an application.  If it has not defined
2651     * an icon, the default app icon is returned.  Does not return null.
2652     *
2653     * @param info Information about application being queried.
2654     *
2655     * @return Returns the image of the icon, or the default application icon
2656     * if it could not be found.
2657     *
2658     * @see #getApplicationIcon(String)
2659     */
2660    public abstract Drawable getApplicationIcon(ApplicationInfo info);
2661
2662    /**
2663     * Retrieve the icon associated with an application.  Given the name of the
2664     * application's package, retrieves the information about it and calls
2665     * getApplicationIcon() to return its icon. If the application cannot be
2666     * found, NameNotFoundException is thrown.
2667     *
2668     * @param packageName Name of the package whose application icon is to be
2669     *                    retrieved.
2670     *
2671     * @return Returns the image of the icon, or the default application icon
2672     * if it could not be found.  Does not return null.
2673     * @throws NameNotFoundException Thrown if the resources for the given
2674     * application could not be loaded.
2675     *
2676     * @see #getApplicationIcon(ApplicationInfo)
2677     */
2678    public abstract Drawable getApplicationIcon(String packageName)
2679            throws NameNotFoundException;
2680
2681    /**
2682     * Retrieve the banner associated with an application.
2683     *
2684     * @param info Information about application being queried.
2685     * @return Returns the image of the banner or null if the application has no
2686     *         banner specified.
2687     * @see #getApplicationBanner(String)
2688     */
2689    public abstract Drawable getApplicationBanner(ApplicationInfo info);
2690
2691    /**
2692     * Retrieve the banner associated with an application. Given the name of the
2693     * application's package, retrieves the information about it and calls
2694     * getApplicationIcon() to return its banner. If the application cannot be
2695     * found, NameNotFoundException is thrown.
2696     *
2697     * @param packageName Name of the package whose application banner is to be
2698     *            retrieved.
2699     * @return Returns the image of the banner or null if the application has no
2700     *         banner specified.
2701     * @throws NameNotFoundException Thrown if the resources for the given
2702     *             application could not be loaded.
2703     * @see #getApplicationBanner(ApplicationInfo)
2704     */
2705    public abstract Drawable getApplicationBanner(String packageName)
2706            throws NameNotFoundException;
2707
2708    /**
2709     * Retrieve the logo associated with an activity. Given the full name of an
2710     * activity, retrieves the information about it and calls
2711     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
2712     * logo. If the activity cannot be found, NameNotFoundException is thrown.
2713     *
2714     * @param activityName Name of the activity whose logo is to be retrieved.
2715     * @return Returns the image of the logo or null if the activity has no logo
2716     *         specified.
2717     * @throws NameNotFoundException Thrown if the resources for the given
2718     *             activity could not be loaded.
2719     * @see #getActivityLogo(Intent)
2720     */
2721    public abstract Drawable getActivityLogo(ComponentName activityName)
2722            throws NameNotFoundException;
2723
2724    /**
2725     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
2726     * set, this simply returns the result of
2727     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
2728     * component and returns the logo associated with the resolved component.
2729     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2730     * to a component, NameNotFoundException is thrown.
2731     *
2732     * @param intent The intent for which you would like to retrieve a logo.
2733     *
2734     * @return Returns the image of the logo, or null if the activity has no
2735     * logo specified.
2736     *
2737     * @throws NameNotFoundException Thrown if the resources for application
2738     * matching the given intent could not be loaded.
2739     *
2740     * @see #getActivityLogo(ComponentName)
2741     */
2742    public abstract Drawable getActivityLogo(Intent intent)
2743            throws NameNotFoundException;
2744
2745    /**
2746     * Retrieve the logo associated with an application.  If it has not specified
2747     * a logo, this method returns null.
2748     *
2749     * @param info Information about application being queried.
2750     *
2751     * @return Returns the image of the logo, or null if no logo is specified
2752     * by the application.
2753     *
2754     * @see #getApplicationLogo(String)
2755     */
2756    public abstract Drawable getApplicationLogo(ApplicationInfo info);
2757
2758    /**
2759     * Retrieve the logo associated with an application.  Given the name of the
2760     * application's package, retrieves the information about it and calls
2761     * getApplicationLogo() to return its logo. If the application cannot be
2762     * found, NameNotFoundException is thrown.
2763     *
2764     * @param packageName Name of the package whose application logo is to be
2765     *                    retrieved.
2766     *
2767     * @return Returns the image of the logo, or null if no application logo
2768     * has been specified.
2769     *
2770     * @throws NameNotFoundException Thrown if the resources for the given
2771     * application could not be loaded.
2772     *
2773     * @see #getApplicationLogo(ApplicationInfo)
2774     */
2775    public abstract Drawable getApplicationLogo(String packageName)
2776            throws NameNotFoundException;
2777
2778    /**
2779     * Retrieve text from a package.  This is a low-level API used by
2780     * the various package manager info structures (such as
2781     * {@link ComponentInfo} to implement retrieval of their associated
2782     * labels and other text.
2783     *
2784     * @param packageName The name of the package that this text is coming from.
2785     * Cannot be null.
2786     * @param resid The resource identifier of the desired text.  Cannot be 0.
2787     * @param appInfo Overall information about <var>packageName</var>.  This
2788     * may be null, in which case the application information will be retrieved
2789     * for you if needed; if you already have this information around, it can
2790     * be much more efficient to supply it here.
2791     *
2792     * @return Returns a CharSequence holding the requested text.  Returns null
2793     * if the text could not be found for any reason.
2794     */
2795    public abstract CharSequence getText(String packageName, int resid,
2796            ApplicationInfo appInfo);
2797
2798    /**
2799     * Retrieve an XML file from a package.  This is a low-level API used to
2800     * retrieve XML meta data.
2801     *
2802     * @param packageName The name of the package that this xml is coming from.
2803     * Cannot be null.
2804     * @param resid The resource identifier of the desired xml.  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 an XmlPullParser allowing you to parse out the XML
2811     * data.  Returns null if the xml resource could not be found for any
2812     * reason.
2813     */
2814    public abstract XmlResourceParser getXml(String packageName, int resid,
2815            ApplicationInfo appInfo);
2816
2817    /**
2818     * Return the label to use for this application.
2819     *
2820     * @return Returns the label associated with this application, or null if
2821     * it could not be found for any reason.
2822     * @param info The application to get the label of.
2823     */
2824    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
2825
2826    /**
2827     * Retrieve the resources associated with an activity.  Given the full
2828     * name of an activity, retrieves the information about it and calls
2829     * getResources() to return its application's resources.  If the activity
2830     * cannot be found, NameNotFoundException is thrown.
2831     *
2832     * @param activityName Name of the activity whose resources are to be
2833     *                     retrieved.
2834     *
2835     * @return Returns the application's Resources.
2836     * @throws NameNotFoundException Thrown if the resources for the given
2837     * application could not be loaded.
2838     *
2839     * @see #getResourcesForApplication(ApplicationInfo)
2840     */
2841    public abstract Resources getResourcesForActivity(ComponentName activityName)
2842            throws NameNotFoundException;
2843
2844    /**
2845     * Retrieve the resources for an application.  Throws NameNotFoundException
2846     * if the package is no longer installed.
2847     *
2848     * @param app Information about the desired application.
2849     *
2850     * @return Returns the application's Resources.
2851     * @throws NameNotFoundException Thrown if the resources for the given
2852     * application could not be loaded (most likely because it was uninstalled).
2853     */
2854    public abstract Resources getResourcesForApplication(ApplicationInfo app)
2855            throws NameNotFoundException;
2856
2857    /**
2858     * Retrieve the resources associated with an application.  Given the full
2859     * package name of an application, retrieves the information about it and
2860     * calls getResources() to return its application's resources.  If the
2861     * appPackageName cannot be found, NameNotFoundException is thrown.
2862     *
2863     * @param appPackageName Package name of the application whose resources
2864     *                       are to be retrieved.
2865     *
2866     * @return Returns the application's Resources.
2867     * @throws NameNotFoundException Thrown if the resources for the given
2868     * application could not be loaded.
2869     *
2870     * @see #getResourcesForApplication(ApplicationInfo)
2871     */
2872    public abstract Resources getResourcesForApplication(String appPackageName)
2873            throws NameNotFoundException;
2874
2875    /** @hide */
2876    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
2877            throws NameNotFoundException;
2878
2879    /**
2880     * Retrieve overall information about an application package defined
2881     * in a package archive file
2882     *
2883     * @param archiveFilePath The path to the archive file
2884     * @param flags Additional option flags. Use any combination of
2885     * {@link #GET_ACTIVITIES},
2886     * {@link #GET_GIDS},
2887     * {@link #GET_CONFIGURATIONS},
2888     * {@link #GET_INSTRUMENTATION},
2889     * {@link #GET_PERMISSIONS},
2890     * {@link #GET_PROVIDERS},
2891     * {@link #GET_RECEIVERS},
2892     * {@link #GET_SERVICES},
2893     * {@link #GET_SIGNATURES}, to modify the data returned.
2894     *
2895     * @return Returns the information about the package. Returns
2896     * null if the package could not be successfully parsed.
2897     *
2898     * @see #GET_ACTIVITIES
2899     * @see #GET_GIDS
2900     * @see #GET_CONFIGURATIONS
2901     * @see #GET_INSTRUMENTATION
2902     * @see #GET_PERMISSIONS
2903     * @see #GET_PROVIDERS
2904     * @see #GET_RECEIVERS
2905     * @see #GET_SERVICES
2906     * @see #GET_SIGNATURES
2907     *
2908     */
2909    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
2910        final PackageParser parser = new PackageParser();
2911        final File apkFile = new File(archiveFilePath);
2912        try {
2913            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
2914            if ((flags & GET_SIGNATURES) != 0) {
2915                parser.collectCertificates(pkg, 0);
2916                parser.collectManifestDigest(pkg);
2917            }
2918            PackageUserState state = new PackageUserState();
2919            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
2920        } catch (PackageParserException e) {
2921            return null;
2922        }
2923    }
2924
2925    /**
2926     * @hide
2927     *
2928     * Install a package. Since this may take a little while, the result will
2929     * be posted back to the given observer.  An installation will fail if the calling context
2930     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
2931     * package named in the package file's manifest is already installed, or if there's no space
2932     * available on the device.
2933     *
2934     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
2935     * 'content:' URI.
2936     * @param observer An observer callback to get notified when the package installation is
2937     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
2938     * called when that happens.  This parameter must not be null.
2939     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2940     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2941     * @param installerPackageName Optional package name of the application that is performing the
2942     * installation. This identifies which market the package came from.
2943     * @deprecated Use {@link #installPackage(Uri, IPackageInstallObserver2, int, String)}
2944     * instead.  This method will continue to be supported but the older observer interface
2945     * will not get additional failure details.
2946     */
2947    // @SystemApi
2948    public abstract void installPackage(
2949            Uri packageURI, IPackageInstallObserver observer, int flags,
2950            String installerPackageName);
2951
2952    /**
2953     * Similar to
2954     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
2955     * with an extra verification file provided.
2956     *
2957     * @param packageURI The location of the package file to install. This can
2958     *            be a 'file:' or a 'content:' URI.
2959     * @param observer An observer callback to get notified when the package
2960     *            installation is complete.
2961     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
2962     *            will be called when that happens. This parameter must not be null.
2963     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2964     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2965     * @param installerPackageName Optional package name of the application that
2966     *            is performing the installation. This identifies which market
2967     *            the package came from.
2968     * @param verificationURI The location of the supplementary verification
2969     *            file. This can be a 'file:' or a 'content:' URI. May be
2970     *            {@code null}.
2971     * @param manifestDigest an object that holds the digest of the package
2972     *            which can be used to verify ownership. May be {@code null}.
2973     * @param encryptionParams if the package to be installed is encrypted,
2974     *            these parameters describing the encryption and authentication
2975     *            used. May be {@code null}.
2976     * @hide
2977     * @deprecated Use {@link #installPackageWithVerification(Uri, IPackageInstallObserver2,
2978     * int, String, Uri, ManifestDigest, ContainerEncryptionParams)} instead.  This method will
2979     * continue to be supported but the older observer interface will not get additional failure
2980     * details.
2981     */
2982    // @SystemApi
2983    public abstract void installPackageWithVerification(Uri packageURI,
2984            IPackageInstallObserver observer, int flags, String installerPackageName,
2985            Uri verificationURI, ManifestDigest manifestDigest,
2986            ContainerEncryptionParams encryptionParams);
2987
2988    /**
2989     * Similar to
2990     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
2991     * with an extra verification information provided.
2992     *
2993     * @param packageURI The location of the package file to install. This can
2994     *            be a 'file:' or a 'content:' URI.
2995     * @param observer An observer callback to get notified when the package
2996     *            installation is complete.
2997     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
2998     *            will be called when that happens. This parameter must not be null.
2999     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3000     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3001     * @param installerPackageName Optional package name of the application that
3002     *            is performing the installation. This identifies which market
3003     *            the package came from.
3004     * @param verificationParams an object that holds signal information to
3005     *            assist verification. May be {@code null}.
3006     * @param encryptionParams if the package to be installed is encrypted,
3007     *            these parameters describing the encryption and authentication
3008     *            used. May be {@code null}.
3009     *
3010     * @hide
3011     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3012     * IPackageInstallObserver2, int, String, VerificationParams,
3013     * ContainerEncryptionParams)} instead.  This method will continue to be
3014     * supported but the older observer interface will not get additional failure details.
3015     */
3016    @Deprecated
3017    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3018            IPackageInstallObserver observer, int flags, String installerPackageName,
3019            VerificationParams verificationParams,
3020            ContainerEncryptionParams encryptionParams);
3021
3022    // Package-install variants that take the new, expanded form of observer interface.
3023    // Note that these *also* take the original observer type and will redundantly
3024    // report the same information to that observer if supplied; but it is not required.
3025
3026    /**
3027     * @hide
3028     *
3029     * Install a package. Since this may take a little while, the result will
3030     * be posted back to the given observer.  An installation will fail if the calling context
3031     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3032     * package named in the package file's manifest is already installed, or if there's no space
3033     * available on the device.
3034     *
3035     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3036     * 'content:' URI.
3037     * @param observer An observer callback to get notified when the package installation is
3038     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3039     * called when that happens. This parameter must not be null.
3040     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3041     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3042     * @param installerPackageName Optional package name of the application that is performing the
3043     * installation. This identifies which market the package came from.
3044     */
3045    public abstract void installPackage(
3046            Uri packageURI, PackageInstallObserver observer,
3047            int flags, String installerPackageName);
3048
3049    /**
3050     * Similar to
3051     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3052     * with an extra verification file provided.
3053     *
3054     * @param packageURI The location of the package file to install. This can
3055     *            be a 'file:' or a 'content:' URI.
3056     * @param observer An observer callback to get notified when the package installation is
3057     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3058     * called when that happens. This parameter must not be null.
3059     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3060     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3061     * @param installerPackageName Optional package name of the application that
3062     *            is performing the installation. This identifies which market
3063     *            the package came from.
3064     * @param verificationURI The location of the supplementary verification
3065     *            file. This can be a 'file:' or a 'content:' URI. May be
3066     *            {@code null}.
3067     * @param manifestDigest an object that holds the digest of the package
3068     *            which can be used to verify ownership. May be {@code null}.
3069     * @param encryptionParams if the package to be installed is encrypted,
3070     *            these parameters describing the encryption and authentication
3071     *            used. May be {@code null}.
3072     * @hide
3073     */
3074    public abstract void installPackageWithVerification(Uri packageURI,
3075            PackageInstallObserver observer, int flags, String installerPackageName,
3076            Uri verificationURI, ManifestDigest manifestDigest,
3077            ContainerEncryptionParams encryptionParams);
3078
3079    /**
3080     * Similar to
3081     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3082     * with an extra verification information provided.
3083     *
3084     * @param packageURI The location of the package file to install. This can
3085     *            be a 'file:' or a 'content:' URI.
3086     * @param observer An observer callback to get notified when the package installation is
3087     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3088     * called when that happens. This parameter must not be null.
3089     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3090     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3091     * @param installerPackageName Optional package name of the application that
3092     *            is performing the installation. This identifies which market
3093     *            the package came from.
3094     * @param verificationParams an object that holds signal information to
3095     *            assist verification. May be {@code null}.
3096     * @param encryptionParams if the package to be installed is encrypted,
3097     *            these parameters describing the encryption and authentication
3098     *            used. May be {@code null}.
3099     *
3100     * @hide
3101     */
3102    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3103            PackageInstallObserver observer, int flags, String installerPackageName,
3104            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3105
3106    /**
3107     * If there is already an application with the given package name installed
3108     * on the system for other users, also install it for the calling user.
3109     * @hide
3110     */
3111    // @SystemApi
3112    public abstract int installExistingPackage(String packageName)
3113            throws NameNotFoundException;
3114
3115    /**
3116     * Allows a package listening to the
3117     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3118     * broadcast} to respond to the package manager. The response must include
3119     * the {@code verificationCode} which is one of
3120     * {@link PackageManager#VERIFICATION_ALLOW} or
3121     * {@link PackageManager#VERIFICATION_REJECT}.
3122     *
3123     * @param id pending package identifier as passed via the
3124     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3125     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3126     *            or {@link PackageManager#VERIFICATION_REJECT}.
3127     * @throws SecurityException if the caller does not have the
3128     *            PACKAGE_VERIFICATION_AGENT permission.
3129     */
3130    public abstract void verifyPendingInstall(int id, int verificationCode);
3131
3132    /**
3133     * Allows a package listening to the
3134     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3135     * broadcast} to extend the default timeout for a response and declare what
3136     * action to perform after the timeout occurs. The response must include
3137     * the {@code verificationCodeAtTimeout} which is one of
3138     * {@link PackageManager#VERIFICATION_ALLOW} or
3139     * {@link PackageManager#VERIFICATION_REJECT}.
3140     *
3141     * This method may only be called once per package id. Additional calls
3142     * will have no effect.
3143     *
3144     * @param id pending package identifier as passed via the
3145     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3146     * @param verificationCodeAtTimeout either
3147     *            {@link PackageManager#VERIFICATION_ALLOW} or
3148     *            {@link PackageManager#VERIFICATION_REJECT}. If
3149     *            {@code verificationCodeAtTimeout} is neither
3150     *            {@link PackageManager#VERIFICATION_ALLOW} or
3151     *            {@link PackageManager#VERIFICATION_REJECT}, then
3152     *            {@code verificationCodeAtTimeout} will default to
3153     *            {@link PackageManager#VERIFICATION_REJECT}.
3154     * @param millisecondsToDelay the amount of time requested for the timeout.
3155     *            Must be positive and less than
3156     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3157     *            {@code millisecondsToDelay} is out of bounds,
3158     *            {@code millisecondsToDelay} will be set to the closest in
3159     *            bounds value; namely, 0 or
3160     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3161     * @throws SecurityException if the caller does not have the
3162     *            PACKAGE_VERIFICATION_AGENT permission.
3163     */
3164    public abstract void extendVerificationTimeout(int id,
3165            int verificationCodeAtTimeout, long millisecondsToDelay);
3166
3167    /**
3168     * Change the installer associated with a given package.  There are limitations
3169     * on how the installer package can be changed; in particular:
3170     * <ul>
3171     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3172     * is not signed with the same certificate as the calling application.
3173     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3174     * has an installer package, and that installer package is not signed with
3175     * the same certificate as the calling application.
3176     * </ul>
3177     *
3178     * @param targetPackage The installed package whose installer will be changed.
3179     * @param installerPackageName The package name of the new installer.  May be
3180     * null to clear the association.
3181     */
3182    public abstract void setInstallerPackageName(String targetPackage,
3183            String installerPackageName);
3184
3185    /**
3186     * Attempts to delete a package.  Since this may take a little while, the result will
3187     * be posted back to the given observer.  A deletion will fail if the calling context
3188     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3189     * named package cannot be found, or if the named package is a "system package".
3190     * (TODO: include pointer to documentation on "system packages")
3191     *
3192     * @param packageName The name of the package to delete
3193     * @param observer An observer callback to get notified when the package deletion is
3194     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3195     * called when that happens.  observer may be null to indicate that no callback is desired.
3196     * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3197     * {@link #DELETE_ALL_USERS}.
3198     *
3199     * @hide
3200     */
3201    // @SystemApi
3202    public abstract void deletePackage(
3203            String packageName, IPackageDeleteObserver observer, int flags);
3204
3205    /**
3206     * Retrieve the package name of the application that installed a package. This identifies
3207     * which market the package came from.
3208     *
3209     * @param packageName The name of the package to query
3210     */
3211    public abstract String getInstallerPackageName(String packageName);
3212
3213    /**
3214     * Attempts to clear the user data directory of an application.
3215     * Since this may take a little while, the result will
3216     * be posted back to the given observer.  A deletion will fail if the
3217     * named package cannot be found, or if the named package is a "system package".
3218     *
3219     * @param packageName The name of the package
3220     * @param observer An observer callback to get notified when the operation is finished
3221     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3222     * will be called when that happens.  observer may be null to indicate that
3223     * no callback is desired.
3224     *
3225     * @hide
3226     */
3227    public abstract void clearApplicationUserData(String packageName,
3228            IPackageDataObserver observer);
3229    /**
3230     * Attempts to delete the cache files associated with an application.
3231     * Since this may take a little while, the result will
3232     * be posted back to the given observer.  A deletion will fail if the calling context
3233     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3234     * named package cannot be found, or if the named package is a "system package".
3235     *
3236     * @param packageName The name of the package to delete
3237     * @param observer An observer callback to get notified when the cache file deletion
3238     * is complete.
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 deleteApplicationCacheFiles(String packageName,
3246            IPackageDataObserver observer);
3247
3248    /**
3249     * Free storage by deleting LRU sorted list of cache files across
3250     * all applications. If the currently available free storage
3251     * on the device is greater than or equal to the requested
3252     * free storage, no cache files are cleared. If the currently
3253     * available storage on the device is less than the requested
3254     * free storage, some or all of the cache files across
3255     * all applications are deleted (based on last accessed time)
3256     * to increase the free storage space on the device to
3257     * the requested value. There is no guarantee that clearing all
3258     * the cache files from all applications will clear up
3259     * enough storage to achieve the desired value.
3260     * @param freeStorageSize The number of bytes of storage to be
3261     * freed by the system. Say if freeStorageSize is XX,
3262     * and the current free storage is YY,
3263     * if XX is less than YY, just return. if not free XX-YY number
3264     * of bytes if possible.
3265     * @param observer call back used to notify when
3266     * the operation is completed
3267     *
3268     * @hide
3269     */
3270    // @SystemApi
3271    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
3272
3273    /**
3274     * Free storage by deleting LRU sorted list of cache files across
3275     * all applications. If the currently available free storage
3276     * on the device is greater than or equal to the requested
3277     * free storage, no cache files are cleared. If the currently
3278     * available storage on the device is less than the requested
3279     * free storage, some or all of the cache files across
3280     * all applications are deleted (based on last accessed time)
3281     * to increase the free storage space on the device to
3282     * the requested value. There is no guarantee that clearing all
3283     * the cache files from all applications will clear up
3284     * enough storage to achieve the desired value.
3285     * @param freeStorageSize The number of bytes of storage to be
3286     * freed by the system. Say if freeStorageSize is XX,
3287     * and the current free storage is YY,
3288     * if XX is less than YY, just return. if not free XX-YY number
3289     * of bytes if possible.
3290     * @param pi IntentSender call back used to
3291     * notify when the operation is completed.May be null
3292     * to indicate that no call back is desired.
3293     *
3294     * @hide
3295     */
3296    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
3297
3298    /**
3299     * Retrieve the size information for a package.
3300     * Since this may take a little while, the result will
3301     * be posted back to the given observer.  The calling context
3302     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
3303     *
3304     * @param packageName The name of the package whose size information is to be retrieved
3305     * @param userHandle The user whose size information should be retrieved.
3306     * @param observer An observer callback to get notified when the operation
3307     * is complete.
3308     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
3309     * The observer's callback is invoked with a PackageStats object(containing the
3310     * code, data and cache sizes of the package) and a boolean value representing
3311     * the status of the operation. observer may be null to indicate that
3312     * no callback is desired.
3313     *
3314     * @hide
3315     */
3316    public abstract void getPackageSizeInfo(String packageName, int userHandle,
3317            IPackageStatsObserver observer);
3318
3319    /**
3320     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
3321     * returns the size for the calling user.
3322     *
3323     * @hide
3324     */
3325    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
3326        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
3327    }
3328
3329    /**
3330     * @deprecated This function no longer does anything; it was an old
3331     * approach to managing preferred activities, which has been superseded
3332     * by (and conflicts with) the modern activity-based preferences.
3333     */
3334    @Deprecated
3335    public abstract void addPackageToPreferred(String packageName);
3336
3337    /**
3338     * @deprecated This function no longer does anything; it was an old
3339     * approach to managing preferred activities, which has been superseded
3340     * by (and conflicts with) the modern activity-based preferences.
3341     */
3342    @Deprecated
3343    public abstract void removePackageFromPreferred(String packageName);
3344
3345    /**
3346     * Retrieve the list of all currently configured preferred packages.  The
3347     * first package on the list is the most preferred, the last is the
3348     * least preferred.
3349     *
3350     * @param flags Additional option flags. Use any combination of
3351     * {@link #GET_ACTIVITIES},
3352     * {@link #GET_GIDS},
3353     * {@link #GET_CONFIGURATIONS},
3354     * {@link #GET_INSTRUMENTATION},
3355     * {@link #GET_PERMISSIONS},
3356     * {@link #GET_PROVIDERS},
3357     * {@link #GET_RECEIVERS},
3358     * {@link #GET_SERVICES},
3359     * {@link #GET_SIGNATURES}, to modify the data returned.
3360     *
3361     * @return Returns a list of PackageInfo objects describing each
3362     * preferred application, in order of preference.
3363     *
3364     * @see #GET_ACTIVITIES
3365     * @see #GET_GIDS
3366     * @see #GET_CONFIGURATIONS
3367     * @see #GET_INSTRUMENTATION
3368     * @see #GET_PERMISSIONS
3369     * @see #GET_PROVIDERS
3370     * @see #GET_RECEIVERS
3371     * @see #GET_SERVICES
3372     * @see #GET_SIGNATURES
3373     */
3374    public abstract List<PackageInfo> getPreferredPackages(int flags);
3375
3376    /**
3377     * @deprecated This is a protected API that should not have been available
3378     * to third party applications.  It is the platform's responsibility for
3379     * assigning preferred activities and this cannot be directly modified.
3380     *
3381     * Add a new preferred activity mapping to the system.  This will be used
3382     * to automatically select the given activity component when
3383     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3384     * multiple matching activities and also matches the given filter.
3385     *
3386     * @param filter The set of intents under which this activity will be
3387     * made preferred.
3388     * @param match The IntentFilter match category that this preference
3389     * applies to.
3390     * @param set The set of activities that the user was picking from when
3391     * this preference was made.
3392     * @param activity The component name of the activity that is to be
3393     * preferred.
3394     */
3395    @Deprecated
3396    public abstract void addPreferredActivity(IntentFilter filter, int match,
3397            ComponentName[] set, ComponentName activity);
3398
3399    /**
3400     * Same as {@link #addPreferredActivity(IntentFilter, int,
3401            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
3402            to.
3403     * @hide
3404     */
3405    public void addPreferredActivity(IntentFilter filter, int match,
3406            ComponentName[] set, ComponentName activity, int userId) {
3407        throw new RuntimeException("Not implemented. Must override in a subclass.");
3408    }
3409
3410    /**
3411     * @deprecated This is a protected API that should not have been available
3412     * to third party applications.  It is the platform's responsibility for
3413     * assigning preferred activities and this cannot be directly modified.
3414     *
3415     * Replaces an existing preferred activity mapping to the system, and if that were not present
3416     * adds a new preferred activity.  This will be used
3417     * to automatically select the given activity component when
3418     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3419     * multiple matching activities and also matches the given filter.
3420     *
3421     * @param filter The set of intents under which this activity will be
3422     * made preferred.
3423     * @param match The IntentFilter match category that this preference
3424     * applies to.
3425     * @param set The set of activities that the user was picking from when
3426     * this preference was made.
3427     * @param activity The component name of the activity that is to be
3428     * preferred.
3429     * @hide
3430     */
3431    @Deprecated
3432    public abstract void replacePreferredActivity(IntentFilter filter, int match,
3433            ComponentName[] set, ComponentName activity);
3434
3435    /**
3436     * Remove all preferred activity mappings, previously added with
3437     * {@link #addPreferredActivity}, from the
3438     * system whose activities are implemented in the given package name.
3439     * An application can only clear its own package(s).
3440     *
3441     * @param packageName The name of the package whose preferred activity
3442     * mappings are to be removed.
3443     */
3444    public abstract void clearPackagePreferredActivities(String packageName);
3445
3446    /**
3447     * Retrieve all preferred activities, previously added with
3448     * {@link #addPreferredActivity}, that are
3449     * currently registered with the system.
3450     *
3451     * @param outFilters A list in which to place the filters of all of the
3452     * preferred activities, or null for none.
3453     * @param outActivities A list in which to place the component names of
3454     * all of the preferred activities, or null for none.
3455     * @param packageName An option package in which you would like to limit
3456     * the list.  If null, all activities will be returned; if non-null, only
3457     * those activities in the given package are returned.
3458     *
3459     * @return Returns the total number of registered preferred activities
3460     * (the number of distinct IntentFilter records, not the number of unique
3461     * activity components) that were found.
3462     */
3463    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
3464            List<ComponentName> outActivities, String packageName);
3465
3466    /**
3467     * Ask for the set of available 'home' activities and the current explicit
3468     * default, if any.
3469     * @hide
3470     */
3471    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
3472
3473    /**
3474     * Set the enabled setting for a package component (activity, receiver, service, provider).
3475     * This setting will override any enabled state which may have been set by the component in its
3476     * manifest.
3477     *
3478     * @param componentName The component to enable
3479     * @param newState The new enabled state for the component.  The legal values for this state
3480     *                 are:
3481     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3482     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3483     *                   and
3484     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3485     *                 The last one removes the setting, thereby restoring the component's state to
3486     *                 whatever was set in it's manifest (or enabled, by default).
3487     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3488     */
3489    public abstract void setComponentEnabledSetting(ComponentName componentName,
3490            int newState, int flags);
3491
3492
3493    /**
3494     * Return the enabled setting for a package component (activity,
3495     * receiver, service, provider).  This returns the last value set by
3496     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
3497     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3498     * the value originally specified in the manifest has not been modified.
3499     *
3500     * @param componentName The component to retrieve.
3501     * @return Returns the current enabled state for the component.  May
3502     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3503     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3504     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3505     * component's enabled state is based on the original information in
3506     * the manifest as found in {@link ComponentInfo}.
3507     */
3508    public abstract int getComponentEnabledSetting(ComponentName componentName);
3509
3510    /**
3511     * Set the enabled setting for an application
3512     * This setting will override any enabled state which may have been set by the application in
3513     * its manifest.  It also overrides the enabled state set in the manifest for any of the
3514     * application's components.  It does not override any enabled state set by
3515     * {@link #setComponentEnabledSetting} for any of the application's components.
3516     *
3517     * @param packageName The package name of the application to enable
3518     * @param newState The new enabled state for the component.  The legal values for this state
3519     *                 are:
3520     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3521     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3522     *                   and
3523     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3524     *                 The last one removes the setting, thereby restoring the applications's state to
3525     *                 whatever was set in its manifest (or enabled, by default).
3526     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3527     */
3528    public abstract void setApplicationEnabledSetting(String packageName,
3529            int newState, int flags);
3530
3531    /**
3532     * Return the enabled setting for an application. This returns
3533     * the last value set by
3534     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
3535     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3536     * the value originally specified in the manifest has not been modified.
3537     *
3538     * @param packageName The package name of the application to retrieve.
3539     * @return Returns the current enabled state for the application.  May
3540     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3541     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3542     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3543     * application's enabled state is based on the original information in
3544     * the manifest as found in {@link ComponentInfo}.
3545     * @throws IllegalArgumentException if the named package does not exist.
3546     */
3547    public abstract int getApplicationEnabledSetting(String packageName);
3548
3549    /**
3550     * Puts the package in a blocked state, which is almost like an uninstalled state,
3551     * making the package unavailable, but it doesn't remove the data or the actual
3552     * package file.
3553     * @hide
3554     */
3555    public abstract boolean setApplicationBlockedSettingAsUser(String packageName, boolean blocked,
3556            UserHandle userHandle);
3557
3558    /**
3559     * Returns the blocked state of a package.
3560     * @see #setApplicationBlockedSettingAsUser(String, boolean, UserHandle)
3561     * @hide
3562     */
3563    public abstract boolean getApplicationBlockedSettingAsUser(String packageName,
3564            UserHandle userHandle);
3565
3566    /**
3567     * Return whether the device has been booted into safe mode.
3568     */
3569    public abstract boolean isSafeMode();
3570
3571    /**
3572     * Attempts to move package resources from internal to external media or vice versa.
3573     * Since this may take a little while, the result will
3574     * be posted back to the given observer.   This call may fail if the calling context
3575     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
3576     * named package cannot be found, or if the named package is a "system package".
3577     *
3578     * @param packageName The name of the package to delete
3579     * @param observer An observer callback to get notified when the package move is
3580     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
3581     * called when that happens.  observer may be null to indicate that no callback is desired.
3582     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
3583     * {@link #MOVE_EXTERNAL_MEDIA}
3584     *
3585     * @hide
3586     */
3587    public abstract void movePackage(
3588            String packageName, IPackageMoveObserver observer, int flags);
3589
3590    /**
3591     * Returns the device identity that verifiers can use to associate their scheme to a particular
3592     * device. This should not be used by anything other than a package verifier.
3593     *
3594     * @return identity that uniquely identifies current device
3595     * @hide
3596     */
3597    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
3598
3599    /** {@hide} */
3600    public abstract PackageInstaller getPackageInstaller();
3601
3602    /**
3603     * Returns the data directory for a particular user and package, given the uid of the package.
3604     * @param uid uid of the package, including the userId and appId
3605     * @param packageName name of the package
3606     * @return the user-specific data directory for the package
3607     * @hide
3608     */
3609    public static String getDataDirForUser(int userId, String packageName) {
3610        // TODO: This should be shared with Installer's knowledge of user directory
3611        return Environment.getDataDirectory().toString() + "/user/" + userId
3612                + "/" + packageName;
3613    }
3614
3615    /**
3616     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
3617     * user with id sourceUserId can also be be resolved by activities in the user with id
3618     * targetUserId if they match the specified intent filter.
3619     * @param filter the {@link IntentFilter} the intent has to match
3620     * @param removable if set to false, {@link clearCrossProfileIntentFilters} will not remove this
3621     * {@link CrossProfileIntentFilter}
3622     * @hide
3623     */
3624    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
3625            int targetUserId, int flags);
3626
3627    /**
3628     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
3629     * source, and have been set by the profile owner
3630     * @param sourceUserId
3631     * @hide
3632     */
3633    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
3634
3635    /**
3636     * Forwards all intents for {@link packageName} for user {@link sourceUserId} to user
3637     * {@link targetUserId}.
3638     * @hide
3639     */
3640    public abstract void addCrossProfileIntentsForPackage(String packageName,
3641            int sourceUserId, int targetUserId);
3642    /**
3643     * @hide
3644     */
3645    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
3646}
3647