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