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