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