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