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