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