PackageManager.java revision 8a9ab24a5c9b595ac0268fcade4b5bbfe7c45c2d
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 it's 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 265 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 266 * that you don't want to kill the app containing the component. Be careful when you set this 267 * since changing component states can make the containing application's behavior unpredictable. 268 */ 269 public static final int DONT_KILL_APP = 0x00000001; 270 271 /** 272 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 273 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success. 274 * @hide 275 */ 276 public static final int INSTALL_SUCCEEDED = 1; 277 278 /** 279 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 280 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is 281 * already installed. 282 * @hide 283 */ 284 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 285 286 /** 287 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 288 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive 289 * file is invalid. 290 * @hide 291 */ 292 public static final int INSTALL_FAILED_INVALID_APK = -2; 293 294 /** 295 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 296 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in 297 * is invalid. 298 * @hide 299 */ 300 public static final int INSTALL_FAILED_INVALID_URI = -3; 301 302 /** 303 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 304 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager 305 * service found that the device didn't have enough storage space to install the app. 306 * @hide 307 */ 308 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 309 310 /** 311 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 312 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a 313 * package is already installed with the same name. 314 * @hide 315 */ 316 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 317 318 /** 319 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 320 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 321 * the requested shared user does not exist. 322 * @hide 323 */ 324 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 325 326 /** 327 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 328 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 329 * a previously installed package of the same name has a different signature 330 * than the new package (and the old package's data was not removed). 331 * @hide 332 */ 333 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 334 335 /** 336 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 337 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 338 * the new package is requested a shared user which is already installed on the 339 * device and does not have matching signature. 340 * @hide 341 */ 342 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 343 344 /** 345 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 346 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 347 * the new package uses a shared library that is not available. 348 * @hide 349 */ 350 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 351 352 /** 353 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 354 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 355 * the new package uses a shared library that is not available. 356 * @hide 357 */ 358 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 359 360 /** 361 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 362 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 363 * the new package failed while optimizing and validating its dex files, 364 * either because there was not enough storage or the validation failed. 365 * @hide 366 */ 367 public static final int INSTALL_FAILED_DEXOPT = -11; 368 369 /** 370 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 371 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 372 * the new package failed because the current SDK version is older than 373 * that required by the package. 374 * @hide 375 */ 376 public static final int INSTALL_FAILED_OLDER_SDK = -12; 377 378 /** 379 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 380 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 381 * the new package failed because it contains a content provider with the 382 * same authority as a provider already installed in the system. 383 * @hide 384 */ 385 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 386 387 /** 388 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 389 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 390 * the new package failed because the current SDK version is newer than 391 * that required by the package. 392 * @hide 393 */ 394 public static final int INSTALL_FAILED_NEWER_SDK = -14; 395 396 /** 397 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 398 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 399 * the new package failed because it has specified that it is a test-only 400 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST} 401 * flag. 402 * @hide 403 */ 404 public static final int INSTALL_FAILED_TEST_ONLY = -15; 405 406 /** 407 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 408 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 409 * the package being installed contains native code, but none that is 410 * compatible with the the device's CPU_ABI. 411 * @hide 412 */ 413 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 414 415 /** 416 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 417 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 418 * the new package uses a feature that is not available. 419 * @hide 420 */ 421 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 422 423 // ------ Errors related to sdcard 424 /** 425 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 426 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 427 * a secure container mount point couldn't be accessed on external media. 428 * @hide 429 */ 430 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 431 432 /** 433 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 434 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 435 * the new package couldn't be installed in the specified install 436 * location. 437 * @hide 438 */ 439 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 440 441 /** 442 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 443 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 444 * the new package couldn't be installed in the specified install 445 * location because the media is not available. 446 * @hide 447 */ 448 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 449 450 /** 451 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 452 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 453 * if the parser was given a path that is not a file, or does not end with the expected 454 * '.apk' extension. 455 * @hide 456 */ 457 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 458 459 /** 460 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 461 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 462 * if the parser was unable to retrieve the AndroidManifest.xml file. 463 * @hide 464 */ 465 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 466 467 /** 468 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 469 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 470 * if the parser encountered an unexpected exception. 471 * @hide 472 */ 473 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 474 475 /** 476 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 477 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 478 * if the parser did not find any certificates in the .apk. 479 * @hide 480 */ 481 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 482 483 /** 484 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 485 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 486 * if the parser found inconsistent certificates on the files in the .apk. 487 * @hide 488 */ 489 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 490 491 /** 492 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 493 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 494 * if the parser encountered a CertificateEncodingException in one of the 495 * files in the .apk. 496 * @hide 497 */ 498 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 499 500 /** 501 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 502 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 503 * if the parser encountered a bad or missing package name in the manifest. 504 * @hide 505 */ 506 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 507 508 /** 509 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 510 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 511 * if the parser encountered a bad shared user id name in the manifest. 512 * @hide 513 */ 514 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 515 516 /** 517 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 518 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 519 * if the parser encountered some structural problem in the manifest. 520 * @hide 521 */ 522 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 523 524 /** 525 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 526 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 527 * if the parser did not find any actionable tags (instrumentation or application) 528 * in the manifest. 529 * @hide 530 */ 531 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 532 533 /** 534 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 535 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 536 * if the system failed to install the package because of system issues. 537 * @hide 538 */ 539 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 540 541 /** 542 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 543 * package's data directory. 544 * 545 * @hide 546 */ 547 public static final int DONT_DELETE_DATA = 0x00000001; 548 549 /** 550 * Return code that is passed to the {@link IPackageMoveObserver} by 551 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 552 * when the package has been successfully moved by the system. 553 * @hide 554 */ 555 public static final int MOVE_SUCCEEDED = 1; 556 /** 557 * Error code that is passed to the {@link IPackageMoveObserver} by 558 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 559 * when the package hasn't been successfully moved by the system 560 * because of insufficient memory on specified media. 561 * @hide 562 */ 563 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 564 565 /** 566 * Error code that is passed to the {@link IPackageMoveObserver} by 567 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 568 * if the specified package doesn't exist. 569 * @hide 570 */ 571 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 572 573 /** 574 * Error code that is passed to the {@link IPackageMoveObserver} by 575 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 576 * if the specified package cannot be moved since its a system package. 577 * @hide 578 */ 579 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 580 581 /** 582 * Error code that is passed to the {@link IPackageMoveObserver} by 583 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 584 * if the specified package cannot be moved since its forward locked. 585 * @hide 586 */ 587 public static final int MOVE_FAILED_FORWARD_LOCKED = -4; 588 589 /** 590 * Error code that is passed to the {@link IPackageMoveObserver} by 591 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 592 * if the specified package cannot be moved to the specified location. 593 * @hide 594 */ 595 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 596 597 /** 598 * Error code that is passed to the {@link IPackageMoveObserver} by 599 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 600 * if the specified package cannot be moved to the specified location. 601 * @hide 602 */ 603 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 604 605 /** 606 * Flag parameter for {@link #movePackage} to indicate that 607 * the package should be moved to internal storage if its 608 * been installed on external media. 609 * @hide 610 */ 611 public static final int MOVE_INTERNAL = 0x00000001; 612 613 /** 614 * Flag parameter for {@link #movePackage} to indicate that 615 * the package should be moved to external media. 616 * @hide 617 */ 618 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 619 620 /** 621 * Feature for {@link #getSystemAvailableFeatures} and 622 * {@link #hasSystemFeature}: The device is capable of communicating with 623 * other devices via Bluetooth. 624 */ 625 @SdkConstant(SdkConstantType.FEATURE) 626 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 627 628 /** 629 * Feature for {@link #getSystemAvailableFeatures} and 630 * {@link #hasSystemFeature}: The device has a camera facing away 631 * from the screen. 632 */ 633 @SdkConstant(SdkConstantType.FEATURE) 634 public static final String FEATURE_CAMERA = "android.hardware.camera"; 635 636 /** 637 * Feature for {@link #getSystemAvailableFeatures} and 638 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 639 */ 640 @SdkConstant(SdkConstantType.FEATURE) 641 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 642 643 /** 644 * Feature for {@link #getSystemAvailableFeatures} and 645 * {@link #hasSystemFeature}: The device's camera supports flash. 646 */ 647 @SdkConstant(SdkConstantType.FEATURE) 648 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 649 650 /** 651 * Feature for {@link #getSystemAvailableFeatures} and 652 * {@link #hasSystemFeature}: The device supports one or more methods of 653 * reporting current location. 654 */ 655 @SdkConstant(SdkConstantType.FEATURE) 656 public static final String FEATURE_LOCATION = "android.hardware.location"; 657 658 /** 659 * Feature for {@link #getSystemAvailableFeatures} and 660 * {@link #hasSystemFeature}: The device has a Global Positioning System 661 * receiver and can report precise location. 662 */ 663 @SdkConstant(SdkConstantType.FEATURE) 664 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 665 666 /** 667 * Feature for {@link #getSystemAvailableFeatures} and 668 * {@link #hasSystemFeature}: The device can report location with coarse 669 * accuracy using a network-based geolocation system. 670 */ 671 @SdkConstant(SdkConstantType.FEATURE) 672 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 673 674 /** 675 * Feature for {@link #getSystemAvailableFeatures} and 676 * {@link #hasSystemFeature}: The device can record audio via a 677 * microphone. 678 */ 679 @SdkConstant(SdkConstantType.FEATURE) 680 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 681 682 /** 683 * Feature for {@link #getSystemAvailableFeatures} and 684 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 685 */ 686 @SdkConstant(SdkConstantType.FEATURE) 687 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 688 689 /** 690 * Feature for {@link #getSystemAvailableFeatures} and 691 * {@link #hasSystemFeature}: The device includes an accelerometer. 692 */ 693 @SdkConstant(SdkConstantType.FEATURE) 694 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 695 696 /** 697 * Feature for {@link #getSystemAvailableFeatures} and 698 * {@link #hasSystemFeature}: The device includes a light sensor. 699 */ 700 @SdkConstant(SdkConstantType.FEATURE) 701 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 702 703 /** 704 * Feature for {@link #getSystemAvailableFeatures} and 705 * {@link #hasSystemFeature}: The device includes a proximity sensor. 706 */ 707 @SdkConstant(SdkConstantType.FEATURE) 708 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 709 710 /** 711 * Feature for {@link #getSystemAvailableFeatures} and 712 * {@link #hasSystemFeature}: The device has a telephony radio with data 713 * communication support. 714 */ 715 @SdkConstant(SdkConstantType.FEATURE) 716 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 717 718 /** 719 * Feature for {@link #getSystemAvailableFeatures} and 720 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 721 */ 722 @SdkConstant(SdkConstantType.FEATURE) 723 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 724 725 /** 726 * Feature for {@link #getSystemAvailableFeatures} and 727 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 728 */ 729 @SdkConstant(SdkConstantType.FEATURE) 730 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 731 732 /** 733 * Feature for {@link #getSystemAvailableFeatures} and 734 * {@link #hasSystemFeature}: The device's touch screen supports 735 * multitouch sufficient for basic two-finger gesture detection. 736 */ 737 @SdkConstant(SdkConstantType.FEATURE) 738 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 739 740 /** 741 * Feature for {@link #getSystemAvailableFeatures} and 742 * {@link #hasSystemFeature}: The device's touch screen is capable of 743 * tracking two or more fingers fully independently. 744 */ 745 @SdkConstant(SdkConstantType.FEATURE) 746 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 747 748 /** 749 * Feature for {@link #getSystemAvailableFeatures} and 750 * {@link #hasSystemFeature}: The device supports live wallpapers. 751 */ 752 @SdkConstant(SdkConstantType.FEATURE) 753 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 754 755 /** 756 * Feature for {@link #getSystemAvailableFeatures} and 757 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 758 */ 759 @SdkConstant(SdkConstantType.FEATURE) 760 public static final String FEATURE_WIFI = "android.hardware.wifi"; 761 762 /** 763 * Action to external storage service to clean out removed apps. 764 * @hide 765 */ 766 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 767 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 768 769 /** 770 * Retrieve overall information about an application package that is 771 * installed on the system. 772 * 773 * <p>Throws {@link NameNotFoundException} if a package with the given 774 * name can not be found on the system. 775 * 776 * @param packageName The full name (i.e. com.google.apps.contacts) of the 777 * desired package. 778 779 * @param flags Additional option flags. Use any combination of 780 * {@link #GET_ACTIVITIES}, 781 * {@link #GET_GIDS}, 782 * {@link #GET_CONFIGURATIONS}, 783 * {@link #GET_INSTRUMENTATION}, 784 * {@link #GET_PERMISSIONS}, 785 * {@link #GET_PROVIDERS}, 786 * {@link #GET_RECEIVERS}, 787 * {@link #GET_SERVICES}, 788 * {@link #GET_SIGNATURES}, 789 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 790 * 791 * @return Returns a PackageInfo object containing information about the package. 792 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 793 * found in the list of installed applications, the package information is 794 * retrieved from the list of uninstalled applications(which includes 795 * installed applications as well as applications 796 * with data directory ie applications which had been 797 * deleted with DONT_DELTE_DATA flag set). 798 * 799 * @see #GET_ACTIVITIES 800 * @see #GET_GIDS 801 * @see #GET_CONFIGURATIONS 802 * @see #GET_INSTRUMENTATION 803 * @see #GET_PERMISSIONS 804 * @see #GET_PROVIDERS 805 * @see #GET_RECEIVERS 806 * @see #GET_SERVICES 807 * @see #GET_SIGNATURES 808 * @see #GET_UNINSTALLED_PACKAGES 809 * 810 */ 811 public abstract PackageInfo getPackageInfo(String packageName, int flags) 812 throws NameNotFoundException; 813 814 /** 815 * Map from the current package names in use on the device to whatever 816 * the current canonical name of that package is. 817 * @param names Array of current names to be mapped. 818 * @return Returns an array of the same size as the original, containing 819 * the canonical name for each package. 820 */ 821 public abstract String[] currentToCanonicalPackageNames(String[] names); 822 823 /** 824 * Map from a packages canonical name to the current name in use on the device. 825 * @param names Array of new names to be mapped. 826 * @return Returns an array of the same size as the original, containing 827 * the current name for each package. 828 */ 829 public abstract String[] canonicalToCurrentPackageNames(String[] names); 830 831 /** 832 * Return a "good" intent to launch a front-door activity in a package, 833 * for use for example to implement an "open" button when browsing through 834 * packages. The current implementation will look first for a main 835 * activity in the category {@link Intent#CATEGORY_INFO}, next for a 836 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return 837 * null if neither are found. 838 * 839 * <p>Throws {@link NameNotFoundException} if a package with the given 840 * name can not be found on the system. 841 * 842 * @param packageName The name of the package to inspect. 843 * 844 * @return Returns either a fully-qualified Intent that can be used to 845 * launch the main activity in the package, or null if the package does 846 * not contain such an activity. 847 */ 848 public abstract Intent getLaunchIntentForPackage(String packageName); 849 850 /** 851 * Return an array of all of the secondary group-ids that have been 852 * assigned to a package. 853 * 854 * <p>Throws {@link NameNotFoundException} if a package with the given 855 * name can not be found on the system. 856 * 857 * @param packageName The full name (i.e. com.google.apps.contacts) of the 858 * desired package. 859 * 860 * @return Returns an int array of the assigned gids, or null if there 861 * are none. 862 */ 863 public abstract int[] getPackageGids(String packageName) 864 throws NameNotFoundException; 865 866 /** 867 * Retrieve all of the information we know about a particular permission. 868 * 869 * <p>Throws {@link NameNotFoundException} if a permission with the given 870 * name can not be found on the system. 871 * 872 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 873 * of the permission you are interested in. 874 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 875 * retrieve any meta-data associated with the permission. 876 * 877 * @return Returns a {@link PermissionInfo} containing information about the 878 * permission. 879 */ 880 public abstract PermissionInfo getPermissionInfo(String name, int flags) 881 throws NameNotFoundException; 882 883 /** 884 * Query for all of the permissions associated with a particular group. 885 * 886 * <p>Throws {@link NameNotFoundException} if the given group does not 887 * exist. 888 * 889 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 890 * of the permission group you are interested in. Use null to 891 * find all of the permissions not associated with a group. 892 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 893 * retrieve any meta-data associated with the permissions. 894 * 895 * @return Returns a list of {@link PermissionInfo} containing information 896 * about all of the permissions in the given group. 897 */ 898 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 899 int flags) throws NameNotFoundException; 900 901 /** 902 * Retrieve all of the information we know about a particular group of 903 * permissions. 904 * 905 * <p>Throws {@link NameNotFoundException} if a permission group with the given 906 * name can not be found on the system. 907 * 908 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 909 * of the permission you are interested in. 910 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 911 * retrieve any meta-data associated with the permission group. 912 * 913 * @return Returns a {@link PermissionGroupInfo} containing information 914 * about the permission. 915 */ 916 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 917 int flags) throws NameNotFoundException; 918 919 /** 920 * Retrieve all of the known permission groups in the system. 921 * 922 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 923 * retrieve any meta-data associated with the permission group. 924 * 925 * @return Returns a list of {@link PermissionGroupInfo} containing 926 * information about all of the known permission groups. 927 */ 928 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 929 930 /** 931 * Retrieve all of the information we know about a particular 932 * package/application. 933 * 934 * <p>Throws {@link NameNotFoundException} if an application with the given 935 * package name can not be found on the system. 936 * 937 * @param packageName The full name (i.e. com.google.apps.contacts) of an 938 * application. 939 * @param flags Additional option flags. Use any combination of 940 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 941 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 942 * 943 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 944 * information about the package. 945 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 946 * found in the list of installed applications, 947 * the application information is retrieved from the 948 * list of uninstalled applications(which includes 949 * installed applications as well as applications 950 * with data directory ie applications which had been 951 * deleted with DONT_DELTE_DATA flag set). 952 * 953 * @see #GET_META_DATA 954 * @see #GET_SHARED_LIBRARY_FILES 955 * @see #GET_UNINSTALLED_PACKAGES 956 */ 957 public abstract ApplicationInfo getApplicationInfo(String packageName, 958 int flags) throws NameNotFoundException; 959 960 /** 961 * Retrieve all of the information we know about a particular activity 962 * class. 963 * 964 * <p>Throws {@link NameNotFoundException} if an activity with the given 965 * class name can not be found on the system. 966 * 967 * @param className The full name (i.e. 968 * com.google.apps.contacts.ContactsList) of an Activity 969 * class. 970 * @param flags Additional option flags. Use any combination of 971 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 972 * to modify the data (in ApplicationInfo) returned. 973 * 974 * @return {@link ActivityInfo} containing information about the activity. 975 * 976 * @see #GET_INTENT_FILTERS 977 * @see #GET_META_DATA 978 * @see #GET_SHARED_LIBRARY_FILES 979 */ 980 public abstract ActivityInfo getActivityInfo(ComponentName className, 981 int flags) throws NameNotFoundException; 982 983 /** 984 * Retrieve all of the information we know about a particular receiver 985 * class. 986 * 987 * <p>Throws {@link NameNotFoundException} if a receiver with the given 988 * class name can not be found on the system. 989 * 990 * @param className The full name (i.e. 991 * com.google.apps.contacts.CalendarAlarm) of a Receiver 992 * class. 993 * @param flags Additional option flags. Use any combination of 994 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 995 * to modify the data returned. 996 * 997 * @return {@link ActivityInfo} containing information about the receiver. 998 * 999 * @see #GET_INTENT_FILTERS 1000 * @see #GET_META_DATA 1001 * @see #GET_SHARED_LIBRARY_FILES 1002 */ 1003 public abstract ActivityInfo getReceiverInfo(ComponentName className, 1004 int flags) throws NameNotFoundException; 1005 1006 /** 1007 * Retrieve all of the information we know about a particular service 1008 * class. 1009 * 1010 * <p>Throws {@link NameNotFoundException} if a service with the given 1011 * class name can not be found on the system. 1012 * 1013 * @param className The full name (i.e. 1014 * com.google.apps.media.BackgroundPlayback) of a Service 1015 * class. 1016 * @param flags Additional option flags. Use any combination of 1017 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1018 * to modify the data returned. 1019 * 1020 * @return ServiceInfo containing information about the service. 1021 * 1022 * @see #GET_META_DATA 1023 * @see #GET_SHARED_LIBRARY_FILES 1024 */ 1025 public abstract ServiceInfo getServiceInfo(ComponentName className, 1026 int flags) throws NameNotFoundException; 1027 1028 /** 1029 * Return a List of all packages that are installed 1030 * on the device. 1031 * 1032 * @param flags Additional option flags. Use any combination of 1033 * {@link #GET_ACTIVITIES}, 1034 * {@link #GET_GIDS}, 1035 * {@link #GET_CONFIGURATIONS}, 1036 * {@link #GET_INSTRUMENTATION}, 1037 * {@link #GET_PERMISSIONS}, 1038 * {@link #GET_PROVIDERS}, 1039 * {@link #GET_RECEIVERS}, 1040 * {@link #GET_SERVICES}, 1041 * {@link #GET_SIGNATURES}, 1042 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1043 * 1044 * @return A List of PackageInfo objects, one for each package that is 1045 * installed on the device. In the unlikely case of there being no 1046 * installed packages, an empty list is returned. 1047 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1048 * applications including those deleted with DONT_DELETE_DATA 1049 * (partially installed apps with data directory) will be returned. 1050 * 1051 * @see #GET_ACTIVITIES 1052 * @see #GET_GIDS 1053 * @see #GET_CONFIGURATIONS 1054 * @see #GET_INSTRUMENTATION 1055 * @see #GET_PERMISSIONS 1056 * @see #GET_PROVIDERS 1057 * @see #GET_RECEIVERS 1058 * @see #GET_SERVICES 1059 * @see #GET_SIGNATURES 1060 * @see #GET_UNINSTALLED_PACKAGES 1061 * 1062 */ 1063 public abstract List<PackageInfo> getInstalledPackages(int flags); 1064 1065 /** 1066 * Check whether a particular package has been granted a particular 1067 * permission. 1068 * 1069 * @param permName The name of the permission you are checking for, 1070 * @param pkgName The name of the package you are checking against. 1071 * 1072 * @return If the package has the permission, PERMISSION_GRANTED is 1073 * returned. If it does not have the permission, PERMISSION_DENIED 1074 * is returned. 1075 * 1076 * @see #PERMISSION_GRANTED 1077 * @see #PERMISSION_DENIED 1078 */ 1079 public abstract int checkPermission(String permName, String pkgName); 1080 1081 /** 1082 * Add a new dynamic permission to the system. For this to work, your 1083 * package must have defined a permission tree through the 1084 * {@link android.R.styleable#AndroidManifestPermissionTree 1085 * <permission-tree>} tag in its manifest. A package can only add 1086 * permissions to trees that were defined by either its own package or 1087 * another with the same user id; a permission is in a tree if it 1088 * matches the name of the permission tree + ".": for example, 1089 * "com.foo.bar" is a member of the permission tree "com.foo". 1090 * 1091 * <p>It is good to make your permission tree name descriptive, because you 1092 * are taking possession of that entire set of permission names. Thus, it 1093 * must be under a domain you control, with a suffix that will not match 1094 * any normal permissions that may be declared in any applications that 1095 * are part of that domain. 1096 * 1097 * <p>New permissions must be added before 1098 * any .apks are installed that use those permissions. Permissions you 1099 * add through this method are remembered across reboots of the device. 1100 * If the given permission already exists, the info you supply here 1101 * will be used to update it. 1102 * 1103 * @param info Description of the permission to be added. 1104 * 1105 * @return Returns true if a new permission was created, false if an 1106 * existing one was updated. 1107 * 1108 * @throws SecurityException if you are not allowed to add the 1109 * given permission name. 1110 * 1111 * @see #removePermission(String) 1112 */ 1113 public abstract boolean addPermission(PermissionInfo info); 1114 1115 /** 1116 * Removes a permission that was previously added with 1117 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 1118 * -- you are only allowed to remove permissions that you are allowed 1119 * to add. 1120 * 1121 * @param name The name of the permission to remove. 1122 * 1123 * @throws SecurityException if you are not allowed to remove the 1124 * given permission name. 1125 * 1126 * @see #addPermission(PermissionInfo) 1127 */ 1128 public abstract void removePermission(String name); 1129 1130 /** 1131 * Compare the signatures of two packages to determine if the same 1132 * signature appears in both of them. If they do contain the same 1133 * signature, then they are allowed special privileges when working 1134 * with each other: they can share the same user-id, run instrumentation 1135 * against each other, etc. 1136 * 1137 * @param pkg1 First package name whose signature will be compared. 1138 * @param pkg2 Second package name whose signature will be compared. 1139 * @return Returns an integer indicating whether there is a matching 1140 * signature: the value is >= 0 if there is a match (or neither package 1141 * is signed), or < 0 if there is not a match. The match result can be 1142 * further distinguished with the success (>= 0) constants 1143 * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or 1144 * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED}, 1145 * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH}, 1146 * or {@link #SIGNATURE_UNKNOWN_PACKAGE}. 1147 * 1148 * @see #checkSignatures(int, int) 1149 * @see #SIGNATURE_MATCH 1150 * @see #SIGNATURE_NEITHER_SIGNED 1151 * @see #SIGNATURE_FIRST_NOT_SIGNED 1152 * @see #SIGNATURE_SECOND_NOT_SIGNED 1153 * @see #SIGNATURE_NO_MATCH 1154 * @see #SIGNATURE_UNKNOWN_PACKAGE 1155 */ 1156 public abstract int checkSignatures(String pkg1, String pkg2); 1157 1158 /** 1159 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 1160 * the two packages to be checked. This can be useful, for example, 1161 * when doing the check in an IPC, where the UID is the only identity 1162 * available. It is functionally identical to determining the package 1163 * associated with the UIDs and checking their signatures. 1164 * 1165 * @param uid1 First UID whose signature will be compared. 1166 * @param uid2 Second UID whose signature will be compared. 1167 * @return Returns an integer indicating whether there is a matching 1168 * signature: the value is >= 0 if there is a match (or neither package 1169 * is signed), or < 0 if there is not a match. The match result can be 1170 * further distinguished with the success (>= 0) constants 1171 * {@link #SIGNATURE_MATCH}, {@link #SIGNATURE_NEITHER_SIGNED}; or 1172 * failure (< 0) constants {@link #SIGNATURE_FIRST_NOT_SIGNED}, 1173 * {@link #SIGNATURE_SECOND_NOT_SIGNED}, {@link #SIGNATURE_NO_MATCH}, 1174 * or {@link #SIGNATURE_UNKNOWN_PACKAGE}. 1175 * 1176 * @see #checkSignatures(int, int) 1177 * @see #SIGNATURE_MATCH 1178 * @see #SIGNATURE_NEITHER_SIGNED 1179 * @see #SIGNATURE_FIRST_NOT_SIGNED 1180 * @see #SIGNATURE_SECOND_NOT_SIGNED 1181 * @see #SIGNATURE_NO_MATCH 1182 * @see #SIGNATURE_UNKNOWN_PACKAGE 1183 */ 1184 public abstract int checkSignatures(int uid1, int uid2); 1185 1186 /** 1187 * Retrieve the names of all packages that are associated with a particular 1188 * user id. In most cases, this will be a single package name, the package 1189 * that has been assigned that user id. Where there are multiple packages 1190 * sharing the same user id through the "sharedUserId" mechanism, all 1191 * packages with that id will be returned. 1192 * 1193 * @param uid The user id for which you would like to retrieve the 1194 * associated packages. 1195 * 1196 * @return Returns an array of one or more packages assigned to the user 1197 * id, or null if there are no known packages with the given id. 1198 */ 1199 public abstract String[] getPackagesForUid(int uid); 1200 1201 /** 1202 * Retrieve the official name associated with a user id. This name is 1203 * guaranteed to never change, though it is possibly for the underlying 1204 * user id to be changed. That is, if you are storing information about 1205 * user ids in persistent storage, you should use the string returned 1206 * by this function instead of the raw user-id. 1207 * 1208 * @param uid The user id for which you would like to retrieve a name. 1209 * @return Returns a unique name for the given user id, or null if the 1210 * user id is not currently assigned. 1211 */ 1212 public abstract String getNameForUid(int uid); 1213 1214 /** 1215 * Return the user id associated with a shared user name. Multiple 1216 * applications can specify a shared user name in their manifest and thus 1217 * end up using a common uid. This might be used for new applications 1218 * that use an existing shared user name and need to know the uid of the 1219 * shared user. 1220 * 1221 * @param sharedUserName The shared user name whose uid is to be retrieved. 1222 * @return Returns the uid associated with the shared user, or NameNotFoundException 1223 * if the shared user name is not being used by any installed packages 1224 * @hide 1225 */ 1226 public abstract int getUidForSharedUser(String sharedUserName) 1227 throws NameNotFoundException; 1228 1229 /** 1230 * Return a List of all application packages that are installed on the 1231 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 1232 * applications including those deleted with DONT_DELETE_DATA(partially 1233 * installed apps with data directory) will be returned. 1234 * 1235 * @param flags Additional option flags. Use any combination of 1236 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1237 * {link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1238 * 1239 * @return A List of ApplicationInfo objects, one for each application that 1240 * is installed on the device. In the unlikely case of there being 1241 * no installed applications, an empty list is returned. 1242 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1243 * applications including those deleted with DONT_DELETE_DATA 1244 * (partially installed apps with data directory) will be returned. 1245 * 1246 * @see #GET_META_DATA 1247 * @see #GET_SHARED_LIBRARY_FILES 1248 * @see #GET_UNINSTALLED_PACKAGES 1249 */ 1250 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 1251 1252 /** 1253 * Get a list of shared libraries that are available on the 1254 * system. 1255 * 1256 * @return An array of shared library names that are 1257 * available on the system, or null if none are installed. 1258 * 1259 */ 1260 public abstract String[] getSystemSharedLibraryNames(); 1261 1262 /** 1263 * Get a list of features that are available on the 1264 * system. 1265 * 1266 * @return An array of FeatureInfo classes describing the features 1267 * that are available on the system, or null if there are none(!!). 1268 */ 1269 public abstract FeatureInfo[] getSystemAvailableFeatures(); 1270 1271 /** 1272 * Check whether the given feature name is one of the available 1273 * features as returned by {@link #getSystemAvailableFeatures()}. 1274 * 1275 * @return Returns true if the devices supports the feature, else 1276 * false. 1277 */ 1278 public abstract boolean hasSystemFeature(String name); 1279 1280 /** 1281 * Determine the best action to perform for a given Intent. This is how 1282 * {@link Intent#resolveActivity} finds an activity if a class has not 1283 * been explicitly specified. 1284 * 1285 * @param intent An intent containing all of the desired specification 1286 * (action, data, type, category, and/or component). 1287 * @param flags Additional option flags. The most important is 1288 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1289 * those activities that support the CATEGORY_DEFAULT. 1290 * 1291 * @return Returns a ResolveInfo containing the final activity intent that 1292 * was determined to be the best action. Returns null if no 1293 * matching activity was found. If multiple matching activities are 1294 * found and there is no default set, returns a ResolveInfo 1295 * containing something else, such as the activity resolver. 1296 * 1297 * @see #MATCH_DEFAULT_ONLY 1298 * @see #GET_INTENT_FILTERS 1299 * @see #GET_RESOLVED_FILTER 1300 */ 1301 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 1302 1303 /** 1304 * Retrieve all activities that can be performed for the given intent. 1305 * 1306 * @param intent The desired intent as per resolveActivity(). 1307 * @param flags Additional option flags. The most important is 1308 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1309 * those activities that support the CATEGORY_DEFAULT. 1310 * 1311 * @return A List<ResolveInfo> containing one entry for each matching 1312 * Activity. These are ordered from best to worst match -- that 1313 * is, the first item in the list is what is returned by 1314 * resolveActivity(). If there are no matching activities, an empty 1315 * list is returned. 1316 * 1317 * @see #MATCH_DEFAULT_ONLY 1318 * @see #GET_INTENT_FILTERS 1319 * @see #GET_RESOLVED_FILTER 1320 */ 1321 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 1322 int flags); 1323 1324 /** 1325 * Retrieve a set of activities that should be presented to the user as 1326 * similar options. This is like {@link #queryIntentActivities}, except it 1327 * also allows you to supply a list of more explicit Intents that you would 1328 * like to resolve to particular options, and takes care of returning the 1329 * final ResolveInfo list in a reasonable order, with no duplicates, based 1330 * on those inputs. 1331 * 1332 * @param caller The class name of the activity that is making the 1333 * request. This activity will never appear in the output 1334 * list. Can be null. 1335 * @param specifics An array of Intents that should be resolved to the 1336 * first specific results. Can be null. 1337 * @param intent The desired intent as per resolveActivity(). 1338 * @param flags Additional option flags. The most important is 1339 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1340 * those activities that support the CATEGORY_DEFAULT. 1341 * 1342 * @return A List<ResolveInfo> containing one entry for each matching 1343 * Activity. These are ordered first by all of the intents resolved 1344 * in <var>specifics</var> and then any additional activities that 1345 * can handle <var>intent</var> but did not get included by one of 1346 * the <var>specifics</var> intents. If there are no matching 1347 * activities, an empty list is returned. 1348 * 1349 * @see #MATCH_DEFAULT_ONLY 1350 * @see #GET_INTENT_FILTERS 1351 * @see #GET_RESOLVED_FILTER 1352 */ 1353 public abstract List<ResolveInfo> queryIntentActivityOptions( 1354 ComponentName caller, Intent[] specifics, Intent intent, int flags); 1355 1356 /** 1357 * Retrieve all receivers that can handle a broadcast of the given intent. 1358 * 1359 * @param intent The desired intent as per resolveActivity(). 1360 * @param flags Additional option flags. The most important is 1361 * MATCH_DEFAULT_ONLY, to limit the resolution to only 1362 * those activities that support the CATEGORY_DEFAULT. 1363 * 1364 * @return A List<ResolveInfo> containing one entry for each matching 1365 * Receiver. These are ordered from first to last in priority. If 1366 * there are no matching receivers, an empty list is returned. 1367 * 1368 * @see #MATCH_DEFAULT_ONLY 1369 * @see #GET_INTENT_FILTERS 1370 * @see #GET_RESOLVED_FILTER 1371 */ 1372 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 1373 int flags); 1374 1375 /** 1376 * Determine the best service to handle for a given Intent. 1377 * 1378 * @param intent An intent containing all of the desired specification 1379 * (action, data, type, category, and/or component). 1380 * @param flags Additional option flags. 1381 * 1382 * @return Returns a ResolveInfo containing the final service intent that 1383 * was determined to be the best action. Returns null if no 1384 * matching service was found. 1385 * 1386 * @see #GET_INTENT_FILTERS 1387 * @see #GET_RESOLVED_FILTER 1388 */ 1389 public abstract ResolveInfo resolveService(Intent intent, int flags); 1390 1391 /** 1392 * Retrieve all services that can match the given intent. 1393 * 1394 * @param intent The desired intent as per resolveService(). 1395 * @param flags Additional option flags. 1396 * 1397 * @return A List<ResolveInfo> containing one entry for each matching 1398 * ServiceInfo. These are ordered from best to worst match -- that 1399 * is, the first item in the list is what is returned by 1400 * resolveService(). If there are no matching services, an empty 1401 * list is returned. 1402 * 1403 * @see #GET_INTENT_FILTERS 1404 * @see #GET_RESOLVED_FILTER 1405 */ 1406 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 1407 int flags); 1408 1409 /** 1410 * Find a single content provider by its base path name. 1411 * 1412 * @param name The name of the provider to find. 1413 * @param flags Additional option flags. Currently should always be 0. 1414 * 1415 * @return ContentProviderInfo Information about the provider, if found, 1416 * else null. 1417 */ 1418 public abstract ProviderInfo resolveContentProvider(String name, 1419 int flags); 1420 1421 /** 1422 * Retrieve content provider information. 1423 * 1424 * <p><em>Note: unlike most other methods, an empty result set is indicated 1425 * by a null return instead of an empty list.</em> 1426 * 1427 * @param processName If non-null, limits the returned providers to only 1428 * those that are hosted by the given process. If null, 1429 * all content providers are returned. 1430 * @param uid If <var>processName</var> is non-null, this is the required 1431 * uid owning the requested content providers. 1432 * @param flags Additional option flags. Currently should always be 0. 1433 * 1434 * @return A List<ContentProviderInfo> containing one entry for each 1435 * content provider either patching <var>processName</var> or, if 1436 * <var>processName</var> is null, all known content providers. 1437 * <em>If there are no matching providers, null is returned.</em> 1438 */ 1439 public abstract List<ProviderInfo> queryContentProviders( 1440 String processName, int uid, int flags); 1441 1442 /** 1443 * Retrieve all of the information we know about a particular 1444 * instrumentation class. 1445 * 1446 * <p>Throws {@link NameNotFoundException} if instrumentation with the 1447 * given class name can not be found on the system. 1448 * 1449 * @param className The full name (i.e. 1450 * com.google.apps.contacts.InstrumentList) of an 1451 * Instrumentation class. 1452 * @param flags Additional option flags. Currently should always be 0. 1453 * 1454 * @return InstrumentationInfo containing information about the 1455 * instrumentation. 1456 */ 1457 public abstract InstrumentationInfo getInstrumentationInfo( 1458 ComponentName className, int flags) throws NameNotFoundException; 1459 1460 /** 1461 * Retrieve information about available instrumentation code. May be used 1462 * to retrieve either all instrumentation code, or only the code targeting 1463 * a particular package. 1464 * 1465 * @param targetPackage If null, all instrumentation is returned; only the 1466 * instrumentation targeting this package name is 1467 * returned. 1468 * @param flags Additional option flags. Currently should always be 0. 1469 * 1470 * @return A List<InstrumentationInfo> containing one entry for each 1471 * matching available Instrumentation. Returns an empty list if 1472 * there is no instrumentation available for the given package. 1473 */ 1474 public abstract List<InstrumentationInfo> queryInstrumentation( 1475 String targetPackage, int flags); 1476 1477 /** 1478 * Retrieve an image from a package. This is a low-level API used by 1479 * the various package manager info structures (such as 1480 * {@link ComponentInfo} to implement retrieval of their associated 1481 * icon. 1482 * 1483 * @param packageName The name of the package that this icon is coming from. 1484 * Can not be null. 1485 * @param resid The resource identifier of the desired image. Can not be 0. 1486 * @param appInfo Overall information about <var>packageName</var>. This 1487 * may be null, in which case the application information will be retrieved 1488 * for you if needed; if you already have this information around, it can 1489 * be much more efficient to supply it here. 1490 * 1491 * @return Returns a Drawable holding the requested image. Returns null if 1492 * an image could not be found for any reason. 1493 */ 1494 public abstract Drawable getDrawable(String packageName, int resid, 1495 ApplicationInfo appInfo); 1496 1497 /** 1498 * Retrieve the icon associated with an activity. Given the full name of 1499 * an activity, retrieves the information about it and calls 1500 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 1501 * If the activity can not be found, NameNotFoundException is thrown. 1502 * 1503 * @param activityName Name of the activity whose icon is to be retrieved. 1504 * 1505 * @return Returns the image of the icon, or the default activity icon if 1506 * it could not be found. Does not return null. 1507 * @throws NameNotFoundException Thrown if the resources for the given 1508 * activity could not be loaded. 1509 * 1510 * @see #getActivityIcon(Intent) 1511 */ 1512 public abstract Drawable getActivityIcon(ComponentName activityName) 1513 throws NameNotFoundException; 1514 1515 /** 1516 * Retrieve the icon associated with an Intent. If intent.getClassName() is 1517 * set, this simply returns the result of 1518 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 1519 * component and returns the icon associated with the resolved component. 1520 * If intent.getClassName() can not be found or the Intent can not be resolved 1521 * to a component, NameNotFoundException is thrown. 1522 * 1523 * @param intent The intent for which you would like to retrieve an icon. 1524 * 1525 * @return Returns the image of the icon, or the default activity icon if 1526 * it could not be found. Does not return null. 1527 * @throws NameNotFoundException Thrown if the resources for application 1528 * matching the given intent could not be loaded. 1529 * 1530 * @see #getActivityIcon(ComponentName) 1531 */ 1532 public abstract Drawable getActivityIcon(Intent intent) 1533 throws NameNotFoundException; 1534 1535 /** 1536 * Return the generic icon for an activity that is used when no specific 1537 * icon is defined. 1538 * 1539 * @return Drawable Image of the icon. 1540 */ 1541 public abstract Drawable getDefaultActivityIcon(); 1542 1543 /** 1544 * Retrieve the icon associated with an application. If it has not defined 1545 * an icon, the default app icon is returned. Does not return null. 1546 * 1547 * @param info Information about application being queried. 1548 * 1549 * @return Returns the image of the icon, or the default application icon 1550 * if it could not be found. 1551 * 1552 * @see #getApplicationIcon(String) 1553 */ 1554 public abstract Drawable getApplicationIcon(ApplicationInfo info); 1555 1556 /** 1557 * Retrieve the icon associated with an application. Given the name of the 1558 * application's package, retrieves the information about it and calls 1559 * getApplicationIcon() to return its icon. If the application can not be 1560 * found, NameNotFoundException is thrown. 1561 * 1562 * @param packageName Name of the package whose application icon is to be 1563 * retrieved. 1564 * 1565 * @return Returns the image of the icon, or the default application icon 1566 * if it could not be found. Does not return null. 1567 * @throws NameNotFoundException Thrown if the resources for the given 1568 * application could not be loaded. 1569 * 1570 * @see #getApplicationIcon(ApplicationInfo) 1571 */ 1572 public abstract Drawable getApplicationIcon(String packageName) 1573 throws NameNotFoundException; 1574 1575 /** 1576 * Retrieve text from a package. This is a low-level API used by 1577 * the various package manager info structures (such as 1578 * {@link ComponentInfo} to implement retrieval of their associated 1579 * labels and other text. 1580 * 1581 * @param packageName The name of the package that this text is coming from. 1582 * Can not be null. 1583 * @param resid The resource identifier of the desired text. Can not be 0. 1584 * @param appInfo Overall information about <var>packageName</var>. This 1585 * may be null, in which case the application information will be retrieved 1586 * for you if needed; if you already have this information around, it can 1587 * be much more efficient to supply it here. 1588 * 1589 * @return Returns a CharSequence holding the requested text. Returns null 1590 * if the text could not be found for any reason. 1591 */ 1592 public abstract CharSequence getText(String packageName, int resid, 1593 ApplicationInfo appInfo); 1594 1595 /** 1596 * Retrieve an XML file from a package. This is a low-level API used to 1597 * retrieve XML meta data. 1598 * 1599 * @param packageName The name of the package that this xml is coming from. 1600 * Can not be null. 1601 * @param resid The resource identifier of the desired xml. Can not be 0. 1602 * @param appInfo Overall information about <var>packageName</var>. This 1603 * may be null, in which case the application information will be retrieved 1604 * for you if needed; if you already have this information around, it can 1605 * be much more efficient to supply it here. 1606 * 1607 * @return Returns an XmlPullParser allowing you to parse out the XML 1608 * data. Returns null if the xml resource could not be found for any 1609 * reason. 1610 */ 1611 public abstract XmlResourceParser getXml(String packageName, int resid, 1612 ApplicationInfo appInfo); 1613 1614 /** 1615 * Return the label to use for this application. 1616 * 1617 * @return Returns the label associated with this application, or null if 1618 * it could not be found for any reason. 1619 * @param info The application to get the label of 1620 */ 1621 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 1622 1623 /** 1624 * Retrieve the resources associated with an activity. Given the full 1625 * name of an activity, retrieves the information about it and calls 1626 * getResources() to return its application's resources. If the activity 1627 * can not be found, NameNotFoundException is thrown. 1628 * 1629 * @param activityName Name of the activity whose resources are to be 1630 * retrieved. 1631 * 1632 * @return Returns the application's Resources. 1633 * @throws NameNotFoundException Thrown if the resources for the given 1634 * application could not be loaded. 1635 * 1636 * @see #getResourcesForApplication(ApplicationInfo) 1637 */ 1638 public abstract Resources getResourcesForActivity(ComponentName activityName) 1639 throws NameNotFoundException; 1640 1641 /** 1642 * Retrieve the resources for an application. Throws NameNotFoundException 1643 * if the package is no longer installed. 1644 * 1645 * @param app Information about the desired application. 1646 * 1647 * @return Returns the application's Resources. 1648 * @throws NameNotFoundException Thrown if the resources for the given 1649 * application could not be loaded (most likely because it was uninstalled). 1650 */ 1651 public abstract Resources getResourcesForApplication(ApplicationInfo app) 1652 throws NameNotFoundException; 1653 1654 /** 1655 * Retrieve the resources associated with an application. Given the full 1656 * package name of an application, retrieves the information about it and 1657 * calls getResources() to return its application's resources. If the 1658 * appPackageName can not be found, NameNotFoundException is thrown. 1659 * 1660 * @param appPackageName Package name of the application whose resources 1661 * are to be retrieved. 1662 * 1663 * @return Returns the application's Resources. 1664 * @throws NameNotFoundException Thrown if the resources for the given 1665 * application could not be loaded. 1666 * 1667 * @see #getResourcesForApplication(ApplicationInfo) 1668 */ 1669 public abstract Resources getResourcesForApplication(String appPackageName) 1670 throws NameNotFoundException; 1671 1672 /** 1673 * Retrieve overall information about an application package defined 1674 * in a package archive file 1675 * 1676 * @param archiveFilePath The path to the archive file 1677 * @param flags Additional option flags. Use any combination of 1678 * {@link #GET_ACTIVITIES}, 1679 * {@link #GET_GIDS}, 1680 * {@link #GET_CONFIGURATIONS}, 1681 * {@link #GET_INSTRUMENTATION}, 1682 * {@link #GET_PERMISSIONS}, 1683 * {@link #GET_PROVIDERS}, 1684 * {@link #GET_RECEIVERS}, 1685 * {@link #GET_SERVICES}, 1686 * {@link #GET_SIGNATURES}, to modify the data returned. 1687 * 1688 * @return Returns the information about the package. Returns 1689 * null if the package could not be successfully parsed. 1690 * 1691 * @see #GET_ACTIVITIES 1692 * @see #GET_GIDS 1693 * @see #GET_CONFIGURATIONS 1694 * @see #GET_INSTRUMENTATION 1695 * @see #GET_PERMISSIONS 1696 * @see #GET_PROVIDERS 1697 * @see #GET_RECEIVERS 1698 * @see #GET_SERVICES 1699 * @see #GET_SIGNATURES 1700 * 1701 */ 1702 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 1703 PackageParser packageParser = new PackageParser(archiveFilePath); 1704 DisplayMetrics metrics = new DisplayMetrics(); 1705 metrics.setToDefaults(); 1706 final File sourceFile = new File(archiveFilePath); 1707 PackageParser.Package pkg = packageParser.parsePackage( 1708 sourceFile, archiveFilePath, metrics, 0); 1709 if (pkg == null) { 1710 return null; 1711 } 1712 return PackageParser.generatePackageInfo(pkg, null, flags); 1713 } 1714 1715 /** 1716 * @hide 1717 * 1718 * Install a package. Since this may take a little while, the result will 1719 * be posted back to the given observer. An installation will fail if the calling context 1720 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 1721 * package named in the package file's manifest is already installed, or if there's no space 1722 * available on the device. 1723 * 1724 * @param packageURI The location of the package file to install. This can be a 'file:' or a 1725 * 'content:' URI. 1726 * @param observer An observer callback to get notified when the package installation is 1727 * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be 1728 * called when that happens. observer may be null to indicate that no callback is desired. 1729 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 1730 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 1731 * @param installerPackageName Optional package name of the application that is performing the 1732 * installation. This identifies which market the package came from. 1733 */ 1734 public abstract void installPackage( 1735 Uri packageURI, IPackageInstallObserver observer, int flags, 1736 String installerPackageName); 1737 1738 /** 1739 * Attempts to delete a package. Since this may take a little while, the result will 1740 * be posted back to the given observer. A deletion will fail if the calling context 1741 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 1742 * named package cannot be found, or if the named package is a "system package". 1743 * (TODO: include pointer to documentation on "system packages") 1744 * 1745 * @param packageName The name of the package to delete 1746 * @param observer An observer callback to get notified when the package deletion is 1747 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 1748 * called when that happens. observer may be null to indicate that no callback is desired. 1749 * @param flags - possible values: {@link #DONT_DELETE_DATA} 1750 * 1751 * @hide 1752 */ 1753 public abstract void deletePackage( 1754 String packageName, IPackageDeleteObserver observer, int flags); 1755 1756 /** 1757 * Retrieve the package name of the application that installed a package. This identifies 1758 * which market the package came from. 1759 * 1760 * @param packageName The name of the package to query 1761 */ 1762 public abstract String getInstallerPackageName(String packageName); 1763 1764 /** 1765 * Attempts to clear the user data directory of an application. 1766 * Since this may take a little while, the result will 1767 * be posted back to the given observer. A deletion will fail if the 1768 * named package cannot be found, or if the named package is a "system package". 1769 * 1770 * @param packageName The name of the package 1771 * @param observer An observer callback to get notified when the operation is finished 1772 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 1773 * will be called when that happens. observer may be null to indicate that 1774 * no callback is desired. 1775 * 1776 * @hide 1777 */ 1778 public abstract void clearApplicationUserData(String packageName, 1779 IPackageDataObserver observer); 1780 /** 1781 * Attempts to delete the cache files associated with an application. 1782 * Since this may take a little while, the result will 1783 * be posted back to the given observer. A deletion will fail if the calling context 1784 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 1785 * named package cannot be found, or if the named package is a "system package". 1786 * 1787 * @param packageName The name of the package to delete 1788 * @param observer An observer callback to get notified when the cache file deletion 1789 * is complete. 1790 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 1791 * will be called when that happens. observer may be null to indicate that 1792 * no callback is desired. 1793 * 1794 * @hide 1795 */ 1796 public abstract void deleteApplicationCacheFiles(String packageName, 1797 IPackageDataObserver observer); 1798 1799 /** 1800 * Free storage by deleting LRU sorted list of cache files across 1801 * all applications. If the currently available free storage 1802 * on the device is greater than or equal to the requested 1803 * free storage, no cache files are cleared. If the currently 1804 * available storage on the device is less than the requested 1805 * free storage, some or all of the cache files across 1806 * all applications are deleted (based on last accessed time) 1807 * to increase the free storage space on the device to 1808 * the requested value. There is no guarantee that clearing all 1809 * the cache files from all applications will clear up 1810 * enough storage to achieve the desired value. 1811 * @param freeStorageSize The number of bytes of storage to be 1812 * freed by the system. Say if freeStorageSize is XX, 1813 * and the current free storage is YY, 1814 * if XX is less than YY, just return. if not free XX-YY number 1815 * of bytes if possible. 1816 * @param observer call back used to notify when 1817 * the operation is completed 1818 * 1819 * @hide 1820 */ 1821 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); 1822 1823 /** 1824 * Free storage by deleting LRU sorted list of cache files across 1825 * all applications. If the currently available free storage 1826 * on the device is greater than or equal to the requested 1827 * free storage, no cache files are cleared. If the currently 1828 * available storage on the device is less than the requested 1829 * free storage, some or all of the cache files across 1830 * all applications are deleted (based on last accessed time) 1831 * to increase the free storage space on the device to 1832 * the requested value. There is no guarantee that clearing all 1833 * the cache files from all applications will clear up 1834 * enough storage to achieve the desired value. 1835 * @param freeStorageSize The number of bytes of storage to be 1836 * freed by the system. Say if freeStorageSize is XX, 1837 * and the current free storage is YY, 1838 * if XX is less than YY, just return. if not free XX-YY number 1839 * of bytes if possible. 1840 * @param pi IntentSender call back used to 1841 * notify when the operation is completed.May be null 1842 * to indicate that no call back is desired. 1843 * 1844 * @hide 1845 */ 1846 public abstract void freeStorage(long freeStorageSize, IntentSender pi); 1847 1848 /** 1849 * Retrieve the size information for a package. 1850 * Since this may take a little while, the result will 1851 * be posted back to the given observer. The calling context 1852 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 1853 * 1854 * @param packageName The name of the package whose size information is to be retrieved 1855 * @param observer An observer callback to get notified when the operation 1856 * is complete. 1857 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 1858 * The observer's callback is invoked with a PackageStats object(containing the 1859 * code, data and cache sizes of the package) and a boolean value representing 1860 * the status of the operation. observer may be null to indicate that 1861 * no callback is desired. 1862 * 1863 * @hide 1864 */ 1865 public abstract void getPackageSizeInfo(String packageName, 1866 IPackageStatsObserver observer); 1867 1868 /** 1869 * @deprecated This function no longer does anything; it was an old 1870 * approach to managing preferred activities, which has been superceeded 1871 * (and conflicts with) the modern activity-based preferences. 1872 */ 1873 @Deprecated 1874 public abstract void addPackageToPreferred(String packageName); 1875 1876 /** 1877 * @deprecated This function no longer does anything; it was an old 1878 * approach to managing preferred activities, which has been superceeded 1879 * (and conflicts with) the modern activity-based preferences. 1880 */ 1881 @Deprecated 1882 public abstract void removePackageFromPreferred(String packageName); 1883 1884 /** 1885 * Retrieve the list of all currently configured preferred packages. The 1886 * first package on the list is the most preferred, the last is the 1887 * least preferred. 1888 * 1889 * @param flags Additional option flags. Use any combination of 1890 * {@link #GET_ACTIVITIES}, 1891 * {@link #GET_GIDS}, 1892 * {@link #GET_CONFIGURATIONS}, 1893 * {@link #GET_INSTRUMENTATION}, 1894 * {@link #GET_PERMISSIONS}, 1895 * {@link #GET_PROVIDERS}, 1896 * {@link #GET_RECEIVERS}, 1897 * {@link #GET_SERVICES}, 1898 * {@link #GET_SIGNATURES}, to modify the data returned. 1899 * 1900 * @return Returns a list of PackageInfo objects describing each 1901 * preferred application, in order of preference. 1902 * 1903 * @see #GET_ACTIVITIES 1904 * @see #GET_GIDS 1905 * @see #GET_CONFIGURATIONS 1906 * @see #GET_INSTRUMENTATION 1907 * @see #GET_PERMISSIONS 1908 * @see #GET_PROVIDERS 1909 * @see #GET_RECEIVERS 1910 * @see #GET_SERVICES 1911 * @see #GET_SIGNATURES 1912 */ 1913 public abstract List<PackageInfo> getPreferredPackages(int flags); 1914 1915 /** 1916 * @deprecated This is a protected API that should not have been available 1917 * to third party applications. It is the platform's responsibility for 1918 * assigning preferred activities and this can not be directly modified. 1919 * 1920 * Add a new preferred activity mapping to the system. This will be used 1921 * to automatically select the given activity component when 1922 * {@link Context#startActivity(Intent) Context.startActivity()} finds 1923 * multiple matching activities and also matches the given filter. 1924 * 1925 * @param filter The set of intents under which this activity will be 1926 * made preferred. 1927 * @param match The IntentFilter match category that this preference 1928 * applies to. 1929 * @param set The set of activities that the user was picking from when 1930 * this preference was made. 1931 * @param activity The component name of the activity that is to be 1932 * preferred. 1933 */ 1934 @Deprecated 1935 public abstract void addPreferredActivity(IntentFilter filter, int match, 1936 ComponentName[] set, ComponentName activity); 1937 1938 /** 1939 * @deprecated This is a protected API that should not have been available 1940 * to third party applications. It is the platform's responsibility for 1941 * assigning preferred activities and this can not be directly modified. 1942 * 1943 * Replaces an existing preferred activity mapping to the system, and if that were not present 1944 * adds a new preferred activity. This will be used 1945 * to automatically select the given activity component when 1946 * {@link Context#startActivity(Intent) Context.startActivity()} finds 1947 * multiple matching activities and also matches the given filter. 1948 * 1949 * @param filter The set of intents under which this activity will be 1950 * made preferred. 1951 * @param match The IntentFilter match category that this preference 1952 * applies to. 1953 * @param set The set of activities that the user was picking from when 1954 * this preference was made. 1955 * @param activity The component name of the activity that is to be 1956 * preferred. 1957 * @hide 1958 */ 1959 @Deprecated 1960 public abstract void replacePreferredActivity(IntentFilter filter, int match, 1961 ComponentName[] set, ComponentName activity); 1962 1963 /** 1964 * Remove all preferred activity mappings, previously added with 1965 * {@link #addPreferredActivity}, from the 1966 * system whose activities are implemented in the given package name. 1967 * An application can only clear its own package(s). 1968 * 1969 * @param packageName The name of the package whose preferred activity 1970 * mappings are to be removed. 1971 */ 1972 public abstract void clearPackagePreferredActivities(String packageName); 1973 1974 /** 1975 * Retrieve all preferred activities, previously added with 1976 * {@link #addPreferredActivity}, that are 1977 * currently registered with the system. 1978 * 1979 * @param outFilters A list in which to place the filters of all of the 1980 * preferred activities, or null for none. 1981 * @param outActivities A list in which to place the component names of 1982 * all of the preferred activities, or null for none. 1983 * @param packageName An option package in which you would like to limit 1984 * the list. If null, all activities will be returned; if non-null, only 1985 * those activities in the given package are returned. 1986 * 1987 * @return Returns the total number of registered preferred activities 1988 * (the number of distinct IntentFilter records, not the number of unique 1989 * activity components) that were found. 1990 */ 1991 public abstract int getPreferredActivities(List<IntentFilter> outFilters, 1992 List<ComponentName> outActivities, String packageName); 1993 1994 /** 1995 * Set the enabled setting for a package component (activity, receiver, service, provider). 1996 * This setting will override any enabled state which may have been set by the component in its 1997 * manifest. 1998 * 1999 * @param componentName The component to enable 2000 * @param newState The new enabled state for the component. The legal values for this state 2001 * are: 2002 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2003 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2004 * and 2005 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2006 * The last one removes the setting, thereby restoring the component's state to 2007 * whatever was set in it's manifest (or enabled, by default). 2008 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2009 */ 2010 public abstract void setComponentEnabledSetting(ComponentName componentName, 2011 int newState, int flags); 2012 2013 2014 /** 2015 * Return the the enabled setting for a package component (activity, 2016 * receiver, service, provider). This returns the last value set by 2017 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 2018 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2019 * the value originally specified in the manifest has not been modified. 2020 * 2021 * @param componentName The component to retrieve. 2022 * @return Returns the current enabled state for the component. May 2023 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2024 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2025 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2026 * component's enabled state is based on the original information in 2027 * the manifest as found in {@link ComponentInfo}. 2028 */ 2029 public abstract int getComponentEnabledSetting(ComponentName componentName); 2030 2031 /** 2032 * Set the enabled setting for an application 2033 * This setting will override any enabled state which may have been set by the application in 2034 * its manifest. It also overrides the enabled state set in the manifest for any of the 2035 * application's components. It does not override any enabled state set by 2036 * {@link #setComponentEnabledSetting} for any of the application's components. 2037 * 2038 * @param packageName The package name of the application to enable 2039 * @param newState The new enabled state for the component. The legal values for this state 2040 * are: 2041 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2042 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2043 * and 2044 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2045 * The last one removes the setting, thereby restoring the applications's state to 2046 * whatever was set in its manifest (or enabled, by default). 2047 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2048 */ 2049 public abstract void setApplicationEnabledSetting(String packageName, 2050 int newState, int flags); 2051 2052 /** 2053 * Return the the enabled setting for an application. This returns 2054 * the last value set by 2055 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 2056 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2057 * the value originally specified in the manifest has not been modified. 2058 * 2059 * @param packageName The component to retrieve. 2060 * @return Returns the current enabled state for the component. May 2061 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2062 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2063 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2064 * application's enabled state is based on the original information in 2065 * the manifest as found in {@link ComponentInfo}. 2066 */ 2067 public abstract int getApplicationEnabledSetting(String packageName); 2068 2069 /** 2070 * Return whether the device has been booted into safe mode. 2071 */ 2072 public abstract boolean isSafeMode(); 2073 2074 /** 2075 * Attempts to move package resources from internal to external media or vice versa. 2076 * Since this may take a little while, the result will 2077 * be posted back to the given observer. This call may fail if the calling context 2078 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 2079 * named package cannot be found, or if the named package is a "system package". 2080 * 2081 * @param packageName The name of the package to delete 2082 * @param observer An observer callback to get notified when the package move is 2083 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 2084 * called when that happens. observer may be null to indicate that no callback is desired. 2085 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 2086 * {@link #MOVE_EXTERNAL_MEDIA} 2087 * 2088 * @hide 2089 */ 2090 public abstract void movePackage( 2091 String packageName, IPackageMoveObserver observer, int flags); 2092} 2093