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