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