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