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