PackageManager.java revision a73e4599506a1d3498ef5e9c240d79d7125fd2e9
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 if the
3278     * target user is the caller and is itself a managed profile, then this
3279     * returns a badged copy of the given icon to be able to distinguish it from
3280     * the original icon. For badging an arbitrary drawable use
3281     * {@link #getUserBadgedDrawableForDensity(
3282     * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}.
3283     * <p>
3284     * If the original drawable is a BitmapDrawable and the backing bitmap is
3285     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging
3286     * is performed in place and the original drawable is returned.
3287     * </p>
3288     *
3289     * @param icon The icon to badge.
3290     * @param user The target user.
3291     * @return A drawable that combines the original icon and a badge as
3292     *         determined by the system.
3293     */
3294    public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user);
3295
3296    /**
3297     * If the target user is a managed profile of the calling user or the caller
3298     * is itself a managed profile, then this returns a badged copy of the given
3299     * drawable allowing the user to distinguish it from the original drawable.
3300     * The caller can specify the location in the bounds of the drawable to be
3301     * badged where the badge should be applied as well as the density of the
3302     * badge to be used.
3303     * <p>
3304     * If the original drawable is a BitmapDrawable and the backing bitmap is
3305     * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading
3306     * is performed in place and the original drawable is returned.
3307     * </p>
3308     *
3309     * @param drawable The drawable to badge.
3310     * @param user The target user.
3311     * @param badgeLocation Where in the bounds of the badged drawable to place
3312     *         the badge. If not provided, the badge is applied on top of the entire
3313     *         drawable being badged.
3314     * @param badgeDensity The optional desired density for the badge as per
3315     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided,
3316     *         the density of the display is used.
3317     * @return A drawable that combines the original drawable and a badge as
3318     *         determined by the system.
3319     */
3320    public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable,
3321            UserHandle user, Rect badgeLocation, int badgeDensity);
3322
3323    /**
3324     * If the target user is a managed profile of the calling user or the caller
3325     * is itself a managed profile, then this returns a drawable to use as a small
3326     * icon to include in a view to distinguish it from the original icon.
3327     *
3328     * @param user The target user.
3329     * @param density The optional desired density for the badge as per
3330     *         {@link android.util.DisplayMetrics#densityDpi}. If not provided
3331     *         the density of the current display is used.
3332     * @return the drawable or null if no drawable is required.
3333     * @hide
3334     */
3335    public abstract Drawable getUserBadgeForDensity(UserHandle user, int density);
3336
3337    /**
3338     * If the target user is a managed profile of the calling user or the caller
3339     * is itself a managed profile, then this returns a copy of the label with
3340     * badging for accessibility services like talkback. E.g. passing in "Email"
3341     * and it might return "Work Email" for Email in the work profile.
3342     *
3343     * @param label The label to change.
3344     * @param user The target user.
3345     * @return A label that combines the original label and a badge as
3346     *         determined by the system.
3347     */
3348    public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user);
3349
3350    /**
3351     * Retrieve text from a package.  This is a low-level API used by
3352     * the various package manager info structures (such as
3353     * {@link ComponentInfo} to implement retrieval of their associated
3354     * labels and other text.
3355     *
3356     * @param packageName The name of the package that this text is coming from.
3357     * Cannot be null.
3358     * @param resid The resource identifier of the desired text.  Cannot be 0.
3359     * @param appInfo Overall information about <var>packageName</var>.  This
3360     * may be null, in which case the application information will be retrieved
3361     * for you if needed; if you already have this information around, it can
3362     * be much more efficient to supply it here.
3363     *
3364     * @return Returns a CharSequence holding the requested text.  Returns null
3365     * if the text could not be found for any reason.
3366     */
3367    public abstract CharSequence getText(String packageName, @StringRes int resid,
3368            ApplicationInfo appInfo);
3369
3370    /**
3371     * Retrieve an XML file from a package.  This is a low-level API used to
3372     * retrieve XML meta data.
3373     *
3374     * @param packageName The name of the package that this xml is coming from.
3375     * Cannot be null.
3376     * @param resid The resource identifier of the desired xml.  Cannot be 0.
3377     * @param appInfo Overall information about <var>packageName</var>.  This
3378     * may be null, in which case the application information will be retrieved
3379     * for you if needed; if you already have this information around, it can
3380     * be much more efficient to supply it here.
3381     *
3382     * @return Returns an XmlPullParser allowing you to parse out the XML
3383     * data.  Returns null if the xml resource could not be found for any
3384     * reason.
3385     */
3386    public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid,
3387            ApplicationInfo appInfo);
3388
3389    /**
3390     * Return the label to use for this application.
3391     *
3392     * @return Returns the label associated with this application, or null if
3393     * it could not be found for any reason.
3394     * @param info The application to get the label of.
3395     */
3396    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
3397
3398    /**
3399     * Retrieve the resources associated with an activity.  Given the full
3400     * name of an activity, retrieves the information about it and calls
3401     * getResources() to return its application's resources.  If the activity
3402     * cannot be found, NameNotFoundException is thrown.
3403     *
3404     * @param activityName Name of the activity whose resources are to be
3405     *                     retrieved.
3406     *
3407     * @return Returns the application's Resources.
3408     * @throws NameNotFoundException Thrown if the resources for the given
3409     * application could not be loaded.
3410     *
3411     * @see #getResourcesForApplication(ApplicationInfo)
3412     */
3413    public abstract Resources getResourcesForActivity(ComponentName activityName)
3414            throws NameNotFoundException;
3415
3416    /**
3417     * Retrieve the resources for an application.  Throws NameNotFoundException
3418     * if the package is no longer installed.
3419     *
3420     * @param app Information about the desired application.
3421     *
3422     * @return Returns the application's Resources.
3423     * @throws NameNotFoundException Thrown if the resources for the given
3424     * application could not be loaded (most likely because it was uninstalled).
3425     */
3426    public abstract Resources getResourcesForApplication(ApplicationInfo app)
3427            throws NameNotFoundException;
3428
3429    /**
3430     * Retrieve the resources associated with an application.  Given the full
3431     * package name of an application, retrieves the information about it and
3432     * calls getResources() to return its application's resources.  If the
3433     * appPackageName cannot be found, NameNotFoundException is thrown.
3434     *
3435     * @param appPackageName Package name of the application whose resources
3436     *                       are to be retrieved.
3437     *
3438     * @return Returns the application's Resources.
3439     * @throws NameNotFoundException Thrown if the resources for the given
3440     * application could not be loaded.
3441     *
3442     * @see #getResourcesForApplication(ApplicationInfo)
3443     */
3444    public abstract Resources getResourcesForApplication(String appPackageName)
3445            throws NameNotFoundException;
3446
3447    /** @hide */
3448    public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId)
3449            throws NameNotFoundException;
3450
3451    /**
3452     * Retrieve overall information about an application package defined
3453     * in a package archive file
3454     *
3455     * @param archiveFilePath The path to the archive file
3456     * @param flags Additional option flags. Use any combination of
3457     * {@link #GET_ACTIVITIES},
3458     * {@link #GET_GIDS},
3459     * {@link #GET_CONFIGURATIONS},
3460     * {@link #GET_INSTRUMENTATION},
3461     * {@link #GET_PERMISSIONS},
3462     * {@link #GET_PROVIDERS},
3463     * {@link #GET_RECEIVERS},
3464     * {@link #GET_SERVICES},
3465     * {@link #GET_SIGNATURES}, to modify the data returned.
3466     *
3467     * @return Returns the information about the package. Returns
3468     * null if the package could not be successfully parsed.
3469     *
3470     * @see #GET_ACTIVITIES
3471     * @see #GET_GIDS
3472     * @see #GET_CONFIGURATIONS
3473     * @see #GET_INSTRUMENTATION
3474     * @see #GET_PERMISSIONS
3475     * @see #GET_PROVIDERS
3476     * @see #GET_RECEIVERS
3477     * @see #GET_SERVICES
3478     * @see #GET_SIGNATURES
3479     *
3480     */
3481    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
3482        final PackageParser parser = new PackageParser();
3483        final File apkFile = new File(archiveFilePath);
3484        try {
3485            PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0);
3486            if ((flags & GET_SIGNATURES) != 0) {
3487                parser.collectCertificates(pkg, 0);
3488                parser.collectManifestDigest(pkg);
3489            }
3490            PackageUserState state = new PackageUserState();
3491            return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state);
3492        } catch (PackageParserException e) {
3493            return null;
3494        }
3495    }
3496
3497    /**
3498     * @hide Install a package. Since this may take a little while, the result
3499     *       will be posted back to the given observer. An installation will
3500     *       fail if the calling context lacks the
3501     *       {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if
3502     *       the package named in the package file's manifest is already
3503     *       installed, or if there's no space available on the device.
3504     * @param packageURI The location of the package file to install. This can
3505     *            be a 'file:' or a 'content:' URI.
3506     * @param observer An observer callback to get notified when the package
3507     *            installation is complete.
3508     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3509     *            will be called when that happens. This parameter must not be
3510     *            null.
3511     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3512     *            {@link #INSTALL_REPLACE_EXISTING},
3513     *            {@link #INSTALL_ALLOW_TEST}.
3514     * @param installerPackageName Optional package name of the application that
3515     *            is performing the installation. This identifies which market
3516     *            the package came from.
3517     * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int,
3518     *             String)} instead. This method will continue to be supported
3519     *             but the older observer interface will not get additional
3520     *             failure details.
3521     */
3522    // @SystemApi
3523    public abstract void installPackage(
3524            Uri packageURI, IPackageInstallObserver observer, int flags,
3525            String installerPackageName);
3526
3527    /**
3528     * Similar to
3529     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3530     * with an extra verification file provided.
3531     *
3532     * @param packageURI The location of the package file to install. This can
3533     *            be a 'file:' or a 'content:' URI.
3534     * @param observer An observer callback to get notified when the package
3535     *            installation is complete.
3536     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3537     *            will be called when that happens. This parameter must not be
3538     *            null.
3539     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3540     *            {@link #INSTALL_REPLACE_EXISTING},
3541     *            {@link #INSTALL_ALLOW_TEST}.
3542     * @param installerPackageName Optional package name of the application that
3543     *            is performing the installation. This identifies which market
3544     *            the package came from.
3545     * @param verificationURI The location of the supplementary verification
3546     *            file. This can be a 'file:' or a 'content:' URI. May be
3547     *            {@code null}.
3548     * @param manifestDigest an object that holds the digest of the package
3549     *            which can be used to verify ownership. May be {@code null}.
3550     * @param encryptionParams if the package to be installed is encrypted,
3551     *            these parameters describing the encryption and authentication
3552     *            used. May be {@code null}.
3553     * @hide
3554     * @deprecated Use {@link #installPackageWithVerification(Uri,
3555     *             PackageInstallObserver, int, String, Uri, ManifestDigest,
3556     *             ContainerEncryptionParams)} instead. This method will
3557     *             continue to be supported but the older observer interface
3558     *             will not get additional failure details.
3559     */
3560    // @SystemApi
3561    public abstract void installPackageWithVerification(Uri packageURI,
3562            IPackageInstallObserver observer, int flags, String installerPackageName,
3563            Uri verificationURI, ManifestDigest manifestDigest,
3564            ContainerEncryptionParams encryptionParams);
3565
3566    /**
3567     * Similar to
3568     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3569     * with an extra verification information provided.
3570     *
3571     * @param packageURI The location of the package file to install. This can
3572     *            be a 'file:' or a 'content:' URI.
3573     * @param observer An observer callback to get notified when the package
3574     *            installation is complete.
3575     *            {@link IPackageInstallObserver#packageInstalled(String, int)}
3576     *            will be called when that happens. This parameter must not be
3577     *            null.
3578     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3579     *            {@link #INSTALL_REPLACE_EXISTING},
3580     *            {@link #INSTALL_ALLOW_TEST}.
3581     * @param installerPackageName Optional package name of the application that
3582     *            is performing the installation. This identifies which market
3583     *            the package came from.
3584     * @param verificationParams an object that holds signal information to
3585     *            assist verification. May be {@code null}.
3586     * @param encryptionParams if the package to be installed is encrypted,
3587     *            these parameters describing the encryption and authentication
3588     *            used. May be {@code null}.
3589     * @hide
3590     * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri,
3591     *             PackageInstallObserver, int, String, VerificationParams,
3592     *             ContainerEncryptionParams)} instead. This method will
3593     *             continue to be supported but the older observer interface
3594     *             will not get additional failure details.
3595     */
3596    @Deprecated
3597    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3598            IPackageInstallObserver observer, int flags, String installerPackageName,
3599            VerificationParams verificationParams,
3600            ContainerEncryptionParams encryptionParams);
3601
3602    // Package-install variants that take the new, expanded form of observer interface.
3603    // Note that these *also* take the original observer type and will redundantly
3604    // report the same information to that observer if supplied; but it is not required.
3605
3606    /**
3607     * @hide
3608     *
3609     * Install a package. Since this may take a little while, the result will
3610     * be posted back to the given observer.  An installation will fail if the calling context
3611     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
3612     * package named in the package file's manifest is already installed, or if there's no space
3613     * available on the device.
3614     *
3615     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
3616     * 'content:' URI.
3617     * @param observer An observer callback to get notified when the package installation is
3618     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3619     * called when that happens. This parameter must not be null.
3620     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3621     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3622     * @param installerPackageName Optional package name of the application that is performing the
3623     * installation. This identifies which market the package came from.
3624     */
3625    public abstract void installPackage(
3626            Uri packageURI, PackageInstallObserver observer,
3627            int flags, String installerPackageName);
3628
3629    /**
3630     * Similar to
3631     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3632     * with an extra verification file provided.
3633     *
3634     * @param packageURI The location of the package file to install. This can
3635     *            be a 'file:' or a 'content:' URI.
3636     * @param observer An observer callback to get notified when the package installation is
3637     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3638     * called when that happens. This parameter must not be null.
3639     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3640     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3641     * @param installerPackageName Optional package name of the application that
3642     *            is performing the installation. This identifies which market
3643     *            the package came from.
3644     * @param verificationURI The location of the supplementary verification
3645     *            file. This can be a 'file:' or a 'content:' URI. May be
3646     *            {@code null}.
3647     * @param manifestDigest an object that holds the digest of the package
3648     *            which can be used to verify ownership. May be {@code null}.
3649     * @param encryptionParams if the package to be installed is encrypted,
3650     *            these parameters describing the encryption and authentication
3651     *            used. May be {@code null}.
3652     * @hide
3653     */
3654    public abstract void installPackageWithVerification(Uri packageURI,
3655            PackageInstallObserver observer, int flags, String installerPackageName,
3656            Uri verificationURI, ManifestDigest manifestDigest,
3657            ContainerEncryptionParams encryptionParams);
3658
3659    /**
3660     * Similar to
3661     * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but
3662     * with an extra verification information provided.
3663     *
3664     * @param packageURI The location of the package file to install. This can
3665     *            be a 'file:' or a 'content:' URI.
3666     * @param observer An observer callback to get notified when the package installation is
3667     * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be
3668     * called when that happens. This parameter must not be null.
3669     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
3670     *            {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
3671     * @param installerPackageName Optional package name of the application that
3672     *            is performing the installation. This identifies which market
3673     *            the package came from.
3674     * @param verificationParams an object that holds signal information to
3675     *            assist verification. May be {@code null}.
3676     * @param encryptionParams if the package to be installed is encrypted,
3677     *            these parameters describing the encryption and authentication
3678     *            used. May be {@code null}.
3679     *
3680     * @hide
3681     */
3682    public abstract void installPackageWithVerificationAndEncryption(Uri packageURI,
3683            PackageInstallObserver observer, int flags, String installerPackageName,
3684            VerificationParams verificationParams, ContainerEncryptionParams encryptionParams);
3685
3686    /**
3687     * If there is already an application with the given package name installed
3688     * on the system for other users, also install it for the calling user.
3689     * @hide
3690     */
3691    // @SystemApi
3692    public abstract int installExistingPackage(String packageName)
3693            throws NameNotFoundException;
3694
3695    /**
3696     * Allows a package listening to the
3697     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3698     * broadcast} to respond to the package manager. The response must include
3699     * the {@code verificationCode} which is one of
3700     * {@link PackageManager#VERIFICATION_ALLOW} or
3701     * {@link PackageManager#VERIFICATION_REJECT}.
3702     *
3703     * @param id pending package identifier as passed via the
3704     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3705     * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW}
3706     *            or {@link PackageManager#VERIFICATION_REJECT}.
3707     * @throws SecurityException if the caller does not have the
3708     *            PACKAGE_VERIFICATION_AGENT permission.
3709     */
3710    public abstract void verifyPendingInstall(int id, int verificationCode);
3711
3712    /**
3713     * Allows a package listening to the
3714     * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification
3715     * broadcast} to extend the default timeout for a response and declare what
3716     * action to perform after the timeout occurs. The response must include
3717     * the {@code verificationCodeAtTimeout} which is one of
3718     * {@link PackageManager#VERIFICATION_ALLOW} or
3719     * {@link PackageManager#VERIFICATION_REJECT}.
3720     *
3721     * This method may only be called once per package id. Additional calls
3722     * will have no effect.
3723     *
3724     * @param id pending package identifier as passed via the
3725     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3726     * @param verificationCodeAtTimeout either
3727     *            {@link PackageManager#VERIFICATION_ALLOW} or
3728     *            {@link PackageManager#VERIFICATION_REJECT}. If
3729     *            {@code verificationCodeAtTimeout} is neither
3730     *            {@link PackageManager#VERIFICATION_ALLOW} or
3731     *            {@link PackageManager#VERIFICATION_REJECT}, then
3732     *            {@code verificationCodeAtTimeout} will default to
3733     *            {@link PackageManager#VERIFICATION_REJECT}.
3734     * @param millisecondsToDelay the amount of time requested for the timeout.
3735     *            Must be positive and less than
3736     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If
3737     *            {@code millisecondsToDelay} is out of bounds,
3738     *            {@code millisecondsToDelay} will be set to the closest in
3739     *            bounds value; namely, 0 or
3740     *            {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}.
3741     * @throws SecurityException if the caller does not have the
3742     *            PACKAGE_VERIFICATION_AGENT permission.
3743     */
3744    public abstract void extendVerificationTimeout(int id,
3745            int verificationCodeAtTimeout, long millisecondsToDelay);
3746
3747    /**
3748     * Allows a package listening to the
3749     * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification
3750     * broadcast} to respond to the package manager. The response must include
3751     * the {@code verificationCode} which is one of
3752     * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or
3753     * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
3754     *
3755     * @param verificationId pending package identifier as passed via the
3756     *            {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra.
3757     * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS}
3758     *            or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}.
3759     * @param outFailedDomains a list of failed domains if the verificationCode is
3760     *            {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null;
3761     * @throws SecurityException if the caller does not have the
3762     *            INTENT_FILTER_VERIFICATION_AGENT permission.
3763     *
3764     * @hide
3765     */
3766    @SystemApi
3767    public abstract void verifyIntentFilter(int verificationId, int verificationCode,
3768            List<String> outFailedDomains);
3769
3770    /**
3771     * Get the status of a Domain Verification Result for an IntentFilter. This is
3772     * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
3773     * {@link android.content.IntentFilter#getAutoVerify()}
3774     *
3775     * This is used by the ResolverActivity to change the status depending on what the User select
3776     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
3777     * for a domain.
3778     *
3779     * @param packageName The package name of the Activity associated with the IntentFilter.
3780     * @param userId The user id.
3781     *
3782     * @return The status to set to. This can be
3783     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
3784     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
3785     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or
3786     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED}
3787     *
3788     * @hide
3789     */
3790    public abstract int getIntentVerificationStatus(String packageName, int userId);
3791
3792    /**
3793     * Allow to change the status of a Intent Verification status for all IntentFilter of an App.
3794     * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and
3795     * {@link android.content.IntentFilter#getAutoVerify()}
3796     *
3797     * This is used by the ResolverActivity to change the status depending on what the User select
3798     * in the Disambiguation Dialog and also used by the Settings App for changing the default App
3799     * for a domain.
3800     *
3801     * @param packageName The package name of the Activity associated with the IntentFilter.
3802     * @param status The status to set to. This can be
3803     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or
3804     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or
3805     *              {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER}
3806     * @param userId The user id.
3807     *
3808     * @return true if the status has been set. False otherwise.
3809     *
3810     * @hide
3811     */
3812    public abstract boolean updateIntentVerificationStatus(String packageName, int status,
3813            int userId);
3814
3815    /**
3816     * Get the list of IntentFilterVerificationInfo for a specific package and User.
3817     *
3818     * @param packageName the package name. When this parameter is set to a non null value,
3819     *                    the results will be filtered by the package name provided.
3820     *                    Otherwise, there will be no filtering and it will return a list
3821     *                    corresponding for all packages
3822     *
3823     * @return a list of IntentFilterVerificationInfo for a specific package.
3824     *
3825     * @hide
3826     */
3827    public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications(
3828            String packageName);
3829
3830    /**
3831     * Get the list of IntentFilter for a specific package.
3832     *
3833     * @param packageName the package name. This parameter is set to a non null value,
3834     *                    the list will contain all the IntentFilter for that package.
3835     *                    Otherwise, the list will be empty.
3836     *
3837     * @return a list of IntentFilter for a specific package.
3838     *
3839     * @hide
3840     */
3841    public abstract List<IntentFilter> getAllIntentFilters(String packageName);
3842
3843    /**
3844     * Get the default Browser package name for a specific user.
3845     *
3846     * @param userId The user id.
3847     *
3848     * @return the package name of the default Browser for the specified user. If the user id passed
3849     *         is -1 (all users) it will return a null value.
3850     *
3851     * @hide
3852     */
3853    public abstract String getDefaultBrowserPackageName(int userId);
3854
3855    /**
3856     * Set the default Browser package name for a specific user.
3857     *
3858     * @param packageName The package name of the default Browser.
3859     * @param userId The user id.
3860     *
3861     * @return true if the default Browser for the specified user has been set,
3862     *         otherwise return false. If the user id passed is -1 (all users) this call will not
3863     *         do anything and just return false.
3864     *
3865     * @hide
3866     */
3867    public abstract boolean setDefaultBrowserPackageName(String packageName, int userId);
3868
3869    /**
3870     * Change the installer associated with a given package.  There are limitations
3871     * on how the installer package can be changed; in particular:
3872     * <ul>
3873     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
3874     * is not signed with the same certificate as the calling application.
3875     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
3876     * has an installer package, and that installer package is not signed with
3877     * the same certificate as the calling application.
3878     * </ul>
3879     *
3880     * @param targetPackage The installed package whose installer will be changed.
3881     * @param installerPackageName The package name of the new installer.  May be
3882     * null to clear the association.
3883     */
3884    public abstract void setInstallerPackageName(String targetPackage,
3885            String installerPackageName);
3886
3887    /**
3888     * Attempts to delete a package.  Since this may take a little while, the result will
3889     * be posted back to the given observer.  A deletion will fail if the calling context
3890     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
3891     * named package cannot be found, or if the named package is a "system package".
3892     * (TODO: include pointer to documentation on "system packages")
3893     *
3894     * @param packageName The name of the package to delete
3895     * @param observer An observer callback to get notified when the package deletion is
3896     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
3897     * called when that happens.  observer may be null to indicate that no callback is desired.
3898     * @param flags - possible values: {@link #DELETE_KEEP_DATA},
3899     * {@link #DELETE_ALL_USERS}.
3900     *
3901     * @hide
3902     */
3903    // @SystemApi
3904    public abstract void deletePackage(
3905            String packageName, IPackageDeleteObserver observer, int flags);
3906
3907    /**
3908     * Retrieve the package name of the application that installed a package. This identifies
3909     * which market the package came from.
3910     *
3911     * @param packageName The name of the package to query
3912     */
3913    public abstract String getInstallerPackageName(String packageName);
3914
3915    /**
3916     * Attempts to clear the user data directory of an application.
3917     * Since this may take a little while, the result will
3918     * be posted back to the given observer.  A deletion will fail if the
3919     * named package cannot be found, or if the named package is a "system package".
3920     *
3921     * @param packageName The name of the package
3922     * @param observer An observer callback to get notified when the operation is finished
3923     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3924     * will be called when that happens.  observer may be null to indicate that
3925     * no callback is desired.
3926     *
3927     * @hide
3928     */
3929    public abstract void clearApplicationUserData(String packageName,
3930            IPackageDataObserver observer);
3931    /**
3932     * Attempts to delete the cache files associated with an application.
3933     * Since this may take a little while, the result will
3934     * be posted back to the given observer.  A deletion will fail if the calling context
3935     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
3936     * named package cannot be found, or if the named package is a "system package".
3937     *
3938     * @param packageName The name of the package to delete
3939     * @param observer An observer callback to get notified when the cache file deletion
3940     * is complete.
3941     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
3942     * will be called when that happens.  observer may be null to indicate that
3943     * no callback is desired.
3944     *
3945     * @hide
3946     */
3947    public abstract void deleteApplicationCacheFiles(String packageName,
3948            IPackageDataObserver observer);
3949
3950    /**
3951     * Free storage by deleting LRU sorted list of cache files across
3952     * all applications. If the currently available free storage
3953     * on the device is greater than or equal to the requested
3954     * free storage, no cache files are cleared. If the currently
3955     * available storage on the device is less than the requested
3956     * free storage, some or all of the cache files across
3957     * all applications are deleted (based on last accessed time)
3958     * to increase the free storage space on the device to
3959     * the requested value. There is no guarantee that clearing all
3960     * the cache files from all applications will clear up
3961     * enough storage to achieve the desired value.
3962     * @param freeStorageSize The number of bytes of storage to be
3963     * freed by the system. Say if freeStorageSize is XX,
3964     * and the current free storage is YY,
3965     * if XX is less than YY, just return. if not free XX-YY number
3966     * of bytes if possible.
3967     * @param observer call back used to notify when
3968     * the operation is completed
3969     *
3970     * @hide
3971     */
3972    // @SystemApi
3973    public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) {
3974        freeStorageAndNotify(null, freeStorageSize, observer);
3975    }
3976
3977    /** {@hide} */
3978    public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize,
3979            IPackageDataObserver observer);
3980
3981    /**
3982     * Free storage by deleting LRU sorted list of cache files across
3983     * all applications. If the currently available free storage
3984     * on the device is greater than or equal to the requested
3985     * free storage, no cache files are cleared. If the currently
3986     * available storage on the device is less than the requested
3987     * free storage, some or all of the cache files across
3988     * all applications are deleted (based on last accessed time)
3989     * to increase the free storage space on the device to
3990     * the requested value. There is no guarantee that clearing all
3991     * the cache files from all applications will clear up
3992     * enough storage to achieve the desired value.
3993     * @param freeStorageSize The number of bytes of storage to be
3994     * freed by the system. Say if freeStorageSize is XX,
3995     * and the current free storage is YY,
3996     * if XX is less than YY, just return. if not free XX-YY number
3997     * of bytes if possible.
3998     * @param pi IntentSender call back used to
3999     * notify when the operation is completed.May be null
4000     * to indicate that no call back is desired.
4001     *
4002     * @hide
4003     */
4004    public void freeStorage(long freeStorageSize, IntentSender pi) {
4005        freeStorage(null, freeStorageSize, pi);
4006    }
4007
4008    /** {@hide} */
4009    public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi);
4010
4011    /**
4012     * Retrieve the size information for a package.
4013     * Since this may take a little while, the result will
4014     * be posted back to the given observer.  The calling context
4015     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
4016     *
4017     * @param packageName The name of the package whose size information is to be retrieved
4018     * @param userHandle The user whose size information should be retrieved.
4019     * @param observer An observer callback to get notified when the operation
4020     * is complete.
4021     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
4022     * The observer's callback is invoked with a PackageStats object(containing the
4023     * code, data and cache sizes of the package) and a boolean value representing
4024     * the status of the operation. observer may be null to indicate that
4025     * no callback is desired.
4026     *
4027     * @hide
4028     */
4029    public abstract void getPackageSizeInfo(String packageName, int userHandle,
4030            IPackageStatsObserver observer);
4031
4032    /**
4033     * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but
4034     * returns the size for the calling user.
4035     *
4036     * @hide
4037     */
4038    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
4039        getPackageSizeInfo(packageName, UserHandle.myUserId(), observer);
4040    }
4041
4042    /**
4043     * @deprecated This function no longer does anything; it was an old
4044     * approach to managing preferred activities, which has been superseded
4045     * by (and conflicts with) the modern activity-based preferences.
4046     */
4047    @Deprecated
4048    public abstract void addPackageToPreferred(String packageName);
4049
4050    /**
4051     * @deprecated This function no longer does anything; it was an old
4052     * approach to managing preferred activities, which has been superseded
4053     * by (and conflicts with) the modern activity-based preferences.
4054     */
4055    @Deprecated
4056    public abstract void removePackageFromPreferred(String packageName);
4057
4058    /**
4059     * Retrieve the list of all currently configured preferred packages.  The
4060     * first package on the list is the most preferred, the last is the
4061     * least preferred.
4062     *
4063     * @param flags Additional option flags. Use any combination of
4064     * {@link #GET_ACTIVITIES},
4065     * {@link #GET_GIDS},
4066     * {@link #GET_CONFIGURATIONS},
4067     * {@link #GET_INSTRUMENTATION},
4068     * {@link #GET_PERMISSIONS},
4069     * {@link #GET_PROVIDERS},
4070     * {@link #GET_RECEIVERS},
4071     * {@link #GET_SERVICES},
4072     * {@link #GET_SIGNATURES}, to modify the data returned.
4073     *
4074     * @return Returns a list of PackageInfo objects describing each
4075     * preferred application, in order of preference.
4076     *
4077     * @see #GET_ACTIVITIES
4078     * @see #GET_GIDS
4079     * @see #GET_CONFIGURATIONS
4080     * @see #GET_INSTRUMENTATION
4081     * @see #GET_PERMISSIONS
4082     * @see #GET_PROVIDERS
4083     * @see #GET_RECEIVERS
4084     * @see #GET_SERVICES
4085     * @see #GET_SIGNATURES
4086     */
4087    public abstract List<PackageInfo> getPreferredPackages(int flags);
4088
4089    /**
4090     * @deprecated This is a protected API that should not have been available
4091     * to third party applications.  It is the platform's responsibility for
4092     * assigning preferred activities and this cannot be directly modified.
4093     *
4094     * Add a new preferred activity mapping to the system.  This will be used
4095     * to automatically select the given activity component when
4096     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4097     * multiple matching activities and also matches the given filter.
4098     *
4099     * @param filter The set of intents under which this activity will be
4100     * made preferred.
4101     * @param match The IntentFilter match category that this preference
4102     * applies to.
4103     * @param set The set of activities that the user was picking from when
4104     * this preference was made.
4105     * @param activity The component name of the activity that is to be
4106     * preferred.
4107     */
4108    @Deprecated
4109    public abstract void addPreferredActivity(IntentFilter filter, int match,
4110            ComponentName[] set, ComponentName activity);
4111
4112    /**
4113     * Same as {@link #addPreferredActivity(IntentFilter, int,
4114            ComponentName[], ComponentName)}, but with a specific userId to apply the preference
4115            to.
4116     * @hide
4117     */
4118    public void addPreferredActivity(IntentFilter filter, int match,
4119            ComponentName[] set, ComponentName activity, int userId) {
4120        throw new RuntimeException("Not implemented. Must override in a subclass.");
4121    }
4122
4123    /**
4124     * @deprecated This is a protected API that should not have been available
4125     * to third party applications.  It is the platform's responsibility for
4126     * assigning preferred activities and this cannot be directly modified.
4127     *
4128     * Replaces an existing preferred activity mapping to the system, and if that were not present
4129     * adds a new preferred activity.  This will be used
4130     * to automatically select the given activity component when
4131     * {@link Context#startActivity(Intent) Context.startActivity()} finds
4132     * multiple matching activities and also matches the given filter.
4133     *
4134     * @param filter The set of intents under which this activity will be
4135     * made preferred.
4136     * @param match The IntentFilter match category that this preference
4137     * applies to.
4138     * @param set The set of activities that the user was picking from when
4139     * this preference was made.
4140     * @param activity The component name of the activity that is to be
4141     * preferred.
4142     * @hide
4143     */
4144    @Deprecated
4145    public abstract void replacePreferredActivity(IntentFilter filter, int match,
4146            ComponentName[] set, ComponentName activity);
4147
4148    /**
4149     * @hide
4150     */
4151    @Deprecated
4152    public void replacePreferredActivityAsUser(IntentFilter filter, int match,
4153           ComponentName[] set, ComponentName activity, int userId) {
4154        throw new RuntimeException("Not implemented. Must override in a subclass.");
4155    }
4156
4157    /**
4158     * Remove all preferred activity mappings, previously added with
4159     * {@link #addPreferredActivity}, from the
4160     * system whose activities are implemented in the given package name.
4161     * An application can only clear its own package(s).
4162     *
4163     * @param packageName The name of the package whose preferred activity
4164     * mappings are to be removed.
4165     */
4166    public abstract void clearPackagePreferredActivities(String packageName);
4167
4168    /**
4169     * Retrieve all preferred activities, previously added with
4170     * {@link #addPreferredActivity}, that are
4171     * currently registered with the system.
4172     *
4173     * @param outFilters A required list in which to place the filters of all of the
4174     * preferred activities.
4175     * @param outActivities A required list in which to place the component names of
4176     * all of the preferred activities.
4177     * @param packageName An optional package in which you would like to limit
4178     * the list.  If null, all activities will be returned; if non-null, only
4179     * those activities in the given package are returned.
4180     *
4181     * @return Returns the total number of registered preferred activities
4182     * (the number of distinct IntentFilter records, not the number of unique
4183     * activity components) that were found.
4184     */
4185    public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters,
4186            @NonNull List<ComponentName> outActivities, String packageName);
4187
4188    /**
4189     * Ask for the set of available 'home' activities and the current explicit
4190     * default, if any.
4191     * @hide
4192     */
4193    public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities);
4194
4195    /**
4196     * Set the enabled setting for a package component (activity, receiver, service, provider).
4197     * This setting will override any enabled state which may have been set by the component in its
4198     * manifest.
4199     *
4200     * @param componentName The component to enable
4201     * @param newState The new enabled state for the component.  The legal values for this state
4202     *                 are:
4203     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4204     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4205     *                   and
4206     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4207     *                 The last one removes the setting, thereby restoring the component's state to
4208     *                 whatever was set in it's manifest (or enabled, by default).
4209     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4210     */
4211    public abstract void setComponentEnabledSetting(ComponentName componentName,
4212            int newState, int flags);
4213
4214
4215    /**
4216     * Return the enabled setting for a package component (activity,
4217     * receiver, service, provider).  This returns the last value set by
4218     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
4219     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4220     * the value originally specified in the manifest has not been modified.
4221     *
4222     * @param componentName The component to retrieve.
4223     * @return Returns the current enabled state for the component.  May
4224     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4225     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4226     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4227     * component's enabled state is based on the original information in
4228     * the manifest as found in {@link ComponentInfo}.
4229     */
4230    public abstract int getComponentEnabledSetting(ComponentName componentName);
4231
4232    /**
4233     * Set the enabled setting for an application
4234     * This setting will override any enabled state which may have been set by the application in
4235     * its manifest.  It also overrides the enabled state set in the manifest for any of the
4236     * application's components.  It does not override any enabled state set by
4237     * {@link #setComponentEnabledSetting} for any of the application's components.
4238     *
4239     * @param packageName The package name of the application to enable
4240     * @param newState The new enabled state for the component.  The legal values for this state
4241     *                 are:
4242     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
4243     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
4244     *                   and
4245     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
4246     *                 The last one removes the setting, thereby restoring the applications's state to
4247     *                 whatever was set in its manifest (or enabled, by default).
4248     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
4249     */
4250    public abstract void setApplicationEnabledSetting(String packageName,
4251            int newState, int flags);
4252
4253    /**
4254     * Return the enabled setting for an application. This returns
4255     * the last value set by
4256     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
4257     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
4258     * the value originally specified in the manifest has not been modified.
4259     *
4260     * @param packageName The package name of the application to retrieve.
4261     * @return Returns the current enabled state for the application.  May
4262     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
4263     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
4264     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
4265     * application's enabled state is based on the original information in
4266     * the manifest as found in {@link ComponentInfo}.
4267     * @throws IllegalArgumentException if the named package does not exist.
4268     */
4269    public abstract int getApplicationEnabledSetting(String packageName);
4270
4271    /**
4272     * Puts the package in a hidden state, which is almost like an uninstalled state,
4273     * making the package unavailable, but it doesn't remove the data or the actual
4274     * package file. Application can be unhidden by either resetting the hidden state
4275     * or by installing it, such as with {@link #installExistingPackage(String)}
4276     * @hide
4277     */
4278    public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
4279            UserHandle userHandle);
4280
4281    /**
4282     * Returns the hidden state of a package.
4283     * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle)
4284     * @hide
4285     */
4286    public abstract boolean getApplicationHiddenSettingAsUser(String packageName,
4287            UserHandle userHandle);
4288
4289    /**
4290     * Return whether the device has been booted into safe mode.
4291     */
4292    public abstract boolean isSafeMode();
4293
4294    /**
4295     * Return the {@link KeySet} associated with the String alias for this
4296     * application.
4297     *
4298     * @param alias The alias for a given {@link KeySet} as defined in the
4299     *        application's AndroidManifest.xml.
4300     * @hide
4301     */
4302    public abstract KeySet getKeySetByAlias(String packageName, String alias);
4303
4304    /** Return the signing {@link KeySet} for this application.
4305     * @hide
4306     */
4307    public abstract KeySet getSigningKeySet(String packageName);
4308
4309    /**
4310     * Return whether the package denoted by packageName has been signed by all
4311     * of the keys specified by the {@link KeySet} ks.  This will return true if
4312     * the package has been signed by additional keys (a superset) as well.
4313     * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}.
4314     * @hide
4315     */
4316    public abstract boolean isSignedBy(String packageName, KeySet ks);
4317
4318    /**
4319     * Return whether the package denoted by packageName has been signed by all
4320     * of, and only, the keys specified by the {@link KeySet} ks. Compare to
4321     * {@link #isSignedBy(String packageName, KeySet ks)}.
4322     * @hide
4323     */
4324    public abstract boolean isSignedByExactly(String packageName, KeySet ks);
4325
4326    /**
4327     * Attempts to move package resources from internal to external media or vice versa.
4328     * Since this may take a little while, the result will
4329     * be posted back to the given observer.   This call may fail if the calling context
4330     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
4331     * named package cannot be found, or if the named package is a "system package".
4332     *
4333     * @param packageName The name of the package to delete
4334     * @param observer An observer callback to get notified when the package move is
4335     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
4336     * called when that happens.  observer may be null to indicate that no callback is desired.
4337     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
4338     * {@link #MOVE_EXTERNAL_MEDIA}
4339     *
4340     * @hide
4341     */
4342    @Deprecated
4343    public void movePackage(String packageName, IPackageMoveObserver observer, int flags) {
4344        throw new UnsupportedOperationException();
4345    }
4346
4347    /** {@hide} */
4348    public static boolean isMoveStatusFinished(int status) {
4349        return (status < 0 || status > 100);
4350    }
4351
4352    /** {@hide} */
4353    public static abstract class MoveCallback {
4354        public void onCreated(int moveId, Bundle extras) {}
4355        public abstract void onStatusChanged(int moveId, int status, long estMillis);
4356    }
4357
4358    /** {@hide} */
4359    public abstract int getMoveStatus(int moveId);
4360
4361    /** {@hide} */
4362    public abstract void registerMoveCallback(MoveCallback callback, Handler handler);
4363    /** {@hide} */
4364    public abstract void unregisterMoveCallback(MoveCallback callback);
4365
4366    /** {@hide} */
4367    public abstract int movePackage(String packageName, VolumeInfo vol);
4368    /** {@hide} */
4369    public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app);
4370    /** {@hide} */
4371    public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app);
4372
4373    /** {@hide} */
4374    public abstract int movePrimaryStorage(VolumeInfo vol);
4375    /** {@hide} */
4376    public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume();
4377    /** {@hide} */
4378    public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes();
4379
4380    /**
4381     * Returns the device identity that verifiers can use to associate their scheme to a particular
4382     * device. This should not be used by anything other than a package verifier.
4383     *
4384     * @return identity that uniquely identifies current device
4385     * @hide
4386     */
4387    public abstract VerifierDeviceIdentity getVerifierDeviceIdentity();
4388
4389    /**
4390     * Returns true if the device is upgrading, such as first boot after OTA.
4391     *
4392     * @hide
4393     */
4394    public abstract boolean isUpgrade();
4395
4396    /**
4397     * Return interface that offers the ability to install, upgrade, and remove
4398     * applications on the device.
4399     */
4400    public abstract @NonNull PackageInstaller getPackageInstaller();
4401
4402    /**
4403     * Returns the data directory for a particular package and user.
4404     *
4405     * @hide
4406     */
4407    public static File getDataDirForUser(String volumeUuid, String packageName, int userId) {
4408        // TODO: This should be shared with Installer's knowledge of user directory
4409        final File base;
4410        if (TextUtils.isEmpty(volumeUuid)) {
4411            base = Environment.getDataDirectory();
4412        } else {
4413            base = new File("/mnt/expand/" + volumeUuid);
4414        }
4415        return new File(base, "user/" + userId + "/" + packageName);
4416    }
4417
4418    /**
4419     * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the
4420     * user with id sourceUserId can also be be resolved by activities in the user with id
4421     * targetUserId if they match the specified intent filter.
4422     * @param filter The {@link IntentFilter} the intent has to match
4423     * @param sourceUserId The source user id.
4424     * @param targetUserId The target user id.
4425     * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE}
4426     * @hide
4427     */
4428    public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId,
4429            int targetUserId, int flags);
4430
4431    /**
4432     * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their
4433     * source, and have been set by the app calling this method.
4434     * @param sourceUserId The source user id.
4435     * @hide
4436     */
4437    public abstract void clearCrossProfileIntentFilters(int sourceUserId);
4438
4439    /**
4440     * @hide
4441     */
4442    public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4443
4444    /**
4445     * @hide
4446     */
4447    public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo);
4448
4449    /** {@hide} */
4450    public abstract boolean isPackageAvailable(String packageName);
4451
4452    /** {@hide} */
4453    public static String installStatusToString(int status, String msg) {
4454        final String str = installStatusToString(status);
4455        if (msg != null) {
4456            return str + ": " + msg;
4457        } else {
4458            return str;
4459        }
4460    }
4461
4462    /** {@hide} */
4463    public static String installStatusToString(int status) {
4464        switch (status) {
4465            case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED";
4466            case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS";
4467            case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK";
4468            case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI";
4469            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE";
4470            case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE";
4471            case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER";
4472            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE";
4473            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE";
4474            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY";
4475            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE";
4476            case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT";
4477            case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK";
4478            case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER";
4479            case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK";
4480            case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY";
4481            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE";
4482            case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE";
4483            case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR";
4484            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION";
4485            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE";
4486            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT";
4487            case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE";
4488            case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED";
4489            case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED";
4490            case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE";
4491            case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK";
4492            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST";
4493            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION";
4494            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES";
4495            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES";
4496            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING";
4497            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME";
4498            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID";
4499            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED";
4500            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY";
4501            case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR";
4502            case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED";
4503            case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION";
4504            case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS";
4505            case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED";
4506            default: return Integer.toString(status);
4507        }
4508    }
4509
4510    /** {@hide} */
4511    public static int installStatusToPublicStatus(int status) {
4512        switch (status) {
4513            case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4514            case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4515            case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4516            case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID;
4517            case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4518            case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4519            case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4520            case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4521            case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4522            case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4523            case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4524            case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID;
4525            case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4526            case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4527            case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4528            case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID;
4529            case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4530            case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4531            case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE;
4532            case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE;
4533            case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE;
4534            case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED;
4535            case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED;
4536            case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4537            case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID;
4538            case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4539            case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID;
4540            case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID;
4541            case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID;
4542            case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID;
4543            case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4544            case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID;
4545            case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID;
4546            case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID;
4547            case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID;
4548            case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID;
4549            case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID;
4550            case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4551            case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4552            case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT;
4553            case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE;
4554            case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4555            default: return PackageInstaller.STATUS_FAILURE;
4556        }
4557    }
4558
4559    /** {@hide} */
4560    public static String deleteStatusToString(int status, String msg) {
4561        final String str = deleteStatusToString(status);
4562        if (msg != null) {
4563            return str + ": " + msg;
4564        } else {
4565            return str;
4566        }
4567    }
4568
4569    /** {@hide} */
4570    public static String deleteStatusToString(int status) {
4571        switch (status) {
4572            case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED";
4573            case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR";
4574            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER";
4575            case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED";
4576            case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED";
4577            case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED";
4578            default: return Integer.toString(status);
4579        }
4580    }
4581
4582    /** {@hide} */
4583    public static int deleteStatusToPublicStatus(int status) {
4584        switch (status) {
4585            case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS;
4586            case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE;
4587            case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4588            case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4589            case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED;
4590            case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED;
4591            default: return PackageInstaller.STATUS_FAILURE;
4592        }
4593    }
4594
4595    /** {@hide} */
4596    public static class LegacyPackageInstallObserver extends PackageInstallObserver {
4597        private final IPackageInstallObserver mLegacy;
4598
4599        public LegacyPackageInstallObserver(IPackageInstallObserver legacy) {
4600            mLegacy = legacy;
4601        }
4602
4603        @Override
4604        public void onPackageInstalled(String basePackageName, int returnCode, String msg,
4605                Bundle extras) {
4606            if (mLegacy == null) return;
4607            try {
4608                mLegacy.packageInstalled(basePackageName, returnCode);
4609            } catch (RemoteException ignored) {
4610            }
4611        }
4612    }
4613
4614    /** {@hide} */
4615    public static class LegacyPackageDeleteObserver extends PackageDeleteObserver {
4616        private final IPackageDeleteObserver mLegacy;
4617
4618        public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) {
4619            mLegacy = legacy;
4620        }
4621
4622        @Override
4623        public void onPackageDeleted(String basePackageName, int returnCode, String msg) {
4624            if (mLegacy == null) return;
4625            try {
4626                mLegacy.packageDeleted(basePackageName, returnCode);
4627            } catch (RemoteException ignored) {
4628            }
4629        }
4630    }
4631}
4632