blob: bbf4ca1fc16fd0899466cfe4430636d3f2278489 [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
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -080019import android.annotation.SdkConstant;
20import android.annotation.SdkConstant.SdkConstantType;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.ComponentName;
22import android.content.Context;
23import android.content.Intent;
24import android.content.IntentFilter;
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -070025import android.content.IntentSender;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.content.res.Resources;
27import android.content.res.XmlResourceParser;
28import android.graphics.drawable.Drawable;
29import android.net.Uri;
Oscar Montemayor1228d0a2010-01-28 12:01:44 -080030import android.os.Environment;
31import android.os.StatFs;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.util.AndroidException;
33import android.util.DisplayMetrics;
34
35import java.io.File;
36import java.util.List;
37
38/**
39 * Class for retrieving various kinds of information related to the application
40 * packages that are currently installed on the device.
41 *
42 * You can find this class through {@link Context#getPackageManager}.
43 */
44public abstract class PackageManager {
45
46 /**
47 * This exception is thrown when a given package, application, or component
48 * name can not be found.
49 */
50 public static class NameNotFoundException extends AndroidException {
51 public NameNotFoundException() {
52 }
53
54 public NameNotFoundException(String name) {
55 super(name);
56 }
57 }
58
59 /**
60 * {@link PackageInfo} flag: return information about
61 * activities in the package in {@link PackageInfo#activities}.
62 */
63 public static final int GET_ACTIVITIES = 0x00000001;
64
65 /**
66 * {@link PackageInfo} flag: return information about
67 * intent receivers in the package in
68 * {@link PackageInfo#receivers}.
69 */
70 public static final int GET_RECEIVERS = 0x00000002;
71
72 /**
73 * {@link PackageInfo} flag: return information about
74 * services in the package in {@link PackageInfo#services}.
75 */
76 public static final int GET_SERVICES = 0x00000004;
77
78 /**
79 * {@link PackageInfo} flag: return information about
80 * content providers in the package in
81 * {@link PackageInfo#providers}.
82 */
83 public static final int GET_PROVIDERS = 0x00000008;
84
85 /**
86 * {@link PackageInfo} flag: return information about
87 * instrumentation in the package in
88 * {@link PackageInfo#instrumentation}.
89 */
90 public static final int GET_INSTRUMENTATION = 0x00000010;
91
92 /**
93 * {@link PackageInfo} flag: return information about the
94 * intent filters supported by the activity.
95 */
96 public static final int GET_INTENT_FILTERS = 0x00000020;
97
98 /**
99 * {@link PackageInfo} flag: return information about the
100 * signatures included in the package.
101 */
102 public static final int GET_SIGNATURES = 0x00000040;
103
104 /**
105 * {@link ResolveInfo} flag: return the IntentFilter that
106 * was matched for a particular ResolveInfo in
107 * {@link ResolveInfo#filter}.
108 */
109 public static final int GET_RESOLVED_FILTER = 0x00000040;
110
111 /**
112 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
113 * data {@link android.os.Bundle}s that are associated with a component.
114 * This applies for any API returning a ComponentInfo subclass.
115 */
116 public static final int GET_META_DATA = 0x00000080;
117
118 /**
119 * {@link PackageInfo} flag: return the
120 * {@link PackageInfo#gids group ids} that are associated with an
121 * application.
122 * This applies for any API returning an PackageInfo class, either
123 * directly or nested inside of another.
124 */
125 public static final int GET_GIDS = 0x00000100;
126
127 /**
128 * {@link PackageInfo} flag: include disabled components in the returned info.
129 */
130 public static final int GET_DISABLED_COMPONENTS = 0x00000200;
131
132 /**
133 * {@link ApplicationInfo} flag: return the
134 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries}
135 * that are associated with an application.
136 * This applies for any API returning an ApplicationInfo class, either
137 * directly or nested inside of another.
138 */
139 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400;
140
141 /**
142 * {@link ProviderInfo} flag: return the
143 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns}
144 * that are associated with a content provider.
145 * This applies for any API returning an ProviderInfo class, either
146 * directly or nested inside of another.
147 */
148 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800;
149 /**
150 * {@link PackageInfo} flag: return information about
151 * permissions in the package in
152 * {@link PackageInfo#permissions}.
153 */
154 public static final int GET_PERMISSIONS = 0x00001000;
155
156 /**
157 * Flag parameter to retrieve all applications(even uninstalled ones) with data directories.
158 * This state could have resulted if applications have been deleted with flag
159 * DONT_DELETE_DATA
160 * with a possibility of being replaced or reinstalled in future
161 */
162 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000;
163
164 /**
165 * {@link PackageInfo} flag: return information about
Dianne Hackborn49237342009-08-27 20:08:01 -0700166 * hardware preferences in
167 * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and
168 * requested features in {@link PackageInfo#reqFeatures
169 * PackageInfo.reqFeatures}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170 */
171 public static final int GET_CONFIGURATIONS = 0x00004000;
172
173 /**
Dianne Hackborn1655be42009-05-08 14:29:01 -0700174 * Resolution and querying flag: if set, only filters that support the
175 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for
176 * matching. This is a synonym for including the CATEGORY_DEFAULT in your
177 * supplied Intent.
178 */
179 public static final int MATCH_DEFAULT_ONLY = 0x00010000;
180
181 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800182 * Permission check result: this is returned by {@link #checkPermission}
183 * if the permission has been granted to the given package.
184 */
185 public static final int PERMISSION_GRANTED = 0;
186
187 /**
188 * Permission check result: this is returned by {@link #checkPermission}
189 * if the permission has not been granted to the given package.
190 */
191 public static final int PERMISSION_DENIED = -1;
192
193 /**
194 * Signature check result: this is returned by {@link #checkSignatures}
195 * if the two packages have a matching signature.
196 */
197 public static final int SIGNATURE_MATCH = 0;
198
199 /**
200 * Signature check result: this is returned by {@link #checkSignatures}
201 * if neither of the two packages is signed.
202 */
203 public static final int SIGNATURE_NEITHER_SIGNED = 1;
204
205 /**
206 * Signature check result: this is returned by {@link #checkSignatures}
207 * if the first package is not signed, but the second is.
208 */
209 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1;
210
211 /**
212 * Signature check result: this is returned by {@link #checkSignatures}
213 * if the second package is not signed, but the first is.
214 */
215 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2;
216
217 /**
218 * Signature check result: this is returned by {@link #checkSignatures}
219 * if both packages are signed but there is no matching signature.
220 */
221 public static final int SIGNATURE_NO_MATCH = -3;
222
223 /**
224 * Signature check result: this is returned by {@link #checkSignatures}
225 * if either of the given package names are not valid.
226 */
227 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4;
228
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800229 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0;
230 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1;
231 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2;
232
233 /**
234 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to
235 * indicate that this package should be installed as forward locked, i.e. only the app itself
236 * should have access to it's code and non-resource assets.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700237 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800238 */
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700239 public static final int INSTALL_FORWARD_LOCK = 0x00000001;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800240
241 /**
242 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700243 * installed package, if one exists.
244 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800245 */
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700246 public static final int INSTALL_REPLACE_EXISTING = 0x00000002;
247
248 /**
249 * Flag parameter for {@link #installPackage} to indicate that you want to
250 * allow test packages (those that have set android:testOnly in their
251 * manifest) to be installed.
252 * @hide
253 */
254 public static final int INSTALL_ALLOW_TEST = 0x00000004;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800255
256 /**
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800257 * Flag parameter for {@link #installPackage} to indicate that this
258 * package has to be installed on the sdcard.
259 * @hide
260 */
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -0800261 public static final int INSTALL_EXTERNAL = 0x00000008;
Oscar Montemayor539d3c42010-01-29 15:27:00 -0800262
263 /**
Suchi Amalapurapu14b6abd2010-03-17 08:37:04 -0700264 * Flag parameter for {@link #installPackage} to indicate that this
265 * package has to be installed on the sdcard.
266 * @hide
267 */
268 public static final int INSTALL_INTERNAL = 0x00000010;
269
270 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800271 * Flag parameter for
272 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate
273 * that you don't want to kill the app containing the component. Be careful when you set this
274 * since changing component states can make the containing application's behavior unpredictable.
275 */
276 public static final int DONT_KILL_APP = 0x00000001;
277
278 /**
279 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
280 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700281 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800282 */
283 public static final int INSTALL_SUCCEEDED = 1;
284
285 /**
286 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
287 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is
288 * already installed.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700289 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800290 */
291 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1;
292
293 /**
294 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
295 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive
296 * file is invalid.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700297 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800298 */
299 public static final int INSTALL_FAILED_INVALID_APK = -2;
300
301 /**
302 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
303 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in
304 * is invalid.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700305 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800306 */
307 public static final int INSTALL_FAILED_INVALID_URI = -3;
308
309 /**
310 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
311 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700312 * service found that the device didn't have enough storage space to install the app.
313 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800314 */
315 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4;
316
317 /**
318 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
319 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a
320 * package is already installed with the same name.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700321 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800322 */
323 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5;
324
325 /**
326 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
327 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
328 * the requested shared user does not exist.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700329 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800330 */
331 public static final int INSTALL_FAILED_NO_SHARED_USER = -6;
332
333 /**
334 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
335 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
336 * a previously installed package of the same name has a different signature
337 * than the new package (and the old package's data was not removed).
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700338 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800339 */
340 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7;
341
342 /**
343 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
344 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
345 * the new package is requested a shared user which is already installed on the
346 * device and does not have matching signature.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700347 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800348 */
349 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8;
350
351 /**
352 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
353 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
354 * the new package uses a shared library that is not available.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700355 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800356 */
357 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9;
358
359 /**
360 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
361 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
362 * the new package uses a shared library that is not available.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700363 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800364 */
365 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10;
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 while optimizing and validating its dex files,
371 * either because there was not enough storage or the validation failed.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700372 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800373 */
374 public static final int INSTALL_FAILED_DEXOPT = -11;
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 older than
380 * that required by the package.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700381 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800382 */
383 public static final int INSTALL_FAILED_OLDER_SDK = -12;
384
385 /**
The Android Open Source Project10592532009-03-18 17:39:46 -0700386 * 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 contains a content provider with the
389 * same authority as a provider already installed in the system.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700390 * @hide
The Android Open Source Project10592532009-03-18 17:39:46 -0700391 */
392 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13;
393
394 /**
Dianne Hackborn851a5412009-05-08 12:06:44 -0700395 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
396 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
397 * the new package failed because the current SDK version is newer than
398 * that required by the package.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700399 * @hide
Dianne Hackborn851a5412009-05-08 12:06:44 -0700400 */
401 public static final int INSTALL_FAILED_NEWER_SDK = -14;
402
403 /**
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700404 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
405 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
406 * the new package failed because it has specified that it is a test-only
407 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST}
408 * flag.
409 * @hide
410 */
411 public static final int INSTALL_FAILED_TEST_ONLY = -15;
412
413 /**
Dianne Hackbornb1811182009-05-21 15:45:42 -0700414 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
415 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
416 * the package being installed contains native code, but none that is
417 * compatible with the the device's CPU_ABI.
418 * @hide
419 */
420 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16;
421
422 /**
Dianne Hackborn49237342009-08-27 20:08:01 -0700423 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
424 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
425 * the new package uses a feature that is not available.
426 * @hide
427 */
428 public static final int INSTALL_FAILED_MISSING_FEATURE = -17;
429
Suchi Amalapurapuaf8e9f42010-01-12 10:17:28 -0800430 // ------ Errors related to sdcard
431 /**
432 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
433 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
434 * a secure container mount point couldn't be accessed on external media.
435 * @hide
436 */
437 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18;
438
Dianne Hackborn49237342009-08-27 20:08:01 -0700439 /**
Suchi Amalapurapub56ae202010-02-04 22:51:07 -0800440 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
441 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
442 * the new package couldn't be installed in the specified install
443 * location.
444 * @hide
445 */
446 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19;
447
448 /**
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -0800449 * Installation return code: this is passed to the {@link IPackageInstallObserver} by
450 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if
451 * the new package couldn't be installed in the specified install
452 * location because the media is not available.
453 * @hide
454 */
455 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20;
456
457 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800458 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
459 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
460 * if the parser was given a path that is not a file, or does not end with the expected
461 * '.apk' extension.
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_NOT_APK = -100;
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 was unable to retrieve the AndroidManifest.xml file.
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_BAD_MANIFEST = -101;
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 encountered an unexpected exception.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700478 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800479 */
480 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102;
481
482 /**
483 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
484 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
485 * if the parser did not find any certificates in the .apk.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700486 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800487 */
488 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103;
489
490 /**
491 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
492 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
493 * if the parser found inconsistent certificates on the files in the .apk.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700494 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800495 */
496 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104;
497
498 /**
499 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
500 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
501 * if the parser encountered a CertificateEncodingException in one of the
502 * files in the .apk.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700503 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800504 */
505 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105;
506
507 /**
508 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
509 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
510 * if the parser encountered a bad or missing package name in the manifest.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700511 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800512 */
513 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106;
514
515 /**
516 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
517 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
518 * if the parser encountered a bad shared user id name in the manifest.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700519 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800520 */
521 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107;
522
523 /**
524 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
525 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
526 * if the parser encountered some structural problem in the manifest.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700527 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800528 */
529 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108;
530
531 /**
532 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by
533 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
534 * if the parser did not find any actionable tags (instrumentation or application)
535 * in the manifest.
Dianne Hackbornade3eca2009-05-11 18:54:45 -0700536 * @hide
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800537 */
538 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109;
539
540 /**
Suchi Amalapurapu5b993ce2010-02-12 09:43:29 -0800541 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by
542 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)}
543 * if the system failed to install the package because of system issues.
544 * @hide
545 */
546 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110;
547
548 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the
550 * package's data directory.
551 *
552 * @hide
553 */
554 public static final int DONT_DELETE_DATA = 0x00000001;
555
556 /**
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -0800557 * Return code that is passed to the {@link IPackageMoveObserver} by
558 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
559 * when the package has been successfully moved by the system.
560 * @hide
561 */
562 public static final int MOVE_SUCCEEDED = 1;
563 /**
564 * Error code that is passed to the {@link IPackageMoveObserver} by
565 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
566 * when the package hasn't been successfully moved by the system
567 * because of insufficient memory on specified media.
568 * @hide
569 */
570 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1;
571
572 /**
573 * Error code that is passed to the {@link IPackageMoveObserver} by
574 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
575 * if the specified package doesn't exist.
576 * @hide
577 */
578 public static final int MOVE_FAILED_DOESNT_EXIST = -2;
579
580 /**
581 * Error code that is passed to the {@link IPackageMoveObserver} by
582 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
583 * if the specified package cannot be moved since its a system package.
584 * @hide
585 */
586 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3;
587
588 /**
589 * Error code that is passed to the {@link IPackageMoveObserver} by
590 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
591 * if the specified package cannot be moved since its forward locked.
592 * @hide
593 */
594 public static final int MOVE_FAILED_FORWARD_LOCKED = -4;
595
596 /**
597 * Error code that is passed to the {@link IPackageMoveObserver} by
598 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
599 * if the specified package cannot be moved to the specified location.
600 * @hide
601 */
602 public static final int MOVE_FAILED_INVALID_LOCATION = -5;
603
604 /**
Suchi Amalapurapu8a9ab242010-03-11 16:49:16 -0800605 * Error code that is passed to the {@link IPackageMoveObserver} by
606 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)}
607 * if the specified package cannot be moved to the specified location.
608 * @hide
609 */
610 public static final int MOVE_FAILED_INTERNAL_ERROR = -6;
611
612 /**
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -0800613 * Flag parameter for {@link #movePackage} to indicate that
614 * the package should be moved to internal storage if its
615 * been installed on external media.
616 * @hide
617 */
618 public static final int MOVE_INTERNAL = 0x00000001;
619
620 /**
621 * Flag parameter for {@link #movePackage} to indicate that
622 * the package should be moved to external media.
623 * @hide
624 */
625 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002;
626
627 /**
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800628 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -0800629 * {@link #hasSystemFeature}: The device is capable of communicating with
630 * other devices via Bluetooth.
631 */
632 @SdkConstant(SdkConstantType.FEATURE)
633 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
634
635 /**
636 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800637 * {@link #hasSystemFeature}: The device has a camera facing away
638 * from the screen.
639 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800640 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800641 public static final String FEATURE_CAMERA = "android.hardware.camera";
Dan Morrill50ab63f2010-03-05 16:16:19 -0800642
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800643 /**
644 * Feature for {@link #getSystemAvailableFeatures} and
645 * {@link #hasSystemFeature}: The device's camera supports auto-focus.
646 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800647 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800648 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus";
Dan Morrill50ab63f2010-03-05 16:16:19 -0800649
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800650 /**
651 * Feature for {@link #getSystemAvailableFeatures} and
652 * {@link #hasSystemFeature}: The device's camera supports flash.
653 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800654 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800655 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash";
Dan Morrill50ab63f2010-03-05 16:16:19 -0800656
657 /**
658 * Feature for {@link #getSystemAvailableFeatures} and
659 * {@link #hasSystemFeature}: The device supports one or more methods of
660 * reporting current location.
661 */
662 @SdkConstant(SdkConstantType.FEATURE)
663 public static final String FEATURE_LOCATION = "android.hardware.location";
664
665 /**
666 * Feature for {@link #getSystemAvailableFeatures} and
667 * {@link #hasSystemFeature}: The device has a Global Positioning System
668 * receiver and can report precise location.
669 */
670 @SdkConstant(SdkConstantType.FEATURE)
671 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps";
672
673 /**
674 * Feature for {@link #getSystemAvailableFeatures} and
675 * {@link #hasSystemFeature}: The device can report location with coarse
676 * accuracy using a network-based geolocation system.
677 */
678 @SdkConstant(SdkConstantType.FEATURE)
679 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network";
680
681 /**
682 * Feature for {@link #getSystemAvailableFeatures} and
683 * {@link #hasSystemFeature}: The device can record audio via a
684 * microphone.
685 */
686 @SdkConstant(SdkConstantType.FEATURE)
687 public static final String FEATURE_MICROPHONE = "android.hardware.microphone";
688
689 /**
690 * Feature for {@link #getSystemAvailableFeatures} and
691 * {@link #hasSystemFeature}: The device includes a magnetometer (compass).
692 */
693 @SdkConstant(SdkConstantType.FEATURE)
694 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass";
695
696 /**
697 * Feature for {@link #getSystemAvailableFeatures} and
698 * {@link #hasSystemFeature}: The device includes an accelerometer.
699 */
700 @SdkConstant(SdkConstantType.FEATURE)
701 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer";
702
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800703 /**
704 * Feature for {@link #getSystemAvailableFeatures} and
705 * {@link #hasSystemFeature}: The device includes a light sensor.
706 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800707 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800708 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light";
Dan Morrill50ab63f2010-03-05 16:16:19 -0800709
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800710 /**
711 * Feature for {@link #getSystemAvailableFeatures} and
712 * {@link #hasSystemFeature}: The device includes a proximity sensor.
713 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800714 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800715 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity";
716
717 /**
718 * Feature for {@link #getSystemAvailableFeatures} and
719 * {@link #hasSystemFeature}: The device has a telephony radio with data
720 * communication support.
721 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800722 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800723 public static final String FEATURE_TELEPHONY = "android.hardware.telephony";
724
725 /**
726 * Feature for {@link #getSystemAvailableFeatures} and
727 * {@link #hasSystemFeature}: The device has a CDMA telephony stack.
728 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800729 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800730 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma";
731
732 /**
733 * Feature for {@link #getSystemAvailableFeatures} and
734 * {@link #hasSystemFeature}: The device has a GSM telephony stack.
735 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800736 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800737 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm";
738
739 /**
740 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -0800741 * {@link #hasSystemFeature}: The device's touch screen supports
742 * multitouch sufficient for basic two-finger gesture detection.
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800743 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800744 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800745 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch";
746
747 /**
748 * Feature for {@link #getSystemAvailableFeatures} and
Dan Morrill50ab63f2010-03-05 16:16:19 -0800749 * {@link #hasSystemFeature}: The device's touch screen is capable of
750 * tracking two or more fingers fully independently.
751 */
752 @SdkConstant(SdkConstantType.FEATURE)
753 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct";
754
755 /**
756 * Feature for {@link #getSystemAvailableFeatures} and
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800757 * {@link #hasSystemFeature}: The device supports live wallpapers.
758 */
Xavier Ducrohet3274b9b2009-12-14 17:52:20 -0800759 @SdkConstant(SdkConstantType.FEATURE)
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800760 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper";
Oscar Montemayor1228d0a2010-01-28 12:01:44 -0800761
Oscar Montemayor1228d0a2010-01-28 12:01:44 -0800762 /**
Dan Morrill50ab63f2010-03-05 16:16:19 -0800763 * Feature for {@link #getSystemAvailableFeatures} and
764 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking.
765 */
766 @SdkConstant(SdkConstantType.FEATURE)
767 public static final String FEATURE_WIFI = "android.hardware.wifi";
768
769 /**
Dianne Hackborne83cefce2010-02-04 17:38:14 -0800770 * Action to external storage service to clean out removed apps.
771 * @hide
772 */
773 public static final String ACTION_CLEAN_EXTERNAL_STORAGE
774 = "android.content.pm.CLEAN_EXTERNAL_STORAGE";
Oscar Montemayor1228d0a2010-01-28 12:01:44 -0800775
Dianne Hackborn08ee42c2009-11-19 17:08:01 -0800776 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800777 * Retrieve overall information about an application package that is
778 * installed on the system.
779 *
780 * <p>Throws {@link NameNotFoundException} if a package with the given
781 * name can not be found on the system.
782 *
783 * @param packageName The full name (i.e. com.google.apps.contacts) of the
784 * desired package.
785
786 * @param flags Additional option flags. Use any combination of
787 * {@link #GET_ACTIVITIES},
788 * {@link #GET_GIDS},
789 * {@link #GET_CONFIGURATIONS},
790 * {@link #GET_INSTRUMENTATION},
791 * {@link #GET_PERMISSIONS},
792 * {@link #GET_PROVIDERS},
793 * {@link #GET_RECEIVERS},
794 * {@link #GET_SERVICES},
795 * {@link #GET_SIGNATURES},
796 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
797 *
798 * @return Returns a PackageInfo object containing information about the package.
799 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not
800 * found in the list of installed applications, the package information is
801 * retrieved from the list of uninstalled applications(which includes
802 * installed applications as well as applications
803 * with data directory ie applications which had been
804 * deleted with DONT_DELTE_DATA flag set).
805 *
806 * @see #GET_ACTIVITIES
807 * @see #GET_GIDS
808 * @see #GET_CONFIGURATIONS
809 * @see #GET_INSTRUMENTATION
810 * @see #GET_PERMISSIONS
811 * @see #GET_PROVIDERS
812 * @see #GET_RECEIVERS
813 * @see #GET_SERVICES
814 * @see #GET_SIGNATURES
815 * @see #GET_UNINSTALLED_PACKAGES
816 *
817 */
818 public abstract PackageInfo getPackageInfo(String packageName, int flags)
819 throws NameNotFoundException;
820
821 /**
Dianne Hackborn47096932010-02-11 15:57:09 -0800822 * Map from the current package names in use on the device to whatever
823 * the current canonical name of that package is.
824 * @param names Array of current names to be mapped.
825 * @return Returns an array of the same size as the original, containing
826 * the canonical name for each package.
827 */
828 public abstract String[] currentToCanonicalPackageNames(String[] names);
829
830 /**
831 * Map from a packages canonical name to the current name in use on the device.
832 * @param names Array of new names to be mapped.
833 * @return Returns an array of the same size as the original, containing
834 * the current name for each package.
835 */
836 public abstract String[] canonicalToCurrentPackageNames(String[] names);
837
838 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800839 * Return a "good" intent to launch a front-door activity in a package,
840 * for use for example to implement an "open" button when browsing through
841 * packages. The current implementation will look first for a main
842 * activity in the category {@link Intent#CATEGORY_INFO}, next for a
843 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return
844 * null if neither are found.
845 *
846 * <p>Throws {@link NameNotFoundException} if a package with the given
847 * name can not be found on the system.
848 *
849 * @param packageName The name of the package to inspect.
850 *
851 * @return Returns either a fully-qualified Intent that can be used to
852 * launch the main activity in the package, or null if the package does
853 * not contain such an activity.
854 */
Mihai Predaeae850c2009-05-13 10:13:48 +0200855 public abstract Intent getLaunchIntentForPackage(String packageName);
856
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800857 /**
858 * Return an array of all of the secondary group-ids that have been
859 * assigned to a package.
860 *
861 * <p>Throws {@link NameNotFoundException} if a package with the given
862 * name can not be found on the system.
863 *
864 * @param packageName The full name (i.e. com.google.apps.contacts) of the
865 * desired package.
866 *
867 * @return Returns an int array of the assigned gids, or null if there
868 * are none.
869 */
870 public abstract int[] getPackageGids(String packageName)
871 throws NameNotFoundException;
872
873 /**
874 * Retrieve all of the information we know about a particular permission.
875 *
876 * <p>Throws {@link NameNotFoundException} if a permission with the given
877 * name can not be found on the system.
878 *
879 * @param name The fully qualified name (i.e. com.google.permission.LOGIN)
880 * of the permission you are interested in.
881 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
882 * retrieve any meta-data associated with the permission.
883 *
884 * @return Returns a {@link PermissionInfo} containing information about the
885 * permission.
886 */
887 public abstract PermissionInfo getPermissionInfo(String name, int flags)
888 throws NameNotFoundException;
889
890 /**
891 * Query for all of the permissions associated with a particular group.
892 *
893 * <p>Throws {@link NameNotFoundException} if the given group does not
894 * exist.
895 *
896 * @param group The fully qualified name (i.e. com.google.permission.LOGIN)
897 * of the permission group you are interested in. Use null to
898 * find all of the permissions not associated with a group.
899 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
900 * retrieve any meta-data associated with the permissions.
901 *
902 * @return Returns a list of {@link PermissionInfo} containing information
903 * about all of the permissions in the given group.
904 */
905 public abstract List<PermissionInfo> queryPermissionsByGroup(String group,
906 int flags) throws NameNotFoundException;
907
908 /**
909 * Retrieve all of the information we know about a particular group of
910 * permissions.
911 *
912 * <p>Throws {@link NameNotFoundException} if a permission group with the given
913 * name can not be found on the system.
914 *
915 * @param name The fully qualified name (i.e. com.google.permission_group.APPS)
916 * of the permission you are interested in.
917 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
918 * retrieve any meta-data associated with the permission group.
919 *
920 * @return Returns a {@link PermissionGroupInfo} containing information
921 * about the permission.
922 */
923 public abstract PermissionGroupInfo getPermissionGroupInfo(String name,
924 int flags) throws NameNotFoundException;
925
926 /**
927 * Retrieve all of the known permission groups in the system.
928 *
929 * @param flags Additional option flags. Use {@link #GET_META_DATA} to
930 * retrieve any meta-data associated with the permission group.
931 *
932 * @return Returns a list of {@link PermissionGroupInfo} containing
933 * information about all of the known permission groups.
934 */
935 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags);
936
937 /**
938 * Retrieve all of the information we know about a particular
939 * package/application.
940 *
941 * <p>Throws {@link NameNotFoundException} if an application with the given
942 * package name can not be found on the system.
943 *
944 * @param packageName The full name (i.e. com.google.apps.contacts) of an
945 * application.
946 * @param flags Additional option flags. Use any combination of
947 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
948 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
949 *
950 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing
951 * information about the package.
952 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not
953 * found in the list of installed applications,
954 * the application information is retrieved from the
955 * list of uninstalled applications(which includes
956 * installed applications as well as applications
957 * with data directory ie applications which had been
958 * deleted with DONT_DELTE_DATA flag set).
959 *
960 * @see #GET_META_DATA
961 * @see #GET_SHARED_LIBRARY_FILES
962 * @see #GET_UNINSTALLED_PACKAGES
963 */
964 public abstract ApplicationInfo getApplicationInfo(String packageName,
965 int flags) throws NameNotFoundException;
966
967 /**
968 * Retrieve all of the information we know about a particular activity
969 * class.
970 *
971 * <p>Throws {@link NameNotFoundException} if an activity with the given
972 * class name can not be found on the system.
973 *
974 * @param className The full name (i.e.
975 * com.google.apps.contacts.ContactsList) of an Activity
976 * class.
977 * @param flags Additional option flags. Use any combination of
978 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
979 * to modify the data (in ApplicationInfo) returned.
980 *
981 * @return {@link ActivityInfo} containing information about the activity.
982 *
983 * @see #GET_INTENT_FILTERS
984 * @see #GET_META_DATA
985 * @see #GET_SHARED_LIBRARY_FILES
986 */
987 public abstract ActivityInfo getActivityInfo(ComponentName className,
988 int flags) throws NameNotFoundException;
989
990 /**
991 * Retrieve all of the information we know about a particular receiver
992 * class.
993 *
994 * <p>Throws {@link NameNotFoundException} if a receiver with the given
995 * class name can not be found on the system.
996 *
997 * @param className The full name (i.e.
998 * com.google.apps.contacts.CalendarAlarm) of a Receiver
999 * class.
1000 * @param flags Additional option flags. Use any combination of
1001 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1002 * to modify the data returned.
1003 *
1004 * @return {@link ActivityInfo} containing information about the receiver.
1005 *
1006 * @see #GET_INTENT_FILTERS
1007 * @see #GET_META_DATA
1008 * @see #GET_SHARED_LIBRARY_FILES
1009 */
1010 public abstract ActivityInfo getReceiverInfo(ComponentName className,
1011 int flags) throws NameNotFoundException;
1012
1013 /**
1014 * Retrieve all of the information we know about a particular service
1015 * class.
1016 *
1017 * <p>Throws {@link NameNotFoundException} if a service with the given
1018 * class name can not be found on the system.
1019 *
1020 * @param className The full name (i.e.
1021 * com.google.apps.media.BackgroundPlayback) of a Service
1022 * class.
1023 * @param flags Additional option flags. Use any combination of
1024 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1025 * to modify the data returned.
1026 *
1027 * @return ServiceInfo containing information about the service.
1028 *
1029 * @see #GET_META_DATA
1030 * @see #GET_SHARED_LIBRARY_FILES
1031 */
1032 public abstract ServiceInfo getServiceInfo(ComponentName className,
1033 int flags) throws NameNotFoundException;
1034
1035 /**
1036 * Return a List of all packages that are installed
1037 * on the device.
1038 *
1039 * @param flags Additional option flags. Use any combination of
1040 * {@link #GET_ACTIVITIES},
1041 * {@link #GET_GIDS},
1042 * {@link #GET_CONFIGURATIONS},
1043 * {@link #GET_INSTRUMENTATION},
1044 * {@link #GET_PERMISSIONS},
1045 * {@link #GET_PROVIDERS},
1046 * {@link #GET_RECEIVERS},
1047 * {@link #GET_SERVICES},
1048 * {@link #GET_SIGNATURES},
1049 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1050 *
1051 * @return A List of PackageInfo objects, one for each package that is
1052 * installed on the device. In the unlikely case of there being no
1053 * installed packages, an empty list is returned.
1054 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1055 * applications including those deleted with DONT_DELETE_DATA
1056 * (partially installed apps with data directory) will be returned.
1057 *
1058 * @see #GET_ACTIVITIES
1059 * @see #GET_GIDS
1060 * @see #GET_CONFIGURATIONS
1061 * @see #GET_INSTRUMENTATION
1062 * @see #GET_PERMISSIONS
1063 * @see #GET_PROVIDERS
1064 * @see #GET_RECEIVERS
1065 * @see #GET_SERVICES
1066 * @see #GET_SIGNATURES
1067 * @see #GET_UNINSTALLED_PACKAGES
1068 *
1069 */
1070 public abstract List<PackageInfo> getInstalledPackages(int flags);
1071
1072 /**
1073 * Check whether a particular package has been granted a particular
1074 * permission.
1075 *
1076 * @param permName The name of the permission you are checking for,
1077 * @param pkgName The name of the package you are checking against.
1078 *
1079 * @return If the package has the permission, PERMISSION_GRANTED is
1080 * returned. If it does not have the permission, PERMISSION_DENIED
1081 * is returned.
1082 *
1083 * @see #PERMISSION_GRANTED
1084 * @see #PERMISSION_DENIED
1085 */
1086 public abstract int checkPermission(String permName, String pkgName);
1087
1088 /**
1089 * Add a new dynamic permission to the system. For this to work, your
1090 * package must have defined a permission tree through the
1091 * {@link android.R.styleable#AndroidManifestPermissionTree
1092 * &lt;permission-tree&gt;} tag in its manifest. A package can only add
1093 * permissions to trees that were defined by either its own package or
1094 * another with the same user id; a permission is in a tree if it
1095 * matches the name of the permission tree + ".": for example,
1096 * "com.foo.bar" is a member of the permission tree "com.foo".
1097 *
1098 * <p>It is good to make your permission tree name descriptive, because you
1099 * are taking possession of that entire set of permission names. Thus, it
1100 * must be under a domain you control, with a suffix that will not match
1101 * any normal permissions that may be declared in any applications that
1102 * are part of that domain.
1103 *
1104 * <p>New permissions must be added before
1105 * any .apks are installed that use those permissions. Permissions you
1106 * add through this method are remembered across reboots of the device.
1107 * If the given permission already exists, the info you supply here
1108 * will be used to update it.
1109 *
1110 * @param info Description of the permission to be added.
1111 *
1112 * @return Returns true if a new permission was created, false if an
1113 * existing one was updated.
1114 *
1115 * @throws SecurityException if you are not allowed to add the
1116 * given permission name.
1117 *
1118 * @see #removePermission(String)
1119 */
1120 public abstract boolean addPermission(PermissionInfo info);
1121
1122 /**
1123 * Removes a permission that was previously added with
1124 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply
1125 * -- you are only allowed to remove permissions that you are allowed
1126 * to add.
1127 *
1128 * @param name The name of the permission to remove.
1129 *
1130 * @throws SecurityException if you are not allowed to remove the
1131 * given permission name.
1132 *
1133 * @see #addPermission(PermissionInfo)
1134 */
1135 public abstract void removePermission(String name);
1136
1137 /**
1138 * Compare the signatures of two packages to determine if the same
1139 * signature appears in both of them. If they do contain the same
1140 * signature, then they are allowed special privileges when working
1141 * with each other: they can share the same user-id, run instrumentation
1142 * against each other, etc.
1143 *
1144 * @param pkg1 First package name whose signature will be compared.
1145 * @param pkg2 Second package name whose signature will be compared.
1146 * @return Returns an integer indicating whether there is a matching
1147 * signature: the value is >= 0 if there is a match (or neither package
1148 * is signed), or < 0 if there is not a match. The match result can be
1149 * further distinguished with the success (>= 0) constants
1150 * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or
1151 * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED},
1152 * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH},
1153 * or {@link #SIGNATURE_UNKNOWN_PACKAGE}.
1154 *
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07001155 * @see #checkSignatures(int, int)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001156 * @see #SIGNATURE_MATCH
1157 * @see #SIGNATURE_NEITHER_SIGNED
1158 * @see #SIGNATURE_FIRST_NOT_SIGNED
1159 * @see #SIGNATURE_SECOND_NOT_SIGNED
1160 * @see #SIGNATURE_NO_MATCH
1161 * @see #SIGNATURE_UNKNOWN_PACKAGE
1162 */
1163 public abstract int checkSignatures(String pkg1, String pkg2);
1164
1165 /**
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07001166 * Like {@link #checkSignatures(String, String)}, but takes UIDs of
1167 * the two packages to be checked. This can be useful, for example,
1168 * when doing the check in an IPC, where the UID is the only identity
1169 * available. It is functionally identical to determining the package
1170 * associated with the UIDs and checking their signatures.
1171 *
Joe Onorato25660ec2009-08-12 22:40:37 -07001172 * @param uid1 First UID whose signature will be compared.
1173 * @param uid2 Second UID whose signature will be compared.
Dianne Hackborn766cbfe2009-08-12 18:33:39 -07001174 * @return Returns an integer indicating whether there is a matching
1175 * signature: the value is >= 0 if there is a match (or neither package
1176 * is signed), or < 0 if there is not a match. The match result can be
1177 * further distinguished with the success (>= 0) constants
1178 * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or
1179 * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED},
1180 * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH},
1181 * or {@link #SIGNATURE_UNKNOWN_PACKAGE}.
1182 *
1183 * @see #checkSignatures(int, int)
1184 * @see #SIGNATURE_MATCH
1185 * @see #SIGNATURE_NEITHER_SIGNED
1186 * @see #SIGNATURE_FIRST_NOT_SIGNED
1187 * @see #SIGNATURE_SECOND_NOT_SIGNED
1188 * @see #SIGNATURE_NO_MATCH
1189 * @see #SIGNATURE_UNKNOWN_PACKAGE
1190 */
1191 public abstract int checkSignatures(int uid1, int uid2);
1192
1193 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001194 * Retrieve the names of all packages that are associated with a particular
1195 * user id. In most cases, this will be a single package name, the package
1196 * that has been assigned that user id. Where there are multiple packages
1197 * sharing the same user id through the "sharedUserId" mechanism, all
1198 * packages with that id will be returned.
1199 *
1200 * @param uid The user id for which you would like to retrieve the
1201 * associated packages.
1202 *
1203 * @return Returns an array of one or more packages assigned to the user
1204 * id, or null if there are no known packages with the given id.
1205 */
1206 public abstract String[] getPackagesForUid(int uid);
1207
1208 /**
1209 * Retrieve the official name associated with a user id. This name is
1210 * guaranteed to never change, though it is possibly for the underlying
1211 * user id to be changed. That is, if you are storing information about
1212 * user ids in persistent storage, you should use the string returned
1213 * by this function instead of the raw user-id.
1214 *
1215 * @param uid The user id for which you would like to retrieve a name.
1216 * @return Returns a unique name for the given user id, or null if the
1217 * user id is not currently assigned.
1218 */
1219 public abstract String getNameForUid(int uid);
1220
1221 /**
1222 * Return the user id associated with a shared user name. Multiple
1223 * applications can specify a shared user name in their manifest and thus
1224 * end up using a common uid. This might be used for new applications
1225 * that use an existing shared user name and need to know the uid of the
1226 * shared user.
1227 *
1228 * @param sharedUserName The shared user name whose uid is to be retrieved.
1229 * @return Returns the uid associated with the shared user, or NameNotFoundException
1230 * if the shared user name is not being used by any installed packages
1231 * @hide
1232 */
1233 public abstract int getUidForSharedUser(String sharedUserName)
1234 throws NameNotFoundException;
1235
1236 /**
1237 * Return a List of all application packages that are installed on the
1238 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all
1239 * applications including those deleted with DONT_DELETE_DATA(partially
1240 * installed apps with data directory) will be returned.
1241 *
1242 * @param flags Additional option flags. Use any combination of
1243 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES},
1244 * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
1245 *
1246 * @return A List of ApplicationInfo objects, one for each application that
1247 * is installed on the device. In the unlikely case of there being
1248 * no installed applications, an empty list is returned.
1249 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
1250 * applications including those deleted with DONT_DELETE_DATA
1251 * (partially installed apps with data directory) will be returned.
1252 *
1253 * @see #GET_META_DATA
1254 * @see #GET_SHARED_LIBRARY_FILES
1255 * @see #GET_UNINSTALLED_PACKAGES
1256 */
1257 public abstract List<ApplicationInfo> getInstalledApplications(int flags);
1258
1259 /**
1260 * Get a list of shared libraries that are available on the
1261 * system.
1262 *
1263 * @return An array of shared library names that are
1264 * available on the system, or null if none are installed.
1265 *
1266 */
1267 public abstract String[] getSystemSharedLibraryNames();
1268
1269 /**
Dianne Hackborn49237342009-08-27 20:08:01 -07001270 * Get a list of features that are available on the
1271 * system.
1272 *
1273 * @return An array of FeatureInfo classes describing the features
1274 * that are available on the system, or null if there are none(!!).
Dianne Hackborn49237342009-08-27 20:08:01 -07001275 */
1276 public abstract FeatureInfo[] getSystemAvailableFeatures();
1277
1278 /**
Dianne Hackborn039c68e2009-09-26 16:39:23 -07001279 * Check whether the given feature name is one of the available
1280 * features as returned by {@link #getSystemAvailableFeatures()}.
1281 *
1282 * @return Returns true if the devices supports the feature, else
1283 * false.
1284 */
1285 public abstract boolean hasSystemFeature(String name);
1286
1287 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001288 * Determine the best action to perform for a given Intent. This is how
1289 * {@link Intent#resolveActivity} finds an activity if a class has not
1290 * been explicitly specified.
1291 *
1292 * @param intent An intent containing all of the desired specification
1293 * (action, data, type, category, and/or component).
1294 * @param flags Additional option flags. The most important is
1295 * MATCH_DEFAULT_ONLY, to limit the resolution to only
1296 * those activities that support the CATEGORY_DEFAULT.
1297 *
1298 * @return Returns a ResolveInfo containing the final activity intent that
1299 * was determined to be the best action. Returns null if no
Mike LeBeaubd3f5272010-02-18 19:27:17 -08001300 * matching activity was found. If multiple matching activities are
1301 * found and there is no default set, returns a ResolveInfo
1302 * containing something else, such as the activity resolver.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001303 *
1304 * @see #MATCH_DEFAULT_ONLY
1305 * @see #GET_INTENT_FILTERS
1306 * @see #GET_RESOLVED_FILTER
1307 */
1308 public abstract ResolveInfo resolveActivity(Intent intent, int flags);
1309
1310 /**
1311 * Retrieve all activities that can be performed for the given intent.
1312 *
1313 * @param intent The desired intent as per resolveActivity().
1314 * @param flags Additional option flags. The most important is
1315 * MATCH_DEFAULT_ONLY, to limit the resolution to only
1316 * those activities that support the CATEGORY_DEFAULT.
1317 *
1318 * @return A List<ResolveInfo> containing one entry for each matching
1319 * Activity. These are ordered from best to worst match -- that
1320 * is, the first item in the list is what is returned by
1321 * resolveActivity(). If there are no matching activities, an empty
1322 * list is returned.
1323 *
1324 * @see #MATCH_DEFAULT_ONLY
1325 * @see #GET_INTENT_FILTERS
1326 * @see #GET_RESOLVED_FILTER
1327 */
1328 public abstract List<ResolveInfo> queryIntentActivities(Intent intent,
1329 int flags);
1330
1331 /**
1332 * Retrieve a set of activities that should be presented to the user as
1333 * similar options. This is like {@link #queryIntentActivities}, except it
1334 * also allows you to supply a list of more explicit Intents that you would
1335 * like to resolve to particular options, and takes care of returning the
1336 * final ResolveInfo list in a reasonable order, with no duplicates, based
1337 * on those inputs.
1338 *
1339 * @param caller The class name of the activity that is making the
1340 * request. This activity will never appear in the output
1341 * list. Can be null.
1342 * @param specifics An array of Intents that should be resolved to the
1343 * first specific results. Can be null.
1344 * @param intent The desired intent as per resolveActivity().
1345 * @param flags Additional option flags. The most important is
1346 * MATCH_DEFAULT_ONLY, to limit the resolution to only
1347 * those activities that support the CATEGORY_DEFAULT.
1348 *
1349 * @return A List<ResolveInfo> containing one entry for each matching
1350 * Activity. These are ordered first by all of the intents resolved
1351 * in <var>specifics</var> and then any additional activities that
1352 * can handle <var>intent</var> but did not get included by one of
1353 * the <var>specifics</var> intents. If there are no matching
1354 * activities, an empty list is returned.
1355 *
1356 * @see #MATCH_DEFAULT_ONLY
1357 * @see #GET_INTENT_FILTERS
1358 * @see #GET_RESOLVED_FILTER
1359 */
1360 public abstract List<ResolveInfo> queryIntentActivityOptions(
1361 ComponentName caller, Intent[] specifics, Intent intent, int flags);
1362
1363 /**
1364 * Retrieve all receivers that can handle a broadcast of the given intent.
1365 *
1366 * @param intent The desired intent as per resolveActivity().
1367 * @param flags Additional option flags. The most important is
1368 * MATCH_DEFAULT_ONLY, to limit the resolution to only
1369 * those activities that support the CATEGORY_DEFAULT.
1370 *
1371 * @return A List<ResolveInfo> containing one entry for each matching
1372 * Receiver. These are ordered from first to last in priority. If
1373 * there are no matching receivers, an empty list is returned.
1374 *
1375 * @see #MATCH_DEFAULT_ONLY
1376 * @see #GET_INTENT_FILTERS
1377 * @see #GET_RESOLVED_FILTER
1378 */
1379 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent,
1380 int flags);
1381
1382 /**
1383 * Determine the best service to handle for a given Intent.
1384 *
1385 * @param intent An intent containing all of the desired specification
1386 * (action, data, type, category, and/or component).
1387 * @param flags Additional option flags.
1388 *
1389 * @return Returns a ResolveInfo containing the final service intent that
1390 * was determined to be the best action. Returns null if no
1391 * matching service was found.
1392 *
1393 * @see #GET_INTENT_FILTERS
1394 * @see #GET_RESOLVED_FILTER
1395 */
1396 public abstract ResolveInfo resolveService(Intent intent, int flags);
1397
1398 /**
1399 * Retrieve all services that can match the given intent.
1400 *
1401 * @param intent The desired intent as per resolveService().
1402 * @param flags Additional option flags.
1403 *
1404 * @return A List<ResolveInfo> containing one entry for each matching
1405 * ServiceInfo. These are ordered from best to worst match -- that
1406 * is, the first item in the list is what is returned by
1407 * resolveService(). If there are no matching services, an empty
1408 * list is returned.
1409 *
1410 * @see #GET_INTENT_FILTERS
1411 * @see #GET_RESOLVED_FILTER
1412 */
1413 public abstract List<ResolveInfo> queryIntentServices(Intent intent,
1414 int flags);
1415
1416 /**
1417 * Find a single content provider by its base path name.
1418 *
1419 * @param name The name of the provider to find.
1420 * @param flags Additional option flags. Currently should always be 0.
1421 *
1422 * @return ContentProviderInfo Information about the provider, if found,
1423 * else null.
1424 */
1425 public abstract ProviderInfo resolveContentProvider(String name,
1426 int flags);
1427
1428 /**
1429 * Retrieve content provider information.
1430 *
1431 * <p><em>Note: unlike most other methods, an empty result set is indicated
1432 * by a null return instead of an empty list.</em>
1433 *
1434 * @param processName If non-null, limits the returned providers to only
1435 * those that are hosted by the given process. If null,
1436 * all content providers are returned.
1437 * @param uid If <var>processName</var> is non-null, this is the required
1438 * uid owning the requested content providers.
1439 * @param flags Additional option flags. Currently should always be 0.
1440 *
1441 * @return A List<ContentProviderInfo> containing one entry for each
1442 * content provider either patching <var>processName</var> or, if
1443 * <var>processName</var> is null, all known content providers.
1444 * <em>If there are no matching providers, null is returned.</em>
1445 */
1446 public abstract List<ProviderInfo> queryContentProviders(
1447 String processName, int uid, int flags);
1448
1449 /**
1450 * Retrieve all of the information we know about a particular
1451 * instrumentation class.
1452 *
1453 * <p>Throws {@link NameNotFoundException} if instrumentation with the
1454 * given class name can not be found on the system.
1455 *
1456 * @param className The full name (i.e.
1457 * com.google.apps.contacts.InstrumentList) of an
1458 * Instrumentation class.
1459 * @param flags Additional option flags. Currently should always be 0.
1460 *
1461 * @return InstrumentationInfo containing information about the
1462 * instrumentation.
1463 */
1464 public abstract InstrumentationInfo getInstrumentationInfo(
1465 ComponentName className, int flags) throws NameNotFoundException;
1466
1467 /**
1468 * Retrieve information about available instrumentation code. May be used
1469 * to retrieve either all instrumentation code, or only the code targeting
1470 * a particular package.
1471 *
1472 * @param targetPackage If null, all instrumentation is returned; only the
1473 * instrumentation targeting this package name is
1474 * returned.
1475 * @param flags Additional option flags. Currently should always be 0.
1476 *
1477 * @return A List<InstrumentationInfo> containing one entry for each
1478 * matching available Instrumentation. Returns an empty list if
1479 * there is no instrumentation available for the given package.
1480 */
1481 public abstract List<InstrumentationInfo> queryInstrumentation(
1482 String targetPackage, int flags);
1483
1484 /**
1485 * Retrieve an image from a package. This is a low-level API used by
1486 * the various package manager info structures (such as
1487 * {@link ComponentInfo} to implement retrieval of their associated
1488 * icon.
1489 *
1490 * @param packageName The name of the package that this icon is coming from.
1491 * Can not be null.
1492 * @param resid The resource identifier of the desired image. Can not be 0.
1493 * @param appInfo Overall information about <var>packageName</var>. This
1494 * may be null, in which case the application information will be retrieved
1495 * for you if needed; if you already have this information around, it can
1496 * be much more efficient to supply it here.
1497 *
1498 * @return Returns a Drawable holding the requested image. Returns null if
1499 * an image could not be found for any reason.
1500 */
1501 public abstract Drawable getDrawable(String packageName, int resid,
1502 ApplicationInfo appInfo);
1503
1504 /**
1505 * Retrieve the icon associated with an activity. Given the full name of
1506 * an activity, retrieves the information about it and calls
1507 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon.
1508 * If the activity can not be found, NameNotFoundException is thrown.
1509 *
1510 * @param activityName Name of the activity whose icon is to be retrieved.
1511 *
1512 * @return Returns the image of the icon, or the default activity icon if
1513 * it could not be found. Does not return null.
1514 * @throws NameNotFoundException Thrown if the resources for the given
1515 * activity could not be loaded.
1516 *
1517 * @see #getActivityIcon(Intent)
1518 */
1519 public abstract Drawable getActivityIcon(ComponentName activityName)
1520 throws NameNotFoundException;
1521
1522 /**
1523 * Retrieve the icon associated with an Intent. If intent.getClassName() is
1524 * set, this simply returns the result of
1525 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's
1526 * component and returns the icon associated with the resolved component.
1527 * If intent.getClassName() can not be found or the Intent can not be resolved
1528 * to a component, NameNotFoundException is thrown.
1529 *
1530 * @param intent The intent for which you would like to retrieve an icon.
1531 *
1532 * @return Returns the image of the icon, or the default activity icon if
1533 * it could not be found. Does not return null.
1534 * @throws NameNotFoundException Thrown if the resources for application
1535 * matching the given intent could not be loaded.
1536 *
1537 * @see #getActivityIcon(ComponentName)
1538 */
1539 public abstract Drawable getActivityIcon(Intent intent)
1540 throws NameNotFoundException;
1541
1542 /**
1543 * Return the generic icon for an activity that is used when no specific
1544 * icon is defined.
1545 *
1546 * @return Drawable Image of the icon.
1547 */
1548 public abstract Drawable getDefaultActivityIcon();
1549
1550 /**
1551 * Retrieve the icon associated with an application. If it has not defined
1552 * an icon, the default app icon is returned. Does not return null.
1553 *
1554 * @param info Information about application being queried.
1555 *
1556 * @return Returns the image of the icon, or the default application icon
1557 * if it could not be found.
1558 *
1559 * @see #getApplicationIcon(String)
1560 */
1561 public abstract Drawable getApplicationIcon(ApplicationInfo info);
1562
1563 /**
1564 * Retrieve the icon associated with an application. Given the name of the
1565 * application's package, retrieves the information about it and calls
1566 * getApplicationIcon() to return its icon. If the application can not be
1567 * found, NameNotFoundException is thrown.
1568 *
1569 * @param packageName Name of the package whose application icon is to be
1570 * retrieved.
1571 *
1572 * @return Returns the image of the icon, or the default application icon
1573 * if it could not be found. Does not return null.
1574 * @throws NameNotFoundException Thrown if the resources for the given
1575 * application could not be loaded.
1576 *
1577 * @see #getApplicationIcon(ApplicationInfo)
1578 */
1579 public abstract Drawable getApplicationIcon(String packageName)
1580 throws NameNotFoundException;
1581
1582 /**
1583 * Retrieve text from a package. This is a low-level API used by
1584 * the various package manager info structures (such as
1585 * {@link ComponentInfo} to implement retrieval of their associated
1586 * labels and other text.
1587 *
1588 * @param packageName The name of the package that this text is coming from.
1589 * Can not be null.
1590 * @param resid The resource identifier of the desired text. Can not be 0.
1591 * @param appInfo Overall information about <var>packageName</var>. This
1592 * may be null, in which case the application information will be retrieved
1593 * for you if needed; if you already have this information around, it can
1594 * be much more efficient to supply it here.
1595 *
1596 * @return Returns a CharSequence holding the requested text. Returns null
1597 * if the text could not be found for any reason.
1598 */
1599 public abstract CharSequence getText(String packageName, int resid,
1600 ApplicationInfo appInfo);
1601
1602 /**
1603 * Retrieve an XML file from a package. This is a low-level API used to
1604 * retrieve XML meta data.
1605 *
1606 * @param packageName The name of the package that this xml is coming from.
1607 * Can not be null.
1608 * @param resid The resource identifier of the desired xml. Can not be 0.
1609 * @param appInfo Overall information about <var>packageName</var>. This
1610 * may be null, in which case the application information will be retrieved
1611 * for you if needed; if you already have this information around, it can
1612 * be much more efficient to supply it here.
1613 *
1614 * @return Returns an XmlPullParser allowing you to parse out the XML
1615 * data. Returns null if the xml resource could not be found for any
1616 * reason.
1617 */
1618 public abstract XmlResourceParser getXml(String packageName, int resid,
1619 ApplicationInfo appInfo);
1620
1621 /**
1622 * Return the label to use for this application.
1623 *
1624 * @return Returns the label associated with this application, or null if
1625 * it could not be found for any reason.
1626 * @param info The application to get the label of
1627 */
1628 public abstract CharSequence getApplicationLabel(ApplicationInfo info);
1629
1630 /**
1631 * Retrieve the resources associated with an activity. Given the full
1632 * name of an activity, retrieves the information about it and calls
1633 * getResources() to return its application's resources. If the activity
1634 * can not be found, NameNotFoundException is thrown.
1635 *
1636 * @param activityName Name of the activity whose resources are to be
1637 * retrieved.
1638 *
1639 * @return Returns the application's Resources.
1640 * @throws NameNotFoundException Thrown if the resources for the given
1641 * application could not be loaded.
1642 *
1643 * @see #getResourcesForApplication(ApplicationInfo)
1644 */
1645 public abstract Resources getResourcesForActivity(ComponentName activityName)
1646 throws NameNotFoundException;
1647
1648 /**
1649 * Retrieve the resources for an application. Throws NameNotFoundException
1650 * if the package is no longer installed.
1651 *
1652 * @param app Information about the desired application.
1653 *
1654 * @return Returns the application's Resources.
1655 * @throws NameNotFoundException Thrown if the resources for the given
1656 * application could not be loaded (most likely because it was uninstalled).
1657 */
1658 public abstract Resources getResourcesForApplication(ApplicationInfo app)
1659 throws NameNotFoundException;
1660
1661 /**
1662 * Retrieve the resources associated with an application. Given the full
1663 * package name of an application, retrieves the information about it and
1664 * calls getResources() to return its application's resources. If the
1665 * appPackageName can not be found, NameNotFoundException is thrown.
1666 *
1667 * @param appPackageName Package name of the application whose resources
1668 * are to be retrieved.
1669 *
1670 * @return Returns the application's Resources.
1671 * @throws NameNotFoundException Thrown if the resources for the given
1672 * application could not be loaded.
1673 *
1674 * @see #getResourcesForApplication(ApplicationInfo)
1675 */
1676 public abstract Resources getResourcesForApplication(String appPackageName)
1677 throws NameNotFoundException;
1678
1679 /**
1680 * Retrieve overall information about an application package defined
1681 * in a package archive file
1682 *
1683 * @param archiveFilePath The path to the archive file
1684 * @param flags Additional option flags. Use any combination of
1685 * {@link #GET_ACTIVITIES},
1686 * {@link #GET_GIDS},
1687 * {@link #GET_CONFIGURATIONS},
1688 * {@link #GET_INSTRUMENTATION},
1689 * {@link #GET_PERMISSIONS},
1690 * {@link #GET_PROVIDERS},
1691 * {@link #GET_RECEIVERS},
1692 * {@link #GET_SERVICES},
1693 * {@link #GET_SIGNATURES}, to modify the data returned.
1694 *
1695 * @return Returns the information about the package. Returns
1696 * null if the package could not be successfully parsed.
1697 *
1698 * @see #GET_ACTIVITIES
1699 * @see #GET_GIDS
1700 * @see #GET_CONFIGURATIONS
1701 * @see #GET_INSTRUMENTATION
1702 * @see #GET_PERMISSIONS
1703 * @see #GET_PROVIDERS
1704 * @see #GET_RECEIVERS
1705 * @see #GET_SERVICES
1706 * @see #GET_SIGNATURES
1707 *
1708 */
1709 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
1710 PackageParser packageParser = new PackageParser(archiveFilePath);
1711 DisplayMetrics metrics = new DisplayMetrics();
1712 metrics.setToDefaults();
1713 final File sourceFile = new File(archiveFilePath);
1714 PackageParser.Package pkg = packageParser.parsePackage(
1715 sourceFile, archiveFilePath, metrics, 0);
1716 if (pkg == null) {
1717 return null;
1718 }
1719 return PackageParser.generatePackageInfo(pkg, null, flags);
1720 }
1721
1722 /**
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001723 * @hide
1724 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001725 * Install a package. Since this may take a little while, the result will
1726 * be posted back to the given observer. An installation will fail if the calling context
1727 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the
1728 * package named in the package file's manifest is already installed, or if there's no space
1729 * available on the device.
1730 *
1731 * @param packageURI The location of the package file to install. This can be a 'file:' or a
1732 * 'content:' URI.
1733 * @param observer An observer callback to get notified when the package installation is
1734 * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be
1735 * called when that happens. observer may be null to indicate that no callback is desired.
Dianne Hackbornade3eca2009-05-11 18:54:45 -07001736 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK},
1737 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}.
Jacek Surazski65e13172009-04-28 15:26:38 +02001738 * @param installerPackageName Optional package name of the application that is performing the
1739 * installation. This identifies which market the package came from.
Jacek Surazski65e13172009-04-28 15:26:38 +02001740 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001741 public abstract void installPackage(
Jacek Surazski65e13172009-04-28 15:26:38 +02001742 Uri packageURI, IPackageInstallObserver observer, int flags,
1743 String installerPackageName);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001744
1745 /**
1746 * Attempts to delete a package. Since this may take a little while, the result will
1747 * be posted back to the given observer. A deletion will fail if the calling context
1748 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the
1749 * named package cannot be found, or if the named package is a "system package".
1750 * (TODO: include pointer to documentation on "system packages")
1751 *
1752 * @param packageName The name of the package to delete
1753 * @param observer An observer callback to get notified when the package deletion is
1754 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be
1755 * called when that happens. observer may be null to indicate that no callback is desired.
1756 * @param flags - possible values: {@link #DONT_DELETE_DATA}
1757 *
1758 * @hide
1759 */
1760 public abstract void deletePackage(
1761 String packageName, IPackageDeleteObserver observer, int flags);
Jacek Surazski65e13172009-04-28 15:26:38 +02001762
1763 /**
1764 * Retrieve the package name of the application that installed a package. This identifies
1765 * which market the package came from.
1766 *
1767 * @param packageName The name of the package to query
1768 */
1769 public abstract String getInstallerPackageName(String packageName);
1770
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001771 /**
1772 * Attempts to clear the user data directory of an application.
1773 * Since this may take a little while, the result will
1774 * be posted back to the given observer. A deletion will fail if the
1775 * named package cannot be found, or if the named package is a "system package".
1776 *
1777 * @param packageName The name of the package
1778 * @param observer An observer callback to get notified when the operation is finished
1779 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
1780 * will be called when that happens. observer may be null to indicate that
1781 * no callback is desired.
1782 *
1783 * @hide
1784 */
1785 public abstract void clearApplicationUserData(String packageName,
1786 IPackageDataObserver observer);
1787 /**
1788 * Attempts to delete the cache files associated with an application.
1789 * Since this may take a little while, the result will
1790 * be posted back to the given observer. A deletion will fail if the calling context
1791 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the
1792 * named package cannot be found, or if the named package is a "system package".
1793 *
1794 * @param packageName The name of the package to delete
1795 * @param observer An observer callback to get notified when the cache file deletion
1796 * is complete.
1797 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)}
1798 * will be called when that happens. observer may be null to indicate that
1799 * no callback is desired.
1800 *
1801 * @hide
1802 */
1803 public abstract void deleteApplicationCacheFiles(String packageName,
1804 IPackageDataObserver observer);
1805
1806 /**
1807 * Free storage by deleting LRU sorted list of cache files across
1808 * all applications. If the currently available free storage
1809 * on the device is greater than or equal to the requested
1810 * free storage, no cache files are cleared. If the currently
1811 * available storage on the device is less than the requested
1812 * free storage, some or all of the cache files across
1813 * all applications are deleted (based on last accessed time)
1814 * to increase the free storage space on the device to
1815 * the requested value. There is no guarantee that clearing all
1816 * the cache files from all applications will clear up
1817 * enough storage to achieve the desired value.
1818 * @param freeStorageSize The number of bytes of storage to be
1819 * freed by the system. Say if freeStorageSize is XX,
1820 * and the current free storage is YY,
1821 * if XX is less than YY, just return. if not free XX-YY number
1822 * of bytes if possible.
1823 * @param observer call back used to notify when
1824 * the operation is completed
1825 *
1826 * @hide
1827 */
1828 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer);
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -07001829
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001830 /**
1831 * Free storage by deleting LRU sorted list of cache files across
1832 * all applications. If the currently available free storage
1833 * on the device is greater than or equal to the requested
1834 * free storage, no cache files are cleared. If the currently
1835 * available storage on the device is less than the requested
1836 * free storage, some or all of the cache files across
1837 * all applications are deleted (based on last accessed time)
1838 * to increase the free storage space on the device to
1839 * the requested value. There is no guarantee that clearing all
1840 * the cache files from all applications will clear up
1841 * enough storage to achieve the desired value.
1842 * @param freeStorageSize The number of bytes of storage to be
1843 * freed by the system. Say if freeStorageSize is XX,
1844 * and the current free storage is YY,
1845 * if XX is less than YY, just return. if not free XX-YY number
1846 * of bytes if possible.
Suchi Amalapurapu1ccac752009-06-12 10:09:58 -07001847 * @param pi IntentSender call back used to
1848 * notify when the operation is completed.May be null
1849 * to indicate that no call back is desired.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001850 *
1851 * @hide
1852 */
Suchi Amalapurapubc806f62009-06-17 15:18:19 -07001853 public abstract void freeStorage(long freeStorageSize, IntentSender pi);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001854
1855 /**
1856 * Retrieve the size information for a package.
1857 * Since this may take a little while, the result will
1858 * be posted back to the given observer. The calling context
1859 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission.
1860 *
1861 * @param packageName The name of the package whose size information is to be retrieved
1862 * @param observer An observer callback to get notified when the operation
1863 * is complete.
1864 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)}
1865 * The observer's callback is invoked with a PackageStats object(containing the
1866 * code, data and cache sizes of the package) and a boolean value representing
1867 * the status of the operation. observer may be null to indicate that
1868 * no callback is desired.
1869 *
1870 * @hide
1871 */
1872 public abstract void getPackageSizeInfo(String packageName,
1873 IPackageStatsObserver observer);
1874
1875 /**
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08001876 * @deprecated This function no longer does anything; it was an old
1877 * approach to managing preferred activities, which has been superceeded
1878 * (and conflicts with) the modern activity-based preferences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001879 */
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08001880 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001881 public abstract void addPackageToPreferred(String packageName);
1882
1883 /**
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08001884 * @deprecated This function no longer does anything; it was an old
1885 * approach to managing preferred activities, which has been superceeded
1886 * (and conflicts with) the modern activity-based preferences.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001887 */
Dianne Hackborna7ca0e52009-12-01 14:31:55 -08001888 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001889 public abstract void removePackageFromPreferred(String packageName);
1890
1891 /**
1892 * Retrieve the list of all currently configured preferred packages. The
1893 * first package on the list is the most preferred, the last is the
1894 * least preferred.
1895 *
1896 * @param flags Additional option flags. Use any combination of
1897 * {@link #GET_ACTIVITIES},
1898 * {@link #GET_GIDS},
1899 * {@link #GET_CONFIGURATIONS},
1900 * {@link #GET_INSTRUMENTATION},
1901 * {@link #GET_PERMISSIONS},
1902 * {@link #GET_PROVIDERS},
1903 * {@link #GET_RECEIVERS},
1904 * {@link #GET_SERVICES},
1905 * {@link #GET_SIGNATURES}, to modify the data returned.
1906 *
1907 * @return Returns a list of PackageInfo objects describing each
1908 * preferred application, in order of preference.
1909 *
1910 * @see #GET_ACTIVITIES
1911 * @see #GET_GIDS
1912 * @see #GET_CONFIGURATIONS
1913 * @see #GET_INSTRUMENTATION
1914 * @see #GET_PERMISSIONS
1915 * @see #GET_PROVIDERS
1916 * @see #GET_RECEIVERS
1917 * @see #GET_SERVICES
1918 * @see #GET_SIGNATURES
1919 */
1920 public abstract List<PackageInfo> getPreferredPackages(int flags);
1921
1922 /**
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08001923 * @deprecated This is a protected API that should not have been available
1924 * to third party applications. It is the platform's responsibility for
1925 * assigning preferred activities and this can not be directly modified.
1926 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001927 * Add a new preferred activity mapping to the system. This will be used
1928 * to automatically select the given activity component when
1929 * {@link Context#startActivity(Intent) Context.startActivity()} finds
1930 * multiple matching activities and also matches the given filter.
1931 *
1932 * @param filter The set of intents under which this activity will be
1933 * made preferred.
1934 * @param match The IntentFilter match category that this preference
1935 * applies to.
1936 * @param set The set of activities that the user was picking from when
1937 * this preference was made.
1938 * @param activity The component name of the activity that is to be
1939 * preferred.
1940 */
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08001941 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001942 public abstract void addPreferredActivity(IntentFilter filter, int match,
1943 ComponentName[] set, ComponentName activity);
1944
1945 /**
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08001946 * @deprecated This is a protected API that should not have been available
1947 * to third party applications. It is the platform's responsibility for
1948 * assigning preferred activities and this can not be directly modified.
1949 *
Satish Sampath8dbe6122009-06-02 23:35:54 +01001950 * Replaces an existing preferred activity mapping to the system, and if that were not present
1951 * adds a new preferred activity. This will be used
1952 * to automatically select the given activity component when
1953 * {@link Context#startActivity(Intent) Context.startActivity()} finds
1954 * multiple matching activities and also matches the given filter.
1955 *
1956 * @param filter The set of intents under which this activity will be
1957 * made preferred.
1958 * @param match The IntentFilter match category that this preference
1959 * applies to.
1960 * @param set The set of activities that the user was picking from when
1961 * this preference was made.
1962 * @param activity The component name of the activity that is to be
1963 * preferred.
1964 * @hide
1965 */
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08001966 @Deprecated
Satish Sampath8dbe6122009-06-02 23:35:54 +01001967 public abstract void replacePreferredActivity(IntentFilter filter, int match,
1968 ComponentName[] set, ComponentName activity);
1969
1970 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001971 * Remove all preferred activity mappings, previously added with
1972 * {@link #addPreferredActivity}, from the
1973 * system whose activities are implemented in the given package name.
Dianne Hackborn2ee89ea2010-03-10 18:27:09 -08001974 * An application can only clear its own package(s).
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001975 *
1976 * @param packageName The name of the package whose preferred activity
1977 * mappings are to be removed.
1978 */
1979 public abstract void clearPackagePreferredActivities(String packageName);
1980
1981 /**
1982 * Retrieve all preferred activities, previously added with
1983 * {@link #addPreferredActivity}, that are
1984 * currently registered with the system.
1985 *
1986 * @param outFilters A list in which to place the filters of all of the
1987 * preferred activities, or null for none.
1988 * @param outActivities A list in which to place the component names of
1989 * all of the preferred activities, or null for none.
1990 * @param packageName An option package in which you would like to limit
1991 * the list. If null, all activities will be returned; if non-null, only
1992 * those activities in the given package are returned.
1993 *
1994 * @return Returns the total number of registered preferred activities
1995 * (the number of distinct IntentFilter records, not the number of unique
1996 * activity components) that were found.
1997 */
1998 public abstract int getPreferredActivities(List<IntentFilter> outFilters,
1999 List<ComponentName> outActivities, String packageName);
2000
2001 /**
2002 * Set the enabled setting for a package component (activity, receiver, service, provider).
2003 * This setting will override any enabled state which may have been set by the component in its
2004 * manifest.
2005 *
2006 * @param componentName The component to enable
2007 * @param newState The new enabled state for the component. The legal values for this state
2008 * are:
2009 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
2010 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
2011 * and
2012 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2013 * The last one removes the setting, thereby restoring the component's state to
2014 * whatever was set in it's manifest (or enabled, by default).
2015 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2016 */
2017 public abstract void setComponentEnabledSetting(ComponentName componentName,
2018 int newState, int flags);
2019
2020
2021 /**
2022 * Return the the enabled setting for a package component (activity,
2023 * receiver, service, provider). This returns the last value set by
2024 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most
2025 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2026 * the value originally specified in the manifest has not been modified.
2027 *
2028 * @param componentName The component to retrieve.
2029 * @return Returns the current enabled state for the component. May
2030 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2031 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2032 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
2033 * component's enabled state is based on the original information in
2034 * the manifest as found in {@link ComponentInfo}.
2035 */
2036 public abstract int getComponentEnabledSetting(ComponentName componentName);
2037
2038 /**
2039 * Set the enabled setting for an application
2040 * This setting will override any enabled state which may have been set by the application in
2041 * its manifest. It also overrides the enabled state set in the manifest for any of the
2042 * application's components. It does not override any enabled state set by
2043 * {@link #setComponentEnabledSetting} for any of the application's components.
2044 *
2045 * @param packageName The package name of the application to enable
2046 * @param newState The new enabled state for the component. The legal values for this state
2047 * are:
2048 * {@link #COMPONENT_ENABLED_STATE_ENABLED},
2049 * {@link #COMPONENT_ENABLED_STATE_DISABLED}
2050 * and
2051 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}
2052 * The last one removes the setting, thereby restoring the applications's state to
2053 * whatever was set in its manifest (or enabled, by default).
2054 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0.
2055 */
2056 public abstract void setApplicationEnabledSetting(String packageName,
2057 int newState, int flags);
2058
2059 /**
2060 * Return the the enabled setting for an application. This returns
2061 * the last value set by
2062 * {@link #setApplicationEnabledSetting(String, int, int)}; in most
2063 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since
2064 * the value originally specified in the manifest has not been modified.
2065 *
2066 * @param packageName The component to retrieve.
2067 * @return Returns the current enabled state for the component. May
2068 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED},
2069 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or
2070 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the
2071 * application's enabled state is based on the original information in
2072 * the manifest as found in {@link ComponentInfo}.
2073 */
2074 public abstract int getApplicationEnabledSetting(String packageName);
2075
2076 /**
2077 * Return whether the device has been booted into safe mode.
2078 */
2079 public abstract boolean isSafeMode();
Suchi Amalapurapu8946dd32010-02-19 09:19:34 -08002080
2081 /**
2082 * Attempts to move package resources from internal to external media or vice versa.
2083 * Since this may take a little while, the result will
2084 * be posted back to the given observer. This call may fail if the calling context
2085 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the
2086 * named package cannot be found, or if the named package is a "system package".
2087 *
2088 * @param packageName The name of the package to delete
2089 * @param observer An observer callback to get notified when the package move is
2090 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be
2091 * called when that happens. observer may be null to indicate that no callback is desired.
2092 * @param flags To indicate install location {@link #MOVE_INTERNAL} or
2093 * {@link #MOVE_EXTERNAL_MEDIA}
2094 *
2095 * @hide
2096 */
2097 public abstract void movePackage(
2098 String packageName, IPackageMoveObserver observer, int flags);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002099}