PackageManager.java revision b3523c45dd764ba9926ee70a04cfee78b10e7ab4
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.Manifest;
20import android.annotation.CheckResult;
21import android.annotation.DrawableRes;
22import android.annotation.IntDef;
23import android.annotation.NonNull;
24import android.annotation.Nullable;
25import android.annotation.RequiresPermission;
26import android.annotation.SdkConstant;
27import android.annotation.SdkConstant.SdkConstantType;
28import android.annotation.StringRes;
29import android.annotation.SystemApi;
30import android.annotation.XmlRes;
31import android.app.PackageDeleteObserver;
32import android.app.PackageInstallObserver;
33import android.app.admin.DevicePolicyManager;
34import android.content.ComponentName;
35import android.content.Context;
36import android.content.Intent;
37import android.content.IntentFilter;
38import android.content.IntentSender;
39import android.content.pm.PackageParser.PackageParserException;
40import android.content.res.Resources;
41import android.content.res.XmlResourceParser;
42import android.graphics.Rect;
43import android.graphics.drawable.Drawable;
44import android.net.Uri;
45import android.os.Bundle;
46import android.os.Handler;
47import android.os.RemoteException;
48import android.os.UserHandle;
49import android.os.storage.VolumeInfo;
50import android.util.AndroidException;
51
52import com.android.internal.util.ArrayUtils;
53
54import java.io.File;
55import java.lang.annotation.Retention;
56import java.lang.annotation.RetentionPolicy;
57import java.util.List;
58
59/**
60 * Class for retrieving various kinds of information related to the application
61 * packages that are currently installed on the device.
62 *
63 * You can find this class through {@link Context#getPackageManager}.
64 */
65public abstract class PackageManager {
66
67    /**
68     * This exception is thrown when a given package, application, or component
69     * name cannot be found.
70     */
71    public static class NameNotFoundException extends AndroidException {
72        public NameNotFoundException() {
73        }
74
75        public NameNotFoundException(String name) {
76            super(name);
77        }
78    }
79
80    /**
81     * Listener for changes in permissions granted to a UID.
82     *
83     * @hide
84     */
85    @SystemApi
86    public interface OnPermissionsChangedListener {
87
88        /**
89         * Called when the permissions for a UID change.
90         * @param uid The UID with a change.
91         */
92        public void onPermissionsChanged(int uid);
93    }
94
95    /**
96     * {@link PackageInfo} flag: return information about
97     * activities in the package in {@link PackageInfo#activities}.
98     */
99    public static final int GET_ACTIVITIES              = 0x00000001;
100
101    /**
102     * {@link PackageInfo} flag: return information about
103     * intent receivers in the package in
104     * {@link PackageInfo#receivers}.
105     */
106    public static final int GET_RECEIVERS               = 0x00000002;
107
108    /**
109     * {@link PackageInfo} flag: return information about
110     * services in the package in {@link PackageInfo#services}.
111     */
112    public static final int GET_SERVICES                = 0x00000004;
113
114    /**
115     * {@link PackageInfo} flag: return information about
116     * content providers in the package in
117     * {@link PackageInfo#providers}.
118     */
119    public static final int GET_PROVIDERS               = 0x00000008;
120
121    /**
122     * {@link PackageInfo} flag: return information about
123     * instrumentation in the package in
124     * {@link PackageInfo#instrumentation}.
125     */
126    public static final int GET_INSTRUMENTATION         = 0x00000010;
127
128    /**
129     * {@link PackageInfo} flag: return information about the
130     * intent filters supported by the activity.
131     */
132    public static final int GET_INTENT_FILTERS          = 0x00000020;
133
134    /**
135     * {@link PackageInfo} flag: return information about the
136     * signatures included in the package.
137     */
138    public static final int GET_SIGNATURES          = 0x00000040;
139
140    /**
141     * {@link ResolveInfo} flag: return the IntentFilter that
142     * was matched for a particular ResolveInfo in
143     * {@link ResolveInfo#filter}.
144     */
145    public static final int GET_RESOLVED_FILTER         = 0x00000040;
146
147    /**
148     * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
149     * data {@link android.os.Bundle}s that are associated with a component.
150     * This applies for any API returning a ComponentInfo subclass.
151     */
152    public static final int GET_META_DATA               = 0x00000080;
153
154    /**
155     * {@link PackageInfo} flag: return the
156     * {@link PackageInfo#gids group ids} that are associated with an
157     * application.
158     * This applies for any API returning a PackageInfo class, either
159     * directly or nested inside of another.
160     */
161    public static final int GET_GIDS                    = 0x00000100;
162
163    /**
164     * {@link PackageInfo} flag: include disabled components in the returned info.
165     */
166    public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
167
168    /**
169     * {@link ApplicationInfo} flag: return the
170     * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
171     * that are associated with an application.
172     * This applies for any API returning an ApplicationInfo class, either
173     * directly or nested inside of another.
174     */
175    public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
176
177    /**
178     * {@link ProviderInfo} flag: return the
179     * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
180     * that are associated with a content provider.
181     * This applies for any API returning a ProviderInfo class, either
182     * directly or nested inside of another.
183     */
184    public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
185    /**
186     * {@link PackageInfo} flag: return information about
187     * permissions in the package in
188     * {@link PackageInfo#permissions}.
189     */
190    public static final int GET_PERMISSIONS               = 0x00001000;
191
192    /**
193     * Flag parameter to retrieve some information about all applications (even
194     * uninstalled ones) which have data directories. This state could have
195     * resulted if applications have been deleted with flag
196     * {@code DONT_DELETE_DATA} with a possibility of being replaced or
197     * reinstalled in future.
198     * <p>
199     * Note: this flag may cause less information about currently installed
200     * applications to be returned.
201     */
202    public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
203
204    /**
205     * {@link PackageInfo} flag: return information about
206     * hardware preferences in
207     * {@link PackageInfo#configPreferences PackageInfo.configPreferences},
208     * and requested features in {@link PackageInfo#reqFeatures} and
209     * {@link PackageInfo#featureGroups}.
210     */
211    public static final int GET_CONFIGURATIONS = 0x00004000;
212
213    /**
214     * {@link PackageInfo} flag: include disabled components which are in
215     * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED}
216     * in the returned info.  Note that if you set this flag, applications
217     * that are in this disabled state will be reported as enabled.
218     */
219    public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000;
220
221    /**
222     * Resolution and querying flag: if set, only filters that support the
223     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
224     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
225     * supplied Intent.
226     */
227    public static final int MATCH_DEFAULT_ONLY  = 0x00010000;
228
229    /**
230     * Querying flag: if set and if the platform is doing any filtering of the results, then
231     * the filtering will not happen. This is a synonym for saying that all results should
232     * be returned.
233     */
234    public static final int MATCH_ALL = 0x00020000;
235
236    /**
237     * {@link PackageInfo} flag: include components which aren't encryption
238     * aware in the returned info, regardless of the current user state.
239     */
240    public static final int GET_ENCRYPTION_UNAWARE_COMPONENTS = 0x00040000;
241
242    /**
243     * {@link PackageInfo} flag: return components that are marked as
244     * {@link ComponentInfo#encryptionAware}, unless
245     * {@link #GET_ENCRYPTION_UNAWARE_COMPONENTS} is also specified.
246     * <p>
247     * This flag is for internal use only.
248     *
249     * @hide
250     */
251    public static final int MATCH_ENCRYPTION_AWARE_ONLY = 0x00080000;
252
253    /**
254     * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
255     * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current
256     * profile will be skipped.
257     * Only activities in the target user can respond to the intent.
258     * @hide
259     */
260    public static final int SKIP_CURRENT_PROFILE = 0x00000002;
261
262    /**
263     * Flag for {@link addCrossProfileIntentFilter}: if this flag is set:
264     * activities in the other profiles can respond to the intent only if no activity with
265     * non-negative priority in current profile can respond to the intent.
266     * @hide
267     */
268    public static final int ONLY_IF_NO_MATCH_FOUND = 0x00000004;
269
270    /** @hide */
271    @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED})
272    @Retention(RetentionPolicy.SOURCE)
273    public @interface PermissionResult {}
274
275    /**
276     * Permission check result: this is returned by {@link #checkPermission}
277     * if the permission has been granted to the given package.
278     */
279    public static final int PERMISSION_GRANTED = 0;
280
281    /**
282     * Permission check result: this is returned by {@link #checkPermission}
283     * if the permission has not been granted to the given package.
284     */
285    public static final int PERMISSION_DENIED = -1;
286
287    /**
288     * Signature check result: this is returned by {@link #checkSignatures}
289     * if all signatures on the two packages match.
290     */
291    public static final int SIGNATURE_MATCH = 0;
292
293    /**
294     * Signature check result: this is returned by {@link #checkSignatures}
295     * if neither of the two packages is signed.
296     */
297    public static final int SIGNATURE_NEITHER_SIGNED = 1;
298
299    /**
300     * Signature check result: this is returned by {@link #checkSignatures}
301     * if the first package is not signed but the second is.
302     */
303    public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
304
305    /**
306     * Signature check result: this is returned by {@link #checkSignatures}
307     * if the second package is not signed but the first is.
308     */
309    public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
310
311    /**
312     * Signature check result: this is returned by {@link #checkSignatures}
313     * if not all signatures on both packages match.
314     */
315    public static final int SIGNATURE_NO_MATCH = -3;
316
317    /**
318     * Signature check result: this is returned by {@link #checkSignatures}
319     * if either of the packages are not valid.
320     */
321    public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
322
323    /**
324     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
325     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
326     * component or application is in its default enabled state (as specified
327     * in its manifest).
328     */
329    public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
330
331    /**
332     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
333     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
334     * component or application has been explictily enabled, regardless of
335     * what it has specified in its manifest.
336     */
337    public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
338
339    /**
340     * Flag for {@link #setApplicationEnabledSetting(String, int, int)}
341     * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This
342     * component or application has been explicitly disabled, regardless of
343     * what it has specified in its manifest.
344     */
345    public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
346
347    /**
348     * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The
349     * user has explicitly disabled the application, regardless of what it has
350     * specified in its manifest.  Because this is due to the user's request,
351     * they may re-enable it if desired through the appropriate system UI.  This
352     * option currently <strong>cannot</strong> be used with
353     * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
354     */
355    public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3;
356
357    /**
358     * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This
359     * application should be considered, until the point where the user actually
360     * wants to use it.  This means that it will not normally show up to the user
361     * (such as in the launcher), but various parts of the user interface can
362     * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow
363     * the user to select it (as for example an IME, device admin, etc).  Such code,
364     * once the user has selected the app, should at that point also make it enabled.
365     * This option currently <strong>can not</strong> be used with
366     * {@link #setComponentEnabledSetting(ComponentName, int, int)}.
367     */
368    public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4;
369
370    /**
371     * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
372     * indicate that this package should be installed as forward locked, i.e. only the app itself
373     * should have access to its code and non-resource assets.
374     * @hide
375     */
376    public static final int INSTALL_FORWARD_LOCK = 0x00000001;
377
378    /**
379     * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
380     * installed package, if one exists.
381     * @hide
382     */
383    public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
384
385    /**
386     * Flag parameter for {@link #installPackage} to indicate that you want to
387     * allow test packages (those that have set android:testOnly in their
388     * manifest) to be installed.
389     * @hide
390     */
391    public static final int INSTALL_ALLOW_TEST = 0x00000004;
392
393    /**
394     * Flag parameter for {@link #installPackage} to indicate that this package
395     * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}.
396     *
397     * @hide
398     */
399    public static final int INSTALL_EXTERNAL = 0x00000008;
400
401    /**
402     * Flag parameter for {@link #installPackage} to indicate that this package
403     * must be installed to internal storage.
404     *
405     * @hide
406     */
407    public static final int INSTALL_INTERNAL = 0x00000010;
408
409    /**
410     * Flag parameter for {@link #installPackage} to indicate that this install
411     * was initiated via ADB.
412     *
413     * @hide
414     */
415    public static final int INSTALL_FROM_ADB = 0x00000020;
416
417    /**
418     * Flag parameter for {@link #installPackage} to indicate that this install
419     * should immediately be visible to all users.
420     *
421     * @hide
422     */
423    public static final int INSTALL_ALL_USERS = 0x00000040;
424
425    /**
426     * Flag parameter for {@link #installPackage} to indicate that it is okay
427     * to install an update to an app where the newly installed app has a lower
428     * version code than the currently installed app.
429     *
430     * @hide
431     */
432    public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080;
433
434    /**
435     * Flag parameter for {@link #installPackage} to indicate that all runtime
436     * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS}
437     * is set the runtime permissions will be granted to all users, otherwise
438     * only to the owner.
439     *
440     * @hide
441     */
442    public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100;
443
444    /** {@hide} */
445    public static final int INSTALL_FORCE_VOLUME_UUID = 0x00000200;
446
447    /**
448     * Flag parameter for {@link #installPackage} to indicate that we always want to force
449     * the prompt for permission approval. This overrides any special behaviour for internal
450     * components.
451     *
452     * @hide
453     */
454    public static final int INSTALL_FORCE_PERMISSION_PROMPT = 0x00000400;
455
456    /**
457     * Flag parameter for {@link #installPackage} to indicate that this package is
458     * to be installed quickly.
459     *
460     * @hide
461     */
462    public static final int INSTALL_QUICK = 0x00000800;
463
464    /**
465     * Flag parameter for
466     * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
467     * that you don't want to kill the app containing the component.  Be careful when you set this
468     * since changing component states can make the containing application's behavior unpredictable.
469     */
470    public static final int DONT_KILL_APP = 0x00000001;
471
472    /**
473     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
474     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
475     * @hide
476     */
477    @SystemApi
478    public static final int INSTALL_SUCCEEDED = 1;
479
480    /**
481     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
482     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
483     * already installed.
484     * @hide
485     */
486    @SystemApi
487    public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
488
489    /**
490     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
491     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
492     * file is invalid.
493     * @hide
494     */
495    @SystemApi
496    public static final int INSTALL_FAILED_INVALID_APK = -2;
497
498    /**
499     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
500     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
501     * is invalid.
502     * @hide
503     */
504    @SystemApi
505    public static final int INSTALL_FAILED_INVALID_URI = -3;
506
507    /**
508     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
509     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
510     * service found that the device didn't have enough storage space to install the app.
511     * @hide
512     */
513    @SystemApi
514    public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
515
516    /**
517     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
518     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
519     * package is already installed with the same name.
520     * @hide
521     */
522    @SystemApi
523    public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
524
525    /**
526     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
527     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
528     * the requested shared user does not exist.
529     * @hide
530     */
531    @SystemApi
532    public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
533
534    /**
535     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
536     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
537     * a previously installed package of the same name has a different signature
538     * than the new package (and the old package's data was not removed).
539     * @hide
540     */
541    @SystemApi
542    public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
543
544    /**
545     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
546     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
547     * the new package is requested a shared user which is already installed on the
548     * device and does not have matching signature.
549     * @hide
550     */
551    @SystemApi
552    public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
553
554    /**
555     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
556     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
557     * the new package uses a shared library that is not available.
558     * @hide
559     */
560    @SystemApi
561    public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
562
563    /**
564     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
565     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
566     * the new package uses a shared library that is not available.
567     * @hide
568     */
569    @SystemApi
570    public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
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 failed while optimizing and validating its dex files,
576     * either because there was not enough storage or the validation failed.
577     * @hide
578     */
579    @SystemApi
580    public static final int INSTALL_FAILED_DEXOPT = -11;
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 failed because the current SDK version is older than
586     * that required by the package.
587     * @hide
588     */
589    @SystemApi
590    public static final int INSTALL_FAILED_OLDER_SDK = -12;
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 failed because it contains a content provider with the
596     * same authority as a provider already installed in the system.
597     * @hide
598     */
599    @SystemApi
600    public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
601
602    /**
603     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
604     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
605     * the new package failed because the current SDK version is newer than
606     * that required by the package.
607     * @hide
608     */
609    @SystemApi
610    public static final int INSTALL_FAILED_NEWER_SDK = -14;
611
612    /**
613     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
614     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
615     * the new package failed because it has specified that it is a test-only
616     * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
617     * flag.
618     * @hide
619     */
620    @SystemApi
621    public static final int INSTALL_FAILED_TEST_ONLY = -15;
622
623    /**
624     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
625     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
626     * the package being installed contains native code, but none that is
627     * compatible with the device's CPU_ABI.
628     * @hide
629     */
630    @SystemApi
631    public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
632
633    /**
634     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
635     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
636     * the new package uses a feature that is not available.
637     * @hide
638     */
639    @SystemApi
640    public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
641
642    // ------ Errors related to sdcard
643    /**
644     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
645     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
646     * a secure container mount point couldn't be accessed on external media.
647     * @hide
648     */
649    @SystemApi
650    public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
651
652    /**
653     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
654     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
655     * the new package couldn't be installed in the specified install
656     * location.
657     * @hide
658     */
659    @SystemApi
660    public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
661
662    /**
663     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
664     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
665     * the new package couldn't be installed in the specified install
666     * location because the media is not available.
667     * @hide
668     */
669    @SystemApi
670    public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
671
672    /**
673     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
674     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
675     * the new package couldn't be installed because the verification timed out.
676     * @hide
677     */
678    @SystemApi
679    public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21;
680
681    /**
682     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
683     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
684     * the new package couldn't be installed because the verification did not succeed.
685     * @hide
686     */
687    @SystemApi
688    public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22;
689
690    /**
691     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
692     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
693     * the package changed from what the calling program expected.
694     * @hide
695     */
696    @SystemApi
697    public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23;
698
699    /**
700     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
701     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
702     * the new package is assigned a different UID than it previously held.
703     * @hide
704     */
705    public static final int INSTALL_FAILED_UID_CHANGED = -24;
706
707    /**
708     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
709     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
710     * the new package has an older version code than the currently installed package.
711     * @hide
712     */
713    public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25;
714
715    /**
716     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
717     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
718     * the old package has target SDK high enough to support runtime permission and
719     * the new package has target SDK low enough to not support runtime permissions.
720     * @hide
721     */
722    @SystemApi
723    public static final int INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE = -26;
724
725    /**
726     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
727     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
728     * if the parser was given a path that is not a file, or does not end with the expected
729     * '.apk' extension.
730     * @hide
731     */
732    @SystemApi
733    public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
734
735    /**
736     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
737     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
738     * if the parser was unable to retrieve the AndroidManifest.xml file.
739     * @hide
740     */
741    @SystemApi
742    public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
743
744    /**
745     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
746     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
747     * if the parser encountered an unexpected exception.
748     * @hide
749     */
750    @SystemApi
751    public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
752
753    /**
754     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
755     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
756     * if the parser did not find any certificates in the .apk.
757     * @hide
758     */
759    @SystemApi
760    public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
761
762    /**
763     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
764     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
765     * if the parser found inconsistent certificates on the files in the .apk.
766     * @hide
767     */
768    @SystemApi
769    public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
770
771    /**
772     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
773     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
774     * if the parser encountered a CertificateEncodingException in one of the
775     * files in the .apk.
776     * @hide
777     */
778    @SystemApi
779    public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
780
781    /**
782     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
783     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
784     * if the parser encountered a bad or missing package name in the manifest.
785     * @hide
786     */
787    @SystemApi
788    public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
789
790    /**
791     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
792     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
793     * if the parser encountered a bad shared user id name in the manifest.
794     * @hide
795     */
796    @SystemApi
797    public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
798
799    /**
800     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
801     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
802     * if the parser encountered some structural problem in the manifest.
803     * @hide
804     */
805    @SystemApi
806    public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
807
808    /**
809     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
810     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
811     * if the parser did not find any actionable tags (instrumentation or application)
812     * in the manifest.
813     * @hide
814     */
815    @SystemApi
816    public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
817
818    /**
819     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
820     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
821     * if the system failed to install the package because of system issues.
822     * @hide
823     */
824    @SystemApi
825    public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
826
827    /**
828     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
829     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
830     * if the system failed to install the package because the user is restricted from installing
831     * apps.
832     * @hide
833     */
834    public static final int INSTALL_FAILED_USER_RESTRICTED = -111;
835
836    /**
837     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
838     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
839     * if the system failed to install the package because it is attempting to define a
840     * permission that is already defined by some existing package.
841     *
842     * <p>The package name of the app which has already defined the permission is passed to
843     * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE}
844     * string extra; and the name of the permission being redefined is passed in the
845     * {@link #EXTRA_EXISTING_PERMISSION} string extra.
846     * @hide
847     */
848    public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112;
849
850    /**
851     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
852     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
853     * if the system failed to install the package because its packaged native code did not
854     * match any of the ABIs supported by the system.
855     *
856     * @hide
857     */
858    public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113;
859
860    /**
861     * Internal return code for NativeLibraryHelper methods to indicate that the package
862     * being processed did not contain any native code. This is placed here only so that
863     * it can belong to the same value space as the other install failure codes.
864     *
865     * @hide
866     */
867    public static final int NO_NATIVE_LIBRARIES = -114;
868
869    /** {@hide} */
870    public static final int INSTALL_FAILED_ABORTED = -115;
871
872    /**
873     * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
874     * package's data directory.
875     *
876     * @hide
877     */
878    public static final int DELETE_KEEP_DATA = 0x00000001;
879
880    /**
881     * Flag parameter for {@link #deletePackage} to indicate that you want the
882     * package deleted for all users.
883     *
884     * @hide
885     */
886    public static final int DELETE_ALL_USERS = 0x00000002;
887
888    /**
889     * Flag parameter for {@link #deletePackage} to indicate that, if you are calling
890     * uninstall on a system that has been updated, then don't do the normal process
891     * of uninstalling the update and rolling back to the older system version (which
892     * needs to happen for all users); instead, just mark the app as uninstalled for
893     * the current user.
894     *
895     * @hide
896     */
897    public static final int DELETE_SYSTEM_APP = 0x00000004;
898
899    /**
900     * Return code for when package deletion succeeds. This is passed to the
901     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
902     * succeeded in deleting the package.
903     *
904     * @hide
905     */
906    public static final int DELETE_SUCCEEDED = 1;
907
908    /**
909     * Deletion failed return code: this is passed to the
910     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
911     * failed to delete the package for an unspecified reason.
912     *
913     * @hide
914     */
915    public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
916
917    /**
918     * Deletion failed return code: this is passed to the
919     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
920     * failed to delete the package because it is the active DevicePolicy
921     * manager.
922     *
923     * @hide
924     */
925    public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
926
927    /**
928     * Deletion failed return code: this is passed to the
929     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
930     * failed to delete the package since the user is restricted.
931     *
932     * @hide
933     */
934    public static final int DELETE_FAILED_USER_RESTRICTED = -3;
935
936    /**
937     * Deletion failed return code: this is passed to the
938     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
939     * failed to delete the package because a profile
940     * or device owner has marked the package as uninstallable.
941     *
942     * @hide
943     */
944    public static final int DELETE_FAILED_OWNER_BLOCKED = -4;
945
946    /** {@hide} */
947    public static final int DELETE_FAILED_ABORTED = -5;
948
949    /**
950     * Return code that is passed to the {@link IPackageMoveObserver} by
951     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
952     * package has been successfully moved by the system.
953     *
954     * @hide
955     */
956    public static final int MOVE_SUCCEEDED = -100;
957
958    /**
959     * Error code that is passed to the {@link IPackageMoveObserver} by
960     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
961     * when the package hasn't been successfully moved by the system
962     * because of insufficient memory on specified media.
963     * @hide
964     */
965    public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
966
967    /**
968     * Error code that is passed to the {@link IPackageMoveObserver} by
969     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
970     * if the specified package doesn't exist.
971     * @hide
972     */
973    public static final int MOVE_FAILED_DOESNT_EXIST = -2;
974
975    /**
976     * Error code that is passed to the {@link IPackageMoveObserver} by
977     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
978     * if the specified package cannot be moved since its a system package.
979     * @hide
980     */
981    public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
982
983    /**
984     * Error code that is passed to the {@link IPackageMoveObserver} by
985     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
986     * if the specified package cannot be moved since its forward locked.
987     * @hide
988     */
989    public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
990
991    /**
992     * Error code that is passed to the {@link IPackageMoveObserver} by
993     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
994     * if the specified package cannot be moved to the specified location.
995     * @hide
996     */
997    public static final int MOVE_FAILED_INVALID_LOCATION = -5;
998
999    /**
1000     * Error code that is passed to the {@link IPackageMoveObserver} by
1001     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
1002     * if the specified package cannot be moved to the specified location.
1003     * @hide
1004     */
1005    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
1006
1007    /**
1008     * Error code that is passed to the {@link IPackageMoveObserver} by
1009     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
1010     * specified package already has an operation pending in the
1011     * {@link PackageHandler} queue.
1012     *
1013     * @hide
1014     */
1015    public static final int MOVE_FAILED_OPERATION_PENDING = -7;
1016
1017    /**
1018     * Flag parameter for {@link #movePackage} to indicate that
1019     * the package should be moved to internal storage if its
1020     * been installed on external media.
1021     * @hide
1022     */
1023    @Deprecated
1024    public static final int MOVE_INTERNAL = 0x00000001;
1025
1026    /**
1027     * Flag parameter for {@link #movePackage} to indicate that
1028     * the package should be moved to external media.
1029     * @hide
1030     */
1031    @Deprecated
1032    public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
1033
1034    /** {@hide} */
1035    public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID";
1036
1037    /**
1038     * Usable by the required verifier as the {@code verificationCode} argument
1039     * for {@link PackageManager#verifyPendingInstall} to indicate that it will
1040     * allow the installation to proceed without any of the optional verifiers
1041     * needing to vote.
1042     *
1043     * @hide
1044     */
1045    public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2;
1046
1047    /**
1048     * Used as the {@code verificationCode} argument for
1049     * {@link PackageManager#verifyPendingInstall} to indicate that the calling
1050     * package verifier allows the installation to proceed.
1051     */
1052    public static final int VERIFICATION_ALLOW = 1;
1053
1054    /**
1055     * Used as the {@code verificationCode} argument for
1056     * {@link PackageManager#verifyPendingInstall} to indicate the calling
1057     * package verifier does not vote to allow the installation to proceed.
1058     */
1059    public static final int VERIFICATION_REJECT = -1;
1060
1061    /**
1062     * Used as the {@code verificationCode} argument for
1063     * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1064     * IntentFilter Verifier confirms that the IntentFilter is verified.
1065     *
1066     * @hide
1067     */
1068    public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1;
1069
1070    /**
1071     * Used as the {@code verificationCode} argument for
1072     * {@link PackageManager#verifyIntentFilter} to indicate that the calling
1073     * IntentFilter Verifier confirms that the IntentFilter is NOT verified.
1074     *
1075     * @hide
1076     */
1077    public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1;
1078
1079    /**
1080     * Internal status code to indicate that an IntentFilter verification result is not specified.
1081     *
1082     * @hide
1083     */
1084    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0;
1085
1086    /**
1087     * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
1088     * to indicate that the User will always be prompted the Intent Disambiguation Dialog if there
1089     * are two or more Intent resolved for the IntentFilter's domain(s).
1090     *
1091     * @hide
1092     */
1093    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1;
1094
1095    /**
1096     * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
1097     * to indicate that the User will never be prompted the Intent Disambiguation Dialog if there
1098     * are two or more resolution of the Intent. The default App for the domain(s) specified in the
1099     * IntentFilter will also ALWAYS be used.
1100     *
1101     * @hide
1102     */
1103    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2;
1104
1105    /**
1106     * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
1107     * to indicate that the User may be prompted the Intent Disambiguation Dialog if there
1108     * are two or more Intent resolved. The default App for the domain(s) specified in the
1109     * IntentFilter will also NEVER be presented to the User.
1110     *
1111     * @hide
1112     */
1113    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3;
1114
1115    /**
1116     * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus}
1117     * to indicate that this app should always be considered as an ambiguous candidate for
1118     * handling the matching Intent even if there are other candidate apps in the "always"
1119     * state.  Put another way: if there are any 'always ask' apps in a set of more than
1120     * one candidate app, then a disambiguation is *always* presented even if there is
1121     * another candidate app with the 'always' state.
1122     *
1123     * @hide
1124     */
1125    public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4;
1126
1127    /**
1128     * Can be used as the {@code millisecondsToDelay} argument for
1129     * {@link PackageManager#extendVerificationTimeout}. This is the
1130     * maximum time {@code PackageManager} waits for the verification
1131     * agent to return (in milliseconds).
1132     */
1133    public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000;
1134
1135    /**
1136     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
1137     * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
1138     * lag in sound input or output.
1139     */
1140    @SdkConstant(SdkConstantType.FEATURE)
1141    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
1142
1143    /**
1144     * Feature for {@link #getSystemAvailableFeatures} and
1145     * {@link #hasSystemFeature}: The device includes at least one form of audio
1146     * output, such as speakers, audio jack or streaming over bluetooth
1147     */
1148    @SdkConstant(SdkConstantType.FEATURE)
1149    public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
1150
1151    /**
1152     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1153     * The device has professional audio level of functionality and performance.
1154     */
1155    @SdkConstant(SdkConstantType.FEATURE)
1156    public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
1157
1158    /**
1159     * Feature for {@link #getSystemAvailableFeatures} and
1160     * {@link #hasSystemFeature}: The device is capable of communicating with
1161     * other devices via Bluetooth.
1162     */
1163    @SdkConstant(SdkConstantType.FEATURE)
1164    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
1165
1166    /**
1167     * Feature for {@link #getSystemAvailableFeatures} and
1168     * {@link #hasSystemFeature}: The device is capable of communicating with
1169     * other devices via Bluetooth Low Energy radio.
1170     */
1171    @SdkConstant(SdkConstantType.FEATURE)
1172    public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le";
1173
1174    /**
1175     * Feature for {@link #getSystemAvailableFeatures} and
1176     * {@link #hasSystemFeature}: The device has a camera facing away
1177     * from the screen.
1178     */
1179    @SdkConstant(SdkConstantType.FEATURE)
1180    public static final String FEATURE_CAMERA = "android.hardware.camera";
1181
1182    /**
1183     * Feature for {@link #getSystemAvailableFeatures} and
1184     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
1185     */
1186    @SdkConstant(SdkConstantType.FEATURE)
1187    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
1188
1189    /**
1190     * Feature for {@link #getSystemAvailableFeatures} and
1191     * {@link #hasSystemFeature}: The device has at least one camera pointing in
1192     * some direction, or can support an external camera being connected to it.
1193     */
1194    @SdkConstant(SdkConstantType.FEATURE)
1195    public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any";
1196
1197    /**
1198     * Feature for {@link #getSystemAvailableFeatures} and
1199     * {@link #hasSystemFeature}: The device can support having an external camera connected to it.
1200     * The external camera may not always be connected or available to applications to use.
1201     */
1202    @SdkConstant(SdkConstantType.FEATURE)
1203    public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external";
1204
1205    /**
1206     * Feature for {@link #getSystemAvailableFeatures} and
1207     * {@link #hasSystemFeature}: The device's camera supports flash.
1208     */
1209    @SdkConstant(SdkConstantType.FEATURE)
1210    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
1211
1212    /**
1213     * Feature for {@link #getSystemAvailableFeatures} and
1214     * {@link #hasSystemFeature}: The device has a front facing camera.
1215     */
1216    @SdkConstant(SdkConstantType.FEATURE)
1217    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
1218
1219    /**
1220     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1221     * of the cameras on the device supports the
1222     * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware}
1223     * capability level.
1224     */
1225    @SdkConstant(SdkConstantType.FEATURE)
1226    public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full";
1227
1228    /**
1229     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1230     * of the cameras on the device supports the
1231     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor}
1232     * capability level.
1233     */
1234    @SdkConstant(SdkConstantType.FEATURE)
1235    public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR =
1236            "android.hardware.camera.capability.manual_sensor";
1237
1238    /**
1239     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1240     * of the cameras on the device supports the
1241     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing}
1242     * capability level.
1243     */
1244    @SdkConstant(SdkConstantType.FEATURE)
1245    public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING =
1246            "android.hardware.camera.capability.manual_post_processing";
1247
1248    /**
1249     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one
1250     * of the cameras on the device supports the
1251     * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW}
1252     * capability level.
1253     */
1254    @SdkConstant(SdkConstantType.FEATURE)
1255    public static final String FEATURE_CAMERA_CAPABILITY_RAW =
1256            "android.hardware.camera.capability.raw";
1257
1258    /**
1259     * Feature for {@link #getSystemAvailableFeatures} and
1260     * {@link #hasSystemFeature}: The device is capable of communicating with
1261     * consumer IR devices.
1262     */
1263    @SdkConstant(SdkConstantType.FEATURE)
1264    public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir";
1265
1266    /**
1267     * Feature for {@link #getSystemAvailableFeatures} and
1268     * {@link #hasSystemFeature}: The device supports one or more methods of
1269     * reporting current location.
1270     */
1271    @SdkConstant(SdkConstantType.FEATURE)
1272    public static final String FEATURE_LOCATION = "android.hardware.location";
1273
1274    /**
1275     * Feature for {@link #getSystemAvailableFeatures} and
1276     * {@link #hasSystemFeature}: The device has a Global Positioning System
1277     * receiver and can report precise location.
1278     */
1279    @SdkConstant(SdkConstantType.FEATURE)
1280    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
1281
1282    /**
1283     * Feature for {@link #getSystemAvailableFeatures} and
1284     * {@link #hasSystemFeature}: The device can report location with coarse
1285     * accuracy using a network-based geolocation system.
1286     */
1287    @SdkConstant(SdkConstantType.FEATURE)
1288    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
1289
1290    /**
1291     * Feature for {@link #getSystemAvailableFeatures} and
1292     * {@link #hasSystemFeature}: The device can record audio via a
1293     * microphone.
1294     */
1295    @SdkConstant(SdkConstantType.FEATURE)
1296    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
1297
1298    /**
1299     * Feature for {@link #getSystemAvailableFeatures} and
1300     * {@link #hasSystemFeature}: The device can communicate using Near-Field
1301     * Communications (NFC).
1302     */
1303    @SdkConstant(SdkConstantType.FEATURE)
1304    public static final String FEATURE_NFC = "android.hardware.nfc";
1305
1306    /**
1307     * Feature for {@link #getSystemAvailableFeatures} and
1308     * {@link #hasSystemFeature}: The device supports host-
1309     * based NFC card emulation.
1310     *
1311     * TODO remove when depending apps have moved to new constant.
1312     * @hide
1313     * @deprecated
1314     */
1315    @Deprecated
1316    @SdkConstant(SdkConstantType.FEATURE)
1317    public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce";
1318
1319    /**
1320     * Feature for {@link #getSystemAvailableFeatures} and
1321     * {@link #hasSystemFeature}: The device supports host-
1322     * based NFC card emulation.
1323     */
1324    @SdkConstant(SdkConstantType.FEATURE)
1325    public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce";
1326
1327    /**
1328     * Feature for {@link #getSystemAvailableFeatures} and
1329     * {@link #hasSystemFeature}: The device supports the OpenGL ES
1330     * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt">
1331     * Android Extension Pack</a>.
1332     */
1333    @SdkConstant(SdkConstantType.FEATURE)
1334    public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep";
1335
1336    /**
1337     * Feature for {@link #getSystemAvailableFeatures} and
1338     * {@link #hasSystemFeature}: The device includes an accelerometer.
1339     */
1340    @SdkConstant(SdkConstantType.FEATURE)
1341    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
1342
1343    /**
1344     * Feature for {@link #getSystemAvailableFeatures} and
1345     * {@link #hasSystemFeature}: The device includes a barometer (air
1346     * pressure sensor.)
1347     */
1348    @SdkConstant(SdkConstantType.FEATURE)
1349    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
1350
1351    /**
1352     * Feature for {@link #getSystemAvailableFeatures} and
1353     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
1354     */
1355    @SdkConstant(SdkConstantType.FEATURE)
1356    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
1357
1358    /**
1359     * Feature for {@link #getSystemAvailableFeatures} and
1360     * {@link #hasSystemFeature}: The device includes a gyroscope.
1361     */
1362    @SdkConstant(SdkConstantType.FEATURE)
1363    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
1364
1365    /**
1366     * Feature for {@link #getSystemAvailableFeatures} and
1367     * {@link #hasSystemFeature}: The device includes a light sensor.
1368     */
1369    @SdkConstant(SdkConstantType.FEATURE)
1370    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
1371
1372    /**
1373     * Feature for {@link #getSystemAvailableFeatures} and
1374     * {@link #hasSystemFeature}: The device includes a proximity sensor.
1375     */
1376    @SdkConstant(SdkConstantType.FEATURE)
1377    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
1378
1379    /**
1380     * Feature for {@link #getSystemAvailableFeatures} and
1381     * {@link #hasSystemFeature}: The device includes a hardware step counter.
1382     */
1383    @SdkConstant(SdkConstantType.FEATURE)
1384    public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter";
1385
1386    /**
1387     * Feature for {@link #getSystemAvailableFeatures} and
1388     * {@link #hasSystemFeature}: The device includes a hardware step detector.
1389     */
1390    @SdkConstant(SdkConstantType.FEATURE)
1391    public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector";
1392
1393    /**
1394     * Feature for {@link #getSystemAvailableFeatures} and
1395     * {@link #hasSystemFeature}: The device includes a heart rate monitor.
1396     */
1397    @SdkConstant(SdkConstantType.FEATURE)
1398    public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate";
1399
1400    /**
1401     * Feature for {@link #getSystemAvailableFeatures} and
1402     * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram.
1403     */
1404    @SdkConstant(SdkConstantType.FEATURE)
1405    public static final String FEATURE_SENSOR_HEART_RATE_ECG =
1406            "android.hardware.sensor.heartrate.ecg";
1407
1408    /**
1409     * Feature for {@link #getSystemAvailableFeatures} and
1410     * {@link #hasSystemFeature}: The device includes a relative humidity sensor.
1411     */
1412    @SdkConstant(SdkConstantType.FEATURE)
1413    public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY =
1414            "android.hardware.sensor.relative_humidity";
1415
1416    /**
1417     * Feature for {@link #getSystemAvailableFeatures} and
1418     * {@link #hasSystemFeature}: The device includes an ambient temperature sensor.
1419     */
1420    @SdkConstant(SdkConstantType.FEATURE)
1421    public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE =
1422            "android.hardware.sensor.ambient_temperature";
1423
1424    /**
1425     * Feature for {@link #getSystemAvailableFeatures} and
1426     * {@link #hasSystemFeature}: The device supports high fidelity sensor processing
1427     * capabilities.
1428     */
1429    @SdkConstant(SdkConstantType.FEATURE)
1430    public static final String FEATURE_HIFI_SENSORS =
1431            "android.hardware.sensor.hifi_sensors";
1432
1433    /**
1434     * Feature for {@link #getSystemAvailableFeatures} and
1435     * {@link #hasSystemFeature}: The device has a telephony radio with data
1436     * communication support.
1437     */
1438    @SdkConstant(SdkConstantType.FEATURE)
1439    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
1440
1441    /**
1442     * Feature for {@link #getSystemAvailableFeatures} and
1443     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
1444     */
1445    @SdkConstant(SdkConstantType.FEATURE)
1446    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
1447
1448    /**
1449     * Feature for {@link #getSystemAvailableFeatures} and
1450     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
1451     */
1452    @SdkConstant(SdkConstantType.FEATURE)
1453    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
1454
1455    /**
1456     * Feature for {@link #getSystemAvailableFeatures} and
1457     * {@link #hasSystemFeature}: The device supports connecting to USB devices
1458     * as the USB host.
1459     */
1460    @SdkConstant(SdkConstantType.FEATURE)
1461    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
1462
1463    /**
1464     * Feature for {@link #getSystemAvailableFeatures} and
1465     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
1466     */
1467    @SdkConstant(SdkConstantType.FEATURE)
1468    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
1469
1470    /**
1471     * Feature for {@link #getSystemAvailableFeatures} and
1472     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
1473     */
1474    @SdkConstant(SdkConstantType.FEATURE)
1475    public static final String FEATURE_SIP = "android.software.sip";
1476
1477    /**
1478     * Feature for {@link #getSystemAvailableFeatures} and
1479     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
1480     */
1481    @SdkConstant(SdkConstantType.FEATURE)
1482    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
1483
1484    /**
1485     * Feature for {@link #getSystemAvailableFeatures} and
1486     * {@link #hasSystemFeature}: The Connection Service API is enabled on the device.
1487     */
1488    @SdkConstant(SdkConstantType.FEATURE)
1489    public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice";
1490
1491    /**
1492     * Feature for {@link #getSystemAvailableFeatures} and
1493     * {@link #hasSystemFeature}: The device's display has a touch screen.
1494     */
1495    @SdkConstant(SdkConstantType.FEATURE)
1496    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
1497
1498    /**
1499     * Feature for {@link #getSystemAvailableFeatures} and
1500     * {@link #hasSystemFeature}: The device's touch screen supports
1501     * multitouch sufficient for basic two-finger gesture detection.
1502     */
1503    @SdkConstant(SdkConstantType.FEATURE)
1504    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
1505
1506    /**
1507     * Feature for {@link #getSystemAvailableFeatures} and
1508     * {@link #hasSystemFeature}: The device's touch screen is capable of
1509     * tracking two or more fingers fully independently.
1510     */
1511    @SdkConstant(SdkConstantType.FEATURE)
1512    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
1513
1514    /**
1515     * Feature for {@link #getSystemAvailableFeatures} and
1516     * {@link #hasSystemFeature}: The device's touch screen is capable of
1517     * tracking a full hand of fingers fully independently -- that is, 5 or
1518     * more simultaneous independent pointers.
1519     */
1520    @SdkConstant(SdkConstantType.FEATURE)
1521    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
1522
1523    /**
1524     * Feature for {@link #getSystemAvailableFeatures} and
1525     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1526     * does support touch emulation for basic events. For instance, the
1527     * device might use a mouse or remote control to drive a cursor, and
1528     * emulate basic touch pointer events like down, up, drag, etc. All
1529     * devices that support android.hardware.touchscreen or a sub-feature are
1530     * presumed to also support faketouch.
1531     */
1532    @SdkConstant(SdkConstantType.FEATURE)
1533    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
1534
1535    /**
1536     * Feature for {@link #getSystemAvailableFeatures} and
1537     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1538     * does support touch emulation for basic events that supports distinct
1539     * tracking of two or more fingers.  This is an extension of
1540     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1541     * that unlike a distinct multitouch screen as defined by
1542     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
1543     * devices will not actually provide full two-finger gestures since the
1544     * input is being transformed to cursor movement on the screen.  That is,
1545     * single finger gestures will move a cursor; two-finger swipes will
1546     * result in single-finger touch events; other two-finger gestures will
1547     * result in the corresponding two-finger touch event.
1548     */
1549    @SdkConstant(SdkConstantType.FEATURE)
1550    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
1551
1552    /**
1553     * Feature for {@link #getSystemAvailableFeatures} and
1554     * {@link #hasSystemFeature}: The device does not have a touch screen, but
1555     * does support touch emulation for basic events that supports tracking
1556     * a hand of fingers (5 or more fingers) fully independently.
1557     * This is an extension of
1558     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
1559     * that unlike a multitouch screen as defined by
1560     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
1561     * gestures can be detected due to the limitations described for
1562     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
1563     */
1564    @SdkConstant(SdkConstantType.FEATURE)
1565    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
1566
1567    /**
1568     * Feature for {@link #getSystemAvailableFeatures} and
1569     * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint.
1570      */
1571    @SdkConstant(SdkConstantType.FEATURE)
1572    public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint";
1573
1574    /**
1575     * Feature for {@link #getSystemAvailableFeatures} and
1576     * {@link #hasSystemFeature}: The device supports portrait orientation
1577     * screens.  For backwards compatibility, you can assume that if neither
1578     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
1579     * both portrait and landscape.
1580     */
1581    @SdkConstant(SdkConstantType.FEATURE)
1582    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
1583
1584    /**
1585     * Feature for {@link #getSystemAvailableFeatures} and
1586     * {@link #hasSystemFeature}: The device supports landscape orientation
1587     * screens.  For backwards compatibility, you can assume that if neither
1588     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
1589     * both portrait and landscape.
1590     */
1591    @SdkConstant(SdkConstantType.FEATURE)
1592    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
1593
1594    /**
1595     * Feature for {@link #getSystemAvailableFeatures} and
1596     * {@link #hasSystemFeature}: The device supports live wallpapers.
1597     */
1598    @SdkConstant(SdkConstantType.FEATURE)
1599    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
1600    /**
1601     * Feature for {@link #getSystemAvailableFeatures} and
1602     * {@link #hasSystemFeature}: The device supports app widgets.
1603     */
1604    @SdkConstant(SdkConstantType.FEATURE)
1605    public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets";
1606
1607    /**
1608     * @hide
1609     * Feature for {@link #getSystemAvailableFeatures} and
1610     * {@link #hasSystemFeature}: The device supports
1611     * {@link android.service.voice.VoiceInteractionService} and
1612     * {@link android.app.VoiceInteractor}.
1613     */
1614    @SdkConstant(SdkConstantType.FEATURE)
1615    public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers";
1616
1617
1618    /**
1619     * Feature for {@link #getSystemAvailableFeatures} and
1620     * {@link #hasSystemFeature}: The device supports a home screen that is replaceable
1621     * by third party applications.
1622     */
1623    @SdkConstant(SdkConstantType.FEATURE)
1624    public static final String FEATURE_HOME_SCREEN = "android.software.home_screen";
1625
1626    /**
1627     * Feature for {@link #getSystemAvailableFeatures} and
1628     * {@link #hasSystemFeature}: The device supports adding new input methods implemented
1629     * with the {@link android.inputmethodservice.InputMethodService} API.
1630     */
1631    @SdkConstant(SdkConstantType.FEATURE)
1632    public static final String FEATURE_INPUT_METHODS = "android.software.input_methods";
1633
1634    /**
1635     * Feature for {@link #getSystemAvailableFeatures} and
1636     * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins.
1637     */
1638    @SdkConstant(SdkConstantType.FEATURE)
1639    public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin";
1640
1641    /**
1642     * Feature for {@link #getSystemAvailableFeatures} and
1643     * {@link #hasSystemFeature}: The device supports leanback UI. This is
1644     * typically used in a living room television experience, but is a software
1645     * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this
1646     * feature will use resources associated with the "television" UI mode.
1647     */
1648    @SdkConstant(SdkConstantType.FEATURE)
1649    public static final String FEATURE_LEANBACK = "android.software.leanback";
1650
1651    /**
1652     * Feature for {@link #getSystemAvailableFeatures} and
1653     * {@link #hasSystemFeature}: The device supports only leanback UI. Only
1654     * applications designed for this experience should be run, though this is
1655     * not enforced by the system.
1656     * @hide
1657     */
1658    @SdkConstant(SdkConstantType.FEATURE)
1659    public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only";
1660
1661    /**
1662     * Feature for {@link #getSystemAvailableFeatures} and
1663     * {@link #hasSystemFeature}: The device supports live TV and can display
1664     * contents from TV inputs implemented with the
1665     * {@link android.media.tv.TvInputService} API.
1666     */
1667    @SdkConstant(SdkConstantType.FEATURE)
1668    public static final String FEATURE_LIVE_TV = "android.software.live_tv";
1669
1670    /**
1671     * Feature for {@link #getSystemAvailableFeatures} and
1672     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
1673     */
1674    @SdkConstant(SdkConstantType.FEATURE)
1675    public static final String FEATURE_WIFI = "android.hardware.wifi";
1676
1677    /**
1678     * Feature for {@link #getSystemAvailableFeatures} and
1679     * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking.
1680     */
1681    @SdkConstant(SdkConstantType.FEATURE)
1682    public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct";
1683
1684    /**
1685     * Feature for {@link #getSystemAvailableFeatures} and
1686     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1687     * on a vehicle headunit. A headunit here is defined to be inside a
1688     * vehicle that may or may not be moving. A headunit uses either a
1689     * primary display in the center console and/or additional displays in
1690     * the instrument cluster or elsewhere in the vehicle. Headunit display(s)
1691     * have limited size and resolution. The user will likely be focused on
1692     * driving so limiting driver distraction is a primary concern. User input
1693     * can be a variety of hard buttons, touch, rotary controllers and even mouse-
1694     * like interfaces.
1695     */
1696    @SdkConstant(SdkConstantType.FEATURE)
1697    public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
1698
1699    /**
1700     * Feature for {@link #getSystemAvailableFeatures} and
1701     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1702     * on a television.  Television here is defined to be a typical living
1703     * room television experience: displayed on a big screen, where the user
1704     * is sitting far away from it, and the dominant form of input will be
1705     * something like a DPAD, not through touch or mouse.
1706     * @deprecated use {@link #FEATURE_LEANBACK} instead.
1707     */
1708    @Deprecated
1709    @SdkConstant(SdkConstantType.FEATURE)
1710    public static final String FEATURE_TELEVISION = "android.hardware.type.television";
1711
1712    /**
1713     * Feature for {@link #getSystemAvailableFeatures} and
1714     * {@link #hasSystemFeature}: This is a device dedicated to showing UI
1715     * on a watch. A watch here is defined to be a device worn on the body, perhaps on
1716     * the wrist. The user is very close when interacting with the device.
1717     */
1718    @SdkConstant(SdkConstantType.FEATURE)
1719    public static final String FEATURE_WATCH = "android.hardware.type.watch";
1720
1721    /**
1722     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1723     * The device supports printing.
1724     */
1725    @SdkConstant(SdkConstantType.FEATURE)
1726    public static final String FEATURE_PRINTING = "android.software.print";
1727
1728    /**
1729     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1730     * The device can perform backup and restore operations on installed applications.
1731     */
1732    @SdkConstant(SdkConstantType.FEATURE)
1733    public static final String FEATURE_BACKUP = "android.software.backup";
1734
1735    /**
1736     * Feature for {@link #getSystemAvailableFeatures} and
1737     * {@link #hasSystemFeature}: The device supports freeform window management.
1738     * Windows have title bars and can be moved and resized.
1739     */
1740    // If this feature is present, you also need to set
1741    // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay.
1742    @SdkConstant(SdkConstantType.FEATURE)
1743    public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT
1744            = "android.software.freeform_window_management";
1745
1746    /**
1747     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1748     * The device supports creating secondary users and managed profiles via
1749     * {@link DevicePolicyManager}.
1750     */
1751    @SdkConstant(SdkConstantType.FEATURE)
1752    public static final String FEATURE_MANAGED_USERS = "android.software.managed_users";
1753
1754    /**
1755     * @hide
1756     * TODO: Remove after dependencies updated b/17392243
1757     */
1758    public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users";
1759
1760    /**
1761     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1762     * The device supports verified boot.
1763     */
1764    @SdkConstant(SdkConstantType.FEATURE)
1765    public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot";
1766
1767    /**
1768     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1769     * The device supports secure removal of users. When a user is deleted the data associated
1770     * with that user is securely deleted and no longer available.
1771     */
1772    @SdkConstant(SdkConstantType.FEATURE)
1773    public static final String FEATURE_SECURELY_REMOVES_USERS
1774            = "android.software.securely_removes_users";
1775
1776    /**
1777     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1778     * The device has a full implementation of the android.webkit.* APIs. Devices
1779     * lacking this feature will not have a functioning WebView implementation.
1780     */
1781    @SdkConstant(SdkConstantType.FEATURE)
1782    public static final String FEATURE_WEBVIEW = "android.software.webview";
1783
1784    /**
1785     * Feature for {@link #getSystemAvailableFeatures} and
1786     * {@link #hasSystemFeature}: This device supports ethernet.
1787     * @hide
1788     */
1789    @SdkConstant(SdkConstantType.FEATURE)
1790    public static final String FEATURE_ETHERNET = "android.hardware.ethernet";
1791
1792    /**
1793     * Feature for {@link #getSystemAvailableFeatures} and
1794     * {@link #hasSystemFeature}: This device supports HDMI-CEC.
1795     * @hide
1796     */
1797    @SdkConstant(SdkConstantType.FEATURE)
1798    public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec";
1799
1800    /**
1801     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1802     * The device has all of the inputs necessary to be considered a compatible game controller, or
1803     * includes a compatible game controller in the box.
1804     */
1805    @SdkConstant(SdkConstantType.FEATURE)
1806    public static final String FEATURE_GAMEPAD = "android.hardware.gamepad";
1807
1808    /**
1809     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
1810     * The device has a full implementation of the android.media.midi.* APIs.
1811     */
1812    @SdkConstant(SdkConstantType.FEATURE)
1813    public static final String FEATURE_MIDI = "android.software.midi";
1814
1815    /**
1816     * Action to external storage service to clean out removed apps.
1817     * @hide
1818     */
1819    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1820            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1821
1822    /**
1823     * Extra field name for the URI to a verification file. Passed to a package
1824     * verifier.
1825     *
1826     * @hide
1827     */
1828    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1829
1830    /**
1831     * Extra field name for the ID of a package pending verification. Passed to
1832     * a package verifier and is used to call back to
1833     * {@link PackageManager#verifyPendingInstall(int, int)}
1834     */
1835    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1836
1837    /**
1838     * Extra field name for the package identifier which is trying to install
1839     * the package.
1840     *
1841     * @hide
1842     */
1843    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1844            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1845
1846    /**
1847     * Extra field name for the requested install flags for a package pending
1848     * verification. Passed to a package verifier.
1849     *
1850     * @hide
1851     */
1852    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1853            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1854
1855    /**
1856     * Extra field name for the uid of who is requesting to install
1857     * the package.
1858     *
1859     * @hide
1860     */
1861    public static final String EXTRA_VERIFICATION_INSTALLER_UID
1862            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1863
1864    /**
1865     * Extra field name for the package name of a package pending verification.
1866     *
1867     * @hide
1868     */
1869    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1870            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1871    /**
1872     * Extra field name for the result of a verification, either
1873     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1874     * Passed to package verifiers after a package is verified.
1875     */
1876    public static final String EXTRA_VERIFICATION_RESULT
1877            = "android.content.pm.extra.VERIFICATION_RESULT";
1878
1879    /**
1880     * Extra field name for the version code of a package pending verification.
1881     *
1882     * @hide
1883     */
1884    public static final String EXTRA_VERIFICATION_VERSION_CODE
1885            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1886
1887    /**
1888     * Extra field name for the ID of a intent filter pending verification. Passed to
1889     * an intent filter verifier and is used to call back to
1890     * {@link PackageManager#verifyIntentFilter(int, int)}
1891     *
1892     * @hide
1893     */
1894    public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
1895            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
1896
1897    /**
1898     * Extra field name for the scheme used for an intent filter pending verification. Passed to
1899     * an intent filter verifier and is used to construct the URI to verify against.
1900     *
1901     * Usually this is "https"
1902     *
1903     * @hide
1904     */
1905    public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
1906            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
1907
1908    /**
1909     * Extra field name for the host names to be used for an intent filter pending verification.
1910     * Passed to an intent filter verifier and is used to construct the URI to verify the
1911     * intent filter.
1912     *
1913     * This is a space delimited list of hosts.
1914     *
1915     * @hide
1916     */
1917    public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
1918            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
1919
1920    /**
1921     * Extra field name for the package name to be used for an intent filter pending verification.
1922     * Passed to an intent filter verifier and is used to check the verification responses coming
1923     * from the hosts. Each host response will need to include the package name of APK containing
1924     * the intent filter.
1925     *
1926     * @hide
1927     */
1928    public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
1929            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
1930
1931    /**
1932     * The action used to request that the user approve a permission request
1933     * from the application.
1934     *
1935     * @hide
1936     */
1937    @SystemApi
1938    public static final String ACTION_REQUEST_PERMISSIONS =
1939            "android.content.pm.action.REQUEST_PERMISSIONS";
1940
1941    /**
1942     * The names of the requested permissions.
1943     * <p>
1944     * <strong>Type:</strong> String[]
1945     * </p>
1946     *
1947     * @hide
1948     */
1949    @SystemApi
1950    public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
1951            "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
1952
1953    /**
1954     * The results from the permissions request.
1955     * <p>
1956     * <strong>Type:</strong> int[] of #PermissionResult
1957     * </p>
1958     *
1959     * @hide
1960     */
1961    @SystemApi
1962    public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
1963            = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
1964
1965    /**
1966     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1967     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
1968     * the existing definition for the permission.
1969     * @hide
1970     */
1971    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1972            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1973
1974    /**
1975     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1976     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
1977     * being redundantly defined by the package being installed.
1978     * @hide
1979     */
1980    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1981            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1982
1983   /**
1984    * Permission flag: The permission is set in its current state
1985    * by the user and apps can still request it at runtime.
1986    *
1987    * @hide
1988    */
1989    public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
1990
1991    /**
1992     * Permission flag: The permission is set in its current state
1993     * by the user and it is fixed, i.e. apps can no longer request
1994     * this permission.
1995     *
1996     * @hide
1997     */
1998    public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
1999
2000    /**
2001     * Permission flag: The permission is set in its current state
2002     * by device policy and neither apps nor the user can change
2003     * its state.
2004     *
2005     * @hide
2006     */
2007    public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
2008
2009    /**
2010     * Permission flag: The permission is set in a granted state but
2011     * access to resources it guards is restricted by other means to
2012     * enable revoking a permission on legacy apps that do not support
2013     * runtime permissions. If this permission is upgraded to runtime
2014     * because the app was updated to support runtime permissions, the
2015     * the permission will be revoked in the upgrade process.
2016     *
2017     * @hide
2018     */
2019    public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
2020
2021    /**
2022     * Permission flag: The permission is set in its current state
2023     * because the app is a component that is a part of the system.
2024     *
2025     * @hide
2026     */
2027    public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
2028
2029    /**
2030     * Permission flag: The permission is granted by default because it
2031     * enables app functionality that is expected to work out-of-the-box
2032     * for providing a smooth user experience. For example, the phone app
2033     * is expected to have the phone permission.
2034     *
2035     * @hide
2036     */
2037    public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
2038
2039    /**
2040     * Permission flag: The permission has to be reviewed before any of
2041     * the app components can run.
2042     *
2043     * @hide
2044     */
2045    public static final int FLAG_PERMISSION_REVIEW_REQUIRED =  1 << 6;
2046
2047    /**
2048     * Mask for all permission flags.
2049     *
2050     * @hide
2051     */
2052    @SystemApi
2053    public static final int MASK_PERMISSION_FLAGS = 0xFF;
2054
2055    /**
2056     * Retrieve overall information about an application package that is
2057     * installed on the system.
2058     * <p>
2059     * Throws {@link NameNotFoundException} if a package with the given name can
2060     * not be found on the system.
2061     *
2062     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2063     *            desired package.
2064     * @param flags Additional option flags. Use any combination of
2065     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2066     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2067     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2068     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2069     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
2070     *            modify the data returned.
2071     * @return A PackageInfo object containing information about the
2072     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
2073     *         package is not found in the list of installed applications, the
2074     *         package information is retrieved from the list of uninstalled
2075     *         applications (which includes installed applications as well as
2076     *         applications with data directory i.e. applications which had been
2077     *         deleted with {@code DONT_DELETE_DATA} flag set).
2078     * @see #GET_ACTIVITIES
2079     * @see #GET_GIDS
2080     * @see #GET_CONFIGURATIONS
2081     * @see #GET_INSTRUMENTATION
2082     * @see #GET_PERMISSIONS
2083     * @see #GET_PROVIDERS
2084     * @see #GET_RECEIVERS
2085     * @see #GET_SERVICES
2086     * @see #GET_SIGNATURES
2087     * @see #GET_UNINSTALLED_PACKAGES
2088     */
2089    public abstract PackageInfo getPackageInfo(String packageName, int flags)
2090            throws NameNotFoundException;
2091
2092    /**
2093     * @hide
2094     * Retrieve overall information about an application package that is
2095     * installed on the system.
2096     * <p>
2097     * Throws {@link NameNotFoundException} if a package with the given name can
2098     * not be found on the system.
2099     *
2100     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2101     *            desired package.
2102     * @param flags Additional option flags. Use any combination of
2103     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2104     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2105     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2106     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2107     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
2108     *            modify the data returned.
2109     * @param userId The user id.
2110     * @return A PackageInfo object containing information about the
2111     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
2112     *         package is not found in the list of installed applications, the
2113     *         package information is retrieved from the list of uninstalled
2114     *         applications (which includes installed applications as well as
2115     *         applications with data directory i.e. applications which had been
2116     *         deleted with {@code DONT_DELETE_DATA} flag set).
2117     * @see #GET_ACTIVITIES
2118     * @see #GET_GIDS
2119     * @see #GET_CONFIGURATIONS
2120     * @see #GET_INSTRUMENTATION
2121     * @see #GET_PERMISSIONS
2122     * @see #GET_PROVIDERS
2123     * @see #GET_RECEIVERS
2124     * @see #GET_SERVICES
2125     * @see #GET_SIGNATURES
2126     * @see #GET_UNINSTALLED_PACKAGES
2127     */
2128    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2129    public abstract PackageInfo getPackageInfoAsUser(String packageName, int flags, int userId)
2130            throws NameNotFoundException;
2131
2132    /**
2133     * Map from the current package names in use on the device to whatever
2134     * the current canonical name of that package is.
2135     * @param names Array of current names to be mapped.
2136     * @return Returns an array of the same size as the original, containing
2137     * the canonical name for each package.
2138     */
2139    public abstract String[] currentToCanonicalPackageNames(String[] names);
2140
2141    /**
2142     * Map from a packages canonical name to the current name in use on the device.
2143     * @param names Array of new names to be mapped.
2144     * @return Returns an array of the same size as the original, containing
2145     * the current name for each package.
2146     */
2147    public abstract String[] canonicalToCurrentPackageNames(String[] names);
2148
2149    /**
2150     * Returns a "good" intent to launch a front-door activity in a package.
2151     * This is used, for example, to implement an "open" button when browsing
2152     * through packages.  The current implementation looks first for a main
2153     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
2154     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
2155     * <code>null</code> if neither are found.
2156     *
2157     * @param packageName The name of the package to inspect.
2158     *
2159     * @return A fully-qualified {@link Intent} that can be used to launch the
2160     * main activity in the package. Returns <code>null</code> if the package
2161     * does not contain such an activity, or if <em>packageName</em> is not
2162     * recognized.
2163     */
2164    public abstract Intent getLaunchIntentForPackage(String packageName);
2165
2166    /**
2167     * Return a "good" intent to launch a front-door Leanback activity in a
2168     * package, for use for example to implement an "open" button when browsing
2169     * through packages. The current implementation will look for a main
2170     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
2171     * return null if no main leanback activities are found.
2172     * <p>
2173     * Throws {@link NameNotFoundException} if a package with the given name
2174     * cannot be found on the system.
2175     *
2176     * @param packageName The name of the package to inspect.
2177     * @return Returns either a fully-qualified Intent that can be used to launch
2178     *         the main Leanback activity in the package, or null if the package
2179     *         does not contain such an activity.
2180     */
2181    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
2182
2183    /**
2184     * Return an array of all of the secondary group-ids that have been assigned
2185     * to a package.
2186     * <p>
2187     * Throws {@link NameNotFoundException} if a package with the given name
2188     * cannot be found on the system.
2189     *
2190     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2191     *            desired package.
2192     * @return Returns an int array of the assigned gids, or null if there are
2193     *         none.
2194     */
2195    public abstract int[] getPackageGids(String packageName)
2196            throws NameNotFoundException;
2197
2198    /**
2199     * @hide Return the uid associated with the given package name for the
2200     * given user.
2201     *
2202     * <p>Throws {@link NameNotFoundException} if a package with the given
2203     * name can not be found on the system.
2204     *
2205     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2206     *                    desired package.
2207     * @param userHandle The user handle identifier to look up the package under.
2208     *
2209     * @return Returns an integer uid who owns the given package name.
2210     */
2211    public abstract int getPackageUid(String packageName, int userHandle)
2212            throws NameNotFoundException;
2213
2214    /**
2215     * Retrieve all of the information we know about a particular permission.
2216     *
2217     * <p>Throws {@link NameNotFoundException} if a permission with the given
2218     * name cannot be found on the system.
2219     *
2220     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
2221     *             of the permission you are interested in.
2222     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2223     * retrieve any meta-data associated with the permission.
2224     *
2225     * @return Returns a {@link PermissionInfo} containing information about the
2226     *         permission.
2227     */
2228    public abstract PermissionInfo getPermissionInfo(String name, int flags)
2229            throws NameNotFoundException;
2230
2231    /**
2232     * Query for all of the permissions associated with a particular group.
2233     *
2234     * <p>Throws {@link NameNotFoundException} if the given group does not
2235     * exist.
2236     *
2237     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
2238     *             of the permission group you are interested in.  Use null to
2239     *             find all of the permissions not associated with a group.
2240     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2241     * retrieve any meta-data associated with the permissions.
2242     *
2243     * @return Returns a list of {@link PermissionInfo} containing information
2244     * about all of the permissions in the given group.
2245     */
2246    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
2247            int flags) throws NameNotFoundException;
2248
2249    /**
2250     * Retrieve all of the information we know about a particular group of
2251     * permissions.
2252     *
2253     * <p>Throws {@link NameNotFoundException} if a permission group with the given
2254     * name cannot be found on the system.
2255     *
2256     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
2257     *             of the permission you are interested in.
2258     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2259     * retrieve any meta-data associated with the permission group.
2260     *
2261     * @return Returns a {@link PermissionGroupInfo} containing information
2262     * about the permission.
2263     */
2264    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
2265            int flags) throws NameNotFoundException;
2266
2267    /**
2268     * Retrieve all of the known permission groups in the system.
2269     *
2270     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2271     * retrieve any meta-data associated with the permission group.
2272     *
2273     * @return Returns a list of {@link PermissionGroupInfo} containing
2274     * information about all of the known permission groups.
2275     */
2276    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
2277
2278    /**
2279     * Retrieve all of the information we know about a particular
2280     * package/application.
2281     *
2282     * <p>Throws {@link NameNotFoundException} if an application with the given
2283     * package name cannot be found on the system.
2284     *
2285     * @param packageName The full name (i.e. com.google.apps.contacts) of an
2286     *                    application.
2287     * @param flags Additional option flags. Use any combination of
2288     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2289     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2290     *
2291     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
2292     *         information about the package.
2293     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
2294     *         found in the list of installed applications,
2295     *         the application information is retrieved from the
2296     *         list of uninstalled applications(which includes
2297     *         installed applications as well as applications
2298     *         with data directory ie applications which had been
2299     *         deleted with {@code DONT_DELETE_DATA} flag set).
2300     *
2301     * @see #GET_META_DATA
2302     * @see #GET_SHARED_LIBRARY_FILES
2303     * @see #GET_UNINSTALLED_PACKAGES
2304     */
2305    public abstract ApplicationInfo getApplicationInfo(String packageName,
2306            int flags) throws NameNotFoundException;
2307
2308    /**
2309     * Retrieve all of the information we know about a particular activity
2310     * class.
2311     *
2312     * <p>Throws {@link NameNotFoundException} if an activity with the given
2313     * class name cannot be found on the system.
2314     *
2315     * @param component The full component name (i.e.
2316     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
2317     * class.
2318     * @param flags Additional option flags. Use any combination of
2319     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2320     * to modify the data (in ApplicationInfo) returned.
2321     *
2322     * @return {@link ActivityInfo} containing information about the activity.
2323     *
2324     * @see #GET_INTENT_FILTERS
2325     * @see #GET_META_DATA
2326     * @see #GET_SHARED_LIBRARY_FILES
2327     */
2328    public abstract ActivityInfo getActivityInfo(ComponentName component,
2329            int flags) throws NameNotFoundException;
2330
2331    /**
2332     * Retrieve all of the information we know about a particular receiver
2333     * class.
2334     *
2335     * <p>Throws {@link NameNotFoundException} if a receiver with the given
2336     * class name cannot be found on the system.
2337     *
2338     * @param component The full component name (i.e.
2339     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
2340     * class.
2341     * @param flags Additional option flags.  Use any combination of
2342     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2343     * to modify the data returned.
2344     *
2345     * @return {@link ActivityInfo} containing information about the receiver.
2346     *
2347     * @see #GET_INTENT_FILTERS
2348     * @see #GET_META_DATA
2349     * @see #GET_SHARED_LIBRARY_FILES
2350     */
2351    public abstract ActivityInfo getReceiverInfo(ComponentName component,
2352            int flags) throws NameNotFoundException;
2353
2354    /**
2355     * Retrieve all of the information we know about a particular service
2356     * class.
2357     *
2358     * <p>Throws {@link NameNotFoundException} if a service with the given
2359     * class name cannot be found on the system.
2360     *
2361     * @param component The full component name (i.e.
2362     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
2363     * class.
2364     * @param flags Additional option flags.  Use any combination of
2365     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2366     * to modify the data returned.
2367     *
2368     * @return ServiceInfo containing information about the service.
2369     *
2370     * @see #GET_META_DATA
2371     * @see #GET_SHARED_LIBRARY_FILES
2372     */
2373    public abstract ServiceInfo getServiceInfo(ComponentName component,
2374            int flags) throws NameNotFoundException;
2375
2376    /**
2377     * Retrieve all of the information we know about a particular content
2378     * provider class.
2379     *
2380     * <p>Throws {@link NameNotFoundException} if a provider with the given
2381     * class name cannot be found on the system.
2382     *
2383     * @param component The full component name (i.e.
2384     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
2385     * ContentProvider class.
2386     * @param flags Additional option flags.  Use any combination of
2387     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2388     * to modify the data returned.
2389     *
2390     * @return ProviderInfo containing information about the service.
2391     *
2392     * @see #GET_META_DATA
2393     * @see #GET_SHARED_LIBRARY_FILES
2394     */
2395    public abstract ProviderInfo getProviderInfo(ComponentName component,
2396            int flags) throws NameNotFoundException;
2397
2398    /**
2399     * Return a List of all packages that are installed
2400     * on the device.
2401     *
2402     * @param flags Additional option flags. Use any combination of
2403     * {@link #GET_ACTIVITIES},
2404     * {@link #GET_GIDS},
2405     * {@link #GET_CONFIGURATIONS},
2406     * {@link #GET_INSTRUMENTATION},
2407     * {@link #GET_PERMISSIONS},
2408     * {@link #GET_PROVIDERS},
2409     * {@link #GET_RECEIVERS},
2410     * {@link #GET_SERVICES},
2411     * {@link #GET_SIGNATURES},
2412     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2413     *
2414     * @return A List of PackageInfo objects, one for each package that is
2415     *         installed on the device.  In the unlikely case of there being no
2416     *         installed packages, an empty list is returned.
2417     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2418     *         applications including those deleted with {@code DONT_DELETE_DATA}
2419     *         (partially installed apps with data directory) will be returned.
2420     *
2421     * @see #GET_ACTIVITIES
2422     * @see #GET_GIDS
2423     * @see #GET_CONFIGURATIONS
2424     * @see #GET_INSTRUMENTATION
2425     * @see #GET_PERMISSIONS
2426     * @see #GET_PROVIDERS
2427     * @see #GET_RECEIVERS
2428     * @see #GET_SERVICES
2429     * @see #GET_SIGNATURES
2430     * @see #GET_UNINSTALLED_PACKAGES
2431     */
2432    public abstract List<PackageInfo> getInstalledPackages(int flags);
2433
2434    /**
2435     * Return a List of all installed packages that are currently
2436     * holding any of the given permissions.
2437     *
2438     * @param flags Additional option flags. Use any combination of
2439     * {@link #GET_ACTIVITIES},
2440     * {@link #GET_GIDS},
2441     * {@link #GET_CONFIGURATIONS},
2442     * {@link #GET_INSTRUMENTATION},
2443     * {@link #GET_PERMISSIONS},
2444     * {@link #GET_PROVIDERS},
2445     * {@link #GET_RECEIVERS},
2446     * {@link #GET_SERVICES},
2447     * {@link #GET_SIGNATURES},
2448     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2449     *
2450     * @return Returns a List of PackageInfo objects, one for each installed
2451     * application that is holding any of the permissions that were provided.
2452     *
2453     * @see #GET_ACTIVITIES
2454     * @see #GET_GIDS
2455     * @see #GET_CONFIGURATIONS
2456     * @see #GET_INSTRUMENTATION
2457     * @see #GET_PERMISSIONS
2458     * @see #GET_PROVIDERS
2459     * @see #GET_RECEIVERS
2460     * @see #GET_SERVICES
2461     * @see #GET_SIGNATURES
2462     * @see #GET_UNINSTALLED_PACKAGES
2463     */
2464    public abstract List<PackageInfo> getPackagesHoldingPermissions(
2465            String[] permissions, int flags);
2466
2467    /**
2468     * Return a List of all packages that are installed on the device, for a specific user.
2469     * Requesting a list of installed packages for another user
2470     * will require the permission INTERACT_ACROSS_USERS_FULL.
2471     * @param flags Additional option flags. Use any combination of
2472     * {@link #GET_ACTIVITIES},
2473     * {@link #GET_GIDS},
2474     * {@link #GET_CONFIGURATIONS},
2475     * {@link #GET_INSTRUMENTATION},
2476     * {@link #GET_PERMISSIONS},
2477     * {@link #GET_PROVIDERS},
2478     * {@link #GET_RECEIVERS},
2479     * {@link #GET_SERVICES},
2480     * {@link #GET_SIGNATURES},
2481     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2482     * @param userId The user for whom the installed packages are to be listed
2483     *
2484     * @return A List of PackageInfo objects, one for each package that is
2485     *         installed on the device.  In the unlikely case of there being no
2486     *         installed packages, an empty list is returned.
2487     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2488     *         applications including those deleted with {@code DONT_DELETE_DATA}
2489     *         (partially installed apps with data directory) will be returned.
2490     *
2491     * @see #GET_ACTIVITIES
2492     * @see #GET_GIDS
2493     * @see #GET_CONFIGURATIONS
2494     * @see #GET_INSTRUMENTATION
2495     * @see #GET_PERMISSIONS
2496     * @see #GET_PROVIDERS
2497     * @see #GET_RECEIVERS
2498     * @see #GET_SERVICES
2499     * @see #GET_SIGNATURES
2500     * @see #GET_UNINSTALLED_PACKAGES
2501     *
2502     * @hide
2503     */
2504    public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2505
2506    /**
2507     * Check whether a particular package has been granted a particular
2508     * permission.
2509     *
2510     * @param permName The name of the permission you are checking for.
2511     * @param pkgName The name of the package you are checking against.
2512     *
2513     * @return If the package has the permission, PERMISSION_GRANTED is
2514     * returned.  If it does not have the permission, PERMISSION_DENIED
2515     * is returned.
2516     *
2517     * @see #PERMISSION_GRANTED
2518     * @see #PERMISSION_DENIED
2519     */
2520    @CheckResult
2521    public abstract int checkPermission(String permName, String pkgName);
2522
2523    /**
2524     * Checks whether a particular permissions has been revoked for a
2525     * package by policy. Typically the device owner or the profile owner
2526     * may apply such a policy. The user cannot grant policy revoked
2527     * permissions, hence the only way for an app to get such a permission
2528     * is by a policy change.
2529     *
2530     * @param permName The name of the permission you are checking for.
2531     * @param pkgName The name of the package you are checking against.
2532     *
2533     * @return Whether the permission is restricted by policy.
2534     */
2535    @CheckResult
2536    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
2537            @NonNull String pkgName);
2538
2539    /**
2540     * Gets the package name of the component controlling runtime permissions.
2541     *
2542     * @return The package name.
2543     *
2544     * @hide
2545     */
2546    public abstract String getPermissionControllerPackageName();
2547
2548    /**
2549     * Add a new dynamic permission to the system.  For this to work, your
2550     * package must have defined a permission tree through the
2551     * {@link android.R.styleable#AndroidManifestPermissionTree
2552     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
2553     * permissions to trees that were defined by either its own package or
2554     * another with the same user id; a permission is in a tree if it
2555     * matches the name of the permission tree + ".": for example,
2556     * "com.foo.bar" is a member of the permission tree "com.foo".
2557     *
2558     * <p>It is good to make your permission tree name descriptive, because you
2559     * are taking possession of that entire set of permission names.  Thus, it
2560     * must be under a domain you control, with a suffix that will not match
2561     * any normal permissions that may be declared in any applications that
2562     * are part of that domain.
2563     *
2564     * <p>New permissions must be added before
2565     * any .apks are installed that use those permissions.  Permissions you
2566     * add through this method are remembered across reboots of the device.
2567     * If the given permission already exists, the info you supply here
2568     * will be used to update it.
2569     *
2570     * @param info Description of the permission to be added.
2571     *
2572     * @return Returns true if a new permission was created, false if an
2573     * existing one was updated.
2574     *
2575     * @throws SecurityException if you are not allowed to add the
2576     * given permission name.
2577     *
2578     * @see #removePermission(String)
2579     */
2580    public abstract boolean addPermission(PermissionInfo info);
2581
2582    /**
2583     * Like {@link #addPermission(PermissionInfo)} but asynchronously
2584     * persists the package manager state after returning from the call,
2585     * allowing it to return quicker and batch a series of adds at the
2586     * expense of no guarantee the added permission will be retained if
2587     * the device is rebooted before it is written.
2588     */
2589    public abstract boolean addPermissionAsync(PermissionInfo info);
2590
2591    /**
2592     * Removes a permission that was previously added with
2593     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
2594     * -- you are only allowed to remove permissions that you are allowed
2595     * to add.
2596     *
2597     * @param name The name of the permission to remove.
2598     *
2599     * @throws SecurityException if you are not allowed to remove the
2600     * given permission name.
2601     *
2602     * @see #addPermission(PermissionInfo)
2603     */
2604    public abstract void removePermission(String name);
2605
2606
2607    /**
2608     * Permission flags set when granting or revoking a permission.
2609     *
2610     * @hide
2611     */
2612    @SystemApi
2613    @IntDef({FLAG_PERMISSION_USER_SET,
2614            FLAG_PERMISSION_USER_FIXED,
2615            FLAG_PERMISSION_POLICY_FIXED,
2616            FLAG_PERMISSION_REVOKE_ON_UPGRADE,
2617            FLAG_PERMISSION_SYSTEM_FIXED,
2618            FLAG_PERMISSION_GRANTED_BY_DEFAULT})
2619    @Retention(RetentionPolicy.SOURCE)
2620    public @interface PermissionFlags {}
2621
2622    /**
2623     * Grant a runtime permission to an application which the application does not
2624     * already have. The permission must have been requested by the application.
2625     * If the application is not allowed to hold the permission, a {@link
2626     * java.lang.SecurityException} is thrown.
2627     * <p>
2628     * <strong>Note: </strong>Using this API requires holding
2629     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
2630     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
2631     * </p>
2632     *
2633     * @param packageName The package to which to grant the permission.
2634     * @param permissionName The permission name to grant.
2635     * @param user The user for which to grant the permission.
2636     *
2637     * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
2638     * @see android.content.pm.PackageManager.PermissionFlags
2639     *
2640     * @hide
2641     */
2642    @SystemApi
2643    public abstract void grantRuntimePermission(@NonNull String packageName,
2644            @NonNull String permissionName, @NonNull UserHandle user);
2645
2646    /**
2647     * Revoke a runtime permission that was previously granted by {@link
2648     * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
2649     * permission must have been requested by and granted to the application.
2650     * If the application is not allowed to hold the permission, a {@link
2651     * java.lang.SecurityException} is thrown.
2652     * <p>
2653     * <strong>Note: </strong>Using this API requires holding
2654     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
2655     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
2656     * </p>
2657     *
2658     * @param packageName The package from which to revoke the permission.
2659     * @param permissionName The permission name to revoke.
2660     * @param user The user for which to revoke the permission.
2661     *
2662     * @see #grantRuntimePermission(String, String, android.os.UserHandle)
2663     * @see android.content.pm.PackageManager.PermissionFlags
2664     *
2665     * @hide
2666     */
2667    @SystemApi
2668    public abstract void revokeRuntimePermission(@NonNull String packageName,
2669            @NonNull String permissionName, @NonNull UserHandle user);
2670
2671    /**
2672     * Gets the state flags associated with a permission.
2673     *
2674     * @param permissionName The permission for which to get the flags.
2675     * @param packageName The package name for which to get the flags.
2676     * @param user The user for which to get permission flags.
2677     * @return The permission flags.
2678     *
2679     * @hide
2680     */
2681    @SystemApi
2682    public abstract @PermissionFlags int getPermissionFlags(String permissionName,
2683            String packageName, @NonNull UserHandle user);
2684
2685    /**
2686     * Updates the flags associated with a permission by replacing the flags in
2687     * the specified mask with the provided flag values.
2688     *
2689     * @param permissionName The permission for which to update the flags.
2690     * @param packageName The package name for which to update the flags.
2691     * @param flagMask The flags which to replace.
2692     * @param flagValues The flags with which to replace.
2693     * @param user The user for which to update the permission flags.
2694     *
2695     * @hide
2696     */
2697    @SystemApi
2698    public abstract void updatePermissionFlags(String permissionName,
2699            String packageName, @PermissionFlags int flagMask, int flagValues,
2700            @NonNull UserHandle user);
2701
2702    /**
2703     * Gets whether you should show UI with rationale for requesting a permission.
2704     * You should do this only if you do not have the permission and the context in
2705     * which the permission is requested does not clearly communicate to the user
2706     * what would be the benefit from grating this permission.
2707     *
2708     * @param permission A permission your app wants to request.
2709     * @return Whether you can show permission rationale UI.
2710     *
2711     * @hide
2712     */
2713    public abstract boolean shouldShowRequestPermissionRationale(String permission);
2714
2715    /**
2716     * Returns an {@link android.content.Intent} suitable for passing to
2717     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
2718     * which prompts the user to grant permissions to this application.
2719     *
2720     * @throws NullPointerException if {@code permissions} is {@code null} or empty.
2721     *
2722     * @hide
2723     */
2724    public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
2725        if (ArrayUtils.isEmpty(permissions)) {
2726           throw new NullPointerException("permission cannot be null or empty");
2727        }
2728        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
2729        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
2730        intent.setPackage(getPermissionControllerPackageName());
2731        return intent;
2732    }
2733
2734    /**
2735     * Compare the signatures of two packages to determine if the same
2736     * signature appears in both of them.  If they do contain the same
2737     * signature, then they are allowed special privileges when working
2738     * with each other: they can share the same user-id, run instrumentation
2739     * against each other, etc.
2740     *
2741     * @param pkg1 First package name whose signature will be compared.
2742     * @param pkg2 Second package name whose signature will be compared.
2743     *
2744     * @return Returns an integer indicating whether all signatures on the
2745     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2746     * all signatures match or < 0 if there is not a match ({@link
2747     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2748     *
2749     * @see #checkSignatures(int, int)
2750     * @see #SIGNATURE_MATCH
2751     * @see #SIGNATURE_NO_MATCH
2752     * @see #SIGNATURE_UNKNOWN_PACKAGE
2753     */
2754    @CheckResult
2755    public abstract int checkSignatures(String pkg1, String pkg2);
2756
2757    /**
2758     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2759     * the two packages to be checked.  This can be useful, for example,
2760     * when doing the check in an IPC, where the UID is the only identity
2761     * available.  It is functionally identical to determining the package
2762     * associated with the UIDs and checking their signatures.
2763     *
2764     * @param uid1 First UID whose signature will be compared.
2765     * @param uid2 Second UID whose signature will be compared.
2766     *
2767     * @return Returns an integer indicating whether all signatures on the
2768     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2769     * all signatures match or < 0 if there is not a match ({@link
2770     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2771     *
2772     * @see #checkSignatures(String, String)
2773     * @see #SIGNATURE_MATCH
2774     * @see #SIGNATURE_NO_MATCH
2775     * @see #SIGNATURE_UNKNOWN_PACKAGE
2776     */
2777    @CheckResult
2778    public abstract int checkSignatures(int uid1, int uid2);
2779
2780    /**
2781     * Retrieve the names of all packages that are associated with a particular
2782     * user id.  In most cases, this will be a single package name, the package
2783     * that has been assigned that user id.  Where there are multiple packages
2784     * sharing the same user id through the "sharedUserId" mechanism, all
2785     * packages with that id will be returned.
2786     *
2787     * @param uid The user id for which you would like to retrieve the
2788     * associated packages.
2789     *
2790     * @return Returns an array of one or more packages assigned to the user
2791     * id, or null if there are no known packages with the given id.
2792     */
2793    public abstract String[] getPackagesForUid(int uid);
2794
2795    /**
2796     * Retrieve the official name associated with a user id.  This name is
2797     * guaranteed to never change, though it is possible for the underlying
2798     * user id to be changed.  That is, if you are storing information about
2799     * user ids in persistent storage, you should use the string returned
2800     * by this function instead of the raw user-id.
2801     *
2802     * @param uid The user id for which you would like to retrieve a name.
2803     * @return Returns a unique name for the given user id, or null if the
2804     * user id is not currently assigned.
2805     */
2806    public abstract String getNameForUid(int uid);
2807
2808    /**
2809     * Return the user id associated with a shared user name. Multiple
2810     * applications can specify a shared user name in their manifest and thus
2811     * end up using a common uid. This might be used for new applications
2812     * that use an existing shared user name and need to know the uid of the
2813     * shared user.
2814     *
2815     * @param sharedUserName The shared user name whose uid is to be retrieved.
2816     * @return Returns the uid associated with the shared user, or  NameNotFoundException
2817     * if the shared user name is not being used by any installed packages
2818     * @hide
2819     */
2820    public abstract int getUidForSharedUser(String sharedUserName)
2821            throws NameNotFoundException;
2822
2823    /**
2824     * Return a List of all application packages that are installed on the
2825     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2826     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2827     * installed apps with data directory) will be returned.
2828     *
2829     * @param flags Additional option flags. Use any combination of
2830     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2831     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2832     *
2833     * @return Returns a List of ApplicationInfo objects, one for each application that
2834     *         is installed on the device.  In the unlikely case of there being
2835     *         no installed applications, an empty list is returned.
2836     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2837     *         applications including those deleted with {@code DONT_DELETE_DATA}
2838     *         (partially installed apps with data directory) will be returned.
2839     *
2840     * @see #GET_META_DATA
2841     * @see #GET_SHARED_LIBRARY_FILES
2842     * @see #GET_UNINSTALLED_PACKAGES
2843     */
2844    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2845
2846    /**
2847     * Get a list of shared libraries that are available on the
2848     * system.
2849     *
2850     * @return An array of shared library names that are
2851     * available on the system, or null if none are installed.
2852     *
2853     */
2854    public abstract String[] getSystemSharedLibraryNames();
2855
2856    /**
2857     * Get a list of features that are available on the
2858     * system.
2859     *
2860     * @return An array of FeatureInfo classes describing the features
2861     * that are available on the system, or null if there are none(!!).
2862     */
2863    public abstract FeatureInfo[] getSystemAvailableFeatures();
2864
2865    /**
2866     * Check whether the given feature name is one of the available
2867     * features as returned by {@link #getSystemAvailableFeatures()}.
2868     *
2869     * @return Returns true if the devices supports the feature, else
2870     * false.
2871     */
2872    public abstract boolean hasSystemFeature(String name);
2873
2874    /**
2875     * Determine the best action to perform for a given Intent.  This is how
2876     * {@link Intent#resolveActivity} finds an activity if a class has not
2877     * been explicitly specified.
2878     *
2879     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2880     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2881     * only flag.  You need to do so to resolve the activity in the same way
2882     * that {@link android.content.Context#startActivity(Intent)} and
2883     * {@link android.content.Intent#resolveActivity(PackageManager)
2884     * Intent.resolveActivity(PackageManager)} do.</p>
2885     *
2886     * @param intent An intent containing all of the desired specification
2887     *               (action, data, type, category, and/or component).
2888     * @param flags Additional option flags.  The most important is
2889     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2890     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2891     *
2892     * @return Returns a ResolveInfo containing the final activity intent that
2893     *         was determined to be the best action.  Returns null if no
2894     *         matching activity was found. If multiple matching activities are
2895     *         found and there is no default set, returns a ResolveInfo
2896     *         containing something else, such as the activity resolver.
2897     *
2898     * @see #MATCH_DEFAULT_ONLY
2899     * @see #GET_INTENT_FILTERS
2900     * @see #GET_RESOLVED_FILTER
2901     */
2902    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2903
2904    /**
2905     * Determine the best action to perform for a given Intent for a given user. This
2906     * is how {@link Intent#resolveActivity} finds an activity if a class has not
2907     * been explicitly specified.
2908     *
2909     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2910     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2911     * only flag.  You need to do so to resolve the activity in the same way
2912     * that {@link android.content.Context#startActivity(Intent)} and
2913     * {@link android.content.Intent#resolveActivity(PackageManager)
2914     * Intent.resolveActivity(PackageManager)} do.</p>
2915     *
2916     * @param intent An intent containing all of the desired specification
2917     *               (action, data, type, category, and/or component).
2918     * @param flags Additional option flags.  The most important is
2919     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2920     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2921     * @param userId The user id.
2922     *
2923     * @return Returns a ResolveInfo containing the final activity intent that
2924     *         was determined to be the best action.  Returns null if no
2925     *         matching activity was found. If multiple matching activities are
2926     *         found and there is no default set, returns a ResolveInfo
2927     *         containing something else, such as the activity resolver.
2928     *
2929     * @see #MATCH_DEFAULT_ONLY
2930     * @see #GET_INTENT_FILTERS
2931     * @see #GET_RESOLVED_FILTER
2932     *
2933     * @hide
2934     */
2935    public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
2936
2937    /**
2938     * Retrieve all activities that can be performed for the given intent.
2939     *
2940     * @param intent The desired intent as per resolveActivity().
2941     * @param flags Additional option flags.  The most important is
2942     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2943     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2944     *
2945     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
2946     *
2947     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2948     *         Activity. These are ordered from best to worst match -- that
2949     *         is, the first item in the list is what is returned by
2950     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2951     *         list is returned.
2952     *
2953     * @see #MATCH_DEFAULT_ONLY
2954     * @see #GET_INTENT_FILTERS
2955     * @see #GET_RESOLVED_FILTER
2956     */
2957    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
2958            int flags);
2959
2960    /**
2961     * Retrieve all activities that can be performed for the given intent, for a specific user.
2962     *
2963     * @param intent The desired intent as per resolveActivity().
2964     * @param flags Additional option flags.  The most important is
2965     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2966     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2967     *
2968     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
2969     *
2970     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
2971     *         Activity. These are ordered from best to worst match -- that
2972     *         is, the first item in the list is what is returned by
2973     *         {@link #resolveActivity}.  If there are no matching activities, an empty
2974     *         list is returned.
2975     *
2976     * @see #MATCH_DEFAULT_ONLY
2977     * @see #GET_INTENT_FILTERS
2978     * @see #GET_RESOLVED_FILTER
2979     * @hide
2980     */
2981    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
2982            int flags, int userId);
2983
2984
2985    /**
2986     * Retrieve a set of activities that should be presented to the user as
2987     * similar options.  This is like {@link #queryIntentActivities}, except it
2988     * also allows you to supply a list of more explicit Intents that you would
2989     * like to resolve to particular options, and takes care of returning the
2990     * final ResolveInfo list in a reasonable order, with no duplicates, based
2991     * on those inputs.
2992     *
2993     * @param caller The class name of the activity that is making the
2994     *               request.  This activity will never appear in the output
2995     *               list.  Can be null.
2996     * @param specifics An array of Intents that should be resolved to the
2997     *                  first specific results.  Can be null.
2998     * @param intent The desired intent as per resolveActivity().
2999     * @param flags Additional option flags.  The most important is
3000     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3001     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3002     *
3003     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3004     *         Activity. These are ordered first by all of the intents resolved
3005     *         in <var>specifics</var> and then any additional activities that
3006     *         can handle <var>intent</var> but did not get included by one of
3007     *         the <var>specifics</var> intents.  If there are no matching
3008     *         activities, an empty list is returned.
3009     *
3010     * @see #MATCH_DEFAULT_ONLY
3011     * @see #GET_INTENT_FILTERS
3012     * @see #GET_RESOLVED_FILTER
3013     */
3014    public abstract List<ResolveInfo> queryIntentActivityOptions(
3015            ComponentName caller, Intent[] specifics, Intent intent, int flags);
3016
3017    /**
3018     * Retrieve all receivers that can handle a broadcast of the given intent.
3019     *
3020     * @param intent The desired intent as per resolveActivity().
3021     * @param flags Additional option flags.
3022     *
3023     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3024     *         Receiver. These are ordered from first to last in priority.  If
3025     *         there are no matching receivers, an empty list is returned.
3026     *
3027     * @see #MATCH_DEFAULT_ONLY
3028     * @see #GET_INTENT_FILTERS
3029     * @see #GET_RESOLVED_FILTER
3030     */
3031    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3032            int flags);
3033
3034    /**
3035     * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
3036     * user.
3037     *
3038     * @param intent The desired intent as per resolveActivity().
3039     * @param flags Additional option flags.
3040     * @param userId The userId of the user being queried.
3041     *
3042     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3043     *         Receiver. These are ordered from first to last in priority.  If
3044     *         there are no matching receivers, an empty list or {@code null} is returned.
3045     *
3046     * @see #MATCH_DEFAULT_ONLY
3047     * @see #GET_INTENT_FILTERS
3048     * @see #GET_RESOLVED_FILTER
3049     * @hide
3050     */
3051    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3052            int flags, int userId);
3053
3054    /**
3055     * Determine the best service to handle for a given Intent.
3056     *
3057     * @param intent An intent containing all of the desired specification
3058     *               (action, data, type, category, and/or component).
3059     * @param flags Additional option flags.
3060     *
3061     * @return Returns a ResolveInfo containing the final service intent that
3062     *         was determined to be the best action.  Returns null if no
3063     *         matching service was found.
3064     *
3065     * @see #GET_INTENT_FILTERS
3066     * @see #GET_RESOLVED_FILTER
3067     */
3068    public abstract ResolveInfo resolveService(Intent intent, int flags);
3069
3070    /**
3071     * Retrieve all services that can match the given intent.
3072     *
3073     * @param intent The desired intent as per resolveService().
3074     * @param flags Additional option flags.
3075     *
3076     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3077     *         ServiceInfo. These are ordered from best to worst match -- that
3078     *         is, the first item in the list is what is returned by
3079     *         resolveService().  If there are no matching services, an empty
3080     *         list or {@code null} is returned.
3081     *
3082     * @see #GET_INTENT_FILTERS
3083     * @see #GET_RESOLVED_FILTER
3084     */
3085    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
3086            int flags);
3087
3088    /**
3089     * Retrieve all services that can match the given intent for a given user.
3090     *
3091     * @param intent The desired intent as per resolveService().
3092     * @param flags Additional option flags.
3093     * @param userId The user id.
3094     *
3095     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3096     *         ServiceInfo. These are ordered from best to worst match -- that
3097     *         is, the first item in the list is what is returned by
3098     *         resolveService().  If there are no matching services, an empty
3099     *         list or {@code null} is returned.
3100     *
3101     * @see #GET_INTENT_FILTERS
3102     * @see #GET_RESOLVED_FILTER
3103     *
3104     * @hide
3105     */
3106    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
3107            int flags, int userId);
3108
3109    /** {@hide} */
3110    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
3111            Intent intent, int flags, int userId);
3112
3113    /**
3114     * Retrieve all providers that can match the given intent.
3115     *
3116     * @param intent An intent containing all of the desired specification
3117     *            (action, data, type, category, and/or component).
3118     * @param flags Additional option flags.
3119     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3120     *         ProviderInfo. These are ordered from best to worst match. If
3121     *         there are no matching providers, an empty list or {@code null} is returned.
3122     * @see #GET_INTENT_FILTERS
3123     * @see #GET_RESOLVED_FILTER
3124     */
3125    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
3126
3127    /**
3128     * Find a single content provider by its base path name.
3129     *
3130     * @param name The name of the provider to find.
3131     * @param flags Additional option flags.  Currently should always be 0.
3132     *
3133     * @return ContentProviderInfo Information about the provider, if found,
3134     *         else null.
3135     */
3136    public abstract ProviderInfo resolveContentProvider(String name,
3137            int flags);
3138
3139    /**
3140     * Find a single content provider by its base path name.
3141     *
3142     * @param name The name of the provider to find.
3143     * @param flags Additional option flags.  Currently should always be 0.
3144     * @param userId The user id.
3145     *
3146     * @return ContentProviderInfo Information about the provider, if found,
3147     *         else null.
3148     * @hide
3149     */
3150    public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
3151
3152    /**
3153     * Retrieve content provider information.
3154     *
3155     * <p><em>Note: unlike most other methods, an empty result set is indicated
3156     * by a null return instead of an empty list.</em>
3157     *
3158     * @param processName If non-null, limits the returned providers to only
3159     *                    those that are hosted by the given process.  If null,
3160     *                    all content providers are returned.
3161     * @param uid If <var>processName</var> is non-null, this is the required
3162     *        uid owning the requested content providers.
3163     * @param flags Additional option flags.  Currently should always be 0.
3164     *
3165     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
3166     *         content provider either patching <var>processName</var> or, if
3167     *         <var>processName</var> is null, all known content providers.
3168     *         <em>If there are no matching providers, null is returned.</em>
3169     */
3170    public abstract List<ProviderInfo> queryContentProviders(
3171            String processName, int uid, int flags);
3172
3173    /**
3174     * Retrieve all of the information we know about a particular
3175     * instrumentation class.
3176     *
3177     * <p>Throws {@link NameNotFoundException} if instrumentation with the
3178     * given class name cannot be found on the system.
3179     *
3180     * @param className The full name (i.e.
3181     *                  com.google.apps.contacts.InstrumentList) of an
3182     *                  Instrumentation class.
3183     * @param flags Additional option flags.  Currently should always be 0.
3184     *
3185     * @return InstrumentationInfo containing information about the
3186     *         instrumentation.
3187     */
3188    public abstract InstrumentationInfo getInstrumentationInfo(
3189            ComponentName className, int flags) throws NameNotFoundException;
3190
3191    /**
3192     * Retrieve information about available instrumentation code.  May be used
3193     * to retrieve either all instrumentation code, or only the code targeting
3194     * a particular package.
3195     *
3196     * @param targetPackage If null, all instrumentation is returned; only the
3197     *                      instrumentation targeting this package name is
3198     *                      returned.
3199     * @param flags Additional option flags.  Currently should always be 0.
3200     *
3201     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
3202     *         matching available Instrumentation.  Returns an empty list if
3203     *         there is no instrumentation available for the given package.
3204     */
3205    public abstract List<InstrumentationInfo> queryInstrumentation(
3206            String targetPackage, int flags);
3207
3208    /**
3209     * Retrieve an image from a package.  This is a low-level API used by
3210     * the various package manager info structures (such as
3211     * {@link ComponentInfo} to implement retrieval of their associated
3212     * icon.
3213     *
3214     * @param packageName The name of the package that this icon is coming from.
3215     * Cannot be null.
3216     * @param resid The resource identifier of the desired image.  Cannot be 0.
3217     * @param appInfo Overall information about <var>packageName</var>.  This
3218     * may be null, in which case the application information will be retrieved
3219     * for you if needed; if you already have this information around, it can
3220     * be much more efficient to supply it here.
3221     *
3222     * @return Returns a Drawable holding the requested image.  Returns null if
3223     * an image could not be found for any reason.
3224     */
3225    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
3226            ApplicationInfo appInfo);
3227
3228    /**
3229     * Retrieve the icon associated with an activity.  Given the full name of
3230     * an activity, retrieves the information about it and calls
3231     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
3232     * If the activity cannot be found, NameNotFoundException is thrown.
3233     *
3234     * @param activityName Name of the activity whose icon is to be retrieved.
3235     *
3236     * @return Returns the image of the icon, or the default activity icon if
3237     * it could not be found.  Does not return null.
3238     * @throws NameNotFoundException Thrown if the resources for the given
3239     * activity could not be loaded.
3240     *
3241     * @see #getActivityIcon(Intent)
3242     */
3243    public abstract Drawable getActivityIcon(ComponentName activityName)
3244            throws NameNotFoundException;
3245
3246    /**
3247     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
3248     * set, this simply returns the result of
3249     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
3250     * component and returns the icon associated with the resolved component.
3251     * If intent.getClassName() cannot be found or the Intent cannot be resolved
3252     * to a component, NameNotFoundException is thrown.
3253     *
3254     * @param intent The intent for which you would like to retrieve an icon.
3255     *
3256     * @return Returns the image of the icon, or the default activity icon if
3257     * it could not be found.  Does not return null.
3258     * @throws NameNotFoundException Thrown if the resources for application
3259     * matching the given intent could not be loaded.
3260     *
3261     * @see #getActivityIcon(ComponentName)
3262     */
3263    public abstract Drawable getActivityIcon(Intent intent)
3264            throws NameNotFoundException;
3265
3266    /**
3267     * Retrieve the banner associated with an activity. Given the full name of
3268     * an activity, retrieves the information about it and calls
3269     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
3270     * banner. If the activity cannot be found, NameNotFoundException is thrown.
3271     *
3272     * @param activityName Name of the activity whose banner is to be retrieved.
3273     * @return Returns the image of the banner, or null if the activity has no
3274     *         banner specified.
3275     * @throws NameNotFoundException Thrown if the resources for the given
3276     *             activity could not be loaded.
3277     * @see #getActivityBanner(Intent)
3278     */
3279    public abstract Drawable getActivityBanner(ComponentName activityName)
3280            throws NameNotFoundException;
3281
3282    /**
3283     * Retrieve the banner associated with an Intent. If intent.getClassName()
3284     * is set, this simply returns the result of
3285     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
3286     * intent's component and returns the banner associated with the resolved
3287     * component. If intent.getClassName() cannot be found or the Intent cannot
3288     * be resolved to a component, NameNotFoundException is thrown.
3289     *
3290     * @param intent The intent for which you would like to retrieve a banner.
3291     * @return Returns the image of the banner, or null if the activity has no
3292     *         banner specified.
3293     * @throws NameNotFoundException Thrown if the resources for application
3294     *             matching the given intent could not be loaded.
3295     * @see #getActivityBanner(ComponentName)
3296     */
3297    public abstract Drawable getActivityBanner(Intent intent)
3298            throws NameNotFoundException;
3299
3300    /**
3301     * Return the generic icon for an activity that is used when no specific
3302     * icon is defined.
3303     *
3304     * @return Drawable Image of the icon.
3305     */
3306    public abstract Drawable getDefaultActivityIcon();
3307
3308    /**
3309     * Retrieve the icon associated with an application.  If it has not defined
3310     * an icon, the default app icon is returned.  Does not return null.
3311     *
3312     * @param info Information about application being queried.
3313     *
3314     * @return Returns the image of the icon, or the default application icon
3315     * if it could not be found.
3316     *
3317     * @see #getApplicationIcon(String)
3318     */
3319    public abstract Drawable getApplicationIcon(ApplicationInfo info);
3320
3321    /**
3322     * Retrieve the icon associated with an application.  Given the name of the
3323     * application's package, retrieves the information about it and calls
3324     * getApplicationIcon() to return its icon. If the application cannot be
3325     * found, NameNotFoundException is thrown.
3326     *
3327     * @param packageName Name of the package whose application icon is to be
3328     *                    retrieved.
3329     *
3330     * @return Returns the image of the icon, or the default application icon
3331     * if it could not be found.  Does not return null.
3332     * @throws NameNotFoundException Thrown if the resources for the given
3333     * application could not be loaded.
3334     *
3335     * @see #getApplicationIcon(ApplicationInfo)
3336     */
3337    public abstract Drawable getApplicationIcon(String packageName)
3338            throws NameNotFoundException;
3339
3340    /**
3341     * Retrieve the banner associated with an application.
3342     *
3343     * @param info Information about application being queried.
3344     * @return Returns the image of the banner or null if the application has no
3345     *         banner specified.
3346     * @see #getApplicationBanner(String)
3347     */
3348    public abstract Drawable getApplicationBanner(ApplicationInfo info);
3349
3350    /**
3351     * Retrieve the banner associated with an application. Given the name of the
3352     * application's package, retrieves the information about it and calls
3353     * getApplicationIcon() to return its banner. If the application cannot be
3354     * found, NameNotFoundException is thrown.
3355     *
3356     * @param packageName Name of the package whose application banner is to be
3357     *            retrieved.
3358     * @return Returns the image of the banner or null if the application has no
3359     *         banner specified.
3360     * @throws NameNotFoundException Thrown if the resources for the given
3361     *             application could not be loaded.
3362     * @see #getApplicationBanner(ApplicationInfo)
3363     */
3364    public abstract Drawable getApplicationBanner(String packageName)
3365            throws NameNotFoundException;
3366
3367    /**
3368     * Retrieve the logo associated with an activity. Given the full name of an
3369     * activity, retrieves the information about it and calls
3370     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
3371     * logo. If the activity cannot be found, NameNotFoundException is thrown.
3372     *
3373     * @param activityName Name of the activity whose logo is to be retrieved.
3374     * @return Returns the image of the logo or null if the activity has no logo
3375     *         specified.
3376     * @throws NameNotFoundException Thrown if the resources for the given
3377     *             activity could not be loaded.
3378     * @see #getActivityLogo(Intent)
3379     */
3380    public abstract Drawable getActivityLogo(ComponentName activityName)
3381            throws NameNotFoundException;
3382
3383    /**
3384     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
3385     * set, this simply returns the result of
3386     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
3387     * component and returns the logo associated with the resolved component.
3388     * If intent.getClassName() cannot be found or the Intent cannot be resolved
3389     * to a component, NameNotFoundException is thrown.
3390     *
3391     * @param intent The intent for which you would like to retrieve a logo.
3392     *
3393     * @return Returns the image of the logo, or null if the activity has no
3394     * logo specified.
3395     *
3396     * @throws NameNotFoundException Thrown if the resources for application
3397     * matching the given intent could not be loaded.
3398     *
3399     * @see #getActivityLogo(ComponentName)
3400     */
3401    public abstract Drawable getActivityLogo(Intent intent)
3402            throws NameNotFoundException;
3403
3404    /**
3405     * Retrieve the logo associated with an application.  If it has not specified
3406     * a logo, this method returns null.
3407     *
3408     * @param info Information about application being queried.
3409     *
3410     * @return Returns the image of the logo, or null if no logo is specified
3411     * by the application.
3412     *
3413     * @see #getApplicationLogo(String)
3414     */
3415    public abstract Drawable getApplicationLogo(ApplicationInfo info);
3416
3417    /**
3418     * Retrieve the logo associated with an application.  Given the name of the
3419     * application's package, retrieves the information about it and calls
3420     * getApplicationLogo() to return its logo. If the application cannot be
3421     * found, NameNotFoundException is thrown.
3422     *
3423     * @param packageName Name of the package whose application logo is to be
3424     *                    retrieved.
3425     *
3426     * @return Returns the image of the logo, or null if no application logo
3427     * has been specified.
3428     *
3429     * @throws NameNotFoundException Thrown if the resources for the given
3430     * application could not be loaded.
3431     *
3432     * @see #getApplicationLogo(ApplicationInfo)
3433     */
3434    public abstract Drawable getApplicationLogo(String packageName)
3435            throws NameNotFoundException;
3436
3437    /**
3438     * If the target user is a managed profile of the calling user or if the
3439     * target user is the caller and is itself a managed profile, then this
3440     * returns a badged copy of the given icon to be able to distinguish it from
3441     * the original icon. For badging an arbitrary drawable use
3442     * {@link #getUserBadgedDrawableForDensity(
3443     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
3444     * <p>
3445     * If the original drawable is a BitmapDrawable and the backing bitmap is
3446     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
3447     * is performed in place and the original drawable is returned.
3448     * </p>
3449     *
3450     * @param icon The icon to badge.
3451     * @param user The target user.
3452     * @return A drawable that combines the original icon and a badge as
3453     *         determined by the system.
3454     */
3455    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
3456
3457    /**
3458     * If the target user is a managed profile of the calling user or the caller
3459     * is itself a managed profile, then this returns a badged copy of the given
3460     * drawable allowing the user to distinguish it from the original drawable.
3461     * The caller can specify the location in the bounds of the drawable to be
3462     * badged where the badge should be applied as well as the density of the
3463     * badge to be used.
3464     * <p>
3465     * If the original drawable is a BitmapDrawable and the backing bitmap is
3466     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
3467     * is performed in place and the original drawable is returned.
3468     * </p>
3469     *
3470     * @param drawable The drawable to badge.
3471     * @param user The target user.
3472     * @param badgeLocation Where in the bounds of the badged drawable to place
3473     *         the badge. If not provided, the badge is applied on top of the entire
3474     *         drawable being badged.
3475     * @param badgeDensity The optional desired density for the badge as per
3476     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
3477     *         the density of the display is used.
3478     * @return A drawable that combines the original drawable and a badge as
3479     *         determined by the system.
3480     */
3481    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
3482            UserHandle user, Rect badgeLocation, int badgeDensity);
3483
3484    /**
3485     * If the target user is a managed profile of the calling user or the caller
3486     * is itself a managed profile, then this returns a drawable to use as a small
3487     * icon to include in a view to distinguish it from the original icon.
3488     *
3489     * @param user The target user.
3490     * @param density The optional desired density for the badge as per
3491     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
3492     *         the density of the current display is used.
3493     * @return the drawable or null if no drawable is required.
3494     * @hide
3495     */
3496    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
3497
3498    /**
3499     * If the target user is a managed profile of the calling user or the caller
3500     * is itself a managed profile, then this returns a copy of the label with
3501     * badging for accessibility services like talkback. E.g. passing in "Email"
3502     * and it might return "Work Email" for Email in the work profile.
3503     *
3504     * @param label The label to change.
3505     * @param user The target user.
3506     * @return A label that combines the original label and a badge as
3507     *         determined by the system.
3508     */
3509    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
3510
3511    /**
3512     * Retrieve text from a package.  This is a low-level API used by
3513     * the various package manager info structures (such as
3514     * {@link ComponentInfo} to implement retrieval of their associated
3515     * labels and other text.
3516     *
3517     * @param packageName The name of the package that this text is coming from.
3518     * Cannot be null.
3519     * @param resid The resource identifier of the desired text.  Cannot be 0.
3520     * @param appInfo Overall information about <var>packageName</var>.  This
3521     * may be null, in which case the application information will be retrieved
3522     * for you if needed; if you already have this information around, it can
3523     * be much more efficient to supply it here.
3524     *
3525     * @return Returns a CharSequence holding the requested text.  Returns null
3526     * if the text could not be found for any reason.
3527     */
3528    public abstract CharSequence getText(String packageName, @StringRes int resid,
3529            ApplicationInfo appInfo);
3530
3531    /**
3532     * Retrieve an XML file from a package.  This is a low-level API used to
3533     * retrieve XML meta data.
3534     *
3535     * @param packageName The name of the package that this xml is coming from.
3536     * Cannot be null.
3537     * @param resid The resource identifier of the desired xml.  Cannot be 0.
3538     * @param appInfo Overall information about <var>packageName</var>.  This
3539     * may be null, in which case the application information will be retrieved
3540     * for you if needed; if you already have this information around, it can
3541     * be much more efficient to supply it here.
3542     *
3543     * @return Returns an XmlPullParser allowing you to parse out the XML
3544     * data.  Returns null if the xml resource could not be found for any
3545     * reason.
3546     */
3547    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
3548            ApplicationInfo appInfo);
3549
3550    /**
3551     * Return the label to use for this application.
3552     *
3553     * @return Returns the label associated with this application, or null if
3554     * it could not be found for any reason.
3555     * @param info The application to get the label of.
3556     */
3557    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
3558
3559    /**
3560     * Retrieve the resources associated with an activity.  Given the full
3561     * name of an activity, retrieves the information about it and calls
3562     * getResources() to return its application's resources.  If the activity
3563     * cannot be found, NameNotFoundException is thrown.
3564     *
3565     * @param activityName Name of the activity whose resources are to be
3566     *                     retrieved.
3567     *
3568     * @return Returns the application's Resources.
3569     * @throws NameNotFoundException Thrown if the resources for the given
3570     * application could not be loaded.
3571     *
3572     * @see #getResourcesForApplication(ApplicationInfo)
3573     */
3574    public abstract Resources getResourcesForActivity(ComponentName activityName)
3575            throws NameNotFoundException;
3576
3577    /**
3578     * Retrieve the resources for an application.  Throws NameNotFoundException
3579     * if the package is no longer installed.
3580     *
3581     * @param app Information about the desired application.
3582     *
3583     * @return Returns the application's Resources.
3584     * @throws NameNotFoundException Thrown if the resources for the given
3585     * application could not be loaded (most likely because it was uninstalled).
3586     */
3587    public abstract Resources getResourcesForApplication(ApplicationInfo app)
3588            throws NameNotFoundException;
3589
3590    /**
3591     * Retrieve the resources associated with an application.  Given the full
3592     * package name of an application, retrieves the information about it and
3593     * calls getResources() to return its application's resources.  If the
3594     * appPackageName cannot be found, NameNotFoundException is thrown.
3595     *
3596     * @param appPackageName Package name of the application whose resources
3597     *                       are to be retrieved.
3598     *
3599     * @return Returns the application's Resources.
3600     * @throws NameNotFoundException Thrown if the resources for the given
3601     * application could not be loaded.
3602     *
3603     * @see #getResourcesForApplication(ApplicationInfo)
3604     */
3605    public abstract Resources getResourcesForApplication(String appPackageName)
3606            throws NameNotFoundException;
3607
3608    /** @hide */
3609    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
3610            throws NameNotFoundException;
3611
3612    /**
3613     * Retrieve overall information about an application package defined
3614     * in a package archive file
3615     *
3616     * @param archiveFilePath The path to the archive file
3617     * @param flags Additional option flags. Use any combination of
3618     * {@link #GET_ACTIVITIES},
3619     * {@link #GET_GIDS},
3620     * {@link #GET_CONFIGURATIONS},
3621     * {@link #GET_INSTRUMENTATION},
3622     * {@link #GET_PERMISSIONS},
3623     * {@link #GET_PROVIDERS},
3624     * {@link #GET_RECEIVERS},
3625     * {@link #GET_SERVICES},
3626     * {@link #GET_SIGNATURES}, to modify the data returned.
3627     *
3628     * @return Returns the information about the package. Returns
3629     * null if the package could not be successfully parsed.
3630     *
3631     * @see #GET_ACTIVITIES
3632     * @see #GET_GIDS
3633     * @see #GET_CONFIGURATIONS
3634     * @see #GET_INSTRUMENTATION
3635     * @see #GET_PERMISSIONS
3636     * @see #GET_PROVIDERS
3637     * @see #GET_RECEIVERS
3638     * @see #GET_SERVICES
3639     * @see #GET_SIGNATURES
3640     *
3641     */
3642    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3643        final PackageParser parser = new PackageParser();
3644        final File apkFile = new File(archiveFilePath);
3645        try {
3646            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3647            if ((flags & GET_SIGNATURES) != 0) {
3648                parser.collectCertificates(pkg, 0);
3649                parser.collectManifestDigest(pkg);
3650            }
3651            PackageUserState state = new PackageUserState();
3652            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3653        } catch (PackageParserException e) {
3654            return null;
3655        }
3656    }
3657
3658    /**
3659     * @hide Install a package. Since this may take a little while, the result
3660     *       will be posted back to the given observer. An installation will
3661     *       fail if the calling context lacks the
3662     *       {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3663     *       the package named in the package file's manifest is already
3664     *       installed, or if there's no space available on the device.
3665     * @param packageURI The location of the package file to install. This can
3666     *            be a 'file:' or a 'content:' URI.
3667     * @param observer An observer callback to get notified when the package
3668     *            installation is complete.
3669     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3670     *            will be called when that happens. This parameter must not be
3671     *            null.
3672     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3673     *            {@link #INSTALL_REPLACE_EXISTING},
3674     *            {@link #INSTALL_ALLOW_TEST}.
3675     * @param installerPackageName Optional package name of the application that
3676     *            is performing the installation. This identifies which market
3677     *            the package came from.
3678     * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3679     *             String)} instead. This method will continue to be supported
3680     *             but the older observer interface will not get additional
3681     *             failure details.
3682     */
3683    // @SystemApi
3684    public abstract void installPackage(
3685            Uri packageURI, IPackageInstallObserver observer, int flags,
3686            String installerPackageName);
3687
3688    /**
3689     * Similar to
3690     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3691     * with an extra verification file provided.
3692     *
3693     * @param packageURI The location of the package file to install. This can
3694     *            be a 'file:' or a 'content:' URI.
3695     * @param observer An observer callback to get notified when the package
3696     *            installation is complete.
3697     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3698     *            will be called when that happens. This parameter must not be
3699     *            null.
3700     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3701     *            {@link #INSTALL_REPLACE_EXISTING},
3702     *            {@link #INSTALL_ALLOW_TEST}.
3703     * @param installerPackageName Optional package name of the application that
3704     *            is performing the installation. This identifies which market
3705     *            the package came from.
3706     * @param verificationURI The location of the supplementary verification
3707     *            file. This can be a 'file:' or a 'content:' URI. May be
3708     *            {@code null}.
3709     * @param manifestDigest an object that holds the digest of the package
3710     *            which can be used to verify ownership. May be {@code null}.
3711     * @param encryptionParams if the package to be installed is encrypted,
3712     *            these parameters describing the encryption and authentication
3713     *            used. May be {@code null}.
3714     * @hide
3715     * @deprecated Use {@link #installPackageWithVerification(Uri,
3716     *             PackageInstallObserver, int, String, Uri, ManifestDigest,
3717     *             ContainerEncryptionParams)} instead. This method will
3718     *             continue to be supported but the older observer interface
3719     *             will not get additional failure details.
3720     */
3721    // @SystemApi
3722    public abstract void installPackageWithVerification(Uri packageURI,
3723            IPackageInstallObserver observer, int flags, String installerPackageName,
3724            Uri verificationURI, ManifestDigest manifestDigest,
3725            ContainerEncryptionParams encryptionParams);
3726
3727    /**
3728     * Similar to
3729     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3730     * with an extra verification information provided.
3731     *
3732     * @param packageURI The location of the package file to install. This can
3733     *            be a 'file:' or a 'content:' URI.
3734     * @param observer An observer callback to get notified when the package
3735     *            installation is complete.
3736     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3737     *            will be called when that happens. This parameter must not be
3738     *            null.
3739     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3740     *            {@link #INSTALL_REPLACE_EXISTING},
3741     *            {@link #INSTALL_ALLOW_TEST}.
3742     * @param installerPackageName Optional package name of the application that
3743     *            is performing the installation. This identifies which market
3744     *            the package came from.
3745     * @param verificationParams an object that holds signal information to
3746     *            assist verification. May be {@code null}.
3747     * @param encryptionParams if the package to be installed is encrypted,
3748     *            these parameters describing the encryption and authentication
3749     *            used. May be {@code null}.
3750     * @hide
3751     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3752     *             PackageInstallObserver, int, String, VerificationParams,
3753     *             ContainerEncryptionParams)} instead. This method will
3754     *             continue to be supported but the older observer interface
3755     *             will not get additional failure details.
3756     */
3757    @Deprecated
3758    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3759            IPackageInstallObserver observer, int flags, String installerPackageName,
3760            VerificationParams verificationParams,
3761            ContainerEncryptionParams encryptionParams);
3762
3763    // Package-install variants that take the new, expanded form of observer interface.
3764    // Note that these *also* take the original observer type and will redundantly
3765    // report the same information to that observer if supplied; but it is not required.
3766
3767    /**
3768     * @hide
3769     *
3770     * Install a package. Since this may take a little while, the result will
3771     * be posted back to the given observer.  An installation will fail if the calling context
3772     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3773     * package named in the package file's manifest is already installed, or if there's no space
3774     * available on the device.
3775     *
3776     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3777     * 'content:' URI.
3778     * @param observer An observer callback to get notified when the package installation is
3779     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3780     * called when that happens. This parameter must not be null.
3781     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3782     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3783     * @param installerPackageName Optional package name of the application that is performing the
3784     * installation. This identifies which market the package came from.
3785     */
3786    public abstract void installPackage(
3787            Uri packageURI, PackageInstallObserver observer,
3788            int flags, String installerPackageName);
3789
3790
3791    /**
3792     * @hide
3793     * Install a package. Since this may take a little while, the result will be
3794     * posted back to the given observer. An installation will fail if the package named
3795     * in the package file's manifest is already installed, or if there's no space
3796     * available on the device.
3797     * @param packageURI The location of the package file to install. This can be a 'file:' or a
3798     * 'content:' URI.
3799     * @param observer An observer callback to get notified when the package installation is
3800     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3801     * called when that happens. This parameter must not be null.
3802     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3803     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3804     * @param installerPackageName Optional package name of the application that is performing the
3805     * installation. This identifies which market the package came from.
3806     * @param userId The user id.
3807     */
3808     @RequiresPermission(anyOf = {
3809            Manifest.permission.INSTALL_PACKAGES,
3810            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
3811    public abstract void installPackageAsUser(
3812            Uri packageURI, PackageInstallObserver observer, int flags,
3813            String installerPackageName, int userId);
3814
3815    /**
3816     * Similar to
3817     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3818     * with an extra verification file provided.
3819     *
3820     * @param packageURI The location of the package file to install. This can
3821     *            be a 'file:' or a 'content:' URI.
3822     * @param observer An observer callback to get notified when the package installation is
3823     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3824     * called when that happens. This parameter must not be null.
3825     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3826     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3827     * @param installerPackageName Optional package name of the application that
3828     *            is performing the installation. This identifies which market
3829     *            the package came from.
3830     * @param verificationURI The location of the supplementary verification
3831     *            file. This can be a 'file:' or a 'content:' URI. May be
3832     *            {@code null}.
3833     * @param manifestDigest an object that holds the digest of the package
3834     *            which can be used to verify ownership. May be {@code null}.
3835     * @param encryptionParams if the package to be installed is encrypted,
3836     *            these parameters describing the encryption and authentication
3837     *            used. May be {@code null}.
3838     * @hide
3839     */
3840    public abstract void installPackageWithVerification(Uri packageURI,
3841            PackageInstallObserver observer, int flags, String installerPackageName,
3842            Uri verificationURI, ManifestDigest manifestDigest,
3843            ContainerEncryptionParams encryptionParams);
3844
3845    /**
3846     * Similar to
3847     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3848     * with an extra verification information provided.
3849     *
3850     * @param packageURI The location of the package file to install. This can
3851     *            be a 'file:' or a 'content:' URI.
3852     * @param observer An observer callback to get notified when the package installation is
3853     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3854     * called when that happens. This parameter must not be null.
3855     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3856     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3857     * @param installerPackageName Optional package name of the application that
3858     *            is performing the installation. This identifies which market
3859     *            the package came from.
3860     * @param verificationParams an object that holds signal information to
3861     *            assist verification. May be {@code null}.
3862     * @param encryptionParams if the package to be installed is encrypted,
3863     *            these parameters describing the encryption and authentication
3864     *            used. May be {@code null}.
3865     *
3866     * @hide
3867     */
3868    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3869            PackageInstallObserver observer, int flags, String installerPackageName,
3870            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3871
3872    /**
3873     * If there is already an application with the given package name installed
3874     * on the system for other users, also install it for the calling user.
3875     * @hide
3876     */
3877    // @SystemApi
3878    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
3879
3880    /**
3881     * If there is already an application with the given package name installed
3882     * on the system for other users, also install it for the specified user.
3883     * @hide
3884     */
3885     @RequiresPermission(anyOf = {
3886            Manifest.permission.INSTALL_PACKAGES,
3887            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
3888    public abstract int installExistingPackageAsUser(String packageName, int userId)
3889            throws NameNotFoundException;
3890
3891    /**
3892     * Allows a package listening to the
3893     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3894     * broadcast} to respond to the package manager. The response must include
3895     * the {@code verificationCode} which is one of
3896     * {@link PackageManager#VERIFICATION_ALLOW} or
3897     * {@link PackageManager#VERIFICATION_REJECT}.
3898     *
3899     * @param id pending package identifier as passed via the
3900     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3901     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3902     *            or {@link PackageManager#VERIFICATION_REJECT}.
3903     * @throws SecurityException if the caller does not have the
3904     *            PACKAGE_VERIFICATION_AGENT permission.
3905     */
3906    public abstract void verifyPendingInstall(int id, int verificationCode);
3907
3908    /**
3909     * Allows a package listening to the
3910     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3911     * broadcast} to extend the default timeout for a response and declare what
3912     * action to perform after the timeout occurs. The response must include
3913     * the {@code verificationCodeAtTimeout} which is one of
3914     * {@link PackageManager#VERIFICATION_ALLOW} or
3915     * {@link PackageManager#VERIFICATION_REJECT}.
3916     *
3917     * This method may only be called once per package id. Additional calls
3918     * will have no effect.
3919     *
3920     * @param id pending package identifier as passed via the
3921     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3922     * @param verificationCodeAtTimeout either
3923     *            {@link PackageManager#VERIFICATION_ALLOW} or
3924     *            {@link PackageManager#VERIFICATION_REJECT}. If
3925     *            {@code verificationCodeAtTimeout} is neither
3926     *            {@link PackageManager#VERIFICATION_ALLOW} or
3927     *            {@link PackageManager#VERIFICATION_REJECT}, then
3928     *            {@code verificationCodeAtTimeout} will default to
3929     *            {@link PackageManager#VERIFICATION_REJECT}.
3930     * @param millisecondsToDelay the amount of time requested for the timeout.
3931     *            Must be positive and less than
3932     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3933     *            {@code millisecondsToDelay} is out of bounds,
3934     *            {@code millisecondsToDelay} will be set to the closest in
3935     *            bounds value; namely, 0 or
3936     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3937     * @throws SecurityException if the caller does not have the
3938     *            PACKAGE_VERIFICATION_AGENT permission.
3939     */
3940    public abstract void extendVerificationTimeout(int id,
3941            int verificationCodeAtTimeout, long millisecondsToDelay);
3942
3943    /**
3944     * Allows a package listening to the
3945     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification
3946     * broadcast} to respond to the package manager. The response must include
3947     * the {@code verificationCode} which is one of
3948     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
3949     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
3950     *
3951     * @param verificationId pending package identifier as passed via the
3952     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3953     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
3954     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
3955     * @param outFailedDomains a list of failed domains if the verificationCode is
3956     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
3957     * @throws SecurityException if the caller does not have the
3958     *            INTENT_FILTER_VERIFICATION_AGENT permission.
3959     *
3960     * @hide
3961     */
3962    @SystemApi
3963    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
3964            List<String> outFailedDomains);
3965
3966    /**
3967     * Get the status of a Domain Verification Result for an IntentFilter. This is
3968     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
3969     * {@link android.content.IntentFilter#getAutoVerify()}
3970     *
3971     * This is used by the ResolverActivity to change the status depending on what the User select
3972     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
3973     * for a domain.
3974     *
3975     * @param packageName The package name of the Activity associated with the IntentFilter.
3976     * @param userId The user id.
3977     *
3978     * @return The status to set to. This can be
3979     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
3980     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
3981     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
3982     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
3983     *
3984     * @hide
3985     */
3986    public abstract int getIntentVerificationStatus(String packageName, int userId);
3987
3988    /**
3989     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
3990     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
3991     * {@link android.content.IntentFilter#getAutoVerify()}
3992     *
3993     * This is used by the ResolverActivity to change the status depending on what the User select
3994     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
3995     * for a domain.
3996     *
3997     * @param packageName The package name of the Activity associated with the IntentFilter.
3998     * @param status The status to set to. This can be
3999     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4000     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4001     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4002     * @param userId The user id.
4003     *
4004     * @return true if the status has been set. False otherwise.
4005     *
4006     * @hide
4007     */
4008    public abstract boolean updateIntentVerificationStatus(String packageName, int status,
4009            int userId);
4010
4011    /**
4012     * Get the list of IntentFilterVerificationInfo for a specific package and User.
4013     *
4014     * @param packageName the package name. When this parameter is set to a non null value,
4015     *                    the results will be filtered by the package name provided.
4016     *                    Otherwise, there will be no filtering and it will return a list
4017     *                    corresponding for all packages
4018     *
4019     * @return a list of IntentFilterVerificationInfo for a specific package.
4020     *
4021     * @hide
4022     */
4023    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4024            String packageName);
4025
4026    /**
4027     * Get the list of IntentFilter for a specific package.
4028     *
4029     * @param packageName the package name. This parameter is set to a non null value,
4030     *                    the list will contain all the IntentFilter for that package.
4031     *                    Otherwise, the list will be empty.
4032     *
4033     * @return a list of IntentFilter for a specific package.
4034     *
4035     * @hide
4036     */
4037    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4038
4039    /**
4040     * Get the default Browser package name for a specific user.
4041     *
4042     * @param userId The user id.
4043     *
4044     * @return the package name of the default Browser for the specified user. If the user id passed
4045     *         is -1 (all users) it will return a null value.
4046     *
4047     * @hide
4048     */
4049    public abstract String getDefaultBrowserPackageName(int userId);
4050
4051    /**
4052     * Set the default Browser package name for a specific user.
4053     *
4054     * @param packageName The package name of the default Browser.
4055     * @param userId The user id.
4056     *
4057     * @return true if the default Browser for the specified user has been set,
4058     *         otherwise return false. If the user id passed is -1 (all users) this call will not
4059     *         do anything and just return false.
4060     *
4061     * @hide
4062     */
4063    public abstract boolean setDefaultBrowserPackageName(String packageName, int userId);
4064
4065    /**
4066     * Change the installer associated with a given package.  There are limitations
4067     * on how the installer package can be changed; in particular:
4068     * <ul>
4069     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4070     * is not signed with the same certificate as the calling application.
4071     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4072     * has an installer package, and that installer package is not signed with
4073     * the same certificate as the calling application.
4074     * </ul>
4075     *
4076     * @param targetPackage The installed package whose installer will be changed.
4077     * @param installerPackageName The package name of the new installer.  May be
4078     * null to clear the association.
4079     */
4080    public abstract void setInstallerPackageName(String targetPackage,
4081            String installerPackageName);
4082
4083    /**
4084     * Attempts to delete a package.  Since this may take a little while, the result will
4085     * be posted back to the given observer.  A deletion will fail if the calling context
4086     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
4087     * named package cannot be found, or if the named package is a "system package".
4088     * (TODO: include pointer to documentation on "system packages")
4089     *
4090     * @param packageName The name of the package to delete
4091     * @param observer An observer callback to get notified when the package deletion is
4092     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
4093     * called when that happens.  observer may be null to indicate that no callback is desired.
4094     * @param flags Possible values: {@link #DELETE_KEEP_DATA},
4095     * {@link #DELETE_ALL_USERS}.
4096     *
4097     * @hide
4098     */
4099    // @SystemApi
4100    public abstract void deletePackage(
4101            String packageName, IPackageDeleteObserver observer, int flags);
4102
4103    /**
4104     * Attempts to delete a package.  Since this may take a little while, the result will
4105     * be posted back to the given observer. A deletion will fail if the named package cannot be
4106     * found, or if the named package is a "system package".
4107     * (TODO: include pointer to documentation on "system packages")
4108     *
4109     * @param packageName The name of the package to delete
4110     * @param observer An observer callback to get notified when the package deletion is
4111     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
4112     * called when that happens.  observer may be null to indicate that no callback is desired.
4113     * @param flags Possible values: {@link #DELETE_KEEP_DATA}, {@link #DELETE_ALL_USERS}.
4114     * @param userId The user Id
4115     *
4116     * @hide
4117     */
4118     @RequiresPermission(anyOf = {
4119            Manifest.permission.DELETE_PACKAGES,
4120            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4121    public abstract void deletePackageAsUser(
4122            String packageName, IPackageDeleteObserver observer, int flags, int userId);
4123
4124    /**
4125     * Retrieve the package name of the application that installed a package. This identifies
4126     * which market the package came from.
4127     *
4128     * @param packageName The name of the package to query
4129     */
4130    public abstract String getInstallerPackageName(String packageName);
4131
4132    /**
4133     * Attempts to clear the user data directory of an application.
4134     * Since this may take a little while, the result will
4135     * be posted back to the given observer.  A deletion will fail if the
4136     * named package cannot be found, or if the named package is a "system package".
4137     *
4138     * @param packageName The name of the package
4139     * @param observer An observer callback to get notified when the operation is finished
4140     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4141     * will be called when that happens.  observer may be null to indicate that
4142     * no callback is desired.
4143     *
4144     * @hide
4145     */
4146    public abstract void clearApplicationUserData(String packageName,
4147            IPackageDataObserver observer);
4148    /**
4149     * Attempts to delete the cache files associated with an application.
4150     * Since this may take a little while, the result will
4151     * be posted back to the given observer.  A deletion will fail if the calling context
4152     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
4153     * named package cannot be found, or if the named package is a "system package".
4154     *
4155     * @param packageName The name of the package to delete
4156     * @param observer An observer callback to get notified when the cache file deletion
4157     * is complete.
4158     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4159     * will be called when that happens.  observer may be null to indicate that
4160     * no callback is desired.
4161     *
4162     * @hide
4163     */
4164    public abstract void deleteApplicationCacheFiles(String packageName,
4165            IPackageDataObserver observer);
4166
4167    /**
4168     * Free storage by deleting LRU sorted list of cache files across
4169     * all applications. If the currently available free storage
4170     * on the device is greater than or equal to the requested
4171     * free storage, no cache files are cleared. If the currently
4172     * available storage on the device is less than the requested
4173     * free storage, some or all of the cache files across
4174     * all applications are deleted (based on last accessed time)
4175     * to increase the free storage space on the device to
4176     * the requested value. There is no guarantee that clearing all
4177     * the cache files from all applications will clear up
4178     * enough storage to achieve the desired value.
4179     * @param freeStorageSize The number of bytes of storage to be
4180     * freed by the system. Say if freeStorageSize is XX,
4181     * and the current free storage is YY,
4182     * if XX is less than YY, just return. if not free XX-YY number
4183     * of bytes if possible.
4184     * @param observer call back used to notify when
4185     * the operation is completed
4186     *
4187     * @hide
4188     */
4189    // @SystemApi
4190    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
4191        freeStorageAndNotify(null, freeStorageSize, observer);
4192    }
4193
4194    /** {@hide} */
4195    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
4196            IPackageDataObserver observer);
4197
4198    /**
4199     * Free storage by deleting LRU sorted list of cache files across
4200     * all applications. If the currently available free storage
4201     * on the device is greater than or equal to the requested
4202     * free storage, no cache files are cleared. If the currently
4203     * available storage on the device is less than the requested
4204     * free storage, some or all of the cache files across
4205     * all applications are deleted (based on last accessed time)
4206     * to increase the free storage space on the device to
4207     * the requested value. There is no guarantee that clearing all
4208     * the cache files from all applications will clear up
4209     * enough storage to achieve the desired value.
4210     * @param freeStorageSize The number of bytes of storage to be
4211     * freed by the system. Say if freeStorageSize is XX,
4212     * and the current free storage is YY,
4213     * if XX is less than YY, just return. if not free XX-YY number
4214     * of bytes if possible.
4215     * @param pi IntentSender call back used to
4216     * notify when the operation is completed.May be null
4217     * to indicate that no call back is desired.
4218     *
4219     * @hide
4220     */
4221    public void freeStorage(long freeStorageSize, IntentSender pi) {
4222        freeStorage(null, freeStorageSize, pi);
4223    }
4224
4225    /** {@hide} */
4226    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
4227
4228    /**
4229     * Retrieve the size information for a package.
4230     * Since this may take a little while, the result will
4231     * be posted back to the given observer.  The calling context
4232     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
4233     *
4234     * @param packageName The name of the package whose size information is to be retrieved
4235     * @param userHandle The user whose size information should be retrieved.
4236     * @param observer An observer callback to get notified when the operation
4237     * is complete.
4238     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
4239     * The observer's callback is invoked with a PackageStats object(containing the
4240     * code, data and cache sizes of the package) and a boolean value representing
4241     * the status of the operation. observer may be null to indicate that
4242     * no callback is desired.
4243     *
4244     * @hide
4245     */
4246    public abstract void getPackageSizeInfo(String packageName, int userHandle,
4247            IPackageStatsObserver observer);
4248
4249    /**
4250     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
4251     * returns the size for the calling user.
4252     *
4253     * @hide
4254     */
4255    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
4256        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
4257    }
4258
4259    /**
4260     * @deprecated This function no longer does anything; it was an old
4261     * approach to managing preferred activities, which has been superseded
4262     * by (and conflicts with) the modern activity-based preferences.
4263     */
4264    @Deprecated
4265    public abstract void addPackageToPreferred(String packageName);
4266
4267    /**
4268     * @deprecated This function no longer does anything; it was an old
4269     * approach to managing preferred activities, which has been superseded
4270     * by (and conflicts with) the modern activity-based preferences.
4271     */
4272    @Deprecated
4273    public abstract void removePackageFromPreferred(String packageName);
4274
4275    /**
4276     * Retrieve the list of all currently configured preferred packages.  The
4277     * first package on the list is the most preferred, the last is the
4278     * least preferred.
4279     *
4280     * @param flags Additional option flags. Use any combination of
4281     * {@link #GET_ACTIVITIES},
4282     * {@link #GET_GIDS},
4283     * {@link #GET_CONFIGURATIONS},
4284     * {@link #GET_INSTRUMENTATION},
4285     * {@link #GET_PERMISSIONS},
4286     * {@link #GET_PROVIDERS},
4287     * {@link #GET_RECEIVERS},
4288     * {@link #GET_SERVICES},
4289     * {@link #GET_SIGNATURES}, to modify the data returned.
4290     *
4291     * @return Returns a list of PackageInfo objects describing each
4292     * preferred application, in order of preference.
4293     *
4294     * @see #GET_ACTIVITIES
4295     * @see #GET_GIDS
4296     * @see #GET_CONFIGURATIONS
4297     * @see #GET_INSTRUMENTATION
4298     * @see #GET_PERMISSIONS
4299     * @see #GET_PROVIDERS
4300     * @see #GET_RECEIVERS
4301     * @see #GET_SERVICES
4302     * @see #GET_SIGNATURES
4303     */
4304    public abstract List<PackageInfo> getPreferredPackages(int flags);
4305
4306    /**
4307     * @deprecated This is a protected API that should not have been available
4308     * to third party applications.  It is the platform's responsibility for
4309     * assigning preferred activities and this cannot be directly modified.
4310     *
4311     * Add a new preferred activity mapping to the system.  This will be used
4312     * to automatically select the given activity component when
4313     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4314     * multiple matching activities and also matches the given filter.
4315     *
4316     * @param filter The set of intents under which this activity will be
4317     * made preferred.
4318     * @param match The IntentFilter match category that this preference
4319     * applies to.
4320     * @param set The set of activities that the user was picking from when
4321     * this preference was made.
4322     * @param activity The component name of the activity that is to be
4323     * preferred.
4324     */
4325    @Deprecated
4326    public abstract void addPreferredActivity(IntentFilter filter, int match,
4327            ComponentName[] set, ComponentName activity);
4328
4329    /**
4330     * Same as {@link #addPreferredActivity(IntentFilter, int,
4331            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
4332            to.
4333     * @hide
4334     */
4335    public void addPreferredActivity(IntentFilter filter, int match,
4336            ComponentName[] set, ComponentName activity, int userId) {
4337        throw new RuntimeException("Not implemented. Must override in a subclass.");
4338    }
4339
4340    /**
4341     * @deprecated This is a protected API that should not have been available
4342     * to third party applications.  It is the platform's responsibility for
4343     * assigning preferred activities and this cannot be directly modified.
4344     *
4345     * Replaces an existing preferred activity mapping to the system, and if that were not present
4346     * adds a new preferred activity.  This will be used
4347     * to automatically select the given activity component when
4348     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4349     * multiple matching activities and also matches the given filter.
4350     *
4351     * @param filter The set of intents under which this activity will be
4352     * made preferred.
4353     * @param match The IntentFilter match category that this preference
4354     * applies to.
4355     * @param set The set of activities that the user was picking from when
4356     * this preference was made.
4357     * @param activity The component name of the activity that is to be
4358     * preferred.
4359     * @hide
4360     */
4361    @Deprecated
4362    public abstract void replacePreferredActivity(IntentFilter filter, int match,
4363            ComponentName[] set, ComponentName activity);
4364
4365    /**
4366     * @hide
4367     */
4368    @Deprecated
4369    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
4370           ComponentName[] set, ComponentName activity, int userId) {
4371        throw new RuntimeException("Not implemented. Must override in a subclass.");
4372    }
4373
4374    /**
4375     * Remove all preferred activity mappings, previously added with
4376     * {@link #addPreferredActivity}, from the
4377     * system whose activities are implemented in the given package name.
4378     * An application can only clear its own package(s).
4379     *
4380     * @param packageName The name of the package whose preferred activity
4381     * mappings are to be removed.
4382     */
4383    public abstract void clearPackagePreferredActivities(String packageName);
4384
4385    /**
4386     * Retrieve all preferred activities, previously added with
4387     * {@link #addPreferredActivity}, that are
4388     * currently registered with the system.
4389     *
4390     * @param outFilters A required list in which to place the filters of all of the
4391     * preferred activities.
4392     * @param outActivities A required list in which to place the component names of
4393     * all of the preferred activities.
4394     * @param packageName An optional package in which you would like to limit
4395     * the list.  If null, all activities will be returned; if non-null, only
4396     * those activities in the given package are returned.
4397     *
4398     * @return Returns the total number of registered preferred activities
4399     * (the number of distinct IntentFilter records, not the number of unique
4400     * activity components) that were found.
4401     */
4402    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
4403            @NonNull List<ComponentName> outActivities, String packageName);
4404
4405    /**
4406     * Ask for the set of available 'home' activities and the current explicit
4407     * default, if any.
4408     * @hide
4409     */
4410    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
4411
4412    /**
4413     * Set the enabled setting for a package component (activity, receiver, service, provider).
4414     * This setting will override any enabled state which may have been set by the component in its
4415     * manifest.
4416     *
4417     * @param componentName The component to enable
4418     * @param newState The new enabled state for the component.  The legal values for this state
4419     *                 are:
4420     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4421     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4422     *                   and
4423     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4424     *                 The last one removes the setting, thereby restoring the component's state to
4425     *                 whatever was set in it's manifest (or enabled, by default).
4426     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4427     */
4428    public abstract void setComponentEnabledSetting(ComponentName componentName,
4429            int newState, int flags);
4430
4431
4432    /**
4433     * Return the enabled setting for a package component (activity,
4434     * receiver, service, provider).  This returns the last value set by
4435     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
4436     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4437     * the value originally specified in the manifest has not been modified.
4438     *
4439     * @param componentName The component to retrieve.
4440     * @return Returns the current enabled state for the component.  May
4441     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4442     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4443     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4444     * component's enabled state is based on the original information in
4445     * the manifest as found in {@link ComponentInfo}.
4446     */
4447    public abstract int getComponentEnabledSetting(ComponentName componentName);
4448
4449    /**
4450     * Set the enabled setting for an application
4451     * This setting will override any enabled state which may have been set by the application in
4452     * its manifest.  It also overrides the enabled state set in the manifest for any of the
4453     * application's components.  It does not override any enabled state set by
4454     * {@link #setComponentEnabledSetting} for any of the application's components.
4455     *
4456     * @param packageName The package name of the application to enable
4457     * @param newState The new enabled state for the component.  The legal values for this state
4458     *                 are:
4459     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4460     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4461     *                   and
4462     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4463     *                 The last one removes the setting, thereby restoring the applications's state to
4464     *                 whatever was set in its manifest (or enabled, by default).
4465     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4466     */
4467    public abstract void setApplicationEnabledSetting(String packageName,
4468            int newState, int flags);
4469
4470    /**
4471     * Return the enabled setting for an application. This returns
4472     * the last value set by
4473     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
4474     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4475     * the value originally specified in the manifest has not been modified.
4476     *
4477     * @param packageName The package name of the application to retrieve.
4478     * @return Returns the current enabled state for the application.  May
4479     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4480     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4481     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4482     * application's enabled state is based on the original information in
4483     * the manifest as found in {@link ComponentInfo}.
4484     * @throws IllegalArgumentException if the named package does not exist.
4485     */
4486    public abstract int getApplicationEnabledSetting(String packageName);
4487
4488    /**
4489     * Puts the package in a hidden state, which is almost like an uninstalled state,
4490     * making the package unavailable, but it doesn't remove the data or the actual
4491     * package file. Application can be unhidden by either resetting the hidden state
4492     * or by installing it, such as with {@link #installExistingPackage(String)}
4493     * @hide
4494     */
4495    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
4496            UserHandle userHandle);
4497
4498    /**
4499     * Returns the hidden state of a package.
4500     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
4501     * @hide
4502     */
4503    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
4504            UserHandle userHandle);
4505
4506    /**
4507     * Return whether the device has been booted into safe mode.
4508     */
4509    public abstract boolean isSafeMode();
4510
4511    /**
4512     * Adds a listener for permission changes for installed packages.
4513     *
4514     * @param listener The listener to add.
4515     *
4516     * @hide
4517     */
4518    @SystemApi
4519    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
4520    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
4521
4522    /**
4523     * Remvoes a listener for permission changes for installed packages.
4524     *
4525     * @param listener The listener to remove.
4526     *
4527     * @hide
4528     */
4529    @SystemApi
4530    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
4531
4532    /**
4533     * Return the {@link KeySet} associated with the String alias for this
4534     * application.
4535     *
4536     * @param alias The alias for a given {@link KeySet} as defined in the
4537     *        application's AndroidManifest.xml.
4538     * @hide
4539     */
4540    public abstract KeySet getKeySetByAlias(String packageName, String alias);
4541
4542    /** Return the signing {@link KeySet} for this application.
4543     * @hide
4544     */
4545    public abstract KeySet getSigningKeySet(String packageName);
4546
4547    /**
4548     * Return whether the package denoted by packageName has been signed by all
4549     * of the keys specified by the {@link KeySet} ks.  This will return true if
4550     * the package has been signed by additional keys (a superset) as well.
4551     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
4552     * @hide
4553     */
4554    public abstract boolean isSignedBy(String packageName, KeySet ks);
4555
4556    /**
4557     * Return whether the package denoted by packageName has been signed by all
4558     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
4559     * {@link #isSignedBy(String packageName, KeySet ks)}.
4560     * @hide
4561     */
4562    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
4563
4564    /**
4565     * Attempts to move package resources from internal to external media or vice versa.
4566     * Since this may take a little while, the result will
4567     * be posted back to the given observer.   This call may fail if the calling context
4568     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
4569     * named package cannot be found, or if the named package is a "system package".
4570     *
4571     * @param packageName The name of the package to delete
4572     * @param observer An observer callback to get notified when the package move is
4573     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
4574     * called when that happens.  observer may be null to indicate that no callback is desired.
4575     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
4576     * {@link #MOVE_EXTERNAL_MEDIA}
4577     *
4578     * @hide
4579     */
4580    @Deprecated
4581    public void movePackage(String packageName, IPackageMoveObserver observer, int flags) {
4582        throw new UnsupportedOperationException();
4583    }
4584
4585    /** {@hide} */
4586    public static boolean isMoveStatusFinished(int status) {
4587        return (status < 0 || status > 100);
4588    }
4589
4590    /** {@hide} */
4591    public static abstract class MoveCallback {
4592        public void onCreated(int moveId, Bundle extras) {}
4593        public abstract void onStatusChanged(int moveId, int status, long estMillis);
4594    }
4595
4596    /** {@hide} */
4597    public abstract int getMoveStatus(int moveId);
4598
4599    /** {@hide} */
4600    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
4601    /** {@hide} */
4602    public abstract void unregisterMoveCallback(MoveCallback callback);
4603
4604    /** {@hide} */
4605    public abstract int movePackage(String packageName, VolumeInfo vol);
4606    /** {@hide} */
4607    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
4608    /** {@hide} */
4609    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
4610
4611    /** {@hide} */
4612    public abstract int movePrimaryStorage(VolumeInfo vol);
4613    /** {@hide} */
4614    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
4615    /** {@hide} */
4616    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
4617
4618    /**
4619     * Returns the device identity that verifiers can use to associate their scheme to a particular
4620     * device. This should not be used by anything other than a package verifier.
4621     *
4622     * @return identity that uniquely identifies current device
4623     * @hide
4624     */
4625    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
4626
4627    /**
4628     * Returns true if the device is upgrading, such as first boot after OTA.
4629     *
4630     * @hide
4631     */
4632    public abstract boolean isUpgrade();
4633
4634    /**
4635     * Return interface that offers the ability to install, upgrade, and remove
4636     * applications on the device.
4637     */
4638    public abstract @NonNull PackageInstaller getPackageInstaller();
4639
4640    /**
4641     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
4642     * user with id sourceUserId can also be be resolved by activities in the user with id
4643     * targetUserId if they match the specified intent filter.
4644     * @param filter The {@link IntentFilter} the intent has to match
4645     * @param sourceUserId The source user id.
4646     * @param targetUserId The target user id.
4647     * @param flags The possible values are {@link SKIP_CURRENT_PROFILE} and
4648     *        {@link ONLY_IF_NO_MATCH_FOUND}.
4649     * @hide
4650     */
4651    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
4652            int targetUserId, int flags);
4653
4654    /**
4655     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
4656     * source, and have been set by the app calling this method.
4657     * @param sourceUserId The source user id.
4658     * @hide
4659     */
4660    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
4661
4662    /**
4663     * @hide
4664     */
4665    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4666
4667    /**
4668     * @hide
4669     */
4670    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4671
4672    /** {@hide} */
4673    public abstract boolean isPackageAvailable(String packageName);
4674
4675    /** {@hide} */
4676    public static String installStatusToString(int status, String msg) {
4677        final String str = installStatusToString(status);
4678        if (msg != null) {
4679            return str + ": " + msg;
4680        } else {
4681            return str;
4682        }
4683    }
4684
4685    /** {@hide} */
4686    public static String installStatusToString(int status) {
4687        switch (status) {
4688            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
4689            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
4690            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
4691            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
4692            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
4693            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
4694            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
4695            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
4696            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
4697            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
4698            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
4699            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
4700            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
4701            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
4702            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
4703            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
4704            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
4705            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
4706            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
4707            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
4708            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
4709            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
4710            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
4711            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
4712            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
4713            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
4714            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
4715            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
4716            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
4717            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
4718            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
4719            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
4720            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
4721            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
4722            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
4723            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
4724            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
4725            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
4726            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
4727            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
4728            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
4729            default: return Integer.toString(status);
4730        }
4731    }
4732
4733    /** {@hide} */
4734    public static int installStatusToPublicStatus(int status) {
4735        switch (status) {
4736            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4737            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4738            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4739            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
4740            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4741            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4742            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4743            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4744            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4745            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4746            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4747            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
4748            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4749            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4750            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4751            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
4752            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4753            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4754            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
4755            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
4756            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4757            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
4758            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
4759            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4760            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4761            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4762            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4763            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4764            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
4765            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
4766            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4767            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4768            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
4769            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
4770            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
4771            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
4772            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
4773            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4774            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4775            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4776            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4777            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4778            default: return PackageInstaller.STATUS_FAILURE;
4779        }
4780    }
4781
4782    /** {@hide} */
4783    public static String deleteStatusToString(int status, String msg) {
4784        final String str = deleteStatusToString(status);
4785        if (msg != null) {
4786            return str + ": " + msg;
4787        } else {
4788            return str;
4789        }
4790    }
4791
4792    /** {@hide} */
4793    public static String deleteStatusToString(int status) {
4794        switch (status) {
4795            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
4796            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
4797            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
4798            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
4799            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
4800            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
4801            default: return Integer.toString(status);
4802        }
4803    }
4804
4805    /** {@hide} */
4806    public static int deleteStatusToPublicStatus(int status) {
4807        switch (status) {
4808            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4809            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4810            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4811            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4812            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4813            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4814            default: return PackageInstaller.STATUS_FAILURE;
4815        }
4816    }
4817
4818    /** {@hide} */
4819    public static String permissionFlagToString(int flag) {
4820        switch (flag) {
4821            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
4822            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
4823            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
4824            case FLAG_PERMISSION_USER_SET: return "USER_SET";
4825            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
4826            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
4827            case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
4828            default: return Integer.toString(flag);
4829        }
4830    }
4831
4832    /** {@hide} */
4833    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
4834        private final IPackageInstallObserver mLegacy;
4835
4836        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
4837            mLegacy = legacy;
4838        }
4839
4840        @Override
4841        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
4842                Bundle extras) {
4843            if (mLegacy == null) return;
4844            try {
4845                mLegacy.packageInstalled(basePackageName, returnCode);
4846            } catch (RemoteException ignored) {
4847            }
4848        }
4849    }
4850
4851    /** {@hide} */
4852    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
4853        private final IPackageDeleteObserver mLegacy;
4854
4855        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
4856            mLegacy = legacy;
4857        }
4858
4859        @Override
4860        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
4861            if (mLegacy == null) return;
4862            try {
4863                mLegacy.packageDeleted(basePackageName, returnCode);
4864            } catch (RemoteException ignored) {
4865            }
4866        }
4867    }
4868}
4869