PackageManager.java revision 373f0b4313d3a2444aebf6b89a71c4ba64566110
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     * Action to external storage service to clean out removed apps.
1834     * @hide
1835     */
1836    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
1837            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
1838
1839    /**
1840     * Extra field name for the URI to a verification file. Passed to a package
1841     * verifier.
1842     *
1843     * @hide
1844     */
1845    public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI";
1846
1847    /**
1848     * Extra field name for the ID of a package pending verification. Passed to
1849     * a package verifier and is used to call back to
1850     * {@link PackageManager#verifyPendingInstall(int, int)}
1851     */
1852    public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID";
1853
1854    /**
1855     * Extra field name for the package identifier which is trying to install
1856     * the package.
1857     *
1858     * @hide
1859     */
1860    public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE
1861            = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE";
1862
1863    /**
1864     * Extra field name for the requested install flags for a package pending
1865     * verification. Passed to a package verifier.
1866     *
1867     * @hide
1868     */
1869    public static final String EXTRA_VERIFICATION_INSTALL_FLAGS
1870            = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS";
1871
1872    /**
1873     * Extra field name for the uid of who is requesting to install
1874     * the package.
1875     *
1876     * @hide
1877     */
1878    public static final String EXTRA_VERIFICATION_INSTALLER_UID
1879            = "android.content.pm.extra.VERIFICATION_INSTALLER_UID";
1880
1881    /**
1882     * Extra field name for the package name of a package pending verification.
1883     *
1884     * @hide
1885     */
1886    public static final String EXTRA_VERIFICATION_PACKAGE_NAME
1887            = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME";
1888    /**
1889     * Extra field name for the result of a verification, either
1890     * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}.
1891     * Passed to package verifiers after a package is verified.
1892     */
1893    public static final String EXTRA_VERIFICATION_RESULT
1894            = "android.content.pm.extra.VERIFICATION_RESULT";
1895
1896    /**
1897     * Extra field name for the version code of a package pending verification.
1898     *
1899     * @hide
1900     */
1901    public static final String EXTRA_VERIFICATION_VERSION_CODE
1902            = "android.content.pm.extra.VERIFICATION_VERSION_CODE";
1903
1904    /**
1905     * Extra field name for the ID of a intent filter pending verification. Passed to
1906     * an intent filter verifier and is used to call back to
1907     * {@link PackageManager#verifyIntentFilter(int, int)}
1908     *
1909     * @hide
1910     */
1911    public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID
1912            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID";
1913
1914    /**
1915     * Extra field name for the scheme used for an intent filter pending verification. Passed to
1916     * an intent filter verifier and is used to construct the URI to verify against.
1917     *
1918     * Usually this is "https"
1919     *
1920     * @hide
1921     */
1922    public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME
1923            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME";
1924
1925    /**
1926     * Extra field name for the host names to be used for an intent filter pending verification.
1927     * Passed to an intent filter verifier and is used to construct the URI to verify the
1928     * intent filter.
1929     *
1930     * This is a space delimited list of hosts.
1931     *
1932     * @hide
1933     */
1934    public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS
1935            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS";
1936
1937    /**
1938     * Extra field name for the package name to be used for an intent filter pending verification.
1939     * Passed to an intent filter verifier and is used to check the verification responses coming
1940     * from the hosts. Each host response will need to include the package name of APK containing
1941     * the intent filter.
1942     *
1943     * @hide
1944     */
1945    public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME
1946            = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME";
1947
1948    /**
1949     * The action used to request that the user approve a permission request
1950     * from the application.
1951     *
1952     * @hide
1953     */
1954    @SystemApi
1955    public static final String ACTION_REQUEST_PERMISSIONS =
1956            "android.content.pm.action.REQUEST_PERMISSIONS";
1957
1958    /**
1959     * The names of the requested permissions.
1960     * <p>
1961     * <strong>Type:</strong> String[]
1962     * </p>
1963     *
1964     * @hide
1965     */
1966    @SystemApi
1967    public static final String EXTRA_REQUEST_PERMISSIONS_NAMES =
1968            "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES";
1969
1970    /**
1971     * The results from the permissions request.
1972     * <p>
1973     * <strong>Type:</strong> int[] of #PermissionResult
1974     * </p>
1975     *
1976     * @hide
1977     */
1978    @SystemApi
1979    public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS
1980            = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS";
1981
1982    /**
1983     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1984     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the package which provides
1985     * the existing definition for the permission.
1986     * @hide
1987     */
1988    public static final String EXTRA_FAILURE_EXISTING_PACKAGE
1989            = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE";
1990
1991    /**
1992     * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of
1993     * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}.  This extra names the permission that is
1994     * being redundantly defined by the package being installed.
1995     * @hide
1996     */
1997    public static final String EXTRA_FAILURE_EXISTING_PERMISSION
1998            = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION";
1999
2000   /**
2001    * Permission flag: The permission is set in its current state
2002    * by the user and apps can still request it at runtime.
2003    *
2004    * @hide
2005    */
2006    public static final int FLAG_PERMISSION_USER_SET = 1 << 0;
2007
2008    /**
2009     * Permission flag: The permission is set in its current state
2010     * by the user and it is fixed, i.e. apps can no longer request
2011     * this permission.
2012     *
2013     * @hide
2014     */
2015    public static final int FLAG_PERMISSION_USER_FIXED =  1 << 1;
2016
2017    /**
2018     * Permission flag: The permission is set in its current state
2019     * by device policy and neither apps nor the user can change
2020     * its state.
2021     *
2022     * @hide
2023     */
2024    public static final int FLAG_PERMISSION_POLICY_FIXED =  1 << 2;
2025
2026    /**
2027     * Permission flag: The permission is set in a granted state but
2028     * access to resources it guards is restricted by other means to
2029     * enable revoking a permission on legacy apps that do not support
2030     * runtime permissions. If this permission is upgraded to runtime
2031     * because the app was updated to support runtime permissions, the
2032     * the permission will be revoked in the upgrade process.
2033     *
2034     * @hide
2035     */
2036    public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE =  1 << 3;
2037
2038    /**
2039     * Permission flag: The permission is set in its current state
2040     * because the app is a component that is a part of the system.
2041     *
2042     * @hide
2043     */
2044    public static final int FLAG_PERMISSION_SYSTEM_FIXED =  1 << 4;
2045
2046    /**
2047     * Permission flag: The permission is granted by default because it
2048     * enables app functionality that is expected to work out-of-the-box
2049     * for providing a smooth user experience. For example, the phone app
2050     * is expected to have the phone permission.
2051     *
2052     * @hide
2053     */
2054    public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT =  1 << 5;
2055
2056    /**
2057     * Permission flag: The permission has to be reviewed before any of
2058     * the app components can run.
2059     *
2060     * @hide
2061     */
2062    public static final int FLAG_PERMISSION_REVIEW_REQUIRED =  1 << 6;
2063
2064    /**
2065     * Mask for all permission flags.
2066     *
2067     * @hide
2068     */
2069    @SystemApi
2070    public static final int MASK_PERMISSION_FLAGS = 0xFF;
2071
2072    /**
2073     * Retrieve overall information about an application package that is
2074     * installed on the system.
2075     * <p>
2076     * Throws {@link NameNotFoundException} if a package with the given name can
2077     * not be found on the system.
2078     *
2079     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2080     *            desired package.
2081     * @param flags Additional option flags. Use any combination of
2082     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2083     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2084     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2085     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2086     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
2087     *            modify the data returned.
2088     * @return A PackageInfo object containing information about the
2089     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
2090     *         package is not found in the list of installed applications, the
2091     *         package information is retrieved from the list of uninstalled
2092     *         applications (which includes installed applications as well as
2093     *         applications with data directory i.e. applications which had been
2094     *         deleted with {@code DONT_DELETE_DATA} flag set).
2095     * @see #GET_ACTIVITIES
2096     * @see #GET_GIDS
2097     * @see #GET_CONFIGURATIONS
2098     * @see #GET_INSTRUMENTATION
2099     * @see #GET_PERMISSIONS
2100     * @see #GET_PROVIDERS
2101     * @see #GET_RECEIVERS
2102     * @see #GET_SERVICES
2103     * @see #GET_SIGNATURES
2104     * @see #GET_UNINSTALLED_PACKAGES
2105     */
2106    public abstract PackageInfo getPackageInfo(String packageName, int flags)
2107            throws NameNotFoundException;
2108
2109    /**
2110     * @hide
2111     * Retrieve overall information about an application package that is
2112     * installed on the system.
2113     * <p>
2114     * Throws {@link NameNotFoundException} if a package with the given name can
2115     * not be found on the system.
2116     *
2117     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2118     *            desired package.
2119     * @param flags Additional option flags. Use any combination of
2120     *            {@link #GET_ACTIVITIES}, {@link #GET_GIDS},
2121     *            {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION},
2122     *            {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS},
2123     *            {@link #GET_RECEIVERS}, {@link #GET_SERVICES},
2124     *            {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to
2125     *            modify the data returned.
2126     * @param userId The user id.
2127     * @return A PackageInfo object containing information about the
2128     *         package. If flag GET_UNINSTALLED_PACKAGES is set and if the
2129     *         package is not found in the list of installed applications, the
2130     *         package information is retrieved from the list of uninstalled
2131     *         applications (which includes installed applications as well as
2132     *         applications with data directory i.e. applications which had been
2133     *         deleted with {@code DONT_DELETE_DATA} flag set).
2134     * @see #GET_ACTIVITIES
2135     * @see #GET_GIDS
2136     * @see #GET_CONFIGURATIONS
2137     * @see #GET_INSTRUMENTATION
2138     * @see #GET_PERMISSIONS
2139     * @see #GET_PROVIDERS
2140     * @see #GET_RECEIVERS
2141     * @see #GET_SERVICES
2142     * @see #GET_SIGNATURES
2143     * @see #GET_UNINSTALLED_PACKAGES
2144     */
2145    @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS)
2146    public abstract PackageInfo getPackageInfoAsUser(String packageName, int flags, int userId)
2147            throws NameNotFoundException;
2148
2149    /**
2150     * Map from the current package names in use on the device to whatever
2151     * the current canonical name of that package is.
2152     * @param names Array of current names to be mapped.
2153     * @return Returns an array of the same size as the original, containing
2154     * the canonical name for each package.
2155     */
2156    public abstract String[] currentToCanonicalPackageNames(String[] names);
2157
2158    /**
2159     * Map from a packages canonical name to the current name in use on the device.
2160     * @param names Array of new names to be mapped.
2161     * @return Returns an array of the same size as the original, containing
2162     * the current name for each package.
2163     */
2164    public abstract String[] canonicalToCurrentPackageNames(String[] names);
2165
2166    /**
2167     * Returns a "good" intent to launch a front-door activity in a package.
2168     * This is used, for example, to implement an "open" button when browsing
2169     * through packages.  The current implementation looks first for a main
2170     * activity in the category {@link Intent#CATEGORY_INFO}, and next for a
2171     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns
2172     * <code>null</code> if neither are found.
2173     *
2174     * @param packageName The name of the package to inspect.
2175     *
2176     * @return A fully-qualified {@link Intent} that can be used to launch the
2177     * main activity in the package. Returns <code>null</code> if the package
2178     * does not contain such an activity, or if <em>packageName</em> is not
2179     * recognized.
2180     */
2181    public abstract Intent getLaunchIntentForPackage(String packageName);
2182
2183    /**
2184     * Return a "good" intent to launch a front-door Leanback activity in a
2185     * package, for use for example to implement an "open" button when browsing
2186     * through packages. The current implementation will look for a main
2187     * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or
2188     * return null if no main leanback activities are found.
2189     * <p>
2190     * Throws {@link NameNotFoundException} if a package with the given name
2191     * cannot be found on the system.
2192     *
2193     * @param packageName The name of the package to inspect.
2194     * @return Returns either a fully-qualified Intent that can be used to launch
2195     *         the main Leanback activity in the package, or null if the package
2196     *         does not contain such an activity.
2197     */
2198    public abstract Intent getLeanbackLaunchIntentForPackage(String packageName);
2199
2200    /**
2201     * Return an array of all of the secondary group-ids that have been assigned
2202     * to a package.
2203     * <p>
2204     * Throws {@link NameNotFoundException} if a package with the given name
2205     * cannot be found on the system.
2206     *
2207     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2208     *            desired package.
2209     * @return Returns an int array of the assigned gids, or null if there are
2210     *         none.
2211     */
2212    public abstract int[] getPackageGids(String packageName)
2213            throws NameNotFoundException;
2214
2215    /**
2216     * @hide Return the uid associated with the given package name for the
2217     * given user.
2218     *
2219     * <p>Throws {@link NameNotFoundException} if a package with the given
2220     * name can not be found on the system.
2221     *
2222     * @param packageName The full name (i.e. com.google.apps.contacts) of the
2223     *                    desired package.
2224     * @param userHandle The user handle identifier to look up the package under.
2225     *
2226     * @return Returns an integer uid who owns the given package name.
2227     */
2228    public abstract int getPackageUid(String packageName, int userHandle)
2229            throws NameNotFoundException;
2230
2231    /**
2232     * Retrieve all of the information we know about a particular permission.
2233     *
2234     * <p>Throws {@link NameNotFoundException} if a permission with the given
2235     * name cannot be found on the system.
2236     *
2237     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
2238     *             of the permission you are interested in.
2239     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2240     * retrieve any meta-data associated with the permission.
2241     *
2242     * @return Returns a {@link PermissionInfo} containing information about the
2243     *         permission.
2244     */
2245    public abstract PermissionInfo getPermissionInfo(String name, int flags)
2246            throws NameNotFoundException;
2247
2248    /**
2249     * Query for all of the permissions associated with a particular group.
2250     *
2251     * <p>Throws {@link NameNotFoundException} if the given group does not
2252     * exist.
2253     *
2254     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
2255     *             of the permission group you are interested in.  Use null to
2256     *             find all of the permissions not associated with a group.
2257     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2258     * retrieve any meta-data associated with the permissions.
2259     *
2260     * @return Returns a list of {@link PermissionInfo} containing information
2261     * about all of the permissions in the given group.
2262     */
2263    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
2264            int flags) throws NameNotFoundException;
2265
2266    /**
2267     * Retrieve all of the information we know about a particular group of
2268     * permissions.
2269     *
2270     * <p>Throws {@link NameNotFoundException} if a permission group with the given
2271     * name cannot be found on the system.
2272     *
2273     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
2274     *             of the permission you are interested in.
2275     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2276     * retrieve any meta-data associated with the permission group.
2277     *
2278     * @return Returns a {@link PermissionGroupInfo} containing information
2279     * about the permission.
2280     */
2281    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
2282            int flags) throws NameNotFoundException;
2283
2284    /**
2285     * Retrieve all of the known permission groups in the system.
2286     *
2287     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
2288     * retrieve any meta-data associated with the permission group.
2289     *
2290     * @return Returns a list of {@link PermissionGroupInfo} containing
2291     * information about all of the known permission groups.
2292     */
2293    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
2294
2295    /**
2296     * Retrieve all of the information we know about a particular
2297     * package/application.
2298     *
2299     * <p>Throws {@link NameNotFoundException} if an application with the given
2300     * package name cannot be found on the system.
2301     *
2302     * @param packageName The full name (i.e. com.google.apps.contacts) of an
2303     *                    application.
2304     * @param flags Additional option flags. Use any combination of
2305     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2306     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2307     *
2308     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
2309     *         information about the package.
2310     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
2311     *         found in the list of installed applications,
2312     *         the application information is retrieved from the
2313     *         list of uninstalled applications(which includes
2314     *         installed applications as well as applications
2315     *         with data directory ie applications which had been
2316     *         deleted with {@code DONT_DELETE_DATA} flag set).
2317     *
2318     * @see #GET_META_DATA
2319     * @see #GET_SHARED_LIBRARY_FILES
2320     * @see #GET_UNINSTALLED_PACKAGES
2321     */
2322    public abstract ApplicationInfo getApplicationInfo(String packageName,
2323            int flags) throws NameNotFoundException;
2324
2325    /**
2326     * Retrieve all of the information we know about a particular activity
2327     * class.
2328     *
2329     * <p>Throws {@link NameNotFoundException} if an activity with the given
2330     * class name cannot be found on the system.
2331     *
2332     * @param component The full component name (i.e.
2333     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
2334     * class.
2335     * @param flags Additional option flags. Use any combination of
2336     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2337     * to modify the data (in ApplicationInfo) returned.
2338     *
2339     * @return {@link ActivityInfo} containing information about the activity.
2340     *
2341     * @see #GET_INTENT_FILTERS
2342     * @see #GET_META_DATA
2343     * @see #GET_SHARED_LIBRARY_FILES
2344     */
2345    public abstract ActivityInfo getActivityInfo(ComponentName component,
2346            int flags) throws NameNotFoundException;
2347
2348    /**
2349     * Retrieve all of the information we know about a particular receiver
2350     * class.
2351     *
2352     * <p>Throws {@link NameNotFoundException} if a receiver with the given
2353     * class name cannot be found on the system.
2354     *
2355     * @param component The full component name (i.e.
2356     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
2357     * class.
2358     * @param flags Additional option flags.  Use any combination of
2359     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2360     * to modify the data returned.
2361     *
2362     * @return {@link ActivityInfo} containing information about the receiver.
2363     *
2364     * @see #GET_INTENT_FILTERS
2365     * @see #GET_META_DATA
2366     * @see #GET_SHARED_LIBRARY_FILES
2367     */
2368    public abstract ActivityInfo getReceiverInfo(ComponentName component,
2369            int flags) throws NameNotFoundException;
2370
2371    /**
2372     * Retrieve all of the information we know about a particular service
2373     * class.
2374     *
2375     * <p>Throws {@link NameNotFoundException} if a service with the given
2376     * class name cannot be found on the system.
2377     *
2378     * @param component The full component name (i.e.
2379     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
2380     * class.
2381     * @param flags Additional option flags.  Use any combination of
2382     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2383     * to modify the data returned.
2384     *
2385     * @return ServiceInfo containing information about the service.
2386     *
2387     * @see #GET_META_DATA
2388     * @see #GET_SHARED_LIBRARY_FILES
2389     */
2390    public abstract ServiceInfo getServiceInfo(ComponentName component,
2391            int flags) throws NameNotFoundException;
2392
2393    /**
2394     * Retrieve all of the information we know about a particular content
2395     * provider class.
2396     *
2397     * <p>Throws {@link NameNotFoundException} if a provider with the given
2398     * class name cannot be found on the system.
2399     *
2400     * @param component The full component name (i.e.
2401     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
2402     * ContentProvider class.
2403     * @param flags Additional option flags.  Use any combination of
2404     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2405     * to modify the data returned.
2406     *
2407     * @return ProviderInfo containing information about the service.
2408     *
2409     * @see #GET_META_DATA
2410     * @see #GET_SHARED_LIBRARY_FILES
2411     */
2412    public abstract ProviderInfo getProviderInfo(ComponentName component,
2413            int flags) throws NameNotFoundException;
2414
2415    /**
2416     * Return a List of all packages that are installed
2417     * on the device.
2418     *
2419     * @param flags Additional option flags. Use any combination of
2420     * {@link #GET_ACTIVITIES},
2421     * {@link #GET_GIDS},
2422     * {@link #GET_CONFIGURATIONS},
2423     * {@link #GET_INSTRUMENTATION},
2424     * {@link #GET_PERMISSIONS},
2425     * {@link #GET_PROVIDERS},
2426     * {@link #GET_RECEIVERS},
2427     * {@link #GET_SERVICES},
2428     * {@link #GET_SIGNATURES},
2429     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2430     *
2431     * @return A List of PackageInfo objects, one for each package that is
2432     *         installed on the device.  In the unlikely case of there being no
2433     *         installed packages, an empty list is returned.
2434     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2435     *         applications including those deleted with {@code DONT_DELETE_DATA}
2436     *         (partially installed apps with data directory) will be returned.
2437     *
2438     * @see #GET_ACTIVITIES
2439     * @see #GET_GIDS
2440     * @see #GET_CONFIGURATIONS
2441     * @see #GET_INSTRUMENTATION
2442     * @see #GET_PERMISSIONS
2443     * @see #GET_PROVIDERS
2444     * @see #GET_RECEIVERS
2445     * @see #GET_SERVICES
2446     * @see #GET_SIGNATURES
2447     * @see #GET_UNINSTALLED_PACKAGES
2448     */
2449    public abstract List<PackageInfo> getInstalledPackages(int flags);
2450
2451    /**
2452     * Return a List of all installed packages that are currently
2453     * holding any of the given permissions.
2454     *
2455     * @param flags Additional option flags. Use any combination of
2456     * {@link #GET_ACTIVITIES},
2457     * {@link #GET_GIDS},
2458     * {@link #GET_CONFIGURATIONS},
2459     * {@link #GET_INSTRUMENTATION},
2460     * {@link #GET_PERMISSIONS},
2461     * {@link #GET_PROVIDERS},
2462     * {@link #GET_RECEIVERS},
2463     * {@link #GET_SERVICES},
2464     * {@link #GET_SIGNATURES},
2465     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2466     *
2467     * @return Returns a List of PackageInfo objects, one for each installed
2468     * application that is holding any of the permissions that were provided.
2469     *
2470     * @see #GET_ACTIVITIES
2471     * @see #GET_GIDS
2472     * @see #GET_CONFIGURATIONS
2473     * @see #GET_INSTRUMENTATION
2474     * @see #GET_PERMISSIONS
2475     * @see #GET_PROVIDERS
2476     * @see #GET_RECEIVERS
2477     * @see #GET_SERVICES
2478     * @see #GET_SIGNATURES
2479     * @see #GET_UNINSTALLED_PACKAGES
2480     */
2481    public abstract List<PackageInfo> getPackagesHoldingPermissions(
2482            String[] permissions, int flags);
2483
2484    /**
2485     * Return a List of all packages that are installed on the device, for a specific user.
2486     * Requesting a list of installed packages for another user
2487     * will require the permission INTERACT_ACROSS_USERS_FULL.
2488     * @param flags Additional option flags. Use any combination of
2489     * {@link #GET_ACTIVITIES},
2490     * {@link #GET_GIDS},
2491     * {@link #GET_CONFIGURATIONS},
2492     * {@link #GET_INSTRUMENTATION},
2493     * {@link #GET_PERMISSIONS},
2494     * {@link #GET_PROVIDERS},
2495     * {@link #GET_RECEIVERS},
2496     * {@link #GET_SERVICES},
2497     * {@link #GET_SIGNATURES},
2498     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2499     * @param userId The user for whom the installed packages are to be listed
2500     *
2501     * @return A List of PackageInfo objects, one for each package that is
2502     *         installed on the device.  In the unlikely case of there being no
2503     *         installed packages, an empty list is returned.
2504     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2505     *         applications including those deleted with {@code DONT_DELETE_DATA}
2506     *         (partially installed apps with data directory) will be returned.
2507     *
2508     * @see #GET_ACTIVITIES
2509     * @see #GET_GIDS
2510     * @see #GET_CONFIGURATIONS
2511     * @see #GET_INSTRUMENTATION
2512     * @see #GET_PERMISSIONS
2513     * @see #GET_PROVIDERS
2514     * @see #GET_RECEIVERS
2515     * @see #GET_SERVICES
2516     * @see #GET_SIGNATURES
2517     * @see #GET_UNINSTALLED_PACKAGES
2518     *
2519     * @hide
2520     */
2521    public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
2522
2523    /**
2524     * Check whether a particular package has been granted a particular
2525     * permission.
2526     *
2527     * @param permName The name of the permission you are checking for.
2528     * @param pkgName The name of the package you are checking against.
2529     *
2530     * @return If the package has the permission, PERMISSION_GRANTED is
2531     * returned.  If it does not have the permission, PERMISSION_DENIED
2532     * is returned.
2533     *
2534     * @see #PERMISSION_GRANTED
2535     * @see #PERMISSION_DENIED
2536     */
2537    @CheckResult
2538    public abstract int checkPermission(String permName, String pkgName);
2539
2540    /**
2541     * Checks whether a particular permissions has been revoked for a
2542     * package by policy. Typically the device owner or the profile owner
2543     * may apply such a policy. The user cannot grant policy revoked
2544     * permissions, hence the only way for an app to get such a permission
2545     * is by a policy change.
2546     *
2547     * @param permName The name of the permission you are checking for.
2548     * @param pkgName The name of the package you are checking against.
2549     *
2550     * @return Whether the permission is restricted by policy.
2551     */
2552    @CheckResult
2553    public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName,
2554            @NonNull String pkgName);
2555
2556    /**
2557     * Gets the package name of the component controlling runtime permissions.
2558     *
2559     * @return The package name.
2560     *
2561     * @hide
2562     */
2563    public abstract String getPermissionControllerPackageName();
2564
2565    /**
2566     * Add a new dynamic permission to the system.  For this to work, your
2567     * package must have defined a permission tree through the
2568     * {@link android.R.styleable#AndroidManifestPermissionTree
2569     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
2570     * permissions to trees that were defined by either its own package or
2571     * another with the same user id; a permission is in a tree if it
2572     * matches the name of the permission tree + ".": for example,
2573     * "com.foo.bar" is a member of the permission tree "com.foo".
2574     *
2575     * <p>It is good to make your permission tree name descriptive, because you
2576     * are taking possession of that entire set of permission names.  Thus, it
2577     * must be under a domain you control, with a suffix that will not match
2578     * any normal permissions that may be declared in any applications that
2579     * are part of that domain.
2580     *
2581     * <p>New permissions must be added before
2582     * any .apks are installed that use those permissions.  Permissions you
2583     * add through this method are remembered across reboots of the device.
2584     * If the given permission already exists, the info you supply here
2585     * will be used to update it.
2586     *
2587     * @param info Description of the permission to be added.
2588     *
2589     * @return Returns true if a new permission was created, false if an
2590     * existing one was updated.
2591     *
2592     * @throws SecurityException if you are not allowed to add the
2593     * given permission name.
2594     *
2595     * @see #removePermission(String)
2596     */
2597    public abstract boolean addPermission(PermissionInfo info);
2598
2599    /**
2600     * Like {@link #addPermission(PermissionInfo)} but asynchronously
2601     * persists the package manager state after returning from the call,
2602     * allowing it to return quicker and batch a series of adds at the
2603     * expense of no guarantee the added permission will be retained if
2604     * the device is rebooted before it is written.
2605     */
2606    public abstract boolean addPermissionAsync(PermissionInfo info);
2607
2608    /**
2609     * Removes a permission that was previously added with
2610     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
2611     * -- you are only allowed to remove permissions that you are allowed
2612     * to add.
2613     *
2614     * @param name The name of the permission to remove.
2615     *
2616     * @throws SecurityException if you are not allowed to remove the
2617     * given permission name.
2618     *
2619     * @see #addPermission(PermissionInfo)
2620     */
2621    public abstract void removePermission(String name);
2622
2623
2624    /**
2625     * Permission flags set when granting or revoking a permission.
2626     *
2627     * @hide
2628     */
2629    @SystemApi
2630    @IntDef({FLAG_PERMISSION_USER_SET,
2631            FLAG_PERMISSION_USER_FIXED,
2632            FLAG_PERMISSION_POLICY_FIXED,
2633            FLAG_PERMISSION_REVOKE_ON_UPGRADE,
2634            FLAG_PERMISSION_SYSTEM_FIXED,
2635            FLAG_PERMISSION_GRANTED_BY_DEFAULT})
2636    @Retention(RetentionPolicy.SOURCE)
2637    public @interface PermissionFlags {}
2638
2639    /**
2640     * Grant a runtime permission to an application which the application does not
2641     * already have. The permission must have been requested by the application.
2642     * If the application is not allowed to hold the permission, a {@link
2643     * java.lang.SecurityException} is thrown.
2644     * <p>
2645     * <strong>Note: </strong>Using this API requires holding
2646     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
2647     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
2648     * </p>
2649     *
2650     * @param packageName The package to which to grant the permission.
2651     * @param permissionName The permission name to grant.
2652     * @param user The user for which to grant the permission.
2653     *
2654     * @see #revokeRuntimePermission(String, String, android.os.UserHandle)
2655     * @see android.content.pm.PackageManager.PermissionFlags
2656     *
2657     * @hide
2658     */
2659    @SystemApi
2660    public abstract void grantRuntimePermission(@NonNull String packageName,
2661            @NonNull String permissionName, @NonNull UserHandle user);
2662
2663    /**
2664     * Revoke a runtime permission that was previously granted by {@link
2665     * #grantRuntimePermission(String, String, android.os.UserHandle)}. The
2666     * permission must have been requested by and granted to the application.
2667     * If the application is not allowed to hold the permission, a {@link
2668     * java.lang.SecurityException} is thrown.
2669     * <p>
2670     * <strong>Note: </strong>Using this API requires holding
2671     * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is
2672     * not the current user android.permission.INTERACT_ACROSS_USERS_FULL.
2673     * </p>
2674     *
2675     * @param packageName The package from which to revoke the permission.
2676     * @param permissionName The permission name to revoke.
2677     * @param user The user for which to revoke the permission.
2678     *
2679     * @see #grantRuntimePermission(String, String, android.os.UserHandle)
2680     * @see android.content.pm.PackageManager.PermissionFlags
2681     *
2682     * @hide
2683     */
2684    @SystemApi
2685    public abstract void revokeRuntimePermission(@NonNull String packageName,
2686            @NonNull String permissionName, @NonNull UserHandle user);
2687
2688    /**
2689     * Gets the state flags associated with a permission.
2690     *
2691     * @param permissionName The permission for which to get the flags.
2692     * @param packageName The package name for which to get the flags.
2693     * @param user The user for which to get permission flags.
2694     * @return The permission flags.
2695     *
2696     * @hide
2697     */
2698    @SystemApi
2699    public abstract @PermissionFlags int getPermissionFlags(String permissionName,
2700            String packageName, @NonNull UserHandle user);
2701
2702    /**
2703     * Updates the flags associated with a permission by replacing the flags in
2704     * the specified mask with the provided flag values.
2705     *
2706     * @param permissionName The permission for which to update the flags.
2707     * @param packageName The package name for which to update the flags.
2708     * @param flagMask The flags which to replace.
2709     * @param flagValues The flags with which to replace.
2710     * @param user The user for which to update the permission flags.
2711     *
2712     * @hide
2713     */
2714    @SystemApi
2715    public abstract void updatePermissionFlags(String permissionName,
2716            String packageName, @PermissionFlags int flagMask, int flagValues,
2717            @NonNull UserHandle user);
2718
2719    /**
2720     * Gets whether you should show UI with rationale for requesting a permission.
2721     * You should do this only if you do not have the permission and the context in
2722     * which the permission is requested does not clearly communicate to the user
2723     * what would be the benefit from grating this permission.
2724     *
2725     * @param permission A permission your app wants to request.
2726     * @return Whether you can show permission rationale UI.
2727     *
2728     * @hide
2729     */
2730    public abstract boolean shouldShowRequestPermissionRationale(String permission);
2731
2732    /**
2733     * Returns an {@link android.content.Intent} suitable for passing to
2734     * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)}
2735     * which prompts the user to grant permissions to this application.
2736     *
2737     * @throws NullPointerException if {@code permissions} is {@code null} or empty.
2738     *
2739     * @hide
2740     */
2741    public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) {
2742        if (ArrayUtils.isEmpty(permissions)) {
2743           throw new NullPointerException("permission cannot be null or empty");
2744        }
2745        Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS);
2746        intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions);
2747        intent.setPackage(getPermissionControllerPackageName());
2748        return intent;
2749    }
2750
2751    /**
2752     * Compare the signatures of two packages to determine if the same
2753     * signature appears in both of them.  If they do contain the same
2754     * signature, then they are allowed special privileges when working
2755     * with each other: they can share the same user-id, run instrumentation
2756     * against each other, etc.
2757     *
2758     * @param pkg1 First package name whose signature will be compared.
2759     * @param pkg2 Second package name whose signature will be compared.
2760     *
2761     * @return Returns an integer indicating whether all signatures on the
2762     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2763     * all signatures match or < 0 if there is not a match ({@link
2764     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2765     *
2766     * @see #checkSignatures(int, int)
2767     * @see #SIGNATURE_MATCH
2768     * @see #SIGNATURE_NO_MATCH
2769     * @see #SIGNATURE_UNKNOWN_PACKAGE
2770     */
2771    @CheckResult
2772    public abstract int checkSignatures(String pkg1, String pkg2);
2773
2774    /**
2775     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
2776     * the two packages to be checked.  This can be useful, for example,
2777     * when doing the check in an IPC, where the UID is the only identity
2778     * available.  It is functionally identical to determining the package
2779     * associated with the UIDs and checking their signatures.
2780     *
2781     * @param uid1 First UID whose signature will be compared.
2782     * @param uid2 Second UID whose signature will be compared.
2783     *
2784     * @return Returns an integer indicating whether all signatures on the
2785     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
2786     * all signatures match or < 0 if there is not a match ({@link
2787     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
2788     *
2789     * @see #checkSignatures(String, String)
2790     * @see #SIGNATURE_MATCH
2791     * @see #SIGNATURE_NO_MATCH
2792     * @see #SIGNATURE_UNKNOWN_PACKAGE
2793     */
2794    @CheckResult
2795    public abstract int checkSignatures(int uid1, int uid2);
2796
2797    /**
2798     * Retrieve the names of all packages that are associated with a particular
2799     * user id.  In most cases, this will be a single package name, the package
2800     * that has been assigned that user id.  Where there are multiple packages
2801     * sharing the same user id through the "sharedUserId" mechanism, all
2802     * packages with that id will be returned.
2803     *
2804     * @param uid The user id for which you would like to retrieve the
2805     * associated packages.
2806     *
2807     * @return Returns an array of one or more packages assigned to the user
2808     * id, or null if there are no known packages with the given id.
2809     */
2810    public abstract String[] getPackagesForUid(int uid);
2811
2812    /**
2813     * Retrieve the official name associated with a user id.  This name is
2814     * guaranteed to never change, though it is possible for the underlying
2815     * user id to be changed.  That is, if you are storing information about
2816     * user ids in persistent storage, you should use the string returned
2817     * by this function instead of the raw user-id.
2818     *
2819     * @param uid The user id for which you would like to retrieve a name.
2820     * @return Returns a unique name for the given user id, or null if the
2821     * user id is not currently assigned.
2822     */
2823    public abstract String getNameForUid(int uid);
2824
2825    /**
2826     * Return the user id associated with a shared user name. Multiple
2827     * applications can specify a shared user name in their manifest and thus
2828     * end up using a common uid. This might be used for new applications
2829     * that use an existing shared user name and need to know the uid of the
2830     * shared user.
2831     *
2832     * @param sharedUserName The shared user name whose uid is to be retrieved.
2833     * @return Returns the uid associated with the shared user, or  NameNotFoundException
2834     * if the shared user name is not being used by any installed packages
2835     * @hide
2836     */
2837    public abstract int getUidForSharedUser(String sharedUserName)
2838            throws NameNotFoundException;
2839
2840    /**
2841     * Return a List of all application packages that are installed on the
2842     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
2843     * applications including those deleted with {@code DONT_DELETE_DATA} (partially
2844     * installed apps with data directory) will be returned.
2845     *
2846     * @param flags Additional option flags. Use any combination of
2847     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
2848     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
2849     *
2850     * @return Returns a List of ApplicationInfo objects, one for each application that
2851     *         is installed on the device.  In the unlikely case of there being
2852     *         no installed applications, an empty list is returned.
2853     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
2854     *         applications including those deleted with {@code DONT_DELETE_DATA}
2855     *         (partially installed apps with data directory) will be returned.
2856     *
2857     * @see #GET_META_DATA
2858     * @see #GET_SHARED_LIBRARY_FILES
2859     * @see #GET_UNINSTALLED_PACKAGES
2860     */
2861    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
2862
2863    /**
2864     * Gets the ephemeral applications the user recently used. Requires
2865     * holding "android.permission.ACCESS_EPHEMERAL_APPS".
2866     *
2867     * @return The ephemeral app list.
2868     *
2869     * @hide
2870     */
2871    @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS)
2872    public abstract List<EphemeralApplicationInfo> getEphemeralApplications();
2873
2874    /**
2875     * Gets the icon for an ephemeral application.
2876     *
2877     * @param packageName The app package name.
2878     *
2879     * @hide
2880     */
2881    public abstract Drawable getEphemeralApplicationIcon(String packageName);
2882
2883    /**
2884     * Gets whether the caller is an ephemeral app.
2885     *
2886     * @return Whether caller is an ephemeral app.
2887     *
2888     * @see #setEphemeralCookie(byte[])
2889     * @see #getEphemeralCookie()
2890     * @see #getEphemeralCookieMaxSizeBytes()
2891     */
2892    public abstract boolean isEphemeralApplication();
2893
2894    /**
2895     * Gets the maximum size in bytes of the cookie data an ephemeral app
2896     * can store on the device.
2897     *
2898     * @return The max cookie size in bytes.
2899     *
2900     * @see #isEphemeralApplication()
2901     * @see #setEphemeralCookie(byte[])
2902     * @see #getEphemeralCookie()
2903     */
2904    public abstract int getEphemeralCookieMaxSizeBytes();
2905
2906    /**
2907     * Gets the ephemeral application cookie for this app. Non
2908     * ephemeral apps and apps that were ephemeral but were upgraded
2909     * to non-ephemeral can still access this API. For ephemeral apps
2910     * this cooke is cached for some time after uninstall while for
2911     * normal apps the cookie is deleted after the app is uninstalled.
2912     * The cookie is always present while the app is installed.
2913     *
2914     * @return The cookie.
2915     *
2916     * @see #isEphemeralApplication()
2917     * @see #setEphemeralCookie(byte[])
2918     * @see #getEphemeralCookieMaxSizeBytes()
2919     */
2920    public abstract @NonNull byte[] getEphemeralCookie();
2921
2922    /**
2923     * Sets the ephemeral application cookie for the calling app. Non
2924     * ephemeral apps and apps that were ephemeral but were upgraded
2925     * to non-ephemeral can still access this API. For ephemeral apps
2926     * this cooke is cached for some time after uninstall while for
2927     * normal apps the cookie is deleted after the app is uninstalled.
2928     * The cookie is always present while the app is installed. The
2929     * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}.
2930     *
2931     * @param cookie The cookie data.
2932     * @return True if the cookie was set.
2933     *
2934     * @see #isEphemeralApplication()
2935     * @see #getEphemeralCookieMaxSizeBytes()
2936     * @see #getEphemeralCookie();
2937     */
2938    public abstract boolean setEphemeralCookie(@NonNull  byte[] cookie);
2939
2940    /**
2941     * Get a list of shared libraries that are available on the
2942     * system.
2943     *
2944     * @return An array of shared library names that are
2945     * available on the system, or null if none are installed.
2946     *
2947     */
2948    public abstract String[] getSystemSharedLibraryNames();
2949
2950    /**
2951     * Get a list of features that are available on the
2952     * system.
2953     *
2954     * @return An array of FeatureInfo classes describing the features
2955     * that are available on the system, or null if there are none(!!).
2956     */
2957    public abstract FeatureInfo[] getSystemAvailableFeatures();
2958
2959    /**
2960     * Check whether the given feature name is one of the available
2961     * features as returned by {@link #getSystemAvailableFeatures()}.
2962     *
2963     * @return Returns true if the devices supports the feature, else
2964     * false.
2965     */
2966    public abstract boolean hasSystemFeature(String name);
2967
2968    /**
2969     * Determine the best action to perform for a given Intent.  This is how
2970     * {@link Intent#resolveActivity} finds an activity if a class has not
2971     * been explicitly specified.
2972     *
2973     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
2974     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
2975     * only flag.  You need to do so to resolve the activity in the same way
2976     * that {@link android.content.Context#startActivity(Intent)} and
2977     * {@link android.content.Intent#resolveActivity(PackageManager)
2978     * Intent.resolveActivity(PackageManager)} do.</p>
2979     *
2980     * @param intent An intent containing all of the desired specification
2981     *               (action, data, type, category, and/or component).
2982     * @param flags Additional option flags.  The most important is
2983     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
2984     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
2985     *
2986     * @return Returns a ResolveInfo containing the final activity intent that
2987     *         was determined to be the best action.  Returns null if no
2988     *         matching activity was found. If multiple matching activities are
2989     *         found and there is no default set, returns a ResolveInfo
2990     *         containing something else, such as the activity resolver.
2991     *
2992     * @see #MATCH_DEFAULT_ONLY
2993     * @see #GET_INTENT_FILTERS
2994     * @see #GET_RESOLVED_FILTER
2995     */
2996    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
2997
2998    /**
2999     * Determine the best action to perform for a given Intent for a given user. This
3000     * is how {@link Intent#resolveActivity} finds an activity if a class has not
3001     * been explicitly specified.
3002     *
3003     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
3004     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
3005     * only flag.  You need to do so to resolve the activity in the same way
3006     * that {@link android.content.Context#startActivity(Intent)} and
3007     * {@link android.content.Intent#resolveActivity(PackageManager)
3008     * Intent.resolveActivity(PackageManager)} do.</p>
3009     *
3010     * @param intent An intent containing all of the desired specification
3011     *               (action, data, type, category, and/or component).
3012     * @param flags Additional option flags.  The most important is
3013     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3014     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3015     * @param userId The user id.
3016     *
3017     * @return Returns a ResolveInfo containing the final activity intent that
3018     *         was determined to be the best action.  Returns null if no
3019     *         matching activity was found. If multiple matching activities are
3020     *         found and there is no default set, returns a ResolveInfo
3021     *         containing something else, such as the activity resolver.
3022     *
3023     * @see #MATCH_DEFAULT_ONLY
3024     * @see #GET_INTENT_FILTERS
3025     * @see #GET_RESOLVED_FILTER
3026     *
3027     * @hide
3028     */
3029    public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId);
3030
3031    /**
3032     * Retrieve all activities that can be performed for the given intent.
3033     *
3034     * @param intent The desired intent as per resolveActivity().
3035     * @param flags Additional option flags.  The most important is
3036     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3037     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3038     *
3039     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
3040     *
3041     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3042     *         Activity. These are ordered from best to worst match -- that
3043     *         is, the first item in the list is what is returned by
3044     *         {@link #resolveActivity}.  If there are no matching activities, an empty
3045     *         list is returned.
3046     *
3047     * @see #MATCH_DEFAULT_ONLY
3048     * @see #GET_INTENT_FILTERS
3049     * @see #GET_RESOLVED_FILTER
3050     */
3051    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
3052            int flags);
3053
3054    /**
3055     * Retrieve all activities that can be performed for the given intent, for a specific user.
3056     *
3057     * @param intent The desired intent as per resolveActivity().
3058     * @param flags Additional option flags.  The most important is
3059     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3060     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3061     *
3062     * You can also set {@link #MATCH_ALL} for preventing the filtering of the results.
3063     *
3064     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3065     *         Activity. These are ordered from best to worst match -- that
3066     *         is, the first item in the list is what is returned by
3067     *         {@link #resolveActivity}.  If there are no matching activities, an empty
3068     *         list is returned.
3069     *
3070     * @see #MATCH_DEFAULT_ONLY
3071     * @see #GET_INTENT_FILTERS
3072     * @see #GET_RESOLVED_FILTER
3073     * @hide
3074     */
3075    public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
3076            int flags, int userId);
3077
3078
3079    /**
3080     * Retrieve a set of activities that should be presented to the user as
3081     * similar options.  This is like {@link #queryIntentActivities}, except it
3082     * also allows you to supply a list of more explicit Intents that you would
3083     * like to resolve to particular options, and takes care of returning the
3084     * final ResolveInfo list in a reasonable order, with no duplicates, based
3085     * on those inputs.
3086     *
3087     * @param caller The class name of the activity that is making the
3088     *               request.  This activity will never appear in the output
3089     *               list.  Can be null.
3090     * @param specifics An array of Intents that should be resolved to the
3091     *                  first specific results.  Can be null.
3092     * @param intent The desired intent as per resolveActivity().
3093     * @param flags Additional option flags.  The most important is
3094     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
3095     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
3096     *
3097     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3098     *         Activity. These are ordered first by all of the intents resolved
3099     *         in <var>specifics</var> and then any additional activities that
3100     *         can handle <var>intent</var> but did not get included by one of
3101     *         the <var>specifics</var> intents.  If there are no matching
3102     *         activities, an empty list is returned.
3103     *
3104     * @see #MATCH_DEFAULT_ONLY
3105     * @see #GET_INTENT_FILTERS
3106     * @see #GET_RESOLVED_FILTER
3107     */
3108    public abstract List<ResolveInfo> queryIntentActivityOptions(
3109            ComponentName caller, Intent[] specifics, Intent intent, int flags);
3110
3111    /**
3112     * Retrieve all receivers that can handle a broadcast of the given intent.
3113     *
3114     * @param intent The desired intent as per resolveActivity().
3115     * @param flags Additional option flags.
3116     *
3117     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3118     *         Receiver. These are ordered from first to last in priority.  If
3119     *         there are no matching receivers, an empty list is returned.
3120     *
3121     * @see #MATCH_DEFAULT_ONLY
3122     * @see #GET_INTENT_FILTERS
3123     * @see #GET_RESOLVED_FILTER
3124     */
3125    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3126            int flags);
3127
3128    /**
3129     * Retrieve all receivers that can handle a broadcast of the given intent, for a specific
3130     * user.
3131     *
3132     * @param intent The desired intent as per resolveActivity().
3133     * @param flags Additional option flags.
3134     * @param userId The userId of the user being queried.
3135     *
3136     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3137     *         Receiver. These are ordered from first to last in priority.  If
3138     *         there are no matching receivers, an empty list or {@code null} is returned.
3139     *
3140     * @see #MATCH_DEFAULT_ONLY
3141     * @see #GET_INTENT_FILTERS
3142     * @see #GET_RESOLVED_FILTER
3143     * @hide
3144     */
3145    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
3146            int flags, int userId);
3147
3148    /**
3149     * Determine the best service to handle for a given Intent.
3150     *
3151     * @param intent An intent containing all of the desired specification
3152     *               (action, data, type, category, and/or component).
3153     * @param flags Additional option flags.
3154     *
3155     * @return Returns a ResolveInfo containing the final service intent that
3156     *         was determined to be the best action.  Returns null if no
3157     *         matching service was found.
3158     *
3159     * @see #GET_INTENT_FILTERS
3160     * @see #GET_RESOLVED_FILTER
3161     */
3162    public abstract ResolveInfo resolveService(Intent intent, int flags);
3163
3164    /**
3165     * Retrieve all services that can match the given intent.
3166     *
3167     * @param intent The desired intent as per resolveService().
3168     * @param flags Additional option flags.
3169     *
3170     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3171     *         ServiceInfo. These are ordered from best to worst match -- that
3172     *         is, the first item in the list is what is returned by
3173     *         resolveService().  If there are no matching services, an empty
3174     *         list or {@code null} is returned.
3175     *
3176     * @see #GET_INTENT_FILTERS
3177     * @see #GET_RESOLVED_FILTER
3178     */
3179    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
3180            int flags);
3181
3182    /**
3183     * Retrieve all services that can match the given intent for a given user.
3184     *
3185     * @param intent The desired intent as per resolveService().
3186     * @param flags Additional option flags.
3187     * @param userId The user id.
3188     *
3189     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3190     *         ServiceInfo. These are ordered from best to worst match -- that
3191     *         is, the first item in the list is what is returned by
3192     *         resolveService().  If there are no matching services, an empty
3193     *         list or {@code null} is returned.
3194     *
3195     * @see #GET_INTENT_FILTERS
3196     * @see #GET_RESOLVED_FILTER
3197     *
3198     * @hide
3199     */
3200    public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent,
3201            int flags, int userId);
3202
3203    /** {@hide} */
3204    public abstract List<ResolveInfo> queryIntentContentProvidersAsUser(
3205            Intent intent, int flags, int userId);
3206
3207    /**
3208     * Retrieve all providers that can match the given intent.
3209     *
3210     * @param intent An intent containing all of the desired specification
3211     *            (action, data, type, category, and/or component).
3212     * @param flags Additional option flags.
3213     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
3214     *         ProviderInfo. These are ordered from best to worst match. If
3215     *         there are no matching providers, an empty list or {@code null} is returned.
3216     * @see #GET_INTENT_FILTERS
3217     * @see #GET_RESOLVED_FILTER
3218     */
3219    public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags);
3220
3221    /**
3222     * Find a single content provider by its base path name.
3223     *
3224     * @param name The name of the provider to find.
3225     * @param flags Additional option flags.  Currently should always be 0.
3226     *
3227     * @return ContentProviderInfo Information about the provider, if found,
3228     *         else null.
3229     */
3230    public abstract ProviderInfo resolveContentProvider(String name,
3231            int flags);
3232
3233    /**
3234     * Find a single content provider by its base path name.
3235     *
3236     * @param name The name of the provider to find.
3237     * @param flags Additional option flags.  Currently should always be 0.
3238     * @param userId The user id.
3239     *
3240     * @return ContentProviderInfo Information about the provider, if found,
3241     *         else null.
3242     * @hide
3243     */
3244    public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId);
3245
3246    /**
3247     * Retrieve content provider information.
3248     *
3249     * <p><em>Note: unlike most other methods, an empty result set is indicated
3250     * by a null return instead of an empty list.</em>
3251     *
3252     * @param processName If non-null, limits the returned providers to only
3253     *                    those that are hosted by the given process.  If null,
3254     *                    all content providers are returned.
3255     * @param uid If <var>processName</var> is non-null, this is the required
3256     *        uid owning the requested content providers.
3257     * @param flags Additional option flags.  Currently should always be 0.
3258     *
3259     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
3260     *         content provider either patching <var>processName</var> or, if
3261     *         <var>processName</var> is null, all known content providers.
3262     *         <em>If there are no matching providers, null is returned.</em>
3263     */
3264    public abstract List<ProviderInfo> queryContentProviders(
3265            String processName, int uid, int flags);
3266
3267    /**
3268     * Retrieve all of the information we know about a particular
3269     * instrumentation class.
3270     *
3271     * <p>Throws {@link NameNotFoundException} if instrumentation with the
3272     * given class name cannot be found on the system.
3273     *
3274     * @param className The full name (i.e.
3275     *                  com.google.apps.contacts.InstrumentList) of an
3276     *                  Instrumentation class.
3277     * @param flags Additional option flags.  Currently should always be 0.
3278     *
3279     * @return InstrumentationInfo containing information about the
3280     *         instrumentation.
3281     */
3282    public abstract InstrumentationInfo getInstrumentationInfo(
3283            ComponentName className, int flags) throws NameNotFoundException;
3284
3285    /**
3286     * Retrieve information about available instrumentation code.  May be used
3287     * to retrieve either all instrumentation code, or only the code targeting
3288     * a particular package.
3289     *
3290     * @param targetPackage If null, all instrumentation is returned; only the
3291     *                      instrumentation targeting this package name is
3292     *                      returned.
3293     * @param flags Additional option flags.  Currently should always be 0.
3294     *
3295     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
3296     *         matching available Instrumentation.  Returns an empty list if
3297     *         there is no instrumentation available for the given package.
3298     */
3299    public abstract List<InstrumentationInfo> queryInstrumentation(
3300            String targetPackage, int flags);
3301
3302    /**
3303     * Retrieve an image from a package.  This is a low-level API used by
3304     * the various package manager info structures (such as
3305     * {@link ComponentInfo} to implement retrieval of their associated
3306     * icon.
3307     *
3308     * @param packageName The name of the package that this icon is coming from.
3309     * Cannot be null.
3310     * @param resid The resource identifier of the desired image.  Cannot be 0.
3311     * @param appInfo Overall information about <var>packageName</var>.  This
3312     * may be null, in which case the application information will be retrieved
3313     * for you if needed; if you already have this information around, it can
3314     * be much more efficient to supply it here.
3315     *
3316     * @return Returns a Drawable holding the requested image.  Returns null if
3317     * an image could not be found for any reason.
3318     */
3319    public abstract Drawable getDrawable(String packageName, @DrawableRes int resid,
3320            ApplicationInfo appInfo);
3321
3322    /**
3323     * Retrieve the icon associated with an activity.  Given the full name of
3324     * an activity, retrieves the information about it and calls
3325     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
3326     * If the activity cannot be found, NameNotFoundException is thrown.
3327     *
3328     * @param activityName Name of the activity whose icon is to be retrieved.
3329     *
3330     * @return Returns the image of the icon, or the default activity icon if
3331     * it could not be found.  Does not return null.
3332     * @throws NameNotFoundException Thrown if the resources for the given
3333     * activity could not be loaded.
3334     *
3335     * @see #getActivityIcon(Intent)
3336     */
3337    public abstract Drawable getActivityIcon(ComponentName activityName)
3338            throws NameNotFoundException;
3339
3340    /**
3341     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
3342     * set, this simply returns the result of
3343     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
3344     * component and returns the icon associated with the resolved component.
3345     * If intent.getClassName() cannot be found or the Intent cannot be resolved
3346     * to a component, NameNotFoundException is thrown.
3347     *
3348     * @param intent The intent for which you would like to retrieve an icon.
3349     *
3350     * @return Returns the image of the icon, or the default activity icon if
3351     * it could not be found.  Does not return null.
3352     * @throws NameNotFoundException Thrown if the resources for application
3353     * matching the given intent could not be loaded.
3354     *
3355     * @see #getActivityIcon(ComponentName)
3356     */
3357    public abstract Drawable getActivityIcon(Intent intent)
3358            throws NameNotFoundException;
3359
3360    /**
3361     * Retrieve the banner associated with an activity. Given the full name of
3362     * an activity, retrieves the information about it and calls
3363     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its
3364     * banner. If the activity cannot be found, NameNotFoundException is thrown.
3365     *
3366     * @param activityName Name of the activity whose banner is to be retrieved.
3367     * @return Returns the image of the banner, or null if the activity has no
3368     *         banner specified.
3369     * @throws NameNotFoundException Thrown if the resources for the given
3370     *             activity could not be loaded.
3371     * @see #getActivityBanner(Intent)
3372     */
3373    public abstract Drawable getActivityBanner(ComponentName activityName)
3374            throws NameNotFoundException;
3375
3376    /**
3377     * Retrieve the banner associated with an Intent. If intent.getClassName()
3378     * is set, this simply returns the result of
3379     * getActivityBanner(intent.getClassName()). Otherwise it resolves the
3380     * intent's component and returns the banner associated with the resolved
3381     * component. If intent.getClassName() cannot be found or the Intent cannot
3382     * be resolved to a component, NameNotFoundException is thrown.
3383     *
3384     * @param intent The intent for which you would like to retrieve a banner.
3385     * @return Returns the image of the banner, or null if the activity has no
3386     *         banner specified.
3387     * @throws NameNotFoundException Thrown if the resources for application
3388     *             matching the given intent could not be loaded.
3389     * @see #getActivityBanner(ComponentName)
3390     */
3391    public abstract Drawable getActivityBanner(Intent intent)
3392            throws NameNotFoundException;
3393
3394    /**
3395     * Return the generic icon for an activity that is used when no specific
3396     * icon is defined.
3397     *
3398     * @return Drawable Image of the icon.
3399     */
3400    public abstract Drawable getDefaultActivityIcon();
3401
3402    /**
3403     * Retrieve the icon associated with an application.  If it has not defined
3404     * an icon, the default app icon is returned.  Does not return null.
3405     *
3406     * @param info Information about application being queried.
3407     *
3408     * @return Returns the image of the icon, or the default application icon
3409     * if it could not be found.
3410     *
3411     * @see #getApplicationIcon(String)
3412     */
3413    public abstract Drawable getApplicationIcon(ApplicationInfo info);
3414
3415    /**
3416     * Retrieve the icon associated with an application.  Given the name of the
3417     * application's package, retrieves the information about it and calls
3418     * getApplicationIcon() to return its icon. If the application cannot be
3419     * found, NameNotFoundException is thrown.
3420     *
3421     * @param packageName Name of the package whose application icon is to be
3422     *                    retrieved.
3423     *
3424     * @return Returns the image of the icon, or the default application icon
3425     * if it could not be found.  Does not return null.
3426     * @throws NameNotFoundException Thrown if the resources for the given
3427     * application could not be loaded.
3428     *
3429     * @see #getApplicationIcon(ApplicationInfo)
3430     */
3431    public abstract Drawable getApplicationIcon(String packageName)
3432            throws NameNotFoundException;
3433
3434    /**
3435     * Retrieve the banner associated with an application.
3436     *
3437     * @param info Information about application being queried.
3438     * @return Returns the image of the banner or null if the application has no
3439     *         banner specified.
3440     * @see #getApplicationBanner(String)
3441     */
3442    public abstract Drawable getApplicationBanner(ApplicationInfo info);
3443
3444    /**
3445     * Retrieve the banner associated with an application. Given the name of the
3446     * application's package, retrieves the information about it and calls
3447     * getApplicationIcon() to return its banner. If the application cannot be
3448     * found, NameNotFoundException is thrown.
3449     *
3450     * @param packageName Name of the package whose application banner is to be
3451     *            retrieved.
3452     * @return Returns the image of the banner or null if the application has no
3453     *         banner specified.
3454     * @throws NameNotFoundException Thrown if the resources for the given
3455     *             application could not be loaded.
3456     * @see #getApplicationBanner(ApplicationInfo)
3457     */
3458    public abstract Drawable getApplicationBanner(String packageName)
3459            throws NameNotFoundException;
3460
3461    /**
3462     * Retrieve the logo associated with an activity. Given the full name of an
3463     * activity, retrieves the information about it and calls
3464     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its
3465     * logo. If the activity cannot be found, NameNotFoundException is thrown.
3466     *
3467     * @param activityName Name of the activity whose logo is to be retrieved.
3468     * @return Returns the image of the logo or null if the activity has no logo
3469     *         specified.
3470     * @throws NameNotFoundException Thrown if the resources for the given
3471     *             activity could not be loaded.
3472     * @see #getActivityLogo(Intent)
3473     */
3474    public abstract Drawable getActivityLogo(ComponentName activityName)
3475            throws NameNotFoundException;
3476
3477    /**
3478     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
3479     * set, this simply returns the result of
3480     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
3481     * component and returns the logo associated with the resolved component.
3482     * If intent.getClassName() cannot be found or the Intent cannot be resolved
3483     * to a component, NameNotFoundException is thrown.
3484     *
3485     * @param intent The intent for which you would like to retrieve a logo.
3486     *
3487     * @return Returns the image of the logo, or null if the activity has no
3488     * logo specified.
3489     *
3490     * @throws NameNotFoundException Thrown if the resources for application
3491     * matching the given intent could not be loaded.
3492     *
3493     * @see #getActivityLogo(ComponentName)
3494     */
3495    public abstract Drawable getActivityLogo(Intent intent)
3496            throws NameNotFoundException;
3497
3498    /**
3499     * Retrieve the logo associated with an application.  If it has not specified
3500     * a logo, this method returns null.
3501     *
3502     * @param info Information about application being queried.
3503     *
3504     * @return Returns the image of the logo, or null if no logo is specified
3505     * by the application.
3506     *
3507     * @see #getApplicationLogo(String)
3508     */
3509    public abstract Drawable getApplicationLogo(ApplicationInfo info);
3510
3511    /**
3512     * Retrieve the logo associated with an application.  Given the name of the
3513     * application's package, retrieves the information about it and calls
3514     * getApplicationLogo() to return its logo. If the application cannot be
3515     * found, NameNotFoundException is thrown.
3516     *
3517     * @param packageName Name of the package whose application logo is to be
3518     *                    retrieved.
3519     *
3520     * @return Returns the image of the logo, or null if no application logo
3521     * has been specified.
3522     *
3523     * @throws NameNotFoundException Thrown if the resources for the given
3524     * application could not be loaded.
3525     *
3526     * @see #getApplicationLogo(ApplicationInfo)
3527     */
3528    public abstract Drawable getApplicationLogo(String packageName)
3529            throws NameNotFoundException;
3530
3531    /**
3532     * If the target user is a managed profile of the calling user or if the
3533     * target user is the caller and is itself a managed profile, then this
3534     * returns a badged copy of the given icon to be able to distinguish it from
3535     * the original icon. For badging an arbitrary drawable use
3536     * {@link #getUserBadgedDrawableForDensity(
3537     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
3538     * <p>
3539     * If the original drawable is a BitmapDrawable and the backing bitmap is
3540     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
3541     * is performed in place and the original drawable is returned.
3542     * </p>
3543     *
3544     * @param icon The icon to badge.
3545     * @param user The target user.
3546     * @return A drawable that combines the original icon and a badge as
3547     *         determined by the system.
3548     */
3549    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
3550
3551    /**
3552     * If the target user is a managed profile of the calling user or the caller
3553     * is itself a managed profile, then this returns a badged copy of the given
3554     * drawable allowing the user to distinguish it from the original drawable.
3555     * The caller can specify the location in the bounds of the drawable to be
3556     * badged where the badge should be applied as well as the density of the
3557     * badge to be used.
3558     * <p>
3559     * If the original drawable is a BitmapDrawable and the backing bitmap is
3560     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
3561     * is performed in place and the original drawable is returned.
3562     * </p>
3563     *
3564     * @param drawable The drawable to badge.
3565     * @param user The target user.
3566     * @param badgeLocation Where in the bounds of the badged drawable to place
3567     *         the badge. If not provided, the badge is applied on top of the entire
3568     *         drawable being badged.
3569     * @param badgeDensity The optional desired density for the badge as per
3570     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
3571     *         the density of the display is used.
3572     * @return A drawable that combines the original drawable and a badge as
3573     *         determined by the system.
3574     */
3575    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
3576            UserHandle user, Rect badgeLocation, int badgeDensity);
3577
3578    /**
3579     * If the target user is a managed profile of the calling user or the caller
3580     * is itself a managed profile, then this returns a drawable to use as a small
3581     * icon to include in a view to distinguish it from the original icon.
3582     *
3583     * @param user The target user.
3584     * @param density The optional desired density for the badge as per
3585     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
3586     *         the density of the current display is used.
3587     * @return the drawable or null if no drawable is required.
3588     * @hide
3589     */
3590    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
3591
3592    /**
3593     * If the target user is a managed profile of the calling user or the caller
3594     * is itself a managed profile, then this returns a copy of the label with
3595     * badging for accessibility services like talkback. E.g. passing in "Email"
3596     * and it might return "Work Email" for Email in the work profile.
3597     *
3598     * @param label The label to change.
3599     * @param user The target user.
3600     * @return A label that combines the original label and a badge as
3601     *         determined by the system.
3602     */
3603    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
3604
3605    /**
3606     * Retrieve text from a package.  This is a low-level API used by
3607     * the various package manager info structures (such as
3608     * {@link ComponentInfo} to implement retrieval of their associated
3609     * labels and other text.
3610     *
3611     * @param packageName The name of the package that this text is coming from.
3612     * Cannot be null.
3613     * @param resid The resource identifier of the desired text.  Cannot be 0.
3614     * @param appInfo Overall information about <var>packageName</var>.  This
3615     * may be null, in which case the application information will be retrieved
3616     * for you if needed; if you already have this information around, it can
3617     * be much more efficient to supply it here.
3618     *
3619     * @return Returns a CharSequence holding the requested text.  Returns null
3620     * if the text could not be found for any reason.
3621     */
3622    public abstract CharSequence getText(String packageName, @StringRes int resid,
3623            ApplicationInfo appInfo);
3624
3625    /**
3626     * Retrieve an XML file from a package.  This is a low-level API used to
3627     * retrieve XML meta data.
3628     *
3629     * @param packageName The name of the package that this xml is coming from.
3630     * Cannot be null.
3631     * @param resid The resource identifier of the desired xml.  Cannot be 0.
3632     * @param appInfo Overall information about <var>packageName</var>.  This
3633     * may be null, in which case the application information will be retrieved
3634     * for you if needed; if you already have this information around, it can
3635     * be much more efficient to supply it here.
3636     *
3637     * @return Returns an XmlPullParser allowing you to parse out the XML
3638     * data.  Returns null if the xml resource could not be found for any
3639     * reason.
3640     */
3641    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
3642            ApplicationInfo appInfo);
3643
3644    /**
3645     * Return the label to use for this application.
3646     *
3647     * @return Returns the label associated with this application, or null if
3648     * it could not be found for any reason.
3649     * @param info The application to get the label of.
3650     */
3651    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
3652
3653    /**
3654     * Retrieve the resources associated with an activity.  Given the full
3655     * name of an activity, retrieves the information about it and calls
3656     * getResources() to return its application's resources.  If the activity
3657     * cannot be found, NameNotFoundException is thrown.
3658     *
3659     * @param activityName Name of the activity whose resources are to be
3660     *                     retrieved.
3661     *
3662     * @return Returns the application's Resources.
3663     * @throws NameNotFoundException Thrown if the resources for the given
3664     * application could not be loaded.
3665     *
3666     * @see #getResourcesForApplication(ApplicationInfo)
3667     */
3668    public abstract Resources getResourcesForActivity(ComponentName activityName)
3669            throws NameNotFoundException;
3670
3671    /**
3672     * Retrieve the resources for an application.  Throws NameNotFoundException
3673     * if the package is no longer installed.
3674     *
3675     * @param app Information about the desired application.
3676     *
3677     * @return Returns the application's Resources.
3678     * @throws NameNotFoundException Thrown if the resources for the given
3679     * application could not be loaded (most likely because it was uninstalled).
3680     */
3681    public abstract Resources getResourcesForApplication(ApplicationInfo app)
3682            throws NameNotFoundException;
3683
3684    /**
3685     * Retrieve the resources associated with an application.  Given the full
3686     * package name of an application, retrieves the information about it and
3687     * calls getResources() to return its application's resources.  If the
3688     * appPackageName cannot be found, NameNotFoundException is thrown.
3689     *
3690     * @param appPackageName Package name of the application whose resources
3691     *                       are to be retrieved.
3692     *
3693     * @return Returns the application's Resources.
3694     * @throws NameNotFoundException Thrown if the resources for the given
3695     * application could not be loaded.
3696     *
3697     * @see #getResourcesForApplication(ApplicationInfo)
3698     */
3699    public abstract Resources getResourcesForApplication(String appPackageName)
3700            throws NameNotFoundException;
3701
3702    /** @hide */
3703    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
3704            throws NameNotFoundException;
3705
3706    /**
3707     * Retrieve overall information about an application package defined
3708     * in a package archive file
3709     *
3710     * @param archiveFilePath The path to the archive file
3711     * @param flags Additional option flags. Use any combination of
3712     * {@link #GET_ACTIVITIES},
3713     * {@link #GET_GIDS},
3714     * {@link #GET_CONFIGURATIONS},
3715     * {@link #GET_INSTRUMENTATION},
3716     * {@link #GET_PERMISSIONS},
3717     * {@link #GET_PROVIDERS},
3718     * {@link #GET_RECEIVERS},
3719     * {@link #GET_SERVICES},
3720     * {@link #GET_SIGNATURES}, to modify the data returned.
3721     *
3722     * @return Returns the information about the package. Returns
3723     * null if the package could not be successfully parsed.
3724     *
3725     * @see #GET_ACTIVITIES
3726     * @see #GET_GIDS
3727     * @see #GET_CONFIGURATIONS
3728     * @see #GET_INSTRUMENTATION
3729     * @see #GET_PERMISSIONS
3730     * @see #GET_PROVIDERS
3731     * @see #GET_RECEIVERS
3732     * @see #GET_SERVICES
3733     * @see #GET_SIGNATURES
3734     *
3735     */
3736    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3737        final PackageParser parser = new PackageParser();
3738        final File apkFile = new File(archiveFilePath);
3739        try {
3740            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3741            if ((flags & GET_SIGNATURES) != 0) {
3742                parser.collectCertificates(pkg, 0);
3743                parser.collectManifestDigest(pkg);
3744            }
3745            PackageUserState state = new PackageUserState();
3746            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3747        } catch (PackageParserException e) {
3748            return null;
3749        }
3750    }
3751
3752    /**
3753     * @hide Install a package. Since this may take a little while, the result
3754     *       will be posted back to the given observer. An installation will
3755     *       fail if the calling context lacks the
3756     *       {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3757     *       the package named in the package file's manifest is already
3758     *       installed, or if there's no space available on the device.
3759     * @param packageURI The location of the package file to install. This can
3760     *            be a 'file:' or a 'content:' URI.
3761     * @param observer An observer callback to get notified when the package
3762     *            installation is complete.
3763     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3764     *            will be called when that happens. This parameter must not be
3765     *            null.
3766     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3767     *            {@link #INSTALL_REPLACE_EXISTING},
3768     *            {@link #INSTALL_ALLOW_TEST}.
3769     * @param installerPackageName Optional package name of the application that
3770     *            is performing the installation. This identifies which market
3771     *            the package came from.
3772     * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3773     *             String)} instead. This method will continue to be supported
3774     *             but the older observer interface will not get additional
3775     *             failure details.
3776     */
3777    // @SystemApi
3778    public abstract void installPackage(
3779            Uri packageURI, IPackageInstallObserver observer, int flags,
3780            String installerPackageName);
3781
3782    /**
3783     * Similar to
3784     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3785     * with an extra verification file provided.
3786     *
3787     * @param packageURI The location of the package file to install. This can
3788     *            be a 'file:' or a 'content:' URI.
3789     * @param observer An observer callback to get notified when the package
3790     *            installation is complete.
3791     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3792     *            will be called when that happens. This parameter must not be
3793     *            null.
3794     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3795     *            {@link #INSTALL_REPLACE_EXISTING},
3796     *            {@link #INSTALL_ALLOW_TEST}.
3797     * @param installerPackageName Optional package name of the application that
3798     *            is performing the installation. This identifies which market
3799     *            the package came from.
3800     * @param verificationURI The location of the supplementary verification
3801     *            file. This can be a 'file:' or a 'content:' URI. May be
3802     *            {@code null}.
3803     * @param manifestDigest an object that holds the digest of the package
3804     *            which can be used to verify ownership. May be {@code null}.
3805     * @param encryptionParams if the package to be installed is encrypted,
3806     *            these parameters describing the encryption and authentication
3807     *            used. May be {@code null}.
3808     * @hide
3809     * @deprecated Use {@link #installPackageWithVerification(Uri,
3810     *             PackageInstallObserver, int, String, Uri, ManifestDigest,
3811     *             ContainerEncryptionParams)} instead. This method will
3812     *             continue to be supported but the older observer interface
3813     *             will not get additional failure details.
3814     */
3815    // @SystemApi
3816    public abstract void installPackageWithVerification(Uri packageURI,
3817            IPackageInstallObserver observer, int flags, String installerPackageName,
3818            Uri verificationURI, ManifestDigest manifestDigest,
3819            ContainerEncryptionParams encryptionParams);
3820
3821    /**
3822     * Similar to
3823     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3824     * with an extra verification information provided.
3825     *
3826     * @param packageURI The location of the package file to install. This can
3827     *            be a 'file:' or a 'content:' URI.
3828     * @param observer An observer callback to get notified when the package
3829     *            installation is complete.
3830     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3831     *            will be called when that happens. This parameter must not be
3832     *            null.
3833     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3834     *            {@link #INSTALL_REPLACE_EXISTING},
3835     *            {@link #INSTALL_ALLOW_TEST}.
3836     * @param installerPackageName Optional package name of the application that
3837     *            is performing the installation. This identifies which market
3838     *            the package came from.
3839     * @param verificationParams an object that holds signal information to
3840     *            assist verification. May be {@code null}.
3841     * @param encryptionParams if the package to be installed is encrypted,
3842     *            these parameters describing the encryption and authentication
3843     *            used. May be {@code null}.
3844     * @hide
3845     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3846     *             PackageInstallObserver, int, String, VerificationParams,
3847     *             ContainerEncryptionParams)} instead. This method will
3848     *             continue to be supported but the older observer interface
3849     *             will not get additional failure details.
3850     */
3851    @Deprecated
3852    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3853            IPackageInstallObserver observer, int flags, String installerPackageName,
3854            VerificationParams verificationParams,
3855            ContainerEncryptionParams encryptionParams);
3856
3857    // Package-install variants that take the new, expanded form of observer interface.
3858    // Note that these *also* take the original observer type and will redundantly
3859    // report the same information to that observer if supplied; but it is not required.
3860
3861    /**
3862     * @hide
3863     *
3864     * Install a package. Since this may take a little while, the result will
3865     * be posted back to the given observer.  An installation will fail if the calling context
3866     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3867     * package named in the package file's manifest is already installed, or if there's no space
3868     * available on the device.
3869     *
3870     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3871     * 'content:' URI.
3872     * @param observer An observer callback to get notified when the package installation is
3873     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3874     * called when that happens. This parameter must not be null.
3875     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3876     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3877     * @param installerPackageName Optional package name of the application that is performing the
3878     * installation. This identifies which market the package came from.
3879     */
3880    public abstract void installPackage(
3881            Uri packageURI, PackageInstallObserver observer,
3882            int flags, String installerPackageName);
3883
3884
3885    /**
3886     * @hide
3887     * Install a package. Since this may take a little while, the result will be
3888     * posted back to the given observer. An installation will fail if the package named
3889     * in the package file's manifest is already installed, or if there's no space
3890     * available on the device.
3891     * @param packageURI The location of the package file to install. This can be a 'file:' or a
3892     * 'content:' URI.
3893     * @param observer An observer callback to get notified when the package installation is
3894     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3895     * called when that happens. This parameter must not be null.
3896     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3897     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3898     * @param installerPackageName Optional package name of the application that is performing the
3899     * installation. This identifies which market the package came from.
3900     * @param userId The user id.
3901     */
3902     @RequiresPermission(anyOf = {
3903            Manifest.permission.INSTALL_PACKAGES,
3904            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
3905    public abstract void installPackageAsUser(
3906            Uri packageURI, PackageInstallObserver observer, int flags,
3907            String installerPackageName, int userId);
3908
3909    /**
3910     * Similar to
3911     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3912     * with an extra verification file provided.
3913     *
3914     * @param packageURI The location of the package file to install. This can
3915     *            be a 'file:' or a 'content:' URI.
3916     * @param observer An observer callback to get notified when the package installation is
3917     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3918     * called when that happens. This parameter must not be null.
3919     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3920     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3921     * @param installerPackageName Optional package name of the application that
3922     *            is performing the installation. This identifies which market
3923     *            the package came from.
3924     * @param verificationURI The location of the supplementary verification
3925     *            file. This can be a 'file:' or a 'content:' URI. May be
3926     *            {@code null}.
3927     * @param manifestDigest an object that holds the digest of the package
3928     *            which can be used to verify ownership. May be {@code null}.
3929     * @param encryptionParams if the package to be installed is encrypted,
3930     *            these parameters describing the encryption and authentication
3931     *            used. May be {@code null}.
3932     * @hide
3933     */
3934    public abstract void installPackageWithVerification(Uri packageURI,
3935            PackageInstallObserver observer, int flags, String installerPackageName,
3936            Uri verificationURI, ManifestDigest manifestDigest,
3937            ContainerEncryptionParams encryptionParams);
3938
3939    /**
3940     * Similar to
3941     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3942     * with an extra verification information provided.
3943     *
3944     * @param packageURI The location of the package file to install. This can
3945     *            be a 'file:' or a 'content:' URI.
3946     * @param observer An observer callback to get notified when the package installation is
3947     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3948     * called when that happens. This parameter must not be null.
3949     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3950     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3951     * @param installerPackageName Optional package name of the application that
3952     *            is performing the installation. This identifies which market
3953     *            the package came from.
3954     * @param verificationParams an object that holds signal information to
3955     *            assist verification. May be {@code null}.
3956     * @param encryptionParams if the package to be installed is encrypted,
3957     *            these parameters describing the encryption and authentication
3958     *            used. May be {@code null}.
3959     *
3960     * @hide
3961     */
3962    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3963            PackageInstallObserver observer, int flags, String installerPackageName,
3964            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3965
3966    /**
3967     * If there is already an application with the given package name installed
3968     * on the system for other users, also install it for the calling user.
3969     * @hide
3970     */
3971    // @SystemApi
3972    public abstract int installExistingPackage(String packageName) throws NameNotFoundException;
3973
3974    /**
3975     * If there is already an application with the given package name installed
3976     * on the system for other users, also install it for the specified user.
3977     * @hide
3978     */
3979     @RequiresPermission(anyOf = {
3980            Manifest.permission.INSTALL_PACKAGES,
3981            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
3982    public abstract int installExistingPackageAsUser(String packageName, int userId)
3983            throws NameNotFoundException;
3984
3985    /**
3986     * Allows a package listening to the
3987     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3988     * broadcast} to respond to the package manager. The response must include
3989     * the {@code verificationCode} which is one of
3990     * {@link PackageManager#VERIFICATION_ALLOW} or
3991     * {@link PackageManager#VERIFICATION_REJECT}.
3992     *
3993     * @param id pending package identifier as passed via the
3994     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3995     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3996     *            or {@link PackageManager#VERIFICATION_REJECT}.
3997     * @throws SecurityException if the caller does not have the
3998     *            PACKAGE_VERIFICATION_AGENT permission.
3999     */
4000    public abstract void verifyPendingInstall(int id, int verificationCode);
4001
4002    /**
4003     * Allows a package listening to the
4004     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
4005     * broadcast} to extend the default timeout for a response and declare what
4006     * action to perform after the timeout occurs. The response must include
4007     * the {@code verificationCodeAtTimeout} which is one of
4008     * {@link PackageManager#VERIFICATION_ALLOW} or
4009     * {@link PackageManager#VERIFICATION_REJECT}.
4010     *
4011     * This method may only be called once per package id. Additional calls
4012     * will have no effect.
4013     *
4014     * @param id pending package identifier as passed via the
4015     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4016     * @param verificationCodeAtTimeout either
4017     *            {@link PackageManager#VERIFICATION_ALLOW} or
4018     *            {@link PackageManager#VERIFICATION_REJECT}. If
4019     *            {@code verificationCodeAtTimeout} is neither
4020     *            {@link PackageManager#VERIFICATION_ALLOW} or
4021     *            {@link PackageManager#VERIFICATION_REJECT}, then
4022     *            {@code verificationCodeAtTimeout} will default to
4023     *            {@link PackageManager#VERIFICATION_REJECT}.
4024     * @param millisecondsToDelay the amount of time requested for the timeout.
4025     *            Must be positive and less than
4026     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
4027     *            {@code millisecondsToDelay} is out of bounds,
4028     *            {@code millisecondsToDelay} will be set to the closest in
4029     *            bounds value; namely, 0 or
4030     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
4031     * @throws SecurityException if the caller does not have the
4032     *            PACKAGE_VERIFICATION_AGENT permission.
4033     */
4034    public abstract void extendVerificationTimeout(int id,
4035            int verificationCodeAtTimeout, long millisecondsToDelay);
4036
4037    /**
4038     * Allows a package listening to the
4039     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification
4040     * broadcast} to respond to the package manager. The response must include
4041     * the {@code verificationCode} which is one of
4042     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
4043     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4044     *
4045     * @param verificationId pending package identifier as passed via the
4046     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
4047     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
4048     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
4049     * @param outFailedDomains a list of failed domains if the verificationCode is
4050     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
4051     * @throws SecurityException if the caller does not have the
4052     *            INTENT_FILTER_VERIFICATION_AGENT permission.
4053     *
4054     * @hide
4055     */
4056    @SystemApi
4057    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
4058            List<String> outFailedDomains);
4059
4060    /**
4061     * Get the status of a Domain Verification Result for an IntentFilter. This is
4062     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4063     * {@link android.content.IntentFilter#getAutoVerify()}
4064     *
4065     * This is used by the ResolverActivity to change the status depending on what the User select
4066     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4067     * for a domain.
4068     *
4069     * @param packageName The package name of the Activity associated with the IntentFilter.
4070     * @param userId The user id.
4071     *
4072     * @return The status to set to. This can be
4073     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4074     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4075     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
4076     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
4077     *
4078     * @hide
4079     */
4080    public abstract int getIntentVerificationStatus(String packageName, int userId);
4081
4082    /**
4083     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
4084     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
4085     * {@link android.content.IntentFilter#getAutoVerify()}
4086     *
4087     * This is used by the ResolverActivity to change the status depending on what the User select
4088     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
4089     * for a domain.
4090     *
4091     * @param packageName The package name of the Activity associated with the IntentFilter.
4092     * @param status The status to set to. This can be
4093     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
4094     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
4095     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
4096     * @param userId The user id.
4097     *
4098     * @return true if the status has been set. False otherwise.
4099     *
4100     * @hide
4101     */
4102    public abstract boolean updateIntentVerificationStatus(String packageName, int status,
4103            int userId);
4104
4105    /**
4106     * Get the list of IntentFilterVerificationInfo for a specific package and User.
4107     *
4108     * @param packageName the package name. When this parameter is set to a non null value,
4109     *                    the results will be filtered by the package name provided.
4110     *                    Otherwise, there will be no filtering and it will return a list
4111     *                    corresponding for all packages
4112     *
4113     * @return a list of IntentFilterVerificationInfo for a specific package.
4114     *
4115     * @hide
4116     */
4117    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
4118            String packageName);
4119
4120    /**
4121     * Get the list of IntentFilter for a specific package.
4122     *
4123     * @param packageName the package name. This parameter is set to a non null value,
4124     *                    the list will contain all the IntentFilter for that package.
4125     *                    Otherwise, the list will be empty.
4126     *
4127     * @return a list of IntentFilter for a specific package.
4128     *
4129     * @hide
4130     */
4131    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
4132
4133    /**
4134     * Get the default Browser package name for a specific user.
4135     *
4136     * @param userId The user id.
4137     *
4138     * @return the package name of the default Browser for the specified user. If the user id passed
4139     *         is -1 (all users) it will return a null value.
4140     *
4141     * @hide
4142     */
4143    public abstract String getDefaultBrowserPackageName(int userId);
4144
4145    /**
4146     * Set the default Browser package name for a specific user.
4147     *
4148     * @param packageName The package name of the default Browser.
4149     * @param userId The user id.
4150     *
4151     * @return true if the default Browser for the specified user has been set,
4152     *         otherwise return false. If the user id passed is -1 (all users) this call will not
4153     *         do anything and just return false.
4154     *
4155     * @hide
4156     */
4157    public abstract boolean setDefaultBrowserPackageName(String packageName, int userId);
4158
4159    /**
4160     * Change the installer associated with a given package.  There are limitations
4161     * on how the installer package can be changed; in particular:
4162     * <ul>
4163     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
4164     * is not signed with the same certificate as the calling application.
4165     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
4166     * has an installer package, and that installer package is not signed with
4167     * the same certificate as the calling application.
4168     * </ul>
4169     *
4170     * @param targetPackage The installed package whose installer will be changed.
4171     * @param installerPackageName The package name of the new installer.  May be
4172     * null to clear the association.
4173     */
4174    public abstract void setInstallerPackageName(String targetPackage,
4175            String installerPackageName);
4176
4177    /**
4178     * Attempts to delete a package.  Since this may take a little while, the result will
4179     * be posted back to the given observer.  A deletion will fail if the calling context
4180     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
4181     * named package cannot be found, or if the named package is a "system package".
4182     * (TODO: include pointer to documentation on "system packages")
4183     *
4184     * @param packageName The name of the package to delete
4185     * @param observer An observer callback to get notified when the package deletion is
4186     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
4187     * called when that happens.  observer may be null to indicate that no callback is desired.
4188     * @param flags Possible values: {@link #DELETE_KEEP_DATA},
4189     * {@link #DELETE_ALL_USERS}.
4190     *
4191     * @hide
4192     */
4193    // @SystemApi
4194    public abstract void deletePackage(
4195            String packageName, IPackageDeleteObserver observer, int flags);
4196
4197    /**
4198     * Attempts to delete a package.  Since this may take a little while, the result will
4199     * be posted back to the given observer. A deletion will fail if the named package cannot be
4200     * found, or if the named package is a "system package".
4201     * (TODO: include pointer to documentation on "system packages")
4202     *
4203     * @param packageName The name of the package to delete
4204     * @param observer An observer callback to get notified when the package deletion is
4205     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
4206     * called when that happens.  observer may be null to indicate that no callback is desired.
4207     * @param flags Possible values: {@link #DELETE_KEEP_DATA}, {@link #DELETE_ALL_USERS}.
4208     * @param userId The user Id
4209     *
4210     * @hide
4211     */
4212     @RequiresPermission(anyOf = {
4213            Manifest.permission.DELETE_PACKAGES,
4214            Manifest.permission.INTERACT_ACROSS_USERS_FULL})
4215    public abstract void deletePackageAsUser(
4216            String packageName, IPackageDeleteObserver observer, int flags, int userId);
4217
4218    /**
4219     * Retrieve the package name of the application that installed a package. This identifies
4220     * which market the package came from.
4221     *
4222     * @param packageName The name of the package to query
4223     */
4224    public abstract String getInstallerPackageName(String packageName);
4225
4226    /**
4227     * Attempts to clear the user data directory of an application.
4228     * Since this may take a little while, the result will
4229     * be posted back to the given observer.  A deletion will fail if the
4230     * named package cannot be found, or if the named package is a "system package".
4231     *
4232     * @param packageName The name of the package
4233     * @param observer An observer callback to get notified when the operation is finished
4234     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4235     * will be called when that happens.  observer may be null to indicate that
4236     * no callback is desired.
4237     *
4238     * @hide
4239     */
4240    public abstract void clearApplicationUserData(String packageName,
4241            IPackageDataObserver observer);
4242    /**
4243     * Attempts to delete the cache files associated with an application.
4244     * Since this may take a little while, the result will
4245     * be posted back to the given observer.  A deletion will fail if the calling context
4246     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
4247     * named package cannot be found, or if the named package is a "system package".
4248     *
4249     * @param packageName The name of the package to delete
4250     * @param observer An observer callback to get notified when the cache file deletion
4251     * is complete.
4252     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
4253     * will be called when that happens.  observer may be null to indicate that
4254     * no callback is desired.
4255     *
4256     * @hide
4257     */
4258    public abstract void deleteApplicationCacheFiles(String packageName,
4259            IPackageDataObserver observer);
4260
4261    /**
4262     * Free storage by deleting LRU sorted list of cache files across
4263     * all applications. If the currently available free storage
4264     * on the device is greater than or equal to the requested
4265     * free storage, no cache files are cleared. If the currently
4266     * available storage on the device is less than the requested
4267     * free storage, some or all of the cache files across
4268     * all applications are deleted (based on last accessed time)
4269     * to increase the free storage space on the device to
4270     * the requested value. There is no guarantee that clearing all
4271     * the cache files from all applications will clear up
4272     * enough storage to achieve the desired value.
4273     * @param freeStorageSize The number of bytes of storage to be
4274     * freed by the system. Say if freeStorageSize is XX,
4275     * and the current free storage is YY,
4276     * if XX is less than YY, just return. if not free XX-YY number
4277     * of bytes if possible.
4278     * @param observer call back used to notify when
4279     * the operation is completed
4280     *
4281     * @hide
4282     */
4283    // @SystemApi
4284    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
4285        freeStorageAndNotify(null, freeStorageSize, observer);
4286    }
4287
4288    /** {@hide} */
4289    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
4290            IPackageDataObserver observer);
4291
4292    /**
4293     * Free storage by deleting LRU sorted list of cache files across
4294     * all applications. If the currently available free storage
4295     * on the device is greater than or equal to the requested
4296     * free storage, no cache files are cleared. If the currently
4297     * available storage on the device is less than the requested
4298     * free storage, some or all of the cache files across
4299     * all applications are deleted (based on last accessed time)
4300     * to increase the free storage space on the device to
4301     * the requested value. There is no guarantee that clearing all
4302     * the cache files from all applications will clear up
4303     * enough storage to achieve the desired value.
4304     * @param freeStorageSize The number of bytes of storage to be
4305     * freed by the system. Say if freeStorageSize is XX,
4306     * and the current free storage is YY,
4307     * if XX is less than YY, just return. if not free XX-YY number
4308     * of bytes if possible.
4309     * @param pi IntentSender call back used to
4310     * notify when the operation is completed.May be null
4311     * to indicate that no call back is desired.
4312     *
4313     * @hide
4314     */
4315    public void freeStorage(long freeStorageSize, IntentSender pi) {
4316        freeStorage(null, freeStorageSize, pi);
4317    }
4318
4319    /** {@hide} */
4320    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
4321
4322    /**
4323     * Retrieve the size information for a package.
4324     * Since this may take a little while, the result will
4325     * be posted back to the given observer.  The calling context
4326     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
4327     *
4328     * @param packageName The name of the package whose size information is to be retrieved
4329     * @param userHandle The user whose size information should be retrieved.
4330     * @param observer An observer callback to get notified when the operation
4331     * is complete.
4332     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
4333     * The observer's callback is invoked with a PackageStats object(containing the
4334     * code, data and cache sizes of the package) and a boolean value representing
4335     * the status of the operation. observer may be null to indicate that
4336     * no callback is desired.
4337     *
4338     * @hide
4339     */
4340    public abstract void getPackageSizeInfo(String packageName, int userHandle,
4341            IPackageStatsObserver observer);
4342
4343    /**
4344     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
4345     * returns the size for the calling user.
4346     *
4347     * @hide
4348     */
4349    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
4350        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
4351    }
4352
4353    /**
4354     * @deprecated This function no longer does anything; it was an old
4355     * approach to managing preferred activities, which has been superseded
4356     * by (and conflicts with) the modern activity-based preferences.
4357     */
4358    @Deprecated
4359    public abstract void addPackageToPreferred(String packageName);
4360
4361    /**
4362     * @deprecated This function no longer does anything; it was an old
4363     * approach to managing preferred activities, which has been superseded
4364     * by (and conflicts with) the modern activity-based preferences.
4365     */
4366    @Deprecated
4367    public abstract void removePackageFromPreferred(String packageName);
4368
4369    /**
4370     * Retrieve the list of all currently configured preferred packages.  The
4371     * first package on the list is the most preferred, the last is the
4372     * least preferred.
4373     *
4374     * @param flags Additional option flags. Use any combination of
4375     * {@link #GET_ACTIVITIES},
4376     * {@link #GET_GIDS},
4377     * {@link #GET_CONFIGURATIONS},
4378     * {@link #GET_INSTRUMENTATION},
4379     * {@link #GET_PERMISSIONS},
4380     * {@link #GET_PROVIDERS},
4381     * {@link #GET_RECEIVERS},
4382     * {@link #GET_SERVICES},
4383     * {@link #GET_SIGNATURES}, to modify the data returned.
4384     *
4385     * @return Returns a list of PackageInfo objects describing each
4386     * preferred application, in order of preference.
4387     *
4388     * @see #GET_ACTIVITIES
4389     * @see #GET_GIDS
4390     * @see #GET_CONFIGURATIONS
4391     * @see #GET_INSTRUMENTATION
4392     * @see #GET_PERMISSIONS
4393     * @see #GET_PROVIDERS
4394     * @see #GET_RECEIVERS
4395     * @see #GET_SERVICES
4396     * @see #GET_SIGNATURES
4397     */
4398    public abstract List<PackageInfo> getPreferredPackages(int flags);
4399
4400    /**
4401     * @deprecated This is a protected API that should not have been available
4402     * to third party applications.  It is the platform's responsibility for
4403     * assigning preferred activities and this cannot be directly modified.
4404     *
4405     * Add a new preferred activity mapping to the system.  This will be used
4406     * to automatically select the given activity component when
4407     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4408     * multiple matching activities and also matches the given filter.
4409     *
4410     * @param filter The set of intents under which this activity will be
4411     * made preferred.
4412     * @param match The IntentFilter match category that this preference
4413     * applies to.
4414     * @param set The set of activities that the user was picking from when
4415     * this preference was made.
4416     * @param activity The component name of the activity that is to be
4417     * preferred.
4418     */
4419    @Deprecated
4420    public abstract void addPreferredActivity(IntentFilter filter, int match,
4421            ComponentName[] set, ComponentName activity);
4422
4423    /**
4424     * Same as {@link #addPreferredActivity(IntentFilter, int,
4425            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
4426            to.
4427     * @hide
4428     */
4429    public void addPreferredActivity(IntentFilter filter, int match,
4430            ComponentName[] set, ComponentName activity, int userId) {
4431        throw new RuntimeException("Not implemented. Must override in a subclass.");
4432    }
4433
4434    /**
4435     * @deprecated This is a protected API that should not have been available
4436     * to third party applications.  It is the platform's responsibility for
4437     * assigning preferred activities and this cannot be directly modified.
4438     *
4439     * Replaces an existing preferred activity mapping to the system, and if that were not present
4440     * adds a new preferred activity.  This will be used
4441     * to automatically select the given activity component when
4442     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4443     * multiple matching activities and also matches the given filter.
4444     *
4445     * @param filter The set of intents under which this activity will be
4446     * made preferred.
4447     * @param match The IntentFilter match category that this preference
4448     * applies to.
4449     * @param set The set of activities that the user was picking from when
4450     * this preference was made.
4451     * @param activity The component name of the activity that is to be
4452     * preferred.
4453     * @hide
4454     */
4455    @Deprecated
4456    public abstract void replacePreferredActivity(IntentFilter filter, int match,
4457            ComponentName[] set, ComponentName activity);
4458
4459    /**
4460     * @hide
4461     */
4462    @Deprecated
4463    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
4464           ComponentName[] set, ComponentName activity, int userId) {
4465        throw new RuntimeException("Not implemented. Must override in a subclass.");
4466    }
4467
4468    /**
4469     * Remove all preferred activity mappings, previously added with
4470     * {@link #addPreferredActivity}, from the
4471     * system whose activities are implemented in the given package name.
4472     * An application can only clear its own package(s).
4473     *
4474     * @param packageName The name of the package whose preferred activity
4475     * mappings are to be removed.
4476     */
4477    public abstract void clearPackagePreferredActivities(String packageName);
4478
4479    /**
4480     * Retrieve all preferred activities, previously added with
4481     * {@link #addPreferredActivity}, that are
4482     * currently registered with the system.
4483     *
4484     * @param outFilters A required list in which to place the filters of all of the
4485     * preferred activities.
4486     * @param outActivities A required list in which to place the component names of
4487     * all of the preferred activities.
4488     * @param packageName An optional package in which you would like to limit
4489     * the list.  If null, all activities will be returned; if non-null, only
4490     * those activities in the given package are returned.
4491     *
4492     * @return Returns the total number of registered preferred activities
4493     * (the number of distinct IntentFilter records, not the number of unique
4494     * activity components) that were found.
4495     */
4496    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
4497            @NonNull List<ComponentName> outActivities, String packageName);
4498
4499    /**
4500     * Ask for the set of available 'home' activities and the current explicit
4501     * default, if any.
4502     * @hide
4503     */
4504    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
4505
4506    /**
4507     * Set the enabled setting for a package component (activity, receiver, service, provider).
4508     * This setting will override any enabled state which may have been set by the component in its
4509     * manifest.
4510     *
4511     * @param componentName The component to enable
4512     * @param newState The new enabled state for the component.  The legal values for this state
4513     *                 are:
4514     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4515     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4516     *                   and
4517     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4518     *                 The last one removes the setting, thereby restoring the component's state to
4519     *                 whatever was set in it's manifest (or enabled, by default).
4520     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4521     */
4522    public abstract void setComponentEnabledSetting(ComponentName componentName,
4523            int newState, int flags);
4524
4525
4526    /**
4527     * Return the enabled setting for a package component (activity,
4528     * receiver, service, provider).  This returns the last value set by
4529     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
4530     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4531     * the value originally specified in the manifest has not been modified.
4532     *
4533     * @param componentName The component to retrieve.
4534     * @return Returns the current enabled state for the component.  May
4535     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4536     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4537     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4538     * component's enabled state is based on the original information in
4539     * the manifest as found in {@link ComponentInfo}.
4540     */
4541    public abstract int getComponentEnabledSetting(ComponentName componentName);
4542
4543    /**
4544     * Set the enabled setting for an application
4545     * This setting will override any enabled state which may have been set by the application in
4546     * its manifest.  It also overrides the enabled state set in the manifest for any of the
4547     * application's components.  It does not override any enabled state set by
4548     * {@link #setComponentEnabledSetting} for any of the application's components.
4549     *
4550     * @param packageName The package name of the application to enable
4551     * @param newState The new enabled state for the component.  The legal values for this state
4552     *                 are:
4553     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4554     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4555     *                   and
4556     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4557     *                 The last one removes the setting, thereby restoring the applications's state to
4558     *                 whatever was set in its manifest (or enabled, by default).
4559     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4560     */
4561    public abstract void setApplicationEnabledSetting(String packageName,
4562            int newState, int flags);
4563
4564    /**
4565     * Return the enabled setting for an application. This returns
4566     * the last value set by
4567     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
4568     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4569     * the value originally specified in the manifest has not been modified.
4570     *
4571     * @param packageName The package name of the application to retrieve.
4572     * @return Returns the current enabled state for the application.  May
4573     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4574     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4575     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4576     * application's enabled state is based on the original information in
4577     * the manifest as found in {@link ComponentInfo}.
4578     * @throws IllegalArgumentException if the named package does not exist.
4579     */
4580    public abstract int getApplicationEnabledSetting(String packageName);
4581
4582    /**
4583     * Puts the package in a hidden state, which is almost like an uninstalled state,
4584     * making the package unavailable, but it doesn't remove the data or the actual
4585     * package file. Application can be unhidden by either resetting the hidden state
4586     * or by installing it, such as with {@link #installExistingPackage(String)}
4587     * @hide
4588     */
4589    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
4590            UserHandle userHandle);
4591
4592    /**
4593     * Returns the hidden state of a package.
4594     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
4595     * @hide
4596     */
4597    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
4598            UserHandle userHandle);
4599
4600    /**
4601     * Return whether the device has been booted into safe mode.
4602     */
4603    public abstract boolean isSafeMode();
4604
4605    /**
4606     * Adds a listener for permission changes for installed packages.
4607     *
4608     * @param listener The listener to add.
4609     *
4610     * @hide
4611     */
4612    @SystemApi
4613    @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS)
4614    public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener);
4615
4616    /**
4617     * Remvoes a listener for permission changes for installed packages.
4618     *
4619     * @param listener The listener to remove.
4620     *
4621     * @hide
4622     */
4623    @SystemApi
4624    public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener);
4625
4626    /**
4627     * Return the {@link KeySet} associated with the String alias for this
4628     * application.
4629     *
4630     * @param alias The alias for a given {@link KeySet} as defined in the
4631     *        application's AndroidManifest.xml.
4632     * @hide
4633     */
4634    public abstract KeySet getKeySetByAlias(String packageName, String alias);
4635
4636    /** Return the signing {@link KeySet} for this application.
4637     * @hide
4638     */
4639    public abstract KeySet getSigningKeySet(String packageName);
4640
4641    /**
4642     * Return whether the package denoted by packageName has been signed by all
4643     * of the keys specified by the {@link KeySet} ks.  This will return true if
4644     * the package has been signed by additional keys (a superset) as well.
4645     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
4646     * @hide
4647     */
4648    public abstract boolean isSignedBy(String packageName, KeySet ks);
4649
4650    /**
4651     * Return whether the package denoted by packageName has been signed by all
4652     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
4653     * {@link #isSignedBy(String packageName, KeySet ks)}.
4654     * @hide
4655     */
4656    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
4657
4658    /**
4659     * Attempts to move package resources from internal to external media or vice versa.
4660     * Since this may take a little while, the result will
4661     * be posted back to the given observer.   This call may fail if the calling context
4662     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
4663     * named package cannot be found, or if the named package is a "system package".
4664     *
4665     * @param packageName The name of the package to delete
4666     * @param observer An observer callback to get notified when the package move is
4667     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
4668     * called when that happens.  observer may be null to indicate that no callback is desired.
4669     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
4670     * {@link #MOVE_EXTERNAL_MEDIA}
4671     *
4672     * @hide
4673     */
4674    @Deprecated
4675    public void movePackage(String packageName, IPackageMoveObserver observer, int flags) {
4676        throw new UnsupportedOperationException();
4677    }
4678
4679    /**
4680     * Puts the package in a suspended state, making the package un-runnable,
4681     * but it doesn't remove the data or the actual package file. The application notifications
4682     * will be hidden and also the application will not show up in recents.
4683     *
4684     * @param packageName The name of the package to set the suspended status.
4685     * @param suspended If set to {@code true} than the package will be suspended, if set to
4686     * {@code false} the package will be unsuspended.
4687     * @param userId The user id.
4688     *
4689     * @hide
4690     */
4691    public abstract boolean setPackageSuspendedAsUser(
4692            String packageName, boolean suspended, int userId);
4693
4694    /** {@hide} */
4695    public static boolean isMoveStatusFinished(int status) {
4696        return (status < 0 || status > 100);
4697    }
4698
4699    /** {@hide} */
4700    public static abstract class MoveCallback {
4701        public void onCreated(int moveId, Bundle extras) {}
4702        public abstract void onStatusChanged(int moveId, int status, long estMillis);
4703    }
4704
4705    /** {@hide} */
4706    public abstract int getMoveStatus(int moveId);
4707
4708    /** {@hide} */
4709    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
4710    /** {@hide} */
4711    public abstract void unregisterMoveCallback(MoveCallback callback);
4712
4713    /** {@hide} */
4714    public abstract int movePackage(String packageName, VolumeInfo vol);
4715    /** {@hide} */
4716    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
4717    /** {@hide} */
4718    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
4719
4720    /** {@hide} */
4721    public abstract int movePrimaryStorage(VolumeInfo vol);
4722    /** {@hide} */
4723    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
4724    /** {@hide} */
4725    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
4726
4727    /**
4728     * Returns the device identity that verifiers can use to associate their scheme to a particular
4729     * device. This should not be used by anything other than a package verifier.
4730     *
4731     * @return identity that uniquely identifies current device
4732     * @hide
4733     */
4734    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
4735
4736    /**
4737     * Returns true if the device is upgrading, such as first boot after OTA.
4738     *
4739     * @hide
4740     */
4741    public abstract boolean isUpgrade();
4742
4743    /**
4744     * Return interface that offers the ability to install, upgrade, and remove
4745     * applications on the device.
4746     */
4747    public abstract @NonNull PackageInstaller getPackageInstaller();
4748
4749    /**
4750     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
4751     * user with id sourceUserId can also be be resolved by activities in the user with id
4752     * targetUserId if they match the specified intent filter.
4753     * @param filter The {@link IntentFilter} the intent has to match
4754     * @param sourceUserId The source user id.
4755     * @param targetUserId The target user id.
4756     * @param flags The possible values are {@link SKIP_CURRENT_PROFILE} and
4757     *        {@link ONLY_IF_NO_MATCH_FOUND}.
4758     * @hide
4759     */
4760    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
4761            int targetUserId, int flags);
4762
4763    /**
4764     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
4765     * source, and have been set by the app calling this method.
4766     * @param sourceUserId The source user id.
4767     * @hide
4768     */
4769    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
4770
4771    /**
4772     * @hide
4773     */
4774    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4775
4776    /**
4777     * @hide
4778     */
4779    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4780
4781    /** {@hide} */
4782    public abstract boolean isPackageAvailable(String packageName);
4783
4784    /** {@hide} */
4785    public static String installStatusToString(int status, String msg) {
4786        final String str = installStatusToString(status);
4787        if (msg != null) {
4788            return str + ": " + msg;
4789        } else {
4790            return str;
4791        }
4792    }
4793
4794    /** {@hide} */
4795    public static String installStatusToString(int status) {
4796        switch (status) {
4797            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
4798            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
4799            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
4800            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
4801            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
4802            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
4803            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
4804            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
4805            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
4806            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
4807            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
4808            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
4809            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
4810            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
4811            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
4812            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
4813            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
4814            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
4815            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
4816            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
4817            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
4818            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
4819            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
4820            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
4821            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
4822            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
4823            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
4824            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
4825            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
4826            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
4827            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
4828            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
4829            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
4830            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
4831            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
4832            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
4833            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
4834            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
4835            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
4836            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
4837            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
4838            default: return Integer.toString(status);
4839        }
4840    }
4841
4842    /** {@hide} */
4843    public static int installStatusToPublicStatus(int status) {
4844        switch (status) {
4845            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4846            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4847            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4848            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
4849            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4850            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4851            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4852            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4853            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4854            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4855            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4856            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
4857            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4858            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4859            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4860            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
4861            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4862            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4863            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
4864            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
4865            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4866            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
4867            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
4868            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4869            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4870            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4871            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4872            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4873            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
4874            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
4875            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4876            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4877            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
4878            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
4879            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
4880            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
4881            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
4882            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4883            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4884            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4885            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4886            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4887            default: return PackageInstaller.STATUS_FAILURE;
4888        }
4889    }
4890
4891    /** {@hide} */
4892    public static String deleteStatusToString(int status, String msg) {
4893        final String str = deleteStatusToString(status);
4894        if (msg != null) {
4895            return str + ": " + msg;
4896        } else {
4897            return str;
4898        }
4899    }
4900
4901    /** {@hide} */
4902    public static String deleteStatusToString(int status) {
4903        switch (status) {
4904            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
4905            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
4906            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
4907            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
4908            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
4909            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
4910            default: return Integer.toString(status);
4911        }
4912    }
4913
4914    /** {@hide} */
4915    public static int deleteStatusToPublicStatus(int status) {
4916        switch (status) {
4917            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4918            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4919            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4920            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4921            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4922            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4923            default: return PackageInstaller.STATUS_FAILURE;
4924        }
4925    }
4926
4927    /** {@hide} */
4928    public static String permissionFlagToString(int flag) {
4929        switch (flag) {
4930            case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT";
4931            case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED";
4932            case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED";
4933            case FLAG_PERMISSION_USER_SET: return "USER_SET";
4934            case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE";
4935            case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED";
4936            case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED";
4937            default: return Integer.toString(flag);
4938        }
4939    }
4940
4941    /** {@hide} */
4942    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
4943        private final IPackageInstallObserver mLegacy;
4944
4945        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
4946            mLegacy = legacy;
4947        }
4948
4949        @Override
4950        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
4951                Bundle extras) {
4952            if (mLegacy == null) return;
4953            try {
4954                mLegacy.packageInstalled(basePackageName, returnCode);
4955            } catch (RemoteException ignored) {
4956            }
4957        }
4958    }
4959
4960    /** {@hide} */
4961    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
4962        private final IPackageDeleteObserver mLegacy;
4963
4964        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
4965            mLegacy = legacy;
4966        }
4967
4968        @Override
4969        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
4970            if (mLegacy == null) return;
4971            try {
4972                mLegacy.packageDeleted(basePackageName, returnCode);
4973            } catch (RemoteException ignored) {
4974            }
4975        }
4976    }
4977}
4978