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