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