• 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.content.ComponentName;
20 import android.content.Context;
21 import android.content.Intent;
22 import android.content.IntentFilter;
23 import android.content.IntentSender;
24 import android.content.res.Resources;
25 import android.content.res.XmlResourceParser;
26 import android.graphics.drawable.Drawable;
27 import android.net.Uri;
28 import android.util.AndroidException;
29 import android.util.DisplayMetrics;
30 
31 import java.io.File;
32 import java.util.List;
33 
34 /**
35  * Class for retrieving various kinds of information related to the application
36  * packages that are currently installed on the device.
37  *
38  * You can find this class through {@link Context#getPackageManager}.
39  */
40 public abstract class PackageManager {
41 
42     /**
43      * This exception is thrown when a given package, application, or component
44      * name can not be found.
45      */
46     public static class NameNotFoundException extends AndroidException {
NameNotFoundException()47         public NameNotFoundException() {
48         }
49 
NameNotFoundException(String name)50         public NameNotFoundException(String name) {
51             super(name);
52         }
53     }
54 
55     /**
56      * {@link PackageInfo} flag: return information about
57      * activities in the package in {@link PackageInfo#activities}.
58      */
59     public static final int GET_ACTIVITIES              = 0x00000001;
60 
61     /**
62      * {@link PackageInfo} flag: return information about
63      * intent receivers in the package in
64      * {@link PackageInfo#receivers}.
65      */
66     public static final int GET_RECEIVERS               = 0x00000002;
67 
68     /**
69      * {@link PackageInfo} flag: return information about
70      * services in the package in {@link PackageInfo#services}.
71      */
72     public static final int GET_SERVICES                = 0x00000004;
73 
74     /**
75      * {@link PackageInfo} flag: return information about
76      * content providers in the package in
77      * {@link PackageInfo#providers}.
78      */
79     public static final int GET_PROVIDERS               = 0x00000008;
80 
81     /**
82      * {@link PackageInfo} flag: return information about
83      * instrumentation in the package in
84      * {@link PackageInfo#instrumentation}.
85      */
86     public static final int GET_INSTRUMENTATION         = 0x00000010;
87 
88     /**
89      * {@link PackageInfo} flag: return information about the
90      * intent filters supported by the activity.
91      */
92     public static final int GET_INTENT_FILTERS          = 0x00000020;
93 
94     /**
95      * {@link PackageInfo} flag: return information about the
96      * signatures included in the package.
97      */
98     public static final int GET_SIGNATURES          = 0x00000040;
99 
100     /**
101      * {@link ResolveInfo} flag: return the IntentFilter that
102      * was matched for a particular ResolveInfo in
103      * {@link ResolveInfo#filter}.
104      */
105     public static final int GET_RESOLVED_FILTER         = 0x00000040;
106 
107     /**
108      * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
109      * data {@link android.os.Bundle}s that are associated with a component.
110      * This applies for any API returning a ComponentInfo subclass.
111      */
112     public static final int GET_META_DATA               = 0x00000080;
113 
114     /**
115      * {@link PackageInfo} flag: return the
116      * {@link PackageInfo#gids group ids} that are associated with an
117      * application.
118      * This applies for any API returning an PackageInfo class, either
119      * directly or nested inside of another.
120      */
121     public static final int GET_GIDS                    = 0x00000100;
122 
123     /**
124      * {@link PackageInfo} flag: include disabled components in the returned info.
125      */
126     public static final int GET_DISABLED_COMPONENTS     = 0x00000200;
127 
128     /**
129      * {@link ApplicationInfo} flag: return the
130      * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
131      * that are associated with an application.
132      * This applies for any API returning an ApplicationInfo class, either
133      * directly or nested inside of another.
134      */
135     public static final int GET_SHARED_LIBRARY_FILES    = 0x00000400;
136 
137     /**
138      * {@link ProviderInfo} flag: return the
139      * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
140      * that are associated with a content provider.
141      * This applies for any API returning an ProviderInfo class, either
142      * directly or nested inside of another.
143      */
144     public static final int GET_URI_PERMISSION_PATTERNS  = 0x00000800;
145     /**
146      * {@link PackageInfo} flag: return information about
147      * permissions in the package in
148      * {@link PackageInfo#permissions}.
149      */
150     public static final int GET_PERMISSIONS               = 0x00001000;
151 
152     /**
153      * Flag parameter to retrieve all applications(even uninstalled ones) with data directories.
154      * This state could have resulted if applications have been deleted with flag
155      * DONT_DELETE_DATA
156      * with a possibility of being replaced or reinstalled in future
157      */
158     public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
159 
160     /**
161      * {@link PackageInfo} flag: return information about
162      * hardware preferences in
163      * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
164      * requested features in {@link PackageInfo#reqFeatures
165      * PackageInfo.reqFeatures}.
166      */
167     public static final int GET_CONFIGURATIONS = 0x00004000;
168 
169     /**
170      * Resolution and querying flag: if set, only filters that support the
171      * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
172      * matching.  This is a synonym for including the CATEGORY_DEFAULT in your
173      * supplied Intent.
174      */
175     public static final int MATCH_DEFAULT_ONLY   = 0x00010000;
176 
177     /**
178      * Permission check result: this is returned by {@link #checkPermission}
179      * if the permission has been granted to the given package.
180      */
181     public static final int PERMISSION_GRANTED = 0;
182 
183     /**
184      * Permission check result: this is returned by {@link #checkPermission}
185      * if the permission has not been granted to the given package.
186      */
187     public static final int PERMISSION_DENIED = -1;
188 
189     /**
190      * Signature check result: this is returned by {@link #checkSignatures}
191      * if the two packages have a matching signature.
192      */
193     public static final int SIGNATURE_MATCH = 0;
194 
195     /**
196      * Signature check result: this is returned by {@link #checkSignatures}
197      * if neither of the two packages is signed.
198      */
199     public static final int SIGNATURE_NEITHER_SIGNED = 1;
200 
201     /**
202      * Signature check result: this is returned by {@link #checkSignatures}
203      * if the first package is not signed, but the second is.
204      */
205     public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
206 
207     /**
208      * Signature check result: this is returned by {@link #checkSignatures}
209      * if the second package is not signed, but the first is.
210      */
211     public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
212 
213     /**
214      * Signature check result: this is returned by {@link #checkSignatures}
215      * if both packages are signed but there is no matching signature.
216      */
217     public static final int SIGNATURE_NO_MATCH = -3;
218 
219     /**
220      * Signature check result: this is returned by {@link #checkSignatures}
221      * if either of the given package names are not valid.
222      */
223     public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
224 
225     public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
226     public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
227     public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
228 
229     /**
230      * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
231      * indicate that this package should be installed as forward locked, i.e. only the app itself
232      * should have access to it's code and non-resource assets.
233      * @hide
234      */
235     public static final int INSTALL_FORWARD_LOCK = 0x00000001;
236 
237     /**
238      * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
239      * installed package, if one exists.
240      * @hide
241      */
242     public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
243 
244     /**
245      * Flag parameter for {@link #installPackage} to indicate that you want to
246      * allow test packages (those that have set android:testOnly in their
247      * manifest) to be installed.
248      * @hide
249      */
250     public static final int INSTALL_ALLOW_TEST = 0x00000004;
251 
252     /**
253      * Flag parameter for
254      * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
255      * that you don't want to kill the app containing the component.  Be careful when you set this
256      * since changing component states can make the containing application's behavior unpredictable.
257      */
258     public static final int DONT_KILL_APP = 0x00000001;
259 
260     /**
261      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
262      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
263      * @hide
264      */
265     public static final int INSTALL_SUCCEEDED = 1;
266 
267     /**
268      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
269      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
270      * already installed.
271      * @hide
272      */
273     public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
274 
275     /**
276      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
277      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
278      * file is invalid.
279      * @hide
280      */
281     public static final int INSTALL_FAILED_INVALID_APK = -2;
282 
283     /**
284      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
285      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
286      * is invalid.
287      * @hide
288      */
289     public static final int INSTALL_FAILED_INVALID_URI = -3;
290 
291     /**
292      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
293      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
294      * service found that the device didn't have enough storage space to install the app.
295      * @hide
296      */
297     public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
298 
299     /**
300      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
301      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
302      * package is already installed with the same name.
303      * @hide
304      */
305     public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
306 
307     /**
308      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
309      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
310      * the requested shared user does not exist.
311      * @hide
312      */
313     public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
314 
315     /**
316      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
317      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
318      * a previously installed package of the same name has a different signature
319      * than the new package (and the old package's data was not removed).
320      * @hide
321      */
322     public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
323 
324     /**
325      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
326      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
327      * the new package is requested a shared user which is already installed on the
328      * device and does not have matching signature.
329      * @hide
330      */
331     public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
332 
333     /**
334      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
335      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
336      * the new package uses a shared library that is not available.
337      * @hide
338      */
339     public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
340 
341     /**
342      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
343      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
344      * the new package uses a shared library that is not available.
345      * @hide
346      */
347     public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
348 
349     /**
350      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
351      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
352      * the new package failed while optimizing and validating its dex files,
353      * either because there was not enough storage or the validation failed.
354      * @hide
355      */
356     public static final int INSTALL_FAILED_DEXOPT = -11;
357 
358     /**
359      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
360      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
361      * the new package failed because the current SDK version is older than
362      * that required by the package.
363      * @hide
364      */
365     public static final int INSTALL_FAILED_OLDER_SDK = -12;
366 
367     /**
368      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
369      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
370      * the new package failed because it contains a content provider with the
371      * same authority as a provider already installed in the system.
372      * @hide
373      */
374     public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
375 
376     /**
377      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
378      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
379      * the new package failed because the current SDK version is newer than
380      * that required by the package.
381      * @hide
382      */
383     public static final int INSTALL_FAILED_NEWER_SDK = -14;
384 
385     /**
386      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
387      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
388      * the new package failed because it has specified that it is a test-only
389      * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
390      * flag.
391      * @hide
392      */
393     public static final int INSTALL_FAILED_TEST_ONLY = -15;
394 
395     /**
396      * Installation return code: this is passed to the {@link IPackageInstallObserver} by
397      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
398      * the package being installed contains native code, but none that is
399      * compatible with the the device's CPU_ABI.
400      * @hide
401      */
402     public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
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 uses a feature that is not available.
408      * @hide
409      */
410     public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
411 
412     /**
413      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
414      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
415      * if the parser was given a path that is not a file, or does not end with the expected
416      * '.apk' extension.
417      * @hide
418      */
419     public static final int INSTALL_PARSE_FAILED_NOT_APK = -100;
420 
421     /**
422      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
423      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
424      * if the parser was unable to retrieve the AndroidManifest.xml file.
425      * @hide
426      */
427     public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101;
428 
429     /**
430      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
431      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
432      * if the parser encountered an unexpected exception.
433      * @hide
434      */
435     public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
436 
437     /**
438      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
439      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
440      * if the parser did not find any certificates in the .apk.
441      * @hide
442      */
443     public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
444 
445     /**
446      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
447      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
448      * if the parser found inconsistent certificates on the files in the .apk.
449      * @hide
450      */
451     public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
452 
453     /**
454      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
455      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
456      * if the parser encountered a CertificateEncodingException in one of the
457      * files in the .apk.
458      * @hide
459      */
460     public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
461 
462     /**
463      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
464      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
465      * if the parser encountered a bad or missing package name in the manifest.
466      * @hide
467      */
468     public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
469 
470     /**
471      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
472      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
473      * if the parser encountered a bad shared user id name in the manifest.
474      * @hide
475      */
476     public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
477 
478     /**
479      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
480      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
481      * if the parser encountered some structural problem in the manifest.
482      * @hide
483      */
484     public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
485 
486     /**
487      * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
488      * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
489      * if the parser did not find any actionable tags (instrumentation or application)
490      * in the manifest.
491      * @hide
492      */
493     public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
494 
495     /**
496      * Indicates the state of installation. Used by PackageManager to
497      * figure out incomplete installations. Say a package is being installed
498      * (the state is set to PKG_INSTALL_INCOMPLETE) and remains so till
499      * the package installation is successful or unsuccesful lin which case
500      * the PackageManager will no longer maintain state information associated
501      * with the package. If some exception(like device freeze or battery being
502      * pulled out) occurs during installation of a package, the PackageManager
503      * needs this information to clean up the previously failed installation.
504      */
505     public static final int PKG_INSTALL_INCOMPLETE = 0;
506     public static final int PKG_INSTALL_COMPLETE = 1;
507 
508     /**
509      * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
510      * package's data directory.
511      *
512      * @hide
513      */
514     public static final int DONT_DELETE_DATA = 0x00000001;
515 
516     /**
517      * Retrieve overall information about an application package that is
518      * installed on the system.
519      *
520      * <p>Throws {@link NameNotFoundException} if a package with the given
521      * name can not be found on the system.
522      *
523      * @param packageName The full name (i.e. com.google.apps.contacts) of the
524      *                    desired package.
525 
526      * @param flags Additional option flags. Use any combination of
527      * {@link #GET_ACTIVITIES},
528      * {@link #GET_GIDS},
529      * {@link #GET_CONFIGURATIONS},
530      * {@link #GET_INSTRUMENTATION},
531      * {@link #GET_PERMISSIONS},
532      * {@link #GET_PROVIDERS},
533      * {@link #GET_RECEIVERS},
534      * {@link #GET_SERVICES},
535      * {@link #GET_SIGNATURES},
536      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
537      *
538      * @return Returns a PackageInfo object containing information about the package.
539      *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
540      *         found in the list of installed applications, the package information is
541      *         retrieved from the list of uninstalled applications(which includes
542      *         installed applications as well as applications
543      *         with data directory ie applications which had been
544      *         deleted with DONT_DELTE_DATA flag set).
545      *
546      * @see #GET_ACTIVITIES
547      * @see #GET_GIDS
548      * @see #GET_CONFIGURATIONS
549      * @see #GET_INSTRUMENTATION
550      * @see #GET_PERMISSIONS
551      * @see #GET_PROVIDERS
552      * @see #GET_RECEIVERS
553      * @see #GET_SERVICES
554      * @see #GET_SIGNATURES
555      * @see #GET_UNINSTALLED_PACKAGES
556      *
557      */
getPackageInfo(String packageName, int flags)558     public abstract PackageInfo getPackageInfo(String packageName, int flags)
559             throws NameNotFoundException;
560 
561     /**
562      * Return a "good" intent to launch a front-door activity in a package,
563      * for use for example to implement an "open" button when browsing through
564      * packages.  The current implementation will look first for a main
565      * activity in the category {@link Intent#CATEGORY_INFO}, next for a
566      * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
567      * null if neither are found.
568      *
569      * <p>Throws {@link NameNotFoundException} if a package with the given
570      * name can not be found on the system.
571      *
572      * @param packageName The name of the package to inspect.
573      *
574      * @return Returns either a fully-qualified Intent that can be used to
575      * launch the main activity in the package, or null if the package does
576      * not contain such an activity.
577      */
getLaunchIntentForPackage(String packageName)578     public abstract Intent getLaunchIntentForPackage(String packageName);
579 
580     /**
581      * Return an array of all of the secondary group-ids that have been
582      * assigned to a package.
583      *
584      * <p>Throws {@link NameNotFoundException} if a package with the given
585      * name can not be found on the system.
586      *
587      * @param packageName The full name (i.e. com.google.apps.contacts) of the
588      *                    desired package.
589      *
590      * @return Returns an int array of the assigned gids, or null if there
591      * are none.
592      */
getPackageGids(String packageName)593     public abstract int[] getPackageGids(String packageName)
594             throws NameNotFoundException;
595 
596     /**
597      * Retrieve all of the information we know about a particular permission.
598      *
599      * <p>Throws {@link NameNotFoundException} if a permission with the given
600      * name can not be found on the system.
601      *
602      * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
603      *             of the permission you are interested in.
604      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
605      * retrieve any meta-data associated with the permission.
606      *
607      * @return Returns a {@link PermissionInfo} containing information about the
608      *         permission.
609      */
getPermissionInfo(String name, int flags)610     public abstract PermissionInfo getPermissionInfo(String name, int flags)
611             throws NameNotFoundException;
612 
613     /**
614      * Query for all of the permissions associated with a particular group.
615      *
616      * <p>Throws {@link NameNotFoundException} if the given group does not
617      * exist.
618      *
619      * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
620      *             of the permission group you are interested in.  Use null to
621      *             find all of the permissions not associated with a group.
622      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
623      * retrieve any meta-data associated with the permissions.
624      *
625      * @return Returns a list of {@link PermissionInfo} containing information
626      * about all of the permissions in the given group.
627      */
queryPermissionsByGroup(String group, int flags)628     public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
629             int flags) throws NameNotFoundException;
630 
631     /**
632      * Retrieve all of the information we know about a particular group of
633      * permissions.
634      *
635      * <p>Throws {@link NameNotFoundException} if a permission group with the given
636      * name can not be found on the system.
637      *
638      * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
639      *             of the permission you are interested in.
640      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
641      * retrieve any meta-data associated with the permission group.
642      *
643      * @return Returns a {@link PermissionGroupInfo} containing information
644      * about the permission.
645      */
getPermissionGroupInfo(String name, int flags)646     public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
647             int flags) throws NameNotFoundException;
648 
649     /**
650      * Retrieve all of the known permission groups in the system.
651      *
652      * @param flags Additional option flags.  Use {@link #GET_META_DATA} to
653      * retrieve any meta-data associated with the permission group.
654      *
655      * @return Returns a list of {@link PermissionGroupInfo} containing
656      * information about all of the known permission groups.
657      */
getAllPermissionGroups(int flags)658     public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
659 
660     /**
661      * Retrieve all of the information we know about a particular
662      * package/application.
663      *
664      * <p>Throws {@link NameNotFoundException} if an application with the given
665      * package name can not be found on the system.
666      *
667      * @param packageName The full name (i.e. com.google.apps.contacts) of an
668      *                    application.
669      * @param flags Additional option flags. Use any combination of
670      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
671      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
672      *
673      * @return  {@link ApplicationInfo} Returns ApplicationInfo object containing
674      *         information about the package.
675      *         If flag GET_UNINSTALLED_PACKAGES is set and  if the package is not
676      *         found in the list of installed applications,
677      *         the application information is retrieved from the
678      *         list of uninstalled applications(which includes
679      *         installed applications as well as applications
680      *         with data directory ie applications which had been
681      *         deleted with DONT_DELTE_DATA flag set).
682      *
683      * @see #GET_META_DATA
684      * @see #GET_SHARED_LIBRARY_FILES
685      * @see #GET_UNINSTALLED_PACKAGES
686      */
getApplicationInfo(String packageName, int flags)687     public abstract ApplicationInfo getApplicationInfo(String packageName,
688             int flags) throws NameNotFoundException;
689 
690     /**
691      * Retrieve all of the information we know about a particular activity
692      * class.
693      *
694      * <p>Throws {@link NameNotFoundException} if an activity with the given
695      * class name can not be found on the system.
696      *
697      * @param className The full name (i.e.
698      *                  com.google.apps.contacts.ContactsList) of an Activity
699      *                  class.
700      * @param flags Additional option flags. Use any combination of
701      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
702      * to modify the data (in ApplicationInfo) returned.
703      *
704      * @return {@link ActivityInfo} containing information about the activity.
705      *
706      * @see #GET_INTENT_FILTERS
707      * @see #GET_META_DATA
708      * @see #GET_SHARED_LIBRARY_FILES
709      */
getActivityInfo(ComponentName className, int flags)710     public abstract ActivityInfo getActivityInfo(ComponentName className,
711             int flags) throws NameNotFoundException;
712 
713     /**
714      * Retrieve all of the information we know about a particular receiver
715      * class.
716      *
717      * <p>Throws {@link NameNotFoundException} if a receiver with the given
718      * class name can not be found on the system.
719      *
720      * @param className The full name (i.e.
721      *                  com.google.apps.contacts.CalendarAlarm) of a Receiver
722      *                  class.
723      * @param flags Additional option flags.  Use any combination of
724      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
725      * to modify the data returned.
726      *
727      * @return {@link ActivityInfo} containing information about the receiver.
728      *
729      * @see #GET_INTENT_FILTERS
730      * @see #GET_META_DATA
731      * @see #GET_SHARED_LIBRARY_FILES
732      */
getReceiverInfo(ComponentName className, int flags)733     public abstract ActivityInfo getReceiverInfo(ComponentName className,
734             int flags) throws NameNotFoundException;
735 
736     /**
737      * Retrieve all of the information we know about a particular service
738      * class.
739      *
740      * <p>Throws {@link NameNotFoundException} if a service with the given
741      * class name can not be found on the system.
742      *
743      * @param className The full name (i.e.
744      *                  com.google.apps.media.BackgroundPlayback) of a Service
745      *                  class.
746      * @param flags Additional option flags.  Use any combination of
747      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
748      * to modify the data returned.
749      *
750      * @return ServiceInfo containing information about the service.
751      *
752      * @see #GET_META_DATA
753      * @see #GET_SHARED_LIBRARY_FILES
754      */
getServiceInfo(ComponentName className, int flags)755     public abstract ServiceInfo getServiceInfo(ComponentName className,
756             int flags) throws NameNotFoundException;
757 
758     /**
759      * Return a List of all packages that are installed
760      * on the device.
761      *
762      * @param flags Additional option flags. Use any combination of
763      * {@link #GET_ACTIVITIES},
764      * {@link #GET_GIDS},
765      * {@link #GET_CONFIGURATIONS},
766      * {@link #GET_INSTRUMENTATION},
767      * {@link #GET_PERMISSIONS},
768      * {@link #GET_PROVIDERS},
769      * {@link #GET_RECEIVERS},
770      * {@link #GET_SERVICES},
771      * {@link #GET_SIGNATURES},
772      * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
773      *
774      * @return A List of PackageInfo objects, one for each package that is
775      *         installed on the device.  In the unlikely case of there being no
776      *         installed packages, an empty list is returned.
777      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
778      *         applications including those deleted with DONT_DELETE_DATA
779      *         (partially installed apps with data directory) will be returned.
780      *
781      * @see #GET_ACTIVITIES
782      * @see #GET_GIDS
783      * @see #GET_CONFIGURATIONS
784      * @see #GET_INSTRUMENTATION
785      * @see #GET_PERMISSIONS
786      * @see #GET_PROVIDERS
787      * @see #GET_RECEIVERS
788      * @see #GET_SERVICES
789      * @see #GET_SIGNATURES
790      * @see #GET_UNINSTALLED_PACKAGES
791      *
792      */
getInstalledPackages(int flags)793     public abstract List<PackageInfo> getInstalledPackages(int flags);
794 
795     /**
796      * Check whether a particular package has been granted a particular
797      * permission.
798      *
799      * @param permName The name of the permission you are checking for,
800      * @param pkgName The name of the package you are checking against.
801      *
802      * @return If the package has the permission, PERMISSION_GRANTED is
803      * returned.  If it does not have the permission, PERMISSION_DENIED
804      * is returned.
805      *
806      * @see #PERMISSION_GRANTED
807      * @see #PERMISSION_DENIED
808      */
checkPermission(String permName, String pkgName)809     public abstract int checkPermission(String permName, String pkgName);
810 
811     /**
812      * Add a new dynamic permission to the system.  For this to work, your
813      * package must have defined a permission tree through the
814      * {@link android.R.styleable#AndroidManifestPermissionTree
815      * &lt;permission-tree&gt;} tag in its manifest.  A package can only add
816      * permissions to trees that were defined by either its own package or
817      * another with the same user id; a permission is in a tree if it
818      * matches the name of the permission tree + ".": for example,
819      * "com.foo.bar" is a member of the permission tree "com.foo".
820      *
821      * <p>It is good to make your permission tree name descriptive, because you
822      * are taking possession of that entire set of permission names.  Thus, it
823      * must be under a domain you control, with a suffix that will not match
824      * any normal permissions that may be declared in any applications that
825      * are part of that domain.
826      *
827      * <p>New permissions must be added before
828      * any .apks are installed that use those permissions.  Permissions you
829      * add through this method are remembered across reboots of the device.
830      * If the given permission already exists, the info you supply here
831      * will be used to update it.
832      *
833      * @param info Description of the permission to be added.
834      *
835      * @return Returns true if a new permission was created, false if an
836      * existing one was updated.
837      *
838      * @throws SecurityException if you are not allowed to add the
839      * given permission name.
840      *
841      * @see #removePermission(String)
842      */
addPermission(PermissionInfo info)843     public abstract boolean addPermission(PermissionInfo info);
844 
845     /**
846      * Removes a permission that was previously added with
847      * {@link #addPermission(PermissionInfo)}.  The same ownership rules apply
848      * -- you are only allowed to remove permissions that you are allowed
849      * to add.
850      *
851      * @param name The name of the permission to remove.
852      *
853      * @throws SecurityException if you are not allowed to remove the
854      * given permission name.
855      *
856      * @see #addPermission(PermissionInfo)
857      */
removePermission(String name)858     public abstract void removePermission(String name);
859 
860     /**
861      * Compare the signatures of two packages to determine if the same
862      * signature appears in both of them.  If they do contain the same
863      * signature, then they are allowed special privileges when working
864      * with each other: they can share the same user-id, run instrumentation
865      * against each other, etc.
866      *
867      * @param pkg1 First package name whose signature will be compared.
868      * @param pkg2 Second package name whose signature will be compared.
869      * @return Returns an integer indicating whether there is a matching
870      * signature: the value is >= 0 if there is a match (or neither package
871      * is signed), or < 0 if there is not a match.  The match result can be
872      * further distinguished with the success (>= 0) constants
873      * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or
874      * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED},
875      * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH},
876      * or {@link #SIGNATURE_UNKNOWN_PACKAGE}.
877      *
878      * @see #checkSignatures(int, int)
879      * @see #SIGNATURE_MATCH
880      * @see #SIGNATURE_NEITHER_SIGNED
881      * @see #SIGNATURE_FIRST_NOT_SIGNED
882      * @see #SIGNATURE_SECOND_NOT_SIGNED
883      * @see #SIGNATURE_NO_MATCH
884      * @see #SIGNATURE_UNKNOWN_PACKAGE
885      */
checkSignatures(String pkg1, String pkg2)886     public abstract int checkSignatures(String pkg1, String pkg2);
887 
888     /**
889      * Like {@link #checkSignatures(String, String)}, but takes UIDs of
890      * the two packages to be checked.  This can be useful, for example,
891      * when doing the check in an IPC, where the UID is the only identity
892      * available.  It is functionally identical to determining the package
893      * associated with the UIDs and checking their signatures.
894      *
895      * @param uid1 First UID whose signature will be compared.
896      * @param uid2 Second UID whose signature will be compared.
897      * @return Returns an integer indicating whether there is a matching
898      * signature: the value is >= 0 if there is a match (or neither package
899      * is signed), or < 0 if there is not a match.  The match result can be
900      * further distinguished with the success (>= 0) constants
901      * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or
902      * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED},
903      * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH},
904      * or {@link #SIGNATURE_UNKNOWN_PACKAGE}.
905      *
906      * @see #checkSignatures(int, int)
907      * @see #SIGNATURE_MATCH
908      * @see #SIGNATURE_NEITHER_SIGNED
909      * @see #SIGNATURE_FIRST_NOT_SIGNED
910      * @see #SIGNATURE_SECOND_NOT_SIGNED
911      * @see #SIGNATURE_NO_MATCH
912      * @see #SIGNATURE_UNKNOWN_PACKAGE
913      */
checkSignatures(int uid1, int uid2)914     public abstract int checkSignatures(int uid1, int uid2);
915 
916     /**
917      * Retrieve the names of all packages that are associated with a particular
918      * user id.  In most cases, this will be a single package name, the package
919      * that has been assigned that user id.  Where there are multiple packages
920      * sharing the same user id through the "sharedUserId" mechanism, all
921      * packages with that id will be returned.
922      *
923      * @param uid The user id for which you would like to retrieve the
924      * associated packages.
925      *
926      * @return Returns an array of one or more packages assigned to the user
927      * id, or null if there are no known packages with the given id.
928      */
getPackagesForUid(int uid)929     public abstract String[] getPackagesForUid(int uid);
930 
931     /**
932      * Retrieve the official name associated with a user id.  This name is
933      * guaranteed to never change, though it is possibly for the underlying
934      * user id to be changed.  That is, if you are storing information about
935      * user ids in persistent storage, you should use the string returned
936      * by this function instead of the raw user-id.
937      *
938      * @param uid The user id for which you would like to retrieve a name.
939      * @return Returns a unique name for the given user id, or null if the
940      * user id is not currently assigned.
941      */
getNameForUid(int uid)942     public abstract String getNameForUid(int uid);
943 
944     /**
945      * Return the user id associated with a shared user name. Multiple
946      * applications can specify a shared user name in their manifest and thus
947      * end up using a common uid. This might be used for new applications
948      * that use an existing shared user name and need to know the uid of the
949      * shared user.
950      *
951      * @param sharedUserName The shared user name whose uid is to be retrieved.
952      * @return Returns the uid associated with the shared user, or  NameNotFoundException
953      * if the shared user name is not being used by any installed packages
954      * @hide
955      */
getUidForSharedUser(String sharedUserName)956     public abstract int getUidForSharedUser(String sharedUserName)
957             throws NameNotFoundException;
958 
959     /**
960      * Return a List of all application packages that are installed on the
961      * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
962      * applications including those deleted with DONT_DELETE_DATA(partially
963      * installed apps with data directory) will be returned.
964      *
965      * @param flags Additional option flags. Use any combination of
966      * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
967      * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
968      *
969      * @return A List of ApplicationInfo objects, one for each application that
970      *         is installed on the device.  In the unlikely case of there being
971      *         no installed applications, an empty list is returned.
972      *         If flag GET_UNINSTALLED_PACKAGES is set, a list of all
973      *         applications including those deleted with DONT_DELETE_DATA
974      *         (partially installed apps with data directory) will be returned.
975      *
976      * @see #GET_META_DATA
977      * @see #GET_SHARED_LIBRARY_FILES
978      * @see #GET_UNINSTALLED_PACKAGES
979      */
getInstalledApplications(int flags)980     public abstract List<ApplicationInfo> getInstalledApplications(int flags);
981 
982     /**
983      * Get a list of shared libraries that are available on the
984      * system.
985      *
986      * @return An array of shared library names that are
987      * available on the system, or null if none are installed.
988      *
989      */
getSystemSharedLibraryNames()990     public abstract String[] getSystemSharedLibraryNames();
991 
992     /**
993      * Get a list of features that are available on the
994      * system.
995      *
996      * @return An array of FeatureInfo classes describing the features
997      * that are available on the system, or null if there are none(!!).
998      */
getSystemAvailableFeatures()999     public abstract FeatureInfo[] getSystemAvailableFeatures();
1000 
1001     /**
1002      * Check whether the given feature name is one of the available
1003      * features as returned by {@link #getSystemAvailableFeatures()}.
1004      *
1005      * @return Returns true if the devices supports the feature, else
1006      * false.
1007      */
hasSystemFeature(String name)1008     public abstract boolean hasSystemFeature(String name);
1009 
1010     /**
1011      * Determine the best action to perform for a given Intent.  This is how
1012      * {@link Intent#resolveActivity} finds an activity if a class has not
1013      * been explicitly specified.
1014      *
1015      * @param intent An intent containing all of the desired specification
1016      *               (action, data, type, category, and/or component).
1017      * @param flags Additional option flags.  The most important is
1018      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
1019      *                    those activities that support the CATEGORY_DEFAULT.
1020      *
1021      * @return Returns a ResolveInfo containing the final activity intent that
1022      *         was determined to be the best action.  Returns null if no
1023      *         matching activity was found.
1024      *
1025      * @see #MATCH_DEFAULT_ONLY
1026      * @see #GET_INTENT_FILTERS
1027      * @see #GET_RESOLVED_FILTER
1028      */
resolveActivity(Intent intent, int flags)1029     public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1030 
1031     /**
1032      * Retrieve all activities that can be performed for the given intent.
1033      *
1034      * @param intent The desired intent as per resolveActivity().
1035      * @param flags Additional option flags.  The most important is
1036      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
1037      *                    those activities that support the CATEGORY_DEFAULT.
1038      *
1039      * @return A List<ResolveInfo> containing one entry for each matching
1040      *         Activity. These are ordered from best to worst match -- that
1041      *         is, the first item in the list is what is returned by
1042      *         resolveActivity().  If there are no matching activities, an empty
1043      *         list is returned.
1044      *
1045      * @see #MATCH_DEFAULT_ONLY
1046      * @see #GET_INTENT_FILTERS
1047      * @see #GET_RESOLVED_FILTER
1048      */
queryIntentActivities(Intent intent, int flags)1049     public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
1050             int flags);
1051 
1052     /**
1053      * Retrieve a set of activities that should be presented to the user as
1054      * similar options.  This is like {@link #queryIntentActivities}, except it
1055      * also allows you to supply a list of more explicit Intents that you would
1056      * like to resolve to particular options, and takes care of returning the
1057      * final ResolveInfo list in a reasonable order, with no duplicates, based
1058      * on those inputs.
1059      *
1060      * @param caller The class name of the activity that is making the
1061      *               request.  This activity will never appear in the output
1062      *               list.  Can be null.
1063      * @param specifics An array of Intents that should be resolved to the
1064      *                  first specific results.  Can be null.
1065      * @param intent The desired intent as per resolveActivity().
1066      * @param flags Additional option flags.  The most important is
1067      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
1068      *                    those activities that support the CATEGORY_DEFAULT.
1069      *
1070      * @return A List<ResolveInfo> containing one entry for each matching
1071      *         Activity. These are ordered first by all of the intents resolved
1072      *         in <var>specifics</var> and then any additional activities that
1073      *         can handle <var>intent</var> but did not get included by one of
1074      *         the <var>specifics</var> intents.  If there are no matching
1075      *         activities, an empty list is returned.
1076      *
1077      * @see #MATCH_DEFAULT_ONLY
1078      * @see #GET_INTENT_FILTERS
1079      * @see #GET_RESOLVED_FILTER
1080      */
queryIntentActivityOptions( ComponentName caller, Intent[] specifics, Intent intent, int flags)1081     public abstract List<ResolveInfo> queryIntentActivityOptions(
1082             ComponentName caller, Intent[] specifics, Intent intent, int flags);
1083 
1084     /**
1085      * Retrieve all receivers that can handle a broadcast of the given intent.
1086      *
1087      * @param intent The desired intent as per resolveActivity().
1088      * @param flags Additional option flags.  The most important is
1089      *                    MATCH_DEFAULT_ONLY, to limit the resolution to only
1090      *                    those activities that support the CATEGORY_DEFAULT.
1091      *
1092      * @return A List<ResolveInfo> containing one entry for each matching
1093      *         Receiver. These are ordered from first to last in priority.  If
1094      *         there are no matching receivers, an empty list is returned.
1095      *
1096      * @see #MATCH_DEFAULT_ONLY
1097      * @see #GET_INTENT_FILTERS
1098      * @see #GET_RESOLVED_FILTER
1099      */
queryBroadcastReceivers(Intent intent, int flags)1100     public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
1101             int flags);
1102 
1103     /**
1104      * Determine the best service to handle for a given Intent.
1105      *
1106      * @param intent An intent containing all of the desired specification
1107      *               (action, data, type, category, and/or component).
1108      * @param flags Additional option flags.
1109      *
1110      * @return Returns a ResolveInfo containing the final service intent that
1111      *         was determined to be the best action.  Returns null if no
1112      *         matching service was found.
1113      *
1114      * @see #GET_INTENT_FILTERS
1115      * @see #GET_RESOLVED_FILTER
1116      */
resolveService(Intent intent, int flags)1117     public abstract ResolveInfo resolveService(Intent intent, int flags);
1118 
1119     /**
1120      * Retrieve all services that can match the given intent.
1121      *
1122      * @param intent The desired intent as per resolveService().
1123      * @param flags Additional option flags.
1124      *
1125      * @return A List<ResolveInfo> containing one entry for each matching
1126      *         ServiceInfo. These are ordered from best to worst match -- that
1127      *         is, the first item in the list is what is returned by
1128      *         resolveService().  If there are no matching services, an empty
1129      *         list is returned.
1130      *
1131      * @see #GET_INTENT_FILTERS
1132      * @see #GET_RESOLVED_FILTER
1133      */
queryIntentServices(Intent intent, int flags)1134     public abstract List<ResolveInfo> queryIntentServices(Intent intent,
1135             int flags);
1136 
1137     /**
1138      * Find a single content provider by its base path name.
1139      *
1140      * @param name The name of the provider to find.
1141      * @param flags Additional option flags.  Currently should always be 0.
1142      *
1143      * @return ContentProviderInfo Information about the provider, if found,
1144      *         else null.
1145      */
resolveContentProvider(String name, int flags)1146     public abstract ProviderInfo resolveContentProvider(String name,
1147             int flags);
1148 
1149     /**
1150      * Retrieve content provider information.
1151      *
1152      * <p><em>Note: unlike most other methods, an empty result set is indicated
1153      * by a null return instead of an empty list.</em>
1154      *
1155      * @param processName If non-null, limits the returned providers to only
1156      *                    those that are hosted by the given process.  If null,
1157      *                    all content providers are returned.
1158      * @param uid If <var>processName</var> is non-null, this is the required
1159      *        uid owning the requested content providers.
1160      * @param flags Additional option flags.  Currently should always be 0.
1161      *
1162      * @return A List<ContentProviderInfo> containing one entry for each
1163      *         content provider either patching <var>processName</var> or, if
1164      *         <var>processName</var> is null, all known content providers.
1165      *         <em>If there are no matching providers, null is returned.</em>
1166      */
queryContentProviders( String processName, int uid, int flags)1167     public abstract List<ProviderInfo> queryContentProviders(
1168             String processName, int uid, int flags);
1169 
1170     /**
1171      * Retrieve all of the information we know about a particular
1172      * instrumentation class.
1173      *
1174      * <p>Throws {@link NameNotFoundException} if instrumentation with the
1175      * given class name can not be found on the system.
1176      *
1177      * @param className The full name (i.e.
1178      *                  com.google.apps.contacts.InstrumentList) of an
1179      *                  Instrumentation class.
1180      * @param flags Additional option flags.  Currently should always be 0.
1181      *
1182      * @return InstrumentationInfo containing information about the
1183      *         instrumentation.
1184      */
getInstrumentationInfo( ComponentName className, int flags)1185     public abstract InstrumentationInfo getInstrumentationInfo(
1186             ComponentName className, int flags) throws NameNotFoundException;
1187 
1188     /**
1189      * Retrieve information about available instrumentation code.  May be used
1190      * to retrieve either all instrumentation code, or only the code targeting
1191      * a particular package.
1192      *
1193      * @param targetPackage If null, all instrumentation is returned; only the
1194      *                      instrumentation targeting this package name is
1195      *                      returned.
1196      * @param flags Additional option flags.  Currently should always be 0.
1197      *
1198      * @return A List<InstrumentationInfo> containing one entry for each
1199      *         matching available Instrumentation.  Returns an empty list if
1200      *         there is no instrumentation available for the given package.
1201      */
queryInstrumentation( String targetPackage, int flags)1202     public abstract List<InstrumentationInfo> queryInstrumentation(
1203             String targetPackage, int flags);
1204 
1205     /**
1206      * Retrieve an image from a package.  This is a low-level API used by
1207      * the various package manager info structures (such as
1208      * {@link ComponentInfo} to implement retrieval of their associated
1209      * icon.
1210      *
1211      * @param packageName The name of the package that this icon is coming from.
1212      * Can not be null.
1213      * @param resid The resource identifier of the desired image.  Can not be 0.
1214      * @param appInfo Overall information about <var>packageName</var>.  This
1215      * may be null, in which case the application information will be retrieved
1216      * for you if needed; if you already have this information around, it can
1217      * be much more efficient to supply it here.
1218      *
1219      * @return Returns a Drawable holding the requested image.  Returns null if
1220      * an image could not be found for any reason.
1221      */
getDrawable(String packageName, int resid, ApplicationInfo appInfo)1222     public abstract Drawable getDrawable(String packageName, int resid,
1223             ApplicationInfo appInfo);
1224 
1225     /**
1226      * Retrieve the icon associated with an activity.  Given the full name of
1227      * an activity, retrieves the information about it and calls
1228      * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
1229      * If the activity can not be found, NameNotFoundException is thrown.
1230      *
1231      * @param activityName Name of the activity whose icon is to be retrieved.
1232      *
1233      * @return Returns the image of the icon, or the default activity icon if
1234      * it could not be found.  Does not return null.
1235      * @throws NameNotFoundException Thrown if the resources for the given
1236      * activity could not be loaded.
1237      *
1238      * @see #getActivityIcon(Intent)
1239      */
getActivityIcon(ComponentName activityName)1240     public abstract Drawable getActivityIcon(ComponentName activityName)
1241             throws NameNotFoundException;
1242 
1243     /**
1244      * Retrieve the icon associated with an Intent.  If intent.getClassName() is
1245      * set, this simply returns the result of
1246      * getActivityIcon(intent.getClassName()).  Otherwise it resolves the intent's
1247      * component and returns the icon associated with the resolved component.
1248      * If intent.getClassName() can not be found or the Intent can not be resolved
1249      * to a component, NameNotFoundException is thrown.
1250      *
1251      * @param intent The intent for which you would like to retrieve an icon.
1252      *
1253      * @return Returns the image of the icon, or the default activity icon if
1254      * it could not be found.  Does not return null.
1255      * @throws NameNotFoundException Thrown if the resources for application
1256      * matching the given intent could not be loaded.
1257      *
1258      * @see #getActivityIcon(ComponentName)
1259      */
getActivityIcon(Intent intent)1260     public abstract Drawable getActivityIcon(Intent intent)
1261             throws NameNotFoundException;
1262 
1263     /**
1264      * Return the generic icon for an activity that is used when no specific
1265      * icon is defined.
1266      *
1267      * @return Drawable Image of the icon.
1268      */
getDefaultActivityIcon()1269     public abstract Drawable getDefaultActivityIcon();
1270 
1271     /**
1272      * Retrieve the icon associated with an application.  If it has not defined
1273      * an icon, the default app icon is returned.  Does not return null.
1274      *
1275      * @param info Information about application being queried.
1276      *
1277      * @return Returns the image of the icon, or the default application icon
1278      * if it could not be found.
1279      *
1280      * @see #getApplicationIcon(String)
1281      */
getApplicationIcon(ApplicationInfo info)1282     public abstract Drawable getApplicationIcon(ApplicationInfo info);
1283 
1284     /**
1285      * Retrieve the icon associated with an application.  Given the name of the
1286      * application's package, retrieves the information about it and calls
1287      * getApplicationIcon() to return its icon. If the application can not be
1288      * found, NameNotFoundException is thrown.
1289      *
1290      * @param packageName Name of the package whose application icon is to be
1291      *                    retrieved.
1292      *
1293      * @return Returns the image of the icon, or the default application icon
1294      * if it could not be found.  Does not return null.
1295      * @throws NameNotFoundException Thrown if the resources for the given
1296      * application could not be loaded.
1297      *
1298      * @see #getApplicationIcon(ApplicationInfo)
1299      */
getApplicationIcon(String packageName)1300     public abstract Drawable getApplicationIcon(String packageName)
1301             throws NameNotFoundException;
1302 
1303     /**
1304      * Retrieve text from a package.  This is a low-level API used by
1305      * the various package manager info structures (such as
1306      * {@link ComponentInfo} to implement retrieval of their associated
1307      * labels and other text.
1308      *
1309      * @param packageName The name of the package that this text is coming from.
1310      * Can not be null.
1311      * @param resid The resource identifier of the desired text.  Can not be 0.
1312      * @param appInfo Overall information about <var>packageName</var>.  This
1313      * may be null, in which case the application information will be retrieved
1314      * for you if needed; if you already have this information around, it can
1315      * be much more efficient to supply it here.
1316      *
1317      * @return Returns a CharSequence holding the requested text.  Returns null
1318      * if the text could not be found for any reason.
1319      */
getText(String packageName, int resid, ApplicationInfo appInfo)1320     public abstract CharSequence getText(String packageName, int resid,
1321             ApplicationInfo appInfo);
1322 
1323     /**
1324      * Retrieve an XML file from a package.  This is a low-level API used to
1325      * retrieve XML meta data.
1326      *
1327      * @param packageName The name of the package that this xml is coming from.
1328      * Can not be null.
1329      * @param resid The resource identifier of the desired xml.  Can not be 0.
1330      * @param appInfo Overall information about <var>packageName</var>.  This
1331      * may be null, in which case the application information will be retrieved
1332      * for you if needed; if you already have this information around, it can
1333      * be much more efficient to supply it here.
1334      *
1335      * @return Returns an XmlPullParser allowing you to parse out the XML
1336      * data.  Returns null if the xml resource could not be found for any
1337      * reason.
1338      */
getXml(String packageName, int resid, ApplicationInfo appInfo)1339     public abstract XmlResourceParser getXml(String packageName, int resid,
1340             ApplicationInfo appInfo);
1341 
1342     /**
1343      * Return the label to use for this application.
1344      *
1345      * @return Returns the label associated with this application, or null if
1346      * it could not be found for any reason.
1347      * @param info The application to get the label of
1348      */
getApplicationLabel(ApplicationInfo info)1349     public abstract CharSequence getApplicationLabel(ApplicationInfo info);
1350 
1351     /**
1352      * Retrieve the resources associated with an activity.  Given the full
1353      * name of an activity, retrieves the information about it and calls
1354      * getResources() to return its application's resources.  If the activity
1355      * can not be found, NameNotFoundException is thrown.
1356      *
1357      * @param activityName Name of the activity whose resources are to be
1358      *                     retrieved.
1359      *
1360      * @return Returns the application's Resources.
1361      * @throws NameNotFoundException Thrown if the resources for the given
1362      * application could not be loaded.
1363      *
1364      * @see #getResourcesForApplication(ApplicationInfo)
1365      */
getResourcesForActivity(ComponentName activityName)1366     public abstract Resources getResourcesForActivity(ComponentName activityName)
1367             throws NameNotFoundException;
1368 
1369     /**
1370      * Retrieve the resources for an application.  Throws NameNotFoundException
1371      * if the package is no longer installed.
1372      *
1373      * @param app Information about the desired application.
1374      *
1375      * @return Returns the application's Resources.
1376      * @throws NameNotFoundException Thrown if the resources for the given
1377      * application could not be loaded (most likely because it was uninstalled).
1378      */
getResourcesForApplication(ApplicationInfo app)1379     public abstract Resources getResourcesForApplication(ApplicationInfo app)
1380             throws NameNotFoundException;
1381 
1382     /**
1383      * Retrieve the resources associated with an application.  Given the full
1384      * package name of an application, retrieves the information about it and
1385      * calls getResources() to return its application's resources.  If the
1386      * appPackageName can not be found, NameNotFoundException is thrown.
1387      *
1388      * @param appPackageName Package name of the application whose resources
1389      *                       are to be retrieved.
1390      *
1391      * @return Returns the application's Resources.
1392      * @throws NameNotFoundException Thrown if the resources for the given
1393      * application could not be loaded.
1394      *
1395      * @see #getResourcesForApplication(ApplicationInfo)
1396      */
getResourcesForApplication(String appPackageName)1397     public abstract Resources getResourcesForApplication(String appPackageName)
1398             throws NameNotFoundException;
1399 
1400     /**
1401      * Retrieve overall information about an application package defined
1402      * in a package archive file
1403      *
1404      * @param archiveFilePath The path to the archive file
1405      * @param flags Additional option flags. Use any combination of
1406      * {@link #GET_ACTIVITIES},
1407      * {@link #GET_GIDS},
1408      * {@link #GET_CONFIGURATIONS},
1409      * {@link #GET_INSTRUMENTATION},
1410      * {@link #GET_PERMISSIONS},
1411      * {@link #GET_PROVIDERS},
1412      * {@link #GET_RECEIVERS},
1413      * {@link #GET_SERVICES},
1414      * {@link #GET_SIGNATURES}, to modify the data returned.
1415      *
1416      * @return Returns the information about the package. Returns
1417      * null if the package could not be successfully parsed.
1418      *
1419      * @see #GET_ACTIVITIES
1420      * @see #GET_GIDS
1421      * @see #GET_CONFIGURATIONS
1422      * @see #GET_INSTRUMENTATION
1423      * @see #GET_PERMISSIONS
1424      * @see #GET_PROVIDERS
1425      * @see #GET_RECEIVERS
1426      * @see #GET_SERVICES
1427      * @see #GET_SIGNATURES
1428      *
1429      */
getPackageArchiveInfo(String archiveFilePath, int flags)1430     public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
1431         PackageParser packageParser = new PackageParser(archiveFilePath);
1432         DisplayMetrics metrics = new DisplayMetrics();
1433         metrics.setToDefaults();
1434         final File sourceFile = new File(archiveFilePath);
1435         PackageParser.Package pkg = packageParser.parsePackage(
1436                 sourceFile, archiveFilePath, metrics, 0);
1437         if (pkg == null) {
1438             return null;
1439         }
1440         return PackageParser.generatePackageInfo(pkg, null, flags);
1441     }
1442 
1443     /**
1444      * @hide
1445      *
1446      * Install a package. Since this may take a little while, the result will
1447      * be posted back to the given observer.  An installation will fail if the calling context
1448      * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
1449      * package named in the package file's manifest is already installed, or if there's no space
1450      * available on the device.
1451      *
1452      * @param packageURI The location of the package file to install.  This can be a 'file:' or a
1453      * 'content:' URI.
1454      * @param observer An observer callback to get notified when the package installation is
1455      * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
1456      * called when that happens.  observer may be null to indicate that no callback is desired.
1457      * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
1458      * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
1459      * @param installerPackageName Optional package name of the application that is performing the
1460      * installation. This identifies which market the package came from.
1461      */
installPackage( Uri packageURI, IPackageInstallObserver observer, int flags, String installerPackageName)1462     public abstract void installPackage(
1463             Uri packageURI, IPackageInstallObserver observer, int flags,
1464             String installerPackageName);
1465 
1466     /**
1467      * Attempts to delete a package.  Since this may take a little while, the result will
1468      * be posted back to the given observer.  A deletion will fail if the calling context
1469      * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
1470      * named package cannot be found, or if the named package is a "system package".
1471      * (TODO: include pointer to documentation on "system packages")
1472      *
1473      * @param packageName The name of the package to delete
1474      * @param observer An observer callback to get notified when the package deletion is
1475      * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
1476      * called when that happens.  observer may be null to indicate that no callback is desired.
1477      * @param flags - possible values: {@link #DONT_DELETE_DATA}
1478      *
1479      * @hide
1480      */
deletePackage( String packageName, IPackageDeleteObserver observer, int flags)1481     public abstract void deletePackage(
1482             String packageName, IPackageDeleteObserver observer, int flags);
1483 
1484     /**
1485      * Retrieve the package name of the application that installed a package. This identifies
1486      * which market the package came from.
1487      *
1488      * @param packageName The name of the package to query
1489      */
getInstallerPackageName(String packageName)1490     public abstract String getInstallerPackageName(String packageName);
1491 
1492     /**
1493      * Attempts to clear the user data directory of an application.
1494      * Since this may take a little while, the result will
1495      * be posted back to the given observer.  A deletion will fail if the
1496      * named package cannot be found, or if the named package is a "system package".
1497      *
1498      * @param packageName The name of the package
1499      * @param observer An observer callback to get notified when the operation is finished
1500      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
1501      * will be called when that happens.  observer may be null to indicate that
1502      * no callback is desired.
1503      *
1504      * @hide
1505      */
clearApplicationUserData(String packageName, IPackageDataObserver observer)1506     public abstract void clearApplicationUserData(String packageName,
1507             IPackageDataObserver observer);
1508     /**
1509      * Attempts to delete the cache files associated with an application.
1510      * Since this may take a little while, the result will
1511      * be posted back to the given observer.  A deletion will fail if the calling context
1512      * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
1513      * named package cannot be found, or if the named package is a "system package".
1514      *
1515      * @param packageName The name of the package to delete
1516      * @param observer An observer callback to get notified when the cache file deletion
1517      * is complete.
1518      * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
1519      * will be called when that happens.  observer may be null to indicate that
1520      * no callback is desired.
1521      *
1522      * @hide
1523      */
deleteApplicationCacheFiles(String packageName, IPackageDataObserver observer)1524     public abstract void deleteApplicationCacheFiles(String packageName,
1525             IPackageDataObserver observer);
1526 
1527     /**
1528      * Free storage by deleting LRU sorted list of cache files across
1529      * all applications. If the currently available free storage
1530      * on the device is greater than or equal to the requested
1531      * free storage, no cache files are cleared. If the currently
1532      * available storage on the device is less than the requested
1533      * free storage, some or all of the cache files across
1534      * all applications are deleted (based on last accessed time)
1535      * to increase the free storage space on the device to
1536      * the requested value. There is no guarantee that clearing all
1537      * the cache files from all applications will clear up
1538      * enough storage to achieve the desired value.
1539      * @param freeStorageSize The number of bytes of storage to be
1540      * freed by the system. Say if freeStorageSize is XX,
1541      * and the current free storage is YY,
1542      * if XX is less than YY, just return. if not free XX-YY number
1543      * of bytes if possible.
1544      * @param observer call back used to notify when
1545      * the operation is completed
1546      *
1547      * @hide
1548      */
freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer)1549     public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
1550 
1551     /**
1552      * Free storage by deleting LRU sorted list of cache files across
1553      * all applications. If the currently available free storage
1554      * on the device is greater than or equal to the requested
1555      * free storage, no cache files are cleared. If the currently
1556      * available storage on the device is less than the requested
1557      * free storage, some or all of the cache files across
1558      * all applications are deleted (based on last accessed time)
1559      * to increase the free storage space on the device to
1560      * the requested value. There is no guarantee that clearing all
1561      * the cache files from all applications will clear up
1562      * enough storage to achieve the desired value.
1563      * @param freeStorageSize The number of bytes of storage to be
1564      * freed by the system. Say if freeStorageSize is XX,
1565      * and the current free storage is YY,
1566      * if XX is less than YY, just return. if not free XX-YY number
1567      * of bytes if possible.
1568      * @param pi IntentSender call back used to
1569      * notify when the operation is completed.May be null
1570      * to indicate that no call back is desired.
1571      *
1572      * @hide
1573      */
freeStorage(long freeStorageSize, IntentSender pi)1574     public abstract void freeStorage(long freeStorageSize, IntentSender pi);
1575 
1576     /**
1577      * Retrieve the size information for a package.
1578      * Since this may take a little while, the result will
1579      * be posted back to the given observer.  The calling context
1580      * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
1581      *
1582      * @param packageName The name of the package whose size information is to be retrieved
1583      * @param observer An observer callback to get notified when the operation
1584      * is complete.
1585      * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
1586      * The observer's callback is invoked with a PackageStats object(containing the
1587      * code, data and cache sizes of the package) and a boolean value representing
1588      * the status of the operation. observer may be null to indicate that
1589      * no callback is desired.
1590      *
1591      * @hide
1592      */
getPackageSizeInfo(String packageName, IPackageStatsObserver observer)1593     public abstract void getPackageSizeInfo(String packageName,
1594             IPackageStatsObserver observer);
1595 
1596     /**
1597      * Add a new package to the list of preferred packages.  This new package
1598      * will be added to the front of the list (removed from its current location
1599      * if already listed), meaning it will now be preferred over all other
1600      * packages when resolving conflicts.
1601      *
1602      * @param packageName The package name of the new package to make preferred.
1603      */
addPackageToPreferred(String packageName)1604     public abstract void addPackageToPreferred(String packageName);
1605 
1606     /**
1607      * Remove a package from the list of preferred packages.  If it was on
1608      * the list, it will no longer be preferred over other packages.
1609      *
1610      * @param packageName The package name to remove.
1611      */
removePackageFromPreferred(String packageName)1612     public abstract void removePackageFromPreferred(String packageName);
1613 
1614     /**
1615      * Retrieve the list of all currently configured preferred packages.  The
1616      * first package on the list is the most preferred, the last is the
1617      * least preferred.
1618      *
1619      * @param flags Additional option flags. Use any combination of
1620      * {@link #GET_ACTIVITIES},
1621      * {@link #GET_GIDS},
1622      * {@link #GET_CONFIGURATIONS},
1623      * {@link #GET_INSTRUMENTATION},
1624      * {@link #GET_PERMISSIONS},
1625      * {@link #GET_PROVIDERS},
1626      * {@link #GET_RECEIVERS},
1627      * {@link #GET_SERVICES},
1628      * {@link #GET_SIGNATURES}, to modify the data returned.
1629      *
1630      * @return Returns a list of PackageInfo objects describing each
1631      * preferred application, in order of preference.
1632      *
1633      * @see #GET_ACTIVITIES
1634      * @see #GET_GIDS
1635      * @see #GET_CONFIGURATIONS
1636      * @see #GET_INSTRUMENTATION
1637      * @see #GET_PERMISSIONS
1638      * @see #GET_PROVIDERS
1639      * @see #GET_RECEIVERS
1640      * @see #GET_SERVICES
1641      * @see #GET_SIGNATURES
1642      */
getPreferredPackages(int flags)1643     public abstract List<PackageInfo> getPreferredPackages(int flags);
1644 
1645     /**
1646      * Add a new preferred activity mapping to the system.  This will be used
1647      * to automatically select the given activity component when
1648      * {@link Context#startActivity(Intent) Context.startActivity()} finds
1649      * multiple matching activities and also matches the given filter.
1650      *
1651      * @param filter The set of intents under which this activity will be
1652      * made preferred.
1653      * @param match The IntentFilter match category that this preference
1654      * applies to.
1655      * @param set The set of activities that the user was picking from when
1656      * this preference was made.
1657      * @param activity The component name of the activity that is to be
1658      * preferred.
1659      */
addPreferredActivity(IntentFilter filter, int match, ComponentName[] set, ComponentName activity)1660     public abstract void addPreferredActivity(IntentFilter filter, int match,
1661             ComponentName[] set, ComponentName activity);
1662 
1663     /**
1664      * Replaces an existing preferred activity mapping to the system, and if that were not present
1665      * adds a new preferred activity.  This will be used
1666      * to automatically select the given activity component when
1667      * {@link Context#startActivity(Intent) Context.startActivity()} finds
1668      * multiple matching activities and also matches the given filter.
1669      *
1670      * @param filter The set of intents under which this activity will be
1671      * made preferred.
1672      * @param match The IntentFilter match category that this preference
1673      * applies to.
1674      * @param set The set of activities that the user was picking from when
1675      * this preference was made.
1676      * @param activity The component name of the activity that is to be
1677      * preferred.
1678      * @hide
1679      */
replacePreferredActivity(IntentFilter filter, int match, ComponentName[] set, ComponentName activity)1680     public abstract void replacePreferredActivity(IntentFilter filter, int match,
1681             ComponentName[] set, ComponentName activity);
1682 
1683     /**
1684      * Remove all preferred activity mappings, previously added with
1685      * {@link #addPreferredActivity}, from the
1686      * system whose activities are implemented in the given package name.
1687      *
1688      * @param packageName The name of the package whose preferred activity
1689      * mappings are to be removed.
1690      */
clearPackagePreferredActivities(String packageName)1691     public abstract void clearPackagePreferredActivities(String packageName);
1692 
1693     /**
1694      * Retrieve all preferred activities, previously added with
1695      * {@link #addPreferredActivity}, that are
1696      * currently registered with the system.
1697      *
1698      * @param outFilters A list in which to place the filters of all of the
1699      * preferred activities, or null for none.
1700      * @param outActivities A list in which to place the component names of
1701      * all of the preferred activities, or null for none.
1702      * @param packageName An option package in which you would like to limit
1703      * the list.  If null, all activities will be returned; if non-null, only
1704      * those activities in the given package are returned.
1705      *
1706      * @return Returns the total number of registered preferred activities
1707      * (the number of distinct IntentFilter records, not the number of unique
1708      * activity components) that were found.
1709      */
getPreferredActivities(List<IntentFilter> outFilters, List<ComponentName> outActivities, String packageName)1710     public abstract int getPreferredActivities(List<IntentFilter> outFilters,
1711             List<ComponentName> outActivities, String packageName);
1712 
1713     /**
1714      * Set the enabled setting for a package component (activity, receiver, service, provider).
1715      * This setting will override any enabled state which may have been set by the component in its
1716      * manifest.
1717      *
1718      * @param componentName The component to enable
1719      * @param newState The new enabled state for the component.  The legal values for this state
1720      *                 are:
1721      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
1722      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
1723      *                   and
1724      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
1725      *                 The last one removes the setting, thereby restoring the component's state to
1726      *                 whatever was set in it's manifest (or enabled, by default).
1727      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
1728      */
setComponentEnabledSetting(ComponentName componentName, int newState, int flags)1729     public abstract void setComponentEnabledSetting(ComponentName componentName,
1730             int newState, int flags);
1731 
1732 
1733     /**
1734      * Return the the enabled setting for a package component (activity,
1735      * receiver, service, provider).  This returns the last value set by
1736      * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
1737      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
1738      * the value originally specified in the manifest has not been modified.
1739      *
1740      * @param componentName The component to retrieve.
1741      * @return Returns the current enabled state for the component.  May
1742      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
1743      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
1744      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
1745      * component's enabled state is based on the original information in
1746      * the manifest as found in {@link ComponentInfo}.
1747      */
getComponentEnabledSetting(ComponentName componentName)1748     public abstract int getComponentEnabledSetting(ComponentName componentName);
1749 
1750     /**
1751      * Set the enabled setting for an application
1752      * This setting will override any enabled state which may have been set by the application in
1753      * its manifest.  It also overrides the enabled state set in the manifest for any of the
1754      * application's components.  It does not override any enabled state set by
1755      * {@link #setComponentEnabledSetting} for any of the application's components.
1756      *
1757      * @param packageName The package name of the application to enable
1758      * @param newState The new enabled state for the component.  The legal values for this state
1759      *                 are:
1760      *                   {@link #COMPONENT_ENABLED_STATE_ENABLED},
1761      *                   {@link #COMPONENT_ENABLED_STATE_DISABLED}
1762      *                   and
1763      *                   {@link #COMPONENT_ENABLED_STATE_DEFAULT}
1764      *                 The last one removes the setting, thereby restoring the applications's state to
1765      *                 whatever was set in its manifest (or enabled, by default).
1766      * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
1767      */
setApplicationEnabledSetting(String packageName, int newState, int flags)1768     public abstract void setApplicationEnabledSetting(String packageName,
1769             int newState, int flags);
1770 
1771     /**
1772      * Return the the enabled setting for an application.  This returns
1773      * the last value set by
1774      * {@link #setApplicationEnabledSetting(String, int, int)}; in most
1775      * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
1776      * the value originally specified in the manifest has not been modified.
1777      *
1778      * @param packageName The component to retrieve.
1779      * @return Returns the current enabled state for the component.  May
1780      * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
1781      * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
1782      * {@link #COMPONENT_ENABLED_STATE_DEFAULT}.  The last one means the
1783      * application's enabled state is based on the original information in
1784      * the manifest as found in {@link ComponentInfo}.
1785      */
getApplicationEnabledSetting(String packageName)1786     public abstract int getApplicationEnabledSetting(String packageName);
1787 
1788     /**
1789      * Return whether the device has been booted into safe mode.
1790      */
isSafeMode()1791     public abstract boolean isSafeMode();
1792 }
1793