PackageManager.java revision fa4533f3a07ebed479d2a0e7af7d6e03d4417d41
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     * Retrieve content provider information.
2482     *
2483     * <p><em>Note: unlike most other methods, an empty result set is indicated
2484     * by a null return instead of an empty list.</em>
2485     *
2486     * @param processName If non-null, limits the returned providers to only
2487     *                    those that are hosted by the given process.  If null,
2488     *                    all content providers are returned.
2489     * @param uid If <var>processName</var> is non-null, this is the required
2490     *        uid owning the requested content providers.
2491     * @param flags Additional option flags.  Currently should always be 0.
2492     *
2493     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
2494     *         content provider either patching <var>processName</var> or, if
2495     *         <var>processName</var> is null, all known content providers.
2496     *         <em>If there are no matching providers, null is returned.</em>
2497     */
2498    public abstract List<ProviderInfo> queryContentProviders(
2499            String processName, int uid, int flags);
2500
2501    /**
2502     * Retrieve all of the information we know about a particular
2503     * instrumentation class.
2504     *
2505     * <p>Throws {@link NameNotFoundException} if instrumentation with the
2506     * given class name cannot be found on the system.
2507     *
2508     * @param className The full name (i.e.
2509     *                  com.google.apps.contacts.InstrumentList) of an
2510     *                  Instrumentation class.
2511     * @param flags Additional option flags.  Currently should always be 0.
2512     *
2513     * @return InstrumentationInfo containing information about the
2514     *         instrumentation.
2515     */
2516    public abstract InstrumentationInfo getInstrumentationInfo(
2517            ComponentName className, int flags) throws NameNotFoundException;
2518
2519    /**
2520     * Retrieve information about available instrumentation code.  May be used
2521     * to retrieve either all instrumentation code, or only the code targeting
2522     * a particular package.
2523     *
2524     * @param targetPackage If null, all instrumentation is returned; only the
2525     *                      instrumentation targeting this package name is
2526     *                      returned.
2527     * @param flags Additional option flags.  Currently should always be 0.
2528     *
2529     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
2530     *         matching available Instrumentation.  Returns an empty list if
2531     *         there is no instrumentation available for the given package.
2532     */
2533    public abstract List<InstrumentationInfo> queryInstrumentation(
2534            String targetPackage, int flags);
2535
2536    /**
2537     * Retrieve an image from a package.  This is a low-level API used by
2538     * the various package manager info structures (such as
2539     * {@link ComponentInfo} to implement retrieval of their associated
2540     * icon.
2541     *
2542     * @param packageName The name of the package that this icon is coming from.
2543     * Cannot be null.
2544     * @param resid The resource identifier of the desired image.  Cannot be 0.
2545     * @param appInfo Overall information about <var>packageName</var>.  This
2546     * may be null, in which case the application information will be retrieved
2547     * for you if needed; if you already have this information around, it can
2548     * be much more efficient to supply it here.
2549     *
2550     * @return Returns a Drawable holding the requested image.  Returns null if
2551     * an image could not be found for any reason.
2552     */
2553    public abstract Drawable getDrawable(String packageName, int resid,
2554            ApplicationInfo appInfo);
2555
2556    /**
2557     * Retrieve the icon associated with an activity.  Given the full name of
2558     * an activity, retrieves the information about it and calls
2559     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
2560     * If the activity cannot be found, NameNotFoundException is thrown.
2561     *
2562     * @param activityName Name of the activity whose icon is to be retrieved.
2563     *
2564     * @return Returns the image of the icon, or the default activity icon if
2565     * it could not be found.  Does not return null.
2566     * @throws NameNotFoundException Thrown if the resources for the given
2567     * activity could not be loaded.
2568     *
2569     * @see #getActivityIcon(Intent)
2570     */
2571    public abstract Drawable getActivityIcon(ComponentName activityName)
2572            throws NameNotFoundException;
2573
2574    /**
2575     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
2576     * set, this simply returns the result of
2577     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
2578     * component and returns the icon associated with the resolved component.
2579     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2580     * to a component, NameNotFoundException is thrown.
2581     *
2582     * @param intent The intent for which you would like to retrieve an icon.
2583     *
2584     * @return Returns the image of the icon, or the default activity icon if
2585     * it could not be found.  Does not return null.
2586     * @throws NameNotFoundException Thrown if the resources for application
2587     * matching the given intent could not be loaded.
2588     *
2589     * @see #getActivityIcon(ComponentName)
2590     */
2591    public abstract Drawable getActivityIcon(Intent intent)
2592            throws NameNotFoundException;
2593
2594    /**
2595     * Retrieve the banner associated with an activity. Given the full name of
2596     * an activity, retrieves the information about it and calls
2597     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
2598     * banner. If the activity cannot be found, NameNotFoundException is thrown.
2599     *
2600     * @param activityName Name of the activity whose banner is to be retrieved.
2601     * @return Returns the image of the banner, or null if the activity has no
2602     *         banner specified.
2603     * @throws NameNotFoundException Thrown if the resources for the given
2604     *             activity could not be loaded.
2605     * @see #getActivityBanner(Intent)
2606     */
2607    public abstract Drawable getActivityBanner(ComponentName activityName)
2608            throws NameNotFoundException;
2609
2610    /**
2611     * Retrieve the banner associated with an Intent. If intent.getClassName()
2612     * is set, this simply returns the result of
2613     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
2614     * intent's component and returns the banner associated with the resolved
2615     * component. If intent.getClassName() cannot be found or the Intent cannot
2616     * be resolved to a component, NameNotFoundException is thrown.
2617     *
2618     * @param intent The intent for which you would like to retrieve a banner.
2619     * @return Returns the image of the banner, or null if the activity has no
2620     *         banner specified.
2621     * @throws NameNotFoundException Thrown if the resources for application
2622     *             matching the given intent could not be loaded.
2623     * @see #getActivityBanner(ComponentName)
2624     */
2625    public abstract Drawable getActivityBanner(Intent intent)
2626            throws NameNotFoundException;
2627
2628    /**
2629     * Return the generic icon for an activity that is used when no specific
2630     * icon is defined.
2631     *
2632     * @return Drawable Image of the icon.
2633     */
2634    public abstract Drawable getDefaultActivityIcon();
2635
2636    /**
2637     * Retrieve the icon associated with an application.  If it has not defined
2638     * an icon, the default app icon is returned.  Does not return null.
2639     *
2640     * @param info Information about application being queried.
2641     *
2642     * @return Returns the image of the icon, or the default application icon
2643     * if it could not be found.
2644     *
2645     * @see #getApplicationIcon(String)
2646     */
2647    public abstract Drawable getApplicationIcon(ApplicationInfo info);
2648
2649    /**
2650     * Retrieve the icon associated with an application.  Given the name of the
2651     * application's package, retrieves the information about it and calls
2652     * getApplicationIcon() to return its icon. If the application cannot be
2653     * found, NameNotFoundException is thrown.
2654     *
2655     * @param packageName Name of the package whose application icon is to be
2656     *                    retrieved.
2657     *
2658     * @return Returns the image of the icon, or the default application icon
2659     * if it could not be found.  Does not return null.
2660     * @throws NameNotFoundException Thrown if the resources for the given
2661     * application could not be loaded.
2662     *
2663     * @see #getApplicationIcon(ApplicationInfo)
2664     */
2665    public abstract Drawable getApplicationIcon(String packageName)
2666            throws NameNotFoundException;
2667
2668    /**
2669     * Retrieve the banner associated with an application.
2670     *
2671     * @param info Information about application being queried.
2672     * @return Returns the image of the banner or null if the application has no
2673     *         banner specified.
2674     * @see #getApplicationBanner(String)
2675     */
2676    public abstract Drawable getApplicationBanner(ApplicationInfo info);
2677
2678    /**
2679     * Retrieve the banner associated with an application. Given the name of the
2680     * application's package, retrieves the information about it and calls
2681     * getApplicationIcon() to return its banner. If the application cannot be
2682     * found, NameNotFoundException is thrown.
2683     *
2684     * @param packageName Name of the package whose application banner is to be
2685     *            retrieved.
2686     * @return Returns the image of the banner or null if the application has no
2687     *         banner specified.
2688     * @throws NameNotFoundException Thrown if the resources for the given
2689     *             application could not be loaded.
2690     * @see #getApplicationBanner(ApplicationInfo)
2691     */
2692    public abstract Drawable getApplicationBanner(String packageName)
2693            throws NameNotFoundException;
2694
2695    /**
2696     * Retrieve the logo associated with an activity. Given the full name of an
2697     * activity, retrieves the information about it and calls
2698     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
2699     * logo. If the activity cannot be found, NameNotFoundException is thrown.
2700     *
2701     * @param activityName Name of the activity whose logo is to be retrieved.
2702     * @return Returns the image of the logo or null if the activity has no logo
2703     *         specified.
2704     * @throws NameNotFoundException Thrown if the resources for the given
2705     *             activity could not be loaded.
2706     * @see #getActivityLogo(Intent)
2707     */
2708    public abstract Drawable getActivityLogo(ComponentName activityName)
2709            throws NameNotFoundException;
2710
2711    /**
2712     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
2713     * set, this simply returns the result of
2714     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
2715     * component and returns the logo associated with the resolved component.
2716     * If intent.getClassName() cannot be found or the Intent cannot be resolved
2717     * to a component, NameNotFoundException is thrown.
2718     *
2719     * @param intent The intent for which you would like to retrieve a logo.
2720     *
2721     * @return Returns the image of the logo, or null if the activity has no
2722     * logo specified.
2723     *
2724     * @throws NameNotFoundException Thrown if the resources for application
2725     * matching the given intent could not be loaded.
2726     *
2727     * @see #getActivityLogo(ComponentName)
2728     */
2729    public abstract Drawable getActivityLogo(Intent intent)
2730            throws NameNotFoundException;
2731
2732    /**
2733     * Retrieve the logo associated with an application.  If it has not specified
2734     * a logo, this method returns null.
2735     *
2736     * @param info Information about application being queried.
2737     *
2738     * @return Returns the image of the logo, or null if no logo is specified
2739     * by the application.
2740     *
2741     * @see #getApplicationLogo(String)
2742     */
2743    public abstract Drawable getApplicationLogo(ApplicationInfo info);
2744
2745    /**
2746     * Retrieve the logo associated with an application.  Given the name of the
2747     * application's package, retrieves the information about it and calls
2748     * getApplicationLogo() to return its logo. If the application cannot be
2749     * found, NameNotFoundException is thrown.
2750     *
2751     * @param packageName Name of the package whose application logo is to be
2752     *                    retrieved.
2753     *
2754     * @return Returns the image of the logo, or null if no application logo
2755     * has been specified.
2756     *
2757     * @throws NameNotFoundException Thrown if the resources for the given
2758     * application could not be loaded.
2759     *
2760     * @see #getApplicationLogo(ApplicationInfo)
2761     */
2762    public abstract Drawable getApplicationLogo(String packageName)
2763            throws NameNotFoundException;
2764
2765    /**
2766     * Retrieve text from a package.  This is a low-level API used by
2767     * the various package manager info structures (such as
2768     * {@link ComponentInfo} to implement retrieval of their associated
2769     * labels and other text.
2770     *
2771     * @param packageName The name of the package that this text is coming from.
2772     * Cannot be null.
2773     * @param resid The resource identifier of the desired text.  Cannot be 0.
2774     * @param appInfo Overall information about <var>packageName</var>.  This
2775     * may be null, in which case the application information will be retrieved
2776     * for you if needed; if you already have this information around, it can
2777     * be much more efficient to supply it here.
2778     *
2779     * @return Returns a CharSequence holding the requested text.  Returns null
2780     * if the text could not be found for any reason.
2781     */
2782    public abstract CharSequence getText(String packageName, int resid,
2783            ApplicationInfo appInfo);
2784
2785    /**
2786     * Retrieve an XML file from a package.  This is a low-level API used to
2787     * retrieve XML meta data.
2788     *
2789     * @param packageName The name of the package that this xml is coming from.
2790     * Cannot be null.
2791     * @param resid The resource identifier of the desired xml.  Cannot be 0.
2792     * @param appInfo Overall information about <var>packageName</var>.  This
2793     * may be null, in which case the application information will be retrieved
2794     * for you if needed; if you already have this information around, it can
2795     * be much more efficient to supply it here.
2796     *
2797     * @return Returns an XmlPullParser allowing you to parse out the XML
2798     * data.  Returns null if the xml resource could not be found for any
2799     * reason.
2800     */
2801    public abstract XmlResourceParser getXml(String packageName, int resid,
2802            ApplicationInfo appInfo);
2803
2804    /**
2805     * Return the label to use for this application.
2806     *
2807     * @return Returns the label associated with this application, or null if
2808     * it could not be found for any reason.
2809     * @param info The application to get the label of.
2810     */
2811    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
2812
2813    /**
2814     * Retrieve the resources associated with an activity.  Given the full
2815     * name of an activity, retrieves the information about it and calls
2816     * getResources() to return its application's resources.  If the activity
2817     * cannot be found, NameNotFoundException is thrown.
2818     *
2819     * @param activityName Name of the activity whose resources are to be
2820     *                     retrieved.
2821     *
2822     * @return Returns the application's Resources.
2823     * @throws NameNotFoundException Thrown if the resources for the given
2824     * application could not be loaded.
2825     *
2826     * @see #getResourcesForApplication(ApplicationInfo)
2827     */
2828    public abstract Resources getResourcesForActivity(ComponentName activityName)
2829            throws NameNotFoundException;
2830
2831    /**
2832     * Retrieve the resources for an application.  Throws NameNotFoundException
2833     * if the package is no longer installed.
2834     *
2835     * @param app Information about the desired application.
2836     *
2837     * @return Returns the application's Resources.
2838     * @throws NameNotFoundException Thrown if the resources for the given
2839     * application could not be loaded (most likely because it was uninstalled).
2840     */
2841    public abstract Resources getResourcesForApplication(ApplicationInfo app)
2842            throws NameNotFoundException;
2843
2844    /**
2845     * Retrieve the resources associated with an application.  Given the full
2846     * package name of an application, retrieves the information about it and
2847     * calls getResources() to return its application's resources.  If the
2848     * appPackageName cannot be found, NameNotFoundException is thrown.
2849     *
2850     * @param appPackageName Package name of the application whose resources
2851     *                       are to be retrieved.
2852     *
2853     * @return Returns the application's Resources.
2854     * @throws NameNotFoundException Thrown if the resources for the given
2855     * application could not be loaded.
2856     *
2857     * @see #getResourcesForApplication(ApplicationInfo)
2858     */
2859    public abstract Resources getResourcesForApplication(String appPackageName)
2860            throws NameNotFoundException;
2861
2862    /** @hide */
2863    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
2864            throws NameNotFoundException;
2865
2866    /**
2867     * Retrieve overall information about an application package defined
2868     * in a package archive file
2869     *
2870     * @param archiveFilePath The path to the archive file
2871     * @param flags Additional option flags. Use any combination of
2872     * {@link #GET_ACTIVITIES},
2873     * {@link #GET_GIDS},
2874     * {@link #GET_CONFIGURATIONS},
2875     * {@link #GET_INSTRUMENTATION},
2876     * {@link #GET_PERMISSIONS},
2877     * {@link #GET_PROVIDERS},
2878     * {@link #GET_RECEIVERS},
2879     * {@link #GET_SERVICES},
2880     * {@link #GET_SIGNATURES}, to modify the data returned.
2881     *
2882     * @return Returns the information about the package. Returns
2883     * null if the package could not be successfully parsed.
2884     *
2885     * @see #GET_ACTIVITIES
2886     * @see #GET_GIDS
2887     * @see #GET_CONFIGURATIONS
2888     * @see #GET_INSTRUMENTATION
2889     * @see #GET_PERMISSIONS
2890     * @see #GET_PROVIDERS
2891     * @see #GET_RECEIVERS
2892     * @see #GET_SERVICES
2893     * @see #GET_SIGNATURES
2894     *
2895     */
2896    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
2897        final PackageParser parser = new PackageParser();
2898        final File apkFile = new File(archiveFilePath);
2899        try {
2900            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
2901            if ((flags & GET_SIGNATURES) != 0) {
2902                parser.collectCertificates(pkg, 0);
2903                parser.collectManifestDigest(pkg);
2904            }
2905            PackageUserState state = new PackageUserState();
2906            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
2907        } catch (PackageParserException e) {
2908            return null;
2909        }
2910    }
2911
2912    /**
2913     * @hide
2914     *
2915     * Install a package. Since this may take a little while, the result will
2916     * be posted back to the given observer.  An installation will fail if the calling context
2917     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
2918     * package named in the package file's manifest is already installed, or if there's no space
2919     * available on the device.
2920     *
2921     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
2922     * 'content:' URI.
2923     * @param observer An observer callback to get notified when the package installation is
2924     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
2925     * called when that happens.  This parameter must not be null.
2926     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2927     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2928     * @param installerPackageName Optional package name of the application that is performing the
2929     * installation. This identifies which market the package came from.
2930     * @deprecated Use {@link #installPackage(Uri, IPackageInstallObserver2, int, String)}
2931     * instead.  This method will continue to be supported but the older observer interface
2932     * will not get additional failure details.
2933     */
2934    // @SystemApi
2935    public abstract void installPackage(
2936            Uri packageURI, IPackageInstallObserver observer, int flags,
2937            String installerPackageName);
2938
2939    /**
2940     * Similar to
2941     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
2942     * with an extra verification file provided.
2943     *
2944     * @param packageURI The location of the package file to install. This can
2945     *            be a 'file:' or a 'content:' URI.
2946     * @param observer An observer callback to get notified when the package
2947     *            installation is complete.
2948     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
2949     *            will be called when that happens. This parameter must not be null.
2950     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2951     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2952     * @param installerPackageName Optional package name of the application that
2953     *            is performing the installation. This identifies which market
2954     *            the package came from.
2955     * @param verificationURI The location of the supplementary verification
2956     *            file. This can be a 'file:' or a 'content:' URI. May be
2957     *            {@code null}.
2958     * @param manifestDigest an object that holds the digest of the package
2959     *            which can be used to verify ownership. May be {@code null}.
2960     * @param encryptionParams if the package to be installed is encrypted,
2961     *            these parameters describing the encryption and authentication
2962     *            used. May be {@code null}.
2963     * @hide
2964     * @deprecated Use {@link #installPackageWithVerification(Uri, IPackageInstallObserver2,
2965     * int, String, Uri, ManifestDigest, ContainerEncryptionParams)} instead.  This method will
2966     * continue to be supported but the older observer interface will not get additional failure
2967     * details.
2968     */
2969    // @SystemApi
2970    public abstract void installPackageWithVerification(Uri packageURI,
2971            IPackageInstallObserver observer, int flags, String installerPackageName,
2972            Uri verificationURI, ManifestDigest manifestDigest,
2973            ContainerEncryptionParams encryptionParams);
2974
2975    /**
2976     * Similar to
2977     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
2978     * with an extra verification information provided.
2979     *
2980     * @param packageURI The location of the package file to install. This can
2981     *            be a 'file:' or a 'content:' URI.
2982     * @param observer An observer callback to get notified when the package
2983     *            installation is complete.
2984     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
2985     *            will be called when that happens. This parameter must not be null.
2986     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2987     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2988     * @param installerPackageName Optional package name of the application that
2989     *            is performing the installation. This identifies which market
2990     *            the package came from.
2991     * @param verificationParams an object that holds signal information to
2992     *            assist verification. May be {@code null}.
2993     * @param encryptionParams if the package to be installed is encrypted,
2994     *            these parameters describing the encryption and authentication
2995     *            used. May be {@code null}.
2996     *
2997     * @hide
2998     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
2999     * IPackageInstallObserver2, int, String, VerificationParams,
3000     * ContainerEncryptionParams)} instead.  This method will continue to be
3001     * supported but the older observer interface will not get additional failure details.
3002     */
3003    @Deprecated
3004    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3005            IPackageInstallObserver observer, int flags, String installerPackageName,
3006            VerificationParams verificationParams,
3007            ContainerEncryptionParams encryptionParams);
3008
3009    // Package-install variants that take the new, expanded form of observer interface.
3010    // Note that these *also* take the original observer type and will redundantly
3011    // report the same information to that observer if supplied; but it is not required.
3012
3013    /**
3014     * @hide
3015     *
3016     * Install a package. Since this may take a little while, the result will
3017     * be posted back to the given observer.  An installation will fail if the calling context
3018     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3019     * package named in the package file's manifest is already installed, or if there's no space
3020     * available on the device.
3021     *
3022     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3023     * 'content:' URI.
3024     * @param observer An observer callback to get notified when the package installation is
3025     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3026     * called when that happens. This parameter must not be null.
3027     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3028     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3029     * @param installerPackageName Optional package name of the application that is performing the
3030     * installation. This identifies which market the package came from.
3031     */
3032    public abstract void installPackage(
3033            Uri packageURI, PackageInstallObserver observer,
3034            int flags, String installerPackageName);
3035
3036    /**
3037     * Similar to
3038     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3039     * with an extra verification file provided.
3040     *
3041     * @param packageURI The location of the package file to install. This can
3042     *            be a 'file:' or a 'content:' URI.
3043     * @param observer An observer callback to get notified when the package installation is
3044     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3045     * called when that happens. This parameter must not be null.
3046     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3047     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3048     * @param installerPackageName Optional package name of the application that
3049     *            is performing the installation. This identifies which market
3050     *            the package came from.
3051     * @param verificationURI The location of the supplementary verification
3052     *            file. This can be a 'file:' or a 'content:' URI. May be
3053     *            {@code null}.
3054     * @param manifestDigest an object that holds the digest of the package
3055     *            which can be used to verify ownership. May be {@code null}.
3056     * @param encryptionParams if the package to be installed is encrypted,
3057     *            these parameters describing the encryption and authentication
3058     *            used. May be {@code null}.
3059     * @hide
3060     */
3061    public abstract void installPackageWithVerification(Uri packageURI,
3062            PackageInstallObserver observer, int flags, String installerPackageName,
3063            Uri verificationURI, ManifestDigest manifestDigest,
3064            ContainerEncryptionParams encryptionParams);
3065
3066    /**
3067     * Similar to
3068     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3069     * with an extra verification information provided.
3070     *
3071     * @param packageURI The location of the package file to install. This can
3072     *            be a 'file:' or a 'content:' URI.
3073     * @param observer An observer callback to get notified when the package installation is
3074     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3075     * called when that happens. This parameter must not be null.
3076     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3077     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3078     * @param installerPackageName Optional package name of the application that
3079     *            is performing the installation. This identifies which market
3080     *            the package came from.
3081     * @param verificationParams an object that holds signal information to
3082     *            assist verification. May be {@code null}.
3083     * @param encryptionParams if the package to be installed is encrypted,
3084     *            these parameters describing the encryption and authentication
3085     *            used. May be {@code null}.
3086     *
3087     * @hide
3088     */
3089    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3090            PackageInstallObserver observer, int flags, String installerPackageName,
3091            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3092
3093    /**
3094     * If there is already an application with the given package name installed
3095     * on the system for other users, also install it for the calling user.
3096     * @hide
3097     */
3098    // @SystemApi
3099    public abstract int installExistingPackage(String packageName)
3100            throws NameNotFoundException;
3101
3102    /**
3103     * Allows a package listening to the
3104     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3105     * broadcast} to respond to the package manager. The response must include
3106     * the {@code verificationCode} which is one of
3107     * {@link PackageManager#VERIFICATION_ALLOW} or
3108     * {@link PackageManager#VERIFICATION_REJECT}.
3109     *
3110     * @param id pending package identifier as passed via the
3111     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3112     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3113     *            or {@link PackageManager#VERIFICATION_REJECT}.
3114     * @throws SecurityException if the caller does not have the
3115     *            PACKAGE_VERIFICATION_AGENT permission.
3116     */
3117    public abstract void verifyPendingInstall(int id, int verificationCode);
3118
3119    /**
3120     * Allows a package listening to the
3121     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3122     * broadcast} to extend the default timeout for a response and declare what
3123     * action to perform after the timeout occurs. The response must include
3124     * the {@code verificationCodeAtTimeout} which is one of
3125     * {@link PackageManager#VERIFICATION_ALLOW} or
3126     * {@link PackageManager#VERIFICATION_REJECT}.
3127     *
3128     * This method may only be called once per package id. Additional calls
3129     * will have no effect.
3130     *
3131     * @param id pending package identifier as passed via the
3132     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3133     * @param verificationCodeAtTimeout either
3134     *            {@link PackageManager#VERIFICATION_ALLOW} or
3135     *            {@link PackageManager#VERIFICATION_REJECT}. If
3136     *            {@code verificationCodeAtTimeout} is neither
3137     *            {@link PackageManager#VERIFICATION_ALLOW} or
3138     *            {@link PackageManager#VERIFICATION_REJECT}, then
3139     *            {@code verificationCodeAtTimeout} will default to
3140     *            {@link PackageManager#VERIFICATION_REJECT}.
3141     * @param millisecondsToDelay the amount of time requested for the timeout.
3142     *            Must be positive and less than
3143     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3144     *            {@code millisecondsToDelay} is out of bounds,
3145     *            {@code millisecondsToDelay} will be set to the closest in
3146     *            bounds value; namely, 0 or
3147     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3148     * @throws SecurityException if the caller does not have the
3149     *            PACKAGE_VERIFICATION_AGENT permission.
3150     */
3151    public abstract void extendVerificationTimeout(int id,
3152            int verificationCodeAtTimeout, long millisecondsToDelay);
3153
3154    /**
3155     * Change the installer associated with a given package.  There are limitations
3156     * on how the installer package can be changed; in particular:
3157     * <ul>
3158     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3159     * is not signed with the same certificate as the calling application.
3160     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3161     * has an installer package, and that installer package is not signed with
3162     * the same certificate as the calling application.
3163     * </ul>
3164     *
3165     * @param targetPackage The installed package whose installer will be changed.
3166     * @param installerPackageName The package name of the new installer.  May be
3167     * null to clear the association.
3168     */
3169    public abstract void setInstallerPackageName(String targetPackage,
3170            String installerPackageName);
3171
3172    /**
3173     * Attempts to delete a package.  Since this may take a little while, the result will
3174     * be posted back to the given observer.  A deletion will fail if the calling context
3175     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3176     * named package cannot be found, or if the named package is a "system package".
3177     * (TODO: include pointer to documentation on "system packages")
3178     *
3179     * @param packageName The name of the package to delete
3180     * @param observer An observer callback to get notified when the package deletion is
3181     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3182     * called when that happens.  observer may be null to indicate that no callback is desired.
3183     * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3184     * {@link #DELETE_ALL_USERS}.
3185     *
3186     * @hide
3187     */
3188    // @SystemApi
3189    public abstract void deletePackage(
3190            String packageName, IPackageDeleteObserver observer, int flags);
3191
3192    /**
3193     * Retrieve the package name of the application that installed a package. This identifies
3194     * which market the package came from.
3195     *
3196     * @param packageName The name of the package to query
3197     */
3198    public abstract String getInstallerPackageName(String packageName);
3199
3200    /**
3201     * Attempts to clear the user data directory of an application.
3202     * Since this may take a little while, the result will
3203     * be posted back to the given observer.  A deletion will fail if the
3204     * named package cannot be found, or if the named package is a "system package".
3205     *
3206     * @param packageName The name of the package
3207     * @param observer An observer callback to get notified when the operation is finished
3208     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3209     * will be called when that happens.  observer may be null to indicate that
3210     * no callback is desired.
3211     *
3212     * @hide
3213     */
3214    public abstract void clearApplicationUserData(String packageName,
3215            IPackageDataObserver observer);
3216    /**
3217     * Attempts to delete the cache files associated with an application.
3218     * Since this may take a little while, the result will
3219     * be posted back to the given observer.  A deletion will fail if the calling context
3220     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3221     * named package cannot be found, or if the named package is a "system package".
3222     *
3223     * @param packageName The name of the package to delete
3224     * @param observer An observer callback to get notified when the cache file deletion
3225     * is complete.
3226     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3227     * will be called when that happens.  observer may be null to indicate that
3228     * no callback is desired.
3229     *
3230     * @hide
3231     */
3232    public abstract void deleteApplicationCacheFiles(String packageName,
3233            IPackageDataObserver observer);
3234
3235    /**
3236     * Free storage by deleting LRU sorted list of cache files across
3237     * all applications. If the currently available free storage
3238     * on the device is greater than or equal to the requested
3239     * free storage, no cache files are cleared. If the currently
3240     * available storage on the device is less than the requested
3241     * free storage, some or all of the cache files across
3242     * all applications are deleted (based on last accessed time)
3243     * to increase the free storage space on the device to
3244     * the requested value. There is no guarantee that clearing all
3245     * the cache files from all applications will clear up
3246     * enough storage to achieve the desired value.
3247     * @param freeStorageSize The number of bytes of storage to be
3248     * freed by the system. Say if freeStorageSize is XX,
3249     * and the current free storage is YY,
3250     * if XX is less than YY, just return. if not free XX-YY number
3251     * of bytes if possible.
3252     * @param observer call back used to notify when
3253     * the operation is completed
3254     *
3255     * @hide
3256     */
3257    // @SystemApi
3258    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
3259
3260    /**
3261     * Free storage by deleting LRU sorted list of cache files across
3262     * all applications. If the currently available free storage
3263     * on the device is greater than or equal to the requested
3264     * free storage, no cache files are cleared. If the currently
3265     * available storage on the device is less than the requested
3266     * free storage, some or all of the cache files across
3267     * all applications are deleted (based on last accessed time)
3268     * to increase the free storage space on the device to
3269     * the requested value. There is no guarantee that clearing all
3270     * the cache files from all applications will clear up
3271     * enough storage to achieve the desired value.
3272     * @param freeStorageSize The number of bytes of storage to be
3273     * freed by the system. Say if freeStorageSize is XX,
3274     * and the current free storage is YY,
3275     * if XX is less than YY, just return. if not free XX-YY number
3276     * of bytes if possible.
3277     * @param pi IntentSender call back used to
3278     * notify when the operation is completed.May be null
3279     * to indicate that no call back is desired.
3280     *
3281     * @hide
3282     */
3283    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
3284
3285    /**
3286     * Retrieve the size information for a package.
3287     * Since this may take a little while, the result will
3288     * be posted back to the given observer.  The calling context
3289     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
3290     *
3291     * @param packageName The name of the package whose size information is to be retrieved
3292     * @param userHandle The user whose size information should be retrieved.
3293     * @param observer An observer callback to get notified when the operation
3294     * is complete.
3295     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
3296     * The observer's callback is invoked with a PackageStats object(containing the
3297     * code, data and cache sizes of the package) and a boolean value representing
3298     * the status of the operation. observer may be null to indicate that
3299     * no callback is desired.
3300     *
3301     * @hide
3302     */
3303    public abstract void getPackageSizeInfo(String packageName, int userHandle,
3304            IPackageStatsObserver observer);
3305
3306    /**
3307     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
3308     * returns the size for the calling user.
3309     *
3310     * @hide
3311     */
3312    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
3313        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
3314    }
3315
3316    /**
3317     * @deprecated This function no longer does anything; it was an old
3318     * approach to managing preferred activities, which has been superseded
3319     * by (and conflicts with) the modern activity-based preferences.
3320     */
3321    @Deprecated
3322    public abstract void addPackageToPreferred(String packageName);
3323
3324    /**
3325     * @deprecated This function no longer does anything; it was an old
3326     * approach to managing preferred activities, which has been superseded
3327     * by (and conflicts with) the modern activity-based preferences.
3328     */
3329    @Deprecated
3330    public abstract void removePackageFromPreferred(String packageName);
3331
3332    /**
3333     * Retrieve the list of all currently configured preferred packages.  The
3334     * first package on the list is the most preferred, the last is the
3335     * least preferred.
3336     *
3337     * @param flags Additional option flags. Use any combination of
3338     * {@link #GET_ACTIVITIES},
3339     * {@link #GET_GIDS},
3340     * {@link #GET_CONFIGURATIONS},
3341     * {@link #GET_INSTRUMENTATION},
3342     * {@link #GET_PERMISSIONS},
3343     * {@link #GET_PROVIDERS},
3344     * {@link #GET_RECEIVERS},
3345     * {@link #GET_SERVICES},
3346     * {@link #GET_SIGNATURES}, to modify the data returned.
3347     *
3348     * @return Returns a list of PackageInfo objects describing each
3349     * preferred application, in order of preference.
3350     *
3351     * @see #GET_ACTIVITIES
3352     * @see #GET_GIDS
3353     * @see #GET_CONFIGURATIONS
3354     * @see #GET_INSTRUMENTATION
3355     * @see #GET_PERMISSIONS
3356     * @see #GET_PROVIDERS
3357     * @see #GET_RECEIVERS
3358     * @see #GET_SERVICES
3359     * @see #GET_SIGNATURES
3360     */
3361    public abstract List<PackageInfo> getPreferredPackages(int flags);
3362
3363    /**
3364     * @deprecated This is a protected API that should not have been available
3365     * to third party applications.  It is the platform's responsibility for
3366     * assigning preferred activities and this cannot be directly modified.
3367     *
3368     * Add a new preferred activity mapping to the system.  This will be used
3369     * to automatically select the given activity component when
3370     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3371     * multiple matching activities and also matches the given filter.
3372     *
3373     * @param filter The set of intents under which this activity will be
3374     * made preferred.
3375     * @param match The IntentFilter match category that this preference
3376     * applies to.
3377     * @param set The set of activities that the user was picking from when
3378     * this preference was made.
3379     * @param activity The component name of the activity that is to be
3380     * preferred.
3381     */
3382    @Deprecated
3383    public abstract void addPreferredActivity(IntentFilter filter, int match,
3384            ComponentName[] set, ComponentName activity);
3385
3386    /**
3387     * Same as {@link #addPreferredActivity(IntentFilter, int,
3388            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
3389            to.
3390     * @hide
3391     */
3392    public void addPreferredActivity(IntentFilter filter, int match,
3393            ComponentName[] set, ComponentName activity, int userId) {
3394        throw new RuntimeException("Not implemented. Must override in a subclass.");
3395    }
3396
3397    /**
3398     * @deprecated This is a protected API that should not have been available
3399     * to third party applications.  It is the platform's responsibility for
3400     * assigning preferred activities and this cannot be directly modified.
3401     *
3402     * Replaces an existing preferred activity mapping to the system, and if that were not present
3403     * adds a new preferred activity.  This will be used
3404     * to automatically select the given activity component when
3405     * {@link Context#startActivity(Intent) Context.startActivity()} finds
3406     * multiple matching activities and also matches the given filter.
3407     *
3408     * @param filter The set of intents under which this activity will be
3409     * made preferred.
3410     * @param match The IntentFilter match category that this preference
3411     * applies to.
3412     * @param set The set of activities that the user was picking from when
3413     * this preference was made.
3414     * @param activity The component name of the activity that is to be
3415     * preferred.
3416     * @hide
3417     */
3418    @Deprecated
3419    public abstract void replacePreferredActivity(IntentFilter filter, int match,
3420            ComponentName[] set, ComponentName activity);
3421
3422    /**
3423     * Remove all preferred activity mappings, previously added with
3424     * {@link #addPreferredActivity}, from the
3425     * system whose activities are implemented in the given package name.
3426     * An application can only clear its own package(s).
3427     *
3428     * @param packageName The name of the package whose preferred activity
3429     * mappings are to be removed.
3430     */
3431    public abstract void clearPackagePreferredActivities(String packageName);
3432
3433    /**
3434     * Retrieve all preferred activities, previously added with
3435     * {@link #addPreferredActivity}, that are
3436     * currently registered with the system.
3437     *
3438     * @param outFilters A list in which to place the filters of all of the
3439     * preferred activities, or null for none.
3440     * @param outActivities A list in which to place the component names of
3441     * all of the preferred activities, or null for none.
3442     * @param packageName An option package in which you would like to limit
3443     * the list.  If null, all activities will be returned; if non-null, only
3444     * those activities in the given package are returned.
3445     *
3446     * @return Returns the total number of registered preferred activities
3447     * (the number of distinct IntentFilter records, not the number of unique
3448     * activity components) that were found.
3449     */
3450    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
3451            List<ComponentName> outActivities, String packageName);
3452
3453    /**
3454     * Ask for the set of available 'home' activities and the current explicit
3455     * default, if any.
3456     * @hide
3457     */
3458    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
3459
3460    /**
3461     * Set the enabled setting for a package component (activity, receiver, service, provider).
3462     * This setting will override any enabled state which may have been set by the component in its
3463     * manifest.
3464     *
3465     * @param componentName The component to enable
3466     * @param newState The new enabled state for the component.  The legal values for this state
3467     *                 are:
3468     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3469     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3470     *                   and
3471     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3472     *                 The last one removes the setting, thereby restoring the component's state to
3473     *                 whatever was set in it's manifest (or enabled, by default).
3474     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3475     */
3476    public abstract void setComponentEnabledSetting(ComponentName componentName,
3477            int newState, int flags);
3478
3479
3480    /**
3481     * Return the enabled setting for a package component (activity,
3482     * receiver, service, provider).  This returns the last value set by
3483     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
3484     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3485     * the value originally specified in the manifest has not been modified.
3486     *
3487     * @param componentName The component to retrieve.
3488     * @return Returns the current enabled state for the component.  May
3489     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3490     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3491     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3492     * component's enabled state is based on the original information in
3493     * the manifest as found in {@link ComponentInfo}.
3494     */
3495    public abstract int getComponentEnabledSetting(ComponentName componentName);
3496
3497    /**
3498     * Set the enabled setting for an application
3499     * This setting will override any enabled state which may have been set by the application in
3500     * its manifest.  It also overrides the enabled state set in the manifest for any of the
3501     * application's components.  It does not override any enabled state set by
3502     * {@link #setComponentEnabledSetting} for any of the application's components.
3503     *
3504     * @param packageName The package name of the application to enable
3505     * @param newState The new enabled state for the component.  The legal values for this state
3506     *                 are:
3507     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
3508     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
3509     *                   and
3510     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
3511     *                 The last one removes the setting, thereby restoring the applications's state to
3512     *                 whatever was set in its manifest (or enabled, by default).
3513     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
3514     */
3515    public abstract void setApplicationEnabledSetting(String packageName,
3516            int newState, int flags);
3517
3518    /**
3519     * Return the enabled setting for an application. This returns
3520     * the last value set by
3521     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
3522     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
3523     * the value originally specified in the manifest has not been modified.
3524     *
3525     * @param packageName The package name of the application to retrieve.
3526     * @return Returns the current enabled state for the application.  May
3527     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
3528     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
3529     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
3530     * application's enabled state is based on the original information in
3531     * the manifest as found in {@link ComponentInfo}.
3532     * @throws IllegalArgumentException if the named package does not exist.
3533     */
3534    public abstract int getApplicationEnabledSetting(String packageName);
3535
3536    /**
3537     * Puts the package in a blocked state, which is almost like an uninstalled state,
3538     * making the package unavailable, but it doesn't remove the data or the actual
3539     * package file.
3540     * @hide
3541     */
3542    public abstract boolean setApplicationBlockedSettingAsUser(String packageName, boolean blocked,
3543            UserHandle userHandle);
3544
3545    /**
3546     * Returns the blocked state of a package.
3547     * @see #setApplicationBlockedSettingAsUser(String, boolean, UserHandle)
3548     * @hide
3549     */
3550    public abstract boolean getApplicationBlockedSettingAsUser(String packageName,
3551            UserHandle userHandle);
3552
3553    /**
3554     * Return whether the device has been booted into safe mode.
3555     */
3556    public abstract boolean isSafeMode();
3557
3558    /**
3559     * Attempts to move package resources from internal to external media or vice versa.
3560     * Since this may take a little while, the result will
3561     * be posted back to the given observer.   This call may fail if the calling context
3562     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
3563     * named package cannot be found, or if the named package is a "system package".
3564     *
3565     * @param packageName The name of the package to delete
3566     * @param observer An observer callback to get notified when the package move is
3567     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
3568     * called when that happens.  observer may be null to indicate that no callback is desired.
3569     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
3570     * {@link #MOVE_EXTERNAL_MEDIA}
3571     *
3572     * @hide
3573     */
3574    public abstract void movePackage(
3575            String packageName, IPackageMoveObserver observer, int flags);
3576
3577    /**
3578     * Returns the device identity that verifiers can use to associate their scheme to a particular
3579     * device. This should not be used by anything other than a package verifier.
3580     *
3581     * @return identity that uniquely identifies current device
3582     * @hide
3583     */
3584    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
3585
3586    /** {@hide} */
3587    public abstract PackageInstaller getPackageInstaller();
3588
3589    /**
3590     * Returns the data directory for a particular user and package, given the uid of the package.
3591     * @param uid uid of the package, including the userId and appId
3592     * @param packageName name of the package
3593     * @return the user-specific data directory for the package
3594     * @hide
3595     */
3596    public static String getDataDirForUser(int userId, String packageName) {
3597        // TODO: This should be shared with Installer's knowledge of user directory
3598        return Environment.getDataDirectory().toString() + "/user/" + userId
3599                + "/" + packageName;
3600    }
3601
3602    /**
3603     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
3604     * user with id sourceUserId can also be be resolved by activities in the user with id
3605     * targetUserId if they match the specified intent filter.
3606     * @param filter the {@link IntentFilter} the intent has to match
3607     * @param removable if set to false, {@link clearCrossProfileIntentFilters} will not remove this
3608     * {@link CrossProfileIntentFilter}
3609     * @hide
3610     */
3611    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
3612            int targetUserId, int flags);
3613
3614    /**
3615     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
3616     * source, and have been set by the profile owner
3617     * @param sourceUserId
3618     * @hide
3619     */
3620    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
3621
3622    /**
3623     * Forwards all intents for {@link packageName} for user {@link sourceUserId} to user
3624     * {@link targetUserId}.
3625     * @hide
3626     */
3627    public abstract void addCrossProfileIntentsForPackage(String packageName,
3628            int sourceUserId, int targetUserId);
3629    /**
3630     * @hide
3631     */
3632    public abstract Bitmap getUserIcon(int userId);
3633}
3634