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