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