PackageManager.java revision 151ec4c9f8ca34625733730a4551a23eb97cda23
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's camera supports flash. 839 */ 840 @SdkConstant(SdkConstantType.FEATURE) 841 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 842 843 /** 844 * Feature for {@link #getSystemAvailableFeatures} and 845 * {@link #hasSystemFeature}: The device has a front facing camera. 846 */ 847 @SdkConstant(SdkConstantType.FEATURE) 848 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 849 850 /** 851 * Feature for {@link #getSystemAvailableFeatures} and 852 * {@link #hasSystemFeature}: The device supports one or more methods of 853 * reporting current location. 854 */ 855 @SdkConstant(SdkConstantType.FEATURE) 856 public static final String FEATURE_LOCATION = "android.hardware.location"; 857 858 /** 859 * Feature for {@link #getSystemAvailableFeatures} and 860 * {@link #hasSystemFeature}: The device has a Global Positioning System 861 * receiver and can report precise location. 862 */ 863 @SdkConstant(SdkConstantType.FEATURE) 864 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 865 866 /** 867 * Feature for {@link #getSystemAvailableFeatures} and 868 * {@link #hasSystemFeature}: The device can report location with coarse 869 * accuracy using a network-based geolocation system. 870 */ 871 @SdkConstant(SdkConstantType.FEATURE) 872 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 873 874 /** 875 * Feature for {@link #getSystemAvailableFeatures} and 876 * {@link #hasSystemFeature}: The device can record audio via a 877 * microphone. 878 */ 879 @SdkConstant(SdkConstantType.FEATURE) 880 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 881 882 /** 883 * Feature for {@link #getSystemAvailableFeatures} and 884 * {@link #hasSystemFeature}: The device can communicate using Near-Field 885 * Communications (NFC). 886 */ 887 @SdkConstant(SdkConstantType.FEATURE) 888 public static final String FEATURE_NFC = "android.hardware.nfc"; 889 890 /** 891 * Feature for {@link #getSystemAvailableFeatures} and 892 * {@link #hasSystemFeature}: The device includes an accelerometer. 893 */ 894 @SdkConstant(SdkConstantType.FEATURE) 895 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 896 897 /** 898 * Feature for {@link #getSystemAvailableFeatures} and 899 * {@link #hasSystemFeature}: The device includes a barometer (air 900 * pressure sensor.) 901 */ 902 @SdkConstant(SdkConstantType.FEATURE) 903 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 904 905 /** 906 * Feature for {@link #getSystemAvailableFeatures} and 907 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 908 */ 909 @SdkConstant(SdkConstantType.FEATURE) 910 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 911 912 /** 913 * Feature for {@link #getSystemAvailableFeatures} and 914 * {@link #hasSystemFeature}: The device includes a gyroscope. 915 */ 916 @SdkConstant(SdkConstantType.FEATURE) 917 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 918 919 /** 920 * Feature for {@link #getSystemAvailableFeatures} and 921 * {@link #hasSystemFeature}: The device includes a light sensor. 922 */ 923 @SdkConstant(SdkConstantType.FEATURE) 924 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 925 926 /** 927 * Feature for {@link #getSystemAvailableFeatures} and 928 * {@link #hasSystemFeature}: The device includes a proximity sensor. 929 */ 930 @SdkConstant(SdkConstantType.FEATURE) 931 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 932 933 /** 934 * Feature for {@link #getSystemAvailableFeatures} and 935 * {@link #hasSystemFeature}: The device has a telephony radio with data 936 * communication support. 937 */ 938 @SdkConstant(SdkConstantType.FEATURE) 939 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 940 941 /** 942 * Feature for {@link #getSystemAvailableFeatures} and 943 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 944 */ 945 @SdkConstant(SdkConstantType.FEATURE) 946 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 947 948 /** 949 * Feature for {@link #getSystemAvailableFeatures} and 950 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 951 */ 952 @SdkConstant(SdkConstantType.FEATURE) 953 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 954 955 /** 956 * Feature for {@link #getSystemAvailableFeatures} and 957 * {@link #hasSystemFeature}: The device supports connecting to USB devices 958 * as the USB host. 959 */ 960 @SdkConstant(SdkConstantType.FEATURE) 961 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 962 963 /** 964 * Feature for {@link #getSystemAvailableFeatures} and 965 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 966 */ 967 @SdkConstant(SdkConstantType.FEATURE) 968 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 969 970 /** 971 * Feature for {@link #getSystemAvailableFeatures} and 972 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 973 */ 974 @SdkConstant(SdkConstantType.FEATURE) 975 public static final String FEATURE_SIP = "android.software.sip"; 976 977 /** 978 * Feature for {@link #getSystemAvailableFeatures} and 979 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 980 */ 981 @SdkConstant(SdkConstantType.FEATURE) 982 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 983 984 /** 985 * Feature for {@link #getSystemAvailableFeatures} and 986 * {@link #hasSystemFeature}: The device's display has a touch screen. 987 */ 988 @SdkConstant(SdkConstantType.FEATURE) 989 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 990 991 992 /** 993 * Feature for {@link #getSystemAvailableFeatures} and 994 * {@link #hasSystemFeature}: The device's touch screen supports 995 * multitouch sufficient for basic two-finger gesture detection. 996 */ 997 @SdkConstant(SdkConstantType.FEATURE) 998 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 999 1000 /** 1001 * Feature for {@link #getSystemAvailableFeatures} and 1002 * {@link #hasSystemFeature}: The device's touch screen is capable of 1003 * tracking two or more fingers fully independently. 1004 */ 1005 @SdkConstant(SdkConstantType.FEATURE) 1006 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1007 1008 /** 1009 * Feature for {@link #getSystemAvailableFeatures} and 1010 * {@link #hasSystemFeature}: The device's touch screen is capable of 1011 * tracking a full hand of fingers fully independently -- that is, 5 or 1012 * more simultaneous independent pointers. 1013 */ 1014 @SdkConstant(SdkConstantType.FEATURE) 1015 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1016 1017 /** 1018 * Feature for {@link #getSystemAvailableFeatures} and 1019 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1020 * does support touch emulation for basic events. For instance, the 1021 * device might use a mouse or remote control to drive a cursor, and 1022 * emulate basic touch pointer events like down, up, drag, etc. All 1023 * devices that support android.hardware.touchscreen or a sub-feature are 1024 * presumed to also support faketouch. 1025 */ 1026 @SdkConstant(SdkConstantType.FEATURE) 1027 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1028 1029 /** 1030 * Feature for {@link #getSystemAvailableFeatures} and 1031 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1032 * does support touch emulation for basic events that supports distinct 1033 * tracking of two or more fingers. This is an extension of 1034 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1035 * that unlike a distinct multitouch screen as defined by 1036 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1037 * devices will not actually provide full two-finger gestures since the 1038 * input is being transformed to cursor movement on the screen. That is, 1039 * single finger gestures will move a cursor; two-finger swipes will 1040 * result in single-finger touch events; other two-finger gestures will 1041 * result in the corresponding two-finger touch event. 1042 */ 1043 @SdkConstant(SdkConstantType.FEATURE) 1044 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1045 1046 /** 1047 * Feature for {@link #getSystemAvailableFeatures} and 1048 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1049 * does support touch emulation for basic events that supports tracking 1050 * a hand of fingers (5 or more fingers) fully independently. 1051 * This is an extension of 1052 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1053 * that unlike a multitouch screen as defined by 1054 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1055 * gestures can be detected due to the limitations described for 1056 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1057 */ 1058 @SdkConstant(SdkConstantType.FEATURE) 1059 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1060 1061 /** 1062 * Feature for {@link #getSystemAvailableFeatures} and 1063 * {@link #hasSystemFeature}: The device supports portrait orientation 1064 * screens. For backwards compatibility, you can assume that if neither 1065 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1066 * both portrait and landscape. 1067 */ 1068 @SdkConstant(SdkConstantType.FEATURE) 1069 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1070 1071 /** 1072 * Feature for {@link #getSystemAvailableFeatures} and 1073 * {@link #hasSystemFeature}: The device supports landscape orientation 1074 * screens. For backwards compatibility, you can assume that if neither 1075 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1076 * both portrait and landscape. 1077 */ 1078 @SdkConstant(SdkConstantType.FEATURE) 1079 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1080 1081 /** 1082 * Feature for {@link #getSystemAvailableFeatures} and 1083 * {@link #hasSystemFeature}: The device supports live wallpapers. 1084 */ 1085 @SdkConstant(SdkConstantType.FEATURE) 1086 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1087 1088 /** 1089 * Feature for {@link #getSystemAvailableFeatures} and 1090 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1091 */ 1092 @SdkConstant(SdkConstantType.FEATURE) 1093 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1094 1095 /** 1096 * Feature for {@link #getSystemAvailableFeatures} and 1097 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1098 */ 1099 @SdkConstant(SdkConstantType.FEATURE) 1100 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1101 1102 /** 1103 * Feature for {@link #getSystemAvailableFeatures} and 1104 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1105 * on a television. Television here is defined to be a typical living 1106 * room television experience: displayed on a big screen, where the user 1107 * is sitting far away from it, and the dominant form of input will be 1108 * something like a DPAD, not through touch or mouse. 1109 */ 1110 @SdkConstant(SdkConstantType.FEATURE) 1111 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1112 1113 /** 1114 * Action to external storage service to clean out removed apps. 1115 * @hide 1116 */ 1117 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1118 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1119 1120 /** 1121 * Extra field name for the URI to a verification file. Passed to a package 1122 * verifier. 1123 * 1124 * @hide 1125 */ 1126 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 1127 1128 /** 1129 * Extra field name for the ID of a package pending verification. Passed to 1130 * a package verifier and is used to call back to 1131 * {@link PackageManager#verifyPendingInstall(int, int)} 1132 */ 1133 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 1134 1135 /** 1136 * Extra field name for the package identifier which is trying to install 1137 * the package. 1138 * 1139 * @hide 1140 */ 1141 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 1142 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 1143 1144 /** 1145 * Extra field name for the requested install flags for a package pending 1146 * verification. Passed to a package verifier. 1147 * 1148 * @hide 1149 */ 1150 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 1151 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 1152 1153 /** 1154 * Extra field name for the result of a verification, either 1155 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 1156 * Passed to package verifiers after a package is verified. 1157 */ 1158 public static final String EXTRA_VERIFICATION_RESULT 1159 = "android.content.pm.extra.VERIFICATION_RESULT"; 1160 1161 /** 1162 * Retrieve overall information about an application package that is 1163 * installed on the system. 1164 * <p> 1165 * Throws {@link NameNotFoundException} if a package with the given name can 1166 * not be found on the system. 1167 * 1168 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1169 * desired package. 1170 * @param flags Additional option flags. Use any combination of 1171 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 1172 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 1173 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 1174 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 1175 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 1176 * modify the data returned. 1177 * @return Returns a PackageInfo object containing information about the 1178 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 1179 * package is not found in the list of installed applications, the 1180 * package information is retrieved from the list of uninstalled 1181 * applications(which includes installed applications as well as 1182 * applications with data directory ie applications which had been 1183 * deleted with DONT_DELTE_DATA flag set). 1184 * @see #GET_ACTIVITIES 1185 * @see #GET_GIDS 1186 * @see #GET_CONFIGURATIONS 1187 * @see #GET_INSTRUMENTATION 1188 * @see #GET_PERMISSIONS 1189 * @see #GET_PROVIDERS 1190 * @see #GET_RECEIVERS 1191 * @see #GET_SERVICES 1192 * @see #GET_SIGNATURES 1193 * @see #GET_UNINSTALLED_PACKAGES 1194 */ 1195 public abstract PackageInfo getPackageInfo(String packageName, int flags) 1196 throws NameNotFoundException; 1197 1198 /** 1199 * Map from the current package names in use on the device to whatever 1200 * the current canonical name of that package is. 1201 * @param names Array of current names to be mapped. 1202 * @return Returns an array of the same size as the original, containing 1203 * the canonical name for each package. 1204 */ 1205 public abstract String[] currentToCanonicalPackageNames(String[] names); 1206 1207 /** 1208 * Map from a packages canonical name to the current name in use on the device. 1209 * @param names Array of new names to be mapped. 1210 * @return Returns an array of the same size as the original, containing 1211 * the current name for each package. 1212 */ 1213 public abstract String[] canonicalToCurrentPackageNames(String[] names); 1214 1215 /** 1216 * Return a "good" intent to launch a front-door activity in a package, 1217 * for use for example to implement an "open" button when browsing through 1218 * packages. The current implementation will look first for a main 1219 * activity in the category {@link Intent#CATEGORY_INFO}, next for a 1220 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}, or return 1221 * null if neither are found. 1222 * 1223 * <p>Throws {@link NameNotFoundException} if a package with the given 1224 * name can not be found on the system. 1225 * 1226 * @param packageName The name of the package to inspect. 1227 * 1228 * @return Returns either a fully-qualified Intent that can be used to 1229 * launch the main activity in the package, or null if the package does 1230 * not contain such an activity. 1231 */ 1232 public abstract Intent getLaunchIntentForPackage(String packageName); 1233 1234 /** 1235 * Return an array of all of the secondary group-ids that have been 1236 * assigned to a package. 1237 * 1238 * <p>Throws {@link NameNotFoundException} if a package with the given 1239 * name can not be found on the system. 1240 * 1241 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1242 * desired package. 1243 * 1244 * @return Returns an int array of the assigned gids, or null if there 1245 * are none. 1246 */ 1247 public abstract int[] getPackageGids(String packageName) 1248 throws NameNotFoundException; 1249 1250 /** 1251 * Retrieve all of the information we know about a particular permission. 1252 * 1253 * <p>Throws {@link NameNotFoundException} if a permission with the given 1254 * name can not be found on the system. 1255 * 1256 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 1257 * of the permission you are interested in. 1258 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1259 * retrieve any meta-data associated with the permission. 1260 * 1261 * @return Returns a {@link PermissionInfo} containing information about the 1262 * permission. 1263 */ 1264 public abstract PermissionInfo getPermissionInfo(String name, int flags) 1265 throws NameNotFoundException; 1266 1267 /** 1268 * Query for all of the permissions associated with a particular group. 1269 * 1270 * <p>Throws {@link NameNotFoundException} if the given group does not 1271 * exist. 1272 * 1273 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 1274 * of the permission group you are interested in. Use null to 1275 * find all of the permissions not associated with a group. 1276 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1277 * retrieve any meta-data associated with the permissions. 1278 * 1279 * @return Returns a list of {@link PermissionInfo} containing information 1280 * about all of the permissions in the given group. 1281 */ 1282 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 1283 int flags) throws NameNotFoundException; 1284 1285 /** 1286 * Retrieve all of the information we know about a particular group of 1287 * permissions. 1288 * 1289 * <p>Throws {@link NameNotFoundException} if a permission group with the given 1290 * name can not be found on the system. 1291 * 1292 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 1293 * of the permission you are interested in. 1294 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1295 * retrieve any meta-data associated with the permission group. 1296 * 1297 * @return Returns a {@link PermissionGroupInfo} containing information 1298 * about the permission. 1299 */ 1300 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 1301 int flags) throws NameNotFoundException; 1302 1303 /** 1304 * Retrieve all of the known permission groups in the system. 1305 * 1306 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1307 * retrieve any meta-data associated with the permission group. 1308 * 1309 * @return Returns a list of {@link PermissionGroupInfo} containing 1310 * information about all of the known permission groups. 1311 */ 1312 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 1313 1314 /** 1315 * Retrieve all of the information we know about a particular 1316 * package/application. 1317 * 1318 * <p>Throws {@link NameNotFoundException} if an application with the given 1319 * package name can not be found on the system. 1320 * 1321 * @param packageName The full name (i.e. com.google.apps.contacts) of an 1322 * application. 1323 * @param flags Additional option flags. Use any combination of 1324 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1325 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1326 * 1327 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 1328 * information about the package. 1329 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 1330 * found in the list of installed applications, 1331 * the application information is retrieved from the 1332 * list of uninstalled applications(which includes 1333 * installed applications as well as applications 1334 * with data directory ie applications which had been 1335 * deleted with DONT_DELTE_DATA flag set). 1336 * 1337 * @see #GET_META_DATA 1338 * @see #GET_SHARED_LIBRARY_FILES 1339 * @see #GET_UNINSTALLED_PACKAGES 1340 */ 1341 public abstract ApplicationInfo getApplicationInfo(String packageName, 1342 int flags) throws NameNotFoundException; 1343 1344 /** 1345 * Retrieve all of the information we know about a particular activity 1346 * class. 1347 * 1348 * <p>Throws {@link NameNotFoundException} if an activity with the given 1349 * class name can not be found on the system. 1350 * 1351 * @param component The full component name (i.e. 1352 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 1353 * class. 1354 * @param flags Additional option flags. Use any combination of 1355 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1356 * to modify the data (in ApplicationInfo) returned. 1357 * 1358 * @return {@link ActivityInfo} containing information about the activity. 1359 * 1360 * @see #GET_INTENT_FILTERS 1361 * @see #GET_META_DATA 1362 * @see #GET_SHARED_LIBRARY_FILES 1363 */ 1364 public abstract ActivityInfo getActivityInfo(ComponentName component, 1365 int flags) throws NameNotFoundException; 1366 1367 /** 1368 * Retrieve all of the information we know about a particular receiver 1369 * class. 1370 * 1371 * <p>Throws {@link NameNotFoundException} if a receiver with the given 1372 * class name can not be found on the system. 1373 * 1374 * @param component The full component name (i.e. 1375 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 1376 * class. 1377 * @param flags Additional option flags. Use any combination of 1378 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1379 * to modify the data returned. 1380 * 1381 * @return {@link ActivityInfo} containing information about the receiver. 1382 * 1383 * @see #GET_INTENT_FILTERS 1384 * @see #GET_META_DATA 1385 * @see #GET_SHARED_LIBRARY_FILES 1386 */ 1387 public abstract ActivityInfo getReceiverInfo(ComponentName component, 1388 int flags) throws NameNotFoundException; 1389 1390 /** 1391 * Retrieve all of the information we know about a particular service 1392 * class. 1393 * 1394 * <p>Throws {@link NameNotFoundException} if a service with the given 1395 * class name can not be found on the system. 1396 * 1397 * @param component The full component name (i.e. 1398 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 1399 * class. 1400 * @param flags Additional option flags. Use any combination of 1401 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1402 * to modify the data returned. 1403 * 1404 * @return ServiceInfo containing information about the service. 1405 * 1406 * @see #GET_META_DATA 1407 * @see #GET_SHARED_LIBRARY_FILES 1408 */ 1409 public abstract ServiceInfo getServiceInfo(ComponentName component, 1410 int flags) throws NameNotFoundException; 1411 1412 /** 1413 * Retrieve all of the information we know about a particular content 1414 * provider class. 1415 * 1416 * <p>Throws {@link NameNotFoundException} if a provider with the given 1417 * class name can not be found on the system. 1418 * 1419 * @param component The full component name (i.e. 1420 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 1421 * ContentProvider class. 1422 * @param flags Additional option flags. Use any combination of 1423 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1424 * to modify the data returned. 1425 * 1426 * @return ProviderInfo containing information about the service. 1427 * 1428 * @see #GET_META_DATA 1429 * @see #GET_SHARED_LIBRARY_FILES 1430 */ 1431 public abstract ProviderInfo getProviderInfo(ComponentName component, 1432 int flags) throws NameNotFoundException; 1433 1434 /** 1435 * Return a List of all packages that are installed 1436 * on the device. 1437 * 1438 * @param flags Additional option flags. Use any combination of 1439 * {@link #GET_ACTIVITIES}, 1440 * {@link #GET_GIDS}, 1441 * {@link #GET_CONFIGURATIONS}, 1442 * {@link #GET_INSTRUMENTATION}, 1443 * {@link #GET_PERMISSIONS}, 1444 * {@link #GET_PROVIDERS}, 1445 * {@link #GET_RECEIVERS}, 1446 * {@link #GET_SERVICES}, 1447 * {@link #GET_SIGNATURES}, 1448 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1449 * 1450 * @return A List of PackageInfo objects, one for each package that is 1451 * installed on the device. In the unlikely case of there being no 1452 * installed packages, an empty list is returned. 1453 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1454 * applications including those deleted with DONT_DELETE_DATA 1455 * (partially installed apps with data directory) will be returned. 1456 * 1457 * @see #GET_ACTIVITIES 1458 * @see #GET_GIDS 1459 * @see #GET_CONFIGURATIONS 1460 * @see #GET_INSTRUMENTATION 1461 * @see #GET_PERMISSIONS 1462 * @see #GET_PROVIDERS 1463 * @see #GET_RECEIVERS 1464 * @see #GET_SERVICES 1465 * @see #GET_SIGNATURES 1466 * @see #GET_UNINSTALLED_PACKAGES 1467 * 1468 */ 1469 public abstract List<PackageInfo> getInstalledPackages(int flags); 1470 1471 /** 1472 * Return a List of all packages that are installed on the device, for a specific user. 1473 * Requesting a list of installed packages for another user 1474 * will require the permission INTERACT_ACROSS_USERS_FULL. 1475 * @param flags Additional option flags. Use any combination of 1476 * {@link #GET_ACTIVITIES}, 1477 * {@link #GET_GIDS}, 1478 * {@link #GET_CONFIGURATIONS}, 1479 * {@link #GET_INSTRUMENTATION}, 1480 * {@link #GET_PERMISSIONS}, 1481 * {@link #GET_PROVIDERS}, 1482 * {@link #GET_RECEIVERS}, 1483 * {@link #GET_SERVICES}, 1484 * {@link #GET_SIGNATURES}, 1485 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1486 * @param userId The user for whom the installed packages are to be listed 1487 * 1488 * @return A List of PackageInfo objects, one for each package that is 1489 * installed on the device. In the unlikely case of there being no 1490 * installed packages, an empty list is returned. 1491 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1492 * applications including those deleted with DONT_DELETE_DATA 1493 * (partially installed apps with data directory) will be returned. 1494 * 1495 * @see #GET_ACTIVITIES 1496 * @see #GET_GIDS 1497 * @see #GET_CONFIGURATIONS 1498 * @see #GET_INSTRUMENTATION 1499 * @see #GET_PERMISSIONS 1500 * @see #GET_PROVIDERS 1501 * @see #GET_RECEIVERS 1502 * @see #GET_SERVICES 1503 * @see #GET_SIGNATURES 1504 * @see #GET_UNINSTALLED_PACKAGES 1505 * 1506 * @hide 1507 */ 1508 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId); 1509 1510 /** 1511 * Check whether a particular package has been granted a particular 1512 * permission. 1513 * 1514 * @param permName The name of the permission you are checking for, 1515 * @param pkgName The name of the package you are checking against. 1516 * 1517 * @return If the package has the permission, PERMISSION_GRANTED is 1518 * returned. If it does not have the permission, PERMISSION_DENIED 1519 * is returned. 1520 * 1521 * @see #PERMISSION_GRANTED 1522 * @see #PERMISSION_DENIED 1523 */ 1524 public abstract int checkPermission(String permName, String pkgName); 1525 1526 /** 1527 * Add a new dynamic permission to the system. For this to work, your 1528 * package must have defined a permission tree through the 1529 * {@link android.R.styleable#AndroidManifestPermissionTree 1530 * <permission-tree>} tag in its manifest. A package can only add 1531 * permissions to trees that were defined by either its own package or 1532 * another with the same user id; a permission is in a tree if it 1533 * matches the name of the permission tree + ".": for example, 1534 * "com.foo.bar" is a member of the permission tree "com.foo". 1535 * 1536 * <p>It is good to make your permission tree name descriptive, because you 1537 * are taking possession of that entire set of permission names. Thus, it 1538 * must be under a domain you control, with a suffix that will not match 1539 * any normal permissions that may be declared in any applications that 1540 * are part of that domain. 1541 * 1542 * <p>New permissions must be added before 1543 * any .apks are installed that use those permissions. Permissions you 1544 * add through this method are remembered across reboots of the device. 1545 * If the given permission already exists, the info you supply here 1546 * will be used to update it. 1547 * 1548 * @param info Description of the permission to be added. 1549 * 1550 * @return Returns true if a new permission was created, false if an 1551 * existing one was updated. 1552 * 1553 * @throws SecurityException if you are not allowed to add the 1554 * given permission name. 1555 * 1556 * @see #removePermission(String) 1557 */ 1558 public abstract boolean addPermission(PermissionInfo info); 1559 1560 /** 1561 * Like {@link #addPermission(PermissionInfo)} but asynchronously 1562 * persists the package manager state after returning from the call, 1563 * allowing it to return quicker and batch a series of adds at the 1564 * expense of no guarantee the added permission will be retained if 1565 * the device is rebooted before it is written. 1566 */ 1567 public abstract boolean addPermissionAsync(PermissionInfo info); 1568 1569 /** 1570 * Removes a permission that was previously added with 1571 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 1572 * -- you are only allowed to remove permissions that you are allowed 1573 * to add. 1574 * 1575 * @param name The name of the permission to remove. 1576 * 1577 * @throws SecurityException if you are not allowed to remove the 1578 * given permission name. 1579 * 1580 * @see #addPermission(PermissionInfo) 1581 */ 1582 public abstract void removePermission(String name); 1583 1584 /** 1585 * Grant a permission to an application which the application does not 1586 * already have. The permission must have been requested by the application, 1587 * but as an optional permission. If the application is not allowed to 1588 * hold the permission, a SecurityException is thrown. 1589 * @hide 1590 * 1591 * @param packageName The name of the package that the permission will be 1592 * granted to. 1593 * @param permissionName The name of the permission. 1594 */ 1595 public abstract void grantPermission(String packageName, String permissionName); 1596 1597 /** 1598 * Revoke a permission that was previously granted by {@link #grantPermission}. 1599 * @hide 1600 * 1601 * @param packageName The name of the package that the permission will be 1602 * granted to. 1603 * @param permissionName The name of the permission. 1604 */ 1605 public abstract void revokePermission(String packageName, String permissionName); 1606 1607 /** 1608 * Compare the signatures of two packages to determine if the same 1609 * signature appears in both of them. If they do contain the same 1610 * signature, then they are allowed special privileges when working 1611 * with each other: they can share the same user-id, run instrumentation 1612 * against each other, etc. 1613 * 1614 * @param pkg1 First package name whose signature will be compared. 1615 * @param pkg2 Second package name whose signature will be compared. 1616 * 1617 * @return Returns an integer indicating whether all signatures on the 1618 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 1619 * all signatures match or < 0 if there is not a match ({@link 1620 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 1621 * 1622 * @see #checkSignatures(int, int) 1623 * @see #SIGNATURE_MATCH 1624 * @see #SIGNATURE_NO_MATCH 1625 * @see #SIGNATURE_UNKNOWN_PACKAGE 1626 */ 1627 public abstract int checkSignatures(String pkg1, String pkg2); 1628 1629 /** 1630 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 1631 * the two packages to be checked. This can be useful, for example, 1632 * when doing the check in an IPC, where the UID is the only identity 1633 * available. It is functionally identical to determining the package 1634 * associated with the UIDs and checking their signatures. 1635 * 1636 * @param uid1 First UID whose signature will be compared. 1637 * @param uid2 Second UID whose signature will be compared. 1638 * 1639 * @return Returns an integer indicating whether all signatures on the 1640 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 1641 * all signatures match or < 0 if there is not a match ({@link 1642 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 1643 * 1644 * @see #checkSignatures(String, String) 1645 * @see #SIGNATURE_MATCH 1646 * @see #SIGNATURE_NO_MATCH 1647 * @see #SIGNATURE_UNKNOWN_PACKAGE 1648 */ 1649 public abstract int checkSignatures(int uid1, int uid2); 1650 1651 /** 1652 * Retrieve the names of all packages that are associated with a particular 1653 * user id. In most cases, this will be a single package name, the package 1654 * that has been assigned that user id. Where there are multiple packages 1655 * sharing the same user id through the "sharedUserId" mechanism, all 1656 * packages with that id will be returned. 1657 * 1658 * @param uid The user id for which you would like to retrieve the 1659 * associated packages. 1660 * 1661 * @return Returns an array of one or more packages assigned to the user 1662 * id, or null if there are no known packages with the given id. 1663 */ 1664 public abstract String[] getPackagesForUid(int uid); 1665 1666 /** 1667 * Retrieve the official name associated with a user id. This name is 1668 * guaranteed to never change, though it is possibly for the underlying 1669 * user id to be changed. That is, if you are storing information about 1670 * user ids in persistent storage, you should use the string returned 1671 * by this function instead of the raw user-id. 1672 * 1673 * @param uid The user id for which you would like to retrieve a name. 1674 * @return Returns a unique name for the given user id, or null if the 1675 * user id is not currently assigned. 1676 */ 1677 public abstract String getNameForUid(int uid); 1678 1679 /** 1680 * Return the user id associated with a shared user name. Multiple 1681 * applications can specify a shared user name in their manifest and thus 1682 * end up using a common uid. This might be used for new applications 1683 * that use an existing shared user name and need to know the uid of the 1684 * shared user. 1685 * 1686 * @param sharedUserName The shared user name whose uid is to be retrieved. 1687 * @return Returns the uid associated with the shared user, or NameNotFoundException 1688 * if the shared user name is not being used by any installed packages 1689 * @hide 1690 */ 1691 public abstract int getUidForSharedUser(String sharedUserName) 1692 throws NameNotFoundException; 1693 1694 /** 1695 * Return a List of all application packages that are installed on the 1696 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 1697 * applications including those deleted with DONT_DELETE_DATA(partially 1698 * installed apps with data directory) will be returned. 1699 * 1700 * @param flags Additional option flags. Use any combination of 1701 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1702 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1703 * 1704 * @return A List of ApplicationInfo objects, one for each application that 1705 * is installed on the device. In the unlikely case of there being 1706 * no installed applications, an empty list is returned. 1707 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1708 * applications including those deleted with DONT_DELETE_DATA 1709 * (partially installed apps with data directory) will be returned. 1710 * 1711 * @see #GET_META_DATA 1712 * @see #GET_SHARED_LIBRARY_FILES 1713 * @see #GET_UNINSTALLED_PACKAGES 1714 */ 1715 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 1716 1717 /** 1718 * Get a list of shared libraries that are available on the 1719 * system. 1720 * 1721 * @return An array of shared library names that are 1722 * available on the system, or null if none are installed. 1723 * 1724 */ 1725 public abstract String[] getSystemSharedLibraryNames(); 1726 1727 /** 1728 * Get a list of features that are available on the 1729 * system. 1730 * 1731 * @return An array of FeatureInfo classes describing the features 1732 * that are available on the system, or null if there are none(!!). 1733 */ 1734 public abstract FeatureInfo[] getSystemAvailableFeatures(); 1735 1736 /** 1737 * Check whether the given feature name is one of the available 1738 * features as returned by {@link #getSystemAvailableFeatures()}. 1739 * 1740 * @return Returns true if the devices supports the feature, else 1741 * false. 1742 */ 1743 public abstract boolean hasSystemFeature(String name); 1744 1745 /** 1746 * Determine the best action to perform for a given Intent. This is how 1747 * {@link Intent#resolveActivity} finds an activity if a class has not 1748 * been explicitly specified. 1749 * 1750 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 1751 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 1752 * only flag. You need to do so to resolve the activity in the same way 1753 * that {@link android.content.Context#startActivity(Intent)} and 1754 * {@link android.content.Intent#resolveActivity(PackageManager) 1755 * Intent.resolveActivity(PackageManager)} do.</p> 1756 * 1757 * @param intent An intent containing all of the desired specification 1758 * (action, data, type, category, and/or component). 1759 * @param flags Additional option flags. The most important is 1760 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1761 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1762 * 1763 * @return Returns a ResolveInfo containing the final activity intent that 1764 * was determined to be the best action. Returns null if no 1765 * matching activity was found. If multiple matching activities are 1766 * found and there is no default set, returns a ResolveInfo 1767 * containing something else, such as the activity resolver. 1768 * 1769 * @see #MATCH_DEFAULT_ONLY 1770 * @see #GET_INTENT_FILTERS 1771 * @see #GET_RESOLVED_FILTER 1772 */ 1773 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 1774 1775 /** 1776 * Retrieve all activities that can be performed for the given intent. 1777 * 1778 * @param intent The desired intent as per resolveActivity(). 1779 * @param flags Additional option flags. The most important is 1780 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1781 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1782 * 1783 * @return A List<ResolveInfo> containing one entry for each matching 1784 * Activity. These are ordered from best to worst match -- that 1785 * is, the first item in the list is what is returned by 1786 * {@link #resolveActivity}. If there are no matching activities, an empty 1787 * list is returned. 1788 * 1789 * @see #MATCH_DEFAULT_ONLY 1790 * @see #GET_INTENT_FILTERS 1791 * @see #GET_RESOLVED_FILTER 1792 */ 1793 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 1794 int flags); 1795 1796 /** 1797 * Retrieve all activities that can be performed for the given intent, for a specific user. 1798 * 1799 * @param intent The desired intent as per resolveActivity(). 1800 * @param flags Additional option flags. The most important is 1801 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1802 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1803 * 1804 * @return A List<ResolveInfo> containing one entry for each matching 1805 * Activity. These are ordered from best to worst match -- that 1806 * is, the first item in the list is what is returned by 1807 * {@link #resolveActivity}. If there are no matching activities, an empty 1808 * list is returned. 1809 * 1810 * @see #MATCH_DEFAULT_ONLY 1811 * @see #GET_INTENT_FILTERS 1812 * @see #GET_RESOLVED_FILTER 1813 * @hide 1814 */ 1815 public abstract List<ResolveInfo> queryIntentActivitiesForUser(Intent intent, 1816 int flags, int userId); 1817 1818 1819 /** 1820 * Retrieve a set of activities that should be presented to the user as 1821 * similar options. This is like {@link #queryIntentActivities}, except it 1822 * also allows you to supply a list of more explicit Intents that you would 1823 * like to resolve to particular options, and takes care of returning the 1824 * final ResolveInfo list in a reasonable order, with no duplicates, based 1825 * on those inputs. 1826 * 1827 * @param caller The class name of the activity that is making the 1828 * request. This activity will never appear in the output 1829 * list. Can be null. 1830 * @param specifics An array of Intents that should be resolved to the 1831 * first specific results. Can be null. 1832 * @param intent The desired intent as per resolveActivity(). 1833 * @param flags Additional option flags. The most important is 1834 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 1835 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 1836 * 1837 * @return A List<ResolveInfo> containing one entry for each matching 1838 * Activity. These are ordered first by all of the intents resolved 1839 * in <var>specifics</var> and then any additional activities that 1840 * can handle <var>intent</var> but did not get included by one of 1841 * the <var>specifics</var> intents. If there are no matching 1842 * activities, an empty list is returned. 1843 * 1844 * @see #MATCH_DEFAULT_ONLY 1845 * @see #GET_INTENT_FILTERS 1846 * @see #GET_RESOLVED_FILTER 1847 */ 1848 public abstract List<ResolveInfo> queryIntentActivityOptions( 1849 ComponentName caller, Intent[] specifics, Intent intent, int flags); 1850 1851 /** 1852 * Retrieve all receivers that can handle a broadcast of the given intent. 1853 * 1854 * @param intent The desired intent as per resolveActivity(). 1855 * @param flags Additional option flags. 1856 * 1857 * @return A List<ResolveInfo> containing one entry for each matching 1858 * Receiver. These are ordered from first to last in priority. If 1859 * there are no matching receivers, an empty list is returned. 1860 * 1861 * @see #MATCH_DEFAULT_ONLY 1862 * @see #GET_INTENT_FILTERS 1863 * @see #GET_RESOLVED_FILTER 1864 */ 1865 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 1866 int flags); 1867 1868 /** 1869 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 1870 * user. 1871 * 1872 * @param intent The desired intent as per resolveActivity(). 1873 * @param flags Additional option flags. 1874 * @param userId The userId of the user being queried. 1875 * 1876 * @return A List<ResolveInfo> containing one entry for each matching 1877 * Receiver. These are ordered from first to last in priority. If 1878 * there are no matching receivers, an empty list is returned. 1879 * 1880 * @see #MATCH_DEFAULT_ONLY 1881 * @see #GET_INTENT_FILTERS 1882 * @see #GET_RESOLVED_FILTER 1883 * @hide 1884 */ 1885 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 1886 int flags, int userId); 1887 1888 /** 1889 * Determine the best service to handle for a given Intent. 1890 * 1891 * @param intent An intent containing all of the desired specification 1892 * (action, data, type, category, and/or component). 1893 * @param flags Additional option flags. 1894 * 1895 * @return Returns a ResolveInfo containing the final service intent that 1896 * was determined to be the best action. Returns null if no 1897 * matching service was found. 1898 * 1899 * @see #GET_INTENT_FILTERS 1900 * @see #GET_RESOLVED_FILTER 1901 */ 1902 public abstract ResolveInfo resolveService(Intent intent, int flags); 1903 1904 /** 1905 * Retrieve all services that can match the given intent. 1906 * 1907 * @param intent The desired intent as per resolveService(). 1908 * @param flags Additional option flags. 1909 * 1910 * @return A List<ResolveInfo> containing one entry for each matching 1911 * ServiceInfo. These are ordered from best to worst match -- that 1912 * is, the first item in the list is what is returned by 1913 * resolveService(). If there are no matching services, an empty 1914 * list is returned. 1915 * 1916 * @see #GET_INTENT_FILTERS 1917 * @see #GET_RESOLVED_FILTER 1918 */ 1919 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 1920 int flags); 1921 1922 /** 1923 * Find a single content provider by its base path name. 1924 * 1925 * @param name The name of the provider to find. 1926 * @param flags Additional option flags. Currently should always be 0. 1927 * 1928 * @return ContentProviderInfo Information about the provider, if found, 1929 * else null. 1930 */ 1931 public abstract ProviderInfo resolveContentProvider(String name, 1932 int flags); 1933 1934 /** 1935 * Retrieve content provider information. 1936 * 1937 * <p><em>Note: unlike most other methods, an empty result set is indicated 1938 * by a null return instead of an empty list.</em> 1939 * 1940 * @param processName If non-null, limits the returned providers to only 1941 * those that are hosted by the given process. If null, 1942 * all content providers are returned. 1943 * @param uid If <var>processName</var> is non-null, this is the required 1944 * uid owning the requested content providers. 1945 * @param flags Additional option flags. Currently should always be 0. 1946 * 1947 * @return A List<ContentProviderInfo> containing one entry for each 1948 * content provider either patching <var>processName</var> or, if 1949 * <var>processName</var> is null, all known content providers. 1950 * <em>If there are no matching providers, null is returned.</em> 1951 */ 1952 public abstract List<ProviderInfo> queryContentProviders( 1953 String processName, int uid, int flags); 1954 1955 /** 1956 * Retrieve all of the information we know about a particular 1957 * instrumentation class. 1958 * 1959 * <p>Throws {@link NameNotFoundException} if instrumentation with the 1960 * given class name can not be found on the system. 1961 * 1962 * @param className The full name (i.e. 1963 * com.google.apps.contacts.InstrumentList) of an 1964 * Instrumentation class. 1965 * @param flags Additional option flags. Currently should always be 0. 1966 * 1967 * @return InstrumentationInfo containing information about the 1968 * instrumentation. 1969 */ 1970 public abstract InstrumentationInfo getInstrumentationInfo( 1971 ComponentName className, int flags) throws NameNotFoundException; 1972 1973 /** 1974 * Retrieve information about available instrumentation code. May be used 1975 * to retrieve either all instrumentation code, or only the code targeting 1976 * a particular package. 1977 * 1978 * @param targetPackage If null, all instrumentation is returned; only the 1979 * instrumentation targeting this package name is 1980 * returned. 1981 * @param flags Additional option flags. Currently should always be 0. 1982 * 1983 * @return A List<InstrumentationInfo> containing one entry for each 1984 * matching available Instrumentation. Returns an empty list if 1985 * there is no instrumentation available for the given package. 1986 */ 1987 public abstract List<InstrumentationInfo> queryInstrumentation( 1988 String targetPackage, int flags); 1989 1990 /** 1991 * Retrieve an image from a package. This is a low-level API used by 1992 * the various package manager info structures (such as 1993 * {@link ComponentInfo} to implement retrieval of their associated 1994 * icon. 1995 * 1996 * @param packageName The name of the package that this icon is coming from. 1997 * Can not be null. 1998 * @param resid The resource identifier of the desired image. Can not be 0. 1999 * @param appInfo Overall information about <var>packageName</var>. This 2000 * may be null, in which case the application information will be retrieved 2001 * for you if needed; if you already have this information around, it can 2002 * be much more efficient to supply it here. 2003 * 2004 * @return Returns a Drawable holding the requested image. Returns null if 2005 * an image could not be found for any reason. 2006 */ 2007 public abstract Drawable getDrawable(String packageName, int resid, 2008 ApplicationInfo appInfo); 2009 2010 /** 2011 * Retrieve the icon associated with an activity. Given the full name of 2012 * an activity, retrieves the information about it and calls 2013 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 2014 * If the activity can not be found, NameNotFoundException is thrown. 2015 * 2016 * @param activityName Name of the activity whose icon is to be retrieved. 2017 * 2018 * @return Returns the image of the icon, or the default activity icon if 2019 * it could not be found. Does not return null. 2020 * @throws NameNotFoundException Thrown if the resources for the given 2021 * activity could not be loaded. 2022 * 2023 * @see #getActivityIcon(Intent) 2024 */ 2025 public abstract Drawable getActivityIcon(ComponentName activityName) 2026 throws NameNotFoundException; 2027 2028 /** 2029 * Retrieve the icon associated with an Intent. If intent.getClassName() is 2030 * set, this simply returns the result of 2031 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 2032 * component and returns the icon associated with the resolved component. 2033 * If intent.getClassName() can not be found or the Intent can not be resolved 2034 * to a component, NameNotFoundException is thrown. 2035 * 2036 * @param intent The intent for which you would like to retrieve an icon. 2037 * 2038 * @return Returns the image of the icon, or the default activity icon if 2039 * it could not be found. Does not return null. 2040 * @throws NameNotFoundException Thrown if the resources for application 2041 * matching the given intent could not be loaded. 2042 * 2043 * @see #getActivityIcon(ComponentName) 2044 */ 2045 public abstract Drawable getActivityIcon(Intent intent) 2046 throws NameNotFoundException; 2047 2048 /** 2049 * Return the generic icon for an activity that is used when no specific 2050 * icon is defined. 2051 * 2052 * @return Drawable Image of the icon. 2053 */ 2054 public abstract Drawable getDefaultActivityIcon(); 2055 2056 /** 2057 * Retrieve the icon associated with an application. If it has not defined 2058 * an icon, the default app icon is returned. Does not return null. 2059 * 2060 * @param info Information about application being queried. 2061 * 2062 * @return Returns the image of the icon, or the default application icon 2063 * if it could not be found. 2064 * 2065 * @see #getApplicationIcon(String) 2066 */ 2067 public abstract Drawable getApplicationIcon(ApplicationInfo info); 2068 2069 /** 2070 * Retrieve the icon associated with an application. Given the name of the 2071 * application's package, retrieves the information about it and calls 2072 * getApplicationIcon() to return its icon. If the application can not be 2073 * found, NameNotFoundException is thrown. 2074 * 2075 * @param packageName Name of the package whose application icon is to be 2076 * retrieved. 2077 * 2078 * @return Returns the image of the icon, or the default application icon 2079 * if it could not be found. Does not return null. 2080 * @throws NameNotFoundException Thrown if the resources for the given 2081 * application could not be loaded. 2082 * 2083 * @see #getApplicationIcon(ApplicationInfo) 2084 */ 2085 public abstract Drawable getApplicationIcon(String packageName) 2086 throws NameNotFoundException; 2087 2088 /** 2089 * Retrieve the logo associated with an activity. Given the full name of 2090 * an activity, retrieves the information about it and calls 2091 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its logo. 2092 * If the activity can not be found, NameNotFoundException is thrown. 2093 * 2094 * @param activityName Name of the activity whose logo is to be retrieved. 2095 * 2096 * @return Returns the image of the logo or null if the activity has no 2097 * logo specified. 2098 * 2099 * @throws NameNotFoundException Thrown if the resources for the given 2100 * activity could not be loaded. 2101 * 2102 * @see #getActivityLogo(Intent) 2103 */ 2104 public abstract Drawable getActivityLogo(ComponentName activityName) 2105 throws NameNotFoundException; 2106 2107 /** 2108 * Retrieve the logo associated with an Intent. If intent.getClassName() is 2109 * set, this simply returns the result of 2110 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 2111 * component and returns the logo associated with the resolved component. 2112 * If intent.getClassName() can not be found or the Intent can not be resolved 2113 * to a component, NameNotFoundException is thrown. 2114 * 2115 * @param intent The intent for which you would like to retrieve a logo. 2116 * 2117 * @return Returns the image of the logo, or null if the activity has no 2118 * logo specified. 2119 * 2120 * @throws NameNotFoundException Thrown if the resources for application 2121 * matching the given intent could not be loaded. 2122 * 2123 * @see #getActivityLogo(ComponentName) 2124 */ 2125 public abstract Drawable getActivityLogo(Intent intent) 2126 throws NameNotFoundException; 2127 2128 /** 2129 * Retrieve the logo associated with an application. If it has not specified 2130 * a logo, this method returns null. 2131 * 2132 * @param info Information about application being queried. 2133 * 2134 * @return Returns the image of the logo, or null if no logo is specified 2135 * by the application. 2136 * 2137 * @see #getApplicationLogo(String) 2138 */ 2139 public abstract Drawable getApplicationLogo(ApplicationInfo info); 2140 2141 /** 2142 * Retrieve the logo associated with an application. Given the name of the 2143 * application's package, retrieves the information about it and calls 2144 * getApplicationLogo() to return its logo. If the application can not be 2145 * found, NameNotFoundException is thrown. 2146 * 2147 * @param packageName Name of the package whose application logo is to be 2148 * retrieved. 2149 * 2150 * @return Returns the image of the logo, or null if no application logo 2151 * has been specified. 2152 * 2153 * @throws NameNotFoundException Thrown if the resources for the given 2154 * application could not be loaded. 2155 * 2156 * @see #getApplicationLogo(ApplicationInfo) 2157 */ 2158 public abstract Drawable getApplicationLogo(String packageName) 2159 throws NameNotFoundException; 2160 2161 /** 2162 * Retrieve text from a package. This is a low-level API used by 2163 * the various package manager info structures (such as 2164 * {@link ComponentInfo} to implement retrieval of their associated 2165 * labels and other text. 2166 * 2167 * @param packageName The name of the package that this text is coming from. 2168 * Can not be null. 2169 * @param resid The resource identifier of the desired text. Can not be 0. 2170 * @param appInfo Overall information about <var>packageName</var>. This 2171 * may be null, in which case the application information will be retrieved 2172 * for you if needed; if you already have this information around, it can 2173 * be much more efficient to supply it here. 2174 * 2175 * @return Returns a CharSequence holding the requested text. Returns null 2176 * if the text could not be found for any reason. 2177 */ 2178 public abstract CharSequence getText(String packageName, int resid, 2179 ApplicationInfo appInfo); 2180 2181 /** 2182 * Retrieve an XML file from a package. This is a low-level API used to 2183 * retrieve XML meta data. 2184 * 2185 * @param packageName The name of the package that this xml is coming from. 2186 * Can not be null. 2187 * @param resid The resource identifier of the desired xml. Can not be 0. 2188 * @param appInfo Overall information about <var>packageName</var>. This 2189 * may be null, in which case the application information will be retrieved 2190 * for you if needed; if you already have this information around, it can 2191 * be much more efficient to supply it here. 2192 * 2193 * @return Returns an XmlPullParser allowing you to parse out the XML 2194 * data. Returns null if the xml resource could not be found for any 2195 * reason. 2196 */ 2197 public abstract XmlResourceParser getXml(String packageName, int resid, 2198 ApplicationInfo appInfo); 2199 2200 /** 2201 * Return the label to use for this application. 2202 * 2203 * @return Returns the label associated with this application, or null if 2204 * it could not be found for any reason. 2205 * @param info The application to get the label of 2206 */ 2207 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 2208 2209 /** 2210 * Retrieve the resources associated with an activity. Given the full 2211 * name of an activity, retrieves the information about it and calls 2212 * getResources() to return its application's resources. If the activity 2213 * can not be found, NameNotFoundException is thrown. 2214 * 2215 * @param activityName Name of the activity whose resources are to be 2216 * retrieved. 2217 * 2218 * @return Returns the application's Resources. 2219 * @throws NameNotFoundException Thrown if the resources for the given 2220 * application could not be loaded. 2221 * 2222 * @see #getResourcesForApplication(ApplicationInfo) 2223 */ 2224 public abstract Resources getResourcesForActivity(ComponentName activityName) 2225 throws NameNotFoundException; 2226 2227 /** 2228 * Retrieve the resources for an application. Throws NameNotFoundException 2229 * if the package is no longer installed. 2230 * 2231 * @param app Information about the desired application. 2232 * 2233 * @return Returns the application's Resources. 2234 * @throws NameNotFoundException Thrown if the resources for the given 2235 * application could not be loaded (most likely because it was uninstalled). 2236 */ 2237 public abstract Resources getResourcesForApplication(ApplicationInfo app) 2238 throws NameNotFoundException; 2239 2240 /** 2241 * Retrieve the resources associated with an application. Given the full 2242 * package name of an application, retrieves the information about it and 2243 * calls getResources() to return its application's resources. If the 2244 * appPackageName can not be found, NameNotFoundException is thrown. 2245 * 2246 * @param appPackageName Package name of the application whose resources 2247 * are to be retrieved. 2248 * 2249 * @return Returns the application's Resources. 2250 * @throws NameNotFoundException Thrown if the resources for the given 2251 * application could not be loaded. 2252 * 2253 * @see #getResourcesForApplication(ApplicationInfo) 2254 */ 2255 public abstract Resources getResourcesForApplication(String appPackageName) 2256 throws NameNotFoundException; 2257 2258 /** 2259 * Retrieve overall information about an application package defined 2260 * in a package archive file 2261 * 2262 * @param archiveFilePath The path to the archive file 2263 * @param flags Additional option flags. Use any combination of 2264 * {@link #GET_ACTIVITIES}, 2265 * {@link #GET_GIDS}, 2266 * {@link #GET_CONFIGURATIONS}, 2267 * {@link #GET_INSTRUMENTATION}, 2268 * {@link #GET_PERMISSIONS}, 2269 * {@link #GET_PROVIDERS}, 2270 * {@link #GET_RECEIVERS}, 2271 * {@link #GET_SERVICES}, 2272 * {@link #GET_SIGNATURES}, to modify the data returned. 2273 * 2274 * @return Returns the information about the package. Returns 2275 * null if the package could not be successfully parsed. 2276 * 2277 * @see #GET_ACTIVITIES 2278 * @see #GET_GIDS 2279 * @see #GET_CONFIGURATIONS 2280 * @see #GET_INSTRUMENTATION 2281 * @see #GET_PERMISSIONS 2282 * @see #GET_PROVIDERS 2283 * @see #GET_RECEIVERS 2284 * @see #GET_SERVICES 2285 * @see #GET_SIGNATURES 2286 * 2287 */ 2288 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 2289 PackageParser packageParser = new PackageParser(archiveFilePath); 2290 DisplayMetrics metrics = new DisplayMetrics(); 2291 metrics.setToDefaults(); 2292 final File sourceFile = new File(archiveFilePath); 2293 PackageParser.Package pkg = packageParser.parsePackage( 2294 sourceFile, archiveFilePath, metrics, 0); 2295 if (pkg == null) { 2296 return null; 2297 } 2298 if ((flags & GET_SIGNATURES) != 0) { 2299 packageParser.collectCertificates(pkg, 0); 2300 } 2301 PackageUserState state = new PackageUserState(); 2302 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 2303 } 2304 2305 /** 2306 * @hide 2307 * 2308 * Install a package. Since this may take a little while, the result will 2309 * be posted back to the given observer. An installation will fail if the calling context 2310 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 2311 * package named in the package file's manifest is already installed, or if there's no space 2312 * available on the device. 2313 * 2314 * @param packageURI The location of the package file to install. This can be a 'file:' or a 2315 * 'content:' URI. 2316 * @param observer An observer callback to get notified when the package installation is 2317 * complete. {@link IPackageInstallObserver#packageInstalled(String, int)} will be 2318 * called when that happens. observer may be null to indicate that no callback is desired. 2319 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 2320 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 2321 * @param installerPackageName Optional package name of the application that is performing the 2322 * installation. This identifies which market the package came from. 2323 */ 2324 public abstract void installPackage( 2325 Uri packageURI, IPackageInstallObserver observer, int flags, 2326 String installerPackageName); 2327 2328 /** 2329 * Similar to 2330 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 2331 * with an extra verification file provided. 2332 * 2333 * @param packageURI The location of the package file to install. This can 2334 * be a 'file:' or a 'content:' URI. 2335 * @param observer An observer callback to get notified when the package 2336 * installation is complete. 2337 * {@link IPackageInstallObserver#packageInstalled(String, int)} 2338 * will be called when that happens. observer may be null to 2339 * indicate that no callback is desired. 2340 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 2341 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST} 2342 * . 2343 * @param installerPackageName Optional package name of the application that 2344 * is performing the installation. This identifies which market 2345 * the package came from. 2346 * @param verificationURI The location of the supplementary verification 2347 * file. This can be a 'file:' or a 'content:' URI. May be 2348 * {@code null}. 2349 * @param manifestDigest an object that holds the digest of the package 2350 * which can be used to verify ownership. May be {@code null}. 2351 * @param encryptionParams if the package to be installed is encrypted, 2352 * these parameters describing the encryption and authentication 2353 * used. May be {@code null}. 2354 * @hide 2355 */ 2356 public abstract void installPackageWithVerification(Uri packageURI, 2357 IPackageInstallObserver observer, int flags, String installerPackageName, 2358 Uri verificationURI, ManifestDigest manifestDigest, 2359 ContainerEncryptionParams encryptionParams); 2360 2361 /** 2362 * Similar to 2363 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 2364 * with an extra verification information provided. 2365 * 2366 * @param packageURI The location of the package file to install. This can 2367 * be a 'file:' or a 'content:' URI. 2368 * @param observer An observer callback to get notified when the package 2369 * installation is complete. 2370 * {@link IPackageInstallObserver#packageInstalled(String, int)} 2371 * will be called when that happens. observer may be null to 2372 * indicate that no callback is desired. 2373 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 2374 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST} 2375 * . 2376 * @param installerPackageName Optional package name of the application that 2377 * is performing the installation. This identifies which market 2378 * the package came from. 2379 * @param verificationParams an object that holds signal information to 2380 * assist verification. May be {@code null}. 2381 * @param encryptionParams if the package to be installed is encrypted, 2382 * these parameters describing the encryption and authentication 2383 * used. May be {@code null}. 2384 * 2385 * @hide 2386 */ 2387 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 2388 IPackageInstallObserver observer, int flags, String installerPackageName, 2389 VerificationParams verificationParams, 2390 ContainerEncryptionParams encryptionParams); 2391 2392 /** 2393 * If there is already an application with the given package name installed 2394 * on the system for other users, also install it for the calling user. 2395 * @hide 2396 */ 2397 public abstract int installExistingPackage(String packageName) 2398 throws NameNotFoundException; 2399 2400 /** 2401 * Allows a package listening to the 2402 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 2403 * broadcast} to respond to the package manager. The response must include 2404 * the {@code verificationCode} which is one of 2405 * {@link PackageManager#VERIFICATION_ALLOW} or 2406 * {@link PackageManager#VERIFICATION_REJECT}. 2407 * 2408 * @param id pending package identifier as passed via the 2409 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra 2410 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 2411 * or {@link PackageManager#VERIFICATION_REJECT}. 2412 * @throws SecurityException if the caller does not have the 2413 * {@link android.Manifest.permission#PACKAGE_VERIFICATION_AGENT} 2414 * permission. 2415 */ 2416 public abstract void verifyPendingInstall(int id, int verificationCode); 2417 2418 /** 2419 * Allows a package listening to the 2420 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 2421 * broadcast} to extend the default timeout for a response and declare what 2422 * action to perform after the timeout occurs. The response must include 2423 * the {@code verificationCodeAtTimeout} which is one of 2424 * {@link PackageManager#VERIFICATION_ALLOW} or 2425 * {@link PackageManager#VERIFICATION_REJECT}. 2426 * 2427 * This method may only be called once per package id. Additional calls 2428 * will have no effect. 2429 * 2430 * @param id pending package identifier as passed via the 2431 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra 2432 * @param verificationCodeAtTimeout either 2433 * {@link PackageManager#VERIFICATION_ALLOW} or 2434 * {@link PackageManager#VERIFICATION_REJECT}. If 2435 * {@code verificationCodeAtTimeout} is neither 2436 * {@link PackageManager#VERIFICATION_ALLOW} or 2437 * {@link PackageManager#VERIFICATION_REJECT}, then 2438 * {@code verificationCodeAtTimeout} will default to 2439 * {@link PackageManager#VERIFICATION_REJECT}. 2440 * @param millisecondsToDelay the amount of time requested for the timeout. 2441 * Must be positive and less than 2442 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 2443 * {@code millisecondsToDelay} is out of bounds, 2444 * {@code millisecondsToDelay} will be set to the closest in 2445 * bounds value; namely, 0 or 2446 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 2447 * @throws SecurityException if the caller does not have the 2448 * {@link android.Manifest.permission#PACKAGE_VERIFICATION_AGENT} 2449 * permission. 2450 */ 2451 public abstract void extendVerificationTimeout(int id, 2452 int verificationCodeAtTimeout, long millisecondsToDelay); 2453 2454 /** 2455 * Change the installer associated with a given package. There are limitations 2456 * on how the installer package can be changed; in particular: 2457 * <ul> 2458 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 2459 * is not signed with the same certificate as the calling application. 2460 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 2461 * has an installer package, and that installer package is not signed with 2462 * the same certificate as the calling application. 2463 * </ul> 2464 * 2465 * @param targetPackage The installed package whose installer will be changed. 2466 * @param installerPackageName The package name of the new installer. May be 2467 * null to clear the association. 2468 */ 2469 public abstract void setInstallerPackageName(String targetPackage, 2470 String installerPackageName); 2471 2472 /** 2473 * Attempts to delete a package. Since this may take a little while, the result will 2474 * be posted back to the given observer. A deletion will fail if the calling context 2475 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 2476 * named package cannot be found, or if the named package is a "system package". 2477 * (TODO: include pointer to documentation on "system packages") 2478 * 2479 * @param packageName The name of the package to delete 2480 * @param observer An observer callback to get notified when the package deletion is 2481 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 2482 * called when that happens. observer may be null to indicate that no callback is desired. 2483 * @param flags - possible values: {@link #DELETE_KEEP_DATA}, 2484 * {@link #DELETE_ALL_USERS}. 2485 * 2486 * @hide 2487 */ 2488 public abstract void deletePackage( 2489 String packageName, IPackageDeleteObserver observer, int flags); 2490 2491 /** 2492 * Retrieve the package name of the application that installed a package. This identifies 2493 * which market the package came from. 2494 * 2495 * @param packageName The name of the package to query 2496 */ 2497 public abstract String getInstallerPackageName(String packageName); 2498 2499 /** 2500 * Attempts to clear the user data directory of an application. 2501 * Since this may take a little while, the result will 2502 * be posted back to the given observer. A deletion will fail if the 2503 * named package cannot be found, or if the named package is a "system package". 2504 * 2505 * @param packageName The name of the package 2506 * @param observer An observer callback to get notified when the operation is finished 2507 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 2508 * will be called when that happens. observer may be null to indicate that 2509 * no callback is desired. 2510 * 2511 * @hide 2512 */ 2513 public abstract void clearApplicationUserData(String packageName, 2514 IPackageDataObserver observer); 2515 /** 2516 * Attempts to delete the cache files associated with an application. 2517 * Since this may take a little while, the result will 2518 * be posted back to the given observer. A deletion will fail if the calling context 2519 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 2520 * named package cannot be found, or if the named package is a "system package". 2521 * 2522 * @param packageName The name of the package to delete 2523 * @param observer An observer callback to get notified when the cache file deletion 2524 * is complete. 2525 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 2526 * will be called when that happens. observer may be null to indicate that 2527 * no callback is desired. 2528 * 2529 * @hide 2530 */ 2531 public abstract void deleteApplicationCacheFiles(String packageName, 2532 IPackageDataObserver observer); 2533 2534 /** 2535 * Free storage by deleting LRU sorted list of cache files across 2536 * all applications. If the currently available free storage 2537 * on the device is greater than or equal to the requested 2538 * free storage, no cache files are cleared. If the currently 2539 * available storage on the device is less than the requested 2540 * free storage, some or all of the cache files across 2541 * all applications are deleted (based on last accessed time) 2542 * to increase the free storage space on the device to 2543 * the requested value. There is no guarantee that clearing all 2544 * the cache files from all applications will clear up 2545 * enough storage to achieve the desired value. 2546 * @param freeStorageSize The number of bytes of storage to be 2547 * freed by the system. Say if freeStorageSize is XX, 2548 * and the current free storage is YY, 2549 * if XX is less than YY, just return. if not free XX-YY number 2550 * of bytes if possible. 2551 * @param observer call back used to notify when 2552 * the operation is completed 2553 * 2554 * @hide 2555 */ 2556 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); 2557 2558 /** 2559 * Free storage by deleting LRU sorted list of cache files across 2560 * all applications. If the currently available free storage 2561 * on the device is greater than or equal to the requested 2562 * free storage, no cache files are cleared. If the currently 2563 * available storage on the device is less than the requested 2564 * free storage, some or all of the cache files across 2565 * all applications are deleted (based on last accessed time) 2566 * to increase the free storage space on the device to 2567 * the requested value. There is no guarantee that clearing all 2568 * the cache files from all applications will clear up 2569 * enough storage to achieve the desired value. 2570 * @param freeStorageSize The number of bytes of storage to be 2571 * freed by the system. Say if freeStorageSize is XX, 2572 * and the current free storage is YY, 2573 * if XX is less than YY, just return. if not free XX-YY number 2574 * of bytes if possible. 2575 * @param pi IntentSender call back used to 2576 * notify when the operation is completed.May be null 2577 * to indicate that no call back is desired. 2578 * 2579 * @hide 2580 */ 2581 public abstract void freeStorage(long freeStorageSize, IntentSender pi); 2582 2583 /** 2584 * Retrieve the size information for a package. 2585 * Since this may take a little while, the result will 2586 * be posted back to the given observer. The calling context 2587 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 2588 * 2589 * @param packageName The name of the package whose size information is to be retrieved 2590 * @param userHandle The user whose size information should be retrieved. 2591 * @param observer An observer callback to get notified when the operation 2592 * is complete. 2593 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 2594 * The observer's callback is invoked with a PackageStats object(containing the 2595 * code, data and cache sizes of the package) and a boolean value representing 2596 * the status of the operation. observer may be null to indicate that 2597 * no callback is desired. 2598 * 2599 * @hide 2600 */ 2601 public abstract void getPackageSizeInfo(String packageName, int userHandle, 2602 IPackageStatsObserver observer); 2603 2604 /** 2605 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but 2606 * returns the size for the calling user. 2607 * 2608 * @hide 2609 */ 2610 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 2611 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer); 2612 } 2613 2614 /** 2615 * @deprecated This function no longer does anything; it was an old 2616 * approach to managing preferred activities, which has been superceeded 2617 * (and conflicts with) the modern activity-based preferences. 2618 */ 2619 @Deprecated 2620 public abstract void addPackageToPreferred(String packageName); 2621 2622 /** 2623 * @deprecated This function no longer does anything; it was an old 2624 * approach to managing preferred activities, which has been superceeded 2625 * (and conflicts with) the modern activity-based preferences. 2626 */ 2627 @Deprecated 2628 public abstract void removePackageFromPreferred(String packageName); 2629 2630 /** 2631 * Retrieve the list of all currently configured preferred packages. The 2632 * first package on the list is the most preferred, the last is the 2633 * least preferred. 2634 * 2635 * @param flags Additional option flags. Use any combination of 2636 * {@link #GET_ACTIVITIES}, 2637 * {@link #GET_GIDS}, 2638 * {@link #GET_CONFIGURATIONS}, 2639 * {@link #GET_INSTRUMENTATION}, 2640 * {@link #GET_PERMISSIONS}, 2641 * {@link #GET_PROVIDERS}, 2642 * {@link #GET_RECEIVERS}, 2643 * {@link #GET_SERVICES}, 2644 * {@link #GET_SIGNATURES}, to modify the data returned. 2645 * 2646 * @return Returns a list of PackageInfo objects describing each 2647 * preferred application, in order of preference. 2648 * 2649 * @see #GET_ACTIVITIES 2650 * @see #GET_GIDS 2651 * @see #GET_CONFIGURATIONS 2652 * @see #GET_INSTRUMENTATION 2653 * @see #GET_PERMISSIONS 2654 * @see #GET_PROVIDERS 2655 * @see #GET_RECEIVERS 2656 * @see #GET_SERVICES 2657 * @see #GET_SIGNATURES 2658 */ 2659 public abstract List<PackageInfo> getPreferredPackages(int flags); 2660 2661 /** 2662 * @deprecated This is a protected API that should not have been available 2663 * to third party applications. It is the platform's responsibility for 2664 * assigning preferred activities and this can not be directly modified. 2665 * 2666 * Add a new preferred activity mapping to the system. This will be used 2667 * to automatically select the given activity component when 2668 * {@link Context#startActivity(Intent) Context.startActivity()} finds 2669 * multiple matching activities and also matches the given filter. 2670 * 2671 * @param filter The set of intents under which this activity will be 2672 * made preferred. 2673 * @param match The IntentFilter match category that this preference 2674 * applies to. 2675 * @param set The set of activities that the user was picking from when 2676 * this preference was made. 2677 * @param activity The component name of the activity that is to be 2678 * preferred. 2679 */ 2680 @Deprecated 2681 public abstract void addPreferredActivity(IntentFilter filter, int match, 2682 ComponentName[] set, ComponentName activity); 2683 2684 /** 2685 * Same as {@link #addPreferredActivity(IntentFilter, int, 2686 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 2687 to. 2688 * @hide 2689 */ 2690 public void addPreferredActivity(IntentFilter filter, int match, 2691 ComponentName[] set, ComponentName activity, int userId) { 2692 throw new RuntimeException("Not implemented. Must override in a subclass."); 2693 } 2694 2695 /** 2696 * @deprecated This is a protected API that should not have been available 2697 * to third party applications. It is the platform's responsibility for 2698 * assigning preferred activities and this can not be directly modified. 2699 * 2700 * Replaces an existing preferred activity mapping to the system, and if that were not present 2701 * adds a new preferred activity. This will be used 2702 * to automatically select the given activity component when 2703 * {@link Context#startActivity(Intent) Context.startActivity()} finds 2704 * multiple matching activities and also matches the given filter. 2705 * 2706 * @param filter The set of intents under which this activity will be 2707 * made preferred. 2708 * @param match The IntentFilter match category that this preference 2709 * applies to. 2710 * @param set The set of activities that the user was picking from when 2711 * this preference was made. 2712 * @param activity The component name of the activity that is to be 2713 * preferred. 2714 * @hide 2715 */ 2716 @Deprecated 2717 public abstract void replacePreferredActivity(IntentFilter filter, int match, 2718 ComponentName[] set, ComponentName activity); 2719 2720 /** 2721 * Remove all preferred activity mappings, previously added with 2722 * {@link #addPreferredActivity}, from the 2723 * system whose activities are implemented in the given package name. 2724 * An application can only clear its own package(s). 2725 * 2726 * @param packageName The name of the package whose preferred activity 2727 * mappings are to be removed. 2728 */ 2729 public abstract void clearPackagePreferredActivities(String packageName); 2730 2731 /** 2732 * Retrieve all preferred activities, previously added with 2733 * {@link #addPreferredActivity}, that are 2734 * currently registered with the system. 2735 * 2736 * @param outFilters A list in which to place the filters of all of the 2737 * preferred activities, or null for none. 2738 * @param outActivities A list in which to place the component names of 2739 * all of the preferred activities, or null for none. 2740 * @param packageName An option package in which you would like to limit 2741 * the list. If null, all activities will be returned; if non-null, only 2742 * those activities in the given package are returned. 2743 * 2744 * @return Returns the total number of registered preferred activities 2745 * (the number of distinct IntentFilter records, not the number of unique 2746 * activity components) that were found. 2747 */ 2748 public abstract int getPreferredActivities(List<IntentFilter> outFilters, 2749 List<ComponentName> outActivities, String packageName); 2750 2751 /** 2752 * Set the enabled setting for a package component (activity, receiver, service, provider). 2753 * This setting will override any enabled state which may have been set by the component in its 2754 * manifest. 2755 * 2756 * @param componentName The component to enable 2757 * @param newState The new enabled state for the component. The legal values for this state 2758 * are: 2759 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2760 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2761 * and 2762 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2763 * The last one removes the setting, thereby restoring the component's state to 2764 * whatever was set in it's manifest (or enabled, by default). 2765 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2766 */ 2767 public abstract void setComponentEnabledSetting(ComponentName componentName, 2768 int newState, int flags); 2769 2770 2771 /** 2772 * Return the the enabled setting for a package component (activity, 2773 * receiver, service, provider). This returns the last value set by 2774 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 2775 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2776 * the value originally specified in the manifest has not been modified. 2777 * 2778 * @param componentName The component to retrieve. 2779 * @return Returns the current enabled state for the component. May 2780 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2781 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2782 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2783 * component's enabled state is based on the original information in 2784 * the manifest as found in {@link ComponentInfo}. 2785 */ 2786 public abstract int getComponentEnabledSetting(ComponentName componentName); 2787 2788 /** 2789 * Set the enabled setting for an application 2790 * This setting will override any enabled state which may have been set by the application in 2791 * its manifest. It also overrides the enabled state set in the manifest for any of the 2792 * application's components. It does not override any enabled state set by 2793 * {@link #setComponentEnabledSetting} for any of the application's components. 2794 * 2795 * @param packageName The package name of the application to enable 2796 * @param newState The new enabled state for the component. The legal values for this state 2797 * are: 2798 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2799 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 2800 * and 2801 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 2802 * The last one removes the setting, thereby restoring the applications's state to 2803 * whatever was set in its manifest (or enabled, by default). 2804 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 2805 */ 2806 public abstract void setApplicationEnabledSetting(String packageName, 2807 int newState, int flags); 2808 2809 /** 2810 * Return the the enabled setting for an application. This returns 2811 * the last value set by 2812 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 2813 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 2814 * the value originally specified in the manifest has not been modified. 2815 * 2816 * @param packageName The component to retrieve. 2817 * @return Returns the current enabled state for the component. May 2818 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 2819 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 2820 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 2821 * application's enabled state is based on the original information in 2822 * the manifest as found in {@link ComponentInfo}. 2823 * @throws IllegalArgumentException if the named package does not exist. 2824 */ 2825 public abstract int getApplicationEnabledSetting(String packageName); 2826 2827 /** 2828 * Return whether the device has been booted into safe mode. 2829 */ 2830 public abstract boolean isSafeMode(); 2831 2832 /** 2833 * Attempts to move package resources from internal to external media or vice versa. 2834 * Since this may take a little while, the result will 2835 * be posted back to the given observer. This call may fail if the calling context 2836 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 2837 * named package cannot be found, or if the named package is a "system package". 2838 * 2839 * @param packageName The name of the package to delete 2840 * @param observer An observer callback to get notified when the package move is 2841 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 2842 * called when that happens. observer may be null to indicate that no callback is desired. 2843 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 2844 * {@link #MOVE_EXTERNAL_MEDIA} 2845 * 2846 * @hide 2847 */ 2848 public abstract void movePackage( 2849 String packageName, IPackageMoveObserver observer, int flags); 2850 2851 /** 2852 * Returns the device identity that verifiers can use to associate their scheme to a particular 2853 * device. This should not be used by anything other than a package verifier. 2854 * 2855 * @return identity that uniquely identifies current device 2856 * @hide 2857 */ 2858 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 2859 2860 /** 2861 * Returns the data directory for a particular user and package, given the uid of the package. 2862 * @param uid uid of the package, including the userId and appId 2863 * @param packageName name of the package 2864 * @return the user-specific data directory for the package 2865 * @hide 2866 */ 2867 public static String getDataDirForUser(int userId, String packageName) { 2868 // TODO: This should be shared with Installer's knowledge of user directory 2869 return Environment.getDataDirectory().toString() + "/user/" + userId 2870 + "/" + packageName; 2871 } 2872} 2873