PackageManager.java revision 6993d3d136fed8600a3e337d710907b50d8d6e49
1/* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.content.pm; 18 19import android.annotation.SdkConstant; 20import android.annotation.SdkConstant.SdkConstantType; 21import android.content.ComponentName; 22import android.content.Context; 23import android.content.Intent; 24import android.content.IntentFilter; 25import android.content.IntentSender; 26import android.content.res.Resources; 27import android.content.res.XmlResourceParser; 28import android.graphics.drawable.Drawable; 29import android.net.Uri; 30import android.os.Environment; 31import android.os.StatFs; 32import 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 166 * hardware preferences in 167 * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and 168 * requested features in {@link PackageInfo#reqFeatures 169 * PackageInfo.reqFeatures}. 170 */ 171 public static final int GET_CONFIGURATIONS = 0x00004000; 172 173 /** 174 * 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 /** 182 * 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 229 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 its code and non-resource assets. 237 * @hide 238 */ 239 public static final int INSTALL_FORWARD_LOCK = 0x00000001; 240 241 /** 242 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already 243 * installed package, if one exists. 244 * @hide 245 */ 246 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; 255 256 /** 257 * Flag parameter for {@link #installPackage} to indicate that this 258 * package has to be installed on the sdcard. 259 * @hide 260 */ 261 public static final int INSTALL_EXTERNAL = 0x00000008; 262 263 /** 264 * 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 /** 271 * 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. 281 * @hide 282 */ 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. 289 * @hide 290 */ 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. 297 * @hide 298 */ 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. 305 * @hide 306 */ 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 312 * service found that the device didn't have enough storage space to install the app. 313 * @hide 314 */ 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. 321 * @hide 322 */ 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. 329 * @hide 330 */ 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). 338 * @hide 339 */ 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. 347 * @hide 348 */ 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. 355 * @hide 356 */ 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. 363 * @hide 364 */ 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. 372 * @hide 373 */ 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. 381 * @hide 382 */ 383 public static final int INSTALL_FAILED_OLDER_SDK = -12; 384 385 /** 386 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 387 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 388 * the new package failed because it contains a content provider with the 389 * same authority as a provider already installed in the system. 390 * @hide 391 */ 392 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 393 394 /** 395 * 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. 399 * @hide 400 */ 401 public static final int INSTALL_FAILED_NEWER_SDK = -14; 402 403 /** 404 * 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 /** 414 * 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 /** 423 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 424 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 425 * the new package uses a feature that is not available. 426 * @hide 427 */ 428 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 429 430 // ------ 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 439 /** 440 * 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 /** 449 * 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 /** 458 * 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. 462 * @hide 463 */ 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. 470 * @hide 471 */ 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. 478 * @hide 479 */ 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. 486 * @hide 487 */ 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. 494 * @hide 495 */ 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. 503 * @hide 504 */ 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. 511 * @hide 512 */ 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. 519 * @hide 520 */ 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. 527 * @hide 528 */ 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. 536 * @hide 537 */ 538 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 539 540 /** 541 * 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 /** 549 * 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 /** 557 * 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 /** 605 * 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 /** 613 * Error code that is passed to the {@link IPackageMoveObserver} by 614 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the 615 * specified package already has an operation pending in the 616 * {@link PackageHandler} queue. 617 * 618 * @hide 619 */ 620 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 621 622 /** 623 * Flag parameter for {@link #movePackage} to indicate that 624 * the package should be moved to internal storage if its 625 * been installed on external media. 626 * @hide 627 */ 628 public static final int MOVE_INTERNAL = 0x00000001; 629 630 /** 631 * Flag parameter for {@link #movePackage} to indicate that 632 * the package should be moved to external media. 633 * @hide 634 */ 635 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 636 637 /** 638 * Feature for {@link #getSystemAvailableFeatures} and 639 * {@link #hasSystemFeature}: The device is capable of communicating with 640 * other devices via Bluetooth. 641 */ 642 @SdkConstant(SdkConstantType.FEATURE) 643 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 644 645 /** 646 * Feature for {@link #getSystemAvailableFeatures} and 647 * {@link #hasSystemFeature}: The device has a camera facing away 648 * from the screen. 649 */ 650 @SdkConstant(SdkConstantType.FEATURE) 651 public static final String FEATURE_CAMERA = "android.hardware.camera"; 652 653 /** 654 * Feature for {@link #getSystemAvailableFeatures} and 655 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 656 */ 657 @SdkConstant(SdkConstantType.FEATURE) 658 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 659 660 /** 661 * Feature for {@link #getSystemAvailableFeatures} and 662 * {@link #hasSystemFeature}: The device's camera supports flash. 663 */ 664 @SdkConstant(SdkConstantType.FEATURE) 665 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 666 667 /** 668 * Feature for {@link #getSystemAvailableFeatures} and 669 * {@link #hasSystemFeature}: The device has a front facing camera. 670 */ 671 @SdkConstant(SdkConstantType.FEATURE) 672 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 673 674 /** 675 * Feature for {@link #getSystemAvailableFeatures} and 676 * {@link #hasSystemFeature}: The device supports one or more methods of 677 * reporting current location. 678 */ 679 @SdkConstant(SdkConstantType.FEATURE) 680 public static final String FEATURE_LOCATION = "android.hardware.location"; 681 682 /** 683 * Feature for {@link #getSystemAvailableFeatures} and 684 * {@link #hasSystemFeature}: The device has a Global Positioning System 685 * receiver and can report precise location. 686 */ 687 @SdkConstant(SdkConstantType.FEATURE) 688 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 689 690 /** 691 * Feature for {@link #getSystemAvailableFeatures} and 692 * {@link #hasSystemFeature}: The device can report location with coarse 693 * accuracy using a network-based geolocation system. 694 */ 695 @SdkConstant(SdkConstantType.FEATURE) 696 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 697 698 /** 699 * Feature for {@link #getSystemAvailableFeatures} and 700 * {@link #hasSystemFeature}: The device can record audio via a 701 * microphone. 702 */ 703 @SdkConstant(SdkConstantType.FEATURE) 704 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 705 706 /** 707 * Feature for {@link #getSystemAvailableFeatures} and 708 * {@link #hasSystemFeature}: The device can communicate using Near-Field 709 * Communications (NFC). 710 */ 711 @SdkConstant(SdkConstantType.FEATURE) 712 public static final String FEATURE_NFC = "android.hardware.nfc"; 713 714 /** 715 * Feature for {@link #getSystemAvailableFeatures} and 716 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 717 */ 718 @SdkConstant(SdkConstantType.FEATURE) 719 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 720 721 /** 722 * Feature for {@link #getSystemAvailableFeatures} and 723 * {@link #hasSystemFeature}: The device includes an accelerometer. 724 */ 725 @SdkConstant(SdkConstantType.FEATURE) 726 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 727 728 /** 729 * Feature for {@link #getSystemAvailableFeatures} and 730 * {@link #hasSystemFeature}: The device includes a light sensor. 731 */ 732 @SdkConstant(SdkConstantType.FEATURE) 733 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 734 735 /** 736 * Feature for {@link #getSystemAvailableFeatures} and 737 * {@link #hasSystemFeature}: The device includes a proximity sensor. 738 */ 739 @SdkConstant(SdkConstantType.FEATURE) 740 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 741 742 /** 743 * Feature for {@link #getSystemAvailableFeatures} and 744 * {@link #hasSystemFeature}: The device has a telephony radio with data 745 * communication support. 746 */ 747 @SdkConstant(SdkConstantType.FEATURE) 748 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 749 750 /** 751 * Feature for {@link #getSystemAvailableFeatures} and 752 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 753 */ 754 @SdkConstant(SdkConstantType.FEATURE) 755 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 756 757 /** 758 * Feature for {@link #getSystemAvailableFeatures} and 759 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 760 */ 761 @SdkConstant(SdkConstantType.FEATURE) 762 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 763 764 /** 765 * Feature for {@link #getSystemAvailableFeatures} and 766 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 767 */ 768 @SdkConstant(SdkConstantType.FEATURE) 769 public static final String FEATURE_SIP = "android.software.sip"; 770 771 /** 772 * Feature for {@link #getSystemAvailableFeatures} and 773 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 774 */ 775 @SdkConstant(SdkConstantType.FEATURE) 776 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 777 778 /** 779 * Feature for {@link #getSystemAvailableFeatures} and 780 * {@link #hasSystemFeature}: The device's display has a touch screen. 781 */ 782 @SdkConstant(SdkConstantType.FEATURE) 783 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 784 785 786 /** 787 * Feature for {@link #getSystemAvailableFeatures} and 788 * {@link #hasSystemFeature}: The device's touch screen supports 789 * multitouch sufficient for basic two-finger gesture detection. 790 */ 791 @SdkConstant(SdkConstantType.FEATURE) 792 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 793 794 /** 795 * Feature for {@link #getSystemAvailableFeatures} and 796 * {@link #hasSystemFeature}: The device's touch screen is capable of 797 * tracking two or more fingers fully independently. 798 */ 799 @SdkConstant(SdkConstantType.FEATURE) 800 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 801 802 /** 803 * Feature for {@link #getSystemAvailableFeatures} and 804 * {@link #hasSystemFeature}: The device's touch screen is capable of 805 * tracking a full hand of fingers fully independently -- that is, 5 or 806 * more simultaneous independent pointers. 807 */ 808 @SdkConstant(SdkConstantType.FEATURE) 809 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 810 811 /** 812 * Feature for {@link #getSystemAvailableFeatures} and 813 * {@link #hasSystemFeature}: The device supports live wallpapers. 814 */ 815 @SdkConstant(SdkConstantType.FEATURE) 816 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 817 818 /** 819 * Feature for {@link #getSystemAvailableFeatures} and 820 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 821 */ 822 @SdkConstant(SdkConstantType.FEATURE) 823 public static final String FEATURE_WIFI = "android.hardware.wifi"; 824 825 /** 826 * Action to external storage service to clean out removed apps. 827 * @hide 828 */ 829 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 830 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 831 832 /** 833 * Retrieve overall information about an application package that is 834 * installed on the system. 835 * 836 * <p>Throws {@link NameNotFoundException} if a package with the given 837 * name can not be found on the system. 838 * 839 * @param packageName The full name (i.e. com.google.apps.contacts) of the 840 * desired package. 841 842 * @param flags Additional option flags. Use any combination of 843 * {@link #GET_ACTIVITIES}, 844 * {@link #GET_GIDS}, 845 * {@link #GET_CONFIGURATIONS}, 846 * {@link #GET_INSTRUMENTATION}, 847 * {@link #GET_PERMISSIONS}, 848 * {@link #GET_PROVIDERS}, 849 * {@link #GET_RECEIVERS}, 850 * {@link #GET_SERVICES}, 851 * {@link #GET_SIGNATURES}, 852 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 853 * 854 * @return Returns a PackageInfo object containing information about the package. 855 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 856 * found in the list of installed applications, the package information is 857 * retrieved from the list of uninstalled applications(which includes 858 * installed applications as well as applications 859 * with data directory ie applications which had been 860 * deleted with DONT_DELTE_DATA flag set). 861 * 862 * @see #GET_ACTIVITIES 863 * @see #GET_GIDS 864 * @see #GET_CONFIGURATIONS 865 * @see #GET_INSTRUMENTATION 866 * @see #GET_PERMISSIONS 867 * @see #GET_PROVIDERS 868 * @see #GET_RECEIVERS 869 * @see #GET_SERVICES 870 * @see #GET_SIGNATURES 871 * @see #GET_UNINSTALLED_PACKAGES 872 * 873 */ 874 public abstract PackageInfo getPackageInfo(String packageName, int flags) 875 throws NameNotFoundException; 876 877 /** 878 * Map from the current package names in use on the device to whatever 879 * the current canonical name of that package is. 880 * @param names Array of current names to be mapped. 881 * @return Returns an array of the same size as the original, containing 882 * the canonical name for each package. 883 */ 884 public abstract String[] currentToCanonicalPackageNames(String[] names); 885 886 /** 887 * Map from a packages canonical name to the current name in use on the device. 888 * @param names Array of new names to be mapped. 889 * @return Returns an array of the same size as the original, containing 890 * the current name for each package. 891 */ 892 public abstract String[] canonicalToCurrentPackageNames(String[] names); 893 894 /** 895 * Return a "good" intent to launch a front-door activity in a package, 896 * for use for example to implement an "open" button when browsing through 897 * packages. The current implementation will look first for a main 898 * activity in the category {@link Intent#CATEGORY_INFO}, next for a 899 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return 900 * null if neither are found. 901 * 902 * <p>Throws {@link NameNotFoundException} if a package with the given 903 * name can not be found on the system. 904 * 905 * @param packageName The name of the package to inspect. 906 * 907 * @return Returns either a fully-qualified Intent that can be used to 908 * launch the main activity in the package, or null if the package does 909 * not contain such an activity. 910 */ 911 public abstract Intent getLaunchIntentForPackage(String packageName); 912 913 /** 914 * Return an array of all of the secondary group-ids that have been 915 * assigned to a package. 916 * 917 * <p>Throws {@link NameNotFoundException} if a package with the given 918 * name can not be found on the system. 919 * 920 * @param packageName The full name (i.e. com.google.apps.contacts) of the 921 * desired package. 922 * 923 * @return Returns an int array of the assigned gids, or null if there 924 * are none. 925 */ 926 public abstract int[] getPackageGids(String packageName) 927 throws NameNotFoundException; 928 929 /** 930 * Retrieve all of the information we know about a particular permission. 931 * 932 * <p>Throws {@link NameNotFoundException} if a permission with the given 933 * name can not be found on the system. 934 * 935 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 936 * of the permission you are interested in. 937 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 938 * retrieve any meta-data associated with the permission. 939 * 940 * @return Returns a {@link PermissionInfo} containing information about the 941 * permission. 942 */ 943 public abstract PermissionInfo getPermissionInfo(String name, int flags) 944 throws NameNotFoundException; 945 946 /** 947 * Query for all of the permissions associated with a particular group. 948 * 949 * <p>Throws {@link NameNotFoundException} if the given group does not 950 * exist. 951 * 952 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 953 * of the permission group you are interested in. Use null to 954 * find all of the permissions not associated with a group. 955 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 956 * retrieve any meta-data associated with the permissions. 957 * 958 * @return Returns a list of {@link PermissionInfo} containing information 959 * about all of the permissions in the given group. 960 */ 961 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 962 int flags) throws NameNotFoundException; 963 964 /** 965 * Retrieve all of the information we know about a particular group of 966 * permissions. 967 * 968 * <p>Throws {@link NameNotFoundException} if a permission group with the given 969 * name can not be found on the system. 970 * 971 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 972 * of the permission you are interested in. 973 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 974 * retrieve any meta-data associated with the permission group. 975 * 976 * @return Returns a {@link PermissionGroupInfo} containing information 977 * about the permission. 978 */ 979 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 980 int flags) throws NameNotFoundException; 981 982 /** 983 * Retrieve all of the known permission groups in the system. 984 * 985 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 986 * retrieve any meta-data associated with the permission group. 987 * 988 * @return Returns a list of {@link PermissionGroupInfo} containing 989 * information about all of the known permission groups. 990 */ 991 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 992 993 /** 994 * Retrieve all of the information we know about a particular 995 * package/application. 996 * 997 * <p>Throws {@link NameNotFoundException} if an application with the given 998 * package name can not be found on the system. 999 * 1000 * @param packageName The full name (i.e. com.google.apps.contacts) of an 1001 * application. 1002 * @param flags Additional option flags. Use any combination of 1003 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1004 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1005 * 1006 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 1007 * information about the package. 1008 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 1009 * found in the list of installed applications, 1010 * the application information is retrieved from the 1011 * list of uninstalled applications(which includes 1012 * installed applications as well as applications 1013 * with data directory ie applications which had been 1014 * deleted with DONT_DELTE_DATA flag set). 1015 * 1016 * @see #GET_META_DATA 1017 * @see #GET_SHARED_LIBRARY_FILES 1018 * @see #GET_UNINSTALLED_PACKAGES 1019 */ 1020 public abstract ApplicationInfo getApplicationInfo(String packageName, 1021 int flags) throws NameNotFoundException; 1022 1023 /** 1024 * Retrieve all of the information we know about a particular activity 1025 * class. 1026 * 1027 * <p>Throws {@link NameNotFoundException} if an activity with the given 1028 * class name can not be found on the system. 1029 * 1030 * @param component The full component name (i.e. 1031 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 1032 * class. 1033 * @param flags Additional option flags. Use any combination of 1034 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1035 * to modify the data (in ApplicationInfo) returned. 1036 * 1037 * @return {@link ActivityInfo} containing information about the activity. 1038 * 1039 * @see #GET_INTENT_FILTERS 1040 * @see #GET_META_DATA 1041 * @see #GET_SHARED_LIBRARY_FILES 1042 */ 1043 public abstract ActivityInfo getActivityInfo(ComponentName component, 1044 int flags) throws NameNotFoundException; 1045 1046 /** 1047 * Retrieve all of the information we know about a particular receiver 1048 * class. 1049 * 1050 * <p>Throws {@link NameNotFoundException} if a receiver with the given 1051 * class name can not be found on the system. 1052 * 1053 * @param component The full component name (i.e. 1054 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 1055 * class. 1056 * @param flags Additional option flags. Use any combination of 1057 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1058 * to modify the data returned. 1059 * 1060 * @return {@link ActivityInfo} containing information about the receiver. 1061 * 1062 * @see #GET_INTENT_FILTERS 1063 * @see #GET_META_DATA 1064 * @see #GET_SHARED_LIBRARY_FILES 1065 */ 1066 public abstract ActivityInfo getReceiverInfo(ComponentName component, 1067 int flags) throws NameNotFoundException; 1068 1069 /** 1070 * Retrieve all of the information we know about a particular service 1071 * class. 1072 * 1073 * <p>Throws {@link NameNotFoundException} if a service with the given 1074 * class name can not be found on the system. 1075 * 1076 * @param component The full component name (i.e. 1077 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 1078 * class. 1079 * @param flags Additional option flags. Use any combination of 1080 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1081 * to modify the data returned. 1082 * 1083 * @return ServiceInfo containing information about the service. 1084 * 1085 * @see #GET_META_DATA 1086 * @see #GET_SHARED_LIBRARY_FILES 1087 */ 1088 public abstract ServiceInfo getServiceInfo(ComponentName component, 1089 int flags) throws NameNotFoundException; 1090 1091 /** 1092 * Retrieve all of the information we know about a particular content 1093 * provider class. 1094 * 1095 * <p>Throws {@link NameNotFoundException} if a provider with the given 1096 * class name can not be found on the system. 1097 * 1098 * @param component The full component name (i.e. 1099 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 1100 * ContentProvider class. 1101 * @param flags Additional option flags. Use any combination of 1102 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1103 * to modify the data returned. 1104 * 1105 * @return ProviderInfo containing information about the service. 1106 * 1107 * @see #GET_META_DATA 1108 * @see #GET_SHARED_LIBRARY_FILES 1109 */ 1110 public abstract ProviderInfo getProviderInfo(ComponentName component, 1111 int flags) throws NameNotFoundException; 1112 1113 /** 1114 * Return a List of all packages that are installed 1115 * on the device. 1116 * 1117 * @param flags Additional option flags. Use any combination of 1118 * {@link #GET_ACTIVITIES}, 1119 * {@link #GET_GIDS}, 1120 * {@link #GET_CONFIGURATIONS}, 1121 * {@link #GET_INSTRUMENTATION}, 1122 * {@link #GET_PERMISSIONS}, 1123 * {@link #GET_PROVIDERS}, 1124 * {@link #GET_RECEIVERS}, 1125 * {@link #GET_SERVICES}, 1126 * {@link #GET_SIGNATURES}, 1127 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1128 * 1129 * @return A List of PackageInfo objects, one for each package that is 1130 * installed on the device. In the unlikely case of there being no 1131 * installed packages, an empty list is returned. 1132 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1133 * applications including those deleted with DONT_DELETE_DATA 1134 * (partially installed apps with data directory) will be returned. 1135 * 1136 * @see #GET_ACTIVITIES 1137 * @see #GET_GIDS 1138 * @see #GET_CONFIGURATIONS 1139 * @see #GET_INSTRUMENTATION 1140 * @see #GET_PERMISSIONS 1141 * @see #GET_PROVIDERS 1142 * @see #GET_RECEIVERS 1143 * @see #GET_SERVICES 1144 * @see #GET_SIGNATURES 1145 * @see #GET_UNINSTALLED_PACKAGES 1146 * 1147 */ 1148 public abstract List<PackageInfo> getInstalledPackages(int flags); 1149 1150 /** 1151 * Check whether a particular package has been granted a particular 1152 * permission. 1153 * 1154 * @param permName The name of the permission you are checking for, 1155 * @param pkgName The name of the package you are checking against. 1156 * 1157 * @return If the package has the permission, PERMISSION_GRANTED is 1158 * returned. If it does not have the permission, PERMISSION_DENIED 1159 * is returned. 1160 * 1161 * @see #PERMISSION_GRANTED 1162 * @see #PERMISSION_DENIED 1163 */ 1164 public abstract int checkPermission(String permName, String pkgName); 1165 1166 /** 1167 * Add a new dynamic permission to the system. For this to work, your 1168 * package must have defined a permission tree through the 1169 * {@link android.R.styleable#AndroidManifestPermissionTree 1170 * <permission-tree>} tag in its manifest. A package can only add 1171 * permissions to trees that were defined by either its own package or 1172 * another with the same user id; a permission is in a tree if it 1173 * matches the name of the permission tree + ".": for example, 1174 * "com.foo.bar" is a member of the permission tree "com.foo". 1175 * 1176 * <p>It is good to make your permission tree name descriptive, because you 1177 * are taking possession of that entire set of permission names. Thus, it 1178 * must be under a domain you control, with a suffix that will not match 1179 * any normal permissions that may be declared in any applications that 1180 * are part of that domain. 1181 * 1182 * <p>New permissions must be added before 1183 * any .apks are installed that use those permissions. Permissions you 1184 * add through this method are remembered across reboots of the device. 1185 * If the given permission already exists, the info you supply here 1186 * will be used to update it. 1187 * 1188 * @param info Description of the permission to be added. 1189 * 1190 * @return Returns true if a new permission was created, false if an 1191 * existing one was updated. 1192 * 1193 * @throws SecurityException if you are not allowed to add the 1194 * given permission name. 1195 * 1196 * @see #removePermission(String) 1197 */ 1198 public abstract boolean addPermission(PermissionInfo info); 1199 1200 /** 1201 * Like {@link #addPermission(PermissionInfo)} but asynchronously 1202 * persists the package manager state after returning from the call, 1203 * allowing it to return quicker and batch a series of adds at the 1204 * expense of no guarantee the added permission will be retained if 1205 * the device is rebooted before it is written. 1206 */ 1207 public abstract boolean addPermissionAsync(PermissionInfo info); 1208 1209 /** 1210 * Removes a permission that was previously added with 1211 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 1212 * -- you are only allowed to remove permissions that you are allowed 1213 * to add. 1214 * 1215 * @param name The name of the permission to remove. 1216 * 1217 * @throws SecurityException if you are not allowed to remove the 1218 * given permission name. 1219 * 1220 * @see #addPermission(PermissionInfo) 1221 */ 1222 public abstract void removePermission(String name); 1223 1224 /** 1225 * Compare the signatures of two packages to determine if the same 1226 * signature appears in both of them. If they do contain the same 1227 * signature, then they are allowed special privileges when working 1228 * with each other: they can share the same user-id, run instrumentation 1229 * against each other, etc. 1230 * 1231 * @param pkg1 First package name whose signature will be compared. 1232 * @param pkg2 Second package name whose signature will be compared. 1233 * @return Returns an integer indicating whether there is a matching 1234 * signature: the value is >= 0 if there is a match (or neither package 1235 * is signed), or < 0 if there is not a match. The match result can be 1236 * further distinguished with the success (>= 0) constants 1237 * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or 1238 * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED}, 1239 * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH}, 1240 * or {@link #SIGNATURE_UNKNOWN_PACKAGE}. 1241 * 1242 * @see #checkSignatures(int, int) 1243 * @see #SIGNATURE_MATCH 1244 * @see #SIGNATURE_NEITHER_SIGNED 1245 * @see #SIGNATURE_FIRST_NOT_SIGNED 1246 * @see #SIGNATURE_SECOND_NOT_SIGNED 1247 * @see #SIGNATURE_NO_MATCH 1248 * @see #SIGNATURE_UNKNOWN_PACKAGE 1249 */ 1250 public abstract int checkSignatures(String pkg1, String pkg2); 1251 1252 /** 1253 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 1254 * the two packages to be checked. This can be useful, for example, 1255 * when doing the check in an IPC, where the UID is the only identity 1256 * available. It is functionally identical to determining the package 1257 * associated with the UIDs and checking their signatures. 1258 * 1259 * @param uid1 First UID whose signature will be compared. 1260 * @param uid2 Second UID whose signature will be compared. 1261 * @return Returns an integer indicating whether there is a matching 1262 * signature: the value is >= 0 if there is a match (or neither package 1263 * is signed), or < 0 if there is not a match. The match result can be 1264 * further distinguished with the success (>= 0) constants 1265 * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or 1266 * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED}, 1267 * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH}, 1268 * or {@link #SIGNATURE_UNKNOWN_PACKAGE}. 1269 * 1270 * @see #checkSignatures(int, int) 1271 * @see #SIGNATURE_MATCH 1272 * @see #SIGNATURE_NEITHER_SIGNED 1273 * @see #SIGNATURE_FIRST_NOT_SIGNED 1274 * @see #SIGNATURE_SECOND_NOT_SIGNED 1275 * @see #SIGNATURE_NO_MATCH 1276 * @see #SIGNATURE_UNKNOWN_PACKAGE 1277 */ 1278 public abstract int checkSignatures(int uid1, int uid2); 1279 1280 /** 1281 * Retrieve the names of all packages that are associated with a particular 1282 * user id. In most cases, this will be a single package name, the package 1283 * that has been assigned that user id. Where there are multiple packages 1284 * sharing the same user id through the "sharedUserId" mechanism, all 1285 * packages with that id will be returned. 1286 * 1287 * @param uid The user id for which you would like to retrieve the 1288 * associated packages. 1289 * 1290 * @return Returns an array of one or more packages assigned to the user 1291 * id, or null if there are no known packages with the given id. 1292 */ 1293 public abstract String[] getPackagesForUid(int uid); 1294 1295 /** 1296 * Retrieve the official name associated with a user id. This name is 1297 * guaranteed to never change, though it is possibly for the underlying 1298 * user id to be changed. That is, if you are storing information about 1299 * user ids in persistent storage, you should use the string returned 1300 * by this function instead of the raw user-id. 1301 * 1302 * @param uid The user id for which you would like to retrieve a name. 1303 * @return Returns a unique name for the given user id, or null if the 1304 * user id is not currently assigned. 1305 */ 1306 public abstract String getNameForUid(int uid); 1307 1308 /** 1309 * Return the user id associated with a shared user name. Multiple 1310 * applications can specify a shared user name in their manifest and thus 1311 * end up using a common uid. This might be used for new applications 1312 * that use an existing shared user name and need to know the uid of the 1313 * shared user. 1314 * 1315 * @param sharedUserName The shared user name whose uid is to be retrieved. 1316 * @return Returns the uid associated with the shared user, or NameNotFoundException 1317 * if the shared user name is not being used by any installed packages 1318 * @hide 1319 */ 1320 public abstract int getUidForSharedUser(String sharedUserName) 1321 throws NameNotFoundException; 1322 1323 /** 1324 * Return a List of all application packages that are installed on the 1325 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 1326 * applications including those deleted with DONT_DELETE_DATA(partially 1327 * installed apps with data directory) will be returned. 1328 * 1329 * @param flags Additional option flags. Use any combination of 1330 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1331 * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1332 * 1333 * @return A List of ApplicationInfo objects, one for each application that 1334 * is installed on the device. In the unlikely case of there being 1335 * no installed applications, an empty list is returned. 1336 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1337 * applications including those deleted with DONT_DELETE_DATA 1338 * (partially installed apps with data directory) will be returned. 1339 * 1340 * @see #GET_META_DATA 1341 * @see #GET_SHARED_LIBRARY_FILES 1342 * @see #GET_UNINSTALLED_PACKAGES 1343 */ 1344 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 1345 1346 /** 1347 * Get a list of shared libraries that are available on the 1348 * system. 1349 * 1350 * @return An array of shared library names that are 1351 * available on the system, or null if none are installed. 1352 * 1353 */ 1354 public abstract String[] getSystemSharedLibraryNames(); 1355 1356 /** 1357 * Get a list of features that are available on the 1358 * system. 1359 * 1360 * @return An array of FeatureInfo classes describing the features 1361 * that are available on the system, or null if there are none(!!). 1362 */ 1363 public abstract FeatureInfo[] getSystemAvailableFeatures(); 1364 1365 /** 1366 * Check whether the given feature name is one of the available 1367 * features as returned by {@link #getSystemAvailableFeatures()}. 1368 * 1369 * @return Returns true if the devices supports the feature, else 1370 * false. 1371 */ 1372 public abstract boolean hasSystemFeature(String name); 1373 1374 /** 1375 * Determine the best action to perform for a given Intent. This is how 1376 * {@link Intent#resolveActivity} finds an activity if a class has not 1377 * been explicitly specified. 1378 * 1379 * @param intent An intent containing all of the desired specification 1380 * (action, data, type, category, and/or component). 1381 * @param flags Additional option flags. The most important is 1382 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1383 * those activities that support the CATEGORY_DEFAULT. 1384 * 1385 * @return Returns a ResolveInfo containing the final activity intent that 1386 * was determined to be the best action. Returns null if no 1387 * matching activity was found. If multiple matching activities are 1388 * found and there is no default set, returns a ResolveInfo 1389 * containing something else, such as the activity resolver. 1390 * 1391 * @see #MATCH_DEFAULT_ONLY 1392 * @see #GET_INTENT_FILTERS 1393 * @see #GET_RESOLVED_FILTER 1394 */ 1395 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 1396 1397 /** 1398 * Retrieve all activities that can be performed for the given intent. 1399 * 1400 * @param intent The desired intent as per resolveActivity(). 1401 * @param flags Additional option flags. The most important is 1402 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1403 * those activities that support the CATEGORY_DEFAULT. 1404 * 1405 * @return A List<ResolveInfo> containing one entry for each matching 1406 * Activity. These are ordered from best to worst match -- that 1407 * is, the first item in the list is what is returned by 1408 * resolveActivity(). If there are no matching activities, an empty 1409 * list is returned. 1410 * 1411 * @see #MATCH_DEFAULT_ONLY 1412 * @see #GET_INTENT_FILTERS 1413 * @see #GET_RESOLVED_FILTER 1414 */ 1415 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 1416 int flags); 1417 1418 /** 1419 * Retrieve a set of activities that should be presented to the user as 1420 * similar options. This is like {@link #queryIntentActivities}, except it 1421 * also allows you to supply a list of more explicit Intents that you would 1422 * like to resolve to particular options, and takes care of returning the 1423 * final ResolveInfo list in a reasonable order, with no duplicates, based 1424 * on those inputs. 1425 * 1426 * @param caller The class name of the activity that is making the 1427 * request. This activity will never appear in the output 1428 * list. Can be null. 1429 * @param specifics An array of Intents that should be resolved to the 1430 * first specific results. Can be null. 1431 * @param intent The desired intent as per resolveActivity(). 1432 * @param flags Additional option flags. The most important is 1433 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1434 * those activities that support the CATEGORY_DEFAULT. 1435 * 1436 * @return A List<ResolveInfo> containing one entry for each matching 1437 * Activity. These are ordered first by all of the intents resolved 1438 * in <var>specifics</var> and then any additional activities that 1439 * can handle <var>intent</var> but did not get included by one of 1440 * the <var>specifics</var> intents. If there are no matching 1441 * activities, an empty list is returned. 1442 * 1443 * @see #MATCH_DEFAULT_ONLY 1444 * @see #GET_INTENT_FILTERS 1445 * @see #GET_RESOLVED_FILTER 1446 */ 1447 public abstract List<ResolveInfo> queryIntentActivityOptions( 1448 ComponentName caller, Intent[] specifics, Intent intent, int flags); 1449 1450 /** 1451 * Retrieve all receivers that can handle a broadcast of the given intent. 1452 * 1453 * @param intent The desired intent as per resolveActivity(). 1454 * @param flags Additional option flags. The most important is 1455 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1456 * those activities that support the CATEGORY_DEFAULT. 1457 * 1458 * @return A List<ResolveInfo> containing one entry for each matching 1459 * Receiver. These are ordered from first to last in priority. If 1460 * there are no matching receivers, an empty list is returned. 1461 * 1462 * @see #MATCH_DEFAULT_ONLY 1463 * @see #GET_INTENT_FILTERS 1464 * @see #GET_RESOLVED_FILTER 1465 */ 1466 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 1467 int flags); 1468 1469 /** 1470 * Determine the best service to handle for a given Intent. 1471 * 1472 * @param intent An intent containing all of the desired specification 1473 * (action, data, type, category, and/or component). 1474 * @param flags Additional option flags. 1475 * 1476 * @return Returns a ResolveInfo containing the final service intent that 1477 * was determined to be the best action. Returns null if no 1478 * matching service was found. 1479 * 1480 * @see #GET_INTENT_FILTERS 1481 * @see #GET_RESOLVED_FILTER 1482 */ 1483 public abstract ResolveInfo resolveService(Intent intent, int flags); 1484 1485 /** 1486 * Retrieve all services that can match the given intent. 1487 * 1488 * @param intent The desired intent as per resolveService(). 1489 * @param flags Additional option flags. 1490 * 1491 * @return A List<ResolveInfo> containing one entry for each matching 1492 * ServiceInfo. These are ordered from best to worst match -- that 1493 * is, the first item in the list is what is returned by 1494 * resolveService(). If there are no matching services, an empty 1495 * list is returned. 1496 * 1497 * @see #GET_INTENT_FILTERS 1498 * @see #GET_RESOLVED_FILTER 1499 */ 1500 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 1501 int flags); 1502 1503 /** 1504 * Find a single content provider by its base path name. 1505 * 1506 * @param name The name of the provider to find. 1507 * @param flags Additional option flags. Currently should always be 0. 1508 * 1509 * @return ContentProviderInfo Information about the provider, if found, 1510 * else null. 1511 */ 1512 public abstract ProviderInfo resolveContentProvider(String name, 1513 int flags); 1514 1515 /** 1516 * Retrieve content provider information. 1517 * 1518 * <p><em>Note: unlike most other methods, an empty result set is indicated 1519 * by a null return instead of an empty list.</em> 1520 * 1521 * @param processName If non-null, limits the returned providers to only 1522 * those that are hosted by the given process. If null, 1523 * all content providers are returned. 1524 * @param uid If <var>processName</var> is non-null, this is the required 1525 * uid owning the requested content providers. 1526 * @param flags Additional option flags. Currently should always be 0. 1527 * 1528 * @return A List<ContentProviderInfo> containing one entry for each 1529 * content provider either patching <var>processName</var> or, if 1530 * <var>processName</var> is null, all known content providers. 1531 * <em>If there are no matching providers, null is returned.</em> 1532 */ 1533 public abstract List<ProviderInfo> queryContentProviders( 1534 String processName, int uid, int flags); 1535 1536 /** 1537 * Retrieve all of the information we know about a particular 1538 * instrumentation class. 1539 * 1540 * <p>Throws {@link NameNotFoundException} if instrumentation with the 1541 * given class name can not be found on the system. 1542 * 1543 * @param className The full name (i.e. 1544 * com.google.apps.contacts.InstrumentList) of an 1545 * Instrumentation class. 1546 * @param flags Additional option flags. Currently should always be 0. 1547 * 1548 * @return InstrumentationInfo containing information about the 1549 * instrumentation. 1550 */ 1551 public abstract InstrumentationInfo getInstrumentationInfo( 1552 ComponentName className, int flags) throws NameNotFoundException; 1553 1554 /** 1555 * Retrieve information about available instrumentation code. May be used 1556 * to retrieve either all instrumentation code, or only the code targeting 1557 * a particular package. 1558 * 1559 * @param targetPackage If null, all instrumentation is returned; only the 1560 * instrumentation targeting this package name is 1561 * returned. 1562 * @param flags Additional option flags. Currently should always be 0. 1563 * 1564 * @return A List<InstrumentationInfo> containing one entry for each 1565 * matching available Instrumentation. Returns an empty list if 1566 * there is no instrumentation available for the given package. 1567 */ 1568 public abstract List<InstrumentationInfo> queryInstrumentation( 1569 String targetPackage, int flags); 1570 1571 /** 1572 * Retrieve an image from a package. This is a low-level API used by 1573 * the various package manager info structures (such as 1574 * {@link ComponentInfo} to implement retrieval of their associated 1575 * icon. 1576 * 1577 * @param packageName The name of the package that this icon is coming from. 1578 * Can not be null. 1579 * @param resid The resource identifier of the desired image. Can not be 0. 1580 * @param appInfo Overall information about <var>packageName</var>. This 1581 * may be null, in which case the application information will be retrieved 1582 * for you if needed; if you already have this information around, it can 1583 * be much more efficient to supply it here. 1584 * 1585 * @return Returns a Drawable holding the requested image. Returns null if 1586 * an image could not be found for any reason. 1587 */ 1588 public abstract Drawable getDrawable(String packageName, int resid, 1589 ApplicationInfo appInfo); 1590 1591 /** 1592 * Retrieve the icon associated with an activity. Given the full name of 1593 * an activity, retrieves the information about it and calls 1594 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 1595 * If the activity can not be found, NameNotFoundException is thrown. 1596 * 1597 * @param activityName Name of the activity whose icon is to be retrieved. 1598 * 1599 * @return Returns the image of the icon, or the default activity icon if 1600 * it could not be found. Does not return null. 1601 * @throws NameNotFoundException Thrown if the resources for the given 1602 * activity could not be loaded. 1603 * 1604 * @see #getActivityIcon(Intent) 1605 */ 1606 public abstract Drawable getActivityIcon(ComponentName activityName) 1607 throws NameNotFoundException; 1608 1609 /** 1610 * Retrieve the icon associated with an Intent. If intent.getClassName() is 1611 * set, this simply returns the result of 1612 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 1613 * component and returns the icon associated with the resolved component. 1614 * If intent.getClassName() can not be found or the Intent can not be resolved 1615 * to a component, NameNotFoundException is thrown. 1616 * 1617 * @param intent The intent for which you would like to retrieve an icon. 1618 * 1619 * @return Returns the image of the icon, or the default activity icon if 1620 * it could not be found. Does not return null. 1621 * @throws NameNotFoundException Thrown if the resources for application 1622 * matching the given intent could not be loaded. 1623 * 1624 * @see #getActivityIcon(ComponentName) 1625 */ 1626 public abstract Drawable getActivityIcon(Intent intent) 1627 throws NameNotFoundException; 1628 1629 /** 1630 * Return the generic icon for an activity that is used when no specific 1631 * icon is defined. 1632 * 1633 * @return Drawable Image of the icon. 1634 */ 1635 public abstract Drawable getDefaultActivityIcon(); 1636 1637 /** 1638 * Retrieve the icon associated with an application. If it has not defined 1639 * an icon, the default app icon is returned. Does not return null. 1640 * 1641 * @param info Information about application being queried. 1642 * 1643 * @return Returns the image of the icon, or the default application icon 1644 * if it could not be found. 1645 * 1646 * @see #getApplicationIcon(String) 1647 */ 1648 public abstract Drawable getApplicationIcon(ApplicationInfo info); 1649 1650 /** 1651 * Retrieve the icon associated with an application. Given the name of the 1652 * application's package, retrieves the information about it and calls 1653 * getApplicationIcon() to return its icon. If the application can not be 1654 * found, NameNotFoundException is thrown. 1655 * 1656 * @param packageName Name of the package whose application icon is to be 1657 * retrieved. 1658 * 1659 * @return Returns the image of the icon, or the default application icon 1660 * if it could not be found. Does not return null. 1661 * @throws NameNotFoundException Thrown if the resources for the given 1662 * application could not be loaded. 1663 * 1664 * @see #getApplicationIcon(ApplicationInfo) 1665 */ 1666 public abstract Drawable getApplicationIcon(String packageName) 1667 throws NameNotFoundException; 1668 1669 /** 1670 * Retrieve the logo associated with an activity. Given the full name of 1671 * an activity, retrieves the information about it and calls 1672 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo. 1673 * If the activity can not be found, NameNotFoundException is thrown. 1674 * 1675 * @param activityName Name of the activity whose logo is to be retrieved. 1676 * 1677 * @return Returns the image of the logo or null if the activity has no 1678 * logo specified. 1679 * 1680 * @throws NameNotFoundException Thrown if the resources for the given 1681 * activity could not be loaded. 1682 * 1683 * @see #getActivityLogo(Intent) 1684 */ 1685 public abstract Drawable getActivityLogo(ComponentName activityName) 1686 throws NameNotFoundException; 1687 1688 /** 1689 * Retrieve the logo associated with an Intent. If intent.getClassName() is 1690 * set, this simply returns the result of 1691 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 1692 * component and returns the logo associated with the resolved component. 1693 * If intent.getClassName() can not be found or the Intent can not be resolved 1694 * to a component, NameNotFoundException is thrown. 1695 * 1696 * @param intent The intent for which you would like to retrieve a logo. 1697 * 1698 * @return Returns the image of the logo, or null if the activity has no 1699 * logo specified. 1700 * 1701 * @throws NameNotFoundException Thrown if the resources for application 1702 * matching the given intent could not be loaded. 1703 * 1704 * @see #getActivityLogo(ComponentName) 1705 */ 1706 public abstract Drawable getActivityLogo(Intent intent) 1707 throws NameNotFoundException; 1708 1709 /** 1710 * Retrieve the logo associated with an application. If it has not specified 1711 * a logo, this method returns null. 1712 * 1713 * @param info Information about application being queried. 1714 * 1715 * @return Returns the image of the logo, or null if no logo is specified 1716 * by the application. 1717 * 1718 * @see #getApplicationLogo(String) 1719 */ 1720 public abstract Drawable getApplicationLogo(ApplicationInfo info); 1721 1722 /** 1723 * Retrieve the logo associated with an application. Given the name of the 1724 * application's package, retrieves the information about it and calls 1725 * getApplicationLogo() to return its logo. If the application can not be 1726 * found, NameNotFoundException is thrown. 1727 * 1728 * @param packageName Name of the package whose application logo is to be 1729 * retrieved. 1730 * 1731 * @return Returns the image of the logo, or null if no application logo 1732 * has been specified. 1733 * 1734 * @throws NameNotFoundException Thrown if the resources for the given 1735 * application could not be loaded. 1736 * 1737 * @see #getApplicationLogo(ApplicationInfo) 1738 */ 1739 public abstract Drawable getApplicationLogo(String packageName) 1740 throws NameNotFoundException; 1741 1742 /** 1743 * Retrieve text from a package. This is a low-level API used by 1744 * the various package manager info structures (such as 1745 * {@link ComponentInfo} to implement retrieval of their associated 1746 * labels and other text. 1747 * 1748 * @param packageName The name of the package that this text is coming from. 1749 * Can not be null. 1750 * @param resid The resource identifier of the desired text. Can not be 0. 1751 * @param appInfo Overall information about <var>packageName</var>. This 1752 * may be null, in which case the application information will be retrieved 1753 * for you if needed; if you already have this information around, it can 1754 * be much more efficient to supply it here. 1755 * 1756 * @return Returns a CharSequence holding the requested text. Returns null 1757 * if the text could not be found for any reason. 1758 */ 1759 public abstract CharSequence getText(String packageName, int resid, 1760 ApplicationInfo appInfo); 1761 1762 /** 1763 * Retrieve an XML file from a package. This is a low-level API used to 1764 * retrieve XML meta data. 1765 * 1766 * @param packageName The name of the package that this xml is coming from. 1767 * Can not be null. 1768 * @param resid The resource identifier of the desired xml. Can not be 0. 1769 * @param appInfo Overall information about <var>packageName</var>. This 1770 * may be null, in which case the application information will be retrieved 1771 * for you if needed; if you already have this information around, it can 1772 * be much more efficient to supply it here. 1773 * 1774 * @return Returns an XmlPullParser allowing you to parse out the XML 1775 * data. Returns null if the xml resource could not be found for any 1776 * reason. 1777 */ 1778 public abstract XmlResourceParser getXml(String packageName, int resid, 1779 ApplicationInfo appInfo); 1780 1781 /** 1782 * Return the label to use for this application. 1783 * 1784 * @return Returns the label associated with this application, or null if 1785 * it could not be found for any reason. 1786 * @param info The application to get the label of 1787 */ 1788 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 1789 1790 /** 1791 * Retrieve the resources associated with an activity. Given the full 1792 * name of an activity, retrieves the information about it and calls 1793 * getResources() to return its application's resources. If the activity 1794 * can not be found, NameNotFoundException is thrown. 1795 * 1796 * @param activityName Name of the activity whose resources are to be 1797 * retrieved. 1798 * 1799 * @return Returns the application's Resources. 1800 * @throws NameNotFoundException Thrown if the resources for the given 1801 * application could not be loaded. 1802 * 1803 * @see #getResourcesForApplication(ApplicationInfo) 1804 */ 1805 public abstract Resources getResourcesForActivity(ComponentName activityName) 1806 throws NameNotFoundException; 1807 1808 /** 1809 * Retrieve the resources for an application. Throws NameNotFoundException 1810 * if the package is no longer installed. 1811 * 1812 * @param app Information about the desired application. 1813 * 1814 * @return Returns the application's Resources. 1815 * @throws NameNotFoundException Thrown if the resources for the given 1816 * application could not be loaded (most likely because it was uninstalled). 1817 */ 1818 public abstract Resources getResourcesForApplication(ApplicationInfo app) 1819 throws NameNotFoundException; 1820 1821 /** 1822 * Retrieve the resources associated with an application. Given the full 1823 * package name of an application, retrieves the information about it and 1824 * calls getResources() to return its application's resources. If the 1825 * appPackageName can not be found, NameNotFoundException is thrown. 1826 * 1827 * @param appPackageName Package name of the application whose resources 1828 * are to be retrieved. 1829 * 1830 * @return Returns the application's Resources. 1831 * @throws NameNotFoundException Thrown if the resources for the given 1832 * application could not be loaded. 1833 * 1834 * @see #getResourcesForApplication(ApplicationInfo) 1835 */ 1836 public abstract Resources getResourcesForApplication(String appPackageName) 1837 throws NameNotFoundException; 1838 1839 /** 1840 * Retrieve overall information about an application package defined 1841 * in a package archive file 1842 * 1843 * @param archiveFilePath The path to the archive file 1844 * @param flags Additional option flags. Use any combination of 1845 * {@link #GET_ACTIVITIES}, 1846 * {@link #GET_GIDS}, 1847 * {@link #GET_CONFIGURATIONS}, 1848 * {@link #GET_INSTRUMENTATION}, 1849 * {@link #GET_PERMISSIONS}, 1850 * {@link #GET_PROVIDERS}, 1851 * {@link #GET_RECEIVERS}, 1852 * {@link #GET_SERVICES}, 1853 * {@link #GET_SIGNATURES}, to modify the data returned. 1854 * 1855 * @return Returns the information about the package. Returns 1856 * null if the package could not be successfully parsed. 1857 * 1858 * @see #GET_ACTIVITIES 1859 * @see #GET_GIDS 1860 * @see #GET_CONFIGURATIONS 1861 * @see #GET_INSTRUMENTATION 1862 * @see #GET_PERMISSIONS 1863 * @see #GET_PROVIDERS 1864 * @see #GET_RECEIVERS 1865 * @see #GET_SERVICES 1866 * @see #GET_SIGNATURES 1867 * 1868 */ 1869 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 1870 PackageParser packageParser = new PackageParser(archiveFilePath); 1871 DisplayMetrics metrics = new DisplayMetrics(); 1872 metrics.setToDefaults(); 1873 final File sourceFile = new File(archiveFilePath); 1874 PackageParser.Package pkg = packageParser.parsePackage( 1875 sourceFile, archiveFilePath, metrics, 0); 1876 if (pkg == null) { 1877 return null; 1878 } 1879 return PackageParser.generatePackageInfo(pkg, null, flags); 1880 } 1881 1882 /** 1883 * @hide 1884 * 1885 * Install a package. Since this may take a little while, the result will 1886 * be posted back to the given observer. An installation will fail if the calling context 1887 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 1888 * package named in the package file's manifest is already installed, or if there's no space 1889 * available on the device. 1890 * 1891 * @param packageURI The location of the package file to install. This can be a 'file:' or a 1892 * 'content:' URI. 1893 * @param observer An observer callback to get notified when the package installation is 1894 * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be 1895 * called when that happens. observer may be null to indicate that no callback is desired. 1896 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 1897 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 1898 * @param installerPackageName Optional package name of the application that is performing the 1899 * installation. This identifies which market the package came from. 1900 */ 1901 public abstract void installPackage( 1902 Uri packageURI, IPackageInstallObserver observer, int flags, 1903 String installerPackageName); 1904 1905 /** 1906 * Attempts to delete a package. Since this may take a little while, the result will 1907 * be posted back to the given observer. A deletion will fail if the calling context 1908 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 1909 * named package cannot be found, or if the named package is a "system package". 1910 * (TODO: include pointer to documentation on "system packages") 1911 * 1912 * @param packageName The name of the package to delete 1913 * @param observer An observer callback to get notified when the package deletion is 1914 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 1915 * called when that happens. observer may be null to indicate that no callback is desired. 1916 * @param flags - possible values: {@link #DONT_DELETE_DATA} 1917 * 1918 * @hide 1919 */ 1920 public abstract void deletePackage( 1921 String packageName, IPackageDeleteObserver observer, int flags); 1922 1923 /** 1924 * Retrieve the package name of the application that installed a package. This identifies 1925 * which market the package came from. 1926 * 1927 * @param packageName The name of the package to query 1928 */ 1929 public abstract String getInstallerPackageName(String packageName); 1930 1931 /** 1932 * Attempts to clear the user data directory of an application. 1933 * Since this may take a little while, the result will 1934 * be posted back to the given observer. A deletion will fail if the 1935 * named package cannot be found, or if the named package is a "system package". 1936 * 1937 * @param packageName The name of the package 1938 * @param observer An observer callback to get notified when the operation is finished 1939 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 1940 * will be called when that happens. observer may be null to indicate that 1941 * no callback is desired. 1942 * 1943 * @hide 1944 */ 1945 public abstract void clearApplicationUserData(String packageName, 1946 IPackageDataObserver observer); 1947 /** 1948 * Attempts to delete the cache files associated with an application. 1949 * Since this may take a little while, the result will 1950 * be posted back to the given observer. A deletion will fail if the calling context 1951 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 1952 * named package cannot be found, or if the named package is a "system package". 1953 * 1954 * @param packageName The name of the package to delete 1955 * @param observer An observer callback to get notified when the cache file deletion 1956 * is complete. 1957 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 1958 * will be called when that happens. observer may be null to indicate that 1959 * no callback is desired. 1960 * 1961 * @hide 1962 */ 1963 public abstract void deleteApplicationCacheFiles(String packageName, 1964 IPackageDataObserver observer); 1965 1966 /** 1967 * Free storage by deleting LRU sorted list of cache files across 1968 * all applications. If the currently available free storage 1969 * on the device is greater than or equal to the requested 1970 * free storage, no cache files are cleared. If the currently 1971 * available storage on the device is less than the requested 1972 * free storage, some or all of the cache files across 1973 * all applications are deleted (based on last accessed time) 1974 * to increase the free storage space on the device to 1975 * the requested value. There is no guarantee that clearing all 1976 * the cache files from all applications will clear up 1977 * enough storage to achieve the desired value. 1978 * @param freeStorageSize The number of bytes of storage to be 1979 * freed by the system. Say if freeStorageSize is XX, 1980 * and the current free storage is YY, 1981 * if XX is less than YY, just return. if not free XX-YY number 1982 * of bytes if possible. 1983 * @param observer call back used to notify when 1984 * the operation is completed 1985 * 1986 * @hide 1987 */ 1988 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); 1989 1990 /** 1991 * Free storage by deleting LRU sorted list of cache files across 1992 * all applications. If the currently available free storage 1993 * on the device is greater than or equal to the requested 1994 * free storage, no cache files are cleared. If the currently 1995 * available storage on the device is less than the requested 1996 * free storage, some or all of the cache files across 1997 * all applications are deleted (based on last accessed time) 1998 * to increase the free storage space on the device to 1999 * the requested value. There is no guarantee that clearing all 2000 * the cache files from all applications will clear up 2001 * enough storage to achieve the desired value. 2002 * @param freeStorageSize The number of bytes of storage to be 2003 * freed by the system. Say if freeStorageSize is XX, 2004 * and the current free storage is YY, 2005 * if XX is less than YY, just return. if not free XX-YY number 2006 * of bytes if possible. 2007 * @param pi IntentSender call back used to 2008 * notify when the operation is completed.May be null 2009 * to indicate that no call back is desired. 2010 * 2011 * @hide 2012 */ 2013 public abstract void freeStorage(long freeStorageSize, IntentSender pi); 2014 2015 /** 2016 * Retrieve the size information for a package. 2017 * Since this may take a little while, the result will 2018 * be posted back to the given observer. The calling context 2019 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 2020 * 2021 * @param packageName The name of the package whose size information is to be retrieved 2022 * @param observer An observer callback to get notified when the operation 2023 * is complete. 2024 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 2025 * The observer's callback is invoked with a PackageStats object(containing the 2026 * code, data and cache sizes of the package) and a boolean value representing 2027 * the status of the operation. observer may be null to indicate that 2028 * no callback is desired. 2029 * 2030 * @hide 2031 */ 2032 public abstract void getPackageSizeInfo(String packageName, 2033 IPackageStatsObserver observer); 2034 2035 /** 2036 * @deprecated This function no longer does anything; it was an old 2037 * approach to managing preferred activities, which has been superceeded 2038 * (and conflicts with) the modern activity-based preferences. 2039 */ 2040 @Deprecated 2041 public abstract void addPackageToPreferred(String packageName); 2042 2043 /** 2044 * @deprecated This function no longer does anything; it was an old 2045 * approach to managing preferred activities, which has been superceeded 2046 * (and conflicts with) the modern activity-based preferences. 2047 */ 2048 @Deprecated 2049 public abstract void removePackageFromPreferred(String packageName); 2050 2051 /** 2052 * Retrieve the list of all currently configured preferred packages. The 2053 * first package on the list is the most preferred, the last is the 2054 * least preferred. 2055 * 2056 * @param flags Additional option flags. Use any combination of 2057 * {@link #GET_ACTIVITIES}, 2058 * {@link #GET_GIDS}, 2059 * {@link #GET_CONFIGURATIONS}, 2060 * {@link #GET_INSTRUMENTATION}, 2061 * {@link #GET_PERMISSIONS}, 2062 * {@link #GET_PROVIDERS}, 2063 * {@link #GET_RECEIVERS}, 2064 * {@link #GET_SERVICES}, 2065 * {@link #GET_SIGNATURES}, to modify the data returned. 2066 * 2067 * @return Returns a list of PackageInfo objects describing each 2068 * preferred application, in order of preference. 2069 * 2070 * @see #GET_ACTIVITIES 2071 * @see #GET_GIDS 2072 * @see #GET_CONFIGURATIONS 2073 * @see #GET_INSTRUMENTATION 2074 * @see #GET_PERMISSIONS 2075 * @see #GET_PROVIDERS 2076 * @see #GET_RECEIVERS 2077 * @see #GET_SERVICES 2078 * @see #GET_SIGNATURES 2079 */ 2080 public abstract List<PackageInfo> getPreferredPackages(int flags); 2081 2082 /** 2083 * @deprecated This is a protected API that should not have been available 2084 * to third party applications. It is the platform's responsibility for 2085 * assigning preferred activities and this can not be directly modified. 2086 * 2087 * Add a new preferred activity mapping to the system. This will be used 2088 * to automatically select the given activity component when 2089 * {@link Context#startActivity(Intent) Context.startActivity()} finds 2090 * multiple matching activities and also matches the given filter. 2091 * 2092 * @param filter The set of intents under which this activity will be 2093 * made preferred. 2094 * @param match The IntentFilter match category that this preference 2095 * applies to. 2096 * @param set The set of activities that the user was picking from when 2097 * this preference was made. 2098 * @param activity The component name of the activity that is to be 2099 * preferred. 2100 */ 2101 @Deprecated 2102 public abstract void addPreferredActivity(IntentFilter filter, int match, 2103 ComponentName[] set, ComponentName activity); 2104 2105 /** 2106 * @deprecated This is a protected API that should not have been available 2107 * to third party applications. It is the platform's responsibility for 2108 * assigning preferred activities and this can not be directly modified. 2109 * 2110 * Replaces an existing preferred activity mapping to the system, and if that were not present 2111 * adds a new preferred activity. This will be used 2112 * to automatically select the given activity component when 2113 * {@link Context#startActivity(Intent) Context.startActivity()} finds 2114 * multiple matching activities and also matches the given filter. 2115 * 2116 * @param filter The set of intents under which this activity will be 2117 * made preferred. 2118 * @param match The IntentFilter match category that this preference 2119 * applies to. 2120 * @param set The set of activities that the user was picking from when 2121 * this preference was made. 2122 * @param activity The component name of the activity that is to be 2123 * preferred. 2124 * @hide 2125 */ 2126 @Deprecated 2127 public abstract void replacePreferredActivity(IntentFilter filter, int match, 2128 ComponentName[] set, ComponentName activity); 2129 2130 /** 2131 * Remove all preferred activity mappings, previously added with 2132 * {@link #addPreferredActivity}, from the 2133 * system whose activities are implemented in the given package name. 2134 * An application can only clear its own package(s). 2135 * 2136 * @param packageName The name of the package whose preferred activity 2137 * mappings are to be removed. 2138 */ 2139 public abstract void clearPackagePreferredActivities(String packageName); 2140 2141 /** 2142 * Retrieve all preferred activities, previously added with 2143 * {@link #addPreferredActivity}, that are 2144 * currently registered with the system. 2145 * 2146 * @param outFilters A list in which to place the filters of all of the 2147 * preferred activities, or null for none. 2148 * @param outActivities A list in which to place the component names of 2149 * all of the preferred activities, or null for none. 2150 * @param packageName An option package in which you would like to limit 2151 * the list. If null, all activities will be returned; if non-null, only 2152 * those activities in the given package are returned. 2153 * 2154 * @return Returns the total number of registered preferred activities 2155 * (the number of distinct IntentFilter records, not the number of unique 2156 * activity components) that were found. 2157 */ 2158 public abstract int getPreferredActivities(List<IntentFilter> outFilters, 2159 List<ComponentName> outActivities, String packageName); 2160 2161 /** 2162 * Set the enabled setting for a package component (activity, receiver, service, provider). 2163 * This setting will override any enabled state which may have been set by the component in its 2164 * manifest. 2165 * 2166 * @param componentName The component to enable 2167 * @param newState The new enabled state for the component. The legal values for this state 2168 * are: 2169 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2170 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2171 * and 2172 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2173 * The last one removes the setting, thereby restoring the component's state to 2174 * whatever was set in it's manifest (or enabled, by default). 2175 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2176 */ 2177 public abstract void setComponentEnabledSetting(ComponentName componentName, 2178 int newState, int flags); 2179 2180 2181 /** 2182 * Return the the enabled setting for a package component (activity, 2183 * receiver, service, provider). This returns the last value set by 2184 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 2185 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2186 * the value originally specified in the manifest has not been modified. 2187 * 2188 * @param componentName The component to retrieve. 2189 * @return Returns the current enabled state for the component. May 2190 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2191 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2192 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2193 * component's enabled state is based on the original information in 2194 * the manifest as found in {@link ComponentInfo}. 2195 */ 2196 public abstract int getComponentEnabledSetting(ComponentName componentName); 2197 2198 /** 2199 * Set the enabled setting for an application 2200 * This setting will override any enabled state which may have been set by the application in 2201 * its manifest. It also overrides the enabled state set in the manifest for any of the 2202 * application's components. It does not override any enabled state set by 2203 * {@link #setComponentEnabledSetting} for any of the application's components. 2204 * 2205 * @param packageName The package name of the application to enable 2206 * @param newState The new enabled state for the component. The legal values for this state 2207 * are: 2208 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2209 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2210 * and 2211 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2212 * The last one removes the setting, thereby restoring the applications's state to 2213 * whatever was set in its manifest (or enabled, by default). 2214 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2215 */ 2216 public abstract void setApplicationEnabledSetting(String packageName, 2217 int newState, int flags); 2218 2219 /** 2220 * Return the the enabled setting for an application. This returns 2221 * the last value set by 2222 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 2223 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2224 * the value originally specified in the manifest has not been modified. 2225 * 2226 * @param packageName The component to retrieve. 2227 * @return Returns the current enabled state for the component. May 2228 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2229 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2230 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2231 * application's enabled state is based on the original information in 2232 * the manifest as found in {@link ComponentInfo}. 2233 */ 2234 public abstract int getApplicationEnabledSetting(String packageName); 2235 2236 /** 2237 * Return whether the device has been booted into safe mode. 2238 */ 2239 public abstract boolean isSafeMode(); 2240 2241 /** 2242 * Attempts to move package resources from internal to external media or vice versa. 2243 * Since this may take a little while, the result will 2244 * be posted back to the given observer. This call may fail if the calling context 2245 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 2246 * named package cannot be found, or if the named package is a "system package". 2247 * 2248 * @param packageName The name of the package to delete 2249 * @param observer An observer callback to get notified when the package move is 2250 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 2251 * called when that happens. observer may be null to indicate that no callback is desired. 2252 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 2253 * {@link #MOVE_EXTERNAL_MEDIA} 2254 * 2255 * @hide 2256 */ 2257 public abstract void movePackage( 2258 String packageName, IPackageMoveObserver observer, int flags); 2259 2260 /** 2261 * Sets the Opaque Binary Blob (OBB) file location. 2262 * <p> 2263 * NOTE: The existence or format of this file is not currently checked, but 2264 * it may be in the future. 2265 * 2266 * @param packageName Name of the package with which to associate the .obb 2267 * file 2268 * @param path Path on the filesystem to the .obb file 2269 * @hide 2270 */ 2271 public abstract void setPackageObbPath(String packageName, String path); 2272} 2273