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