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