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