PackageManager.java revision c9108b1856c7b6d98ddc04fbe330df21f2da890d
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.UserHandle; 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 a 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 a 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 some information about all applications (even 158 * uninstalled ones) which have data directories. This state could have 159 * resulted if applications have been deleted with flag 160 * {@code DONT_DELETE_DATA} with a possibility of being replaced or 161 * reinstalled in future. 162 * <p> 163 * Note: this flag may cause less information about currently installed 164 * applications to be returned. 165 */ 166 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; 167 168 /** 169 * {@link PackageInfo} flag: return information about 170 * hardware preferences in 171 * {@link PackageInfo#configPreferences PackageInfo.configPreferences} and 172 * requested features in {@link PackageInfo#reqFeatures 173 * PackageInfo.reqFeatures}. 174 */ 175 public static final int GET_CONFIGURATIONS = 0x00004000; 176 177 /** 178 * Resolution and querying flag: if set, only filters that support the 179 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for 180 * matching. This is a synonym for including the CATEGORY_DEFAULT in your 181 * supplied Intent. 182 */ 183 public static final int MATCH_DEFAULT_ONLY = 0x00010000; 184 185 /** 186 * Permission check result: this is returned by {@link #checkPermission} 187 * if the permission has been granted to the given package. 188 */ 189 public static final int PERMISSION_GRANTED = 0; 190 191 /** 192 * Permission check result: this is returned by {@link #checkPermission} 193 * if the permission has not been granted to the given package. 194 */ 195 public static final int PERMISSION_DENIED = -1; 196 197 /** 198 * Signature check result: this is returned by {@link #checkSignatures} 199 * if all signatures on the two packages match. 200 */ 201 public static final int SIGNATURE_MATCH = 0; 202 203 /** 204 * Signature check result: this is returned by {@link #checkSignatures} 205 * if neither of the two packages is signed. 206 */ 207 public static final int SIGNATURE_NEITHER_SIGNED = 1; 208 209 /** 210 * Signature check result: this is returned by {@link #checkSignatures} 211 * if the first package is not signed but the second is. 212 */ 213 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; 214 215 /** 216 * Signature check result: this is returned by {@link #checkSignatures} 217 * if the second package is not signed but the first is. 218 */ 219 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2; 220 221 /** 222 * Signature check result: this is returned by {@link #checkSignatures} 223 * if not all signatures on both packages match. 224 */ 225 public static final int SIGNATURE_NO_MATCH = -3; 226 227 /** 228 * Signature check result: this is returned by {@link #checkSignatures} 229 * if either of the packages are not valid. 230 */ 231 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; 232 233 /** 234 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 235 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 236 * component or application is in its default enabled state (as specified 237 * in its manifest). 238 */ 239 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; 240 241 /** 242 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 243 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 244 * component or application has been explictily enabled, regardless of 245 * what it has specified in its manifest. 246 */ 247 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; 248 249 /** 250 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 251 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 252 * component or application has been explicitly disabled, regardless of 253 * what it has specified in its manifest. 254 */ 255 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; 256 257 /** 258 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The 259 * user has explicitly disabled the application, regardless of what it has 260 * specified in its manifest. Because this is due to the user's request, 261 * they may re-enable it if desired through the appropriate system UI. This 262 * option currently <strong>can not</strong> be used with 263 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 264 */ 265 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; 266 267 /** 268 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to 269 * indicate that this package should be installed as forward locked, i.e. only the app itself 270 * should have access to its code and non-resource assets. 271 * @hide 272 */ 273 public static final int INSTALL_FORWARD_LOCK = 0x00000001; 274 275 /** 276 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already 277 * installed package, if one exists. 278 * @hide 279 */ 280 public static final int INSTALL_REPLACE_EXISTING = 0x00000002; 281 282 /** 283 * Flag parameter for {@link #installPackage} to indicate that you want to 284 * allow test packages (those that have set android:testOnly in their 285 * manifest) to be installed. 286 * @hide 287 */ 288 public static final int INSTALL_ALLOW_TEST = 0x00000004; 289 290 /** 291 * Flag parameter for {@link #installPackage} to indicate that this 292 * package has to be installed on the sdcard. 293 * @hide 294 */ 295 public static final int INSTALL_EXTERNAL = 0x00000008; 296 297 /** 298 * Flag parameter for {@link #installPackage} to indicate that this package 299 * has to be installed on the sdcard. 300 * @hide 301 */ 302 public static final int INSTALL_INTERNAL = 0x00000010; 303 304 /** 305 * Flag parameter for {@link #installPackage} to indicate that this install 306 * was initiated via ADB. 307 * 308 * @hide 309 */ 310 public static final int INSTALL_FROM_ADB = 0x00000020; 311 312 /** 313 * Flag parameter for {@link #installPackage} to indicate that this install 314 * should immediately be visible to all users. 315 * 316 * @hide 317 */ 318 public static final int INSTALL_ALL_USERS = 0x00000040; 319 320 /** 321 * Flag parameter for {@link #installPackage} to indicate that it is okay 322 * to install an update to an app where the newly installed app has a lower 323 * version code than the currently installed app. 324 * 325 * @hide 326 */ 327 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080; 328 329 /** 330 * Flag parameter for 331 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 332 * that you don't want to kill the app containing the component. Be careful when you set this 333 * since changing component states can make the containing application's behavior unpredictable. 334 */ 335 public static final int DONT_KILL_APP = 0x00000001; 336 337 /** 338 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 339 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success. 340 * @hide 341 */ 342 public static final int INSTALL_SUCCEEDED = 1; 343 344 /** 345 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 346 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is 347 * already installed. 348 * @hide 349 */ 350 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 351 352 /** 353 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 354 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive 355 * file is invalid. 356 * @hide 357 */ 358 public static final int INSTALL_FAILED_INVALID_APK = -2; 359 360 /** 361 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 362 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in 363 * is invalid. 364 * @hide 365 */ 366 public static final int INSTALL_FAILED_INVALID_URI = -3; 367 368 /** 369 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 370 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager 371 * service found that the device didn't have enough storage space to install the app. 372 * @hide 373 */ 374 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 375 376 /** 377 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 378 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a 379 * package is already installed with the same name. 380 * @hide 381 */ 382 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 383 384 /** 385 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 386 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 387 * the requested shared user does not exist. 388 * @hide 389 */ 390 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 391 392 /** 393 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 394 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 395 * a previously installed package of the same name has a different signature 396 * than the new package (and the old package's data was not removed). 397 * @hide 398 */ 399 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 400 401 /** 402 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 403 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 404 * the new package is requested a shared user which is already installed on the 405 * device and does not have matching signature. 406 * @hide 407 */ 408 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 409 410 /** 411 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 412 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 413 * the new package uses a shared library that is not available. 414 * @hide 415 */ 416 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 417 418 /** 419 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 420 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 421 * the new package uses a shared library that is not available. 422 * @hide 423 */ 424 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 425 426 /** 427 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 428 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 429 * the new package failed while optimizing and validating its dex files, 430 * either because there was not enough storage or the validation failed. 431 * @hide 432 */ 433 public static final int INSTALL_FAILED_DEXOPT = -11; 434 435 /** 436 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 437 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 438 * the new package failed because the current SDK version is older than 439 * that required by the package. 440 * @hide 441 */ 442 public static final int INSTALL_FAILED_OLDER_SDK = -12; 443 444 /** 445 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 446 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 447 * the new package failed because it contains a content provider with the 448 * same authority as a provider already installed in the system. 449 * @hide 450 */ 451 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 452 453 /** 454 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 455 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 456 * the new package failed because the current SDK version is newer than 457 * that required by the package. 458 * @hide 459 */ 460 public static final int INSTALL_FAILED_NEWER_SDK = -14; 461 462 /** 463 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 464 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 465 * the new package failed because it has specified that it is a test-only 466 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST} 467 * flag. 468 * @hide 469 */ 470 public static final int INSTALL_FAILED_TEST_ONLY = -15; 471 472 /** 473 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 474 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 475 * the package being installed contains native code, but none that is 476 * compatible with the the device's CPU_ABI. 477 * @hide 478 */ 479 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 480 481 /** 482 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 483 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 484 * the new package uses a feature that is not available. 485 * @hide 486 */ 487 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 488 489 // ------ Errors related to sdcard 490 /** 491 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 492 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 493 * a secure container mount point couldn't be accessed on external media. 494 * @hide 495 */ 496 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 497 498 /** 499 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 500 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 501 * the new package couldn't be installed in the specified install 502 * location. 503 * @hide 504 */ 505 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 506 507 /** 508 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 509 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 510 * the new package couldn't be installed in the specified install 511 * location because the media is not available. 512 * @hide 513 */ 514 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 515 516 /** 517 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 518 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 519 * the new package couldn't be installed because the verification timed out. 520 * @hide 521 */ 522 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; 523 524 /** 525 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 526 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 527 * the new package couldn't be installed because the verification did not succeed. 528 * @hide 529 */ 530 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; 531 532 /** 533 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 534 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 535 * the package changed from what the calling program expected. 536 * @hide 537 */ 538 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; 539 540 /** 541 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 542 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 543 * the new package is assigned a different UID than it previously held. 544 * @hide 545 */ 546 public static final int INSTALL_FAILED_UID_CHANGED = -24; 547 548 /** 549 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 550 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 551 * the new package has an older version code than the currently installed package. 552 * @hide 553 */ 554 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; 555 556 /** 557 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 558 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 559 * if the parser was given a path that is not a file, or does not end with the expected 560 * '.apk' extension. 561 * @hide 562 */ 563 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 564 565 /** 566 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 567 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 568 * if the parser was unable to retrieve the AndroidManifest.xml file. 569 * @hide 570 */ 571 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 572 573 /** 574 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 575 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 576 * if the parser encountered an unexpected exception. 577 * @hide 578 */ 579 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 580 581 /** 582 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 583 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 584 * if the parser did not find any certificates in the .apk. 585 * @hide 586 */ 587 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 588 589 /** 590 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 591 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 592 * if the parser found inconsistent certificates on the files in the .apk. 593 * @hide 594 */ 595 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 596 597 /** 598 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 599 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 600 * if the parser encountered a CertificateEncodingException in one of the 601 * files in the .apk. 602 * @hide 603 */ 604 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 605 606 /** 607 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 608 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 609 * if the parser encountered a bad or missing package name in the manifest. 610 * @hide 611 */ 612 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 613 614 /** 615 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 616 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 617 * if the parser encountered a bad shared user id name in the manifest. 618 * @hide 619 */ 620 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 621 622 /** 623 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 624 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 625 * if the parser encountered some structural problem in the manifest. 626 * @hide 627 */ 628 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 629 630 /** 631 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 632 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 633 * if the parser did not find any actionable tags (instrumentation or application) 634 * in the manifest. 635 * @hide 636 */ 637 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 638 639 /** 640 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 641 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 642 * if the system failed to install the package because of system issues. 643 * @hide 644 */ 645 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 646 647 /** 648 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 649 * package's data directory. 650 * 651 * @hide 652 */ 653 public static final int DELETE_KEEP_DATA = 0x00000001; 654 655 /** 656 * Flag parameter for {@link #deletePackage} to indicate that you want the 657 * package deleted for all users. 658 * 659 * @hide 660 */ 661 public static final int DELETE_ALL_USERS = 0x00000002; 662 663 /** 664 * Return code for when package deletion succeeds. This is passed to the 665 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 666 * succeeded in deleting the package. 667 * 668 * @hide 669 */ 670 public static final int DELETE_SUCCEEDED = 1; 671 672 /** 673 * Deletion failed return code: this is passed to the 674 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 675 * failed to delete the package for an unspecified reason. 676 * 677 * @hide 678 */ 679 public static final int DELETE_FAILED_INTERNAL_ERROR = -1; 680 681 /** 682 * Deletion failed return code: this is passed to the 683 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 684 * failed to delete the package because it is the active DevicePolicy 685 * manager. 686 * 687 * @hide 688 */ 689 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; 690 691 /** 692 * Return code that is passed to the {@link IPackageMoveObserver} by 693 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the 694 * package has been successfully moved by the system. 695 * 696 * @hide 697 */ 698 public static final int MOVE_SUCCEEDED = 1; 699 /** 700 * Error code that is passed to the {@link IPackageMoveObserver} by 701 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 702 * when the package hasn't been successfully moved by the system 703 * because of insufficient memory on specified media. 704 * @hide 705 */ 706 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 707 708 /** 709 * Error code that is passed to the {@link IPackageMoveObserver} by 710 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 711 * if the specified package doesn't exist. 712 * @hide 713 */ 714 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 715 716 /** 717 * Error code that is passed to the {@link IPackageMoveObserver} by 718 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 719 * if the specified package cannot be moved since its a system package. 720 * @hide 721 */ 722 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 723 724 /** 725 * Error code that is passed to the {@link IPackageMoveObserver} by 726 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 727 * if the specified package cannot be moved since its forward locked. 728 * @hide 729 */ 730 public static final int MOVE_FAILED_FORWARD_LOCKED = -4; 731 732 /** 733 * Error code that is passed to the {@link IPackageMoveObserver} by 734 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 735 * if the specified package cannot be moved to the specified location. 736 * @hide 737 */ 738 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 739 740 /** 741 * Error code that is passed to the {@link IPackageMoveObserver} by 742 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 743 * if the specified package cannot be moved to the specified location. 744 * @hide 745 */ 746 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 747 748 /** 749 * Error code that is passed to the {@link IPackageMoveObserver} by 750 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the 751 * specified package already has an operation pending in the 752 * {@link PackageHandler} queue. 753 * 754 * @hide 755 */ 756 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 757 758 /** 759 * Flag parameter for {@link #movePackage} to indicate that 760 * the package should be moved to internal storage if its 761 * been installed on external media. 762 * @hide 763 */ 764 public static final int MOVE_INTERNAL = 0x00000001; 765 766 /** 767 * Flag parameter for {@link #movePackage} to indicate that 768 * the package should be moved to external media. 769 * @hide 770 */ 771 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 772 773 /** 774 * Usable by the required verifier as the {@code verificationCode} argument 775 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 776 * allow the installation to proceed without any of the optional verifiers 777 * needing to vote. 778 * 779 * @hide 780 */ 781 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 782 783 /** 784 * Used as the {@code verificationCode} argument for 785 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 786 * package verifier allows the installation to proceed. 787 */ 788 public static final int VERIFICATION_ALLOW = 1; 789 790 /** 791 * Used as the {@code verificationCode} argument for 792 * {@link PackageManager#verifyPendingInstall} to indicate the calling 793 * package verifier does not vote to allow the installation to proceed. 794 */ 795 public static final int VERIFICATION_REJECT = -1; 796 797 /** 798 * Can be used as the {@code millisecondsToDelay} argument for 799 * {@link PackageManager#extendVerificationTimeout}. This is the 800 * maximum time {@code PackageManager} waits for the verification 801 * agent to return (in milliseconds). 802 */ 803 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 804 805 /** 806 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 807 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 808 * lag in sound input or output. 809 */ 810 @SdkConstant(SdkConstantType.FEATURE) 811 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 812 813 /** 814 * Feature for {@link #getSystemAvailableFeatures} and 815 * {@link #hasSystemFeature}: The device is capable of communicating with 816 * other devices via Bluetooth. 817 */ 818 @SdkConstant(SdkConstantType.FEATURE) 819 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 820 821 /** 822 * Feature for {@link #getSystemAvailableFeatures} and 823 * {@link #hasSystemFeature}: The device has a camera facing away 824 * from the screen. 825 */ 826 @SdkConstant(SdkConstantType.FEATURE) 827 public static final String FEATURE_CAMERA = "android.hardware.camera"; 828 829 /** 830 * Feature for {@link #getSystemAvailableFeatures} and 831 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 832 */ 833 @SdkConstant(SdkConstantType.FEATURE) 834 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 835 836 /** 837 * Feature for {@link #getSystemAvailableFeatures} and 838 * {@link #hasSystemFeature}: The device has at least one camera pointing in 839 * some direction. 840 * @hide 841 */ 842 @SdkConstant(SdkConstantType.FEATURE) 843 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 844 845 /** 846 * Feature for {@link #getSystemAvailableFeatures} and 847 * {@link #hasSystemFeature}: The device's camera supports flash. 848 */ 849 @SdkConstant(SdkConstantType.FEATURE) 850 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 851 852 /** 853 * Feature for {@link #getSystemAvailableFeatures} and 854 * {@link #hasSystemFeature}: The device has a front facing camera. 855 */ 856 @SdkConstant(SdkConstantType.FEATURE) 857 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 858 859 /** 860 * Feature for {@link #getSystemAvailableFeatures} and 861 * {@link #hasSystemFeature}: The device supports one or more methods of 862 * reporting current location. 863 */ 864 @SdkConstant(SdkConstantType.FEATURE) 865 public static final String FEATURE_LOCATION = "android.hardware.location"; 866 867 /** 868 * Feature for {@link #getSystemAvailableFeatures} and 869 * {@link #hasSystemFeature}: The device has a Global Positioning System 870 * receiver and can report precise location. 871 */ 872 @SdkConstant(SdkConstantType.FEATURE) 873 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 874 875 /** 876 * Feature for {@link #getSystemAvailableFeatures} and 877 * {@link #hasSystemFeature}: The device can report location with coarse 878 * accuracy using a network-based geolocation system. 879 */ 880 @SdkConstant(SdkConstantType.FEATURE) 881 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 882 883 /** 884 * Feature for {@link #getSystemAvailableFeatures} and 885 * {@link #hasSystemFeature}: The device can record audio via a 886 * microphone. 887 */ 888 @SdkConstant(SdkConstantType.FEATURE) 889 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 890 891 /** 892 * Feature for {@link #getSystemAvailableFeatures} and 893 * {@link #hasSystemFeature}: The device can communicate using Near-Field 894 * Communications (NFC). 895 */ 896 @SdkConstant(SdkConstantType.FEATURE) 897 public static final String FEATURE_NFC = "android.hardware.nfc"; 898 899 /** 900 * Feature for {@link #getSystemAvailableFeatures} and 901 * {@link #hasSystemFeature}: The device includes an accelerometer. 902 */ 903 @SdkConstant(SdkConstantType.FEATURE) 904 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 905 906 /** 907 * Feature for {@link #getSystemAvailableFeatures} and 908 * {@link #hasSystemFeature}: The device includes a barometer (air 909 * pressure sensor.) 910 */ 911 @SdkConstant(SdkConstantType.FEATURE) 912 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 913 914 /** 915 * Feature for {@link #getSystemAvailableFeatures} and 916 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 917 */ 918 @SdkConstant(SdkConstantType.FEATURE) 919 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 920 921 /** 922 * Feature for {@link #getSystemAvailableFeatures} and 923 * {@link #hasSystemFeature}: The device includes a gyroscope. 924 */ 925 @SdkConstant(SdkConstantType.FEATURE) 926 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 927 928 /** 929 * Feature for {@link #getSystemAvailableFeatures} and 930 * {@link #hasSystemFeature}: The device includes a light sensor. 931 */ 932 @SdkConstant(SdkConstantType.FEATURE) 933 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 934 935 /** 936 * Feature for {@link #getSystemAvailableFeatures} and 937 * {@link #hasSystemFeature}: The device includes a proximity sensor. 938 */ 939 @SdkConstant(SdkConstantType.FEATURE) 940 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 941 942 /** 943 * Feature for {@link #getSystemAvailableFeatures} and 944 * {@link #hasSystemFeature}: The device has a telephony radio with data 945 * communication support. 946 */ 947 @SdkConstant(SdkConstantType.FEATURE) 948 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 949 950 /** 951 * Feature for {@link #getSystemAvailableFeatures} and 952 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 953 */ 954 @SdkConstant(SdkConstantType.FEATURE) 955 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 956 957 /** 958 * Feature for {@link #getSystemAvailableFeatures} and 959 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 960 */ 961 @SdkConstant(SdkConstantType.FEATURE) 962 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 963 964 /** 965 * Feature for {@link #getSystemAvailableFeatures} and 966 * {@link #hasSystemFeature}: The device supports connecting to USB devices 967 * as the USB host. 968 */ 969 @SdkConstant(SdkConstantType.FEATURE) 970 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 971 972 /** 973 * Feature for {@link #getSystemAvailableFeatures} and 974 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 975 */ 976 @SdkConstant(SdkConstantType.FEATURE) 977 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 978 979 /** 980 * Feature for {@link #getSystemAvailableFeatures} and 981 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 982 */ 983 @SdkConstant(SdkConstantType.FEATURE) 984 public static final String FEATURE_SIP = "android.software.sip"; 985 986 /** 987 * Feature for {@link #getSystemAvailableFeatures} and 988 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 989 */ 990 @SdkConstant(SdkConstantType.FEATURE) 991 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 992 993 /** 994 * Feature for {@link #getSystemAvailableFeatures} and 995 * {@link #hasSystemFeature}: The device's display has a touch screen. 996 */ 997 @SdkConstant(SdkConstantType.FEATURE) 998 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 999 1000 1001 /** 1002 * Feature for {@link #getSystemAvailableFeatures} and 1003 * {@link #hasSystemFeature}: The device's touch screen supports 1004 * multitouch sufficient for basic two-finger gesture detection. 1005 */ 1006 @SdkConstant(SdkConstantType.FEATURE) 1007 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1008 1009 /** 1010 * Feature for {@link #getSystemAvailableFeatures} and 1011 * {@link #hasSystemFeature}: The device's touch screen is capable of 1012 * tracking two or more fingers fully independently. 1013 */ 1014 @SdkConstant(SdkConstantType.FEATURE) 1015 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1016 1017 /** 1018 * Feature for {@link #getSystemAvailableFeatures} and 1019 * {@link #hasSystemFeature}: The device's touch screen is capable of 1020 * tracking a full hand of fingers fully independently -- that is, 5 or 1021 * more simultaneous independent pointers. 1022 */ 1023 @SdkConstant(SdkConstantType.FEATURE) 1024 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1025 1026 /** 1027 * Feature for {@link #getSystemAvailableFeatures} and 1028 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1029 * does support touch emulation for basic events. For instance, the 1030 * device might use a mouse or remote control to drive a cursor, and 1031 * emulate basic touch pointer events like down, up, drag, etc. All 1032 * devices that support android.hardware.touchscreen or a sub-feature are 1033 * presumed to also support faketouch. 1034 */ 1035 @SdkConstant(SdkConstantType.FEATURE) 1036 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1037 1038 /** 1039 * Feature for {@link #getSystemAvailableFeatures} and 1040 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1041 * does support touch emulation for basic events that supports distinct 1042 * tracking of two or more fingers. This is an extension of 1043 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1044 * that unlike a distinct multitouch screen as defined by 1045 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1046 * devices will not actually provide full two-finger gestures since the 1047 * input is being transformed to cursor movement on the screen. That is, 1048 * single finger gestures will move a cursor; two-finger swipes will 1049 * result in single-finger touch events; other two-finger gestures will 1050 * result in the corresponding two-finger touch event. 1051 */ 1052 @SdkConstant(SdkConstantType.FEATURE) 1053 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1054 1055 /** 1056 * Feature for {@link #getSystemAvailableFeatures} and 1057 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1058 * does support touch emulation for basic events that supports tracking 1059 * a hand of fingers (5 or more fingers) fully independently. 1060 * This is an extension of 1061 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1062 * that unlike a multitouch screen as defined by 1063 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1064 * gestures can be detected due to the limitations described for 1065 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1066 */ 1067 @SdkConstant(SdkConstantType.FEATURE) 1068 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1069 1070 /** 1071 * Feature for {@link #getSystemAvailableFeatures} and 1072 * {@link #hasSystemFeature}: The device supports portrait orientation 1073 * screens. For backwards compatibility, you can assume that if neither 1074 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1075 * both portrait and landscape. 1076 */ 1077 @SdkConstant(SdkConstantType.FEATURE) 1078 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1079 1080 /** 1081 * Feature for {@link #getSystemAvailableFeatures} and 1082 * {@link #hasSystemFeature}: The device supports landscape orientation 1083 * screens. For backwards compatibility, you can assume that if neither 1084 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1085 * both portrait and landscape. 1086 */ 1087 @SdkConstant(SdkConstantType.FEATURE) 1088 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1089 1090 /** 1091 * Feature for {@link #getSystemAvailableFeatures} and 1092 * {@link #hasSystemFeature}: The device supports live wallpapers. 1093 */ 1094 @SdkConstant(SdkConstantType.FEATURE) 1095 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1096 1097 /** 1098 * Feature for {@link #getSystemAvailableFeatures} and 1099 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1100 */ 1101 @SdkConstant(SdkConstantType.FEATURE) 1102 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1103 1104 /** 1105 * Feature for {@link #getSystemAvailableFeatures} and 1106 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1107 */ 1108 @SdkConstant(SdkConstantType.FEATURE) 1109 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1110 1111 /** 1112 * Feature for {@link #getSystemAvailableFeatures} and 1113 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1114 * on a television. Television here is defined to be a typical living 1115 * room television experience: displayed on a big screen, where the user 1116 * is sitting far away from it, and the dominant form of input will be 1117 * something like a DPAD, not through touch or mouse. 1118 */ 1119 @SdkConstant(SdkConstantType.FEATURE) 1120 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1121 1122 /** 1123 * Action to external storage service to clean out removed apps. 1124 * @hide 1125 */ 1126 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1127 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1128 1129 /** 1130 * Extra field name for the URI to a verification file. Passed to a package 1131 * verifier. 1132 * 1133 * @hide 1134 */ 1135 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 1136 1137 /** 1138 * Extra field name for the ID of a package pending verification. Passed to 1139 * a package verifier and is used to call back to 1140 * {@link PackageManager#verifyPendingInstall(int, int)} 1141 */ 1142 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 1143 1144 /** 1145 * Extra field name for the package identifier which is trying to install 1146 * the package. 1147 * 1148 * @hide 1149 */ 1150 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 1151 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 1152 1153 /** 1154 * Extra field name for the requested install flags for a package pending 1155 * verification. Passed to a package verifier. 1156 * 1157 * @hide 1158 */ 1159 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 1160 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 1161 1162 /** 1163 * Extra field name for the uid of who is requesting to install 1164 * the package. 1165 * 1166 * @hide 1167 */ 1168 public static final String EXTRA_VERIFICATION_INSTALLER_UID 1169 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 1170 1171 /** 1172 * Extra field name for the package name of a package pending verification. 1173 * 1174 * @hide 1175 */ 1176 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 1177 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 1178 /** 1179 * Extra field name for the result of a verification, either 1180 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 1181 * Passed to package verifiers after a package is verified. 1182 */ 1183 public static final String EXTRA_VERIFICATION_RESULT 1184 = "android.content.pm.extra.VERIFICATION_RESULT"; 1185 1186 /** 1187 * Extra field name for the version code of a package pending verification. 1188 * 1189 * @hide 1190 */ 1191 public static final String EXTRA_VERIFICATION_VERSION_CODE 1192 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 1193 1194 /** 1195 * Retrieve overall information about an application package that is 1196 * installed on the system. 1197 * <p> 1198 * Throws {@link NameNotFoundException} if a package with the given name can 1199 * not be found on the system. 1200 * 1201 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1202 * desired package. 1203 * @param flags Additional option flags. Use any combination of 1204 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 1205 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 1206 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 1207 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 1208 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 1209 * modify the data returned. 1210 * @return Returns a PackageInfo object containing information about the 1211 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 1212 * package is not found in the list of installed applications, the 1213 * package information is retrieved from the list of uninstalled 1214 * applications(which includes installed applications as well as 1215 * applications with data directory ie applications which had been 1216 * deleted with DONT_DELTE_DATA flag set). 1217 * @see #GET_ACTIVITIES 1218 * @see #GET_GIDS 1219 * @see #GET_CONFIGURATIONS 1220 * @see #GET_INSTRUMENTATION 1221 * @see #GET_PERMISSIONS 1222 * @see #GET_PROVIDERS 1223 * @see #GET_RECEIVERS 1224 * @see #GET_SERVICES 1225 * @see #GET_SIGNATURES 1226 * @see #GET_UNINSTALLED_PACKAGES 1227 */ 1228 public abstract PackageInfo getPackageInfo(String packageName, int flags) 1229 throws NameNotFoundException; 1230 1231 /** 1232 * Map from the current package names in use on the device to whatever 1233 * the current canonical name of that package is. 1234 * @param names Array of current names to be mapped. 1235 * @return Returns an array of the same size as the original, containing 1236 * the canonical name for each package. 1237 */ 1238 public abstract String[] currentToCanonicalPackageNames(String[] names); 1239 1240 /** 1241 * Map from a packages canonical name to the current name in use on the device. 1242 * @param names Array of new names to be mapped. 1243 * @return Returns an array of the same size as the original, containing 1244 * the current name for each package. 1245 */ 1246 public abstract String[] canonicalToCurrentPackageNames(String[] names); 1247 1248 /** 1249 * Return a "good" intent to launch a front-door activity in a package, 1250 * for use for example to implement an "open" button when browsing through 1251 * packages. The current implementation will look first for a main 1252 * activity in the category {@link Intent#CATEGORY_INFO}, next for a 1253 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return 1254 * null if neither are found. 1255 * 1256 * <p>Throws {@link NameNotFoundException} if a package with the given 1257 * name can not be found on the system. 1258 * 1259 * @param packageName The name of the package to inspect. 1260 * 1261 * @return Returns either a fully-qualified Intent that can be used to 1262 * launch the main activity in the package, or null if the package does 1263 * not contain such an activity. 1264 */ 1265 public abstract Intent getLaunchIntentForPackage(String packageName); 1266 1267 /** 1268 * Return an array of all of the secondary group-ids that have been 1269 * assigned to a package. 1270 * 1271 * <p>Throws {@link NameNotFoundException} if a package with the given 1272 * name can not be found on the system. 1273 * 1274 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1275 * desired package. 1276 * 1277 * @return Returns an int array of the assigned gids, or null if there 1278 * are none. 1279 */ 1280 public abstract int[] getPackageGids(String packageName) 1281 throws NameNotFoundException; 1282 1283 /** 1284 * Retrieve all of the information we know about a particular permission. 1285 * 1286 * <p>Throws {@link NameNotFoundException} if a permission with the given 1287 * name can not be found on the system. 1288 * 1289 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 1290 * of the permission you are interested in. 1291 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1292 * retrieve any meta-data associated with the permission. 1293 * 1294 * @return Returns a {@link PermissionInfo} containing information about the 1295 * permission. 1296 */ 1297 public abstract PermissionInfo getPermissionInfo(String name, int flags) 1298 throws NameNotFoundException; 1299 1300 /** 1301 * Query for all of the permissions associated with a particular group. 1302 * 1303 * <p>Throws {@link NameNotFoundException} if the given group does not 1304 * exist. 1305 * 1306 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 1307 * of the permission group you are interested in. Use null to 1308 * find all of the permissions not associated with a group. 1309 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1310 * retrieve any meta-data associated with the permissions. 1311 * 1312 * @return Returns a list of {@link PermissionInfo} containing information 1313 * about all of the permissions in the given group. 1314 */ 1315 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 1316 int flags) throws NameNotFoundException; 1317 1318 /** 1319 * Retrieve all of the information we know about a particular group of 1320 * permissions. 1321 * 1322 * <p>Throws {@link NameNotFoundException} if a permission group with the given 1323 * name can not be found on the system. 1324 * 1325 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 1326 * of the permission you are interested in. 1327 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1328 * retrieve any meta-data associated with the permission group. 1329 * 1330 * @return Returns a {@link PermissionGroupInfo} containing information 1331 * about the permission. 1332 */ 1333 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 1334 int flags) throws NameNotFoundException; 1335 1336 /** 1337 * Retrieve all of the known permission groups in the system. 1338 * 1339 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1340 * retrieve any meta-data associated with the permission group. 1341 * 1342 * @return Returns a list of {@link PermissionGroupInfo} containing 1343 * information about all of the known permission groups. 1344 */ 1345 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 1346 1347 /** 1348 * Retrieve all of the information we know about a particular 1349 * package/application. 1350 * 1351 * <p>Throws {@link NameNotFoundException} if an application with the given 1352 * package name can not be found on the system. 1353 * 1354 * @param packageName The full name (i.e. com.google.apps.contacts) of an 1355 * application. 1356 * @param flags Additional option flags. Use any combination of 1357 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1358 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1359 * 1360 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 1361 * information about the package. 1362 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 1363 * found in the list of installed applications, 1364 * the application information is retrieved from the 1365 * list of uninstalled applications(which includes 1366 * installed applications as well as applications 1367 * with data directory ie applications which had been 1368 * deleted with DONT_DELTE_DATA flag set). 1369 * 1370 * @see #GET_META_DATA 1371 * @see #GET_SHARED_LIBRARY_FILES 1372 * @see #GET_UNINSTALLED_PACKAGES 1373 */ 1374 public abstract ApplicationInfo getApplicationInfo(String packageName, 1375 int flags) throws NameNotFoundException; 1376 1377 /** 1378 * Retrieve all of the information we know about a particular activity 1379 * class. 1380 * 1381 * <p>Throws {@link NameNotFoundException} if an activity with the given 1382 * class name can not be found on the system. 1383 * 1384 * @param component The full component name (i.e. 1385 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 1386 * class. 1387 * @param flags Additional option flags. Use any combination of 1388 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1389 * to modify the data (in ApplicationInfo) returned. 1390 * 1391 * @return {@link ActivityInfo} containing information about the activity. 1392 * 1393 * @see #GET_INTENT_FILTERS 1394 * @see #GET_META_DATA 1395 * @see #GET_SHARED_LIBRARY_FILES 1396 */ 1397 public abstract ActivityInfo getActivityInfo(ComponentName component, 1398 int flags) throws NameNotFoundException; 1399 1400 /** 1401 * Retrieve all of the information we know about a particular receiver 1402 * class. 1403 * 1404 * <p>Throws {@link NameNotFoundException} if a receiver with the given 1405 * class name can not be found on the system. 1406 * 1407 * @param component The full component name (i.e. 1408 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 1409 * class. 1410 * @param flags Additional option flags. Use any combination of 1411 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1412 * to modify the data returned. 1413 * 1414 * @return {@link ActivityInfo} containing information about the receiver. 1415 * 1416 * @see #GET_INTENT_FILTERS 1417 * @see #GET_META_DATA 1418 * @see #GET_SHARED_LIBRARY_FILES 1419 */ 1420 public abstract ActivityInfo getReceiverInfo(ComponentName component, 1421 int flags) throws NameNotFoundException; 1422 1423 /** 1424 * Retrieve all of the information we know about a particular service 1425 * class. 1426 * 1427 * <p>Throws {@link NameNotFoundException} if a service with the given 1428 * class name can not be found on the system. 1429 * 1430 * @param component The full component name (i.e. 1431 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 1432 * class. 1433 * @param flags Additional option flags. Use any combination of 1434 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1435 * to modify the data returned. 1436 * 1437 * @return ServiceInfo containing information about the service. 1438 * 1439 * @see #GET_META_DATA 1440 * @see #GET_SHARED_LIBRARY_FILES 1441 */ 1442 public abstract ServiceInfo getServiceInfo(ComponentName component, 1443 int flags) throws NameNotFoundException; 1444 1445 /** 1446 * Retrieve all of the information we know about a particular content 1447 * provider class. 1448 * 1449 * <p>Throws {@link NameNotFoundException} if a provider with the given 1450 * class name can not be found on the system. 1451 * 1452 * @param component The full component name (i.e. 1453 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 1454 * ContentProvider class. 1455 * @param flags Additional option flags. Use any combination of 1456 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1457 * to modify the data returned. 1458 * 1459 * @return ProviderInfo containing information about the service. 1460 * 1461 * @see #GET_META_DATA 1462 * @see #GET_SHARED_LIBRARY_FILES 1463 */ 1464 public abstract ProviderInfo getProviderInfo(ComponentName component, 1465 int flags) throws NameNotFoundException; 1466 1467 /** 1468 * Return a List of all packages that are installed 1469 * on the device. 1470 * 1471 * @param flags Additional option flags. Use any combination of 1472 * {@link #GET_ACTIVITIES}, 1473 * {@link #GET_GIDS}, 1474 * {@link #GET_CONFIGURATIONS}, 1475 * {@link #GET_INSTRUMENTATION}, 1476 * {@link #GET_PERMISSIONS}, 1477 * {@link #GET_PROVIDERS}, 1478 * {@link #GET_RECEIVERS}, 1479 * {@link #GET_SERVICES}, 1480 * {@link #GET_SIGNATURES}, 1481 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1482 * 1483 * @return A List of PackageInfo objects, one for each package that is 1484 * installed on the device. In the unlikely case of there being no 1485 * installed packages, an empty list is returned. 1486 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1487 * applications including those deleted with DONT_DELETE_DATA 1488 * (partially installed apps with data directory) will be returned. 1489 * 1490 * @see #GET_ACTIVITIES 1491 * @see #GET_GIDS 1492 * @see #GET_CONFIGURATIONS 1493 * @see #GET_INSTRUMENTATION 1494 * @see #GET_PERMISSIONS 1495 * @see #GET_PROVIDERS 1496 * @see #GET_RECEIVERS 1497 * @see #GET_SERVICES 1498 * @see #GET_SIGNATURES 1499 * @see #GET_UNINSTALLED_PACKAGES 1500 * 1501 */ 1502 public abstract List<PackageInfo> getInstalledPackages(int flags); 1503 1504 /** 1505 * Return a List of all packages that are installed on the device, for a specific user. 1506 * Requesting a list of installed packages for another user 1507 * will require the permission INTERACT_ACROSS_USERS_FULL. 1508 * @param flags Additional option flags. Use any combination of 1509 * {@link #GET_ACTIVITIES}, 1510 * {@link #GET_GIDS}, 1511 * {@link #GET_CONFIGURATIONS}, 1512 * {@link #GET_INSTRUMENTATION}, 1513 * {@link #GET_PERMISSIONS}, 1514 * {@link #GET_PROVIDERS}, 1515 * {@link #GET_RECEIVERS}, 1516 * {@link #GET_SERVICES}, 1517 * {@link #GET_SIGNATURES}, 1518 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1519 * @param userId The user for whom the installed packages are to be listed 1520 * 1521 * @return A List of PackageInfo objects, one for each package that is 1522 * installed on the device. In the unlikely case of there being no 1523 * installed packages, an empty list is returned. 1524 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1525 * applications including those deleted with DONT_DELETE_DATA 1526 * (partially installed apps with data directory) will be returned. 1527 * 1528 * @see #GET_ACTIVITIES 1529 * @see #GET_GIDS 1530 * @see #GET_CONFIGURATIONS 1531 * @see #GET_INSTRUMENTATION 1532 * @see #GET_PERMISSIONS 1533 * @see #GET_PROVIDERS 1534 * @see #GET_RECEIVERS 1535 * @see #GET_SERVICES 1536 * @see #GET_SIGNATURES 1537 * @see #GET_UNINSTALLED_PACKAGES 1538 * 1539 * @hide 1540 */ 1541 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId); 1542 1543 /** 1544 * Check whether a particular package has been granted a particular 1545 * permission. 1546 * 1547 * @param permName The name of the permission you are checking for, 1548 * @param pkgName The name of the package you are checking against. 1549 * 1550 * @return If the package has the permission, PERMISSION_GRANTED is 1551 * returned. If it does not have the permission, PERMISSION_DENIED 1552 * is returned. 1553 * 1554 * @see #PERMISSION_GRANTED 1555 * @see #PERMISSION_DENIED 1556 */ 1557 public abstract int checkPermission(String permName, String pkgName); 1558 1559 /** 1560 * Add a new dynamic permission to the system. For this to work, your 1561 * package must have defined a permission tree through the 1562 * {@link android.R.styleable#AndroidManifestPermissionTree 1563 * <permission-tree>} tag in its manifest. A package can only add 1564 * permissions to trees that were defined by either its own package or 1565 * another with the same user id; a permission is in a tree if it 1566 * matches the name of the permission tree + ".": for example, 1567 * "com.foo.bar" is a member of the permission tree "com.foo". 1568 * 1569 * <p>It is good to make your permission tree name descriptive, because you 1570 * are taking possession of that entire set of permission names. Thus, it 1571 * must be under a domain you control, with a suffix that will not match 1572 * any normal permissions that may be declared in any applications that 1573 * are part of that domain. 1574 * 1575 * <p>New permissions must be added before 1576 * any .apks are installed that use those permissions. Permissions you 1577 * add through this method are remembered across reboots of the device. 1578 * If the given permission already exists, the info you supply here 1579 * will be used to update it. 1580 * 1581 * @param info Description of the permission to be added. 1582 * 1583 * @return Returns true if a new permission was created, false if an 1584 * existing one was updated. 1585 * 1586 * @throws SecurityException if you are not allowed to add the 1587 * given permission name. 1588 * 1589 * @see #removePermission(String) 1590 */ 1591 public abstract boolean addPermission(PermissionInfo info); 1592 1593 /** 1594 * Like {@link #addPermission(PermissionInfo)} but asynchronously 1595 * persists the package manager state after returning from the call, 1596 * allowing it to return quicker and batch a series of adds at the 1597 * expense of no guarantee the added permission will be retained if 1598 * the device is rebooted before it is written. 1599 */ 1600 public abstract boolean addPermissionAsync(PermissionInfo info); 1601 1602 /** 1603 * Removes a permission that was previously added with 1604 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 1605 * -- you are only allowed to remove permissions that you are allowed 1606 * to add. 1607 * 1608 * @param name The name of the permission to remove. 1609 * 1610 * @throws SecurityException if you are not allowed to remove the 1611 * given permission name. 1612 * 1613 * @see #addPermission(PermissionInfo) 1614 */ 1615 public abstract void removePermission(String name); 1616 1617 /** 1618 * Grant a permission to an application which the application does not 1619 * already have. The permission must have been requested by the application, 1620 * but as an optional permission. If the application is not allowed to 1621 * hold the permission, a SecurityException is thrown. 1622 * @hide 1623 * 1624 * @param packageName The name of the package that the permission will be 1625 * granted to. 1626 * @param permissionName The name of the permission. 1627 */ 1628 public abstract void grantPermission(String packageName, String permissionName); 1629 1630 /** 1631 * Revoke a permission that was previously granted by {@link #grantPermission}. 1632 * @hide 1633 * 1634 * @param packageName The name of the package that the permission will be 1635 * granted to. 1636 * @param permissionName The name of the permission. 1637 */ 1638 public abstract void revokePermission(String packageName, String permissionName); 1639 1640 /** 1641 * Compare the signatures of two packages to determine if the same 1642 * signature appears in both of them. If they do contain the same 1643 * signature, then they are allowed special privileges when working 1644 * with each other: they can share the same user-id, run instrumentation 1645 * against each other, etc. 1646 * 1647 * @param pkg1 First package name whose signature will be compared. 1648 * @param pkg2 Second package name whose signature will be compared. 1649 * 1650 * @return Returns an integer indicating whether all signatures on the 1651 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 1652 * all signatures match or < 0 if there is not a match ({@link 1653 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 1654 * 1655 * @see #checkSignatures(int, int) 1656 * @see #SIGNATURE_MATCH 1657 * @see #SIGNATURE_NO_MATCH 1658 * @see #SIGNATURE_UNKNOWN_PACKAGE 1659 */ 1660 public abstract int checkSignatures(String pkg1, String pkg2); 1661 1662 /** 1663 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 1664 * the two packages to be checked. This can be useful, for example, 1665 * when doing the check in an IPC, where the UID is the only identity 1666 * available. It is functionally identical to determining the package 1667 * associated with the UIDs and checking their signatures. 1668 * 1669 * @param uid1 First UID whose signature will be compared. 1670 * @param uid2 Second UID whose signature will be compared. 1671 * 1672 * @return Returns an integer indicating whether all signatures on the 1673 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 1674 * all signatures match or < 0 if there is not a match ({@link 1675 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 1676 * 1677 * @see #checkSignatures(String, String) 1678 * @see #SIGNATURE_MATCH 1679 * @see #SIGNATURE_NO_MATCH 1680 * @see #SIGNATURE_UNKNOWN_PACKAGE 1681 */ 1682 public abstract int checkSignatures(int uid1, int uid2); 1683 1684 /** 1685 * Retrieve the names of all packages that are associated with a particular 1686 * user id. In most cases, this will be a single package name, the package 1687 * that has been assigned that user id. Where there are multiple packages 1688 * sharing the same user id through the "sharedUserId" mechanism, all 1689 * packages with that id will be returned. 1690 * 1691 * @param uid The user id for which you would like to retrieve the 1692 * associated packages. 1693 * 1694 * @return Returns an array of one or more packages assigned to the user 1695 * id, or null if there are no known packages with the given id. 1696 */ 1697 public abstract String[] getPackagesForUid(int uid); 1698 1699 /** 1700 * Retrieve the official name associated with a user id. This name is 1701 * guaranteed to never change, though it is possibly for the underlying 1702 * user id to be changed. That is, if you are storing information about 1703 * user ids in persistent storage, you should use the string returned 1704 * by this function instead of the raw user-id. 1705 * 1706 * @param uid The user id for which you would like to retrieve a name. 1707 * @return Returns a unique name for the given user id, or null if the 1708 * user id is not currently assigned. 1709 */ 1710 public abstract String getNameForUid(int uid); 1711 1712 /** 1713 * Return the user id associated with a shared user name. Multiple 1714 * applications can specify a shared user name in their manifest and thus 1715 * end up using a common uid. This might be used for new applications 1716 * that use an existing shared user name and need to know the uid of the 1717 * shared user. 1718 * 1719 * @param sharedUserName The shared user name whose uid is to be retrieved. 1720 * @return Returns the uid associated with the shared user, or NameNotFoundException 1721 * if the shared user name is not being used by any installed packages 1722 * @hide 1723 */ 1724 public abstract int getUidForSharedUser(String sharedUserName) 1725 throws NameNotFoundException; 1726 1727 /** 1728 * Return a List of all application packages that are installed on the 1729 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 1730 * applications including those deleted with DONT_DELETE_DATA(partially 1731 * installed apps with data directory) will be returned. 1732 * 1733 * @param flags Additional option flags. Use any combination of 1734 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1735 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1736 * 1737 * @return A List of ApplicationInfo objects, one for each application that 1738 * is installed on the device. In the unlikely case of there being 1739 * no installed applications, an empty list is returned. 1740 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1741 * applications including those deleted with DONT_DELETE_DATA 1742 * (partially installed apps with data directory) will be returned. 1743 * 1744 * @see #GET_META_DATA 1745 * @see #GET_SHARED_LIBRARY_FILES 1746 * @see #GET_UNINSTALLED_PACKAGES 1747 */ 1748 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 1749 1750 /** 1751 * Get a list of shared libraries that are available on the 1752 * system. 1753 * 1754 * @return An array of shared library names that are 1755 * available on the system, or null if none are installed. 1756 * 1757 */ 1758 public abstract String[] getSystemSharedLibraryNames(); 1759 1760 /** 1761 * Get a list of features that are available on the 1762 * system. 1763 * 1764 * @return An array of FeatureInfo classes describing the features 1765 * that are available on the system, or null if there are none(!!). 1766 */ 1767 public abstract FeatureInfo[] getSystemAvailableFeatures(); 1768 1769 /** 1770 * Check whether the given feature name is one of the available 1771 * features as returned by {@link #getSystemAvailableFeatures()}. 1772 * 1773 * @return Returns true if the devices supports the feature, else 1774 * false. 1775 */ 1776 public abstract boolean hasSystemFeature(String name); 1777 1778 /** 1779 * Determine the best action to perform for a given Intent. This is how 1780 * {@link Intent#resolveActivity} finds an activity if a class has not 1781 * been explicitly specified. 1782 * 1783 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 1784 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 1785 * only flag. You need to do so to resolve the activity in the same way 1786 * that {@link android.content.Context#startActivity(Intent)} and 1787 * {@link android.content.Intent#resolveActivity(PackageManager) 1788 * Intent.resolveActivity(PackageManager)} do.</p> 1789 * 1790 * @param intent An intent containing all of the desired specification 1791 * (action, data, type, category, and/or component). 1792 * @param flags Additional option flags. The most important is 1793 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1794 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1795 * 1796 * @return Returns a ResolveInfo containing the final activity intent that 1797 * was determined to be the best action. Returns null if no 1798 * matching activity was found. If multiple matching activities are 1799 * found and there is no default set, returns a ResolveInfo 1800 * containing something else, such as the activity resolver. 1801 * 1802 * @see #MATCH_DEFAULT_ONLY 1803 * @see #GET_INTENT_FILTERS 1804 * @see #GET_RESOLVED_FILTER 1805 */ 1806 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 1807 1808 /** 1809 * Determine the best action to perform for a given Intent for a given user. This 1810 * is how {@link Intent#resolveActivity} finds an activity if a class has not 1811 * been explicitly specified. 1812 * 1813 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 1814 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 1815 * only flag. You need to do so to resolve the activity in the same way 1816 * that {@link android.content.Context#startActivity(Intent)} and 1817 * {@link android.content.Intent#resolveActivity(PackageManager) 1818 * Intent.resolveActivity(PackageManager)} do.</p> 1819 * 1820 * @param intent An intent containing all of the desired specification 1821 * (action, data, type, category, and/or component). 1822 * @param flags Additional option flags. The most important is 1823 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1824 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1825 * @param userId The user id. 1826 * 1827 * @return Returns a ResolveInfo containing the final activity intent that 1828 * was determined to be the best action. Returns null if no 1829 * matching activity was found. If multiple matching activities are 1830 * found and there is no default set, returns a ResolveInfo 1831 * containing something else, such as the activity resolver. 1832 * 1833 * @see #MATCH_DEFAULT_ONLY 1834 * @see #GET_INTENT_FILTERS 1835 * @see #GET_RESOLVED_FILTER 1836 * 1837 * @hide 1838 */ 1839 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId); 1840 1841 /** 1842 * Retrieve all activities that can be performed for the given intent. 1843 * 1844 * @param intent The desired intent as per resolveActivity(). 1845 * @param flags Additional option flags. The most important is 1846 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1847 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1848 * 1849 * @return A List<ResolveInfo> containing one entry for each matching 1850 * Activity. These are ordered from best to worst match -- that 1851 * is, the first item in the list is what is returned by 1852 * {@link #resolveActivity}. If there are no matching activities, an empty 1853 * list is returned. 1854 * 1855 * @see #MATCH_DEFAULT_ONLY 1856 * @see #GET_INTENT_FILTERS 1857 * @see #GET_RESOLVED_FILTER 1858 */ 1859 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 1860 int flags); 1861 1862 /** 1863 * Retrieve all activities that can be performed for the given intent, for a specific user. 1864 * 1865 * @param intent The desired intent as per resolveActivity(). 1866 * @param flags Additional option flags. The most important is 1867 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1868 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1869 * 1870 * @return A List<ResolveInfo> containing one entry for each matching 1871 * Activity. These are ordered from best to worst match -- that 1872 * is, the first item in the list is what is returned by 1873 * {@link #resolveActivity}. If there are no matching activities, an empty 1874 * list is returned. 1875 * 1876 * @see #MATCH_DEFAULT_ONLY 1877 * @see #GET_INTENT_FILTERS 1878 * @see #GET_RESOLVED_FILTER 1879 * @hide 1880 */ 1881 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 1882 int flags, int userId); 1883 1884 1885 /** 1886 * Retrieve a set of activities that should be presented to the user as 1887 * similar options. This is like {@link #queryIntentActivities}, except it 1888 * also allows you to supply a list of more explicit Intents that you would 1889 * like to resolve to particular options, and takes care of returning the 1890 * final ResolveInfo list in a reasonable order, with no duplicates, based 1891 * on those inputs. 1892 * 1893 * @param caller The class name of the activity that is making the 1894 * request. This activity will never appear in the output 1895 * list. Can be null. 1896 * @param specifics An array of Intents that should be resolved to the 1897 * first specific results. Can be null. 1898 * @param intent The desired intent as per resolveActivity(). 1899 * @param flags Additional option flags. The most important is 1900 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1901 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1902 * 1903 * @return A List<ResolveInfo> containing one entry for each matching 1904 * Activity. These are ordered first by all of the intents resolved 1905 * in <var>specifics</var> and then any additional activities that 1906 * can handle <var>intent</var> but did not get included by one of 1907 * the <var>specifics</var> intents. If there are no matching 1908 * activities, an empty list is returned. 1909 * 1910 * @see #MATCH_DEFAULT_ONLY 1911 * @see #GET_INTENT_FILTERS 1912 * @see #GET_RESOLVED_FILTER 1913 */ 1914 public abstract List<ResolveInfo> queryIntentActivityOptions( 1915 ComponentName caller, Intent[] specifics, Intent intent, int flags); 1916 1917 /** 1918 * Retrieve all receivers that can handle a broadcast of the given intent. 1919 * 1920 * @param intent The desired intent as per resolveActivity(). 1921 * @param flags Additional option flags. 1922 * 1923 * @return A List<ResolveInfo> containing one entry for each matching 1924 * Receiver. These are ordered from first to last in priority. If 1925 * there are no matching receivers, an empty list is returned. 1926 * 1927 * @see #MATCH_DEFAULT_ONLY 1928 * @see #GET_INTENT_FILTERS 1929 * @see #GET_RESOLVED_FILTER 1930 */ 1931 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 1932 int flags); 1933 1934 /** 1935 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 1936 * user. 1937 * 1938 * @param intent The desired intent as per resolveActivity(). 1939 * @param flags Additional option flags. 1940 * @param userId The userId of the user being queried. 1941 * 1942 * @return A List<ResolveInfo> containing one entry for each matching 1943 * Receiver. These are ordered from first to last in priority. If 1944 * there are no matching receivers, an empty list is returned. 1945 * 1946 * @see #MATCH_DEFAULT_ONLY 1947 * @see #GET_INTENT_FILTERS 1948 * @see #GET_RESOLVED_FILTER 1949 * @hide 1950 */ 1951 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 1952 int flags, int userId); 1953 1954 /** 1955 * Determine the best service to handle for a given Intent. 1956 * 1957 * @param intent An intent containing all of the desired specification 1958 * (action, data, type, category, and/or component). 1959 * @param flags Additional option flags. 1960 * 1961 * @return Returns a ResolveInfo containing the final service intent that 1962 * was determined to be the best action. Returns null if no 1963 * matching service was found. 1964 * 1965 * @see #GET_INTENT_FILTERS 1966 * @see #GET_RESOLVED_FILTER 1967 */ 1968 public abstract ResolveInfo resolveService(Intent intent, int flags); 1969 1970 /** 1971 * Retrieve all services that can match the given intent. 1972 * 1973 * @param intent The desired intent as per resolveService(). 1974 * @param flags Additional option flags. 1975 * 1976 * @return A List<ResolveInfo> containing one entry for each matching 1977 * ServiceInfo. These are ordered from best to worst match -- that 1978 * is, the first item in the list is what is returned by 1979 * resolveService(). If there are no matching services, an empty 1980 * list is returned. 1981 * 1982 * @see #GET_INTENT_FILTERS 1983 * @see #GET_RESOLVED_FILTER 1984 */ 1985 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 1986 int flags); 1987 1988 /** 1989 * Retrieve all services that can match the given intent for a given user. 1990 * 1991 * @param intent The desired intent as per resolveService(). 1992 * @param flags Additional option flags. 1993 * @param userId The user id. 1994 * 1995 * @return A List<ResolveInfo> containing one entry for each matching 1996 * ServiceInfo. These are ordered from best to worst match -- that 1997 * is, the first item in the list is what is returned by 1998 * resolveService(). If there are no matching services, an empty 1999 * list is returned. 2000 * 2001 * @see #GET_INTENT_FILTERS 2002 * @see #GET_RESOLVED_FILTER 2003 * 2004 * @hide 2005 */ 2006 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 2007 int flags, int userId); 2008 2009 /** 2010 * Find a single content provider by its base path name. 2011 * 2012 * @param name The name of the provider to find. 2013 * @param flags Additional option flags. Currently should always be 0. 2014 * 2015 * @return ContentProviderInfo Information about the provider, if found, 2016 * else null. 2017 */ 2018 public abstract ProviderInfo resolveContentProvider(String name, 2019 int flags); 2020 2021 /** 2022 * Retrieve content provider information. 2023 * 2024 * <p><em>Note: unlike most other methods, an empty result set is indicated 2025 * by a null return instead of an empty list.</em> 2026 * 2027 * @param processName If non-null, limits the returned providers to only 2028 * those that are hosted by the given process. If null, 2029 * all content providers are returned. 2030 * @param uid If <var>processName</var> is non-null, this is the required 2031 * uid owning the requested content providers. 2032 * @param flags Additional option flags. Currently should always be 0. 2033 * 2034 * @return A List<ContentProviderInfo> containing one entry for each 2035 * content provider either patching <var>processName</var> or, if 2036 * <var>processName</var> is null, all known content providers. 2037 * <em>If there are no matching providers, null is returned.</em> 2038 */ 2039 public abstract List<ProviderInfo> queryContentProviders( 2040 String processName, int uid, int flags); 2041 2042 /** 2043 * Retrieve all of the information we know about a particular 2044 * instrumentation class. 2045 * 2046 * <p>Throws {@link NameNotFoundException} if instrumentation with the 2047 * given class name can not be found on the system. 2048 * 2049 * @param className The full name (i.e. 2050 * com.google.apps.contacts.InstrumentList) of an 2051 * Instrumentation class. 2052 * @param flags Additional option flags. Currently should always be 0. 2053 * 2054 * @return InstrumentationInfo containing information about the 2055 * instrumentation. 2056 */ 2057 public abstract InstrumentationInfo getInstrumentationInfo( 2058 ComponentName className, int flags) throws NameNotFoundException; 2059 2060 /** 2061 * Retrieve information about available instrumentation code. May be used 2062 * to retrieve either all instrumentation code, or only the code targeting 2063 * a particular package. 2064 * 2065 * @param targetPackage If null, all instrumentation is returned; only the 2066 * instrumentation targeting this package name is 2067 * returned. 2068 * @param flags Additional option flags. Currently should always be 0. 2069 * 2070 * @return A List<InstrumentationInfo> containing one entry for each 2071 * matching available Instrumentation. Returns an empty list if 2072 * there is no instrumentation available for the given package. 2073 */ 2074 public abstract List<InstrumentationInfo> queryInstrumentation( 2075 String targetPackage, int flags); 2076 2077 /** 2078 * Retrieve an image from a package. This is a low-level API used by 2079 * the various package manager info structures (such as 2080 * {@link ComponentInfo} to implement retrieval of their associated 2081 * icon. 2082 * 2083 * @param packageName The name of the package that this icon is coming from. 2084 * Can not be null. 2085 * @param resid The resource identifier of the desired image. Can not be 0. 2086 * @param appInfo Overall information about <var>packageName</var>. This 2087 * may be null, in which case the application information will be retrieved 2088 * for you if needed; if you already have this information around, it can 2089 * be much more efficient to supply it here. 2090 * 2091 * @return Returns a Drawable holding the requested image. Returns null if 2092 * an image could not be found for any reason. 2093 */ 2094 public abstract Drawable getDrawable(String packageName, int resid, 2095 ApplicationInfo appInfo); 2096 2097 /** 2098 * Retrieve the icon associated with an activity. Given the full name of 2099 * an activity, retrieves the information about it and calls 2100 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 2101 * If the activity can not be found, NameNotFoundException is thrown. 2102 * 2103 * @param activityName Name of the activity whose icon is to be retrieved. 2104 * 2105 * @return Returns the image of the icon, or the default activity icon if 2106 * it could not be found. Does not return null. 2107 * @throws NameNotFoundException Thrown if the resources for the given 2108 * activity could not be loaded. 2109 * 2110 * @see #getActivityIcon(Intent) 2111 */ 2112 public abstract Drawable getActivityIcon(ComponentName activityName) 2113 throws NameNotFoundException; 2114 2115 /** 2116 * Retrieve the icon associated with an Intent. If intent.getClassName() is 2117 * set, this simply returns the result of 2118 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 2119 * component and returns the icon associated with the resolved component. 2120 * If intent.getClassName() can not be found or the Intent can not be resolved 2121 * to a component, NameNotFoundException is thrown. 2122 * 2123 * @param intent The intent for which you would like to retrieve an icon. 2124 * 2125 * @return Returns the image of the icon, or the default activity icon if 2126 * it could not be found. Does not return null. 2127 * @throws NameNotFoundException Thrown if the resources for application 2128 * matching the given intent could not be loaded. 2129 * 2130 * @see #getActivityIcon(ComponentName) 2131 */ 2132 public abstract Drawable getActivityIcon(Intent intent) 2133 throws NameNotFoundException; 2134 2135 /** 2136 * Return the generic icon for an activity that is used when no specific 2137 * icon is defined. 2138 * 2139 * @return Drawable Image of the icon. 2140 */ 2141 public abstract Drawable getDefaultActivityIcon(); 2142 2143 /** 2144 * Retrieve the icon associated with an application. If it has not defined 2145 * an icon, the default app icon is returned. Does not return null. 2146 * 2147 * @param info Information about application being queried. 2148 * 2149 * @return Returns the image of the icon, or the default application icon 2150 * if it could not be found. 2151 * 2152 * @see #getApplicationIcon(String) 2153 */ 2154 public abstract Drawable getApplicationIcon(ApplicationInfo info); 2155 2156 /** 2157 * Retrieve the icon associated with an application. Given the name of the 2158 * application's package, retrieves the information about it and calls 2159 * getApplicationIcon() to return its icon. If the application can not be 2160 * found, NameNotFoundException is thrown. 2161 * 2162 * @param packageName Name of the package whose application icon is to be 2163 * retrieved. 2164 * 2165 * @return Returns the image of the icon, or the default application icon 2166 * if it could not be found. Does not return null. 2167 * @throws NameNotFoundException Thrown if the resources for the given 2168 * application could not be loaded. 2169 * 2170 * @see #getApplicationIcon(ApplicationInfo) 2171 */ 2172 public abstract Drawable getApplicationIcon(String packageName) 2173 throws NameNotFoundException; 2174 2175 /** 2176 * Retrieve the logo associated with an activity. Given the full name of 2177 * an activity, retrieves the information about it and calls 2178 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo. 2179 * If the activity can not be found, NameNotFoundException is thrown. 2180 * 2181 * @param activityName Name of the activity whose logo is to be retrieved. 2182 * 2183 * @return Returns the image of the logo or null if the activity has no 2184 * logo specified. 2185 * 2186 * @throws NameNotFoundException Thrown if the resources for the given 2187 * activity could not be loaded. 2188 * 2189 * @see #getActivityLogo(Intent) 2190 */ 2191 public abstract Drawable getActivityLogo(ComponentName activityName) 2192 throws NameNotFoundException; 2193 2194 /** 2195 * Retrieve the logo associated with an Intent. If intent.getClassName() is 2196 * set, this simply returns the result of 2197 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 2198 * component and returns the logo associated with the resolved component. 2199 * If intent.getClassName() can not be found or the Intent can not be resolved 2200 * to a component, NameNotFoundException is thrown. 2201 * 2202 * @param intent The intent for which you would like to retrieve a logo. 2203 * 2204 * @return Returns the image of the logo, or null if the activity has no 2205 * logo specified. 2206 * 2207 * @throws NameNotFoundException Thrown if the resources for application 2208 * matching the given intent could not be loaded. 2209 * 2210 * @see #getActivityLogo(ComponentName) 2211 */ 2212 public abstract Drawable getActivityLogo(Intent intent) 2213 throws NameNotFoundException; 2214 2215 /** 2216 * Retrieve the logo associated with an application. If it has not specified 2217 * a logo, this method returns null. 2218 * 2219 * @param info Information about application being queried. 2220 * 2221 * @return Returns the image of the logo, or null if no logo is specified 2222 * by the application. 2223 * 2224 * @see #getApplicationLogo(String) 2225 */ 2226 public abstract Drawable getApplicationLogo(ApplicationInfo info); 2227 2228 /** 2229 * Retrieve the logo associated with an application. Given the name of the 2230 * application's package, retrieves the information about it and calls 2231 * getApplicationLogo() to return its logo. If the application can not be 2232 * found, NameNotFoundException is thrown. 2233 * 2234 * @param packageName Name of the package whose application logo is to be 2235 * retrieved. 2236 * 2237 * @return Returns the image of the logo, or null if no application logo 2238 * has been specified. 2239 * 2240 * @throws NameNotFoundException Thrown if the resources for the given 2241 * application could not be loaded. 2242 * 2243 * @see #getApplicationLogo(ApplicationInfo) 2244 */ 2245 public abstract Drawable getApplicationLogo(String packageName) 2246 throws NameNotFoundException; 2247 2248 /** 2249 * Retrieve text from a package. This is a low-level API used by 2250 * the various package manager info structures (such as 2251 * {@link ComponentInfo} to implement retrieval of their associated 2252 * labels and other text. 2253 * 2254 * @param packageName The name of the package that this text is coming from. 2255 * Can not be null. 2256 * @param resid The resource identifier of the desired text. Can not be 0. 2257 * @param appInfo Overall information about <var>packageName</var>. This 2258 * may be null, in which case the application information will be retrieved 2259 * for you if needed; if you already have this information around, it can 2260 * be much more efficient to supply it here. 2261 * 2262 * @return Returns a CharSequence holding the requested text. Returns null 2263 * if the text could not be found for any reason. 2264 */ 2265 public abstract CharSequence getText(String packageName, int resid, 2266 ApplicationInfo appInfo); 2267 2268 /** 2269 * Retrieve an XML file from a package. This is a low-level API used to 2270 * retrieve XML meta data. 2271 * 2272 * @param packageName The name of the package that this xml is coming from. 2273 * Can not be null. 2274 * @param resid The resource identifier of the desired xml. Can not be 0. 2275 * @param appInfo Overall information about <var>packageName</var>. This 2276 * may be null, in which case the application information will be retrieved 2277 * for you if needed; if you already have this information around, it can 2278 * be much more efficient to supply it here. 2279 * 2280 * @return Returns an XmlPullParser allowing you to parse out the XML 2281 * data. Returns null if the xml resource could not be found for any 2282 * reason. 2283 */ 2284 public abstract XmlResourceParser getXml(String packageName, int resid, 2285 ApplicationInfo appInfo); 2286 2287 /** 2288 * Return the label to use for this application. 2289 * 2290 * @return Returns the label associated with this application, or null if 2291 * it could not be found for any reason. 2292 * @param info The application to get the label of 2293 */ 2294 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 2295 2296 /** 2297 * Retrieve the resources associated with an activity. Given the full 2298 * name of an activity, retrieves the information about it and calls 2299 * getResources() to return its application's resources. If the activity 2300 * can not be found, NameNotFoundException is thrown. 2301 * 2302 * @param activityName Name of the activity whose resources are to be 2303 * retrieved. 2304 * 2305 * @return Returns the application's Resources. 2306 * @throws NameNotFoundException Thrown if the resources for the given 2307 * application could not be loaded. 2308 * 2309 * @see #getResourcesForApplication(ApplicationInfo) 2310 */ 2311 public abstract Resources getResourcesForActivity(ComponentName activityName) 2312 throws NameNotFoundException; 2313 2314 /** 2315 * Retrieve the resources for an application. Throws NameNotFoundException 2316 * if the package is no longer installed. 2317 * 2318 * @param app Information about the desired application. 2319 * 2320 * @return Returns the application's Resources. 2321 * @throws NameNotFoundException Thrown if the resources for the given 2322 * application could not be loaded (most likely because it was uninstalled). 2323 */ 2324 public abstract Resources getResourcesForApplication(ApplicationInfo app) 2325 throws NameNotFoundException; 2326 2327 /** 2328 * Retrieve the resources associated with an application. Given the full 2329 * package name of an application, retrieves the information about it and 2330 * calls getResources() to return its application's resources. If the 2331 * appPackageName can not be found, NameNotFoundException is thrown. 2332 * 2333 * @param appPackageName Package name of the application whose resources 2334 * are to be retrieved. 2335 * 2336 * @return Returns the application's Resources. 2337 * @throws NameNotFoundException Thrown if the resources for the given 2338 * application could not be loaded. 2339 * 2340 * @see #getResourcesForApplication(ApplicationInfo) 2341 */ 2342 public abstract Resources getResourcesForApplication(String appPackageName) 2343 throws NameNotFoundException; 2344 2345 /** 2346 * Retrieve overall information about an application package defined 2347 * in a package archive file 2348 * 2349 * @param archiveFilePath The path to the archive file 2350 * @param flags Additional option flags. Use any combination of 2351 * {@link #GET_ACTIVITIES}, 2352 * {@link #GET_GIDS}, 2353 * {@link #GET_CONFIGURATIONS}, 2354 * {@link #GET_INSTRUMENTATION}, 2355 * {@link #GET_PERMISSIONS}, 2356 * {@link #GET_PROVIDERS}, 2357 * {@link #GET_RECEIVERS}, 2358 * {@link #GET_SERVICES}, 2359 * {@link #GET_SIGNATURES}, to modify the data returned. 2360 * 2361 * @return Returns the information about the package. Returns 2362 * null if the package could not be successfully parsed. 2363 * 2364 * @see #GET_ACTIVITIES 2365 * @see #GET_GIDS 2366 * @see #GET_CONFIGURATIONS 2367 * @see #GET_INSTRUMENTATION 2368 * @see #GET_PERMISSIONS 2369 * @see #GET_PROVIDERS 2370 * @see #GET_RECEIVERS 2371 * @see #GET_SERVICES 2372 * @see #GET_SIGNATURES 2373 * 2374 */ 2375 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 2376 PackageParser packageParser = new PackageParser(archiveFilePath); 2377 DisplayMetrics metrics = new DisplayMetrics(); 2378 metrics.setToDefaults(); 2379 final File sourceFile = new File(archiveFilePath); 2380 PackageParser.Package pkg = packageParser.parsePackage( 2381 sourceFile, archiveFilePath, metrics, 0); 2382 if (pkg == null) { 2383 return null; 2384 } 2385 if ((flags & GET_SIGNATURES) != 0) { 2386 packageParser.collectCertificates(pkg, 0); 2387 } 2388 PackageUserState state = new PackageUserState(); 2389 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 2390 } 2391 2392 /** 2393 * @hide 2394 * 2395 * Install a package. Since this may take a little while, the result will 2396 * be posted back to the given observer. An installation will fail if the calling context 2397 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 2398 * package named in the package file's manifest is already installed, or if there's no space 2399 * available on the device. 2400 * 2401 * @param packageURI The location of the package file to install. This can be a 'file:' or a 2402 * 'content:' URI. 2403 * @param observer An observer callback to get notified when the package installation is 2404 * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be 2405 * called when that happens. observer may be null to indicate that no callback is desired. 2406 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 2407 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 2408 * @param installerPackageName Optional package name of the application that is performing the 2409 * installation. This identifies which market the package came from. 2410 */ 2411 public abstract void installPackage( 2412 Uri packageURI, IPackageInstallObserver observer, int flags, 2413 String installerPackageName); 2414 2415 /** 2416 * Similar to 2417 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 2418 * with an extra verification file provided. 2419 * 2420 * @param packageURI The location of the package file to install. This can 2421 * be a 'file:' or a 'content:' URI. 2422 * @param observer An observer callback to get notified when the package 2423 * installation is complete. 2424 * {@link IPackageInstallObserver#packageInstalled(String, int)} 2425 * will be called when that happens. observer may be null to 2426 * indicate that no callback is desired. 2427 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 2428 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST} 2429 * . 2430 * @param installerPackageName Optional package name of the application that 2431 * is performing the installation. This identifies which market 2432 * the package came from. 2433 * @param verificationURI The location of the supplementary verification 2434 * file. This can be a 'file:' or a 'content:' URI. May be 2435 * {@code null}. 2436 * @param manifestDigest an object that holds the digest of the package 2437 * which can be used to verify ownership. May be {@code null}. 2438 * @param encryptionParams if the package to be installed is encrypted, 2439 * these parameters describing the encryption and authentication 2440 * used. May be {@code null}. 2441 * @hide 2442 */ 2443 public abstract void installPackageWithVerification(Uri packageURI, 2444 IPackageInstallObserver observer, int flags, String installerPackageName, 2445 Uri verificationURI, ManifestDigest manifestDigest, 2446 ContainerEncryptionParams encryptionParams); 2447 2448 /** 2449 * Similar to 2450 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 2451 * with an extra verification information provided. 2452 * 2453 * @param packageURI The location of the package file to install. This can 2454 * be a 'file:' or a 'content:' URI. 2455 * @param observer An observer callback to get notified when the package 2456 * installation is complete. 2457 * {@link IPackageInstallObserver#packageInstalled(String, int)} 2458 * will be called when that happens. observer may be null to 2459 * indicate that no callback is desired. 2460 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 2461 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST} 2462 * . 2463 * @param installerPackageName Optional package name of the application that 2464 * is performing the installation. This identifies which market 2465 * the package came from. 2466 * @param verificationParams an object that holds signal information to 2467 * assist verification. May be {@code null}. 2468 * @param encryptionParams if the package to be installed is encrypted, 2469 * these parameters describing the encryption and authentication 2470 * used. May be {@code null}. 2471 * 2472 * @hide 2473 */ 2474 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 2475 IPackageInstallObserver observer, int flags, String installerPackageName, 2476 VerificationParams verificationParams, 2477 ContainerEncryptionParams encryptionParams); 2478 2479 /** 2480 * If there is already an application with the given package name installed 2481 * on the system for other users, also install it for the calling user. 2482 * @hide 2483 */ 2484 public abstract int installExistingPackage(String packageName) 2485 throws NameNotFoundException; 2486 2487 /** 2488 * Allows a package listening to the 2489 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 2490 * broadcast} to respond to the package manager. The response must include 2491 * the {@code verificationCode} which is one of 2492 * {@link PackageManager#VERIFICATION_ALLOW} or 2493 * {@link PackageManager#VERIFICATION_REJECT}. 2494 * 2495 * @param id pending package identifier as passed via the 2496 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra 2497 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 2498 * or {@link PackageManager#VERIFICATION_REJECT}. 2499 * @throws SecurityException if the caller does not have the 2500 * PACKAGE_VERIFICATION_AGENT permission. 2501 */ 2502 public abstract void verifyPendingInstall(int id, int verificationCode); 2503 2504 /** 2505 * Allows a package listening to the 2506 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 2507 * broadcast} to extend the default timeout for a response and declare what 2508 * action to perform after the timeout occurs. The response must include 2509 * the {@code verificationCodeAtTimeout} which is one of 2510 * {@link PackageManager#VERIFICATION_ALLOW} or 2511 * {@link PackageManager#VERIFICATION_REJECT}. 2512 * 2513 * This method may only be called once per package id. Additional calls 2514 * will have no effect. 2515 * 2516 * @param id pending package identifier as passed via the 2517 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra 2518 * @param verificationCodeAtTimeout either 2519 * {@link PackageManager#VERIFICATION_ALLOW} or 2520 * {@link PackageManager#VERIFICATION_REJECT}. If 2521 * {@code verificationCodeAtTimeout} is neither 2522 * {@link PackageManager#VERIFICATION_ALLOW} or 2523 * {@link PackageManager#VERIFICATION_REJECT}, then 2524 * {@code verificationCodeAtTimeout} will default to 2525 * {@link PackageManager#VERIFICATION_REJECT}. 2526 * @param millisecondsToDelay the amount of time requested for the timeout. 2527 * Must be positive and less than 2528 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 2529 * {@code millisecondsToDelay} is out of bounds, 2530 * {@code millisecondsToDelay} will be set to the closest in 2531 * bounds value; namely, 0 or 2532 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 2533 * @throws SecurityException if the caller does not have the 2534 * PACKAGE_VERIFICATION_AGENT permission. 2535 */ 2536 public abstract void extendVerificationTimeout(int id, 2537 int verificationCodeAtTimeout, long millisecondsToDelay); 2538 2539 /** 2540 * Change the installer associated with a given package. There are limitations 2541 * on how the installer package can be changed; in particular: 2542 * <ul> 2543 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 2544 * is not signed with the same certificate as the calling application. 2545 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 2546 * has an installer package, and that installer package is not signed with 2547 * the same certificate as the calling application. 2548 * </ul> 2549 * 2550 * @param targetPackage The installed package whose installer will be changed. 2551 * @param installerPackageName The package name of the new installer. May be 2552 * null to clear the association. 2553 */ 2554 public abstract void setInstallerPackageName(String targetPackage, 2555 String installerPackageName); 2556 2557 /** 2558 * Attempts to delete a package. Since this may take a little while, the result will 2559 * be posted back to the given observer. A deletion will fail if the calling context 2560 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 2561 * named package cannot be found, or if the named package is a "system package". 2562 * (TODO: include pointer to documentation on "system packages") 2563 * 2564 * @param packageName The name of the package to delete 2565 * @param observer An observer callback to get notified when the package deletion is 2566 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 2567 * called when that happens. observer may be null to indicate that no callback is desired. 2568 * @param flags - possible values: {@link #DELETE_KEEP_DATA}, 2569 * {@link #DELETE_ALL_USERS}. 2570 * 2571 * @hide 2572 */ 2573 public abstract void deletePackage( 2574 String packageName, IPackageDeleteObserver observer, int flags); 2575 2576 /** 2577 * Retrieve the package name of the application that installed a package. This identifies 2578 * which market the package came from. 2579 * 2580 * @param packageName The name of the package to query 2581 */ 2582 public abstract String getInstallerPackageName(String packageName); 2583 2584 /** 2585 * Attempts to clear the user data directory of an application. 2586 * Since this may take a little while, the result will 2587 * be posted back to the given observer. A deletion will fail if the 2588 * named package cannot be found, or if the named package is a "system package". 2589 * 2590 * @param packageName The name of the package 2591 * @param observer An observer callback to get notified when the operation is finished 2592 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 2593 * will be called when that happens. observer may be null to indicate that 2594 * no callback is desired. 2595 * 2596 * @hide 2597 */ 2598 public abstract void clearApplicationUserData(String packageName, 2599 IPackageDataObserver observer); 2600 /** 2601 * Attempts to delete the cache files associated with an application. 2602 * Since this may take a little while, the result will 2603 * be posted back to the given observer. A deletion will fail if the calling context 2604 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 2605 * named package cannot be found, or if the named package is a "system package". 2606 * 2607 * @param packageName The name of the package to delete 2608 * @param observer An observer callback to get notified when the cache file deletion 2609 * is complete. 2610 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 2611 * will be called when that happens. observer may be null to indicate that 2612 * no callback is desired. 2613 * 2614 * @hide 2615 */ 2616 public abstract void deleteApplicationCacheFiles(String packageName, 2617 IPackageDataObserver observer); 2618 2619 /** 2620 * Free storage by deleting LRU sorted list of cache files across 2621 * all applications. If the currently available free storage 2622 * on the device is greater than or equal to the requested 2623 * free storage, no cache files are cleared. If the currently 2624 * available storage on the device is less than the requested 2625 * free storage, some or all of the cache files across 2626 * all applications are deleted (based on last accessed time) 2627 * to increase the free storage space on the device to 2628 * the requested value. There is no guarantee that clearing all 2629 * the cache files from all applications will clear up 2630 * enough storage to achieve the desired value. 2631 * @param freeStorageSize The number of bytes of storage to be 2632 * freed by the system. Say if freeStorageSize is XX, 2633 * and the current free storage is YY, 2634 * if XX is less than YY, just return. if not free XX-YY number 2635 * of bytes if possible. 2636 * @param observer call back used to notify when 2637 * the operation is completed 2638 * 2639 * @hide 2640 */ 2641 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); 2642 2643 /** 2644 * Free storage by deleting LRU sorted list of cache files across 2645 * all applications. If the currently available free storage 2646 * on the device is greater than or equal to the requested 2647 * free storage, no cache files are cleared. If the currently 2648 * available storage on the device is less than the requested 2649 * free storage, some or all of the cache files across 2650 * all applications are deleted (based on last accessed time) 2651 * to increase the free storage space on the device to 2652 * the requested value. There is no guarantee that clearing all 2653 * the cache files from all applications will clear up 2654 * enough storage to achieve the desired value. 2655 * @param freeStorageSize The number of bytes of storage to be 2656 * freed by the system. Say if freeStorageSize is XX, 2657 * and the current free storage is YY, 2658 * if XX is less than YY, just return. if not free XX-YY number 2659 * of bytes if possible. 2660 * @param pi IntentSender call back used to 2661 * notify when the operation is completed.May be null 2662 * to indicate that no call back is desired. 2663 * 2664 * @hide 2665 */ 2666 public abstract void freeStorage(long freeStorageSize, IntentSender pi); 2667 2668 /** 2669 * Retrieve the size information for a package. 2670 * Since this may take a little while, the result will 2671 * be posted back to the given observer. The calling context 2672 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 2673 * 2674 * @param packageName The name of the package whose size information is to be retrieved 2675 * @param userHandle The user whose size information should be retrieved. 2676 * @param observer An observer callback to get notified when the operation 2677 * is complete. 2678 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 2679 * The observer's callback is invoked with a PackageStats object(containing the 2680 * code, data and cache sizes of the package) and a boolean value representing 2681 * the status of the operation. observer may be null to indicate that 2682 * no callback is desired. 2683 * 2684 * @hide 2685 */ 2686 public abstract void getPackageSizeInfo(String packageName, int userHandle, 2687 IPackageStatsObserver observer); 2688 2689 /** 2690 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but 2691 * returns the size for the calling user. 2692 * 2693 * @hide 2694 */ 2695 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 2696 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer); 2697 } 2698 2699 /** 2700 * @deprecated This function no longer does anything; it was an old 2701 * approach to managing preferred activities, which has been superceeded 2702 * (and conflicts with) the modern activity-based preferences. 2703 */ 2704 @Deprecated 2705 public abstract void addPackageToPreferred(String packageName); 2706 2707 /** 2708 * @deprecated This function no longer does anything; it was an old 2709 * approach to managing preferred activities, which has been superceeded 2710 * (and conflicts with) the modern activity-based preferences. 2711 */ 2712 @Deprecated 2713 public abstract void removePackageFromPreferred(String packageName); 2714 2715 /** 2716 * Retrieve the list of all currently configured preferred packages. The 2717 * first package on the list is the most preferred, the last is the 2718 * least preferred. 2719 * 2720 * @param flags Additional option flags. Use any combination of 2721 * {@link #GET_ACTIVITIES}, 2722 * {@link #GET_GIDS}, 2723 * {@link #GET_CONFIGURATIONS}, 2724 * {@link #GET_INSTRUMENTATION}, 2725 * {@link #GET_PERMISSIONS}, 2726 * {@link #GET_PROVIDERS}, 2727 * {@link #GET_RECEIVERS}, 2728 * {@link #GET_SERVICES}, 2729 * {@link #GET_SIGNATURES}, to modify the data returned. 2730 * 2731 * @return Returns a list of PackageInfo objects describing each 2732 * preferred application, in order of preference. 2733 * 2734 * @see #GET_ACTIVITIES 2735 * @see #GET_GIDS 2736 * @see #GET_CONFIGURATIONS 2737 * @see #GET_INSTRUMENTATION 2738 * @see #GET_PERMISSIONS 2739 * @see #GET_PROVIDERS 2740 * @see #GET_RECEIVERS 2741 * @see #GET_SERVICES 2742 * @see #GET_SIGNATURES 2743 */ 2744 public abstract List<PackageInfo> getPreferredPackages(int flags); 2745 2746 /** 2747 * @deprecated This is a protected API that should not have been available 2748 * to third party applications. It is the platform's responsibility for 2749 * assigning preferred activities and this can not be directly modified. 2750 * 2751 * Add a new preferred activity mapping to the system. This will be used 2752 * to automatically select the given activity component when 2753 * {@link Context#startActivity(Intent) Context.startActivity()} finds 2754 * multiple matching activities and also matches the given filter. 2755 * 2756 * @param filter The set of intents under which this activity will be 2757 * made preferred. 2758 * @param match The IntentFilter match category that this preference 2759 * applies to. 2760 * @param set The set of activities that the user was picking from when 2761 * this preference was made. 2762 * @param activity The component name of the activity that is to be 2763 * preferred. 2764 */ 2765 @Deprecated 2766 public abstract void addPreferredActivity(IntentFilter filter, int match, 2767 ComponentName[] set, ComponentName activity); 2768 2769 /** 2770 * Same as {@link #addPreferredActivity(IntentFilter, int, 2771 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 2772 to. 2773 * @hide 2774 */ 2775 public void addPreferredActivity(IntentFilter filter, int match, 2776 ComponentName[] set, ComponentName activity, int userId) { 2777 throw new RuntimeException("Not implemented. Must override in a subclass."); 2778 } 2779 2780 /** 2781 * @deprecated This is a protected API that should not have been available 2782 * to third party applications. It is the platform's responsibility for 2783 * assigning preferred activities and this can not be directly modified. 2784 * 2785 * Replaces an existing preferred activity mapping to the system, and if that were not present 2786 * adds a new preferred activity. This will be used 2787 * to automatically select the given activity component when 2788 * {@link Context#startActivity(Intent) Context.startActivity()} finds 2789 * multiple matching activities and also matches the given filter. 2790 * 2791 * @param filter The set of intents under which this activity will be 2792 * made preferred. 2793 * @param match The IntentFilter match category that this preference 2794 * applies to. 2795 * @param set The set of activities that the user was picking from when 2796 * this preference was made. 2797 * @param activity The component name of the activity that is to be 2798 * preferred. 2799 * @hide 2800 */ 2801 @Deprecated 2802 public abstract void replacePreferredActivity(IntentFilter filter, int match, 2803 ComponentName[] set, ComponentName activity); 2804 2805 /** 2806 * Remove all preferred activity mappings, previously added with 2807 * {@link #addPreferredActivity}, from the 2808 * system whose activities are implemented in the given package name. 2809 * An application can only clear its own package(s). 2810 * 2811 * @param packageName The name of the package whose preferred activity 2812 * mappings are to be removed. 2813 */ 2814 public abstract void clearPackagePreferredActivities(String packageName); 2815 2816 /** 2817 * Retrieve all preferred activities, previously added with 2818 * {@link #addPreferredActivity}, that are 2819 * currently registered with the system. 2820 * 2821 * @param outFilters A list in which to place the filters of all of the 2822 * preferred activities, or null for none. 2823 * @param outActivities A list in which to place the component names of 2824 * all of the preferred activities, or null for none. 2825 * @param packageName An option package in which you would like to limit 2826 * the list. If null, all activities will be returned; if non-null, only 2827 * those activities in the given package are returned. 2828 * 2829 * @return Returns the total number of registered preferred activities 2830 * (the number of distinct IntentFilter records, not the number of unique 2831 * activity components) that were found. 2832 */ 2833 public abstract int getPreferredActivities(List<IntentFilter> outFilters, 2834 List<ComponentName> outActivities, String packageName); 2835 2836 /** 2837 * Set the enabled setting for a package component (activity, receiver, service, provider). 2838 * This setting will override any enabled state which may have been set by the component in its 2839 * manifest. 2840 * 2841 * @param componentName The component to enable 2842 * @param newState The new enabled state for the component. The legal values for this state 2843 * are: 2844 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2845 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2846 * and 2847 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2848 * The last one removes the setting, thereby restoring the component's state to 2849 * whatever was set in it's manifest (or enabled, by default). 2850 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2851 */ 2852 public abstract void setComponentEnabledSetting(ComponentName componentName, 2853 int newState, int flags); 2854 2855 2856 /** 2857 * Return the the enabled setting for a package component (activity, 2858 * receiver, service, provider). This returns the last value set by 2859 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 2860 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2861 * the value originally specified in the manifest has not been modified. 2862 * 2863 * @param componentName The component to retrieve. 2864 * @return Returns the current enabled state for the component. May 2865 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2866 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2867 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2868 * component's enabled state is based on the original information in 2869 * the manifest as found in {@link ComponentInfo}. 2870 */ 2871 public abstract int getComponentEnabledSetting(ComponentName componentName); 2872 2873 /** 2874 * Set the enabled setting for an application 2875 * This setting will override any enabled state which may have been set by the application in 2876 * its manifest. It also overrides the enabled state set in the manifest for any of the 2877 * application's components. It does not override any enabled state set by 2878 * {@link #setComponentEnabledSetting} for any of the application's components. 2879 * 2880 * @param packageName The package name of the application to enable 2881 * @param newState The new enabled state for the component. The legal values for this state 2882 * are: 2883 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2884 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2885 * and 2886 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2887 * The last one removes the setting, thereby restoring the applications's state to 2888 * whatever was set in its manifest (or enabled, by default). 2889 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2890 */ 2891 public abstract void setApplicationEnabledSetting(String packageName, 2892 int newState, int flags); 2893 2894 /** 2895 * Return the the enabled setting for an application. This returns 2896 * the last value set by 2897 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 2898 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2899 * the value originally specified in the manifest has not been modified. 2900 * 2901 * @param packageName The component to retrieve. 2902 * @return Returns the current enabled state for the component. May 2903 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2904 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2905 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2906 * application's enabled state is based on the original information in 2907 * the manifest as found in {@link ComponentInfo}. 2908 * @throws IllegalArgumentException if the named package does not exist. 2909 */ 2910 public abstract int getApplicationEnabledSetting(String packageName); 2911 2912 /** 2913 * Return whether the device has been booted into safe mode. 2914 */ 2915 public abstract boolean isSafeMode(); 2916 2917 /** 2918 * Attempts to move package resources from internal to external media or vice versa. 2919 * Since this may take a little while, the result will 2920 * be posted back to the given observer. This call may fail if the calling context 2921 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 2922 * named package cannot be found, or if the named package is a "system package". 2923 * 2924 * @param packageName The name of the package to delete 2925 * @param observer An observer callback to get notified when the package move is 2926 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 2927 * called when that happens. observer may be null to indicate that no callback is desired. 2928 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 2929 * {@link #MOVE_EXTERNAL_MEDIA} 2930 * 2931 * @hide 2932 */ 2933 public abstract void movePackage( 2934 String packageName, IPackageMoveObserver observer, int flags); 2935 2936 /** 2937 * Returns the device identity that verifiers can use to associate their scheme to a particular 2938 * device. This should not be used by anything other than a package verifier. 2939 * 2940 * @return identity that uniquely identifies current device 2941 * @hide 2942 */ 2943 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 2944 2945 /** 2946 * Returns the data directory for a particular user and package, given the uid of the package. 2947 * @param uid uid of the package, including the userId and appId 2948 * @param packageName name of the package 2949 * @return the user-specific data directory for the package 2950 * @hide 2951 */ 2952 public static String getDataDirForUser(int userId, String packageName) { 2953 // TODO: This should be shared with Installer's knowledge of user directory 2954 return Environment.getDataDirectory().toString() + "/user/" + userId 2955 + "/" + packageName; 2956 } 2957} 2958