PackageManager.java revision 711516d140390aeec9e3eefb8fdb2681c3454980
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.util.AndroidException;
31import android.util.DisplayMetrics;
32
33import java.io.File;
34import java.util.List;
35
36/**
37 * Class for retrieving various kinds of information related to the application
38 * packages that are currently installed on the device.
39 *
40 * You can find this class through {@link Context#getPackageManager}.
41 */
42public abstract class PackageManager {
43
44    /**
45     * This exception is thrown when a given package, application, or component
46     * name can not be found.
47     */
48    public static class NameNotFoundException extends AndroidException {
49        public NameNotFoundException() {
50        }
51
52        public NameNotFoundException(String name) {
53            super(name);
54        }
55    }
56
57    /**
58     * {@link PackageInfo} flag: return information about
59     * activities in the package in {@link PackageInfo#activities}.
60     */
61    public static final int GET_ACTIVITIES              = 0x00000001;
62
63    /**
64     * {@link PackageInfo} flag: return information about
65     * intent receivers in the package in
66     * {@link PackageInfo#receivers}.
67     */
68    public static final int GET_RECEIVERS               = 0x00000002;
69
70    /**
71     * {@link PackageInfo} flag: return information about
72     * services in the package in {@link PackageInfo#services}.
73     */
74    public static final int GET_SERVICES                = 0x00000004;
75
76    /**
77     * {@link PackageInfo} flag: return information about
78     * content providers in the package in
79     * {@link PackageInfo#providers}.
80     */
81    public static final int GET_PROVIDERS               = 0x00000008;
82
83    /**
84     * {@link PackageInfo} flag: return information about
85     * instrumentation in the package in
86     * {@link PackageInfo#instrumentation}.
87     */
88    public static final int GET_INSTRUMENTATION         = 0x00000010;
89
90    /**
91     * {@link PackageInfo} flag: return information about the
92     * intent filters supported by the activity.
93     */
94    public static final int GET_INTENT_FILTERS          = 0x00000020;
95
96    /**
97     * {@link PackageInfo} flag: return information about the
98     * signatures included in the package.
99     */
100    public static final int GET_SIGNATURES          = 0x00000040;
101
102    /**
103     * {@link ResolveInfo} flag: return the IntentFilter that
104     * was matched for a particular ResolveInfo in
105     * {@link ResolveInfo#filter}.
106     */
107    public static final int GET_RESOLVED_FILTER         = 0x00000040;
108
109    /**
110     * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
111     * data {@link android.os.Bundle}s that are associated with a component.
112     * This applies for any API returning a ComponentInfo subclass.
113     */
114    public static final int GET_META_DATA               = 0x00000080;
115
116    /**
117     * {@link PackageInfo} flag: return the
118     * {@link PackageInfo#gids group ids} that are associated with an
119     * application.
120     * This applies for any API returning an PackageInfo class, either
121     * directly or nested inside of another.
122     */
123    public static final int GET_GIDS                    = 0x00000100;
124
125    /**
126     * {@link PackageInfo} flag: include disabled components in the returned info.
127     */
128    public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
129
130    /**
131     * {@link ApplicationInfo} flag: return the
132     * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
133     * that are associated with an application.
134     * This applies for any API returning an ApplicationInfo class, either
135     * directly or nested inside of another.
136     */
137    public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
138
139    /**
140     * {@link ProviderInfo} flag: return the
141     * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
142     * that are associated with a content provider.
143     * This applies for any API returning an ProviderInfo class, either
144     * directly or nested inside of another.
145     */
146    public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
147    /**
148     * {@link PackageInfo} flag: return information about
149     * permissions in the package in
150     * {@link PackageInfo#permissions}.
151     */
152    public static final int GET_PERMISSIONS               = 0x00001000;
153
154    /**
155     * Flag parameter to retrieve all applications(even uninstalled ones) with data directories.
156     * This state could have resulted if applications have been deleted with flag
157     * DONT_DELETE_DATA
158     * with a possibility of being replaced or reinstalled in future
159     */
160    public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
161
162    /**
163     * {@link PackageInfo} flag: return information about
164     * hardware preferences in
165     * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
166     * requested features in {@link PackageInfo#reqFeatures
167     * PackageInfo.reqFeatures}.
168     */
169    public static final int GET_CONFIGURATIONS = 0x00004000;
170
171    /**
172     * Resolution and querying flag: if set, only filters that support the
173     * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
174     * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
175     * supplied Intent.
176     */
177    public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
178
179    /**
180     * Permission check result: this is returned by {@link #checkPermission}
181     * if the permission has been granted to the given package.
182     */
183    public static final int PERMISSION_GRANTED = 0;
184
185    /**
186     * Permission check result: this is returned by {@link #checkPermission}
187     * if the permission has not been granted to the given package.
188     */
189    public static final int PERMISSION_DENIED = -1;
190
191    /**
192     * Signature check result: this is returned by {@link #checkSignatures}
193     * if all signatures on the two packages match.
194     */
195    public static final int SIGNATURE_MATCH = 0;
196
197    /**
198     * Signature check result: this is returned by {@link #checkSignatures}
199     * if neither of the two packages is signed.
200     */
201    public static final int SIGNATURE_NEITHER_SIGNED = 1;
202
203    /**
204     * Signature check result: this is returned by {@link #checkSignatures}
205     * if the first package is not signed but the second is.
206     */
207    public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
208
209    /**
210     * Signature check result: this is returned by {@link #checkSignatures}
211     * if the second package is not signed but the first is.
212     */
213    public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
214
215    /**
216     * Signature check result: this is returned by {@link #checkSignatures}
217     * if not all signatures on both packages match.
218     */
219    public static final int SIGNATURE_NO_MATCH = -3;
220
221    /**
222     * Signature check result: this is returned by {@link #checkSignatures}
223     * if either of the packages are not valid.
224     */
225    public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
226
227    public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
228    public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
229    public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
230
231    /**
232     * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
233     * indicate that this package should be installed as forward locked, i.e. only the app itself
234     * should have access to its code and non-resource assets.
235     * @hide
236     */
237    public static final int INSTALL_FORWARD_LOCK = 0x00000001;
238
239    /**
240     * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
241     * installed package, if one exists.
242     * @hide
243     */
244    public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
245
246    /**
247     * Flag parameter for {@link #installPackage} to indicate that you want to
248     * allow test packages (those that have set android:testOnly in their
249     * manifest) to be installed.
250     * @hide
251     */
252    public static final int INSTALL_ALLOW_TEST = 0x00000004;
253
254    /**
255     * Flag parameter for {@link #installPackage} to indicate that this
256     * package has to be installed on the sdcard.
257     * @hide
258     */
259    public static final int INSTALL_EXTERNAL = 0x00000008;
260
261    /**
262    * Flag parameter for {@link #installPackage} to indicate that this
263    * package has to be installed on the sdcard.
264    * @hide
265    */
266   public static final int INSTALL_INTERNAL = 0x00000010;
267
268    /**
269     * Flag parameter for
270     * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
271     * that you don't want to kill the app containing the component.  Be careful when you set this
272     * since changing component states can make the containing application's behavior unpredictable.
273     */
274    public static final int DONT_KILL_APP = 0x00000001;
275
276    /**
277     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
278     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
279     * @hide
280     */
281    public static final int INSTALL_SUCCEEDED = 1;
282
283    /**
284     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
285     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
286     * already installed.
287     * @hide
288     */
289    public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
290
291    /**
292     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
293     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
294     * file is invalid.
295     * @hide
296     */
297    public static final int INSTALL_FAILED_INVALID_APK = -2;
298
299    /**
300     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
301     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
302     * is invalid.
303     * @hide
304     */
305    public static final int INSTALL_FAILED_INVALID_URI = -3;
306
307    /**
308     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
309     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
310     * service found that the device didn't have enough storage space to install the app.
311     * @hide
312     */
313    public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
314
315    /**
316     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
317     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
318     * package is already installed with the same name.
319     * @hide
320     */
321    public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
322
323    /**
324     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
325     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
326     * the requested shared user does not exist.
327     * @hide
328     */
329    public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
330
331    /**
332     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
333     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
334     * a previously installed package of the same name has a different signature
335     * than the new package (and the old package's data was not removed).
336     * @hide
337     */
338    public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
339
340    /**
341     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
342     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
343     * the new package is requested a shared user which is already installed on the
344     * device and does not have matching signature.
345     * @hide
346     */
347    public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
348
349    /**
350     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
351     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
352     * the new package uses a shared library that is not available.
353     * @hide
354     */
355    public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
356
357    /**
358     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
359     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
360     * the new package uses a shared library that is not available.
361     * @hide
362     */
363    public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
364
365    /**
366     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
367     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
368     * the new package failed while optimizing and validating its dex files,
369     * either because there was not enough storage or the validation failed.
370     * @hide
371     */
372    public static final int INSTALL_FAILED_DEXOPT = -11;
373
374    /**
375     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
376     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
377     * the new package failed because the current SDK version is older than
378     * that required by the package.
379     * @hide
380     */
381    public static final int INSTALL_FAILED_OLDER_SDK = -12;
382
383    /**
384     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
385     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
386     * the new package failed because it contains a content provider with the
387     * same authority as a provider already installed in the system.
388     * @hide
389     */
390    public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
391
392    /**
393     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
394     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
395     * the new package failed because the current SDK version is newer than
396     * that required by the package.
397     * @hide
398     */
399    public static final int INSTALL_FAILED_NEWER_SDK = -14;
400
401    /**
402     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
403     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
404     * the new package failed because it has specified that it is a test-only
405     * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
406     * flag.
407     * @hide
408     */
409    public static final int INSTALL_FAILED_TEST_ONLY = -15;
410
411    /**
412     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
413     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
414     * the package being installed contains native code, but none that is
415     * compatible with the the device's CPU_ABI.
416     * @hide
417     */
418    public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
419
420    /**
421     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
422     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
423     * the new package uses a feature that is not available.
424     * @hide
425     */
426    public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
427
428    // ------ Errors related to sdcard
429    /**
430     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
431     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
432     * a secure container mount point couldn't be accessed on external media.
433     * @hide
434     */
435    public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
436
437    /**
438     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
439     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
440     * the new package couldn't be installed in the specified install
441     * location.
442     * @hide
443     */
444    public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
445
446    /**
447     * Installation return code: this is passed to the {@link IPackageInstallObserver} by
448     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
449     * the new package couldn't be installed in the specified install
450     * location because the media is not available.
451     * @hide
452     */
453    public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
454
455    /**
456     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
457     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
458     * if the parser was given a path that is not a file, or does not end with the expected
459     * '.apk' extension.
460     * @hide
461     */
462    public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
463
464    /**
465     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
466     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
467     * if the parser was unable to retrieve the AndroidManifest.xml file.
468     * @hide
469     */
470    public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
471
472    /**
473     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
474     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
475     * if the parser encountered an unexpected exception.
476     * @hide
477     */
478    public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
479
480    /**
481     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
482     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
483     * if the parser did not find any certificates in the .apk.
484     * @hide
485     */
486    public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
487
488    /**
489     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
490     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
491     * if the parser found inconsistent certificates on the files in the .apk.
492     * @hide
493     */
494    public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
495
496    /**
497     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
498     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
499     * if the parser encountered a CertificateEncodingException in one of the
500     * files in the .apk.
501     * @hide
502     */
503    public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
504
505    /**
506     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
507     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
508     * if the parser encountered a bad or missing package name in the manifest.
509     * @hide
510     */
511    public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
512
513    /**
514     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
515     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
516     * if the parser encountered a bad shared user id name in the manifest.
517     * @hide
518     */
519    public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
520
521    /**
522     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
523     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
524     * if the parser encountered some structural problem in the manifest.
525     * @hide
526     */
527    public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
528
529    /**
530     * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
531     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
532     * if the parser did not find any actionable tags (instrumentation or application)
533     * in the manifest.
534     * @hide
535     */
536    public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
537
538    /**
539     * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
540     * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
541     * if the system failed to install the package because of system issues.
542     * @hide
543     */
544    public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
545
546    /**
547     * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
548     * package's data directory.
549     *
550     * @hide
551     */
552    public static final int DONT_DELETE_DATA = 0x00000001;
553
554    /**
555     * Return code for when package deletion succeeds. This is passed to the
556     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
557     * succeeded in deleting the package.
558     *
559     * @hide
560     */
561    public static final int DELETE_SUCCEEDED = 1;
562
563    /**
564     * Deletion failed return code: this is passed to the
565     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
566     * failed to delete the package for an unspecified reason.
567     *
568     * @hide
569     */
570    public static final int DELETE_FAILED_INTERNAL_ERROR = -1;
571
572    /**
573     * Deletion failed return code: this is passed to the
574     * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system
575     * failed to delete the package because it is the active DevicePolicy
576     * manager.
577     *
578     * @hide
579     */
580    public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2;
581
582    /**
583     * Return code that is passed to the {@link IPackageMoveObserver} by
584     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the
585     * package has been successfully moved by the system.
586     *
587     * @hide
588     */
589    public static final int MOVE_SUCCEEDED = 1;
590    /**
591     * Error code that is passed to the {@link IPackageMoveObserver} by
592     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
593     * when the package hasn't been successfully moved by the system
594     * because of insufficient memory on specified media.
595     * @hide
596     */
597    public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
598
599    /**
600     * Error code that is passed to the {@link IPackageMoveObserver} by
601     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
602     * if the specified package doesn't exist.
603     * @hide
604     */
605    public static final int MOVE_FAILED_DOESNT_EXIST = -2;
606
607    /**
608     * Error code that is passed to the {@link IPackageMoveObserver} by
609     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
610     * if the specified package cannot be moved since its a system package.
611     * @hide
612     */
613    public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
614
615    /**
616     * Error code that is passed to the {@link IPackageMoveObserver} by
617     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
618     * if the specified package cannot be moved since its forward locked.
619     * @hide
620     */
621    public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
622
623    /**
624     * Error code that is passed to the {@link IPackageMoveObserver} by
625     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
626     * if the specified package cannot be moved to the specified location.
627     * @hide
628     */
629    public static final int MOVE_FAILED_INVALID_LOCATION = -5;
630
631    /**
632     * Error code that is passed to the {@link IPackageMoveObserver} by
633     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
634     * if the specified package cannot be moved to the specified location.
635     * @hide
636     */
637    public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
638
639    /**
640     * Error code that is passed to the {@link IPackageMoveObserver} by
641     * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the
642     * specified package already has an operation pending in the
643     * {@link PackageHandler} queue.
644     *
645     * @hide
646     */
647    public static final int MOVE_FAILED_OPERATION_PENDING = -7;
648
649    /**
650     * Flag parameter for {@link #movePackage} to indicate that
651     * the package should be moved to internal storage if its
652     * been installed on external media.
653     * @hide
654     */
655    public static final int MOVE_INTERNAL = 0x00000001;
656
657    /**
658     * Flag parameter for {@link #movePackage} to indicate that
659     * the package should be moved to external media.
660     * @hide
661     */
662    public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
663
664    /**
665     * Range of IDs allocated for a user.
666     * @hide
667     */
668    public static final int PER_USER_RANGE = 100000;
669
670    /**
671     * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's
672     * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or
673     * lag in sound input or output.
674     */
675    @SdkConstant(SdkConstantType.FEATURE)
676    public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
677
678    /**
679     * Feature for {@link #getSystemAvailableFeatures} and
680     * {@link #hasSystemFeature}: The device is capable of communicating with
681     * other devices via Bluetooth.
682     */
683    @SdkConstant(SdkConstantType.FEATURE)
684    public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
685
686    /**
687     * Feature for {@link #getSystemAvailableFeatures} and
688     * {@link #hasSystemFeature}: The device has a camera facing away
689     * from the screen.
690     */
691    @SdkConstant(SdkConstantType.FEATURE)
692    public static final String FEATURE_CAMERA = "android.hardware.camera";
693
694    /**
695     * Feature for {@link #getSystemAvailableFeatures} and
696     * {@link #hasSystemFeature}: The device's camera supports auto-focus.
697     */
698    @SdkConstant(SdkConstantType.FEATURE)
699    public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
700
701    /**
702     * Feature for {@link #getSystemAvailableFeatures} and
703     * {@link #hasSystemFeature}: The device's camera supports flash.
704     */
705    @SdkConstant(SdkConstantType.FEATURE)
706    public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
707
708    /**
709     * Feature for {@link #getSystemAvailableFeatures} and
710     * {@link #hasSystemFeature}: The device has a front facing camera.
711     */
712    @SdkConstant(SdkConstantType.FEATURE)
713    public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front";
714
715    /**
716     * Feature for {@link #getSystemAvailableFeatures} and
717     * {@link #hasSystemFeature}: The device supports one or more methods of
718     * reporting current location.
719     */
720    @SdkConstant(SdkConstantType.FEATURE)
721    public static final String FEATURE_LOCATION = "android.hardware.location";
722
723    /**
724     * Feature for {@link #getSystemAvailableFeatures} and
725     * {@link #hasSystemFeature}: The device has a Global Positioning System
726     * receiver and can report precise location.
727     */
728    @SdkConstant(SdkConstantType.FEATURE)
729    public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
730
731    /**
732     * Feature for {@link #getSystemAvailableFeatures} and
733     * {@link #hasSystemFeature}: The device can report location with coarse
734     * accuracy using a network-based geolocation system.
735     */
736    @SdkConstant(SdkConstantType.FEATURE)
737    public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
738
739    /**
740     * Feature for {@link #getSystemAvailableFeatures} and
741     * {@link #hasSystemFeature}: The device can record audio via a
742     * microphone.
743     */
744    @SdkConstant(SdkConstantType.FEATURE)
745    public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
746
747    /**
748     * Feature for {@link #getSystemAvailableFeatures} and
749     * {@link #hasSystemFeature}: The device can communicate using Near-Field
750     * Communications (NFC).
751     */
752    @SdkConstant(SdkConstantType.FEATURE)
753    public static final String FEATURE_NFC = "android.hardware.nfc";
754
755    /**
756     * Feature for {@link #getSystemAvailableFeatures} and
757     * {@link #hasSystemFeature}: The device includes an accelerometer.
758     */
759    @SdkConstant(SdkConstantType.FEATURE)
760    public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
761
762    /**
763     * Feature for {@link #getSystemAvailableFeatures} and
764     * {@link #hasSystemFeature}: The device includes a barometer (air
765     * pressure sensor.)
766     */
767    @SdkConstant(SdkConstantType.FEATURE)
768    public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer";
769
770    /**
771     * Feature for {@link #getSystemAvailableFeatures} and
772     * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
773     */
774    @SdkConstant(SdkConstantType.FEATURE)
775    public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
776
777    /**
778     * Feature for {@link #getSystemAvailableFeatures} and
779     * {@link #hasSystemFeature}: The device includes a gyroscope.
780     */
781    @SdkConstant(SdkConstantType.FEATURE)
782    public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope";
783
784    /**
785     * Feature for {@link #getSystemAvailableFeatures} and
786     * {@link #hasSystemFeature}: The device includes a light sensor.
787     */
788    @SdkConstant(SdkConstantType.FEATURE)
789    public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
790
791    /**
792     * Feature for {@link #getSystemAvailableFeatures} and
793     * {@link #hasSystemFeature}: The device includes a proximity sensor.
794     */
795    @SdkConstant(SdkConstantType.FEATURE)
796    public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
797
798    /**
799     * Feature for {@link #getSystemAvailableFeatures} and
800     * {@link #hasSystemFeature}: The device has a telephony radio with data
801     * communication support.
802     */
803    @SdkConstant(SdkConstantType.FEATURE)
804    public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
805
806    /**
807     * Feature for {@link #getSystemAvailableFeatures} and
808     * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
809     */
810    @SdkConstant(SdkConstantType.FEATURE)
811    public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
812
813    /**
814     * Feature for {@link #getSystemAvailableFeatures} and
815     * {@link #hasSystemFeature}: The device has a GSM telephony stack.
816     */
817    @SdkConstant(SdkConstantType.FEATURE)
818    public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
819
820    /**
821     * Feature for {@link #getSystemAvailableFeatures} and
822     * {@link #hasSystemFeature}: The device supports connecting to USB devices
823     * as the USB host.
824     */
825    @SdkConstant(SdkConstantType.FEATURE)
826    public static final String FEATURE_USB_HOST = "android.hardware.usb.host";
827
828    /**
829     * Feature for {@link #getSystemAvailableFeatures} and
830     * {@link #hasSystemFeature}: The device supports connecting to USB accessories.
831     */
832    @SdkConstant(SdkConstantType.FEATURE)
833    public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory";
834
835    /**
836     * Feature for {@link #getSystemAvailableFeatures} and
837     * {@link #hasSystemFeature}: The SIP API is enabled on the device.
838     */
839    @SdkConstant(SdkConstantType.FEATURE)
840    public static final String FEATURE_SIP = "android.software.sip";
841
842    /**
843     * Feature for {@link #getSystemAvailableFeatures} and
844     * {@link #hasSystemFeature}: The device supports SIP-based VOIP.
845     */
846    @SdkConstant(SdkConstantType.FEATURE)
847    public static final String FEATURE_SIP_VOIP = "android.software.sip.voip";
848
849    /**
850     * Feature for {@link #getSystemAvailableFeatures} and
851     * {@link #hasSystemFeature}: The device's display has a touch screen.
852     */
853    @SdkConstant(SdkConstantType.FEATURE)
854    public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen";
855
856
857    /**
858     * Feature for {@link #getSystemAvailableFeatures} and
859     * {@link #hasSystemFeature}: The device's touch screen supports
860     * multitouch sufficient for basic two-finger gesture detection.
861     */
862    @SdkConstant(SdkConstantType.FEATURE)
863    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
864
865    /**
866     * Feature for {@link #getSystemAvailableFeatures} and
867     * {@link #hasSystemFeature}: The device's touch screen is capable of
868     * tracking two or more fingers fully independently.
869     */
870    @SdkConstant(SdkConstantType.FEATURE)
871    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
872
873    /**
874     * Feature for {@link #getSystemAvailableFeatures} and
875     * {@link #hasSystemFeature}: The device's touch screen is capable of
876     * tracking a full hand of fingers fully independently -- that is, 5 or
877     * more simultaneous independent pointers.
878     */
879    @SdkConstant(SdkConstantType.FEATURE)
880    public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand";
881
882    /**
883     * Feature for {@link #getSystemAvailableFeatures} and
884     * {@link #hasSystemFeature}: The device does not have a touch screen, but
885     * does support touch emulation for basic events. For instance, the
886     * device might use a mouse or remote control to drive a cursor, and
887     * emulate basic touch pointer events like down, up, drag, etc. All
888     * devices that support android.hardware.touchscreen or a sub-feature are
889     * presumed to also support faketouch.
890     */
891    @SdkConstant(SdkConstantType.FEATURE)
892    public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch";
893
894    /**
895     * Feature for {@link #getSystemAvailableFeatures} and
896     * {@link #hasSystemFeature}: The device does not have a touch screen, but
897     * does support touch emulation for basic events that supports distinct
898     * tracking of two or more fingers.  This is an extension of
899     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
900     * that unlike a distinct multitouch screen as defined by
901     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input
902     * devices will not actually provide full two-finger gestures since the
903     * input is being transformed to cursor movement on the screen.  That is,
904     * single finger gestures will move a cursor; two-finger swipes will
905     * result in single-finger touch events; other two-finger gestures will
906     * result in the corresponding two-finger touch event.
907     */
908    @SdkConstant(SdkConstantType.FEATURE)
909    public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct";
910
911    /**
912     * Feature for {@link #getSystemAvailableFeatures} and
913     * {@link #hasSystemFeature}: The device does not have a touch screen, but
914     * does support touch emulation for basic events that supports tracking
915     * a hand of fingers (5 or more fingers) fully independently.
916     * This is an extension of
917     * {@link #FEATURE_FAKETOUCH} for input devices with this capability.  Note
918     * that unlike a multitouch screen as defined by
919     * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger
920     * gestures can be detected due to the limitations described for
921     * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}.
922     */
923    @SdkConstant(SdkConstantType.FEATURE)
924    public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand";
925
926    /**
927     * Feature for {@link #getSystemAvailableFeatures} and
928     * {@link #hasSystemFeature}: The device supports portrait orientation
929     * screens.  For backwards compatibility, you can assume that if neither
930     * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports
931     * both portrait and landscape.
932     */
933    @SdkConstant(SdkConstantType.FEATURE)
934    public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait";
935
936    /**
937     * Feature for {@link #getSystemAvailableFeatures} and
938     * {@link #hasSystemFeature}: The device supports landscape orientation
939     * screens.  For backwards compatibility, you can assume that if neither
940     * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports
941     * both portrait and landscape.
942     */
943    @SdkConstant(SdkConstantType.FEATURE)
944    public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape";
945
946    /**
947     * Feature for {@link #getSystemAvailableFeatures} and
948     * {@link #hasSystemFeature}: The device supports live wallpapers.
949     */
950    @SdkConstant(SdkConstantType.FEATURE)
951    public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
952
953    /**
954     * Feature for {@link #getSystemAvailableFeatures} and
955     * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
956     */
957    @SdkConstant(SdkConstantType.FEATURE)
958    public static final String FEATURE_WIFI = "android.hardware.wifi";
959
960    /**
961     * Action to external storage service to clean out removed apps.
962     * @hide
963     */
964    public static final String ACTION_CLEAN_EXTERNAL_STORAGE
965            = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
966
967    /**
968     * Retrieve overall information about an application package that is
969     * installed on the system.
970     *
971     * <p>Throws {@link NameNotFoundException} if a package with the given
972     * name can not be found on the system.
973     *
974     * @param packageName The full name (i.e. com.google.apps.contacts) of the
975     *                    desired package.
976
977     * @param flags Additional option flags. Use any combination of
978     * {@link #GET_ACTIVITIES},
979     * {@link #GET_GIDS},
980     * {@link #GET_CONFIGURATIONS},
981     * {@link #GET_INSTRUMENTATION},
982     * {@link #GET_PERMISSIONS},
983     * {@link #GET_PROVIDERS},
984     * {@link #GET_RECEIVERS},
985     * {@link #GET_SERVICES},
986     * {@link #GET_SIGNATURES},
987     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
988     *
989     * @return Returns a PackageInfo object containing information about the package.
990     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
991     *         found in the list of installed applications, the package information is
992     *         retrieved from the list of uninstalled applications(which includes
993     *         installed applications as well as applications
994     *         with data directory ie applications which had been
995     *         deleted with DONT_DELTE_DATA flag set).
996     *
997     * @see #GET_ACTIVITIES
998     * @see #GET_GIDS
999     * @see #GET_CONFIGURATIONS
1000     * @see #GET_INSTRUMENTATION
1001     * @see #GET_PERMISSIONS
1002     * @see #GET_PROVIDERS
1003     * @see #GET_RECEIVERS
1004     * @see #GET_SERVICES
1005     * @see #GET_SIGNATURES
1006     * @see #GET_UNINSTALLED_PACKAGES
1007     *
1008     */
1009    public abstract PackageInfo getPackageInfo(String packageName, int flags)
1010            throws NameNotFoundException;
1011
1012    /**
1013     * Map from the current package names in use on the device to whatever
1014     * the current canonical name of that package is.
1015     * @param names Array of current names to be mapped.
1016     * @return Returns an array of the same size as the original, containing
1017     * the canonical name for each package.
1018     */
1019    public abstract String[] currentToCanonicalPackageNames(String[] names);
1020
1021    /**
1022     * Map from a packages canonical name to the current name in use on the device.
1023     * @param names Array of new names to be mapped.
1024     * @return Returns an array of the same size as the original, containing
1025     * the current name for each package.
1026     */
1027    public abstract String[] canonicalToCurrentPackageNames(String[] names);
1028
1029    /**
1030     * Return a "good" intent to launch a front-door activity in a package,
1031     * for use for example to implement an "open" button when browsing through
1032     * packages.  The current implementation will look first for a main
1033     * activity in the category {@link Intent#CATEGORY_INFO}, next for a
1034     * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
1035     * null if neither are found.
1036     *
1037     * <p>Throws {@link NameNotFoundException} if a package with the given
1038     * name can not be found on the system.
1039     *
1040     * @param packageName The name of the package to inspect.
1041     *
1042     * @return Returns either a fully-qualified Intent that can be used to
1043     * launch the main activity in the package, or null if the package does
1044     * not contain such an activity.
1045     */
1046    public abstract Intent getLaunchIntentForPackage(String packageName);
1047
1048    /**
1049     * Return an array of all of the secondary group-ids that have been
1050     * assigned to a package.
1051     *
1052     * <p>Throws {@link NameNotFoundException} if a package with the given
1053     * name can not be found on the system.
1054     *
1055     * @param packageName The full name (i.e. com.google.apps.contacts) of the
1056     *                    desired package.
1057     *
1058     * @return Returns an int array of the assigned gids, or null if there
1059     * are none.
1060     */
1061    public abstract int[] getPackageGids(String packageName)
1062            throws NameNotFoundException;
1063
1064    /**
1065     * Retrieve all of the information we know about a particular permission.
1066     *
1067     * <p>Throws {@link NameNotFoundException} if a permission with the given
1068     * name can not be found on the system.
1069     *
1070     * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
1071     *             of the permission you are interested in.
1072     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1073     * retrieve any meta-data associated with the permission.
1074     *
1075     * @return Returns a {@link PermissionInfo} containing information about the
1076     *         permission.
1077     */
1078    public abstract PermissionInfo getPermissionInfo(String name, int flags)
1079            throws NameNotFoundException;
1080
1081    /**
1082     * Query for all of the permissions associated with a particular group.
1083     *
1084     * <p>Throws {@link NameNotFoundException} if the given group does not
1085     * exist.
1086     *
1087     * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
1088     *             of the permission group you are interested in.  Use null to
1089     *             find all of the permissions not associated with a group.
1090     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1091     * retrieve any meta-data associated with the permissions.
1092     *
1093     * @return Returns a list of {@link PermissionInfo} containing information
1094     * about all of the permissions in the given group.
1095     */
1096    public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
1097            int flags) throws NameNotFoundException;
1098
1099    /**
1100     * Retrieve all of the information we know about a particular group of
1101     * permissions.
1102     *
1103     * <p>Throws {@link NameNotFoundException} if a permission group with the given
1104     * name can not be found on the system.
1105     *
1106     * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
1107     *             of the permission you are interested in.
1108     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1109     * retrieve any meta-data associated with the permission group.
1110     *
1111     * @return Returns a {@link PermissionGroupInfo} containing information
1112     * about the permission.
1113     */
1114    public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
1115            int flags) throws NameNotFoundException;
1116
1117    /**
1118     * Retrieve all of the known permission groups in the system.
1119     *
1120     * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
1121     * retrieve any meta-data associated with the permission group.
1122     *
1123     * @return Returns a list of {@link PermissionGroupInfo} containing
1124     * information about all of the known permission groups.
1125     */
1126    public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
1127
1128    /**
1129     * Retrieve all of the information we know about a particular
1130     * package/application.
1131     *
1132     * <p>Throws {@link NameNotFoundException} if an application with the given
1133     * package name can not be found on the system.
1134     *
1135     * @param packageName The full name (i.e. com.google.apps.contacts) of an
1136     *                    application.
1137     * @param flags Additional option flags. Use any combination of
1138     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1139     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1140     *
1141     * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
1142     *         information about the package.
1143     *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
1144     *         found in the list of installed applications,
1145     *         the application information is retrieved from the
1146     *         list of uninstalled applications(which includes
1147     *         installed applications as well as applications
1148     *         with data directory ie applications which had been
1149     *         deleted with DONT_DELTE_DATA flag set).
1150     *
1151     * @see #GET_META_DATA
1152     * @see #GET_SHARED_LIBRARY_FILES
1153     * @see #GET_UNINSTALLED_PACKAGES
1154     */
1155    public abstract ApplicationInfo getApplicationInfo(String packageName,
1156            int flags) throws NameNotFoundException;
1157
1158    /**
1159     * Retrieve all of the information we know about a particular activity
1160     * class.
1161     *
1162     * <p>Throws {@link NameNotFoundException} if an activity with the given
1163     * class name can not be found on the system.
1164     *
1165     * @param component The full component name (i.e.
1166     * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity
1167     * class.
1168     * @param flags Additional option flags. Use any combination of
1169     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1170     * to modify the data (in ApplicationInfo) returned.
1171     *
1172     * @return {@link ActivityInfo} containing information about the activity.
1173     *
1174     * @see #GET_INTENT_FILTERS
1175     * @see #GET_META_DATA
1176     * @see #GET_SHARED_LIBRARY_FILES
1177     */
1178    public abstract ActivityInfo getActivityInfo(ComponentName component,
1179            int flags) throws NameNotFoundException;
1180
1181    /**
1182     * Retrieve all of the information we know about a particular receiver
1183     * class.
1184     *
1185     * <p>Throws {@link NameNotFoundException} if a receiver with the given
1186     * class name can not be found on the system.
1187     *
1188     * @param component The full component name (i.e.
1189     * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver
1190     * class.
1191     * @param flags Additional option flags.  Use any combination of
1192     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1193     * to modify the data returned.
1194     *
1195     * @return {@link ActivityInfo} containing information about the receiver.
1196     *
1197     * @see #GET_INTENT_FILTERS
1198     * @see #GET_META_DATA
1199     * @see #GET_SHARED_LIBRARY_FILES
1200     */
1201    public abstract ActivityInfo getReceiverInfo(ComponentName component,
1202            int flags) throws NameNotFoundException;
1203
1204    /**
1205     * Retrieve all of the information we know about a particular service
1206     * class.
1207     *
1208     * <p>Throws {@link NameNotFoundException} if a service with the given
1209     * class name can not be found on the system.
1210     *
1211     * @param component The full component name (i.e.
1212     * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service
1213     * class.
1214     * @param flags Additional option flags.  Use any combination of
1215     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1216     * to modify the data returned.
1217     *
1218     * @return ServiceInfo containing information about the service.
1219     *
1220     * @see #GET_META_DATA
1221     * @see #GET_SHARED_LIBRARY_FILES
1222     */
1223    public abstract ServiceInfo getServiceInfo(ComponentName component,
1224            int flags) throws NameNotFoundException;
1225
1226    /**
1227     * Retrieve all of the information we know about a particular content
1228     * provider class.
1229     *
1230     * <p>Throws {@link NameNotFoundException} if a provider with the given
1231     * class name can not be found on the system.
1232     *
1233     * @param component The full component name (i.e.
1234     * com.google.providers.media/com.google.providers.media.MediaProvider) of a
1235     * ContentProvider class.
1236     * @param flags Additional option flags.  Use any combination of
1237     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1238     * to modify the data returned.
1239     *
1240     * @return ProviderInfo containing information about the service.
1241     *
1242     * @see #GET_META_DATA
1243     * @see #GET_SHARED_LIBRARY_FILES
1244     */
1245    public abstract ProviderInfo getProviderInfo(ComponentName component,
1246            int flags) throws NameNotFoundException;
1247
1248    /**
1249     * Return a List of all packages that are installed
1250     * on the device.
1251     *
1252     * @param flags Additional option flags. Use any combination of
1253     * {@link #GET_ACTIVITIES},
1254     * {@link #GET_GIDS},
1255     * {@link #GET_CONFIGURATIONS},
1256     * {@link #GET_INSTRUMENTATION},
1257     * {@link #GET_PERMISSIONS},
1258     * {@link #GET_PROVIDERS},
1259     * {@link #GET_RECEIVERS},
1260     * {@link #GET_SERVICES},
1261     * {@link #GET_SIGNATURES},
1262     * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1263     *
1264     * @return A List of PackageInfo objects, one for each package that is
1265     *         installed on the device.  In the unlikely case of there being no
1266     *         installed packages, an empty list is returned.
1267     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1268     *         applications including those deleted with DONT_DELETE_DATA
1269     *         (partially installed apps with data directory) will be returned.
1270     *
1271     * @see #GET_ACTIVITIES
1272     * @see #GET_GIDS
1273     * @see #GET_CONFIGURATIONS
1274     * @see #GET_INSTRUMENTATION
1275     * @see #GET_PERMISSIONS
1276     * @see #GET_PROVIDERS
1277     * @see #GET_RECEIVERS
1278     * @see #GET_SERVICES
1279     * @see #GET_SIGNATURES
1280     * @see #GET_UNINSTALLED_PACKAGES
1281     *
1282     */
1283    public abstract List<PackageInfo> getInstalledPackages(int flags);
1284
1285    /**
1286     * Check whether a particular package has been granted a particular
1287     * permission.
1288     *
1289     * @param permName The name of the permission you are checking for,
1290     * @param pkgName The name of the package you are checking against.
1291     *
1292     * @return If the package has the permission, PERMISSION_GRANTED is
1293     * returned.  If it does not have the permission, PERMISSION_DENIED
1294     * is returned.
1295     *
1296     * @see #PERMISSION_GRANTED
1297     * @see #PERMISSION_DENIED
1298     */
1299    public abstract int checkPermission(String permName, String pkgName);
1300
1301    /**
1302     * Add a new dynamic permission to the system.  For this to work, your
1303     * package must have defined a permission tree through the
1304     * {@link android.R.styleable#AndroidManifestPermissionTree
1305     * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
1306     * permissions to trees that were defined by either its own package or
1307     * another with the same user id; a permission is in a tree if it
1308     * matches the name of the permission tree + ".": for example,
1309     * "com.foo.bar" is a member of the permission tree "com.foo".
1310     *
1311     * <p>It is good to make your permission tree name descriptive, because you
1312     * are taking possession of that entire set of permission names.  Thus, it
1313     * must be under a domain you control, with a suffix that will not match
1314     * any normal permissions that may be declared in any applications that
1315     * are part of that domain.
1316     *
1317     * <p>New permissions must be added before
1318     * any .apks are installed that use those permissions.  Permissions you
1319     * add through this method are remembered across reboots of the device.
1320     * If the given permission already exists, the info you supply here
1321     * will be used to update it.
1322     *
1323     * @param info Description of the permission to be added.
1324     *
1325     * @return Returns true if a new permission was created, false if an
1326     * existing one was updated.
1327     *
1328     * @throws SecurityException if you are not allowed to add the
1329     * given permission name.
1330     *
1331     * @see #removePermission(String)
1332     */
1333    public abstract boolean addPermission(PermissionInfo info);
1334
1335    /**
1336     * Like {@link #addPermission(PermissionInfo)} but asynchronously
1337     * persists the package manager state after returning from the call,
1338     * allowing it to return quicker and batch a series of adds at the
1339     * expense of no guarantee the added permission will be retained if
1340     * the device is rebooted before it is written.
1341     */
1342    public abstract boolean addPermissionAsync(PermissionInfo info);
1343
1344    /**
1345     * Removes a permission that was previously added with
1346     * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
1347     * -- you are only allowed to remove permissions that you are allowed
1348     * to add.
1349     *
1350     * @param name The name of the permission to remove.
1351     *
1352     * @throws SecurityException if you are not allowed to remove the
1353     * given permission name.
1354     *
1355     * @see #addPermission(PermissionInfo)
1356     */
1357    public abstract void removePermission(String name);
1358
1359    /**
1360     * Compare the signatures of two packages to determine if the same
1361     * signature appears in both of them.  If they do contain the same
1362     * signature, then they are allowed special privileges when working
1363     * with each other: they can share the same user-id, run instrumentation
1364     * against each other, etc.
1365     *
1366     * @param pkg1 First package name whose signature will be compared.
1367     * @param pkg2 Second package name whose signature will be compared.
1368     *
1369     * @return Returns an integer indicating whether all signatures on the
1370     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1371     * all signatures match or < 0 if there is not a match ({@link
1372     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1373     *
1374     * @see #checkSignatures(int, int)
1375     * @see #SIGNATURE_MATCH
1376     * @see #SIGNATURE_NO_MATCH
1377     * @see #SIGNATURE_UNKNOWN_PACKAGE
1378     */
1379    public abstract int checkSignatures(String pkg1, String pkg2);
1380
1381    /**
1382     * Like {@link #checkSignatures(String, String)}, but takes UIDs of
1383     * the two packages to be checked.  This can be useful, for example,
1384     * when doing the check in an IPC, where the UID is the only identity
1385     * available.  It is functionally identical to determining the package
1386     * associated with the UIDs and checking their signatures.
1387     *
1388     * @param uid1 First UID whose signature will be compared.
1389     * @param uid2 Second UID whose signature will be compared.
1390     *
1391     * @return Returns an integer indicating whether all signatures on the
1392     * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if
1393     * all signatures match or < 0 if there is not a match ({@link
1394     * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}).
1395     *
1396     * @see #checkSignatures(String, String)
1397     * @see #SIGNATURE_MATCH
1398     * @see #SIGNATURE_NO_MATCH
1399     * @see #SIGNATURE_UNKNOWN_PACKAGE
1400     */
1401    public abstract int checkSignatures(int uid1, int uid2);
1402
1403    /**
1404     * Retrieve the names of all packages that are associated with a particular
1405     * user id.  In most cases, this will be a single package name, the package
1406     * that has been assigned that user id.  Where there are multiple packages
1407     * sharing the same user id through the "sharedUserId" mechanism, all
1408     * packages with that id will be returned.
1409     *
1410     * @param uid The user id for which you would like to retrieve the
1411     * associated packages.
1412     *
1413     * @return Returns an array of one or more packages assigned to the user
1414     * id, or null if there are no known packages with the given id.
1415     */
1416    public abstract String[] getPackagesForUid(int uid);
1417
1418    /**
1419     * Retrieve the official name associated with a user id.  This name is
1420     * guaranteed to never change, though it is possibly for the underlying
1421     * user id to be changed.  That is, if you are storing information about
1422     * user ids in persistent storage, you should use the string returned
1423     * by this function instead of the raw user-id.
1424     *
1425     * @param uid The user id for which you would like to retrieve a name.
1426     * @return Returns a unique name for the given user id, or null if the
1427     * user id is not currently assigned.
1428     */
1429    public abstract String getNameForUid(int uid);
1430
1431    /**
1432     * Return the user id associated with a shared user name. Multiple
1433     * applications can specify a shared user name in their manifest and thus
1434     * end up using a common uid. This might be used for new applications
1435     * that use an existing shared user name and need to know the uid of the
1436     * shared user.
1437     *
1438     * @param sharedUserName The shared user name whose uid is to be retrieved.
1439     * @return Returns the uid associated with the shared user, or  NameNotFoundException
1440     * if the shared user name is not being used by any installed packages
1441     * @hide
1442     */
1443    public abstract int getUidForSharedUser(String sharedUserName)
1444            throws NameNotFoundException;
1445
1446    /**
1447     * Return a List of all application packages that are installed on the
1448     * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
1449     * applications including those deleted with DONT_DELETE_DATA(partially
1450     * installed apps with data directory) will be returned.
1451     *
1452     * @param flags Additional option flags. Use any combination of
1453     * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1454     * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1455     *
1456     * @return A List of ApplicationInfo objects, one for each application that
1457     *         is installed on the device.  In the unlikely case of there being
1458     *         no installed applications, an empty list is returned.
1459     *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1460     *         applications including those deleted with DONT_DELETE_DATA
1461     *         (partially installed apps with data directory) will be returned.
1462     *
1463     * @see #GET_META_DATA
1464     * @see #GET_SHARED_LIBRARY_FILES
1465     * @see #GET_UNINSTALLED_PACKAGES
1466     */
1467    public abstract List<ApplicationInfo> getInstalledApplications(int flags);
1468
1469    /**
1470     * Get a list of shared libraries that are available on the
1471     * system.
1472     *
1473     * @return An array of shared library names that are
1474     * available on the system, or null if none are installed.
1475     *
1476     */
1477    public abstract String[] getSystemSharedLibraryNames();
1478
1479    /**
1480     * Get a list of features that are available on the
1481     * system.
1482     *
1483     * @return An array of FeatureInfo classes describing the features
1484     * that are available on the system, or null if there are none(!!).
1485     */
1486    public abstract FeatureInfo[] getSystemAvailableFeatures();
1487
1488    /**
1489     * Check whether the given feature name is one of the available
1490     * features as returned by {@link #getSystemAvailableFeatures()}.
1491     *
1492     * @return Returns true if the devices supports the feature, else
1493     * false.
1494     */
1495    public abstract boolean hasSystemFeature(String name);
1496
1497    /**
1498     * Determine the best action to perform for a given Intent.  This is how
1499     * {@link Intent#resolveActivity} finds an activity if a class has not
1500     * been explicitly specified.
1501     *
1502     * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName
1503     * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY}
1504     * only flag.  You need to do so to resolve the activity in the same way
1505     * that {@link android.content.Context#startActivity(Intent)} and
1506     * {@link android.content.Intent#resolveActivity(PackageManager)
1507     * Intent.resolveActivity(PackageManager)} do.</p>
1508     *
1509     * @param intent An intent containing all of the desired specification
1510     *               (action, data, type, category, and/or component).
1511     * @param flags Additional option flags.  The most important is
1512     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1513     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1514     *
1515     * @return Returns a ResolveInfo containing the final activity intent that
1516     *         was determined to be the best action.  Returns null if no
1517     *         matching activity was found. If multiple matching activities are
1518     *         found and there is no default set, returns a ResolveInfo
1519     *         containing something else, such as the activity resolver.
1520     *
1521     * @see #MATCH_DEFAULT_ONLY
1522     * @see #GET_INTENT_FILTERS
1523     * @see #GET_RESOLVED_FILTER
1524     */
1525    public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1526
1527    /**
1528     * Retrieve all activities that can be performed for the given intent.
1529     *
1530     * @param intent The desired intent as per resolveActivity().
1531     * @param flags Additional option flags.  The most important is
1532     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1533     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1534     *
1535     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1536     *         Activity. These are ordered from best to worst match -- that
1537     *         is, the first item in the list is what is returned by
1538     *         {@link #resolveActivity}.  If there are no matching activities, an empty
1539     *         list is returned.
1540     *
1541     * @see #MATCH_DEFAULT_ONLY
1542     * @see #GET_INTENT_FILTERS
1543     * @see #GET_RESOLVED_FILTER
1544     */
1545    public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
1546            int flags);
1547
1548    /**
1549     * Retrieve a set of activities that should be presented to the user as
1550     * similar options.  This is like {@link #queryIntentActivities}, except it
1551     * also allows you to supply a list of more explicit Intents that you would
1552     * like to resolve to particular options, and takes care of returning the
1553     * final ResolveInfo list in a reasonable order, with no duplicates, based
1554     * on those inputs.
1555     *
1556     * @param caller The class name of the activity that is making the
1557     *               request.  This activity will never appear in the output
1558     *               list.  Can be null.
1559     * @param specifics An array of Intents that should be resolved to the
1560     *                  first specific results.  Can be null.
1561     * @param intent The desired intent as per resolveActivity().
1562     * @param flags Additional option flags.  The most important is
1563     * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
1564     * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
1565     *
1566     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1567     *         Activity. These are ordered first by all of the intents resolved
1568     *         in <var>specifics</var> and then any additional activities that
1569     *         can handle <var>intent</var> but did not get included by one of
1570     *         the <var>specifics</var> intents.  If there are no matching
1571     *         activities, an empty list is returned.
1572     *
1573     * @see #MATCH_DEFAULT_ONLY
1574     * @see #GET_INTENT_FILTERS
1575     * @see #GET_RESOLVED_FILTER
1576     */
1577    public abstract List<ResolveInfo> queryIntentActivityOptions(
1578            ComponentName caller, Intent[] specifics, Intent intent, int flags);
1579
1580    /**
1581     * Retrieve all receivers that can handle a broadcast of the given intent.
1582     *
1583     * @param intent The desired intent as per resolveActivity().
1584     * @param flags Additional option flags.
1585     *
1586     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1587     *         Receiver. These are ordered from first to last in priority.  If
1588     *         there are no matching receivers, an empty list is returned.
1589     *
1590     * @see #MATCH_DEFAULT_ONLY
1591     * @see #GET_INTENT_FILTERS
1592     * @see #GET_RESOLVED_FILTER
1593     */
1594    public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
1595            int flags);
1596
1597    /**
1598     * Determine the best service to handle for a given Intent.
1599     *
1600     * @param intent An intent containing all of the desired specification
1601     *               (action, data, type, category, and/or component).
1602     * @param flags Additional option flags.
1603     *
1604     * @return Returns a ResolveInfo containing the final service intent that
1605     *         was determined to be the best action.  Returns null if no
1606     *         matching service was found.
1607     *
1608     * @see #GET_INTENT_FILTERS
1609     * @see #GET_RESOLVED_FILTER
1610     */
1611    public abstract ResolveInfo resolveService(Intent intent, int flags);
1612
1613    /**
1614     * Retrieve all services that can match the given intent.
1615     *
1616     * @param intent The desired intent as per resolveService().
1617     * @param flags Additional option flags.
1618     *
1619     * @return A List&lt;ResolveInfo&gt; containing one entry for each matching
1620     *         ServiceInfo. These are ordered from best to worst match -- that
1621     *         is, the first item in the list is what is returned by
1622     *         resolveService().  If there are no matching services, an empty
1623     *         list is returned.
1624     *
1625     * @see #GET_INTENT_FILTERS
1626     * @see #GET_RESOLVED_FILTER
1627     */
1628    public abstract List<ResolveInfo> queryIntentServices(Intent intent,
1629            int flags);
1630
1631    /**
1632     * Find a single content provider by its base path name.
1633     *
1634     * @param name The name of the provider to find.
1635     * @param flags Additional option flags.  Currently should always be 0.
1636     *
1637     * @return ContentProviderInfo Information about the provider, if found,
1638     *         else null.
1639     */
1640    public abstract ProviderInfo resolveContentProvider(String name,
1641            int flags);
1642
1643    /**
1644     * Retrieve content provider information.
1645     *
1646     * <p><em>Note: unlike most other methods, an empty result set is indicated
1647     * by a null return instead of an empty list.</em>
1648     *
1649     * @param processName If non-null, limits the returned providers to only
1650     *                    those that are hosted by the given process.  If null,
1651     *                    all content providers are returned.
1652     * @param uid If <var>processName</var> is non-null, this is the required
1653     *        uid owning the requested content providers.
1654     * @param flags Additional option flags.  Currently should always be 0.
1655     *
1656     * @return A List&lt;ContentProviderInfo&gt; containing one entry for each
1657     *         content provider either patching <var>processName</var> or, if
1658     *         <var>processName</var> is null, all known content providers.
1659     *         <em>If there are no matching providers, null is returned.</em>
1660     */
1661    public abstract List<ProviderInfo> queryContentProviders(
1662            String processName, int uid, int flags);
1663
1664    /**
1665     * Retrieve all of the information we know about a particular
1666     * instrumentation class.
1667     *
1668     * <p>Throws {@link NameNotFoundException} if instrumentation with the
1669     * given class name can not be found on the system.
1670     *
1671     * @param className The full name (i.e.
1672     *                  com.google.apps.contacts.InstrumentList) of an
1673     *                  Instrumentation class.
1674     * @param flags Additional option flags.  Currently should always be 0.
1675     *
1676     * @return InstrumentationInfo containing information about the
1677     *         instrumentation.
1678     */
1679    public abstract InstrumentationInfo getInstrumentationInfo(
1680            ComponentName className, int flags) throws NameNotFoundException;
1681
1682    /**
1683     * Retrieve information about available instrumentation code.  May be used
1684     * to retrieve either all instrumentation code, or only the code targeting
1685     * a particular package.
1686     *
1687     * @param targetPackage If null, all instrumentation is returned; only the
1688     *                      instrumentation targeting this package name is
1689     *                      returned.
1690     * @param flags Additional option flags.  Currently should always be 0.
1691     *
1692     * @return A List&lt;InstrumentationInfo&gt; containing one entry for each
1693     *         matching available Instrumentation.  Returns an empty list if
1694     *         there is no instrumentation available for the given package.
1695     */
1696    public abstract List<InstrumentationInfo> queryInstrumentation(
1697            String targetPackage, int flags);
1698
1699    /**
1700     * Retrieve an image from a package.  This is a low-level API used by
1701     * the various package manager info structures (such as
1702     * {@link ComponentInfo} to implement retrieval of their associated
1703     * icon.
1704     *
1705     * @param packageName The name of the package that this icon is coming from.
1706     * Can not be null.
1707     * @param resid The resource identifier of the desired image.  Can not be 0.
1708     * @param appInfo Overall information about <var>packageName</var>.  This
1709     * may be null, in which case the application information will be retrieved
1710     * for you if needed; if you already have this information around, it can
1711     * be much more efficient to supply it here.
1712     *
1713     * @return Returns a Drawable holding the requested image.  Returns null if
1714     * an image could not be found for any reason.
1715     */
1716    public abstract Drawable getDrawable(String packageName, int resid,
1717            ApplicationInfo appInfo);
1718
1719    /**
1720     * Retrieve the icon associated with an activity.  Given the full name of
1721     * an activity, retrieves the information about it and calls
1722     * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
1723     * If the activity can not be found, NameNotFoundException is thrown.
1724     *
1725     * @param activityName Name of the activity whose icon is to be retrieved.
1726     *
1727     * @return Returns the image of the icon, or the default activity icon if
1728     * it could not be found.  Does not return null.
1729     * @throws NameNotFoundException Thrown if the resources for the given
1730     * activity could not be loaded.
1731     *
1732     * @see #getActivityIcon(Intent)
1733     */
1734    public abstract Drawable getActivityIcon(ComponentName activityName)
1735            throws NameNotFoundException;
1736
1737    /**
1738     * Retrieve the icon associated with an Intent.  If intent.getClassName() is
1739     * set, this simply returns the result of
1740     * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
1741     * component and returns the icon associated with the resolved component.
1742     * If intent.getClassName() can not be found or the Intent can not be resolved
1743     * to a component, NameNotFoundException is thrown.
1744     *
1745     * @param intent The intent for which you would like to retrieve an icon.
1746     *
1747     * @return Returns the image of the icon, or the default activity icon if
1748     * it could not be found.  Does not return null.
1749     * @throws NameNotFoundException Thrown if the resources for application
1750     * matching the given intent could not be loaded.
1751     *
1752     * @see #getActivityIcon(ComponentName)
1753     */
1754    public abstract Drawable getActivityIcon(Intent intent)
1755            throws NameNotFoundException;
1756
1757    /**
1758     * Return the generic icon for an activity that is used when no specific
1759     * icon is defined.
1760     *
1761     * @return Drawable Image of the icon.
1762     */
1763    public abstract Drawable getDefaultActivityIcon();
1764
1765    /**
1766     * Retrieve the icon associated with an application.  If it has not defined
1767     * an icon, the default app icon is returned.  Does not return null.
1768     *
1769     * @param info Information about application being queried.
1770     *
1771     * @return Returns the image of the icon, or the default application icon
1772     * if it could not be found.
1773     *
1774     * @see #getApplicationIcon(String)
1775     */
1776    public abstract Drawable getApplicationIcon(ApplicationInfo info);
1777
1778    /**
1779     * Retrieve the icon associated with an application.  Given the name of the
1780     * application's package, retrieves the information about it and calls
1781     * getApplicationIcon() to return its icon. If the application can not be
1782     * found, NameNotFoundException is thrown.
1783     *
1784     * @param packageName Name of the package whose application icon is to be
1785     *                    retrieved.
1786     *
1787     * @return Returns the image of the icon, or the default application icon
1788     * if it could not be found.  Does not return null.
1789     * @throws NameNotFoundException Thrown if the resources for the given
1790     * application could not be loaded.
1791     *
1792     * @see #getApplicationIcon(ApplicationInfo)
1793     */
1794    public abstract Drawable getApplicationIcon(String packageName)
1795            throws NameNotFoundException;
1796
1797    /**
1798     * Retrieve the logo associated with an activity.  Given the full name of
1799     * an activity, retrieves the information about it and calls
1800     * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo.
1801     * If the activity can not be found, NameNotFoundException is thrown.
1802     *
1803     * @param activityName Name of the activity whose logo is to be retrieved.
1804     *
1805     * @return Returns the image of the logo or null if the activity has no
1806     * logo specified.
1807     *
1808     * @throws NameNotFoundException Thrown if the resources for the given
1809     * activity could not be loaded.
1810     *
1811     * @see #getActivityLogo(Intent)
1812     */
1813    public abstract Drawable getActivityLogo(ComponentName activityName)
1814            throws NameNotFoundException;
1815
1816    /**
1817     * Retrieve the logo associated with an Intent.  If intent.getClassName() is
1818     * set, this simply returns the result of
1819     * getActivityLogo(intent.getClassName()).  Otherwise it resolves the intent's
1820     * component and returns the logo associated with the resolved component.
1821     * If intent.getClassName() can not be found or the Intent can not be resolved
1822     * to a component, NameNotFoundException is thrown.
1823     *
1824     * @param intent The intent for which you would like to retrieve a logo.
1825     *
1826     * @return Returns the image of the logo, or null if the activity has no
1827     * logo specified.
1828     *
1829     * @throws NameNotFoundException Thrown if the resources for application
1830     * matching the given intent could not be loaded.
1831     *
1832     * @see #getActivityLogo(ComponentName)
1833     */
1834    public abstract Drawable getActivityLogo(Intent intent)
1835            throws NameNotFoundException;
1836
1837    /**
1838     * Retrieve the logo associated with an application.  If it has not specified
1839     * a logo, this method returns null.
1840     *
1841     * @param info Information about application being queried.
1842     *
1843     * @return Returns the image of the logo, or null if no logo is specified
1844     * by the application.
1845     *
1846     * @see #getApplicationLogo(String)
1847     */
1848    public abstract Drawable getApplicationLogo(ApplicationInfo info);
1849
1850    /**
1851     * Retrieve the logo associated with an application.  Given the name of the
1852     * application's package, retrieves the information about it and calls
1853     * getApplicationLogo() to return its logo. If the application can not be
1854     * found, NameNotFoundException is thrown.
1855     *
1856     * @param packageName Name of the package whose application logo is to be
1857     *                    retrieved.
1858     *
1859     * @return Returns the image of the logo, or null if no application logo
1860     * has been specified.
1861     *
1862     * @throws NameNotFoundException Thrown if the resources for the given
1863     * application could not be loaded.
1864     *
1865     * @see #getApplicationLogo(ApplicationInfo)
1866     */
1867    public abstract Drawable getApplicationLogo(String packageName)
1868            throws NameNotFoundException;
1869
1870    /**
1871     * Retrieve text from a package.  This is a low-level API used by
1872     * the various package manager info structures (such as
1873     * {@link ComponentInfo} to implement retrieval of their associated
1874     * labels and other text.
1875     *
1876     * @param packageName The name of the package that this text is coming from.
1877     * Can not be null.
1878     * @param resid The resource identifier of the desired text.  Can not be 0.
1879     * @param appInfo Overall information about <var>packageName</var>.  This
1880     * may be null, in which case the application information will be retrieved
1881     * for you if needed; if you already have this information around, it can
1882     * be much more efficient to supply it here.
1883     *
1884     * @return Returns a CharSequence holding the requested text.  Returns null
1885     * if the text could not be found for any reason.
1886     */
1887    public abstract CharSequence getText(String packageName, int resid,
1888            ApplicationInfo appInfo);
1889
1890    /**
1891     * Retrieve an XML file from a package.  This is a low-level API used to
1892     * retrieve XML meta data.
1893     *
1894     * @param packageName The name of the package that this xml is coming from.
1895     * Can not be null.
1896     * @param resid The resource identifier of the desired xml.  Can not be 0.
1897     * @param appInfo Overall information about <var>packageName</var>.  This
1898     * may be null, in which case the application information will be retrieved
1899     * for you if needed; if you already have this information around, it can
1900     * be much more efficient to supply it here.
1901     *
1902     * @return Returns an XmlPullParser allowing you to parse out the XML
1903     * data.  Returns null if the xml resource could not be found for any
1904     * reason.
1905     */
1906    public abstract XmlResourceParser getXml(String packageName, int resid,
1907            ApplicationInfo appInfo);
1908
1909    /**
1910     * Return the label to use for this application.
1911     *
1912     * @return Returns the label associated with this application, or null if
1913     * it could not be found for any reason.
1914     * @param info The application to get the label of
1915     */
1916    public abstract CharSequence getApplicationLabel(ApplicationInfo info);
1917
1918    /**
1919     * Retrieve the resources associated with an activity.  Given the full
1920     * name of an activity, retrieves the information about it and calls
1921     * getResources() to return its application's resources.  If the activity
1922     * can not be found, NameNotFoundException is thrown.
1923     *
1924     * @param activityName Name of the activity whose resources are to be
1925     *                     retrieved.
1926     *
1927     * @return Returns the application's Resources.
1928     * @throws NameNotFoundException Thrown if the resources for the given
1929     * application could not be loaded.
1930     *
1931     * @see #getResourcesForApplication(ApplicationInfo)
1932     */
1933    public abstract Resources getResourcesForActivity(ComponentName activityName)
1934            throws NameNotFoundException;
1935
1936    /**
1937     * Retrieve the resources for an application.  Throws NameNotFoundException
1938     * if the package is no longer installed.
1939     *
1940     * @param app Information about the desired application.
1941     *
1942     * @return Returns the application's Resources.
1943     * @throws NameNotFoundException Thrown if the resources for the given
1944     * application could not be loaded (most likely because it was uninstalled).
1945     */
1946    public abstract Resources getResourcesForApplication(ApplicationInfo app)
1947            throws NameNotFoundException;
1948
1949    /**
1950     * Retrieve the resources associated with an application.  Given the full
1951     * package name of an application, retrieves the information about it and
1952     * calls getResources() to return its application's resources.  If the
1953     * appPackageName can not be found, NameNotFoundException is thrown.
1954     *
1955     * @param appPackageName Package name of the application whose resources
1956     *                       are to be retrieved.
1957     *
1958     * @return Returns the application's Resources.
1959     * @throws NameNotFoundException Thrown if the resources for the given
1960     * application could not be loaded.
1961     *
1962     * @see #getResourcesForApplication(ApplicationInfo)
1963     */
1964    public abstract Resources getResourcesForApplication(String appPackageName)
1965            throws NameNotFoundException;
1966
1967    /**
1968     * Retrieve overall information about an application package defined
1969     * in a package archive file
1970     *
1971     * @param archiveFilePath The path to the archive file
1972     * @param flags Additional option flags. Use any combination of
1973     * {@link #GET_ACTIVITIES},
1974     * {@link #GET_GIDS},
1975     * {@link #GET_CONFIGURATIONS},
1976     * {@link #GET_INSTRUMENTATION},
1977     * {@link #GET_PERMISSIONS},
1978     * {@link #GET_PROVIDERS},
1979     * {@link #GET_RECEIVERS},
1980     * {@link #GET_SERVICES},
1981     * {@link #GET_SIGNATURES}, to modify the data returned.
1982     *
1983     * @return Returns the information about the package. Returns
1984     * null if the package could not be successfully parsed.
1985     *
1986     * @see #GET_ACTIVITIES
1987     * @see #GET_GIDS
1988     * @see #GET_CONFIGURATIONS
1989     * @see #GET_INSTRUMENTATION
1990     * @see #GET_PERMISSIONS
1991     * @see #GET_PROVIDERS
1992     * @see #GET_RECEIVERS
1993     * @see #GET_SERVICES
1994     * @see #GET_SIGNATURES
1995     *
1996     */
1997    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
1998        PackageParser packageParser = new PackageParser(archiveFilePath);
1999        DisplayMetrics metrics = new DisplayMetrics();
2000        metrics.setToDefaults();
2001        final File sourceFile = new File(archiveFilePath);
2002        PackageParser.Package pkg = packageParser.parsePackage(
2003                sourceFile, archiveFilePath, metrics, 0);
2004        if (pkg == null) {
2005            return null;
2006        }
2007        return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0);
2008    }
2009
2010    /**
2011     * @hide
2012     *
2013     * Install a package. Since this may take a little while, the result will
2014     * be posted back to the given observer.  An installation will fail if the calling context
2015     * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
2016     * package named in the package file's manifest is already installed, or if there's no space
2017     * available on the device.
2018     *
2019     * @param packageURI The location of the package file to install.  This can be a 'file:' or a
2020     * 'content:' URI.
2021     * @param observer An observer callback to get notified when the package installation is
2022     * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
2023     * called when that happens.  observer may be null to indicate that no callback is desired.
2024     * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
2025     * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
2026     * @param installerPackageName Optional package name of the application that is performing the
2027     * installation. This identifies which market the package came from.
2028     */
2029    public abstract void installPackage(
2030            Uri packageURI, IPackageInstallObserver observer, int flags,
2031            String installerPackageName);
2032
2033    /**
2034     * Change the installer associated with a given package.  There are limitations
2035     * on how the installer package can be changed; in particular:
2036     * <ul>
2037     * <li> A SecurityException will be thrown if <var>installerPackageName</var>
2038     * is not signed with the same certificate as the calling application.
2039     * <li> A SecurityException will be thrown if <var>targetPackage</var> already
2040     * has an installer package, and that installer package is not signed with
2041     * the same certificate as the calling application.
2042     * </ul>
2043     *
2044     * @param targetPackage The installed package whose installer will be changed.
2045     * @param installerPackageName The package name of the new installer.  May be
2046     * null to clear the association.
2047     */
2048    public abstract void setInstallerPackageName(String targetPackage,
2049            String installerPackageName);
2050
2051    /**
2052     * Attempts to delete a package.  Since this may take a little while, the result will
2053     * be posted back to the given observer.  A deletion will fail if the calling context
2054     * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
2055     * named package cannot be found, or if the named package is a "system package".
2056     * (TODO: include pointer to documentation on "system packages")
2057     *
2058     * @param packageName The name of the package to delete
2059     * @param observer An observer callback to get notified when the package deletion is
2060     * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
2061     * called when that happens.  observer may be null to indicate that no callback is desired.
2062     * @param flags - possible values: {@link #DONT_DELETE_DATA}
2063     *
2064     * @hide
2065     */
2066    public abstract void deletePackage(
2067            String packageName, IPackageDeleteObserver observer, int flags);
2068
2069    /**
2070     * Retrieve the package name of the application that installed a package. This identifies
2071     * which market the package came from.
2072     *
2073     * @param packageName The name of the package to query
2074     */
2075    public abstract String getInstallerPackageName(String packageName);
2076
2077    /**
2078     * Attempts to clear the user data directory of an application.
2079     * Since this may take a little while, the result will
2080     * be posted back to the given observer.  A deletion will fail if the
2081     * named package cannot be found, or if the named package is a "system package".
2082     *
2083     * @param packageName The name of the package
2084     * @param observer An observer callback to get notified when the operation is finished
2085     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2086     * will be called when that happens.  observer may be null to indicate that
2087     * no callback is desired.
2088     *
2089     * @hide
2090     */
2091    public abstract void clearApplicationUserData(String packageName,
2092            IPackageDataObserver observer);
2093    /**
2094     * Attempts to delete the cache files associated with an application.
2095     * Since this may take a little while, the result will
2096     * be posted back to the given observer.  A deletion will fail if the calling context
2097     * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
2098     * named package cannot be found, or if the named package is a "system package".
2099     *
2100     * @param packageName The name of the package to delete
2101     * @param observer An observer callback to get notified when the cache file deletion
2102     * is complete.
2103     * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
2104     * will be called when that happens.  observer may be null to indicate that
2105     * no callback is desired.
2106     *
2107     * @hide
2108     */
2109    public abstract void deleteApplicationCacheFiles(String packageName,
2110            IPackageDataObserver observer);
2111
2112    /**
2113     * Free storage by deleting LRU sorted list of cache files across
2114     * all applications. If the currently available free storage
2115     * on the device is greater than or equal to the requested
2116     * free storage, no cache files are cleared. If the currently
2117     * available storage on the device is less than the requested
2118     * free storage, some or all of the cache files across
2119     * all applications are deleted (based on last accessed time)
2120     * to increase the free storage space on the device to
2121     * the requested value. There is no guarantee that clearing all
2122     * the cache files from all applications will clear up
2123     * enough storage to achieve the desired value.
2124     * @param freeStorageSize The number of bytes of storage to be
2125     * freed by the system. Say if freeStorageSize is XX,
2126     * and the current free storage is YY,
2127     * if XX is less than YY, just return. if not free XX-YY number
2128     * of bytes if possible.
2129     * @param observer call back used to notify when
2130     * the operation is completed
2131     *
2132     * @hide
2133     */
2134    public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
2135
2136    /**
2137     * Free storage by deleting LRU sorted list of cache files across
2138     * all applications. If the currently available free storage
2139     * on the device is greater than or equal to the requested
2140     * free storage, no cache files are cleared. If the currently
2141     * available storage on the device is less than the requested
2142     * free storage, some or all of the cache files across
2143     * all applications are deleted (based on last accessed time)
2144     * to increase the free storage space on the device to
2145     * the requested value. There is no guarantee that clearing all
2146     * the cache files from all applications will clear up
2147     * enough storage to achieve the desired value.
2148     * @param freeStorageSize The number of bytes of storage to be
2149     * freed by the system. Say if freeStorageSize is XX,
2150     * and the current free storage is YY,
2151     * if XX is less than YY, just return. if not free XX-YY number
2152     * of bytes if possible.
2153     * @param pi IntentSender call back used to
2154     * notify when the operation is completed.May be null
2155     * to indicate that no call back is desired.
2156     *
2157     * @hide
2158     */
2159    public abstract void freeStorage(long freeStorageSize, IntentSender pi);
2160
2161    /**
2162     * Retrieve the size information for a package.
2163     * Since this may take a little while, the result will
2164     * be posted back to the given observer.  The calling context
2165     * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
2166     *
2167     * @param packageName The name of the package whose size information is to be retrieved
2168     * @param observer An observer callback to get notified when the operation
2169     * is complete.
2170     * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
2171     * The observer's callback is invoked with a PackageStats object(containing the
2172     * code, data and cache sizes of the package) and a boolean value representing
2173     * the status of the operation. observer may be null to indicate that
2174     * no callback is desired.
2175     *
2176     * @hide
2177     */
2178    public abstract void getPackageSizeInfo(String packageName,
2179            IPackageStatsObserver observer);
2180
2181    /**
2182     * @deprecated This function no longer does anything; it was an old
2183     * approach to managing preferred activities, which has been superceeded
2184     * (and conflicts with) the modern activity-based preferences.
2185     */
2186    @Deprecated
2187    public abstract void addPackageToPreferred(String packageName);
2188
2189    /**
2190     * @deprecated This function no longer does anything; it was an old
2191     * approach to managing preferred activities, which has been superceeded
2192     * (and conflicts with) the modern activity-based preferences.
2193     */
2194    @Deprecated
2195    public abstract void removePackageFromPreferred(String packageName);
2196
2197    /**
2198     * Retrieve the list of all currently configured preferred packages.  The
2199     * first package on the list is the most preferred, the last is the
2200     * least preferred.
2201     *
2202     * @param flags Additional option flags. Use any combination of
2203     * {@link #GET_ACTIVITIES},
2204     * {@link #GET_GIDS},
2205     * {@link #GET_CONFIGURATIONS},
2206     * {@link #GET_INSTRUMENTATION},
2207     * {@link #GET_PERMISSIONS},
2208     * {@link #GET_PROVIDERS},
2209     * {@link #GET_RECEIVERS},
2210     * {@link #GET_SERVICES},
2211     * {@link #GET_SIGNATURES}, to modify the data returned.
2212     *
2213     * @return Returns a list of PackageInfo objects describing each
2214     * preferred application, in order of preference.
2215     *
2216     * @see #GET_ACTIVITIES
2217     * @see #GET_GIDS
2218     * @see #GET_CONFIGURATIONS
2219     * @see #GET_INSTRUMENTATION
2220     * @see #GET_PERMISSIONS
2221     * @see #GET_PROVIDERS
2222     * @see #GET_RECEIVERS
2223     * @see #GET_SERVICES
2224     * @see #GET_SIGNATURES
2225     */
2226    public abstract List<PackageInfo> getPreferredPackages(int flags);
2227
2228    /**
2229     * @deprecated This is a protected API that should not have been available
2230     * to third party applications.  It is the platform's responsibility for
2231     * assigning preferred activities and this can not be directly modified.
2232     *
2233     * Add a new preferred activity mapping to the system.  This will be used
2234     * to automatically select the given activity component when
2235     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2236     * multiple matching activities and also matches the given filter.
2237     *
2238     * @param filter The set of intents under which this activity will be
2239     * made preferred.
2240     * @param match The IntentFilter match category that this preference
2241     * applies to.
2242     * @param set The set of activities that the user was picking from when
2243     * this preference was made.
2244     * @param activity The component name of the activity that is to be
2245     * preferred.
2246     */
2247    @Deprecated
2248    public abstract void addPreferredActivity(IntentFilter filter, int match,
2249            ComponentName[] set, ComponentName activity);
2250
2251    /**
2252     * @deprecated This is a protected API that should not have been available
2253     * to third party applications.  It is the platform's responsibility for
2254     * assigning preferred activities and this can not be directly modified.
2255     *
2256     * Replaces an existing preferred activity mapping to the system, and if that were not present
2257     * adds a new preferred activity.  This will be used
2258     * to automatically select the given activity component when
2259     * {@link Context#startActivity(Intent) Context.startActivity()} finds
2260     * multiple matching activities and also matches the given filter.
2261     *
2262     * @param filter The set of intents under which this activity will be
2263     * made preferred.
2264     * @param match The IntentFilter match category that this preference
2265     * applies to.
2266     * @param set The set of activities that the user was picking from when
2267     * this preference was made.
2268     * @param activity The component name of the activity that is to be
2269     * preferred.
2270     * @hide
2271     */
2272    @Deprecated
2273    public abstract void replacePreferredActivity(IntentFilter filter, int match,
2274            ComponentName[] set, ComponentName activity);
2275
2276    /**
2277     * Remove all preferred activity mappings, previously added with
2278     * {@link #addPreferredActivity}, from the
2279     * system whose activities are implemented in the given package name.
2280     * An application can only clear its own package(s).
2281     *
2282     * @param packageName The name of the package whose preferred activity
2283     * mappings are to be removed.
2284     */
2285    public abstract void clearPackagePreferredActivities(String packageName);
2286
2287    /**
2288     * Retrieve all preferred activities, previously added with
2289     * {@link #addPreferredActivity}, that are
2290     * currently registered with the system.
2291     *
2292     * @param outFilters A list in which to place the filters of all of the
2293     * preferred activities, or null for none.
2294     * @param outActivities A list in which to place the component names of
2295     * all of the preferred activities, or null for none.
2296     * @param packageName An option package in which you would like to limit
2297     * the list.  If null, all activities will be returned; if non-null, only
2298     * those activities in the given package are returned.
2299     *
2300     * @return Returns the total number of registered preferred activities
2301     * (the number of distinct IntentFilter records, not the number of unique
2302     * activity components) that were found.
2303     */
2304    public abstract int getPreferredActivities(List<IntentFilter> outFilters,
2305            List<ComponentName> outActivities, String packageName);
2306
2307    /**
2308     * Set the enabled setting for a package component (activity, receiver, service, provider).
2309     * This setting will override any enabled state which may have been set by the component in its
2310     * manifest.
2311     *
2312     * @param componentName The component to enable
2313     * @param newState The new enabled state for the component.  The legal values for this state
2314     *                 are:
2315     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2316     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2317     *                   and
2318     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2319     *                 The last one removes the setting, thereby restoring the component's state to
2320     *                 whatever was set in it's manifest (or enabled, by default).
2321     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2322     */
2323    public abstract void setComponentEnabledSetting(ComponentName componentName,
2324            int newState, int flags);
2325
2326
2327    /**
2328     * Return the the enabled setting for a package component (activity,
2329     * receiver, service, provider).  This returns the last value set by
2330     * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
2331     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2332     * the value originally specified in the manifest has not been modified.
2333     *
2334     * @param componentName The component to retrieve.
2335     * @return Returns the current enabled state for the component.  May
2336     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2337     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2338     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2339     * component's enabled state is based on the original information in
2340     * the manifest as found in {@link ComponentInfo}.
2341     */
2342    public abstract int getComponentEnabledSetting(ComponentName componentName);
2343
2344    /**
2345     * Set the enabled setting for an application
2346     * This setting will override any enabled state which may have been set by the application in
2347     * its manifest.  It also overrides the enabled state set in the manifest for any of the
2348     * application's components.  It does not override any enabled state set by
2349     * {@link #setComponentEnabledSetting} for any of the application's components.
2350     *
2351     * @param packageName The package name of the application to enable
2352     * @param newState The new enabled state for the component.  The legal values for this state
2353     *                 are:
2354     *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
2355     *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
2356     *                   and
2357     *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2358     *                 The last one removes the setting, thereby restoring the applications's state to
2359     *                 whatever was set in its manifest (or enabled, by default).
2360     * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2361     */
2362    public abstract void setApplicationEnabledSetting(String packageName,
2363            int newState, int flags);
2364
2365    /**
2366     * Return the the enabled setting for an application.  This returns
2367     * the last value set by
2368     * {@link #setApplicationEnabledSetting(String, int, int)}; in most
2369     * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2370     * the value originally specified in the manifest has not been modified.
2371     *
2372     * @param packageName The component to retrieve.
2373     * @return Returns the current enabled state for the component.  May
2374     * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2375     * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2376     * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
2377     * application's enabled state is based on the original information in
2378     * the manifest as found in {@link ComponentInfo}.
2379     */
2380    public abstract int getApplicationEnabledSetting(String packageName);
2381
2382    /**
2383     * Return whether the device has been booted into safe mode.
2384     */
2385    public abstract boolean isSafeMode();
2386
2387    /**
2388     * Attempts to move package resources from internal to external media or vice versa.
2389     * Since this may take a little while, the result will
2390     * be posted back to the given observer.   This call may fail if the calling context
2391     * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
2392     * named package cannot be found, or if the named package is a "system package".
2393     *
2394     * @param packageName The name of the package to delete
2395     * @param observer An observer callback to get notified when the package move is
2396     * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
2397     * called when that happens.  observer may be null to indicate that no callback is desired.
2398     * @param flags To indicate install location {@link #MOVE_INTERNAL} or
2399     * {@link #MOVE_EXTERNAL_MEDIA}
2400     *
2401     * @hide
2402     */
2403    public abstract void movePackage(
2404            String packageName, IPackageMoveObserver observer, int flags);
2405
2406    /**
2407     * Creates a user with the specified name and options.
2408     *
2409     * @param name the user's name
2410     * @param flags flags that identify the type of user and other properties.
2411     * @see UserInfo
2412     *
2413     * @return the UserInfo object for the created user, or null if the user could not be created.
2414     * @hide
2415     */
2416    public abstract UserInfo createUser(String name, int flags);
2417
2418    /**
2419     * @return the list of users that were created
2420     * @hide
2421     */
2422    public abstract List<UserInfo> getUsers();
2423
2424    /**
2425     * @param id the ID of the user, where 0 is the primary user.
2426     * @hide
2427     */
2428    public abstract boolean removeUser(int id);
2429
2430    /**
2431     * Updates the user's name.
2432     *
2433     * @param id the user's id
2434     * @param name the new name for the user
2435     * @hide
2436     */
2437    public abstract void updateUserName(int id, String name);
2438
2439    /**
2440     * Changes the user's properties specified by the flags.
2441     *
2442     * @param id the user's id
2443     * @param flags the new flags for the user
2444     * @hide
2445     */
2446    public abstract void updateUserFlags(int id, int flags);
2447
2448    /**
2449     * Checks to see if the user id is the same for the two uids, i.e., they belong to the same
2450     * user.
2451     * @hide
2452     */
2453    public static boolean isSameUser(int uid1, int uid2) {
2454        return getUserId(uid1) == getUserId(uid2);
2455    }
2456
2457    /**
2458     * Returns the user id for a given uid.
2459     * @hide
2460     */
2461    public static int getUserId(int uid) {
2462        return uid / PER_USER_RANGE;
2463    }
2464
2465    /**
2466     * Returns the uid that is composed from the userId and the appId.
2467     * @hide
2468     */
2469    public static int getUid(int userId, int appId) {
2470        return userId * PER_USER_RANGE + (appId % PER_USER_RANGE);
2471    }
2472
2473    /**
2474     * Returns the app id (or base uid) for a given uid, stripping out the user id from it.
2475     * @hide
2476     */
2477    public static int getAppId(int uid) {
2478        return uid % PER_USER_RANGE;
2479    }
2480}
2481